ERC-6239 Semantic Soulbound Token (Semantic Soulbound Tokens)
Final · Names & metadata · created 2022-12-30
Puts RDF triples, a W3C standard data model, in the metadata of non-transferable tokens (soulbound tokens, SBTs), so that social relationships between accounts and attributes are recorded on-chain in a machine-readable form.
Why it is needed
Soulbound tokens represent an account's commitments, credentials, and affiliations. However, the mere existence of a token does not provide a common data model for managing, in a trustless way, the social meaning the token carries. When each project writes metadata in its own way, it is hard to describe the data in a connected form, and hard to exchange, integrate, or discover it. Building an integrated on-chain social graph from data of multiple sources, designating trusted contacts for social recovery, or supporting fair governance all require a standardized data format. This standard puts RDF triples with a subject-predicate-object structure into token metadata, so that social identity information can be published, linked, and queried bottom-up, without a central intermediary.
What to implement
function rdfOf(uint256 tokenId) external view returns (string memory rdfStatements);: Looks up the RDF statements of the semantic soulbound token by token ID.function schemaURI() external view returns (string memory);: A method of the optional extension ISemanticRDFSchema that returns the URI where the schema of the RDF data is located.
In depth
Four required interfaces
Tokens MUST implement the following interfaces: ERC165 from ERC-165 (0x01ffc9a7), ERC721 from ERC-721 (0x80ac58cd), ERC721Metadata from ERC-721 (0x5b5e139f), and ERC5192 from ERC-5192 (0xb45a3c0e). This standard is therefore an extension that builds on the existing NFT standard and the transfer-lock standard, and it is fully backward compatible with ERC-721 and ERC-5192. The ERC-165 identifier of the ISemanticSBT interface in this standard is 0xfbafb698.
The full form of an RDF statement and its six formats
An RDF statement follows the form rdfStatements = {[format]}<statements>. The format is one of six values: nt (N-Triples), ttl (Turtle), rdf (RDF/XML), rj (RDF/JSON), nq (N-Quads), and trig (TriG). nt separates the subject, predicate, and object with spaces and ends with a period. ttl shortens IRIs with prefixes and lets predicates under the same subject be combined. rdf is written in XML and rj in JSON, while nq and trig add a graph label that points to the dataset the triple belongs to.
The default format is ttl; other formats need an identifier
In the CreateRDF, UpdateRDF, and RemoveRDF events and the rdfOf method, rdfStatements uses the ttl format by default. If no format is specified, it is interpreted as statements = [ttl]statements. To use another format, a format identifier that starts with [ and ends with ] must be prepended. For example, with the nt format, write [nt]subject predicate object . . Turtle is the default because it is easy for people to read and concise, which reduces storage while still being suitable for expressing complex RDF graphs.
rdfOf and the optional extension schemaURI
rdfOf(uint256 tokenId) looks up the RDF data by token ID, and the returned data MUST follow the W3C RDF standard. RDF data is a collection of triples (RDF statements), each made of three parts: subject, predicate, and object. schemaURI() is a method of the OPTIONAL extension ISemanticRDFSchema and returns the URI where the RDF schema is stored. An RDF schema is a data modeling vocabulary that extends the base RDF vocabulary. It is RECOMMENDED to keep the schema in decentralized storage such as Arweave or IPFS and store its URI in the contract.
Three events must be emitted
CreateRDF MUST be emitted when a token is minted, UpdateRDF when RDF data is updated, and RemoveRDF when a token is burned or revoked. The RDF data in each event MUST be an RDF statement made of three parts: subject, predicate, and object. These events notify listeners so they can act on the RDF data that was created, updated, or removed.
Why RDF
RDF is a flexible and extensible standard that models graph data as subject-predicate-object relationships. It can describe rich information, including terms, categories, attributes, and relationships, in a standardized format, which helps different systems interoperate and integrates easily with other data sources on the web. It also supports semantic reasoning, so additional relationships between social graph nodes can be derived automatically from existing data. Even when data is scattered in pieces across individual semantic SBTs, the pieces are connected, so various community detection algorithms can be built on top of them.