There's no JSON-RPC for this, so I guess we should make a binary search using getCode. It would work like this:
Get the current block number
Start a binary search getting the code of the contract between 1 and the current block number
If there's no code in 1 but there is in block number, look at blockNumber/2, repeat.
Once the block number of the deploy is obtained, get all the transactions of that block, get the recipt, check the contractAddress and see if it matches the given address.
Use the tx to also obtain the address that deployed it
Notice that this will only work in ganache and in archive nodes.
There's no JSON-RPC for this, so I guess we should make a binary search using
getCode
. It would work like this:blockNumber/2
, repeat.contractAddress
and see if it matches the given address.Notice that this will only work in ganache and in archive nodes.