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?

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 + 1 .. Y] 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.
  • How do I calculate the address? I found this addr = new memory[offset:offset+length].value(value) I'm not really sure how to interpret this expression. Thanks Mikhail – NowsyMe Apr 17 at 13:58
  • 1
    Check this answer: ethereum.stackexchange.com/questions/760/… – Mikhail Vladimirov Apr 17 at 18:12
  • What is meant by 'nonce of contract as it was at block N - 1?' – NowsyMe Apr 18 at 16:42
  • This should be what web3.eth.getTransactionCount(B, N-1) returns. – Mikhail Vladimirov Apr 18 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.