Content
Content合约允许用户在Relation Protocol网络上发布公共内容。用户可以通过此合约在网络上分享文章、图片、视频等多种类型的内容。同时,由于该合约基于区块链技术,因此其发布的内容具有不可篡改和可追溯的特点,保证了内容的可信度和可靠性。
在PublicContent合约中,用户可以发布内容、查看已发布的内容、评论和点赞其他用户的内容等。
Schema
内容发布的schema 以ttl文件的形式保存至Arweave,交易哈希将作为schemaURI,在初始化合约时传入,参数示例:
ar://HENWTh3esXyAeLe1Yg_BrBOHhW-CcDQoU5inaAx-yNs
schema由以下三部分组成:
schema 前缀列表
PREFIX : <http://relationlabs.ai/entity/>
PREFIX p: <http://relationlabs.ai/property/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
Class
Soul用于表示地址实体
:Soul a rdfs:Class ;
rdfs:label "Soul" ;
rdfs:comment "A soul." .
Predicate
谓词p:publicContent表述发布的内容
p:publicContent a rdf:Property ;
rdfs:label "publicContent" ;
rdfs:comment "The public content." ;
rdfs:domain :Soul ;
rdfs:range xsd:string .
合约
interface IContent is ISemanticSBT {
/**
* 发布内容
* @param content 发布的内容对应的Arweave交易哈希,可通过此交易哈希访问到原始发布内容
*/
function post(string memory content) external;
/**
* 查询发布内容
* @param tokenId
* @return content 发布的内容对应的Arweave交易哈希,可通过此交易哈希访问到原始发布内容
*/
function contentOf(uint256 tokenId) external view returns (string memory);
}
上传至Arweave的内容格式定义如下:
{
"content": {
"body": "${The body of content}",
"title": "${The title of content}"
}
}
完整的合约代码可访问:
Last updated