0

In a situation where there are multiple contracts stored in different blocks, is there any method to retrieve the status of a contract through its owner's address? (e.g. in my situation, each person registered in the blockchain will only have one contract.This contract will be registered with the public key of this person, i.e. the contract owner will be a public key that corresponds to a person.If I know this public key , can I retrieve the status of this contract?)

1

One easy solution is to manage contract address with a registry contract. When a contract is created it will call the registry contract and store the association with the sender.

contractRegistry.registerNew(msg.sender, address(this));

And ContractRegistry will have a mapping (address => address) contracts. That allows to determine the contract given its owner.


Another interesting alternative is to use the new opcode CREATE2 that allows the creation of contract with addresses generated deterministically.

  • Do you have a link with a better explanation of opcode CREATE2? – Mutante Apr 15 at 0:47
  • 1
    Check this post reddit.com/r/ethdev/comments/ahdf02/why_im_excited_for_create2 it has more links. – Ismael Apr 15 at 5:47
  • Thanks! I'll try to use the CREATE2 method like this: I'll generate the opcode of the contract and store it on a database. When I need to check the contract status I'll retrieve the opcode from the database and use it. Is it valid? – Mutante Apr 15 at 17:53

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.