Where do I verify whether a contract has been created with CREATE or CREATE2, would I have to disassemble the contract and look for a CREATE2 opcode in the contract creation code?
Asked
Active
Viewed 927 times
0
NowsyMe
- 1,365
- 1
- 19
- 37
1 Answers
1
At first, most of the contracts a created via transactions from externally owned addresses, i.e. backed by private key, and thus there are neither CREATE nor CREATE2 opcodes involved.
For those contracts, that were created by another contracts, the easiest way to check would be the following:
- Lets assume you need to check contract
Acreated by contractBat blockN - Obtain nonce of contract
Bas it was at blockN - 1, lets call it X. - Obtain nonce of contract
Bas it was at blockN, lets call it Y. - For every nonce in range
[X .. Y - 1]calculate address of the contract that would be deployed with this nonce byBviaCREATEopcode. - If some of the addresses calculated at step 4 is equal to address of
A, thenAwas deployed viaCREATE, otherwise viaCREATE2.
Mikhail Vladimirov
- 7,313
- 1
- 23
- 38
web3.eth.getTransactionCount(B, N-1)returns. – Mikhail Vladimirov Apr 18 '19 at 17:35