> For the complete documentation index, see [llms.txt](https://relationlabs.gitbook.io/semantic-sbt/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://relationlabs.gitbook.io/semantic-sbt/semanticsbt-zh/untitled/ying-yong-chang-jing.md).

# 应用场景

## 基于Semantic合约的Token 2049活动

下面会通过具体的应用场景，来演示Semantic合约的使用过程。

整体的业务流程包括：

* 初始化合约

```solidity
function initialize(
        address minter,
        string memory name_,
        string memory symbol_,
        string memory baseURI_,
        string memory schemaURI_,
        string[] memory classes_,
        Predicate[] memory predicates_
    ) public initializer onlyOwner {}
```

* 指定特定活动

```solidity
function addSubject(string memory value, string memory className_) 
external onlyMinter returns (uint256 sIndex) {}
```

* 生成SBT勋章

```solidity
function mint(address account, uint256 sIndex, 
        IntPO[] memory intPOList, 
        StringPO[] memory stringPOList,
        AddressPO[] memory addressPOList, 
        SubjectPO[] memory subjectPOList,
        BlankNodePO[] memory blankNodePOList
    ) external onlyMinter returns (uint256) {}
```

### 初始化合约

对应生成活动的Class和Predicate：调用方法initialize(owner.address,"Relation SBT","SBT","baseURI","schemaURI,\["Activity"],\["winner","2"]), 代表生成的是2049活动的勋章。

* 第一参数owner.address代表合约的部署者的地址
* 第二参数"Relation Activity Token2049"代表合约的名称
* 第三个参数"SBT"，代表当前Token的symbol
* 第四个参数"baseURI"，代表当前Token的metadata地址目录
* 第五个参数"schemaURI"，代表当前Token的RDF数据对应的schema的地址
* 第六个参数"RelationActivity"，代表当前活动的主体Class
* 第七个参数"WinnerIs"，代表当前活动的Predicate，Predicate Type是String

### 定义主语

调用方法addSubject("Token2049","RelationActivity")。

* 第一参数"Token2049"，活动的主语，即本次活动是“RelationActivity\_Token2049”
* 第二个参数"RelationActivity"，是在初始化时创建的Class Name
* 方法调用成功后会生成一个主语的索引，也就是Subject Index，用于保存时与PredicateAndObject关联。比如此时返回为1.

### 生成SBT勋章

调用方法mint("address",1,\[],\[1,"address"],\[],\[],\[],\[],\[]) 。调用该方法后，相当于给地址"address" 生成了一个“RelationActivity\_Token2049 WinnerIs address”的SBT

* 第一参数"address"，是该SBT的所有者
* 第二个参数1，是Subject Index，此处为第二步生成的“Token2049”
* 第三个参数\[]，是Integer类型的PredicateAndObject，此处为空
* 第四个参数\[1,"address"]，是String类型的PredicateAndObject，1代表初始化的谓词"winner is", "address"指类型为String的Object
* 第五个参数\[]，是Address类型的PredicateAndObject，此处为空
* 第六个参数\[]，是Subject类型的PredicateAndObject，此处为空
* 第七个参数\[]，是BlankNode类型的PredicateAndObject，此处为空


---

# 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://relationlabs.gitbook.io/semantic-sbt/semanticsbt-zh/untitled/ying-yong-chang-jing.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.
