Create ERC71 tokens
info
The ERC721 token definition is the blueprint for NFTs. The token may be referred to as a collection.
Create ERC721 token
Make a POST call to {{CODEFI_API}}/essentials/token/nonfungible?userId={{issuerId}}
with the following body:
{
"tokenStandard": "ERC721Token",
"symbol": "{{tokenSymbol}}",
"name": "{{tokenName}}",
"data": {
"[OPTIONAL]": "[OPTIONAL] Additional use case specific data"
}
}
Example commands
ERC721TOKEN_ID=$(curl --header "Content-Type: application/json" --header "Authorization: Bearer $ADMIN_ACCESS_TOKEN" --request POST --data '{ "tokenStandard": "ERC721Token", "symbol": "TST2", "name": "Test ERC721 Token", "data": {} }' $CODEFI_API/essentials/token/nonfungible?userId=$ISSUER_ID | jq -r '.token.id')
echo ERC721TOKEN_ID=$ERC721TOKEN_ID
Example output
ERC721TOKEN_ID=02fd5e9b-90af-43d7-b069-9472a3ead00c
Mint ERC721 token
Make a POST call to {{CODEFI_API}}/essentials/token/nonfungible/{{token}}/transaction/mint?userId={{issuerId}}
with the following body:
{
"recipientId": "{{investor}}",
"identifier": "1633467",
"data": {
"[OPTIONAL]": "[OPTIONAL] Additional use case specific data"
}
}
This call mints a single NFT.
Example command
curl --header "Content-Type: application/json" --header "Authorization: Bearer $ADMIN_ACCESS_TOKEN" --request POST --data '{ "recipientId": "'"$INVESTOR1_ID"'", "identifier": "1633467", "data": {} }' $CODEFI_API/essentials/token/nonfungible/$ERC721TOKEN_ID/transaction/mint?userId=$ISSUER_ID
Example output
{
...
"message": "Minting of nonfungible token with identifier 1633467, for investor ed3517df-c9ac-4952-bc53-8ff88457b39c, has been successfully requested (transaction sent)"
}
Transfer ERC721 tokens
Make a POST call to {{CODEFI_API}}/essentials/token/nonfungible/{{tokenId}}/transaction/transfer?userId={{investorId1}}
with the following body:
{
"recipientId": "{{recipient}}",
"identifier": "1633467",
"data": {
"[OPTIONAL]": "[OPTIONAL] Additional use case specific data"
}
}
Example command
curl --header "Content-Type: application/json" --header "Authorization: Bearer $ADMIN_ACCESS_TOKEN" --request POST --data '{ "recipientId": "'"$INVESTOR2_ID"'", "identifier": "1633467", "data": {} }' $CODEFI_API/essentials/token/nonfungible/$ERC721TOKEN_ID/transaction/transfer?userId=$INVESTOR1_ID
Wait for the transaction validation on the blockchain.
Example output
{
...
"message": "Transfer of nonfungible token with identifier 1633467, from investor ed3517df-c9ac-4952-bc53-8ff88457b39c, to investor 72f44a8f-3ded-462d-88a4-b45833e95ea0, has been successfully requested (transaction sent)"
}
Burn ERC721 tokens
Make a POST call to {{CODEFI_API}}/essentials/token/nonfungible/{{token}}/transaction/burn?userId={{investorId1}}
with the following body:
{
"identifier": "1633467",
"data": {
"[OPTIONAL]": "[OPTIONAL] Additional use case specific data"
}
}
Example command
curl --header "Content-Type: application/json" --header "Authorization: Bearer $ADMIN_ACCESS_TOKEN" --request POST --data '{ "identifier": "1633467", "data": {} }' $CODEFI_API/essentials/token/nonfungible/$ERC721TOKEN_ID/transaction/burn?userId=$INVESTOR2_ID
Example output
{
...
"message": "Burn of nonfungible token with identifier 1633467, from investor 72f44a8f-3ded-462d-88a4-b45833e95ea0, has been successfully requested (transaction sent)"
}