Listen to events

The events defined in the Relation Protocol are completely inherited from EIP6239arrow-up-right, we need to listen to all events that comply with the EIP6239 specifications:

/**
 * @title Semantic Soulbound Token
 * Note: the EIP-165 identifier for this interface is 0xfbafb698
 */
interface ISemanticSBT {
    /**
     * @dev This emits when minting a Semantic Soulbound Token.
     * @param tokenId The identifier for the Semantic Soulbound Token.
     * @param rdfStatements The RDF statements for the Semantic Soulbound Token. An RDF statement is the statement made by an RDF triple.
     */
    event CreateRDF (
        uint256 indexed tokenId,
        string rdfStatements
    );
    /**
     * @dev This emits when updating the RDF data of Semantic Soulbound Token. RDF data is a collection of RDF statements that are used to represent information about resources.
     * @param tokenId The identifier for the Semantic Soulbound Token.
     * @param rdfStatements The RDF statements for the semantic soulbound token. An RDF statement is the statement made by an RDF triple.
     */
    event UpdateRDF (
        uint256 indexed tokenId,
        string rdfStatements
    );
    /**
     * @dev This emits when burning or revoking Semantic Soulbound Token.
     * @param tokenId The identifier for the Semantic Soulbound Token.
     * @param rdfStatements The RDF statements for the Semantic Soulbound Token. An RDF statement is the statement made by an RDF triple.
     */
    event RemoveRDF (
        uint256 indexed tokenId,
        string rdfStatements
    );
    /**
     * @dev Returns the RDF statements of the Semantic Soulbound Token. An RDF statement is the statement made by an RDF triple.
     * @param tokenId The identifier for the Semantic Soulbound Token.
     */
    function rdfOf(uint256 tokenId) external view returns (string memory);
}
  • CreateRDF: Triggered when a SBT containing RDF semantics is created.

  • UpdateRDF: Triggered when a SBT containing RDF semantics is updated.

  • RemoveRDF: Triggered when a SBT containing RDF semantics is removed.

By listening to these events on the blockchain, you will receive RDF data containing semantics (code 7-1), which contains user behavior data.

Use The Graph index

With The Grapharrow-up-right, we can index users' behavioral data on the blockchain easily. You can refer to The Graph documentationarrow-up-right.

Below is the behavioral data from the Polygon network through our listening. The address is:

https://thegraph.com/hosted-service/subgraph/relationlabs/semantic-sbtarrow-up-right

  • Query via the playground provided by The Graph:

Figure 7-2 Query via the playground
  • Query via the GraphQL API provided by The Graph:

eg. To query the latest two token records:

The result

Use The ethers.js

ethers.jsarrow-up-right is a JavaScript library for interacting with the Ethereum Blockchain and its ecosystem.

For example:

Last updated