如何创建发送原生代币的提案,例如.ETH

问题描述 投票:0回答:1

我正在使用 timelock 和 ERC20 令牌测试我的 Governor,在 js 中使用 truffle 和 ganache。

我成功完成了从 ERC20 代币拨款的提案周期,并且正在尝试创建一个提案,让州长可以将本地代币 (ETH) 发送给拨款接受者。

FOR ERC20 Token(成功):

calldata = erc.contract.methods.transfer(accounts[5], 2).encodeABI();
bountyProposal = await governor.propose([erc.address], [0], [calldata], "Grant 2 Token to team account5 for his latest bug bounty. ", {from: accounts[2]});

原生代币(我试过)

nativeProposal = await governor.propose([recepientAccountAddr],[3],[],"Grant 3 ETH for marketing to Bob",{from:accounts[4]})
txnCalldata = web3.eth.sendTransaction({from: timelock.address, to: accounts[6], value:3}).encodeABI();
propose_res = await governor.propose([timelock.address],[0],[txnCalldata],"Grant 3 ETH for marketing to Bob",{from:accounts[4]})

我偶尔会找到在提案执行后调用其他合约的解决方案,但没有找到任何关于“如何使用 Governor Proposal 编码本机令牌传输”的资源。

smartcontracts web3js ethers.js openzeppelin
1个回答
0
投票

approve()
/
transferFrom()
函数(由 Governor 合约使用)在 ERC-20 合约中实现。

但是原生代币没有任何合约,所以它们不实现任何这些功能。

一般情况下,当应用程序想要使用原生令牌的批准时,他们会使用包装令牌来代替。例如,当你想在 Uniswap 上用 ETH 交易 XYZ 时,他们会在后台使用 WETH (ERC-20),然后将其转换为 ETH(本机)。

解决方案:使用 wrapped token 而不是 native。包装代币合约通常使您能够以 1:1 的比例交换原生代币和包装代币,无需任何额外费用。

© www.soinside.com 2019 - 2024. All rights reserved.