November 2018
Intermediate to advanced
528 pages
13h 21m
English
The second option is to deploy a new instance of a given contract. To achieve that, Solidity provides the new keyword, which can be used as follows:
contract ContractA { uint256 x; function ContractA (uint256 y) payable { x = y; }}contract ContractB { ContractA CAinstance = new ContractA(10);}As you can see, we can pass arguments when we create a contract, since the created contract has a constructor that accepts arguments. The new ContractA(arg) line will execute the created contract's constructor and return its address. Note that an instance of each smart contract is implicitly convertible to its address, and in Solidity we are not dealing with real objects as in OOP to represent contracts as we do for classes.
Moreover, ...
Read now
Unlock full access