0
I am trying to add an test for swapping ETH to Token. However, this works only if I am specifying as Receiver the Owner of the contract. As soon as I am changing the “to” parameter to another address than the contract owner I am receiving an “revert UniswapV2: TRANSFER_FAILED”.
Working code:
await uniswapRouter.swapExactETHForTokensSupportingFeeOnTransferTokens
.sendTransaction(new BN("1000000000000000000"),
[WETH_ADDRESS, contract.address],
expectedOwner,
uniswapBuyExpires,
{ value: web3.utils.toWei(new BN(1), 'ether'), from: expectedOwner});
Not working (throwing an TRANSFER_FAILED):
await uniswapRouter.swapExactETHForTokensSupportingFeeOnTransferTokens
.sendTransaction(new BN("1000000000000000000"),
[WETH_ADDRESS, contract.address],
accounts[5],
uniswapBuyExpires,
{ value: web3.utils.toWei(new BN(1), 'ether'), from: expectedOwner});
as well as (changing “from”)
await uniswapRouter.swapExactETHForTokensSupportingFeeOnTransferTokens
.sendTransaction(new BN("1000000000000000000"),
[WETH_ADDRESS, contract.address],
accounts[5],
uniswapBuyExpires,
{ value: web3.utils.toWei(new BN(1), 'ether'), from: accounts[5]});
Even increasing the allowance of the accounts[5] address won’t solve the error message. I would appreciate any ideas!
Best regards,