2

https://etherscan.io/address/0xabc1c404424bdf24c19a5cc5ef8f47781d18eb3e#code

Notice that this contract has:

  • contract SafeMath
  • contract BasicAccessControl
  • contract EtheremonEnum
  • contract EtheremonDataBase
  • contract EtheremonData

All under one contract address. How would one deploy all of these to one contract address?

2 Answers 2

2

Only one is actually deployed (EthermonData, in this case). It inherits from the other contracts.

EthermonDataBase inherits from some:

contract EtheremonDataBase is EtheremonEnum, BasicAccessControl, SafeMath

and then EthermonData inherits from that:

contract EtheremonData is EtheremonDataBase {

So the final contract that's deployed makes use of all of that code, but there's only one "contract" running.

See http://solidity.readthedocs.io/en/develop/contracts.html#inheritance in the Solidity documentation.

7
  • 1
    I understand inheritance. But when deploying on remix.ethereum.org it makes you choose a specific contract: i.imgur.com/MAXsbG9.png Commented Feb 28, 2018 at 23:19
  • Yes. In this case, the specific contract that was chosen was EthermonData.
    – user19510
    Commented Feb 28, 2018 at 23:19
  • So although EthermonData was the one deployed.. technically all were deployed with it? Commented Feb 28, 2018 at 23:22
  • No, I wouldn't say that. Only EthermonData was deployed. Its code consists of code from a number of inherited contracts. (The source code could even include other contracts that it doesn't inherit from. The presence of those lines of code says nothing about what was deployed.)
    – user19510
    Commented Feb 28, 2018 at 23:23
  • 1
    No, it wouldn't. When the compiler compiles EthermonData, it includes all the necessary code that was inherited. I don't know your programming background, but if you've used object-oriented programming languages before, it works just the same way.
    – user19510
    Commented Feb 28, 2018 at 23:28
0

The compiler generates EVM bytecode from the contracts. Contracts are just a higher-level concept just like classes in object oriented languages. EVM is not contract-aware.

Maybe you are confusing it with libraries, which are deployed and then called by relying contracts (using delegatecall) http://solidity.readthedocs.io/en/develop/contracts.html#libraries

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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