Loading...
Your first smart contract language
Solidity is the most popular programming language for writing smart contracts on EVM chains.
Basic structure of a Solidity contract:
• pragma — Specifies the compiler version (e.g., pragma solidity ^0.8.20)
• contract — Like a class in other languages; contains state variables and functions
• State variables — Stored permanently on the blockchain
• Functions — Executable code that reads or modifies state
Data types:
• uint256 — Unsigned integer (most common for token amounts)
• address — 20-byte Ethereum address
• bool — True or false
• string — Text data
• mapping — Key-value store (like a hash map)
Function visibility:
• public — Callable by anyone
• private — Only within the contract
• internal — Within the contract and derived contracts
• external — Only from outside the contract
view functions read state without modifying it and cost no gas when called externally. pure functions don’t even read state.