when we deploy two contracts in go ethereum and one is inherited by the other ,when we deploy contracts differently how other contracts gets to know where the other contract is and it is able to access the functions of the parent contract ?

  • i was working with the inheritance and i was able to try multiple,multi level inheritance by calling function from parent contracts from child.I am confused how one contract is getting to know where the other contract is in geth ,as m deploying them separately. – Gagan Jun 16 '16 at 10:54
  • i used online compiler for the purpose and copied the compiled code from left panel from web deploy box and deployed.I want to know how internally it is getting to know about the parent and child contracts. – Gagan Jun 16 '16 at 10:57

Once published on the chain, child and parent contract are merged into the child contract. So when you access parent functions on a child contract, you actually access a function that is in the child contract. Inheritance is only existing to make development easier and code more readable, but once you are on the chain everything is concatenated in one.

| improve this answer | |
  • thanks man merging is done at compile time only ? – Gagan Jun 16 '16 at 11:55
  • I don't really know in detail how solc does that but yes, it's compile time as the transaction have to carry the full code of the contracts and no further code manipulation is done once the creation transaction is sent to the chain. – Nicolas Massart Jun 16 '16 at 12:37

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.