Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command to get block and/or transaction that deployed a contract #129

Open
fvictorio opened this issue Mar 19, 2020 · 0 comments
Open

Comments

@fvictorio
Copy link
Contributor

fvictorio commented Mar 19, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant