What is a smart contract?
A smart contract is a program stored on a blockchain such as Ethereum. It holds funds and follows fixed rules: when someone calls it and the conditions are met, it acts automatically, with no company in the middle. It cannot see outside data on its own, and a bug can lose money for good.
Nội dung này hiện chỉ có bản tiếng Anh.

Say 120 people each want to put 1 ETH toward a small game project, but only if it raises enough to get built. Normally a crowdfunding website would hold the money and promise refunds if the goal is missed.
A smart contract can do the same job without the website. The rules are published on a blockchain, and the code itself holds the money.
What a smart contract is
A smart contract is a program stored at an address on a blockchain. It can hold a balance like any account. It has no private key, though, so only its code decides what happens to that balance.
The computer scientist Nick Szabo used the term in the 1990s, long before blockchains existed. Ethereum, launched in 2015, made the idea practical for anyone who can write code.
The name is a little misleading. Most smart contracts involve no legal agreement at all. They are software that moves digital assets according to fixed rules.
How a contract runs
A contract has four parts: its address, its balance, its code and its stored data. The code is split into functions, named actions such as pledge or refund that anyone can ask it to perform.
Nothing happens until someone sends a transaction that calls a function. That person pays the gas fee, in ether, for the work the call takes.
Every validator then runs the same code with the same inputs and must reach the same result. That shared result becomes the new state of the contract.
If a call breaks one of the contract's rules, the whole transaction is undone and the contract stays as it was. The caller still pays gas for the work done before the failure.
A worked example: a crowdfunding contract
Here are the rules of an illustrative crowdfunding contract:
- The goal is 100 ETH, and the deadline is 30 days after launch.
- Anyone can pledge ether before the deadline, and the contract records each pledge.
- After the deadline, if the total is 100 ETH or more, the creator can withdraw all of it.
- If the total is below 100 ETH, each backer can withdraw their own pledge.
Suppose 120 backers pledge 1 ETH each. The total is 120 ETH, which meets the goal, so the creator's withdraw call succeeds and sends 120 ETH to the creator.
Now suppose only 70 backers pledge 1 ETH each. The total of 70 ETH misses the goal, so the creator's withdraw call fails. Each backer can call refund and get their 1 ETH back, paying a little gas.
No backer has to trust the creator to send refunds. The creator cannot take the 70 ETH, because no line of the code allows it.
That promise holds only if the code says what you think it says. Most users never read it, so in practice they rely on audits and on someone else having checked.
What smart contracts cannot do
A contract only sees data already on its own blockchain. It cannot check a match result or the price of gold by itself.
Projects fill the gap with an oracle, a service that posts outside data onto the blockchain for contracts to read. A contract that depends on an oracle is only as reliable as that oracle.
A contract cannot spot a bad input either. If an oracle reports a wrong price, a lending contract may sell a borrower's collateral at that price, exactly as its code says.
Contracts also never act on their own. When the deadline in the example passes, nothing happens until someone sends a transaction that triggers the next step.
Why fixed code cuts both ways
Once deployed, most contract code cannot be edited. That is the appeal: the rules you read are the rules that run.
It also means a bug stays live. Attackers read public contract code looking for mistakes, and one flaw can drain everything a contract holds.
Some contracts can be upgraded through an admin key. That allows fixes, but whoever holds the key can also change the rules, so you are back to trusting people.
Security audits catch many problems. Audited contracts have still been hacked, so an audit lowers the risk without removing it. In DeFi, where contracts hold large sums, this risk comes with every deposit.
Smart contracts and your wallet
When you use a token in a dApp, your crypto wallet often asks you to sign an approval. It gives a contract permission to move a set amount of that token out of your address.
A malicious contract with an unlimited approval can empty that token from your wallet later. Approval tricks are among the common crypto scams, so read what your wallet asks you to sign and remove approvals you no longer need.
Câu hỏi thường gặp
Are smart contracts legally binding?
Usually they are software, and their legal status depends on the country and the situation. A contract can be part of a legal agreement, but code alone rarely is one.
Can a smart contract be changed after it is deployed?
Most cannot. Some include an upgrade mechanism controlled by an admin key, which allows fixes but also lets the key holder change the rules.
What language are smart contracts written in?
On Ethereum most are written in Solidity and compiled to run on the Ethereum Virtual Machine (EVM). Other blockchains use other languages, such as Rust.
Do smart contracts only exist on Ethereum?
No. Many blockchains support them, and several copy Ethereum's virtual machine so the same code can run there too.
Who pays to run a smart contract?
The account that sends the transaction pays the gas fee. Some apps cover that fee for their users, but a contract never runs for free.
Học tiếp
Chương 3What is Ethereum?Ethereum is a public blockchain that records balances and also runs programs called smart contracts. Anyone can use it or build on it without asking permission. Its own currency, ether (ETH), pays the fee for every action. Since 2022 the network has been secured by proof of stake instead of mining.
Chương 3What is a dApp?A dApp, short for decentralized application, is an app whose core rules run as smart contracts on a blockchain instead of on a company's servers. You use it through a website and a crypto wallet that signs each action. No company holds your funds, so contract bugs, fake sites and fees are yours to manage.
Chương 3What is ether, and why does it have value?Ether (ETH) is the native currency of the Ethereum network. Every transaction pays its fee in ether, and validators lock it up as a deposit to secure the network. Its value comes from that demand meeting a supply with no fixed cap, which grows through new issuance and shrinks when fees are burned. Nothing guarantees its price.
Chương 3What moves the price of ether?Ether's price moves when the balance between buyers and sellers shifts. Most days the biggest driver is the crypto market as a whole, led by bitcoin, which in turn reacts to interest rates and risk appetite. Ether's own supply, use of the network, fund flows and forced selling by leveraged traders add moves on top.