Contract composition
Solidity supports contract composition. Composition refers to combining multiple contracts to create complex data structures and contracts. We have already seen numerous examples of contract composition before. Refer to the code snippet for creating contracts using the new
keyword shown in the Using the new keyword section. In this example, the Client
contract is composed of the HelloWorld
contract. Here, HelloWorld
is an independent contract and Client
is a dependent contract. It is dependent on the HelloWorld
contract for its completeness. It is a good practice to break down problems into multicontract solutions and compose them together using contract composition.