Reputation: 11
I am testing my Governor with timelock and ERC20 token, using truffle and ganache in js.
I successfully completed the proposal cycle to grant funds from ERC20 token, and am trying to create a proposal where Governor can send native tokens (ETH) to a grant recepient.
FOR ERC20 Token(successful):
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]});
For native token(I have tried)
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]})
I have occasionally found the solution for other contracts to invoke after the proposal is executed, but didn't find any resource on "How to encode native token transfer" using Governor Proposal.
Upvotes: 0
Views: 383
Reputation: 43481
approve()
/ transferFrom()
functions (used by the Governor contract) are implemented in ERC-20 contracts.
But native tokens do not have any contracts so they don't implement any of these functions.
Generally, when applications want to use approvals of native tokens, they use wrapped tokens instead. For example when you want to trade XYZ fo ETH on Uniswap, they use WETH (ERC-20) in the background, which is then converted to ETH (native).
Solution: Use wrapped tokens instead of native. Wrapped token contracts usually enable you to exchange native to wrapped and back 1:1, without any additional fees.
Upvotes: 0