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.
Code snippets to help
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]})
and also tried
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.
Hi,
The governor proposal receives the list of targets
, the list of values
, and the list of calldatas
, as their first 3 parameters. And when the proposal is successful this is the execution of said proposal:
(bool success, bytes memory returndata) = targets[i].call{value: values[i]}(calldatas[i]);
As you can see if you want to send value (eth), you must include that amount in the values
array, and currently you are passing [0] as the values array, meaning that it wont transfer any eth when the proposal executes. Your first attempt had a number, but you send no calldatas
, and for the proposal to go well the call datas length must be the same as the targets
length.
2 Likes
Hey,
I have been testing my Governor with timelock and ERC20 token to transfer native coins but facing issues while executing.
I want to transfer funds from account 0 to account 3
web3.eth.sendTransaction({from:accounts[0],to:accounts[3],value:10000000})
and im passing proposal as-
await instance.propose([accounts[0]], [10000000], [0x00], "Transfer funds", { from: accounts[2] });
Error:
VM Exception while processing transaction: revert -- Reason given: TimelockController: underlying transaction reverted.
error at line-
await instance.execute([accounts[0]], [10000000], [0x00], descriptionHash, { from: accounts[2] });
Technologies used- Truffle, Ganache.