Smart Contract

A smart contract is a program stored on a blockchain that automatically carries out predefined conditions, such as sending coins, issuing tokens or accepting collateral. Once deployed, it usually cannot be changed or stopped unless the code was written to allow that.

How it works

Cryptographer Nick Szabo described the idea of smart contracts back in the 1990s, but it went mainstream with the launch of Ethereum in 2015. A developer writes code, for example in the Solidity language, and publishes it to the network, where the contract gets its own address, just like a wallet. Anyone can send the contract a transaction and call one of its functions. Network nodes all run the code the same way and reach the same result, so no single party can swap in a different outcome. Every action carries a fee, which on Ethereum is called gas.

Where they are used

Almost everything in crypto beyond simple transfers runs on smart contracts. That includes tokens and stablecoins, decentralised exchanges where swaps happen without an intermediary, lending protocols where code controls collateral and loans, NFTs and games, DAO votes and bridges between networks. Smart contracts are supported by Ethereum and compatible networks, as well as Solana, TON, Tron and many other blockchains. On the Bitcoin network, programming capabilities are deliberately kept modest.

Risks

Code is written by people, and mistakes are costly. In 2016 an attacker exploited a flaw in The DAO contract and drained a large amount of ether, and the community carried out a hard fork of Ethereum to return the funds. Since then, protocols and bridges have been hacked many times. An audit lowers the risk but does not remove it. Besides bugs, there are deliberate loopholes: functions that let the contract owner change the rules, withdraw funds or freeze transfers. A contract executes literally: if you send money to the wrong place, nobody will give it back.

What a smart contract is not

Despite the name, it is closer to a vending machine than to a legal agreement: the code performs the actions built into it, but it does not decide who is right in a dispute and does not account for circumstances its author failed to foresee. A smart contract also knows nothing about the outside world, such as a share price, the ruble exchange rate or a match result, until an oracle feeds it that data. That is why the reliability of many protocols depends not only on their code but also on the data sources they rely on.

Example

A user deposits a hypothetical $1,000 worth of ether into a lending protocol's smart contract and borrows $600 in stablecoins. Under the contract's rules, if the collateral drops below $750, the contract sells the ether itself to repay the debt. The price of ether falls 30%, the collateral is now worth $700, and liquidation starts automatically with no human involved.

Related terms

EthereumBlockchainDeFiTokenDAOBlockchain Oracle

On the site

CryptocurrenciesHow to buy cryptoBitcoin Price PredictionCrypto market Monopoly

This article was written by AI. Check specific rates, taxes and broker terms with primary sources.

↑ Top