1

I'm trying to detect the creation of new ERC20 tokens. My current idea is to scan all transactions in a block, and look for transactions where the "to" address is null. This is normally contract creation transactions.

The problem that I'm having currently is how to get the newly created contract address from the contract creation transaction details? If I can get the newly created contract address, I can then check if the contract adheres to ERC20 standard and then parse it as ERC20 contract.

I normally get transaction details using the following code:

let tx = await web3.eth.getTransaction('0x46af5890c8ab51af8eeba255ad920f74e258218bdfd28951b6795fb0afa61ee6');

1 Answer 1

1

To get the address of the created contract, I use the RPC API function eth_getTransactionReceipt - it has an analogue on the web3.

2
  • My goodness cannot believe it is that simple. You won't believe what I've been doing to get that
    – ceds
    Commented Jan 17, 2021 at 12:07
  • "If all else fails, you should finally read the instructions" (Axiom of Kahn and Orben) :-)
    – Mad Jackal
    Commented Jan 17, 2021 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.