What are Contracts?

Solidity’s code is encapsulated in contracts which means a contract in Solidity is a collection of code (its functions) and data (its state) that resides at a specific address on the Ethereum blockchain. A contract is a fundamental block of building an application on Ethereum.

POP vs OOP vs BOP
Sr.No.TitleShort LanguageDetails
1Procedure Oriented ProgrammingPOP C-LanguageFunctions and Procedure
2Object Oriented ProgrammingOOP CPP / Java / C# LanguagesClasses
State & Functions
3Block Oriented ProgrammingBOP Solidity LanguageContracts
State & Functions
Details
  1. Pragma:

    Pragmas are instructions to the compiler on how to treat the code. All solidity source code should start with a “version pragma” which is a declaration of the version of the solidity compiler this code should use. This helps the code from being incompatible with the future versions of the compiler which may bring changes.

  2. Contract:

    The contract keyword declares a contract under which the code is encapsulated.

  3. State variables:

    State variables are permanently stored in contract storage that is they are written in Ethereum Blockchain.

  4. A function:

    Functions are code blocks that perform specific tasks for different input parameters without repeating lines of code. The most common way to define a function in Solidity is by using the function keyword, followed by a unique function name, a list of parameters (that might be empty), and a statement block surrounded by curly braces.

Video : Solidity Contracts
Resource File
Question / Answer

Pragma is generally the first line of code within any Solidity file. pragma is a directive that specifies the compiler version to be used for current Solidity file.

SPDX is an open standard for communicating software bill of material information, including provenance, license, security, and other related information. SPDX reduces redundant work by providing common formats for organizations and communities to share important data, thereby streamlining and improving compliance, security, and dependability. The SPDX specification is recognized as the international open standard for security, license compliance, and other software supply chain artifacts as ISO/IEC 5962:2021.

Bibliography/References