I have a function in my Ethereum smart contract with the following interface
// submitting a review requires a payment
function addReview(string review) public payable
Using web3 v1 invoking this function would be something like this
contract.methods.addReview(review).send({
from: accounts[0],
value: SOME_AMOUNT_IN_ETH
})
How can I invoke this function with a different ERC20 token rather than using Ether?
If your payable function is foo
and takes 1 parameter and you want to send x
amount of ether and contract
is the contract you want to refer to, you would invoke it like that:
contract.foo.value(x).(param1)(msg.sender);
I hope it is clear.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.