# 智能合约

智能合约是存储在区块链上的计算机程序，被调用时自动执行，无需人类中介即可强制执行写入其代码的规则。美国国家标准与技术研究院（National Institute of Standards and Technology）将其定义为通过加密签名交易部署的代码与数据的集合（有时称为函数与状态），由区块链网络的节点执行，所有执行节点都必须得出相同结果，这些结果随后记录在区块链上<sup>[1](https://csrc.nist.gov/glossary/term/smart_contract)</sup>。这一术语及其基本思想早于区块链本身：计算机科学家兼法律学者[尼克·萨博](https://www.edgepedia.org/zh/nick-szabo)（Nick Szabo）于1994年提出该概念，而大规模实际部署始于2015年的以太坊（Ethereum）<sup>[2](https://www.nber.org/system/files/working_papers/w30006/w30006.pdf)</sup><sup> • </sup><sup>[3](https://technav.ieee.org/topic/smart-contracts/)</sup>。

| 关键事实 | 详情 |
|---|---|
| 定义 | 通过签名交易在区块链上部署的代码与数据；由节点执行，所有节点都必须得出相同结果，结果记录在链上<sup>[1](https://csrc.nist.gov/glossary/term/smart_contract)</sup> |
| 起源 | 尼克·萨博于1994年创造该术语；他1996年的文章以自动售货机作为原始示例<sup>[2](https://www.nber.org/system/files/working_papers/w30006/w30006.pdf)</sup><sup> • </sup><sup>[4](https://nakamotoinstitute.org/library/smart-contracts-building-blocks-for-digital-markets/)</sup> |
| 首个主要平台 | 以太坊，于2015年7月30日启动，具有图灵完备的执行环境（EVM）以及Solidity和Vyper等语言<sup>[3](https://technav.ieee.org/topic/smart-contracts/)</sup><sup> • </sup><sup>[5](https://ethereum.org/developers/docs/smart-contracts/)</sup> |
| 关键特性 | 确定性执行、部署后不可篡改、无需许可即可部署、合约之间的可组合性<sup>[1](https://csrc.nist.gov/glossary/term/smart_contract)</sup><sup> • </sup><sup>[5](https://ethereum.org/developers/docs/smart-contracts/)</sup> |
| 主要限制 | 没有预言机就无法读取链下数据；以太坊上合约最大体积为24 KB<sup>[5](https://ethereum.org/developers/docs/smart-contracts/)</sup> |
| 安全记录 | 2024—2025年公开披露的191起黑客攻击卷走46.7亿美元；遭黑客攻击的代币在六个月内的价格跌幅中位数为61%<sup>[6](https://immunefi.com/blog/research/what-an-onchain-hack-actually-costs-2024-2025-update/)</sup> |
| 法律地位 | 在英格兰和威尔士（England and Wales），法律委员会（Law Commission）于2021年11月得出结论：现有法律无需成文法改革即可支持智能法律合约<sup>[7](https://lawcom.gov.uk/project/smart-contracts/)</sup> |

## 起源：萨博的构想

尼克·萨博是一位计算机科学家兼法律学者，以数字合约和数字货币方面的研究而闻名。他于1994年将智能合约定义为“一组以数字形式规定的承诺，包括各方履行这些承诺所依据的协议”<sup>[2](https://www.nber.org/system/files/working_papers/w30006/w30006.pdf)</sup>。他1996年的文章《智能合约：数字市场的构建模块》（Smart Contracts: Building Blocks for Digital Markets）阐述了其设计目标：将合同条款（例如留置权、保证金和财产权）嵌入硬件和软件，使违约对违约方而言代价高昂<sup>[4](https://nakamotoinstitute.org/library/smart-contracts-building-blocks-for-digital-markets/)</sup>。

萨博的经典例子是自动售货机，他称之为智能合约的原始祖先：机器收取硬币，并通过简单机制公平地找零和出货，潜在损失有限<sup>[4](https://nakamotoinstitute.org/library/smart-contracts-building-blocks-for-digital-markets/)</sup>。以太坊的开发者文档仍使用同样的比喻：只要输入正确，就保证得到某种输出，因为逻辑已编入设备<sup>[5](https://ethereum.org/developers/docs/smart-contracts/)</sup>。

当时，尚无基础设施能够以最小化信任的方式运行此类合约。以太坊改变了这一点：它由[维塔利克·布特林](https://www.edgepedia.org/zh/vitalik-buterin)（Vitalik Buterin）于2013年11月在一份白皮书中提出，并于2015年7月30日启动。以太坊白皮书将该平台描述为一条区块链，内置一套成熟完备的图灵完备编程语言，允许用户将任意状态转换函数编码为合约<sup>[8](https://ethereum.org/whitepaper/)</sup><sup> • </sup><sup>[9](https://ethereum.org/ethereum-history-founder-and-ownership/)</sup>。

## 智能合约如何运作

在以太坊上，智能合约是一种账户：它拥有余额，可以成为交易的目标，并且不受用户控制，而由与其一同存储的代码控制。用户账户通过提交交易来与其交互，这些交易执行合约定义的函数<sup>[5](https://ethereum.org/developers/docs/smart-contracts/)</sup>。[以太坊虚拟机](https://www.edgepedia.org/zh/ethereum-virtual-machine)（EVM）是运行时环境；它处于沙箱中并完全隔离，因此在其内部运行的代码无法访问网络、文件系统或其他进程<sup>[10](https://docs.solidity.org/en/latest/introduction-to-smart-contracts.html)</sup>。

确定性是核心技术要求。由于每个节点都执行合约，而且所有节点都必须就结果状态达成一致，合约不能处理传入数据之外的数据；例如，它不能在执行期间从网络服务获取数据<sup>[1](https://csrc.nist.gov/glossary/term/smart_contract)</sup>。执行以燃料费（gas）支付；在这种费用机制中，部署合约的成本远高于简单的代币转账<sup>[5](https://ethereum.org/developers/docs/smart-contracts/)</sup>。

**部署无需许可。** 任何能够用智能合约语言（例如Solidity或Vyper）编写代码并支付燃料费的人都可以部署合约；代码必须经过编译，以便虚拟机能够解释和存储它<sup>[5](https://ethereum.org/developers/docs/smart-contracts/)</sup>。合约是公开的，可以调用其他合约，这一特性称为可组合性；合约甚至可以部署其他合约<sup>[5](https://ethereum.org/developers/docs/smart-contracts/)</sup>。

**不可篡改性是一把双刃剑。** 默认情况下，合约不能被删除，与其交互不可逆<sup>[5](https://ethereum.org/developers/docs/smart-contracts/)</sup>。这提升了可信度，却使缺陷修复和部署后变更变得困难，围绕这一问题已发展出关于可升级模式的研究文献<sup>[11](https://arxiv.org/abs/2504.02719)</sup>。

## 限制与预言机

智能合约无法自行获取关于现实世界事件的信息，因为依赖外部数据可能危及保障网络安全的共识<sup>[5](https://ethereum.org/developers/docs/smart-contracts/)</sup>。标准解决方案是预言机（oracle），即一种摄取链下数据并将其提供给合约的服务。预言机也带来自身的风险：中心化预言机是单点故障，可以控制决定合约结果的输入，因此预言机网络使用多个独立节点和数据源<sup>[12](https://chain.link/education-hub/oracle-problem)</sup>。

第二个技术限制是体积。在以太坊上，协议规则EIP-170将合约上限设为24 KB，该限制旨在防止永不结束的合约发起拒绝服务攻击；提议的变通方案是钻石模式（Diamond Pattern），将逻辑拆分到多个合约中<sup>[13](https://blockchain-observatory.ec.europa.eu/document/download/53a0aeb4-d144-4054-841e-dc169b44f94d_en?filename=SmartContractsReport_Final.pdf)</sup>。

以太坊并非唯一场景。超级账本 Fabric（Hyperledger Fabric）是一个许可制平台，运行其称为链码（chaincode）的智能合约；这些合约的信任来自区块链和节点间的共识<sup>[14](https://github.com/hyperledger/fabric/blob/main/docs/source/whatis.md)</sup>。索拉纳（Solana）的原生合约语言是Rust，并额外支持C++和Solidity<sup>[13](https://blockchain-observatory.ec.europa.eu/document/download/53a0aeb4-d144-4054-841e-dc169b44f94d_en?filename=SmartContractsReport_Final.pdf)</sup>。

## 安全

由于合约通常持有大量资金，且部署后无法修补，漏洞的代价高昂。最著名的早期事件是2016年的The DAO，其被利用造成约6000万美元的以太币损失，并导致以太坊一次颇具争议的分叉<sup>[15](https://arxiv.org/abs/2504.05968)</sup>。[美国证券交易委员会](https://www.edgepedia.org/zh/u-s-securities-and-exchange-commission)（U.S. Securities and Exchange Commission）2017年7月25日关于The DAO的调查报告认定，其代币属于联邦法律下的证券，从而确立：以代码组建的组织不能豁免于证券监管<sup>[16](https://www.sec.gov/litigation/investreport/34-81207.pdf)</sup>。

损失数据揭示了风险实际所在。众包安全平台Immunefi记录到，2024—2025年有191起公开披露的黑客攻击，被盗金额达46.7亿美元；盗窃金额中位数为220万美元，平均数为2450万美元，分布高度偏斜，其中五起最大黑客攻击占全部被盗资金的62%<sup>[6](https://immunefi.com/blog/research/what-an-onchain-hack-actually-costs-2024-2025-update/)</sup>。遭黑客攻击的协议，其代币在六个月内的价值跌幅中位数为61%，且84%的受攻击代币在该时间段内未能恢复<sup>[6](https://immunefi.com/blog/research/what-an-onchain-hack-actually-costs-2024-2025-update/)</sup>。

损失构成已经发生变化。严格按代码层面漏洞衡量，2025年仅有0.66%的锁定总价值因智能合约和区块链缺陷而损失，按该指标为有记录以来的最低比率<sup>[17](https://immunefi.com/blog/research/93-of-critical-crypto-vulns-are-disclosed-on-immunefi/)</sup>。[金融稳定理事会](https://www.edgepedia.org/zh/financial-stability-board)（Financial Stability Board）同样将智能合约错误、私钥管理不善和交易不可篡改性列为代币化金融的运营脆弱性<sup>[18](https://www.bis.org/publications/fsi-summary-financial-stability-implications-tokenisation-executive-summary)</sup>。

## 法律地位

自动执行的程序并不自动成为具有法律约束力的合同。英国司法辖区工作组（UK Jurisdiction Taskforce）2019年11月的法律声明得出结论：原则上，智能合约能够产生具有约束力的法律义务，并可按其条款强制执行；法律委员会2021年11月25日提交政府的建议得出结论：[英格兰和威尔士](https://www.edgepedia.org/zh/england-and-wales)的现有法律框架无需成文法改革即可促进和支持智能法律合约，同时指出契据和国际私法是仍需进一步工作的领域<sup>[7](https://lawcom.gov.uk/project/smart-contracts/)</sup>。欧盟（European Union）《数据法》（Data Act）提案将智能合约定义为电子账本上基于预定条件执行和结算交易的计算机程序，并针对其在数据共享场景中的使用，在可审计性和访问控制等方面设定要求<sup>[13](https://blockchain-observatory.ec.europa.eu/document/download/53a0aeb4-d144-4054-841e-dc169b44f94d_en?filename=SmartContractsReport_Final.pdf)</sup>。

## 机构与金融应用

[去中心化金融](https://www.edgepedia.org/zh/decentralized-finance)（DeFi）是最发达的商业用途：智能合约自动化借贷、交易和稳定币抵押品管理，以太坊的启动催生了DeFi、NFT和DAO等行业<sup>[19](https://ethereum.org/10years/)</sup>。世界银行（World Bank）的一份简报指出，供应链金融、保险和消费信贷是常被提及的用例，对金融普惠具有影响，其中与降低成本和建立信任的相关性最为明确<sup>[20](https://documents1.worldbank.org/curated/en/710151588785681400/pdf/Smart-Contract-Technology-and-Financial-Inclusion.pdf)</sup>。

各国央行已开始直接测试这项技术。松树项目（Project Pine）由纽约联储（New York Fed）的纽约创新中心（New York Innovation Center）与国际清算银行创新中心（BIS Innovation Hub）联合开展，构建了一套用于货币政策实施的可编程智能合约原型工具包，涵盖准备金利息、公开市场操作和抵押品管理，并发现该原型在十个模拟市场情景中均作出正确响应，证明了在广泛采用代币化的未来状态下具有技术可行性<sup>[21](https://www.newyorkfed.org/aboutthefed/nyic/project-pine)</sup>。在更广泛的代币化市场中，智能合约提供可编程性（交易自动执行）和可组合性；金融稳定理事会指出，这可能造成对金融稳定有影响的不透明相互依赖<sup>[18](https://www.bis.org/publications/fsi-summary-financial-stability-implications-tokenisation-executive-summary)</sup>。

## References

1. [Smart contract, NIST Computer Security Resource Center Glossary](https://csrc.nist.gov/glossary/term/smart_contract)
2. [Cong, L. W. and Mayer, Z. (2021). Smart contracts, NBER Working Paper 30006](https://www.nber.org/system/files/working_papers/w30006/w30006.pdf)
3. [Smart contracts, IEEE Technology Navigator](https://technav.ieee.org/topic/smart-contracts/)
4. [Szabo, N. (1996). Smart Contracts: Building Blocks for Digital Markets, Satoshi Nakamoto Institute](https://nakamotoinstitute.org/library/smart-contracts-building-blocks-for-digital-markets/)
5. [Introduction to smart contracts, ethereum.org](https://ethereum.org/developers/docs/smart-contracts/)
6. [What an Onchain Hack Actually Costs: 2024–2025 Update, Immunefi Research](https://immunefi.com/blog/research/what-an-onchain-hack-actually-costs-2024-2025-update/)
7. [Smart contracts, UK Law Commission](https://lawcom.gov.uk/project/smart-contracts/)
8. [Ethereum Whitepaper, ethereum.org](https://ethereum.org/whitepaper/)
9. [History of Ethereum: founder, launch and ownership, ethereum.org](https://ethereum.org/ethereum-history-founder-and-ownership/)
10. [Introduction to Smart Contracts, Solidity documentation](https://docs.solidity.org/en/latest/introduction-to-smart-contracts.html)
11. [The Myth of Immutability: A Multivocal Review on Smart Contract Upgradeability, arXiv](https://arxiv.org/abs/2504.02719)
12. [The Blockchain Oracle Problem, Chainlink](https://chain.link/education-hub/oracle-problem)
13. [Smart Contracts, EU Blockchain Observatory and Forum (2022)](https://blockchain-observatory.ec.europa.eu/document/download/53a0aeb4-d144-4054-841e-dc169b44f94d_en?filename=SmartContractsReport_Final.pdf)
14. [What is Hyperledger Fabric?, Hyperledger Foundation](https://github.com/hyperledger/fabric/blob/main/docs/source/whatis.md)
15. [Security Vulnerabilities in Ethereum Smart Contracts: A Systematic Analysis, arXiv](https://arxiv.org/abs/2504.05968)
16. [Report of Investigation Pursuant to Section 21(a): The DAO, U.S. Securities and Exchange Commission (25 July 2017)](https://www.sec.gov/litigation/investreport/34-81207.pdf)
17. [93% of Critical Crypto Vulns Are Disclosed on Immunefi, Immunefi Research](https://immunefi.com/blog/research/93-of-critical-crypto-vulns-are-disclosed-on-immunefi/)
18. [The Financial Stability Implications of Tokenisation, Executive Summary, Financial Stability Board / BIS](https://www.bis.org/publications/fsi-summary-financial-stability-implications-tokenisation-executive-summary)
19. [10 Year Anniversary, ethereum.org](https://ethereum.org/10years/)
20. [Smart Contract Technology and Financial Inclusion, World Bank](https://documents1.worldbank.org/curated/en/710151588785681400/pdf/Smart-Contract-Technology-and-Financial-Inclusion.pdf)
21. [Project Pine: Central Bank Open Market Operations With Smart Contracts, Federal Reserve Bank of New York](https://www.newyorkfed.org/aboutthefed/nyic/project-pine)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 17, 2026; Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 网络与安全 › Security governance and internet policy › Cryptographic protocols › Application protocols: voting, payment, and commerce

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/smart-contract

English original: https://www.edgepedia.org/smart-contract
