起源学习站链上学习学院 › Level 5 链上研究者 › 如何阅读智能合约?ORIGIN LearnOn-chain Academy › Level 5 On-chain Researcher › How to read smart contracts?
🔬 Level 5 · 链上研究者🔬 Level 5 · On-chain Researcher

如何阅读智能合约?How to read smart contracts?

8 分钟8 min
学习目标:学完你能在区块浏览器上打开一个合约,分清读/写函数、找到关键权限,判断它能对你做什么。Learning goal: after this lesson you'll be able to open a contract on a block explorer, tell read functions from write functions, find the key permissions, and judge what it can do to you.
大白话In plain words阅读合约不是要你会写代码,而是学会在浏览器上「翻它的说明书」——看它有没有开源、谁是管理员、能不能增发、能不能暂停、能不能升级。Reading a contract isn't about being able to write code — it's about learning to "flip through its manual" on the explorer: is it open source, who is the admin, can it mint, can it pause, can it be upgraded.

在区块浏览器(如 PolygonScan)打开一个合约,重点看几栏:Open a contract on a block explorer (such as PolygonScan) and focus on a few sections:

几个高风险信号要会认:Learn to recognize a few high-risk signals:

关键原则:不要只看函数名字下结论。名字叫 emergencyWithdraw(紧急提取)不代表保护用户,要看它到底是用户提现还是管理员提走合约资产。看到 renounceOwnership(放弃所有权)也别急着放心,可能还有 ProxyAdmin、DEFAULT_ADMIN_ROLE、多签等其他管理入口。Key principle: don't draw conclusions from a function's name alone. A function called emergencyWithdraw doesn't mean it protects users — check whether it's users withdrawing their own funds or an admin taking the contract's assets. Seeing renounceOwnership isn't a reason to relax either — there may still be other admin entry points like ProxyAdmin, DEFAULT_ADMIN_ROLE, or a multisig.

本站的合约验证中心已经把起源两条链上的合约整理好:是否开源、是否代理、可否升级、Owner、多签等一览,每个都能点到浏览器独立核实。先用它建立感觉,再自己去浏览器抠细节。This site's Contract Verify has already organized the contracts on ORIGIN's two chains: whether open source, whether a proxy, whether upgradeable, the owner, the multisig and more — all in one view, each clickable through to the explorer for independent verification. Use it to build a feel first, then dig into the details on the explorer yourself.

案例Example你看到某代币合约有 mint() 函数,别慌也别忽略——去看它的调用权限:如果只有一个普通钱包地址就能无限增发,这就是高风险;如果需要多签且有上限,风险就低很多。函数存在 ≠ 一定危险,要看谁能调、有没有限制。You see that a token contract has a mint() function — don't panic, but don't ignore it either. Check who can call it: if a single ordinary wallet address can mint unlimited supply, that's high risk; if it requires a multisig and has a cap, the risk is much lower. A function existing ≠ definite danger — look at who can call it and whether there are limits.
配套工具(点开在主站打开):Related tools (open on the main site):
🛠 合约验证中心 ›🛠 Contract Verify ›🛠 代币安全自查 ›🛠 Token Safety ›

📝 本节测验📝 Quiz

1. 阅读合约的第一步应确认?1. The first step when reading a contract is to confirm?

2. 下列哪个是「可增发」的信号?2. Which of the following is a signal of "can mint more supply"?

3. 看到 renounceOwnership(放弃所有权)就一定安全吗?3. Does seeing renounceOwnership always mean it's safe?

4. 代理合约(Proxy)意味着?4. A proxy contract (Proxy) means?

5. 判断一个 Write 函数的风险,正确做法是?5. To judge the risk of a Write function, the correct approach is?

❓ 常见问题❓ FAQ

不会编程能读懂合约吗?Can you understand a contract without knowing how to code?

能。阅读合约主要是在区块浏览器上看合约是否开源、区分读/写函数、找出关键权限(能否增发/暂停/升级、owner 是谁),不需要自己写代码。Yes. Reading a contract is mainly about checking on a block explorer whether it's open source, telling read functions from write functions, and finding the key permissions (can it mint / pause / upgrade, who is the owner) — you don't need to write any code yourself.

看到 mint() 函数就说明有问题吗?Does seeing a mint() function mean there's a problem?

不一定。要看谁能调用、有没有上限和多签。函数存在不等于危险,关键是权限是否集中、是否可被单个地址无限调用。Not necessarily. Look at who can call it and whether there's a cap and a multisig. A function existing doesn't equal danger — what matters is whether the power is concentrated and whether a single address can call it without limit.

‹ 上一课‹ Previous如何查看 LGNS 链上数据?How to check LGNS on-chain data?