- 19 April, 2017
- Posted by: toshendra
- Category: Blockchain, Development, Ethereum, Solidity
In this post, we will understand the default standard structure of the Solidity-Based Smart Contract file which generally has the .sol extension.
Notice: This is one of the multi-post series of Learn Solidity - Build Decentralized Application in Ethereum. This is an attempt to teach you all about Solidity - A Programming Language for Ethereum Based Smart Contracts. If you want to take this as a video course please signup using below button.
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 |