繁体   English   中英

Web3 如何调用(using.send())智能合约 function 并发送 ERC20 代币而不是 eth?

[英]Web3 how to call (using .send()) a smart contract function and send ERC20 token instead of eth?

我正在尝试从 web3 using.send() 和 send() 调用智能合约 function 我想发送 ERC20 令牌而不是以太币(通过值参数)

试过这个但它不起作用:

await dao.methods.voteForProposal(0).send({
from: accounts[0],
value: contract.methods.transfer("addr", 1).encodeABI(),
});

这是我试图调用的智能合约中的 function:

function voteForProposal(int _proposalId) public payable isMember currentlyRaising returns (bool) {
    voteBank[msg.sender] += msg.value;
    voters.push(msg.sender);
    proposalVotes[_proposalId] += msg.value;
    return true;
  }

链接到解决方案

TL,博士; 在接收到发送(甚至可以使用调用)function 调用时,从智能合约 function 中转移 ERC20 代币。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM