AnatomyOf

Anatomy of a Solidity file

example.sol
1contract Piggybank {
2 address public owner; // "private" storage everyone can still read
3
4 constructor() {
5 owner = msg.sender;
6 }
7
8 modifier onlyOwner() {
9 require(msg.sender == owner, "not the owner, nice try");
10 _;
11 }
12
13 function withdraw() external onlyOwner {
14 payable(owner).transfer(address(this).balance);
15 }
16}
Solidity is a statically-typed programming language designed for developing smart contracts that run on the Ethereum Virtual Machine (EVM).