ERC-1155 Account Contract APIs

You can use the following identity and access control methods in ERC-1155 account contracts.

Account Management Methods

createAccount
This method creates an account for a specified user. An account must be created for any user who will have tokens at any point. Accounts track balances and on-hold balances. This method can be called only by a Token Admin or by an Org Admin of the specified organization.
Parameters:
  • userId: string – The user name or email ID of the user. The user ID must not be an empty string.
  • orgId: string – The membership service provider (MSP) ID of the user in the current organization. The organization ID must not be an empty string.
  • userAddress: string – The wallet address of the user, which must not be zero.
deleteAccount
This method deletes the account of the specified user. This method can be called only by a Token Admin.
Parameters:
  • userAddress: string – The wallet address of the user, which must not be zero.
getAccountStatus
This method gets the current account status of the specified user. This method can be called by the Token Admin or by the token account owner.
Parameters:
  • userAddress: string – The wallet address of the user, which must not be zero.
Returns:
  • A value of the AccountStatus enum object, either 0, 1, or 2.
    enum AccountStatus {
    active,
    suspended,
    deleted
    }
getAccountByAddress
This method gets the account of the specified user. This method can be called by the Token Admin or by the token account owner.
Parameters:
  • userAddress: string – The wallet address of the user, which must not be zero.
Return Value Example:
{
    "userId": "userA",
    "orgId": "orgA",
	"accountAddress": "0x0fbdc686b912d7722dc86510934589e0aaf3b55a",
	"status":0
}
getAllAccounts
This method gets all accounts, with paginated output. This method can be called only by the Token Admin.
Parameters:
  • offset: uint256 – The offset index that indicates where to start getting account information.
  • limit: uint256 – The number of items to return.
Returns:
  • Return (UserAccount[] memory items, uint256 total, uint256 nextOffset)
Return Value Example:
[{
    "userId": "userA",
    "orgId": "orgA",
	"accountAddress": "0x0fbdc686b912d7722dc86510934589e0aaf3b55a",
	"status":0
}]
total: 15
nextoffset: 6
activateAccount
This method activates the account of the specified user. This method can be called only by a Token Admin.
Parameters:
  • userAddress: string – The wallet address of the user, which must not be zero.
suspendAccount
This method activates the account of the specified user. This method can be called only by a Token Admin.
Parameters:
  • userAddress: string – The wallet address of the user, which must not be zero.

Admin Management Methods

addTokenAdmin
This method adds a Token Admin. This method can be called only by a Token Admin.
Parameters:
  • adminDetails: object – An object that specifies the user ID, organization ID, and wallet address, as shown in the following example.
    {
        "userId": "tokenAdmin1",
        "orgId": "orgA",
    	"accountAddress": "0x0fbdc686b912d7722dc86510934589e0aaf3b55a"    
    }
removeTokenAdmin
This method removes a Token Admin. This method can be called only by a Token Admin.
Parameters:
  • userAddress: string – The wallet address of the user, which must not be zero.
getAllTokenAdmins
This method gets account information for all Token Admin users. This method can be called only by a Token Admin.
Parameters:
  • None
Return Value Example:
[{
    "userId": "tokenadmin1",
    "orgId": "orgA",
	"accountAddress": "0x0fbdc686b912d7722dc86510934589e0aaf3b55a"
},
{
    "userId": "tokenadmin2",
    "orgId": "orgB",
	"accountAddress": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"
}]
isTokenAdmin
This method checks whether a specified user is a Token Admin. This method can be called only by a Token Admin.
Parameters:
  • userAddress: string – The wallet address of the user, which must not be zero.
Returns:
  • A Boolean value (true or false) indicating whether the specified user is a Token Admin.

Role Management Methods

addRole
This method adds a role to a specified user. This method can be called only by a Token Admin.
Parameters:
  • userAddress: string – The wallet address of the user, which must not be zero.
  • role: string – The name of the role to add for the specified user, such as minter, burner, or notary.
  • scopeId: uint256 – The scope ID, which is either an NFT class ID or a fungible token ID.
removeRole
This method removes a role from the specified user. This method can be called only by a Token Admin.
Parameters:
  • userAddress: string – The wallet address of the user, which must not be zero.
  • role: string – The name of the role to remove for the specified user, such as minter, burner, or notary.
  • scopeId: uint256 – The scope ID, which is either an NFT class ID or a fungible token ID.
isInRole
This method checks whether a user has a specified role. This method can be called only by a Token Admin.
Parameters:
  • role: string – The name of the role to check for the specified user, such as minter, burner, or notary.
  • userAddress: string – The wallet address of the user, which must not be zero.
  • scopeId: uint256 – The scope ID, which is either an NFT class ID or a fungible token ID.
Returns:
  • A Boolean value (true or false) indicating whether the user has the specified role.
isInRole
This method checks whether a user has a specified role. This method can be called only by a Token Admin.
Parameters:
  • role: bytes32 – The Keccak-256 hash of the name of the role to check for the specified user, such as minter, burner, or notary.
  • userAddress: string – The wallet address of the user, which must not be zero.
  • scopeId: uint256 – The scope ID, which is either an NFT class ID or a fungible token ID.
Returns:
  • A Boolean value (true or false) indicating whether the user has the specified role.
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: string – The wallet address of the user, which must not be zero.
  • role: string – The name of the role to add. The only supported value is TOKEN_SYS_VAULT_ROLE.
Returns:
  • A Boolean value (true or 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: string – The wallet address of the user, which must not be zero.
  • role: string – The name of the role to remove. The only supported value is TOKEN_SYS_VAULT_ROLE.
Returns:
  • A Boolean value (true or false).
transferTokenSysRole
This method tranfsers the TOKEN_SYS_VAULT_ROLE role from a specified user to a recipient. This method can be called only by a Token Admin.
Parameters:
  • fromAddress: string – The wallet address of the user who currently has the TOKEN_SYS_VAULT_ROLE role.
  • toAddress: string – The wallet address of the user who will receive the TOKEN_SYS_VAULT_ROLE role.
  • role: string – The name of the role to transfer. The only supported value is TOKEN_SYS_VAULT_ROLE.
Returns:
  • A Boolean value (true or false).

Context Management Methods

setContext
This method sets the token contract address for the account contract. This method can be called only by a Token Admin.
Parameters:
  • tokenAddress: address – The contract address of the deployed token, which must not be zero.
getContext
This method gets the token contract address for the account contract. This method can be called by any user.
Parameters:
  • None
Returns
  • The token contract address
setGovernanceContext
This method sets the governance contract to use to manage the governance life cycle for the account contract. This method can be called only by a Token Admin.
Parameters:
  • uuid: string – The unique ID set by the digital assets Token Admin before contract deployment.
  • governance: address – The contract address of the deployed governance contract, which must not be zero.
getGovernanceContext
This method gets the govnerance context details. This method can be called by any user.
Parameters:
  • None
Returns
  • A governanceContext object.
Return Value Example:
{
    "governanceUUID": "abc-def",
    "governance": "0x0000000",
	"deploymentActive": "true"
}
isDeploymentActive
This method checks whether the deployment is active. This method can be called by any user.
Parameters:
  • None
Returns:
  • A Boolean value (true or false) indicating whether the deployment is active.