Hello guys, I’m trying to call a function from a deployed contract where I use
Call.value
, this is the sdk syntax I’m using:
const result = await contract.methods.new_contract(
…
);
console.log(result);
But how can I add a value to the function invocation?
Thanks in advance
@philipp.chain any thoughts? :s
Hey @arthas168,
I think you should add optional object to your call with the value(amount)
something like
const result = await contract.methods.new_contract( {}, {
amount: 10
}
);
1 Like
Something like this?
const result = await contract.methods.new_contract(
“5939679548”,
“1773653015196”,
“000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f”,
“ak_2mwRmUeYmfuW93ti9HMSUJzCk1EYcQEfikVSzgo6k2VghsWhgU”,
“TRX”,
“0x9cc7a534cf742cdb9ee16fbf6b5f48a09e485c52”,
{ options: 100000000 }
);
It doesn’t work though How can I pass in the function parameters in an array or maybe an object before the value object?
The params should not be passed as array, but change options to amount and it should work
2 Likes
Should also work as
const result = await contract.methods.new_contract(
“5939679548”,
“1773653015196”,
“000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f”,
“ak_2mwRmUeYmfuW93ti9HMSUJzCk1EYcQEfikVSzgo6k2VghsWhgU”,
“TRX”,
“0x9cc7a534cf742cdb9ee16fbf6b5f48a09e485c52”,
{ amount: 1000000 }
);
1 Like