起源学习站链上学习学院 › Level 3 DeFi 基础 › 什么是智能合约?ORIGIN LearnOn-chain Academy › Level 3 DeFi Basics › What is a smart contract?
💧 Level 3 · DeFi 基础💧 Level 3 · DeFi Basics

什么是智能合约?What is a smart contract?

6 分钟6 min
学习目标:学完你能用大白话说清智能合约是什么、它为什么不需要中间人,并知道怎样去链上核实一份合约是否开源、权限在谁手里。Learning goal: after this lesson you'll be able to explain in plain words what a smart contract is and why it needs no middleman, and know how to verify on-chain whether a contract is open source and who holds its permissions.
大白话In plain words智能合约就是一台写死了规则的自动售货机——你投币按按钮,它就照程序吐东西,中间没有店员,谁也没法临时改价。A smart contract is like a vending machine with its rules hard-coded — you put in a coin and press the button, and it dispenses exactly as programmed. There's no clerk in the middle, and no one can change the price on the spot.

智能合约,就是一段部署在区块链上、能自动执行的程序。你满足了它写好的条件,它就自动完成动作,比如自动转账、自动发奖励,全程不需要银行或平台当中间人。A smart contract is a program deployed on a blockchain that runs automatically. Once you meet the conditions it has written in, it completes the action on its own — such as auto-transferring funds or auto-distributing rewards — with no bank or platform acting as a middleman.

它最关键的特点是公开且难以私自更改。代码一旦上链,任何人都能查看,规则对所有人一视同仁,不会因为你是谁就区别对待。这也是它比传统中心化系统更透明的地方。Its key trait is being public and hard to alter privately. Once the code is on-chain, anyone can view it, and the rules treat everyone equally — you get no special treatment for who you are. This is where it's more transparent than traditional centralized systems.

但透明不等于安全。你要特别留意这几点:But transparent doesn't mean safe. Pay special attention to these points:

换句话说,智能合约把「信任平台」变成了「信任代码」。代码写得好,它就是一台可靠的自动机器;代码里留了后门,风险同样会自动执行,所以上链自己核实非常重要。In other words, a smart contract turns "trusting a platform" into "trusting the code". If the code is well written, it's a reliable automatic machine; if a back door is left in the code, the risk executes automatically too. That's why verifying it on-chain yourself matters so much.

案例Example你在去中心化交易所换币,点一下确认,合约就自动按规则扣你的 A 币、给你 B 币并收一点手续费,整个过程没有客服审批,全靠代码执行。You swap tokens on a decentralized exchange and click confirm once; the contract automatically deducts your token A, gives you token B, and takes a small fee — all according to its rules. There's no support-staff approval anywhere in the process; it's all executed by code.
配套工具(点开在主站打开):Related tools (open on the main site):
🛠 合约验证中心 ›🛠 Contract Verify ›

📝 本节测验📝 Quiz

1. 智能合约本质上是什么?1. What is a smart contract essentially?

2. 智能合约执行时通常需要谁来审批?2. Who usually needs to approve a smart contract when it executes?

3. 下面哪一点最能体现智能合约的透明性?3. Which point best reflects a smart contract's transparency?

4. 合约「开源」意味着什么?4. What does it mean for a contract to be "open source"?

5. 为什么说「透明不等于安全」?5. Why is it said that "transparent doesn't mean safe"?

❓ 常见问题❓ FAQ

智能合约真的完全改不了吗?Can a smart contract really never be changed at all?

不一定。很多合约是「可升级」的,管理员能替换背后的逻辑。是否能改、谁能改,要去合约验证中心自己看权限,别想当然。Not necessarily. Many contracts are "upgradeable", meaning an admin can replace the logic behind them. Whether it can be changed and who can change it — check the permissions yourself in the contract verify tool; don't take it for granted.

我不懂编程,怎么核实合约?I don't know how to code — how do I verify a contract?

不必读懂每行代码。先看它是否开源、有没有审计、管理员权限大不大,用合约验证中心把这几项过一遍,就能避开很多明显的坑。You don't need to read every line of code. First check whether it's open source, whether it's been audited, and how large the admin privileges are — run through these items with the contract verify tool and you'll avoid many obvious pitfalls.

合约上链后出问题能追回吗?If something goes wrong after a contract is on-chain, can it be recovered?

通常很难。链上交易一旦执行往往不可逆,所以事前核实合约、控制金额比事后维权重要得多。Usually it's very hard. On-chain transactions are often irreversible once executed, so verifying the contract beforehand and controlling your amounts matters far more than seeking recourse afterward.

‹ 上一课‹ Previous如何撤销授权How to revoke approvals