A smart contract is a program that runs on a blockchain and executes automatically when its conditions are met. It holds its own data and often its own funds, and its rules are enforced by the network rather than by a company or intermediary. Once deployed, everyone can see the code and verify what it does. Smart contracts power tokens, NFTs, DeFi protocols, DAOs and much more.
How does a smart contract work?
- Code: on Ethereum and other EVM chains, smart contracts are usually written in Solidity and compiled to bytecode for the EVM; on Solana they are written in Rust.
- Deployment: the compiled contract is published to the blockchain in a transaction and gets its own address.
- Interaction: users and other contracts call its functions by sending transactions, paying gas for the computation.
- Deterministic execution: every node executes the same code with the same result, so the outcome cannot be manipulated by one party.
- State: the contract stores balances, ownership and settings on the blockchain.
Example: an escrow contract
A buyer deposits funds into an escrow contract. The contract releases the money to the seller only when the buyer confirms delivery, or returns it after a deadline if nothing happens. No escrow company is needed: the rules are in the code, and nobody, not even the developer, can take the funds outside those rules.
Limitations and risks
- Bugs are expensive: contracts often hold large amounts, and a vulnerability can be exploited within minutes. Testing, audits and battle-tested libraries such as OpenZeppelin are essential.
- Immutability: deployed code cannot be changed. Upgrades require a proxy pattern, which brings its own governance and security questions.
- No direct access to outside data: prices, weather or delivery status must come in via an oracle.
- Not automatically a legal contract: a smart contract is code; whether it is legally binding depends on the agreements around it.
See our smart contract development, auditing support and upgradeable contracts.
Frequently Asked Questions about Smart Contracts
Can a smart contract be changed?
The deployed code itself cannot. Contracts built with a proxy pattern can point to new code, but that power must be well secured, for example with a multisig and a timelock.
Which language are smart contracts written in?
Mostly Solidity for Ethereum and EVM chains, sometimes Vyper. Solana programs are written in Rust, often with the Anchor framework.
What does it cost to use a smart contract?
Every interaction costs gas, paid to the network. The amount depends on the complexity of the function and how busy the network is; on layer 2 networks it is usually much lower.
Why are smart contract audits important?
Because mistakes can't simply be patched and attackers actively look for them. An audit by independent specialists, combined with thorough tests, greatly reduces the risk of losing funds.