0

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?

NowsyMe
  • 1,365
  • 1
  • 19
  • 37

1 Answers1

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:

  1. Lets assume you need to check contract A created by contract B at block N
  2. Obtain nonce of contract B as it was at block N - 1, lets call it X.
  3. Obtain nonce of contract B as it was at block N, lets call it Y.
  4. For every nonce in range [X .. Y - 1] calculate address of the contract that would be deployed with this nonce by B via CREATE opcode.
  5. If some of the addresses calculated at step 4 is equal to address of A, then A was deployed via CREATE, otherwise via CREATE2.
Mikhail Vladimirov
  • 7,313
  • 1
  • 23
  • 38