> For the complete documentation index, see [llms.txt](https://yeasy.gitbook.io/blockchain_guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yeasy.gitbook.io/blockchain_guide/11_app_dev/chaincode_example04.md).

# 学历认证

[chaincode\_example04.go](https://github.com/yeasy/blockchain_guide/blob/master/11_app_dev/chaincode_example04.go) 演示学校、学生和学历变更记录的链上管理。示例为了便于阅读，使用派生字符串模拟地址、公钥、私钥和签名。

## 数据结构

* `School`：学校名称、位置、地址、公私钥和学生地址列表；
* `Student`：学生姓名、地址和学历记录 ID 列表；
* `Background`：学历记录 ID、离校时间和状态；
* `Record`：学校对学生学历状态的变更记录。

## 主要交易函数

* `CreateSchool`：创建学校；
* `CreateStudent`：创建学生；
* `EnrollStudent`：学校登记学生入学；
* `UpdateDiploma`：学校更新学生学历状态；
* `GetStudentByAddress`、`GetSchoolByAddress`、`GetRecordByID`、`GetBackgroundByID`、`GetRecords`：读取状态。

真实系统中，签名与验签应由客户端身份、证书和密码学库完成，本例只保留业务流程骨架。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
