DEV Community

Shlok Kumar
Shlok Kumar

Posted on

Layout of a Solidity Source File - Part 2

Comments in Solidity

Solidity, like any other programming language, allows commenting code. Solidity supports three sorts of comments:

  • Single line comments
  • Multiline comments
  • Natural Ethereum Specs (Natspec)

Multiline comments are denoted by /* and /, whereas single-line comments are indicated by //. Natspec offers two formats: /// for single-line comments combination of /* for beginning and */ for the end of multiline comments. Natspec is a documentation tool with its own standard.

Let us examine the Solidity comments in the code below:

// This is a single-line comment in Solidity 

/* This is a multiline comment In Solidity. 
Use this when multiple consecutive lines Should be commented as a whole */
Enter fullscreen mode Exit fullscreen mode

Structure of a Smart Contract

Solidity contracts are like classes in modern Object-Oriented Programming languages. State variables, Functions, Function Modifiers, Events, Errors, Struct and Enum Types may all be declared in a contract. Contracts may also be inherited from other contracts.

Libraries and interfaces are two types of special contracts.

Solidity is used to construct smart contracts for Ethereum. EVMs use smart contracts to deploy and execute their code.

A contract contains multiple constructs:

  1. State variables
  2. Structures
  3. Modifiers
  4. Declaratives
  5. Enumerations
  6. Functions

A typical Smart Contract consists of all the preceding constructs.

For Part 1 - https://dev.to/shlok2740/layout-of-a-solidity-source-file-3l5h
For more content, follow me on - https://linktr.ee/shlokkumar2303

Top comments (0)