ERC-1155 Tokenization Flow
After you deploy an ERC-1155 token project, token administrators and token owners follow a typical flow for creating tokens and completing lifecycle operations.
When you deploy a token project, the users in the list passed to the initialization method become token administrators of the chaincode. After deployment, the typical flow for creating tokens and completing lifecycle operations follows these steps:
Token administrator operations:
- Create user accounts for anyone who will possess tokens or complete token-related operations.
- For each user account, create token accounts. Users can have multiple
fungible token accounts, but only one non-fungible token (NFT) account. Token
administrators can use the
createAccount
method to create user and token accounts simultaneously instead of separately. - Create fungible tokens, as needed. When you initialize a fungible token, you can assign the associated metadata and behaviors to the token.
- For fungible tokens, associate the fungible token accounts of users to specific fungible tokens.
- Add minter and burner roles to the token accounts of users as needed.
Token owner operations:
- Users who have the minter role for a specific token can create (mint) NFTs or fungible tokens.
- Users can transfer tokens between accounts, and check account balances.
- Users who have the burner role for a specific token can destroy (burn) NFTs or fungible tokens.
Vault manager operations:
- The user who has the vault role can lock NFTs. A locked NFT cannot be burned or transferred to other users.
The following diagram shows the overall process flow for an ERC-1155 tokenization
scenario.
The following table summarizes the methods that are automatically generated when you scaffold an ERC-1155 token project.
Method Category | Auto-generated Method (TypeScript) | Auto-generated Method (Go) | Called By | Description |
---|---|---|---|---|
Admin Management | init |
Init |
Admin | Initializes the token chaincode |
isTokenAdmin |
IsTokenAdmin |
Admin | Returns true if the caller is an Admin | |
addTokenAdmin |
AddTokenAdmin |
Admin | Adds an Admin | |
removeTokenAdmin |
RemoveTokenAdmin |
Admin | Removes an Admin | |
getAllTokenAdmins |
GetAllTokenAdmins |
Admin | Returns all Admins | |
Account Management | createAccount |
CreateAccount |
Admin | Creates a user account and token accounts |
createUserAccount |
CreateUserAccount |
Admin | Creates a user account | |
createTokenAccount |
CreateTokenAccount |
Admin | Creates a token account | |
associateFungibleTokenAccount |
AssociateFungibleTokenAccount |
Admin | Associates a fungible token account with a fungible token | |
getAccountHistory |
GetAccountHistory |
Admin / Account Owner | Returns history for a token account | |
getAccountTransactionHistory |
GetAccountTransactionHistory |
Admin / Account Owner | Returns transaction history for an account | |
getAccount |
GetAccount |
Admin / Account Owner | Returns details for a token account | |
getAllAccounts |
GetAllAccounts |
Admin | Returns details for all user accounts | |
getAccountDetailsByUser |
GetAccountDetailsByUser |
Admin / Account Owner | Returns details for a user account and all associated tokens | |
getUserByAccountId |
GetUserByAccountId |
Any user | Returns user details for an account ID | |
Role Management | addRole |
AddRole |
Admin | Adds a role to a user and token |
isInRole |
IsInRole |
Admin / Account Owner | Returns whether a user has a specified role for a token | |
removeRole |
RemoveRole |
Admin | Removes a role from a user and token | |
getAccountsByRole |
GetAccountsByRole |
Admin | Returns account IDs for a specified role and token | |
getUsersByRole |
GetUsersByRole |
Admin | Returns a list of users for a specified role and token | |
Mintable Behavior | mintBatch |
MintBatch |
Users with the minter role | Mints multiple tokens |
Transferable Behavior | batchTransferFrom |
BatchTransferFrom |
Any user | Transfers tokens between users |
safeBatchTransferFrom |
SafeBatchTransferFrom |
Any user | Transfers tokens between the method caller and another user | |
balanceOfBatch |
BalanceOfBatch |
Admin / Account Owner | Returns token account balances for multiple users and tokens | |
exchangeToken |
ExchangeToken |
Account Owner | Exchanges tokens between token accounts | |
Burnable Behavior | burnBatch |
BurnBatch |
Users with the burner role | Burns tokens |
Token Management | create<Token
Name>Token |
Create<Token
Name>Token |
Admin (fungible tokens) / Users with the minter role (NFTs) | Creates tokens |
update<Token
Name>Token |
Update<Token
Name>Token |
Admin (fungible tokens) / Token Owner (NFTs) | Updates tokens | |
getTokenHistory |
GetTokenHistory |
Any user | Returns the history of a token | |
getTransactionById |
GetTransactionById |
Any user | Returns the details of a specified transaction | |
deleteHistoricalTransactions |
DeleteHistoricalTransactions |
Admin | Deletes transactions before a specified time | |
getAllTokens |
GetAllTokens |
Admin | Returns all token assets | |
getTokenById |
GetTokenById |
Admin / Token Owner | Returns a token | |
getAllTokensByUser |
GetAllTokensByUser |
Admin / Account Owner | Returns all tokens owned by a specified user | |
ownerOf |
OwnerOf |
Any user | Returns the user details of the owner of a specified token | |
URI |
URI |
Any user | Returns the URI of a specified token | |
name |
Name |
Any user | Returns the name of a specified token | |
totalSupply |
TotalSupply |
Admin | Returns the number of minted tokens for a specified token | |
totalNetSupply |
TotalNetSupply |
Admin | Returns the number of minted tokens minus the number of burned tokens for a specified token | |
getTokensByName |
getTokensByName |
Admin | Returns all token assets for a specified token name | |
getTokenDecimal |
getTokenDecimal |
Admin | Returns the number of decimal places for a specified token |