ERC-20 Account Contract APIs

You can use the following identity and access control methods in ERC-20 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.
  • maxDailyAmount: int256 – The maximum amount of tokens that can be used in transactions daily. If the value is -1, there is no limit.
  • maxDailyTransactions: int256 – The maximum number of transactions that can be completed daily. If the value is -1, there is no limit.
  • applicationGroups: string[] – A list of application groups the user belongs to.
deleteAccount
This method deletes the account of the specified user. This method can be called only by a Token Admin or by an Org Admin of the specified organization.
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 Token Auditor, an Org Admin of the specified organization, 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 Token Auditor, an Org Admin of the specified organization, 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",
    "dailyLimits": {
          "isMaxDailyTxnEnabled": true,
    	  "isMaxDailyAmtEnabled": true, 
		  "dailyAmount": 100,
    	  "dailyTransactions": 5,
		  "maxDailyAmount": 100000,
    	  "maxDailyTransactions": 50,
          "applicationGroups":[]                
    },
	"status":0
}
getAllAccounts
This method gets all accounts, with paginated output. This method can be called only by the Token Admin or Token Auditor.
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",
    "dailyLimits": {
          "isMaxDailyTxnEnabled": true,
    	  "isMaxDailyAmtEnabled": true, 
		  "dailyAmount": 100,
    	  "dailyTransactions": 5,
		  "maxDailyAmount": 100000,
    	  "maxDailyTransactions": 50,
		  "applicationGroups":[]           
	},
	"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 or by an Org Admin of the specified organization.
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 or by an Org Admin of the specified organization.
Parameters:
  • userAddress: string – The wallet address of the user, which must not be zero.
setMaxDailyAmount
This method sets the maximum amount of tokens that can be used in transactions daily by the specified user. This method can be called only by a Token Admin or by an Org Admin of the specified organization.
Parameters:
  • value: int256 – The maximum amount of tokens that can be used in transactions daily.
  • userAddress: string – The wallet address of the user, which must not be zero.
setMaxDailyTransactionCount
This method sets the maximum number of transactions that can be completed daily by the specified user. This method can be called only by a Token Admin or by an Org Admin of the specified organization.
Parameters:
  • count: int256 – The maximum number of transactions that can be completed daily.
  • 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 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 a 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: 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.
addOrgAdmin
This method adds an Org Admin. This method can be called only by a Token Admin or Org Admin of the specified organization.
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"    
    }
removeOrgAdmin
This method removes an Org Admin. This method can be called only by a Token Admin or Org Admin of the specified organization.
Parameters:
  • userAddress: string – The wallet address of the user, which must not be zero.
getAllOrgAdmins
This method gets account information for all Org Admin users. This method can be called only by a 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 a 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: 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 an Org Admin.

Auditor Management Methods

addTokenAuditor
This method adds a Token Auditor. This method can be called only by a Token Admin.
Parameters:
  • auditorDetails: object – An object that specifies the user ID, organization ID, and wallet address, as shown in the following example.
    {
        "userId": "tokenAuditor1",
        "orgId": "orgA",
    	"accountAddress": "0x0fbdc686b912d7722dc86510934589e0aaf3b55a"    
    }
removeTokenAuditor
This method removes a Token Auditor. This method can be called only by a Token Admin.
Parameters:
  • userAddress: string – The wallet address of the user, which must not be zero.
getAllTokenAuditors
This method gets account information for all Token Auditor users. This method can be called only by a 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 a specified user is a Token Auditor. This method can be called by any user.
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 Auditor.
addOrgAuditor
This method adds an Org Auditor. This method can be called only by a Token Admin or Org Admin of the specified organization.
Parameters:
  • adminDetails: object – An object that specifies the user ID, organization ID, and wallet address, as shown in the following example.
    {
        "userId": "tokenAuditor1",
        "orgId": "orgA",
    	"accountAddress": "0x0fbdc686b912d7722dc86510934589e0aaf3b55a"    
    }
removeOrgAuditor
This method removes an Org Auditor. This method can be called only by a Token Admin or Org Admin of the specified organization.
Parameters:
  • userAddress: string – The wallet address of the user, which must not be zero.
getAllOrgAuditors
This method gets account information for all Org Auditor users. This method can be called only by a 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 a specified user is an Org Auditor. This method can be called by any user.
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 an Org Auditor.

Role Management Methods

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: 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.
removeRole
This method removes a role from the specified user. This method can be called only by a Token Admin or Org Admin of the specified organization.
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.
isInRole
This method checks whether a user has a specified role. This method can be called by any user.
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.
Returns:
  • A Boolean value (true or false) indicating whether the user has the specified role.
hasRole
This method checks whether a user has a specified role. This method can be called by any user.
Parameters:
  • account: string – The wallet address of the user, which must not be zero.
  • role: bytes32 – The name of the role to check for the specified user, such as minter, burner, or notary.
Returns:
  • A Boolean value (true or false) indicating whether the user has the specified role.

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 governance 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.