0

If I have done a transaction with a smart contract manually with metamask, how can I repeat that progress with a script written in web3.js/ethers.js so I can automate it?

If I am not wrong, I need to get the transaction details from the log? Can I do this with etherscan/bscscan?

Take this bsc transactions as an example.

dezhi
  • 101
  • 1
  • To call a contract you only need the address and the contract abi. The parameters should be the same used in remix. – Ismael Aug 08 '21 at 03:35
  • I got the idea on how to call a contract. I can get the abi from etherscan/bscscan. The problem is how can I know which function to call and what parameters should I send? Take the example give above, do I just call swapExactETHForTokens with the parameters give in the input data field ? – dezhi Aug 08 '21 at 05:49
  • Or precisely, given a txhash, how can I get the transaction details and so I can repeat the transaction using a script? – dezhi Aug 08 '21 at 06:05
  • You have to decode the InputData field on the transaction. To do that take a look at this answer https://ethereum.stackexchange.com/a/82318. – Ismael Aug 11 '21 at 04:55

0 Answers0