1. Introduction, Environment Setup (Remix)
Solidity is a statically typed language used for writing smart contracts on EVM (Ethereum Virtual Machine) based blockchains like Ethereum.
1.1. Basic Solidity Structure
Every Solidity file begins by specifying the compiler version. The Contract, similar to a class, is the fundamental unit of a smart contract.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract SimpleStorage {
uint256 public data;
function set(uint256 x) public {
data = x;
}
}
1.2. Setting up the Remix IDE
For the initial development phase, the browser-based IDE Remix (remix.ethereum.org) is the most convenient. It handles file creation, compilation, deployment, and testing in one place.
- File Creation: Create a new file in Remix and save it with the
.solextension. - Compilation: Select the Solidity Compiler icon on the left panel, choose the appropriate version (e.g., 0.8.x), and compile.
- Deployment: Select the Deploy & Run Transactions icon and choose 'Injected Provider' or 'Remix VM' to deploy your contract to a blockchain environment.