Replies: 1 comment 1 reply
-
This is a useful special-purpose utility function you may wish to include in your project, if you know the transaction hash the contract was deployed in (for example if you emit an event), but this is seldom the case. :s There isn’t any good way to discover when a contract was deployed on chain using any standard Ethereum methods; services like Etherscan may index this, but those are special cases. The only reason ContractFactory knows is because it submitted the transaction. Otherwise there isn’t a good way to know. Does that make sense? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi guys!
I'm creating Contract instance via
new ethers.Contract(address, abi, signer)
,How can I get exact block & tx hash in which this contract was deployed?
In case of using
ContractFactory
it can be done withcontractInstance.deployTransaction.blockNumber
Is this a good idea to add option parameter to
ethers.Contract
like{ deployTxHash: string }
?Use case: Let we need to gather all events which related to some smart contract. It will be more quickly to traverse blocks SINCE block in which smart contract was deployed, avoiding full chain search like
[0; latestBlock]
What are your thoughts on this?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions