A 30-second Solidity primer (the language of Ethereum)
Solidity is the dominant smart-contract language on Ethereum and other EVM chains. The key concepts you need for the snippets:
- State variables: persistent storage on the contract (e.g.
mapping(address => uint) balances;). - Functions: callable, with visibility (
public/external/internal/private). - Modifiers: reusable preconditions (e.g.
onlyOwnerto restrict a function to the contract owner). - Events: logs that off-chain code can read.
- External calls: calling another contract's function (
to.call{...}) — a primary risk surface. - Immutability: once deployed, the bytecode (usually) can't change. Upgradable proxies exist but add their own risks.
The primer, in one contract