Application Scenarios

Example: Token 2049 event based on a Semantic contract

We will use an application scenario to demonstrate how to use a semantic contract.

The flow includes:

Initialize the contract

function initialize(
        address minter,
        string memory name_,
        string memory symbol_,
        string memory baseURI_,
        string memory schemaURI_,
        string[] memory classes_,
        Predicate[] memory predicates_
    ) public initializer onlyOwner {}

Specify an event

function addSubject(string memory value, string memory className_) 
external onlyMinter returns (uint256 sIndex) {}

Mint a SBT medal

function mint(address account, uint256 sIndex, 
        IntPO[] memory intPOList, 
        StringPO[] memory stringPOList,
        AddressPO[] memory addressPOList, 
        SubjectPO[] memory subjectPOList,
        BlankNodePO[] memory blankNodePOList
    ) external onlyMinter returns (uint256) {}

Initialize the contract

It means that we will generate a medal for the Token2049 event.

  • The first parameter “owner.address” refers to the address which deployed the contract.

  • The second parameter "Relation Activity Token2049" refers to the name of the contract

  • The third parameter "SBT" refers to the symbol of this token.

  • The fourth parameter "baseURI" refers to the address containing the metadata of this token.

  • The fifth parameter "schemaURI" refers to the RDF schema address of this token.

  • The sixth parameter "RelationActivity" refers to the Subject Class of this event.

  • The seventh parameter "WinnerIs" refers to the Predicate of this event. The Predicate is a String type.

Define the Subject

Call the method addSubject("Token2049","RelationActivity").

  • The first parameter "Token2049" is the Subject of this event, meaning that this event is titled “RelationActivity_Token2049”.

  • The second parameter "RelationActivity" is the Class Name created when the contract was initialized.

  • After the call is successful, it will generate a Subject Index to link to a PredicateAndObject. The return value is 1 in this instance.

Mint a SBT Medal

Call the method mint("address",1,[],[1,"address"],[],[],[],[],[]) . Once the call is executed, we will have minted a SBT “RelationActivity_Token2049 WinnerIs address”.

  • The first parameter "address" is the owner of the SBT.

  • The second parameter 1 is the Subject Index corresponding to “Token2049”.

  • The third parameter [] is an Integer type PredicateAndObject. We have left it blank.

  • The fourth parameter [1,"address"] is a String type PredicateAndObject. The number 1 refers to the predicate “winner is” when the contract was initialized, and “address” is a String type Object.

  • The fifth parameter [] is an Address type PredicateAndObject. We have left it blank.

  • The sixth parameter [] is a Subject type PredicateAndObject. We have left it blank.

  • The seventh parameter [] is a BlankNode type PredicateAndObject. We have left it blank.

Last updated