Scaffolded Go Project for Token Taxonomy Framework
Blockchain App Builder takes the input from your token specification file and generates a fully-functional scaffolded chaincode project.
The project automatically generates token lifecycle classes and functions, including CRUD and non-CRUD methods. Validation of arguments, marshalling/unmarshalling, and transparent persistence capability are all supported automatically.
For information on the scaffolded project and methods that are not directly related to tokens, see Scaffolded Go Chaincode Project.
Model
Transparent
Persistence Capability, or simplified ORM, is captured in the
OchainModel
class.
package src
type Digicur struct {
AssetType string `json:"AssetType" final:"otoken"`
Token_id string `json:"Token_id" id:"true" mandatory:"true" validate:"regexp=^[A-Za-z0-9][A-Za-z0-9_-]*$,max=16"`
Token_name string `json:"Token_name" final:"digicur"`
Token_desc string `json:"Token_desc" validate:"max=256"`
Token_type string `json:"Token_type" final:"fungible" validate:"regexp=^fungible$"`
Behavior []string `json:"Behavior" final:"[\"divisible\",\"mintable\",\"transferable\",\"burnable\",\"holdable\",\"roles\"]"`
Roles map[string]interface{} `json:"Roles" final:"{\"minter_role_name\":\"minter\",\"burner_role_name\":\"burner\",\"notary_role_name\":\"notary\"}"`
Mintable map[string]interface{} `json:"Mintable" final:"{\"Max_mint_quantity\":20000}"`
Divisible map[string]interface{} `json:"Divisible" final:"{\"Decimal\":1}"`
Token_to_currency_ratio int `json:"Token_to_currency_ratio" validate:"int"`
Currency_representation string `json:"Currency_representation" validate:"string"`
Metadata interface{} `json:"Metadata,omitempty"`
}
Controller
There is only one main controller.
type Controller struct {
Ctx trxcontext.TrxContext
}
You can create any number of classes, functions, or files, but only those methods that are defined within the main controller class are invokable. The other methods are hidden.
You can use the token SDK methods to write custom methods for your business application.
If you use more than one token SDK method in a custom method, do not use methods that will affect the same key-value pairs in the state database.
Instead, use the BulkTransferTokens
method to transfer
to multiple accounts from the caller's account, as shown in the following code
snippet.
BulkTransferTokens(token_id string, flow: []map[string]interface{})
Note:
If you use more than one token SDK method in a custom method that might affect the same key-value pairs in the state database, enable the MVCC optimization for token chaincodes. For more information, see MVCC Optimization.Automatically Generated Token Methods
Blockchain App Builder automatically generates methods to support tokens and token life cycles. You can use these methods to initialize tokens, manage roles and accounts, and complete other token lifecycle tasks without any additional coding. Controller methods must be public to be invokable. Public method names begin with an upper case character. Method names that begin with a lower case character are private.
- Access Control Management
- Token Configuration Management
- Account Management
- Role Management
- Transaction History Management
- Token Behavior Management
Methods for Access Control Management
-
AddTokenAdmin
- This method adds a user as a
Token Admin
of the chaincode. This method can be called only by aToken Admin
of the chaincode. -
RemoveTokenAdmin
- This method removes a user as a
Token Admin
of the chaincode. This method can be called only by aToken Admin
of the chaincode. -
IsTokenAdmin
- This method returns the Boolean value
true
if the caller of the function is aToken Admin
, otherwise it returnsfalse
. AToken Admin
orOrg Admin
can call this function on any other user in the blockchain network. Other users can call this method only on their own accounts. -
GetAllTokenAdmins
- This method returns a list of all users who are a
Token Admin
of the chaincode. This method can be called only by theToken Admin
orOrg Admin
of the chaincode. -
AddOrgAdmin
- This method adds a user as an
Org Admin
of the organization. This method can be called only by aToken Admin
of the chaincode or by anOrg Admin
of the specified organization. -
RemoveOrgAdmin
- This method removes a user as an
Org Admin
of an organization. This method can be called only by aToken Admin
of the chaincode or by anOrg Admin
of the specified organization. -
GetOrgAdmins
- This method returns a list of all users who are an
Org Admin
of an organization. This method can be called only by aToken Admin
of the chaincode or by anyOrg Admin
.
Methods for Token Configuration Management
-
Init
- This method is called when the chaincode is deployed. Every
Token Admin
is identified by theuser_id
andorg_id
information in the mandatoryadminList
parameter. Theuser_id
is the user name or email ID of the instance owner or the user who is logged in to the instance. Theorg_id
is the membership service provider (MSP) ID of the user in the current network organization. -
Initialize<Token Name>Token
- This method creates a token and initializes the token
properties. The asset and its properties are saved in the state database.
This method can be invoked only by a
Token Admin
of the chaincode. -
Update<Token Name>Token
- This method updates token properties. After a token asset is
created, only the
token_desc
property and custom properties can be updated. This method can be called only by aToken Admin
of the chaincode. -
GetTokenDecimals
- This method returns the number of decimal places that were
configured for a fractional token. If the
divisible
behavior was not specified for the token, then the default value is 0. This method can be called only by aToken Admin
orOrg Admin
of the chaincode. -
GetTokenById
- This method returns a token object if it is present in the state
database. This method can be called only by a
Token Admin
orOrg Admin
of the chaincode. -
GetTokenHistory
- This method returns the token history for a specified token ID. Any user can call this method.
-
GetAllTokens
- This method returns all tokens that are stored in the state
database. This method can be called only by a
Token Admin
orOrg Admin
of the chaincode. -
GetTokensByName
- This method returns all token objects with a specified name.
This method can be called only by a
Token Admin
orOrg Admin
of the chaincode. This method uses Berkeley DB SQL rich queries and can only be called when connected to the remote Oracle Blockchain Platform network.
Methods for Account Management
-
CreateAccount
- This method creates an account for a specified user and token.
An account must be created for any user who will have tokens at any point.
Accounts track balances, on-hold balances, and transation history. An
account ID is an alphanumeric set of characters, prefixed with
oaccount~<token asset name>~
and followed by a hash of the user name or email ID (user_id
) of the instance owner or the user who is logged in to the instance, the membership service provider ID (org_id
) of the user in the current network organization. This method can be called only by aToken Admin
of the chaincode or anOrg Admin
of the specified organization. -
AssociateTokenToAccount
- This method associates a fungible token with an account. This
method can be called only by a
Token Admin
of the chaincode or by anOrg Admin
of the relevant organization. -
GetAccount
- This method returns account details for a specified user and
token. This method can be called only by a
Token Admin
of the chaincode, anOrg Admin
of the specified organization, or theAccountOwner
of the account. -
GetAccountHistory
- This method returns account history details for a specified user
and token. This method can be called only by a
Token Admin
of the chaincode or theAccountOwner
of the account. -
GetAccountOnHoldBalance
- This method returns the current on-hold balance for a specified
account and token. This method can be called only by a
Token Admin
of the chaincode, anOrg Admin
of the specified organization, or theAccountOwner
of the account. -
GetAllAccounts
- This method returns a list of all accounts. This method can be
called only by a
Token Admin
of the chaincode. This method uses Berkeley DB SQL rich queries and can only be called when connected to the remote Oracle Blockchain Platform network. -
GetUserByAccountId
- This method returns user details (
org_id
anduser_id
) for a specified account. This method can be called by any user of the chaincode. -
GetAccountBalance
- This method returns the current balance for a specified account
and token. This method can be called only by a
Token Admin
of the chaincode, anOrg Admin
of the specified organization, or theAccountOwner
of the account. -
GetAllOrgAccounts
- This method returns a list of all token accounts that belong to
a specified organization. This method can be called only by a
Token Admin
of the chaincode or by anOrg Admin
of the specified organization.
Methods for Role Management
-
AddRole
- This method adds a role to a specified user and token. This
method can be called only by a
Token Admin
of the chaincode or by anOrg Admin
of the specified organization who also has the specified role. -
RemoveRole
- This method removes a role from a specified user and token. This
method can be called only by a
Token Admin
of the chaincode or anOrg Admin
of the specified organization who also has the specified role. -
GetAccountsByRole
- This method returns a list of all account IDs for a specified
role and token. This method can be called only by a
Token Admin
of the chaincode. -
GetAccountsByUser
- This method returns a list of all account IDs for a specified
organization ID and user ID. This method can be called only by a
Token Admin
of the chaincode, anOrg Admin
of the specified organization, or by theAccount Owner
specified in the parameters. -
GetUsersByRole
- This method returns a list of all users for a specified role and
token. This method can be called only by a
Token Admin
of the chaincode or by theAccount Owner
specified in the parameters. -
IsInRole
- This method returns a Boolean value to indicate if a user and
token has a specified role. This method can be called only by the
Token Admin
of the chaincode, anOrg Admin
of the specified organization, or theAccountOwner
of the account. -
GetOrgUsersByRole
- This method returns information about all users that have a
specified role in a specified organization. This method can be called only
by a
Token Admin
of the chaincode or by anOrg Admin
of the specified organization. -
GetOrgAccountsByRole
- This method returns information about all accounts that have a
specified role in a specified organization. This method can be called only
by a
Token Admin
of the chaincode or by anOrg Admin
of the specified organization.
Methods for Transaction History Management
-
GetAccountTransactionHistory
- This method returns an array of account transaction history
details for a specified user and token. This method can be called only by
the
Token Admin
of the chaincode, anOrg Admin
of the specified organization, or theAccountOwner
of the account. -
GetAccountTransactionHistoryWithFilters
- This method returns an array of account transaction history
details for a specified user and token. This method can be called only by
the
Token Admin
of the chaincode, anOrg Admin
of the specified organization, or theAccountOwner
of the account. This method can only be called when connected to the remote Oracle Blockchain Platform network. -
GetSubTransactionsById
- This method returns an array of subtransaction history details for a specified transaction.
-
GetSubTransactionsByIdWithFilters
- This method returns an array of subtransaction history details for a specified transaction.
-
GetTransactionById
- This method returns the history of a
Transaction
asset. -
DeleteHistoricalTransactions
- This method deletes older transactions from the state database.
Methods for Token Behavior Management - Mintable Behavior
-
IssueTokens
- This method mints tokens, which are then owned by the caller of
the method. The caller must have an account and the minter role. The number
of tokens that can be minted is limited by the
max_mint_quantity
property ofmintable
behavior in the specification file. If themax_mint_quantity
property is not specified, an unlimited number of tokens can be minted. The quantity must be within the decimal values specified by thedecimal
parameter of thedivisible
behavior in the specification file. This method can be called only by theAccountOwner
of the account with the minter role. -
GetTotalMintedTokens
- This method returns the total number of minted tokens for a
specified token. This method can be called only by a
Token Admin
orOrg Admin
of the chaincode. -
GetNetTokens
- This method returns the total net number of tokens available in
the system for a specified token. The net token total is the amount of
tokens remaining after tokens are burned. In equation form net tokens =
total minted tokens - total burned tokens. If no tokens are burned, then the
number of net tokens is equal to the total minted tokens. This method can be
called only by a
Token Admin
orOrg Admin
of the chaincode.
Methods for Token Behavior Management - Transferable Behavior
-
TransferTokens
- This method transfers tokens from the caller to a specified
account. The caller of the method must have an account. The quantity must be
within the decimal values specified by the
decimal
parameter of thedivisible
behavior in the specification file. This method can be called only by theAccountOwner
of the account. -
BulkTransferTokens
- This method is used to perform bulk transfer of tokens from the
caller account to the accounts that are specified in the
flow
object. The quantities must be within the decimal values specified by thedecimal
parameter of thedivisible
behavior in the specification file.The caller of this method must have an account already created. This method can be called only by theAccountOwner
of the account.
Methods for Token Behavior Management - Holdable Behavior
-
HoldTokens
- This method creates a hold on behalf of the owner of the tokens
with the
to_account_id
account. A notary account is specified, which is responsible to either complete or release the hold. When the hold is created, the specified token balance from the payer is put on hold. A held balance cannot be transferred until the hold is either completed or released. The caller of this method must have an account already created. This method can be called only by theAccountOwner
of the account. -
ExecuteHoldTokens
- This method completes a hold on a token. A quantity of tokens
previously held by a token owner is transferred to a receiver. If the
quantity
value is less than the actual hold value, then the remaining amount is available again to the original owner of the tokens. This method can be called only by theAccountOwner
ID with thenotary
role. The hold can only be completed by the notary. -
ReleaseHoldTokens
- This method releases a hold on tokens. The transfer is not
completed and all held tokens are available again to the original owner.
This method can be called by the
Account Owner
ID with thenotary
role within the specified time limit or by the payer, payee, or notary after the specified time limit. -
GetOnHoldIds
- This method returns a list of all of the holding IDs for a
specified account. This method can be called by the
Token Admin
of the chaincode, anOrg Admin
of the specified organization, or theAccount Owner
of the account. -
GetOnHoldDetailsWithOperationId
- This method returns the on-hold transaction details for a specified operation ID and token. This method can be invoked by anyone.
-
GetOnHoldBalanceWithOperationId
- This method returns the on-hold balance for a specified operation ID and token. This method can be invoked by anyone.
Methods for Token Behavior Management - Burnable Behavior
-
BurnTokens
- This method deactivates, or burns, tokens from the transaction
caller's account. The caller of this method must have an account and the
burner role. The quantity must be within the decimal values specified by the
decimal
parameter of thedivisible
behavior in the specification file. This method can be called by theAccount Owner
of the account with the burner role.
Custom Methods
You can use the token SDK methods to write custom methods for your business application.
Make sure to track the return value when you use the token SDK methods.
Also, to avoid double-spending, do not combine multiple async functions that operate
on the same key-value pairs in the state database. Instead, use the
BulkTransferTokens
method, to make multiple transfers in one
method.
The following example shows how to use token SDK methods in custom
methods. When the BuyTicket
method is called, it transfers 20
tokens from the caller's account to the seller's account, and returns the
transaction message of the transfer.
func (t *Controller) BuyTicket(TokenId string, SellerOrgId string, SellerUserId string) (interface{}, error){
token, err := t.Ctx.Token.Get(TokenId)
if err != nil {
return nil, err
}
/**
* The following method t.Ctx.Account.GenerateAccountId(TokenId, SellerOrgId, SellerUserId) generates account id of the seller
*/
sellerAccountId, err := t.Ctx.Account.GenerateAccountId(TokenId, SellerOrgId, SellerUserId)
if err != nil {
return nil, err
}
/**
* The following method t.Ctx.Token.Transfer(sellerAccountId, 20, token) transfers the quantity 20 from caller's
* account & to seller's account.
*/
transaction, err := t.Ctx.Token.Transfer(sellerAccountId, 20, token)
if err != nil {
return nil, err
}
return transaction, nil
}
Token SDK Methods
- Access Control Management
- Token Configuration Management
- Account Management
- Role Management
- Transaction History Management
- Token Behavior Management
Methods for Access Control Management
Token Admin
, Org Admin
or
AccountOwner
of the token. You can use this feature to ensure
that operations are carried out only by the intended users. Any unauthorized access
results in an error. To use the access control function, import the
Authorization
class from the ../lib/auth
module.import { Authorization } from '../lib/auth';
-
AddAdmin
- This method adds a user as a
Token Admin
of the token chaincode. -
RemoveAdmin
- This method removes a user as a
Token Admin
of the token chaincode. -
GetAllAdmins
- This method returns a list of all users who are a
Token Admin
of the token chaincode. -
GetAllAdminUsers
- This method returns a list of all users who are a
Token Admin
of the token chaincode. -
CheckAuthorization
- Use this method to add access control to your chaincode. Many of
the automatically generated token methods use access control. The mapping
between the SDK receiver and the methods which have access control is
described in the
oChainUtil.go
file. To use your own access control or to disable access control, remove the access control code from the automatically generated controller methods and custom methods.var t TokenAccess var r RoleAccess var a AccountAccess var as AccountStatusAccess var h HoldAccess var ad AdminAccess var trx TransactionAccess var tc TokenConversionAccess var auth AuthAccess auth.IsTokenAdmin = []string{"Admin", "MultipleAccountOwner"} trx.DeleteHistoricalTransactions = []string{"Admin"} ad.AddAdmin = []string{"Admin"} ad.RemoveAdmin = []string{"Admin"} ad.GetAllAdmins = []string{"Admin", "OrgAdmin"} ad.AddOrgAdmin = []string{"Admin", "OrgAdminOrgIdCheck"} ad.RemoveOrgAdmin = []string{"Admin", "OrgAdminOrgIdCheck"} ad.GetOrgAdmins = []string{"Admin", "OrgAdmin"} ad.IsTokenAdmin = []string{"Admin", "MultipleAccountOwner", "OrgAdmin"} t.Save = []string{"Admin"} t.GetAllTokens = []string{"Admin", "OrgAdmin"} t.Update = []string{"Admin"} t.GetTokenDecimals = []string{"Admin", "OrgAdmin"} t.GetTokensByName = []string{"Admin", "OrgAdmin"} t.AddRoleMember = []string{"Admin", "OrgAdminRoleCheck"} t.RemoveRoleMember = []string{"Admin", "OrgAdminRoleCheck"} t.IsInRole = []string{"Admin", "OrgAdminAccountIdCheck", "AccountOwner"} t.GetTotalMintedTokens = []string{"Admin", "OrgAdmin"} t.GetNetTokens = []string{"Admin", "OrgAdmin"} t.Get = []string{"Admin", "OrgAdmin"} t.GetTokenHistory = []string{"Admin", "OrgAdmin"} a.CreateAccount = []string{"Admin", "OrgAdminOrgIdCheck"} a.AssociateToken = []string{"Admin", "OrgAdminAccountIdCheck"} a.GetAllAccounts = []string{"Admin"} a.GetAllOrgAccounts = []string{"Admin", "OrgAdminOrgIdCheck"} a.GetAccount = []string{"Admin", "OrgAdminAccountIdCheck", "AccountOwner"} a.History = []string{"Admin", "AccountOwner"} a.GetAccountTransactionHistory = []string{"Admin", "OrgAdminAccountIdCheck", "AccountOwner"} a.GetAccountTransactionHistoryWithFilters = []string{"Admin", "OrgAdminAccountIdCheck", "AccountOwner"} a.GetSubTransactionsById = []string{"Admin", "TransactionInvoker"} a.GetSubTransactionsByIdWithFilters = []string{"Admin", "TransactionInvoker"} a.GetAccountBalance = []string{"Admin", "OrgAdminAccountIdCheck", "AccountOwner"} a.GetAccountOnHoldBalance = []string{"Admin", "OrgAdminAccountIdCheck", "AccountOwner"} a.GetOnHoldIds = []string{"Admin", "OrgAdminAccountIdCheck", "AccountOwner"} a.GetAccountsByUser = []string{"Admin", "OrgAdminOrgIdCheck", "MultipleAccountOwner"} as.Get = []string{"Admin", "OrgAdminAccountIdCheck", "AccountOwner"} as.ActivateAccount = []string{"Admin", "OrgAdminOrgIdCheck"} as.SuspendAccount = []string{"Admin", "OrgAdminOrgIdCheck"} as.DeleteAccount = []string{"Admin", "OrgAdminOrgIdCheck"} r.GetAccountsByRole = []string{"Admin"} r.GetUsersByRole = []string{"Admin"} r.GetOrgAccountsByRole = []string{"Admin", "OrgAdminOrgIdCheck"} r.GetOrgUsersByRole = []string{"Admin", "OrgAdminOrgIdCheck"} tc.InitializeExchangePoolUser = []string{"Admin"} tc.AddConversionRate = []string{"Admin"} tc.UpdateConversionRate = []string{"Admin"} tc.GetConversionRate = []string{"Admin", "OrgAdmin", "AnyAccountOwner"} tc.GetConversionRateHistory = []string{"Admin", "OrgAdmin", "AnyAccountOwner"} tc.TokenConversion = []string{"Admin", "AnyAccountOwner"} tc.GetExchangePoolUser = []string{"Admin"}
-
IsUserTokenAdmin
- This method returns the Boolean value
true
if the caller of the function is aToken Admin
. Otherwise the method returnsfalse
. -
AddOrgAdmin
- This method adds a user as an
Org Admin
of the organization. -
RemoveOrgAdmin
- This method removes a user as an
Org Admin
of an organization. -
GetOrgAdmins
- This method returns a list of all users who are an
Org Admin
of an organization.
Methods for Token Configuration Management
-
GetTokenDecimals
- This method returns the number of decimal places available for a
fractional token. If the
divisible
behavior is not specified, then the default value is 0. -
GetAllTokens
- This method returns all of the token assets that are saved in the state database. This method uses Berkeley DB SQL rich queries and can only be called when connected to the remote Oracle Blockchain Platform network.
-
GetTokensByName
- This method returns all of the token assets with the specified name. This method uses Berkeley DB SQL rich queries and can only be called when connected to the remote Oracle Blockchain Platform network.
-
Get
- This method returns a token object if it is present in the state
database. This method can be called only by a
Token Admin
of the token chaincode. -
IsTokenType
- This method tests whether a token asset exists for a specified token ID.
-
Save
- This method creates a token and saves its properties in the state database.
-
Update
- This method updates token properties. After a token asset is
created, you can update only the
token_desc
value and its custom properties. -
GetByRange
- This method calls the fabric
getStateByRange
method internally. Even though any asset with the given ID is returned from the ledger, this method casts the asset into the caller Asset type. -
History
- This method returns the token history for a specified token ID.
Methods for Account Management
-
GenerateAccountId
- This method returns an account ID, which is an alphanumeric set
of characters, prefixed with
oaccount~<token asset name>~
and followed by a hash of the user name or email ID (user_id
) of the instance owner or the user who is logged in to the instance, the membership service provider ID (org_id
) of the user in the current network organization and the unique token ID (token_id
). -
CreateAccount
- This method creates an account for a specified user and token.
Every user who has tokens at any point must have an account. Accounts track
a user's balance, on-hold balance, and transaction history. An account ID is
an alphanumeric set of characters, prefixed with
oaccount~<token asset name>~
and followed by a hash of the user name or email ID (user_id
) of the instance owner or the user who is logged in to the instance, the membership service provider ID (org_id
) of the user in the current network organization. This method can be called only by theToken Admin
of the chaincode. -
AssociateToken
- This method associates a fungible token with an account. This
method can be called only by a
Token Admin
of the chaincode. -
GetAccountWithStatus
- This method returns account details for a specified account, including account status.
-
GetAccount
- This method returns account details for a specified account.
-
GetAccountHistory
- This method returns an array of the account history details for a specified account.
-
GetAccountOnHoldBalance
- This method returns the on-hold balance for a specified account.
-
GetAllAccounts
- This method returns a list of all accounts. This method uses Berkeley DB SQL rich queries and can only be called when connected to the remote Oracle Blockchain Platform network.
-
GetUserByAccountId
- This method returns the user details for a specified account.
-
GetAccountBalance
- This method returns the account balance for a specified account.
-
GetAllOrgAccounts
- This method returns a list of all token accounts that belong to a specified organization.
Methods for Role Management
-
AddRoleMember
- This method adds a role to a specified user and token.
-
RemoveRoleMember
- This method removes a role from a specified user and token.
-
GetAccountsByRole
- This method returns a list of all accounts for a specified role and token.
-
GetUsersByRole
- This method returns a list of all users for a specified role and token.
-
IsInRole
- This method indicates whether a user and token has a specified role.
-
RoleCheck
- This method checks if the provided account ID is a member of any role.
-
GetOrgUsersByRole
- This method returns information about all users that have a specified role in a specified organization.
-
GetOrgAccountsByRole
- This method returns information about all accounts that have a specified role in a specified organization.
Methods for Transaction History Management
-
GetAccountTransactionHistory
- This method returns an array of the transaction history details for a specified account.
-
GetAccountTransactionHistoryWithFilters
- This method returns an array of the transaction history details for a specified transaction. This method can only be called when connected to the remote Oracle Blockchain Platform network.
-
GetSubTransactionsById
- This method returns an array of the transaction history details for a specified transaction.
-
GetSubTransactionsByIdWithFilters
- This method returns an array of the transaction history details for a specified transaction.
-
GetTransactionById
- This method returns the history of a
Transaction
asset. -
DeleteHistoricalTransactions
- This method deletes older transactions from the state database.
Methods for Token Behavior Management - Mintable Behavior
-
Mint
- This method mints tokens, which are then owned by the caller of
the method. The caller must have an account and the minter role. The number
of tokens that can be minted is limited by the
max_mint_quantity
property ofmintable
behavior in the specification file. If themax_mint_quantity
property is not specified, an unlimited number of tokens can be minted. The quantity must be within the decimal values specified by thedecimal
parameter of thedivisible
behavior in the specification file. This method can be called only by theAccountOwner
of the account with the minter role. -
GetTotalMintedTokens
- This method returns the total number of tokens minted.
-
GetNetTokens
- This method returns the net quantity of tokens that are available in the system for a specified token. The net tokens are the amount of tokens remaining after tokens are burned. In equation form: net tokens = total minted tokens - total burned tokens. If no tokens are burned, then the number of net tokens is equal to the total minted tokens.
-
GetMaxMintQuantity
- This method returns the maximum mintable quantity for a token.
If the
max_mint_quantity
behavior is not specified, then the default value is 0, which allows any number of tokens to be minted.
Methods for Token Behavior Management - Transferable Behavior
-
Transfer
- This method transfers tokens from the caller to a specified
account. The caller of the method must have an account. The quantity must be
within the decimal values specified by the
decimal
parameter of thedivisible
behavior in the specification file. This method can be called only by theAccountOwner
of the account. -
BulkTransfer
- This method is used to perform bulk transfer of tokens from the
caller account to the accounts that are specified in the
flow
object. The caller of this method must have an account already created.
Methods for Token Behavior Management - Holdable Behavior
-
Hold
- This method creates a hold on behalf of the owner of the tokens
with the
to_account_id
account. A notary account is specified, which is responsible to either complete or release the hold. When the hold is created, the specified token balance from the payer is put on hold. A held balance cannot be transferred until the hold is either completed or released. The caller of this method must have an account already created. -
ExecuteHold
- This method completes a hold on tokens, transferring the
specified quantity of tokens previously on hold to the receiver. If the
quantity
value is less than the actual hold value, then the remaining amount is available again to the original owner of the tokens. This method can be called only by theAccountOwner
ID with thenotary
role. -
ReleaseHold
- This method releases a hold on tokens. The transfer is not
completed and all held tokens are available again to the original owner.
This method can be called by the
Account Owner
ID with thenotary
role within the specified time limit or by the payer, payee, or notary after the specified time limit. -
GetOnHoldIds
- This method returns a list of all the holding IDs for a specified user and token.
-
GetOnHoldDetailsWithOperationID
- This method returns the on-hold transaction details for a specified operation ID and token..
-
GetOnHoldBalanceWithOperationID
- This method returns the on-hold balance for a specified operation ID and token..
Methods for Token Behavior Management - Burnable Behavior