How to create a proposal to send native token, eg.ETH

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.

:1234: 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.

1 Like