Solidity source file structure is little bit different from other programming languages. Every source file should start with a comment indicating its license. You can define the License by declaring // SPDX-License-Identifier: MIT
In the below contract our license type is MIT but you can define any license type that is suitable according to your requirement. if your code is not open source you can declare that by using the word UNLICENSED.
Trust in smart contract can be better established if their source code is available. Since making source code available always touches on legal problems with regards to copyright, the Solidity compiler encourages the use of machine-readable SPDX license identifiers.
Pragmas
The pragma keyword is used to enable certain compiler features or checks. A pragma directive is always local to a source file, If you import another file, the pragma from that file does not automatically apply to the importing file.
Version Pragma
pragma solidity ^0.8.3;
You can also define the compiler version range with the below statement.
You can also define the compiler version range with the below statement.
0.9.0
, you can be sure that your code compiles the way you intended.Contracts in Solidity are similar to classes in object-oriented languages. You declare a contract by using the keyword contract followed by the contract Name. Inside the contract, you code your smart contract logic.