0

I am trying to impersonate an account using forked mainnet what I did was unluck the unknown account, approve the erc-20 token and copy then send the transaction of that address. Everytime the address send a transaction I run the tx first on forked mainnet to estimate if there will be a revert will happen in advance. The issue was every transaction returns a revert error UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT then I check on the etherscan the same transaction is a success. I don't understand why this happen and how to resolve this issue?

Snippet of my code:

const localWeb3 = new Web3(
   new Web3.providers.WebsocketProvider('ws://localhost:8546') // forked mainnet
)
  
localWeb3.extend({
   methods: [{
       name: 'unlockAccount',
       call: 'evm_unlockUnknownAccount',
       params: 1
   }]
})

await localWeb3.unlockAccount(tx.from)

let abi = [ //long abi ]

const localContract = new localWeb3.eth.Contract(abi, tokenAddress)
let allowance = await localContract.methods.allowance(tx.from, UNISWAP_ROUTER_ADDRESS).call()
console.log("allowance: ", allowance)

    
localWeb3.eth.sendTransaction({
    from: tx.from,
    to: tx.to,
    gasPrice: tx.gasPrice,
    gasLimit: tx.gas,
    input: tx.input
})
.on('error', async (err) => {
    console.log(count, err)
})
.then(async (receipt) => { 
    console.log(receipt)                  
})

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.