-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Solidity Programming Essentials
By :
There are the following two ways of creating and using a contract in Solidity:
new keywordThe new keyword in Solidity deploys and creates a new contract instance. It initializes the contract instance by deploying the contract, initializing the state variables, running its constructor, setting the nonce value to one, and, eventually, returns the address of the instance to the caller. Deploying a contract involves checking whether the requestor has provided enough gas to complete deployment, generating a new account/address for contract deployment using the requestor's address and nonce value, and passing on any Ether sent along with it.
In the next screenshot, two contracts, HelloWorld and client, are defined. In this scenario, one contract (client) deploys and creates a new instance of another contract (HelloWorld). It does so using the new keyword as shown in the following code snippet:
HelloWorld...