Content

The Content contract allows a user to publish content openly on the Relation Protocol. Users can share articles, pictures, videos, and more with it. Meanwhile, it is based on blockchain technology, so the content published is immutable and traceable.

With the PublicContent contract, users can publish and read their own contents. They can also comment and like the contents generated by other users.

Schema

The schema of a content to be published is saved to Arweave in the form of a ttl file. The transaction hash will serve as a schemaURI to be passed as a parameter when initializing the contract. The following is an example:

ar://HENWTh3esXyAeLe1Yg_BrBOHhW-CcDQoU5inaAx-yNs

A schema consists of the following three parts:

  • The list of prefixes.

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 is used to represent an address entity.

:Soul a rdfs:Class ;
    rdfs:label "Soul" ;
    rdfs:comment "A soul." .
  • Predicate

The predicate p:publicContent describes the content to be published.

p:publicContent a rdf:Property ;
    rdfs:label "publicContent" ;
    rdfs:comment "The public content." ;
    rdfs:domain :Soul ;
    rdfs:range xsd:string .

The contract

interface IContent is ISemanticSBT {
    
    /**
     * Post a content.
     * @param content  The content should be the hash on arweave. The actual encrypted content and authorization records are stored on arweave.
     */
    function post(string memory content) external;
    
    /**
     * View the hash on arweave corresponding to the token.
     * @param tokenId
     * @return content 
     */
    function contentOf(uint256 tokenId) external view returns (string memory);
}

The content uploaded to Arweave is structured as follows:

{
  "content": {
    "body": "${The body of content}",
    "title": "${The title of content}"
  }
}

Full source code:

Last updated