Developer Hub
Relation ProtocolRelation ONE APIRelation Graph API
中文
中文
  • 概述
  • 快速开始
    • 基于Relation Protocol 部署合约
    • 使用Graph Indexer部署Social Graph的查询服务
  • 关键概念
    • RDF
    • Semantic SBTs
    • Social Graph
  • Relation Protocol的架构
  • Schema Standard
    • 概述
    • schema如何约束智能合约
    • schema存储
    • schema列表
  • Contract Open Standard
    • 概述
    • Identity
      • Name Service
    • Relationship
      • Follow
      • Dao
    • Publication
      • Content
      • Privacy Content
  • Open Standard API
    • 介绍
    • EIP-6239
    • 业务接口
      • Identity
      • Relationship
      • Publication
  • Graph Indexer
    • 定义与用途
    • 事件监听
    • 解析数据
    • 构建图谱
  • 集成
    • 快速开始
    • 构建Relation Protocol社交图谱
    • Relation Protocol 资源列表
    • NameService 合约请求示例
    • Follow 合约请求示例
    • Dao 合约请求示例
    • Content 合约请求示例
    • PrivacyContent 合约请求示例
  • Relation Name Service
    • Name Service Api
  • 用例
  • 附录
    • 使用Hardhat部署合约
    • SemanticSBT部署工具
Powered by GitBook
On this page
  • Schema
  • 合约
  1. Contract Open Standard
  2. Publication

Content

Last updated 2 years ago

Content合约允许用户在Relation Protocol网络上发布公共内容。用户可以通过此合约在网络上分享文章、图片、视频等多种类型的内容。同时,由于该合约基于区块链技术,因此其发布的内容具有不可篡改和可追溯的特点,保证了内容的可信度和可靠性。

在PublicContent合约中,用户可以发布内容、查看已发布的内容、评论和点赞其他用户的内容等。

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}"
  }
}

完整的合约代码可访问:

schema
Content