I am trying to execute deposit
and withdraw
function from yDAI (yearn.finance)
within the same transaction using web3 encodeFunctionCall. deposit
function works, but, withdraw
function fails. However, if I execute the withdraw
function alone separately, then it works.
let abi1 = web3.eth.abi.encodeFunctionCall( { "name": "deposit", "type": "function", "inputs": [ { "name": "_amount", "type": "uint256" } ] }, [web3.utils.toWei((1000).toString(), 'Ether')] );
let abi2 = web3.eth.abi.encodeFunctionCall( {"constant":false,"inputs":[],"name":"withdrawAll","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}, [] );
I am encoding the above in a js file and then calling a function present in my smart contract using an array. Code present in smart contract:
for (uint i = 0; i < _addrs.length; i++)
address(_addrs[i]).call(_bytecode[i]);
There are no error messages.
Here is the code and abi for yDAI (yearn.finance)
.
https://etherscan.io/address/0xACd43E627e64355f1861cEC6d3a6688B31a6F952#code
Can anyone help me to solve this puzzle?