EIPs Explained

ERC-6239 · Final · ERC · 2022-12-30

ERC-6239: Semantic Soulbound Tokens

Soulbound tokens whose metadata carries RDF subject-predicate-object triples, so social facts like follows or memberships become linked, machine-readable data on chain.

What problem does it solve?

Soulbound tokens (non-transferable NFTs, see ERC-5192) are a natural way to record credentials, memberships and relationships on chain. But each project encodes the meaning of its tokens in its own ad-hoc metadata, so a different app cannot easily combine "Alice follows Bob" from one contract with "Bob is a member of DAO X" from another.

ERC-6239 adopts the W3C Resource Description Framework (RDF) as a common data model. Every Semantic SBT carries RDF statements describing what it means, so on-chain social data can be linked, queried and reasoned over like any other linked-data graph.

How it works

A Semantic SBT must implement ERC-165, ERC-721 with the metadata extension, and ERC-5192. On top of that it adds:

  • rdfOf(tokenId) returning the token's RDF statements as a string.
  • Events emitted when the RDF data is created (mint), updated, or removed (burn or revoke): CreateRDF, UpdateRDF, RemoveRDF. Indexers listen to these to maintain a graph.
  • Optionally, schemaURI() pointing to an RDF Schema describing the vocabulary used. Storing it on IPFS or Arweave is recommended.

An RDF statement is a triple: subject, predicate, object. For example, "user1 has name Alice".

Statements default to the Turtle (ttl) format. Other formats are allowed if prefixed with a format tag in square brackets:

Tag Format
(none) or [ttl] Turtle
[nt] N-Triples
[nq] N-Quads
[trig] TriG
[rdf] RDF/XML
[rj] RDF/JSON

The ERC-165 interface id for ISemanticSBT is 0xfbafb698.

Sample code

The core interface:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface ISemanticSBT {
    event CreateRDF(uint256 indexed tokenId, string rdfStatements);
    event UpdateRDF(uint256 indexed tokenId, string rdfStatements);
    event RemoveRDF(uint256 indexed tokenId, string rdfStatements);

    function rdfOf(uint256 tokenId) external view returns (string memory rdfStatements);
}

interface ISemanticRDFSchema {
    function schemaURI() external view returns (string memory);
}

Example RDF payloads a token might return (Turtle default, then N-Triples with its tag):

@prefix : <http://example.org/entity/> .
@prefix p: <http://example.org/property/> .
:user1 a :User ;
       p:name "Alice" .
[nt]<http://example.org/entity/user1> <http://example.org/property/follows> <http://example.org/entity/user2> .

Reading it with ethers v6:

const sbt = new Contract(addr, ["function rdfOf(uint256) view returns (string)"], provider);
console.log(await sbt.rdfOf(1n));

Things to know

  • Status: Final.
  • The ERC fixes the container and formats, not the vocabulary. Interoperability between projects still depends on agreeing on predicates and schemas (hence schemaURI).
  • RDF strings stored on chain are public and can be expensive to write; keep statements compact.
  • Because the tokens are soulbound, statements describe the holder permanently unless the issuer revokes them. Think about what personal or social data you actually want to publish.

#sbt #soulbound #identity #rdf #metadata

Details

Authors
Jessica Chang (@JessicaChg)
Status
Final
Type
Standards Track / ERC
Created
2022-12-30
Requires

Machine-readable: Markdown · JSON