Skip to content

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

@fvictorio

Description

@fvictorio

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions