How to Schema

This guide will take you through registering schemas that are compliant with the Asset Register.

These schemas and shapes help ensure that data about assets, NFTs, and other entities adhere to the required structure and constraints.

Examples

Futureverse

This example defines the core classes and their hierarchies within the Futureverse framework. These definitions create a hierarchy where fv:Asset is the root, and the more specific classes like fv:NFT and fv:SFT inherit from it. Each of these asset types can be further categorized into on-chain or off-chain, depending on where the asset data is stored.

@prefix sh:   <http://www.w3.org/ns/shacl#> .
@prefix fv:   <http://schema.futureverse.dev/fv#> .
@prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xml:  <http://www.w3.org/2001/XMLSchema#> .

fv:Asset a rdfs:Class, sh:NodeShape ;
   rdfs:comment "An asset" ; .

fv:NFT a rdfs:Class, sh:NodeShape ;
   rdfs:subClassOf fv:Asset ;
   rdfs:comment "An NFT" ; .

fv:SFT a rdfs:Class, sh:NodeShape ;
   rdfs:subClassOf fv:Asset ;
   rdfs:comment "An SFT" ; .

fv:OnChainNFT a rdfs:Class, sh:NodeShape ;
   rdfs:subClassOf fv:NFT ;
   rdfs:comment "An on chain NFT" ; .

fv:OffChainNFT a rdfs:Class, sh:NodeShape ;
  rdfs:subClassOf fv:NFT ;
  rdfs:comment "An off chain NFT" ; .

fv:OnChainSFT a rdfs:Class, sh:NodeShape ;
  rdfs:subClassOf fv:NFT ;
  rdfs:comment "An on chain SFT" ; .

fv:OffChainSFT a rdfs:Class, sh:NodeShape ;
   rdfs:subClassOf fv:NFT ;
   rdfs:comment "An off chain SFT" ; .

TNL Boxer

This example defines a specific instance of an OnChainNFT, called Boxer, using SHACL (Shapes Constraint Language).

@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix schema: <http://schema.org/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix fv: <https://schema.futureverse.dev/fv#> .
@prefix this: <https://schema.futureverse.dev/tnl> .
@prefix asm: <https://schema.futureverse.dev/asm> .

this:Boxer a fv:OnChainNft, sh:NodeShape ;
    rdfs:subClassOf fv:OnChainNft;
    sh:property [
        sh:maxCount 1 ;
        sh:minCount 0 ;
        sh:class asm:Brain ;
        sh:path asm:equippedWith_brain ;
    ], [        
        sh:maxCount 1 ;
        sh:minCount 0 ;
        sh:class this:HairStyle ;
        sh:path this:equippedWith_hairStyle ;
    ], [        
        sh:maxCount 1 ;
        sh:minCount 0 ;
        sh:class this:HairDye ;
        sh:path this:equippedWith_hairDye ;
    ], [        
        sh:maxCount 1 ;
        sh:minCount 0 ;
        sh:class this:Bags ;
        sh:path this:equippedWith_bags ;
    ], [        
        sh:maxCount 1 ;
        sh:minCount 0 ;
        sh:class this:OutFit ;
        sh:path this:equippedWith_outfit ;
    ], [
        sh:maxCount 1 ;
        sh:minCount 0 ;
        sh:class this:Gloves ;
        sh:path this:equippedWith_gloves ;
    ], [
        sh:maxCount 1 ;
        sh:minCount 0 ;
        sh:class this:Boots ;
        sh:path this:equippedWith_boots ;
    ] .

TNX Boxer properties

  1. sh:property:

    • The sh:property construct defines constraints on a particular property of a node. Inside each sh:property block, you specify details about the property, such as its path, type, cardinality, and more.

  2. sh:maxCount and sh:minCount:

    • sh:maxCount 1: This specifies that the property can have at most one value. It's used to enforce uniqueness or singularity of a particular property in a node.

    • sh:minCount 0: This means that the property is optional (it can have zero values). If this were set to 1, the property would be required.

    Together, these constraints define a property that is optional but can only occur once if present.

  3. sh:class asm:Brain:

    • The sh:class property is used to enforce that the value of the property must be of a specific RDF class, in this case, asm:Brain. This ensures that the value of asm:equippedWith_brain must be an instance of the asm:Brain class.

  4. Targeting Multiple Classes with sh:class:

    • You can target multiple classes by listing them in a comma-separated list within the sh:class property. For example:

      sh:class fv:Gloves, fv:Mittens ;

      This specifies that the property can be an instance of either fv:Gloves or fv:Mittens.

  5. sh:path Property:

    • The sh:path statement indicates the exact RDF property within your data model that is subject to the constraints defined in the SHACL shape.

      sh:path asm:equippedWith_brain ;

      In this case, asm:equippedWith_brain is the RDF property that the shape is describing. This property might represent a relationship where a Boxer is equipped with a Brain.

ASM Brain

This example defines Brain as a specialized type of OnChainNFT, inheriting properties and constraints from its parent classes.

@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix schema: <http://schema.org/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix fv: <https://schema.futureverse.dev/fv#> .
@prefix this: <https://schema.futureverse.dev/asm> .

this:Brain a fv:OnChainNft, sh:NodeShape ; 
    rdfs:subClassOf fv:OnChainNft;.

Last updated

© 2023 -> ♾️