Pre-General Availability: 2026-03-13

Solidity Smart Contract API

Oracle Blockchain Platform Enterprise Edition for Hyperledger Besu provides Solidity methods that you can use to work with Solidity smart contracts.

The API supports tokens based on the ERC-20 standard and the ERC-1155 standard. The ERC-20 and ERC-1155 implementations comprise an account smart contract and a token smart contract. The account smart contract provides identity and access control methods. The token smart contract provides functions specifically related to tokens.

ERC-20 Account Contract Methods

Methods for Account Management

createAccount
This method creates an account for a specified user. Accounts track a user's token balance and on-hold balance, and must be created for all users who will have tokens at any point. This method can be called only by a Token Admin or an Org Admin of the specified organization.
Parameters:
  • userId: string – The user name or email ID of the user. The user ID string cannot be empty.
  • orgId: string – The membership service provider (MSP) ID of the user in the current organization. The organization ID cannot be empty.
  • userAddress: address – The wallet address of the user. The address cannot be zero.
  • maxDailyAmount: int256 – The maximum amount of tokens that can be used in transactions daily. If maxDailyAmount is -1, there is no limit.
  • maxDailyTransactions: int256 – The maximum number of transactions that can be completed daily. If maxDailyTransactions is -1, there is no limit.
deleteAccount
This method deletes the account of a specified user. An account can be deleted only if the token balance is zero. This method can be called only by a Token Admin or an Org Admin of the specified organization.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
getAccountStatus
This method gets the current status of the specified account. This method can be called only by a Token Admin, Token Auditor, Org Admin of the specified organization, or by the specified user.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
Returns:
  • A value for the enum AccountStatus object, 0, 1, or 2.
    enum AccountStatus {
    active,
    suspended,
    deleted
    }
getAccountByAddress
This method gets the account information for a specified user. This method can be called only by a Token Admin, Token Auditor, Org Admin of the specified organization, or by the specified user.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
Return Value Example:
{
    "userId": "userA",
    "orgId": "orgA",
	"accountAddress": "0x0fbdc686b912d7722dc86510934589e0aaf3b55a",
    "dailyLimits": {
          "isMaxDailyTxnEnabled": true,
    	  "isMaxDailyAmtEnabled": true, 
		  "dailyAmount": 100,
    	  "dailyTransactions": 5,
		  "maxDailyAmount": 100000,
    	  "maxDailyTransactions": 50           
	},
	"status":0
}
getAllAccounts
This method gets the account information for all accounts that fall in a specified range. This method can be called only by a Token Admin or Token Auditor.
Parameters:
  • offset: uint256 – The offset index to get the accounts from.
  • limit: uint256 – The number of items to retrieve.
Return Value Example:
Return (UserAccount[] memory items, uint256 total, uint256 nextOffset)
[{
    "userId": "userA",
    "orgId": "orgA",
	"accountAddress": "0x0fbdc686b912d7722dc86510934589e0aaf3b55a",
    "dailyLimits": {
          "isMaxDailyTxnEnabled": true,
    	  "isMaxDailyAmtEnabled": true, 
		  "dailyAmount": 100,
    	  "dailyTransactions": 5,
		  "maxDailyAmount": 100000,
    	  "maxDailyTransactions": 50           
	},
	"status":0
}]
total: 15
nextoffset: 6
activateAccount
This method activates a user account. This method can be called only by a Token Admin or Org Admin of the specified organization.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
suspendAccount
This method suspends a user account. To delete an account, the account balance must be zero. This method can be called only by a Token Admin or Org Admin of the specified organization.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
setMaxDailyAmount
This method sets the maximum amount of tokens that can be used in transactions daily. This method can be called only by a Token Admin or Org Admin of the specified organization.
Parameters:
  • count: int256 – The maximum amount of tokens that can be used in transactions daily.
  • userAddress: address – The wallet address of the user. The address cannot be zero.
setMaxDailyTransactionCount
This method sets the maximum number of transactions that can be completed daily. This method can be called only by a Token Admin or Org Admin of the specified organization.
Parameters:
  • value: int256 – The maximum number of transactions that can be completed daily.
  • userAddress: address – The wallet address of the user. The address cannot be zero.

Methods for Administrator Management

addTokenAdmin
This method adds a user as a Token Admin. This method can be called only by a Token Admin.
Parameters:
  • adminDetails: JSON – An object that contains details about the user to add as a Token Admin, as shown in the following example.
    {
        "userId": "tokenAdmin1",
        "orgId": "orgA",
    	"accountAddress": "0x0fbdc686b912d7722dc86510934589e0aaf3b55a"    
    }
removeTokenAdmin
This method removes a user as a Token Admin. This method can be called only by a Token Admin.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
getAllTokenAdmins
This method returns a list of all users who are a Token Admin. This method can be called only by the Token Admin or Token Auditor.
Parameters:
  • none
Return Value Example:
[{
    "userId": "tokenadmin1",
    "orgId": "orgA",
	"accountAddress": "0x0fbdc686b912d7722dc86510934589e0aaf3b55a"
},
{
    "userId": "tokenadmin2",
    "orgId": "orgB",
	"accountAddress": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"
}]
isTokenAdmin
This method checks whether the specified user is a Token Admin. This method can be called only by a Token Admin, Token Auditor, Org Admin, or Org Auditor.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
Returns:
  • The method returns true if the specified user is a Token Admin, otherwise it returns false.
addOrgAdmin
This method adds a user as a Org Admin. This method can be called only by a Token Admin or Org Admin of the specified organization.
Parameters:
  • adminDetails: JSON – An object that contains details about the user to add as an Org Admin, as shown in the following example.
    {
        "userId": "tokenAdmin1",
        "orgId": "orgA",
    	"accountAddress": "0x0fbdc686b912d7722dc86510934589e0aaf3b55a"    
    }
removeOrgAdmin
This method removes a user as an Org Admin. This method can be called only by a Token Admin or Org Admin of the specified organization.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
getAllOrgAdmins
This method returns a list of all users who are an Org Admin. This method can be called only by the Token Admin, Token Auditor, Org Admin, or Org Auditor.
Parameters:
  • none
Return Value Example:
[{
    "userId": "orgadmin1",
    "orgId": "orgA",
	"accountAddress": "0x0fbdc686b912d7722dc86510934589e0aaf3b55a"
},
{
    "userId": "orgadmin2",
    "orgId": "orgB",
	"accountAddress": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"
}]
isOrgAdmin
This method checks whether the specified user is an Org Admin. This method can be called only by a Token Admin, Token Auditor, Org Admin, or Org Auditor.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
Returns:
  • The method returns true if the specified user is a Org Admin, otherwise it returns false.

Methods for Auditor Management

addTokenAuditor
This method adds a user as a Token Auditor. This method can be called only by a Token Admin.
Parameters:
  • adminDetails: JSON – An object that contains details about the user to add as a Token Auditor, as shown in the following example.
    {
        "userId": "tokenAuditor1",
        "orgId": "orgA",
    	"accountAddress": "0x0fbdc686b912d7722dc86510934589e0aaf3b55a"    
    }
removeTokenAuditor
This method removes a user as a Token Auditor. This method can be called only by a Token Admin.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
getAllTokenAuditors
This method returns a list of all users who are a Token Auditor. This method can be called only by the Token Admin or Token Auditor.
Parameters:
  • none
Return Value Example:
[{
    "userId": "tokenAuditor1",
    "orgId": "orgA",
	"accountAddress": "0x0fbdc686b912d7722dc86510934589e0aaf3b55a"
},
{
    "userId": "tokenAuditor2",
    "orgId": "orgB",
	"accountAddress": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"
}]
isTokenAuditor
This method checks whether the specified user is a Token Auditor. This method can be called by any user.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
Returns:
  • The method returns true if the specified user is a Token Auditor, otherwise it returns false.
addOrgAuditor
This method adds a user as a Org Auditor. This method can be called only by a Token Admin or Org Admin of the specified organization.
Parameters:
  • adminDetails: JSON – An object that contains details about the user to add as an Org Auditor, as shown in the following example.
    {
        "userId": "tokenAuditor1",
        "orgId": "orgA",
    	"accountAddress": "0x0fbdc686b912d7722dc86510934589e0aaf3b55a"    
    }
removeOrgAuditor
This method removes a user as an Org Auditor. This method can be called only by a Token Admin or Org Admin of the specified organization.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
getAllOrgAuditors
This method returns a list of all users who are an Org Auditor. This method can be called only by the Token Admin, Token Auditor, Org Admin, or Org Auditor.
Parameters:
  • none
Return Value Example:
[{
    "userId": "orgAuditor1",
    "orgId": "orgA",
	"accountAddress": "0x0fbdc686b912d7722dc86510934589e0aaf3b55a"
},
{
    "userId": "orgAuditor2",
    "orgId": "orgB",
	"accountAddress": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"
}]
isOrgAuditor
This method checks whether the specified user is an Org Auditor. This method can be called by any user.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
Returns:
  • The method returns true if the specified user is a Org Auditor, otherwise it returns false.

Methods for Role Management

addRole
This method adds a role to a specified user. This method can be called only by a Token Admin or Org Admin of the specified organization.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
  • role: string – The name of the role to add to the specified user. For example, minter, burner, or notary.
removeRole
This method removes a role from a specified user. This method can be called only by a Token Admin or Org Admin of the specified organization.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
  • role: string – The name of the role to remove from the specified user. For example, minter, burner, or notary.
accountHasRole
This method checks whether a user has a specified role. This method can be called by any user.
Parameters:
  • role: string – The Keccak-256 hash of the name of the role (minter, burner, or notary) to search for.
  • userAddress: address – The wallet address of the user. The address cannot be zero.
Returns:
  • The method returns true if the user has the specified role, otherwise it returns false.

ERC-20 Token Contract Methods

Methods for Token Configuration Management

__ERC20Token_init
This method is called when the token contract is deployed. This method can be called only by a Token Admin.
Parameters:
  • name: string – The name of the token.
  • symbol: string – The symbol of the token.
  • accountContract: address – The address of the account contract.
initializeERC20Token
This method initializes an ERC-20 token. This method can be called only by a Token Admin.
Parameters:
  • token: JSON – An object that defines the token, as shown in the following example.
    {
        "tokenId": "WCBDC-100",
        "tokenName": "wholesale cbdc",
        "tokenDesc": "this is wcbdc contract",
        "tokenStandard": "ttf+",
        "tokenType": "fungible",
        "tokenUnit": "fractional",
        "behaviors": ["mintable", "burnable", "transferable", "roles", "holdable", "pausable"],
        "decimals": 2,
        "mintable": { "maxMintQuantity": 1000000, "mintApprovalRequired": false },
        "burnable": { "burnApprovalRequired": false }
    }
getToken
This method gets details for a token. This method can be called only by a Token Admin, Token Auditor, Org Admin, or Org Auditor.
Parameters:
  • none
Return Value Example:
{
    "tokenId": "WCBDC-100",
    "tokenName": "wholesale cbdc",
    "tokenDesc": "this is wcbdc contract",
    "tokenStandard": "ttf+",
    "tokenType": "fungible",
    "tokenUnit": "fractional",
    "behaviors": ["mintable", "burnable", "transferable", "roles", "holdable", "pausable"],
    "decimals": 2,
    "mintable": { "maxMintQuantity": 1000000, "mintApprovalRequired": false },
    "burnable": { "burnApprovalRequired": false }
}
decimals
This method gets the decimal value for a token. This method can be called only by a Token Admin, Token Auditor, Org Admin, or Org Auditor.
Parameters:
  • none
Returns
  • A uint8 value of the number of decimal places.
__ERC20Token_init
This method is called when token contract is deployed. This method can be called only by a Token Admin.
Parameters:
  • name: string – The name of the token.
  • symbol: string – The symbol of the token.
  • accountContract: address – The address of the account contract.
initializeERC20Token
This method initializes an ERC-20 token. This method can be called only by a Token Admin.
Parameters:
  • token: JSON – An object that defines the token, as shown in the following example.
    {
        "tokenId": "WCBDC-100",
        "tokenName": "wholesale cbdc",
        "tokenDesc": "this is wcbdc contract",
        "tokenStandard": "ttf+",
        "tokenType": "fungible",
        "tokenUnit": "fractional",
        "behaviors": ["mintable", "burnable", "transferable", "roles", "holdable", "pausable"],
        "decimals": 2,
        "mintable": { "maxMintQuantity": 1000000, "mintApprovalRequired": false },
        "burnable": { "burnApprovalRequired": false }
    }
getToken
This method gets details for a token. This method can be called only by a Token Admin, Token Auditor, Org Admin, or Org Auditor.
Parameters:
  • none
Return Value Example:
{
    "tokenId": "WCBDC-100",
    "tokenName": "wholesale cbdc",
    "tokenDesc": "this is wcbdc contract",
    "tokenStandard": "ttf+",
    "tokenType": "fungible",
    "tokenUnit": "fractional",
    "behaviors": ["mintable", "burnable", "transferable", "roles", "holdable", "pausable"],
    "decimals": 2,
    "mintable": { "maxMintQuantity": 1000000, "mintApprovalRequired": false },
    "burnable": { "burnApprovalRequired": false }
}
cap
This method gets the maximum token supply (cap). This method can be called only by a Token Admin, Token Auditor, Org Admin, or Org Auditor.
Parameters:
  • none
Returns
  • A uint256 value of the token supply cap.
balanceOf
This method gets the token balance for the specified user. This method can be called only by a Token Admin, Token Auditor, Org Admin, Org Auditor, or by the specified user.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
Returns
  • A uint256 value of the token balance.
Token Behavior Management - Mintable Behavior
mint
This method creates (mints) tokens. This method can be called by any user with the minter role.
Parameters:
  • to: address – The wallet address of the user. The address cannot be zero.
  • value: uint256 – The quantity of tokens to mint.
batchMint
This method creates (mints) tokens for more than one user at a time. This method can be called by any user with the minter role.
Parameters:
  • toList: address[] – The list of wallet addresses of the users. The addresses cannot be zero.
  • amounts: uint256[] – The list of quantities of tokens to mint.
requestMint
This method can be called by a minter to send a request to the notary to create a specified amount of tokens.
Parameters:
  • notary: address – The wallet address of the notary. The address cannot be zero.
  • amount: uint256 – The quantity of tokens to mint.
  • expiration: uint256 – The expiration time for the request in epoch format.
  • opId: string – The operation ID of the request.
  • info: InfoDetails – An object specifying the category (category) and description (description) of the request.
approveMint
This method can be called by a notary to approve a minting request.
Parameters:
  • opId: string – The operation ID of the request.
rejectMint
This method can be called by a notary to reject a minting request.
Parameters:
  • opId: string – The operation ID of the request.

Token Behavior Management - Burnable Behavior

burn
This method deactivates (burns) tokens. This method can be called by any user with the burner role.
Parameters:
  • account: address – The wallet address of the user. The address cannot be zero.
  • value: uint256 – The quantity of tokens to burn.
batchBurn
This method burns tokens for more than one user at a time. This method can be called by any user with the burner role.
Parameters:
  • toList: address[] – The list of wallet addresses of the users. The addresses cannot be zero.
  • amounts: uint256[] – The list of quantities of tokens to burn.
requestBurn
This method can be called by a burner to send a request to the notary to burn a specified amount of tokens.
Parameters:
  • notary: address – The wallet address of the notary. The address cannot be zero.
  • amount: uint256 – The quantity of tokens to burn.
  • expiration: uint256 – The expiration time for the request in epoch format.
  • opId: string – The operation ID of the request.
  • info: InfoDetails – An object specifying the category (category) and description (description) of the request.
approveBurn
This method can be called by a notary to approve a burning request.
Parameters:
  • opId: string – The operation ID of the request.
rejectBurn
This method can be called by a notary to reject a burning request.
Parameters:
  • opId: string – The operation ID of the request.

Token Behavior Management - Transferable Behavior

transfer
This method transfers tokens to a specified user. This method can be called by any user with tokens.
Parameters:
  • to: address – The wallet address of the receiver. The address cannot be zero.
  • value: uint256 – The quantity of tokens to transfer.
batchTransfer
This method transfers tokens to a specified list of users. This method can be called by any user with tokens.
Parameters:
  • toList: address[] – The list of wallet addresses of the receivers. The addresses cannot be zero.
  • amounts: uint256[] – The list of quantities of tokens to transfer.

Token Behavior Management - Delegable Behavior

allowance
This method delegates token spending to a specified user. This method can be called by any user with tokens.
Parameters:
  • owner: address – The wallet address of the owner who is delegating the spending of tokens. The address cannot be zero.
  • spender: address – The wallet address of the token spender. The address cannot be zero.
Returns
  • A uint256 amount of the tokens that were delegated for spending.
approve
This method approves the amount of tokens for a specified delegated spender. This method can be called by any user with tokens.
Parameters:
  • spender: address – The wallet address of the token spender. The address cannot be zero.
  • value: uint256 – The quantity of tokens the spender is allowed to spend.
transferFrom
Delegated spenders use this method to transfer tokens.
Parameters:
  • from: address – The wallet address of the sender. The address cannot be zero.
  • to: address – The wallet address of the receiver. The address cannot be zero.
  • value: uint256 – The quantity of tokens to transfer.

Token Behavior Management - Pausable Behavior

isPaused
This method checks whether the contract is paused. This method can be called only by a Token Admin, Token Auditor, Org Admin, or Org Auditor.
Parameters:
  • none
pause
This method pauses the contract. This method can be called only by a Token Admin.
Parameters:
  • none
unpause
This method resumes the contract. This method can be called only by a Token Admin.
Parameters:
  • none

Token Behavior Management - Holdable Behavior

hold
This method creates a hold on behalf of the token owner. This method can be called by any user with tokens.
Parameters:
  • to: address – The wallet address of the receiver. The address cannot be zero.
  • notary: address – The wallet address of the notary. The address cannot be zero.
  • amount: uint256 – The quantity of tokens to transfer.
  • expiration: uint256 – The expiration time for the request in epoch format.
  • opId: string – The operation ID of the request.
  • holdType: string – The type of hold. For example, transfer.
  • info: InfoDetails – An object specifying the category (category) and description (description) of the request.
executeHold
This method approves a hold request. This method can be called only by the previously specified notary.
Parameters:
  • amount: uint256 – The quantity of tokens to approve.
  • opId: string – The operation ID of the request.
releaseHold
This method rejects a hold request. This method can be called only by the previously specified notary.
Parameters:
  • opId: string – The operation ID of the request.
getOnHoldBalanceWithOperationId
This method returns the on-hold balance for a specified operation ID. This method can be called by a Token Admin or Token Auditor, Org Admin or Org Auditor of the specified organization, or by a transaction participant (sender, recipient, notary).
Parameters:
  • opId: string – The operation ID of the request.
Returns
  • A uint256 amount of the on-hold balance.
getAccountOnHoldBalance
This method returns the on-hold balance for a specified account. This method can be called by a Token Admin or Token Auditor, Org Admin or Org Auditor of the specified organization, or by a transaction participant (sender, recipient, notary).
Parameters:
  • account: address – The wallet address of the account. The address cannot be zero.
Returns
  • A uint256 amount of the on-hold balance.

ERC-1155 Account Contract Methods

Methods for Account Management

createAccount
This method creates an account for a specified user. Accounts track a user's token balance, and must be created for all users who will have tokens at any point. This method can be called only by a Token Admin.
Parameters:
  • userId: string – The user name or email ID of the user. The user ID string cannot be empty.
  • orgId: string – The membership service provider (MSP) ID of the user in the current organization. The organization ID cannot be empty.
  • userAddress: address – The wallet address of the user. The address cannot be zero.
deleteAccount
This method deletes the account of a specified user. An account can be deleted only if the token balance is zero. This method can be called only by a Token Admin.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
getAccountStatus
This method gets the current status of the specified account. This method can be called only by a Token Admin or by the specified user.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
Returns:
  • A value for the enum AccountStatus object, 0, 1, or 2.
    enum AccountStatus {
    active,
    suspended,
    deleted
    }
getAccountByAddress
This method gets the account information for a specified user. This method can be called only by a Token Admin or by the specified user.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
Return Value Example:
{
    "userId": "userA",
    "orgId": "orgA",
	"accountAddress": "0x0fbdc686b912d7722dc86510934589e0aaf3b55a",
	"status":0
}
getAllAccounts
This method gets the account information for all accounts that fall in a specified range. This method can be called only by a Token Admin.
Parameters:
  • offset: uint256 – The offset index to get the accounts from.
  • limit: uint256 – The number of items to retrieve.
Return Value Example:
Return (UserAccount[] memory items, uint256 total, uint256 nextOffset)
[{
    "userId": "userA",
    "orgId": "orgA",
	"accountAddress": "0x0fbdc686b912d7722dc86510934589e0aaf3b55a",
	"status":0
}]
total: 15
nextoffset: 6
activateAccount
This method activates a user account. This method can be called only by a Token Admin.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
suspendAccount
This method suspends a user account. To delete an account, the account balance must be zero. This method can be called only by a Token Admin.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.

Methods for Administrator Management

addTokenAdmin
This method adds a user as a Token Admin. This method can be called only by a Token Admin.
Parameters:
  • adminDetails: JSON – An object that contains details about the user to add as a Token Admin, as shown in the following example.
    {
        "userId": "tokenAdmin1",
        "orgId": "orgA",
    	"accountAddress": "0x0fbdc686b912d7722dc86510934589e0aaf3b55a"    
    }
removeTokenAdmin
This method removes a user as a Token Admin. This method can be called only by a Token Admin.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
getAllTokenAdmins
This method returns a list of all users who are a Token Admin. This method can be called only by the Token Admin.
Parameters:
  • none
Return Value Example:
[{
    "userId": "tokenadmin1",
    "orgId": "orgA",
	"accountAddress": "0x0fbdc686b912d7722dc86510934589e0aaf3b55a"
},
{
    "userId": "tokenadmin2",
    "orgId": "orgB",
	"accountAddress": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"
}]
isTokenAdmin
This method checks whether the specified user is a Token Admin. This method can be called only by a Token Admin.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
Returns:
  • The method returns true if the specified user is a Token Admin, otherwise it returns false.

Methods for Role Management

addRole
This method adds a role to a specified user. This method can be called only by a Token Admin.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
  • role: string – The name of the role to add to the specified user. For example, minter, burner, or notary.
  • scopeId: uint256 – The non-fungible token (NFT) class ID or the fungible token ID.
removeRole
This method removes a role from a specified user. This method can be called only by a Token Admin or Org Admin of the specified organization.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
  • role: string – The name of the role to remove from the specified user. For example, minter, burner, or notary.
  • scopeId: uint256 – The non-fungible token (NFT) class ID or the fungible token ID.
accountHasRole
This method checks whether a user has a specified role. This method can be called by any user.
Parameters:
  • role: string – The Keccak-256 hash of the name of the role (minter, burner, or notary) to search for.
  • userAddress: address – The wallet address of the user. The address cannot be zero.
  • scopeId: uint256 – The non-fungible token (NFT) class ID or the fungible token ID.
Returns:
  • The method returns true if the user has the specified role, otherwise it returns false.
addTokenSysRole
This method adds the TOKEN_SYS_VAULT_ROLE role to a specified user. This method can be called only by a Token Admin.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
  • role: string – The only supported role is TOKEN_SYS_VAULT_ROLE.
Returns:
  • The method returns true if the role was added successfully, otherwise it returns false.
removeTokenSysRole
This method removes the TOKEN_SYS_VAULT_ROLE role from a specified user. This method can be called only by a Token Admin.
Parameters:
  • userAddress: address – The wallet address of the user. The address cannot be zero.
  • role: string – The only supported role is TOKEN_SYS_VAULT_ROLE.
Returns:
  • The method returns true if the role was removed successfully, otherwise it returns false.
transferTokenSysRole
This method transfers the TOKEN_SYS_VAULT_ROLE role from one user to another. This method can be called only by a Token Admin.
Parameters:
  • fromAddress: address – The wallet address of the sender. The address cannot be zero.
  • toAddress: address – The wallet address of the receiver. The address cannot be zero.
  • role: string – The only supported role is TOKEN_SYS_VAULT_ROLE.
Returns:
  • The method returns true if the role was tramsferred successfully, otherwise it returns false.

ERC-1155 Token Contract Methods

Methods for Token Configuration Management

__ERC1155Token_init
This method is called when the token contract is deployed. This method can be called only by a Token Admin.
Parameters:
  • accountContract: address – The address of the account contract.
  • uri: string – The token type URI.
saveNFTClass
This method saves NFT class information to the ledger. This method can be called only by a Token Admin.
Parameters:
  • classinfo: JSON – The NFT account class information object. The following code shows an example for a whole NFT.
    {
        "nftClassId": (BigInt(1)),
        "tokenName": "ArtCollection2",
        "tokenDesc": "this is art collection contract",
        "tokenStandard": "erc1155",
        "tokenUnit": 0,
        "behaviors": ["mintable", "burnable", "transferable", "roles", "indivisible"],
        "divisible": { "decimals": 0 },
        "mintable": { "maxMintQuantity": 2 }
    }
    The following code shows an example for a fractional NFT.
    {
      "nftClassId": (BigInt(0)),
      "tokenName": "ArtCollection",
      "tokenDesc": "this is art collection contract",
      "tokenStandard": "erc1155",
      "tokenUnit": 1,
      "behaviors": ["mintable", "burnable", "transferable", "roles", "divisible"],
      "divisible": { "decimals": 0 },
      "mintable": { "maxMintQuantity": 1 }
    }
createNonFungibleToken
This method mints NFTs. This method can be called only by a user with the minter role.
Parameters:
  • tokenId: uint256 – The token ID of the NFT, which contains NFT class information. The top 128 bits of the ID represent the NFT class ID and the bottom 128 bits represent the unique index of the NFT.
  • quantity: uint256 – The amount of NFTs to mint (create).
createFungibleToken
This method is called when the token contract is deployed. This method can be called only by a Token Admin.
Parameters:
  • token – The fungible token definition to record in the ledger, as shown in the following example.
     "tokenId": BigInt(0),
     "tokenName": "wcbdc",
     "tokenDesc": "this is wcbdc token",
     "tokenStandard": "erc1155",
     "tokenType": 1,
     "tokenUnit": 1,
     "behaviors": ["mintable", "burnable", "transferable", "roles", "divisible"],
     "divisible": { "decimals": 2 },
     "quantity": 1,
     "mintable": { "maxMintQuantity": 1 }
getTokenById
This method gets details for a token. This method can be called only by a Token Admin or token owner.
Parameters:
  • token – The fungible token definition, as shown in the following example.
     "tokenId": BigInt(0),
     "tokenName": "wcbdc",
     "tokenDesc": "this is wcbdc token",
     "tokenStandard": "erc1155",
     "tokenType": 1,
     "tokenUnit": 1,
     "behaviors": ["mintable", "burnable", "transferable", "roles", "divisible"],
     "divisible": { "decimals": 2 },
     "quantity": 1,
     "mintable": { "maxMintQuantity": 1 }
  • metaInfo: bytes – If the token is fungible, specify an empty value. If the token is a whole NFT, specify an encoded version of the following struct object.
    struct ERC1155WholeNFT {
        bool isBurned;
        bool isLocked;
        uint256 creationDate;
        uint256 quantity;
        address createdBy;
        address owner;
    }
    If the token is a fractional NFT, specify an encoded version of the following struct object.
    struct ERC1155FractionalNFT {
        bool isBurned;
        bool isLocked;
        uint256 creationDate;
        uint256 quantity;
        address createdBy;
        Owners[] owners;
    }
geTokenDecimals
This method gets the decimal value for a token. This method can be called only by a Token Admin.
Parameters:
  • id: uint256 – The token ID.
Returns
  • A uint8 value of the number of decimal places.
tokenIdOf
This method gets the ID of a token. This method can be called only by a Token Admin.
Parameters:
  • classId: uint256 – The NFT class ID.
  • serialId: uint256 – The serial ID in the NFT class.
Returns
  • A uint256 token ID.
balanceOf
This method gets the token balance for the specified user. This method can be called only by a Token Admin or by the token owner.
Parameters:
  • account: address – The wallet address of the user. The address cannot be zero.
  • id: uint256 – The token ID.
Returns
  • A uint256 value of the token balance.
balanceOfBatch
This method gets the token balance for a list of users. This method can be called only by a Token Admin or by the token owner.
Parameters:
  • account: address[] – A list of the wallet addresses of users.
  • id: uint256[] – A list of token IDs.
Returns
  • A uint256[] list of token balances.
exists
This method checks whether a specified token exists. This method can be called only by a Token Admin.
Parameters:
  • id: uint256 – A token ID.
Returns:
  • The method returns true if the specified token exists, otherwise it returns false.
totalSupply
This method checks gets the total supply of all tokens in the contract. This method can be called only by a Token Admin.
Parameters:
  • none
Returns:
  • A uint256[] value of the total token supply.
totalSupply
This method checks gets the total supply of a specified token in the contract. This method can be called only by a Token Admin.
Parameters:
  • id: uint256 – A token ID.
Returns:
  • A uint256[] value of the total supply of the specified token.
Token Behavior Management - Mintable Behavior
mintBatch
This method creates (mints) ERC-1155 tokens in batch mode. The tokens must be initialized. This method can be called by any user with the minter role.
Parameters:
  • tokenIds: uint256[] – The list of tokens to mint.
  • quantity: uint256[] – The list of token quantities to mint.
  • data: byte – Additional bytes of data.

Token Behavior Management - Burnable Behavior

burnBatch
This method destroys (burns) ERC-1155 tokens in batch mode. The tokens must be initialized. This method can be called by any user with the burner role.
Parameters:
  • tokenIds: uint256[] – The list of tokens to burn.
  • quantity: uint256[] – The list of token quantities to burn.
  • data: byte – Additional bytes of data.
burnNFT
This method destroys (burns) a non-fungible token. The tokens must be initialized. This method can be called by any user with the burner role.
Parameters:
  • tokenId: uint256 – The ID of the token to burn.

Token Behavior Management - Transferable Behavior

safeTransferFrom
This method transfers tokens from a sender to a receiver. This method can be called by any user who holds tokens.
Parameters:
  • from: address – The wallet address of the sender. The address cannot be zero.
  • to: address – The wallet address of the receiver. The address cannot be zero.
  • id: uint256 – The ID of the ERC-1155 token to transfer.
  • value: uint256 – The amount of tokens to transfer.
  • data: byte – Additional bytes of data.
safeBatchTransferFrom
This method transfers tokens from a sender to a receiver. This method can be called by any user who holds tokens.
Parameters:
  • from: address – The wallet address of the sender. The address cannot be zero.
  • to: address – The wallet address of the receiver. The address cannot be zero.
  • id: uint256 – The ID of the ERC-1155 token to transfer.
  • value: uint256 – The amount of tokens to transfer.
  • data: byte – Additional bytes of data.

Token Behavior Management - Delegable Behavior

setApprovalForAll
This method grants or revokes permission for an operator to transfer the caller's tokens, based on the approved parameter. This method can be called by any user who holds tokens.
Parameters:
  • operator: address – The wallet address of the operator who is being granted or revoked permissions. The address cannot be zero.
  • approved: bool – A Boolean flag indicated whether the operator has permission to transfer the caller's tokens.
isApprovedForAll
This method checks whether an operator is approved to transfer tokens for a specified account. This method can be called by any user who holds tokens.
Parameters:
  • account: address – The wallet address of the users who granted or revoked permissions to the operator for transferring their tokens. The address cannot be zero.
  • operator: address – The wallet address of the operator who was granted or revoked permissions. The address cannot be zero.
Returns:
  • A Boolean value indicating whether the operator is approved to transfer tokens for the specified account.

Token Behavior Management - Pausable Behavior

paused
This method checks whether the contract is paused. This method can be called by any user.
Parameters:
  • none
pause
This method pauses the contract. This method can be called only by a Token Admin.
Parameters:
  • none
unpause
This method resumes a paused contract. This method can be called only by a Token Admin.
Parameters:
  • none

Token Behavior Management - Lockable Behavior

lockNFT
This method locks a non-fungible token. This method can be called only by a user with the TOKEN_SYS_VAULT_ROLE role.
Parameters:
  • tokenId: uint256 – The ID of the token to lock.
isNFTLocked
This method checks whether a non-fungible token is locked. This method can be called only by a user with the TOKEN_SYS_VAULT_ROLE role or by the Token Admin.
Parameters:
  • tokenId: uint256 – The ID of the token to check.
Returns:
  • A Boolean value indicating whether the token is locked.