Developers Forum for XinFin XDC Network

ruslan wing
ruslan wing

Posted on

What are Soul Bound Tokens? And how to deploy a Sould Bound Token on XDC Network?

Tokenization is one of the key features of XDC Network. You can tokenize any physical or digital items and convert them into single or multiple tokens. Doing this keeps your asset secured and easy to use.

What are Soul Bound Tokens?

Soul Bound Tokens (SBTs) are a unique concept within the realm of blockchain technology. These tokens represent digital assets that possess an inherent connection or "bond" to an individual or entity. Unlike other tokens, SBTs are indivisible, non-fungible and carry distinct properties that grant them exceptional value.

The term "Soul Bound" captures the profound attachment that SBTs have with their rightful owners. It signifies the tokens' special significance and meaning within the context of the associated individual or entity. SBTs serve as a representation of ownership and serve as proof of authenticity for various physical and digital assets, ranging from artwork and collectibles to real estate and intellectual property.

Image description

When considering tokenization, the ability to transfer tokens with the owner's consent is a vital aspect. However, certain documents, such as Birth Certificates and driving licenses, are not intended to be transferable. This is where SBTs, or Soul Bound Tokens, come into play. These tokens are perpetual and incapable of being transferred once minted or assigned to an account. They ensure the immutability and unwavering connection between the asset and its original owner, preserving the integrity and exclusivity of such important documents.

By leveraging SBTs, the tokenization process extends beyond traditional transferability, catering to scenarios where certain assets demand a steadfast and unbreakable bond with their original owners.

How to create a Soul Bound Tokens Token on XDC Network?

Let’s create an SBT NFT. Initially, we will create a standard XRC721 contract.

Let’s generate it on OpenZeppelin wizards. For more details on How to use wizards, check out the detail guide https://medium.com/@ruslanwing100/effortlessly-deploy-your-xrc20-token-with-openzepellin-wizard-a-step-by-step-guide-65eebd674f7b

Image description

After creating an XRC-721 contract, click on the remix. We will have to make some changes to the code.

Image description

_beforeTokenTransfer() function gets triggered every time a token is transferred. To make our NFT a soul-bound token, we need to modify the overridden _beforeTokenTransfer().

function _beforeTokenTransfer(address from, address to, uint256 tokenId, uint256 batchSize)
 internal
 override(ERC721, ERC721Enumerable)
 {
 require(from == address(0), “Token is not transferable”);
 super._beforeTokenTransfer(from, to, tokenId, batchSize);
 }
Enter fullscreen mode Exit fullscreen mode

The above function will only allow the contract to mint tokens. Whenever a transfer happens, the transfer function will call the _beforeTokenTransfer() since our _beforeTokenTransfer() is being modified and restricted only for mint. The transfer function will revert the transaction if it is a standard transfer.

Also, check out the SBT contract code on GitHub https://github.com/RuslanWing/Smartcontracts/blob/main/SBT.sol. After updating the code, we will deploy the Solid Bond token SBT on XDC Network.

Image description

We’ve just developed a simple SBT NFT token on XDC Network. If you have any questions, please feel free to post it on the XDC Network developer’s forum at https://xdc.dev

Discussion (2)

Collapse
lance profile image
Lance Lilly

This would be a great how-to tutorial for documentation.

github.com/XDC-Community/docs/tree...

Collapse
cryptosandtokens profile image
Robert Aronovici

This is a much needed guide for those who are ready to start from scratch! Even better for teams building at hackatons!