Statute of Limitations Reference
Free web tool: Statute of Limitations Reference
bool
Boolean type, true or false.
bool public myBool = true;uint / int
Unsigned and signed integers. uint is alias for uint256 (8 to 256 bits in steps of 8).
uint256 public count = 0;
int256 public balance = -1;address
Holds a 20-byte Ethereum address. payable variant can receive Ether.
address public owner = msg.sender;
address payable recipient;bytes / string
Fixed-size byte arrays (bytes1..bytes32) and dynamic string type.
bytes32 public data;
string public name = "hello";enum
User-defined type with a finite set of constant values.
enum Status { Active, Paused, Stopped }
Status public status = Status.Active;array
Dynamic and fixed-size arrays. Supports push, pop, length.
uint[] public dynamicArr;
uint[5] public fixedArr;mapping
Hash table mapping keys to values. Cannot be iterated.
mapping(address => uint) public balances;struct
Custom composite type grouping variables together.
struct User {
address addr;
uint balance;
}function
Basic function declaration with visibility, mutability, and return type.
function foo(uint x) public pure returns (uint) {
return x * 2;
}view / pure
view reads state but does not modify. pure neither reads nor modifies state.
function getVal() public view returns (uint) { ... }
function calc(uint a) public pure returns (uint) { ... }payable
Functions that can receive Ether. Access amount via msg.value.
function deposit() public payable {
// msg.value available
}receive / fallback
receive is called on plain Ether transfers. fallback handles unknown function calls.
receive() external payable { }
fallback() external payable { }constructor
Runs once on contract deployment. Cannot be called afterward.
constructor(uint _val) {
owner = msg.sender;
}modifier
Reusable precondition checks. _; marks where function body runs.
modifier onlyOwner() {
require(msg.sender == owner, "Not owner");
_;
}
function foo() public onlyOwner { ... }Visibility
public: accessible everywhere. private: current contract only. internal: current + derived. external: only from outside.
public / private / internal / externalevent
Logs stored on blockchain. indexed params are searchable. Up to 3 indexed.
event Transfer(address indexed from, address indexed to, uint amount);
emit Transfer(msg.sender, to, amount);error / require / revert
Custom errors (0.8.4+). require for inline checks. revert for explicit abort.
error InsufficientBalance(uint available, uint required);
require(bal >= amt, "Low balance");
revert InsufficientBalance(bal, amt);inheritance
Single and multiple inheritance. Use virtual/override for polymorphism.
contract Child is Parent {
function foo() public override { ... }
}interface
Abstract contract with no implementation. All functions external.
interface IERC20 {
function totalSupply() external view returns (uint);
}abstract
Contract with at least one unimplemented function.
abstract contract Base {
function foo() public virtual;
}library
Stateless reusable code. Cannot hold state or receive Ether.
library SafeMath {
function add(uint a, uint b) internal pure returns (uint) { ... }
}
using SafeMath for uint;msg
Properties of the current message call.
msg.sender // caller address
msg.value // Ether sent (wei)
msg.data // calldata bytesblock
Properties of the current block.
block.timestamp // current block time
block.number // current block number
block.chainid // chain IDtx
Transaction-level properties. Avoid tx.origin for auth.
tx.origin // original sender
tx.gaspriceAbout Statute of Limitations Reference
The Solidity Reference is a searchable cheat sheet covering the core syntax and patterns of the Solidity smart contract programming language, which is used to build decentralized applications on the Ethereum blockchain and compatible EVM networks. The reference is organized into six categories: Data Types (bool, uint/int, address, bytes/string, enum, array, mapping, struct), Functions (function declarations, view/pure, payable, receive/fallback, constructor), Modifiers (modifier keyword, visibility: public/private/internal/external), Events and Errors (event, custom errors, require, revert), Inheritance and Interfaces (inheritance, interface, abstract contract, library), and Global Variables (msg, block, tx).
This reference is primarily used by blockchain developers who are writing or auditing Solidity contracts for DeFi protocols, NFT collections, DAOs, and other Web3 applications. Developers new to Solidity use it to quickly look up syntax for common patterns — for example, how to write a payable function, how to use modifiers for access control, how to emit events with indexed parameters, or how to implement the ERC-20 interface. Senior developers and auditors also use it to verify correct usage of security-sensitive patterns like tx.origin vs msg.sender.
Technically, the reference uses a full-text search over all entries — matching against item name, description text, and the actual Solidity code syntax. This means you can search for a code keyword like "payable" or "indexed" and find all relevant entries immediately. Categories are collapsible accordion sections that expand by default. Each entry shows the item name, a plain-language description, and a syntax-highlighted code block using the CodeBlock component with JavaScript highlighting. All content is static and renders entirely in the browser with no server-side processing.
Key Features
- Covers 6 major Solidity topic categories with 25+ individual reference entries
- Full-text search across item names, descriptions, and code syntax examples
- Collapsible category sections — all expanded by default for easy scanning
- Syntax-highlighted code blocks for every entry using CodeBlock component
- Covers Solidity 0.8.x patterns including custom errors (error/revert from 0.8.4)
- Security-relevant patterns documented: msg.sender vs tx.origin, payable addresses
- Includes library pattern with using-for syntax and universal gate concepts
- Dark mode support and responsive layout suitable for coding sessions on any device
Frequently Asked Questions
What version of Solidity does this reference cover?
The reference primarily covers Solidity 0.8.x syntax and patterns, including features introduced in recent versions such as custom errors with the error keyword (available from 0.8.4). Legacy patterns that have been replaced are not included.
What is the difference between view and pure functions?
A view function reads state variables from the blockchain but does not modify them — for example, returning a user's balance. A pure function neither reads nor modifies state — it only operates on its input arguments, like a calculation or utility function. Neither view nor pure functions cost gas when called externally (off-chain).
What is the difference between receive() and fallback()?
receive() is called when a contract receives plain Ether transfers (with no calldata). fallback() is called when no other function matches the call, and can also handle plain Ether if marked payable. If a contract needs to receive Ether, at minimum a payable receive() function is required.
Why should I avoid using tx.origin for authentication?
tx.origin refers to the original externally-owned account that initiated the entire transaction chain. If a malicious contract tricks your contract into calling it, tx.origin will still be the innocent user, bypassing your auth check. Always use msg.sender for authentication, which refers only to the direct caller.
What is the difference between internal and private visibility?
Both private and internal restrict access to outside contracts. private means the function or variable can only be accessed within the contract that defines it — not even derived (inherited) contracts can call it. internal means it can be accessed both in the defining contract and in contracts that inherit from it.
What are custom errors and why use them instead of require strings?
Custom errors (introduced in Solidity 0.8.4) allow you to define typed errors with parameters using the error keyword and revert with them. They are more gas-efficient than require with string messages because the error signature is only 4 bytes, while strings are stored in full. They also allow passing structured data with the error context.
What is the difference between a mapping and an array in Solidity?
A mapping is a hash table that maps keys to values (e.g., address to uint). Mappings cannot be iterated over and all values default to zero. An array is an ordered list that can be dynamic (push/pop) or fixed-size. Arrays can be iterated but dynamic arrays cost more gas as they grow. Choose mappings for O(1) lookups and arrays when you need iteration.
What is a Solidity library and when should I use one?
A library is a stateless reusable code contract that cannot hold state or receive Ether. Libraries are used to share utility functions (like math operations or type conversions) across multiple contracts. When used with the using...for syntax, library functions can be called as methods on the target type (e.g., myUint.add(other) if using SafeMath for uint).