What is a smart contract?
A smart contract is a program stored on a blockchain that runs automatically when called, holding and moving assets according to its code.
How it works
A developer writes the contract, compiles it and deploys it to a blockchain such as Ethereum, where it gets its own address. Users and other contracts call its functions by sending transactions, and every node runs the same code to agree on the result.
Once deployed, the code is usually fixed. Some contracts use upgrade patterns that let an admin replace the logic, which adds flexibility but also gives that admin a great deal of power.
Fraud and risk angle
Code is the rulebook, so bugs become losses. Attackers search for flaws such as faulty access checks, unsafe external calls and price feeds that can be manipulated within one transaction.
Malicious contracts are also common. A token contract may block holders from selling, charge hidden fees or let the creator mint unlimited supply, which are typical features of a rug pull. Other contracts exist only to receive token approvals collected through approval phishing.
How to reduce the risk
- Check whether the contract code is published and verified on a block explorer.
- Look for independent security reviews, while keeping in mind that a review does not prove the code is safe.
- Find out who controls admin and upgrade keys, and whether changes go through a delay.
- Limit token approvals to the amount you need and revoke ones you no longer use.
Example
In a hypothetical case, a new token launches with a contract that lets anyone buy but only a list of allowed addresses sell. Buyers see the price rise and add funds, but their sell orders fail. The creator then sells their own large holding and leaves.
Related terms
- Avalanche (AVAX)Avalanche is a proof-of-stake blockchain platform whose native asset is AVAX. Its main smart contract chain, the C-Chain, is EVM compatible, and teams can launch their own linked chains.
- Non-fungible token (NFT)A non-fungible token is a unique token on a blockchain that records ownership of a specific item, such as digital art, a collectible or a ticket, and can be bought, sold and transferred.
- Decentralized finance (DeFi)Decentralized finance (DeFi) is financial services such as trading, lending and borrowing that run as smart contracts on a blockchain instead of through a bank or broker.
- Rug pullA rug pull is a crypto scam in which the creators of a token or project attract investors' funds and then take those funds and disappear.
- Approval phishingApproval phishing tricks a crypto user into granting an attacker permission to spend their tokens, so the attacker can take them later without the user's keys.
- Wallet drainerA wallet drainer is malicious code, often sold as a kit, that tricks users into signing transactions or approvals that move their crypto to an attacker.
- BlockchainA blockchain is a shared ledger that many computers keep in sync, where records are grouped into blocks and linked so that past entries are very hard to change.