In this post, we will understand the default standard structure of the Solidity-Based Smart Contract file which generally has the .sol extension.Please check out the amazing & professional courses on Blockchain, Ethereum, Hyperledger etc. on Tosh Academy.
As you can see in the above code, It always starts with version pragma followed by optional import section through which you can import any existing.sol files into the current .sol file. Then we begin the smart contract, write the inline comments for the auto-generation of the documentation for developers & define the state variables, events, & modifiers without any particular order.
We then write the constructor of the contract which gets called at the time of the creation of the contract. All the parameters of the constructor must be passed during the creation of the contract.
Then we continue writing the functions and at last (which is optional) we define the default function which will be called if the called function is not defined in the contract.
Let’s move the to the next post and understand the General Value Types in Solidity.
|Previous: Basics of Solidity By Example?||Next: General Data Types in Solidity|