πŸͺ” Soulbound Tokens

Introduction

Soulbound tokens are ERC-721 tokens that cannot be transferred to other wallet addresses. This means that once a Soulbound token is minted to a particular wallet address, it cannot be transferred or traded to another address. This restriction can be helpful in certain situations, such as creating unique digital items or rewards for specific users.

Advantages of using Soulbound tokens

There are several advantages to using Soulbound tokens:

  1. Unique rewards: By creating Soulbound tokens, you can ensure each reward or item is unique to a particular user. This can increase the item's perceived value and make it more meaningful to the user.

  2. Security: By restricting the transfer of tokens to other wallet addresses, you can ensure that your tokens are not stolen or misused.

  3. Control: Soulbound tokens give you greater control over the distribution and use of your tokens. You can ensure they are only used for their intended purpose and by their intended recipients.

How to create a Soulbound token using the Co:Create API

To create a Soulbound token using the CoCreate API, you can use the same methods for creating any other ERC-721 token. However, you must enable transfer restrictions to ensure the token is Soulbound.

To create a Soulbound token, follow these steps:

1. Create a new ERC-721

Make a POST request to the ERC721 API. There are a few parameters to include here:

  • name: The name of your token
  • symbol: Your token's symbol (conventionally all upper case)
  • base_uri: The off-chain file your token represents (read more about this here).
  • transfer_restricted: Set to true to prevent your token from being transferred, which is the main property of a Soulbound token.
  • transfer_allowlist [OPTIONAL]: Enables you to add a comma-separated address list to which are allowed to send or receive transfers of the token.

πŸ“˜

Transfer Allowlist Mechanics

If transfers are restricted, only the addresses that are added to the allowlist can transfer the token. The contract checks whether either the sender or receiver is on the allowlist, and if not, the transfer will fail with the error message "Transfer not allowed."
The owner of the contract (your Co:Create admin address) and the 0x00... address can always transfer the token.

Example request:

curl --request POST \
  --url https://api.testcocrt.xyz/alpha/erc721 \
  --header 'Authorization: Bearer <YOUR_KEY_HERE>' \
  --data '{ 
  					"name": "My Soulbound Token",
  					"symbol": "SBT", 
            "base_uri": "https://example.com/media_url/",
            "transfer_restricted": true, 
            "transfer_allowlist": "[
            	"0x0c040570aa12e202a5fa382b5b389dfc794a9f7b", 
            	"0xe371ae58b8cd446924a66488a08b3c02ad9592be"
            ]"
}'
import fetch from 'node-fetch';

const url = 'https://api.testcocrt.xyz/alpha/erc721';
const token = 'Bearer <<YOUR_KEY_HERE>>';
const postData = {
  			name: "My Soulbound Token",
  			symbol: "SBT",
        base_uri: "https://nftstorage.link/ipfs/bafybeiasv4llnkervuprzfte5sulodkzobcmpfc7ldwybdwiqq5ywbbstu/",
        transfer_restricted: true,
        transfer_allowlist:
          [
            "0x0c040570aa12e202a5fa382b5b389dfc794a9f7b",
            "0xe371ae58b8cd446924a66488a08b3c02ad9592be"
          ],
};
const options = {
  method: 'POST',
  withCredentials: true,
  credentials: 'include',
  body: JSON.stringify(postData),
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `${token}`
  }
};

console.log(options);
fetch(url, options)
  .then(res => res.json())
  .then(data => console.log(data))
  .catch(error => console.error(error));

In the above example, we have enabled transfer restrictions for our token.

We have also white-listed two addresses:
0xe371ae58b8cd446924a66488a08b3c02ad9592be
0x0c040570aa12e202a5fa382b5b389dfc794a9f7b
these addresses are allowed to send and receive transfers of the token.

2. Mint the Soulbound token

Once transfer restrictions are enabled, you can mint the Soulbound token to a specific wallet address by making a POST request to the Mint method within the ERC721 API. The wallet address that receives the token will be the only one that can ever own the token.

curl --request POST \
  --url https://api.testcocrt.xyz/alpha/erc721/mint \
  --header 'Authorization: Bearer <YOUR_KEY_HERE>' \
  --data '{
	    "wallet_address":"0xf998201a354418280612bF5E658E0852B79723e3",
      "erc721_id":"f19e6691-3013-4bd1-8803-1a596f3a2af1",
      "mint_quantity":1
}'
import fetch from 'node-fetch';

const url = 'https://api.testcocrt.xyz/alpha/erc721/mint';
const token = 'Bearer <<YOUR_KEY_HERE>>';
const postData = {
      wallet_address:"0xe371ae58b8cd446924a66488a08b3c02ad9592be",
      erc721_id:"19794750-85fb-4124-a825-ad92a5624538",
      mint_quantity: 1
};
const options = {
  method: 'POST',
  withCredentials: true,
  credentials: 'include',
  body: JSON.stringify(postData),
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `${token}`
  }
};

fetch(url, options)
  .then(res => res.json())
  .then(data => console.log(data))
  .catch(error => console.error(error));

πŸ‘

Get Help

If you get stuck at any time, reach out to us on Discord or contact us via email at [email protected].