# 智能合约开发

**代码即律法（Code is law）。**

智能合约丰富了区块链技术的适用范围，让分布式账本支持大规模的商业应用成为可能。

区块链应用开发者不光需要理解业务逻辑，还要能够开发智能合约和用户应用。超级账本 Fabric 的链码支持主流编程语言如 Go、Java、Node，并提供了链码开发框架，简化了分布式应用的开发过程。

本章将介绍 Fabric 链码的基本概念、结构和核心 API，并通过案例演示如何实现典型区块链应用，最后还介绍了外部链码机制，讨论了应用开发的最佳实践。通过本章学习，读者将掌握设计和开发链码的实践技巧。

> 本目录中的 `chaincode_example*.go` 是章节级独立示例，为便于阅读保留在同一目录下，部分示例会复用 `SmartContract`、`main` 等符号。不要在本目录直接运行 `go test ./...`；如需检查某个示例，请按单文件运行，例如 `go test chaincode_example01.go`，或将示例复制到独立链码工程中验证。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yeasy.gitbook.io/blockchain_guide/11_app_dev.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
