2

My question is related to my previous question:

Solidity: How can a contract B, burn from contract A, generate another contract?


As we can in the aforementioned post when we are deploying contract A, we're including all contracts A, B, and C in a transaction sent to the blockchain. So the contract account will contain all the contracts codes (even though contract B and C are not born yet).

Question: Is it right to say a contract account may contain more than one contract?

1

Each contract will be deployed at a different address, even if ContractA references or holds a state variable of type ContractB.

So, no, your assertion is not true. When you deploy a contract, it will be assigned an address (what you are calling account). Even if that contract, internally, deploys N contracts, each those contracts will be deployed to a different address

  • thanks for the answer. I have no question about your answer, but it's still not clear to me where codes/references for contract B and C are stored when the contract A is deployed. Is it the case that codes of contract B and C are stored in contract A's account when contract A is deployed? – Ay. Oct 18 '17 at 11:21
1

Question: Is it right to say a contract account may contain more than one contract?

NO. It's only the contract A is deployed in that address and you won't be able to call contract B or C using the address of A directly.(Of course you can do it via function of A )

So the contract account will contain all the contracts codes (even though contract B and C are not born yet)

AFAIK, that code will be there for the reasons to be used when deploying B and that piece of code will define the interface of B to A (like ABI defines the interface to interact with a contract ).

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.