Token Taxonomy Framework Enhancements

The enhanced version of Blockchain App Builder includes new functionality related to the extended Token Taxonomy Framework standard.

Daily Transaction Limits

You can restrict the number of transactions an account can complete daily, as well as the number of tokens that can be acted on. The max_daily_amount and max_daily_transactions input parameters to the createAccount method control this behavior. These parameters are optional.

You can achieve higher throughput if you do not set the daily transaction limits for an account.

createAccount (TypeScript)
@Validator(yup.string(), yup.string(), yup.string(), yup.object().nullable())

public async createAccount(org_id: string, user_id: string, token_type: string, daily_limits: DailyLimits) {
await this.Ctx.Auth.checkAuthorization("ACCOUNT.createAccount", "TOKEN", { org_id });
return await this.Ctx.Account.createAccount(org_id, user_id, token_type, daily_limits);
}
Additional Parameters:
  • daily_limits: JSON – An object specifying the maximum amount of tokens that can be used in transactions daily (max_daily_amount) and the maximum number of transactions that can be completed daily (max_daily_transactions) as shown in the following example.
    {
         "max_daily_amount": 100000
         "max_daily_transactions": 10000
     }
CreateAccount (Go)
func (t *Controller) CreateAccount(org_id string, user_id string, token_type string, daily_limits ...account.AccountDailyLimits) (interface{}, error) {
auth, err := t.Ctx.Auth.CheckAuthorization("Account.CreateAccount", "TOKEN", map[string]string{"org_id": org_id})
if err != nil && !auth {
return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
}
return t.Ctx.Account.CreateAccount(org_id, user_id, token_type, daily_limits...)
}
Additional Parameters:
  • daily_limits: JSON – A JSON object that includes a MaxDailyAmount parameter (the maximum amount of tokens that can be used in transactions daily) and a MaxDailyTransactions parameter (the maximum number of transactions that can be completed daily), as shown in the following example.
    {
         "MaxDailyAmount": 100000
         "MaxDailyTransactions": 10000
     }
Returns:
  • On success, a JSON object of the account that was created. The BapAccountVersion parameter is defined in the account object for internal use.
Return Value Example:
{ 
   "AssetType":"oaccount",
   "AccountId":"oaccount~a73085a385bc96c4a45aa2dff032e7dede82c0664dee5f396b7c5854eeafd4bd",
   "BapAccountVersion": 0,
   "UserId":"user1",
   "OrgId":"Org1MSP",
   "AccountType":"fungible",
   "TokenId":"",
   "TokenName":"",
   "Balance":0,
   "BalanceOnHold":0
}

Approval Requirements for Minting and Burning

You can set up approvals for minting and burning tokens, so that users with the minter or burner role must submit a request to an approver, instead of minting or burning tokens directly. Approvers can accept or reject requests to mint or burn tokens. To enable approvals for minting and burning, you use the mint_approval_required and burn_approval_required parameters. You must then also specify values for mint_approver_role_name and burn_approval_role_name, as shown in the following example.

behavior: # Token behaviors
          - divisible: 
                decimal: 2  
          - mintable: 
                max_mint_quantity: 1000 
                mint_approval_required: true
          - transferable
          - burnable 
                burn_approval_required: true
          - holdable 
          - roles: 
                minter_role_name: minter
                notary_role_name: notary
                mint_approver_role_name: minter_notary
                burn_approver_role_name: burner_notary
The following methods support requesting, accepting, and rejecting approvals to mint and burn tokens.

TypeScript Methods for Minting and Burning Approval

requestMint
This method can be called by a minter to send a request to the minter notary to create a specified amount of tokens.
@Validator(yup.string(), yup.string(), yup.string(), yup.string(), yup.number().positive(), yup.date(), yup.object().nullable())
public async requestMint( token_id: string, operation_id: string, notary_org_id: string, notary_user_id: string, quantity: number, time_to_expiration: Date, info_details?: InfoDetails) {

const token_asset = await this.getTokenObject(token_id);
const notary_account_id = await this.Ctx.Account.generateAccountId(token_id, notary_org_id, notary_user_id);
return await this.Ctx.Token.hold(operation_id, null, notary_account_id, quantity, time_to_expiration, token_asset, HoldOperationType.MINT, info_details);

}
Parameters:
  • token_id: string – The ID of the token to mint.
  • operation_id: string – The unique operation ID that represents the mint request.
  • notary_org_id: string – The membership service provider (MSP) ID of the minter notary who will process the request.
  • notary_user_id: string – The user name or email ID of the minter notary who will process the request.
  • quantity: number – The amount of tokens to mint.
  • time_to_expiration – The time after which the minting request expires and is no longer valid.
  • info_details: JSON – An object specifying the category (category) and description (description) of the request, as shown in the following example.
    {
         "category" : "category input",
         "description" : "description input"
    }
Return Value Example:
{
msg:
"AccountId oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (Org-Id: Org1MSP, User-Id: admin) has successfully submitted request to mint 100 tokens",
}
approveMint
This method can be called by a minter notary to approve a minting request.
@Validator(yup.string(), yup.string())
public async approveMint(token_id: string, operation_id: string) {
const token_asset = await this.getTokenObject(token_id);
return await this.Ctx.Token.executeHold(operation_id, token_asset);
}
Parameters:
  • token_id: string – The ID of the token to mint.
  • operation_id: string – The unique operation ID that represents the mint request.
Return Value Example:
{
msg:
"Successfully minted 100 tokens to Account Id: oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (Org-Id: Org1MSP, User-Id: admin)"
}
rejectMint
This method can be called by a minter notary to reject a minting request.
@Validator(yup.string(), yup.string())
public async rejectMint(token_id: string, operation_id: string) {
const token_asset = await this.getTokenObject(token_id);
return await this.Ctx.Token.releaseHold(operation_id, token_asset);
}
Parameters:
  • token_id: string – The ID of the token to mint.
  • operation_id: string – The unique operation ID that represents the mint request.
Return Value Example:
{
 msg: "Successfully rejected mint request with Operation Id 'operation1' to mint 100 tokens of token id token"
}
requestBurn
This method can be called by a burner to send a request to the burner notary to destroy a specified amount of tokens.
@Validator(yup.string(), yup.string(), yup.string(), yup.string(), yup.number().positive(), yup.date(), yup.object().nullable())

public async requestBurn( token_id: string, operation_id: string, notary_org_id: string, notary_user_id: string, quantity: number, time_to_expiration: Date, info_details?: InfoDetails ) {

const token_asset = await this.getTokenObject(token_id);
const notary_account_id = await this.Ctx.Account.generateAccountId(token_id, notary_org_id, notary_user_id);
return await this.Ctx.Token.hold(operation_id, null, notary_account_id, quantity, time_to_expiration, token_asset, HoldOperationType.BURN, null, description);
}
Parameters:
  • token_id: string – The ID of the token to burn.
  • operation_id: string – The unique operation ID that represents the burn request.
  • notary_org_id: string – The membership service provider (MSP) ID of the burner notary who will process the request.
  • notary_user_id: string – The user name or email ID of the burner notary who will process the request.
  • quantity: number – The amount of tokens to burn.
  • time_to_expiration – The time after which the burning request expires and is no longer valid.
  • info_details: JSON – An object specifying the category (category) and description (description) of the request, as shown in the following example.
    {
         "category" : "category input",
         "description" : "description input"
    }
Return Value Example:
{
msg:
"AccountId oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (Org-Id: Org1MSP, User-Id: admin) has successfully submitted request to mint 100 tokens",
}
approveBurn
This method can be called by a burner notary to approve a burning request.
@Validator(yup.string(), yup.string())
public async approveBurn(token_id: string, operation_id: string) {
const token_asset = await this.getTokenObject(token_id);
return await this.Ctx.Token.executeHold(operation_id, token_asset);
}
Parameters:
  • token_id: string – The ID of the token to burn.
  • operation_id: string – The unique operation ID that represents the burn request.
Return Value Example:
{
msg:
"Successfully burned 100 tokens from account id: oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (Org-Id: Org1MSP, User-Id: admin)"
}
rejectBurn
This method can be called by a burner notary to reject a burning request.
@Validator(yup.string(), yup.string())
public async rejectBurn(token_id: string, operation_id: string) {
const token_asset = await this.getTokenObject(token_id);
return await this.Ctx.Token.releaseHold(operation_id, token_asset);
}
Parameters:
  • token_id: string – The ID of the token to burn.
  • operation_id: string – The unique operation ID that represents the burn request.
Return Value Example:
{
 msg: "Successfully rejected burn request with Operation Id 'operation1' to burn 100 tokens of token id token",
}

Go Methods for Minting and Burning Approval

RequestMint
This method can be called by a minter to send a request to the minter notary to create a specified amount of tokens.
func (t *Controller) RequestMint(token_id string, operation_id string, notary_org_id string, notary_user_id string, quantity float64, timeToExpiration string, info_details ...token.InfoDetails) (interface{}, error) {
tokenAssetValue, err := t.getTokenObject(token_id)
if err != nil {
return nil, err
}
notary_account_id, err := t.Ctx.Account.GenerateAccountId(token_id, notary_org_id, notary_user_id)
if err != nil {
return nil, fmt.Errorf("error in getting notary account id from org_id: %s and user_id: %s with token_id: %s, error %s ", notary_org_id, notary_user_id, token_id, err.Error())
 }
return t.Ctx.Token.Hold(operation_id, "", notary_account_id, quantity, timeToExpiration, tokenAssetValue.Interface(), constants.HoldMint, info_details...)
}
Parameters:
  • token_id: string – The ID of the token to mint.
  • operation_id: string – The unique operation ID that represents the mint request.
  • notary_org_id: string – The membership service provider (MSP) ID of the minter notary who will process the request.
  • notary_user_id: string – The user name or email ID of the minter notary who will process the request.
  • quantity: number – The amount of tokens to mint.
  • TimeToExpiration – The time after which the minting request expires and is no longer valid.
  • info_details: JSON – An object specifying the category (category) and description (description) of the request, as shown in the following example.
    {
         "Category" : "category input",
         "Description" : "description input"
    }
Return Value Example:
{
msg:
"AccountId oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (org_id: Org1MSP, user_id: admin) has successfully submitted request to mint 100 tokens",
}
ApproveMint
This method can be called by a minter notary to approve a minting request.
func (t *Controller) ApproveMint(token_id string, operation_id string) (interface{}, error) {
tokenAssetValue, err := t.getTokenObject(token_id)
if err != nil {
return nil, err
}
return t.Ctx.Token.ExecuteHold(operation_id, tokenAssetValue.Interface())
}
Parameters:
  • token_id: string – The ID of the token to mint.
  • operation_id: string – The unique operation ID that represents the mint request.
Return Value Example:
{
msg:
"Successfully minted 100 tokens to Account Id: oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (org_id: Org1MSP, user_id: admin)"
}
RejectMint
This method can be called by a minter notary to reject a minting request.
func (t *Controller) RejectMint(token_id string, operation_id string) (interface{}, error) {
tokenAssetValue, err := t.getTokenObject(token_id)
if err != nil {
return nil, err
}
return t.Ctx.Token.ReleaseHold(operation_id, tokenAssetValue.Interface())
}
Parameters:
  • token_id: string – The ID of the token to mint.
  • operation_id: string – The unique operation ID that represents the mint request.
Return Value Example:
{
 msg: "Successfully rejected mint request with Operation Id 'operation1' to mint 100 tokens of token id token"
}
RequestBurn
This method can be called by a burner to send a request to the burner notary to destroy a specified amount of tokens.
func (t *Controller) RequestBurn(token_id string, operation_id string, notary_org_id string, notary_user_id string, quantity float64, timeToExpiration string, info_details ...token.InfoDetails) (interface{}, error) {
tokenAssetValue, err := t.getTokenObject(token_id)
if err != nil {
return nil, err
}
notary_account_id, err := t.Ctx.Account.GenerateAccountId(token_id, notary_org_id, notary_user_id)
if err != nil {
return nil, fmt.Errorf("error in getting notary account id from org_id: %s and user_id: %s with token_id: %s, error %s ", notary_org_id, notary_user_id, token_id, err.Error())
 }
return t.Ctx.Token.Hold(operation_id, "", notary_account_id, quantity, timeToExpiration, tokenAssetValue.Interface(), constants.HoldBurn, info_details...)
}
Parameters:
  • token_id: string – The ID of the token to burn.
  • operation_id: string – The unique operation ID that represents the burn request.
  • notary_org_id: string – The membership service provider (MSP) ID of the burner notary who will process the request.
  • notary_user_id: string – The user name or email ID of the burner notary who will process the request.
  • quantity: number – The amount of tokens to burn.
  • time_to_expiration – The time after which the burning request expires and is no longer valid.
  • info_details: JSON – An object specifying the category (category) and description (description) of the request, as shown in the following example.
    {
         "category" : "category input",
         "description" : "description input"
    }
Return Value Example:
{
msg:
"AccountId oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (org_id: Org1MSP, user_id: admin) has successfully submitted request to mint 100 tokens",
}
ApproveBurn
This method can be called by a burner notary to approve a burning request.
func (t *Controller) ApproveBurn(token_id string, operation_id string) (interface{}, error) {
tokenAssetValue, err := t.getTokenObject(token_id)
if err != nil {
return nil, err
}
return t.Ctx.Token.ExecuteHold(operation_id, tokenAssetValue.Interface())
}
Parameters:
  • token_id: string – The ID of the token to burn.
  • operation_id: string – The unique operation ID that represents the burn request.
Return Value Example:
{
msg:
"Successfully burned 100 tokens from account id: oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (org_id: Org1MSP, user_id: admin)"
}
RejectBurn
This method can be called by a burner notary to reject a burning request.
func (t *Controller) RejectBurn(token_id string, operation_id string) (interface{}, error) {
tokenAssetValue, err := t.getTokenObject(token_id)
if err != nil {
return nil, err
}
return t.Ctx.Token.ReleaseHold(operation_id, tokenAssetValue.Interface())
}
Parameters:
  • token_id: string – The ID of the token to burn.
  • operation_id: string – The unique operation ID that represents the burn request.
Return Value Example:
{
 msg: "Successfully rejected burn request with Operation Id 'operation1' to burn 100 tokens of token id token",
}

Fetching Transaction History from the Rich History Database

You can synchronize data to the rich history database and then fetch the data using chaincode API calls. The following method, shown in TypeScript and in Go, fetchs transaction history from the rich history database. Before you can use these methods, you must run Oracle Autonomous Database with Oracle REST Data Services (ORDS) and OAuth enabled, as described in Oracle Database View Definitions for Wholesale CBDC.
getAccountTransactionHistoryWithFiltersFromRichHistDB (TypeScript)
@GetMethod()
@Validator(yup.string(), yup.string(), yup.string(), yup.string(), yup.string(), yup.object().nullable())
public async getAccountTransactionHistoryWithFiltersFromRichHistDB(token_id: string, org_id: string, user_id: string, custom_endpoint: string, bearer_token: string, filters?: Filters) {
const account_id = await this.Ctx.Account.generateAccountId(token_id, org_id, user_id);
await this.Ctx.Auth.checkAuthorization("ACCOUNT.getAccountTransactionHistoryWithFilters", "TOKEN", { account_id });
return await this.Ctx.Account.getAccountTrxHistoryWithFiltersFromRichHistDB(account_id, org_id, user_id.toLowerCase(), custom_endpoint, bearer_token, filters);
}
Parameters:
  • token_id: string – The ID of the token to mint.
  • org_id: string – The membership service provider (MSP) ID of the user in the current organization.
  • user_id: string – The user name or email ID of the user.
  • custom_endpoint – The RESTful service endpoint of the rich history database.
  • bearer_token – The access authorization token for the RESTful service endpoint.
  • filters: string – An optional parameter. If empty, all records are returned. The PageSize property determines the number of records to return. If PageSize is 0, the default page size is 20. The Bookmark property determines the starting index of the records to return. For more information, see the Hyperledger Fabric documentation. The StartTime and EndTime properties must be specified in RFC-3339 format.
GetAccountTransactionHistoryWithFiltersFromRichHistDB (Go)
func (t *Controller) GetAccountTransactionHistoryWithFiltersFromRichHistDB(token_id string, org_id string, user_id string, custom_endPoint string, bearer_token string, filters ...account.AccountHistoryFilters) (interface{}, error) {
account_id, err := t.Ctx.Account.GenerateAccountId(token_id, org_id, user_id)
if err != nil {
return nil, err
}
auth, err := t.Ctx.Auth.CheckAuthorization("Account.GetAccountTransactionHistoryWithFilters", "TOKEN", map[string]string{"account_id": account_id})
if err != nil && !auth {
return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
}
// sample format of filter: []string{"3", "", "2022-01-16T15:16:36+00:00", "2022-01-17T15:16:36+00:00"}
transactionArray, err := t.Ctx.Account.GetAccountTransactionHistoryWithFiltersFromRichHistDB(account_id, org_id, user_id, custom_endPoint, bearer_token, filters...)
return transactionArray, err
}
Parameters:
  • token_id: string – The ID of the token to mint.
  • org_id: string – The membership service provider (MSP) ID of the user in the current organization.
  • user_id: string – The user name or email ID of the user.
  • custom_endpoint – The RESTful service endpoint of the rich history database.
  • bearer_token – The access authorization token for the RESTful service endpoint.
  • filters: string – An optional parameter. If empty, all records are returned. The PageSize property determines the number of records to return. If PageSize is 0, the default page size is 20. The Bookmark property determines the starting index of the records to return. For more information, see the Hyperledger Fabric documentation. The StartTime and EndTime properties must be specified in RFC-3339 format.

Category and Description Attributes in Transaction Objects

  • Category and description attributes must be included in the transferTokens, holdTokens, issueTokens, requestMint, requestBurn, burnTokens and rejectBurn methods in the controller file. The corresponding SDK methods must also include category and description attributes.
  • The category and description attribute input is in the form of a JSON object named info_details, as shown in the following example.
    {
         "category" : "category input",
         "description" : "description input"
    }
  • The info_details field is optional. You can pass only a category or only a description as needed.
  • The GET methods related to any transactions for transferTokens, holdTokens, executeHold, releaseHold, requestMint, approveMint, rejectMint, requestBurn, approveBurn and rejectBurn must include category and description attributes in the payload response if they are present.
  • The category field is limited 20 characters and the description field is limited to 250 Characters.

TypeScript Methods with Modified Inputs

The following methods support optional category and description attributes when you use the enhanced version of Blockchain App Builder.

transferTokens
This method transfers tokens from the caller to a specified account.
@Validator(yup.string(), yup.string(), yup.string(), yup.number().positive(), yup.object().nullable())
public async transferTokens(token_id: string, to_org_id: string, to_user_id: string, quantity: number, info_details?: InfoDetails) {
const token_asset = await this.getTokenObject(token_id);
const to_account_id = await this.Ctx.Account.generateAccountId(token_id, to_org_id, to_user_id);
return await this.Ctx.Token.transfer(to_account_id, quantity, token_asset, info_details);
}
Parameters:
  • token_id: string – The ID of the token.
  • to_org_id: string – The membership service provider (MSP) ID of the receiver (payee) in the current organization.
  • to_user_id: string – The user name or email ID of the receiver.
  • quantity: number – The number of tokens to transfer.
  • info_details: JSON – An object specifying the category (category) and description (description) of the request, as shown in the following example.
    {
         "category" : "category input",
         "description" : "description input"
    }
Return Value Example:
{
 msg: "Successfully transferred 100 tokens from account id: oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (Org-Id: Org1MSP, User-Id: admin) to account id: oaccount~7yuijg39b4e1e4136dd86a806020c97a930909325340481b8fdhjklliugbv699 (Org-Id: Org1MSP, User-Id: user)",
}
holdTokens
This method creates a hold on behalf of the owner of the tokens with the to_account_id account.
@Validator(yup.string(), yup.string(), yup.string(), yup.string(), yup.string(), yup.string(), yup.number().positive(), yup.date(), yup.object().nullable())
  public async holdTokens( token_id: string, operation_id: string, to_org_id: string, to_user_id: string, notary_org_id: string, notary_user_id: string, quantity: number, time_to_expiration: Date, info_details?: InfoDetails) {
    const token_asset = await this.getTokenObject(token_id);
    const to_account_id = await this.Ctx.Account.generateAccountId(token_id, to_org_id, to_user_id);
    const notary_account_id = await this.Ctx.Account.generateAccountId(token_id, notary_org_id, notary_user_id);
    return await this.Ctx.Token.hold(operation_id, to_account_id, notary_account_id, quantity, time_to_expiration, token_asset, HoldOperationType.TRANSFER, info_details);
  }
Parameters:
  • token_id: string – The ID of the token.
  • operation_id: string – A unique ID to identify the hold operation. Typically this ID is passed by the client application.
  • to_org_id: string – The membership service provider (MSP) ID of the receiver in the current organization.
  • to_user_id: string – The user name or email ID of the receiver.
  • notary_org_id: string – The membership service provider (MSP) ID of the notary in the current organization.
  • notary_user_id: string – The user name or email ID of the notary.
  • quantity: number – The number of tokens to put on hold.
  • time_to_expiration – The time when the hold expires. Specify 0 for a permanent hold. Otherwise use the RFC-3339 format. For example, 2021-06-02T12:46:06Z.
  • info_details: JSON – An object specifying the category (category) and description (description) of the request, as shown in the following example.
    {
         "category" : "category input",
         "description" : "description input"
    }
Return Value Example:
{
msg:
"AccountId oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (Org-Id: Org1MSP, User-Id: admin) is successfully holding 100 tokens",
}
issueTokens
This method mints tokens, which are then owned by the caller of the method.
@Validator(yup.string(), yup.number().positive(), yup.object().nullable())
public async issueTokens(token_id: string, quantity: number, info_details?: InfoDetails) {
const token_asset = await this.getTokenObject(token_id);
return await this.Ctx.Token.mint(quantity, token_asset, info_details);
}
Parameters:
  • token_id: string – The ID of the token.
  • quantity – The number of tokens to mint.
  • info_details: JSON – An object specifying the category (category) and description (description) of the request, as shown in the following example.
    {
         "category" : "category input",
         "description" : "description input"
    }
Return Value Example:
{
msg:
"Successfully minted 100 tokens to Account Id: oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (Org-Id: Org1MSP, User-Id: admin)"
}
burnTokens
This method deactivates, or burns, tokens from the transaction caller's account.
@Validator(yup.string(), yup.number().positive(), yup.object().nullable())

public async burnTokens(token_id: string, quantity: number, info_details?: InfoDetails) {
const token_asset = await this.getTokenObject(token_id);
return await this.Ctx.Token.burn(quantity, token_asset, info_details);
}
Parameters:
  • token_id: string – The ID of the token.
  • quantity – The number of tokens to burn.
  • info_details: JSON – An object specifying the category (category) and description (description) of the request, as shown in the following example.
    {
         "category" : "category input",
         "description" : "description input"
    }
Return Value Example:
{
msg:
"Successfully burned 100 tokens from account id: oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (Org-Id: Org1MSP, User-Id: admin)"
}

Go Methods with Modified Inputs

The following methods support optional category and description attributes when you use the enhanced version of Blockchain App Builder.

TransferTokens
This method transfers tokens from the caller to a specified account.
func (t *Controller) TransferTokens(token_id string, to_org_id string, to_user_id string, quantity float64, info_details ...token.InfoDetails) (interface{}, error) {
tokenAssetValue, err := t.getTokenObject(token_id)
if err != nil {
return nil, err
}
to_account_id, err := t.Ctx.Account.GenerateAccountId(token_id, to_org_id, to_user_id)
if err != nil {
return nil, err
 }
return t.Ctx.Token.Transfer(to_account_id, quantity, tokenAssetValue.Interface(), info_details...)
}
Parameters:
  • token_id: string – The ID of the token.
  • to_org_id: string – The membership service provider (MSP) ID of the receiver (payee) in the current organization.
  • to_user_id: string – The user name or email ID of the receiver.
  • quantity: number – The number of tokens to transfer.
  • info_details: JSON – An object specifying the category (category) and description (description) of the request, as shown in the following example.
    {
         "category" : "category input",
         "description" : "description input"
    }
Return Value Example:
{
 msg: "Successfully transferred 100 tokens from account id: oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (Org-Id: Org1MSP, User-Id: admin) to account id: oaccount~7yuijg39b4e1e4136dd86a806020c97a930909325340481b8fdhjklliugbv699 (Org-Id: Org1MSP, User-Id: user)",
}
HoldTokens
This method creates a hold on behalf of the owner of the tokens with the to_account_id account.
func (t *Controller) HoldTokens(token_id string, operation_id string, to_org_id string, to_user_id string, notary_org_id string, notary_user_id string, quantity float64, timeToExpiration string, info_details ...token.InfoDetails) (interface{}, error) {
tokenAssetValue, err := t.getTokenObject(token_id)
if err != nil {
return nil, err
}
notary_account_id, err := t.Ctx.Account.GenerateAccountId(token_id, notary_org_id, notary_user_id)
if err != nil {
return nil, fmt.Errorf("error in getting notary account id from org_id: %s and user_id: %s with token_id: %s, error %s ", notary_org_id, notary_user_id, token_id, err.Error())
}
to_account_id, err := t.Ctx.Account.GenerateAccountId(token_id, to_org_id, to_user_id)
if err != nil {
return nil, fmt.Errorf("error in getting to_account id from org_id: %s and user_id: %s with token_id: %s, error %s ", to_org_id, to_user_id, token_id, err.Error())
 }
return t.Ctx.Token.Hold(operation_id, to_account_id, notary_account_id, quantity, timeToExpiration, tokenAssetValue.Interface(), constants.HoldTransfer, info_details...)
}
Parameters:
  • token_id: string – The ID of the token.
  • operation_id: string – A unique ID to identify the hold operation. Typically this ID is passed by the client application.
  • to_org_id: string – The membership service provider (MSP) ID of the receiver in the current organization.
  • to_user_id: string – The user name or email ID of the receiver.
  • notary_org_id: string – The membership service provider (MSP) ID of the notary in the current organization.
  • notary_user_id: string – The user name or email ID of the notary.
  • quantity: number – The number of tokens to put on hold.
  • time_to_expiration – The time when the hold expires. Specify 0 for a permanent hold. Otherwise use the RFC-3339 format. For example, 2021-06-02T12:46:06Z.
  • info_details: JSON – An object specifying the category (category) and description (description) of the request, as shown in the following example.
    {
         "category" : "category input",
         "description" : "description input"
    }
Return Value Example:
{
msg:
"AccountId oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (Org-Id: Org1MSP, User-Id: admin) is successfully holding 100 tokens",
}
IssueTokens
This method mints tokens, which are then owned by the caller of the method.
func (t *Controller) IssueTokens(token_id string, quantity float64, info_details ...token.InfoDetails) (interface{}, error) {
tokenAssetValue, err := t.getTokenObject(token_id)
if err != nil {
return nil, err
 }
return t.Ctx.Token.Mint(quantity, tokenAssetValue.Interface(), info_details...)
}
Parameters:
  • token_id: string – The ID of the token.
  • quantity – The number of tokens to mint.
  • info_details: JSON – An object specifying the category (category) and description (description) of the request, as shown in the following example.
    {
         "category" : "category input",
         "description" : "description input"
    }
Return Value Example:
{
msg:
"Successfully minted 100 tokens to Account Id: oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (Org-Id: Org1MSP, User-Id: admin)"
}
BurnTokens
This method deactivates, or burns, tokens from the transaction caller's account.
func (t *Controller) BurnTokens(token_id string, quantity float64, info_details ...token.InfoDetails) (interface{}, error) {
tokenAssetValue, err := t.getTokenObject(token_id)
if err != nil {
return nil, err
 }
return t.Ctx.Token.Burn(quantity, tokenAssetValue.Interface(), info_details...)
}
Parameters:
  • token_id: string – The ID of the token.
  • quantity – The number of tokens to burn.
  • info_details: JSON – An object specifying the category (category) and description (description) of the request, as shown in the following example.
    {
         "category" : "category input",
         "description" : "description input"
    }
Return Value Example:
{
msg:
"Successfully burned 100 tokens from account id: oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (Org-Id: Org1MSP, User-Id: admin)"
}

TypeScript Methods with Modified Outputs

The following methods return the relevant organization and user IDs when you use the enhanced version of Blockchain App Builder.

getAccountTransactionHistory
This method returns an array of account transaction history details for a specified user and token.
@GetMethod()
@Validator(yup.string(), yup.string(), yup.string())
public async getAccountTransactionHistory(token_id: string, org_id: string, user_id: string) {
const account_id = await this.Ctx.Account.generateAccountId(token_id, org_id, user_id);
await this.Ctx.Auth.checkAuthorization("ACCOUNT.getAccountTransactionHistory", "TOKEN", { account_id });
return await this.Ctx.Account.getAccountTransactionHistory(account_id, org_id, user_id.toLowerCase());
}
Parameters:
  • token_id: string – The ID of the token.
  • org_id: string – The membership service provider (MSP) ID of the user in the current organization.
  • user_id: string – The user name or email ID of the user.
Return Value Example:
[
            {
                "transaction_id": "otransaction~64c5a4830949eae1424600f3d4a438c6f603a7c3ea31a68e374b899803999e22",
                "transacted_amount": 10,
                "timestamp": "2024-12-11T13:37:28.000Z",
                "balance": 550,
                "onhold_balance": 10,
                "token_id": "USD",
                "category": "category value",
                "description": "description value",
                "transacted_account": "oaccount~9d9806fa92aa0c4fdb34eaffac6e830181b5d47e64fbce752195e83024125ca0",
                "transaction_type": "REJECT_MINT",
                "transacted_org_id": "CB",
                "transacted_user_id'": "creator_user_cb"
            },
            {
                "transaction_id": "otransaction~a4537ef34a955b023b7c205b9abf06a6c79e4fdd761fb24f41b8eb34126b66c0",
                "transacted_amount": 10,
                "timestamp": "2024-12-11T13:36:32.000Z",
                "balance": 550,
                "onhold_balance": 10,
                "token_id": "USD",
                "description": "description value",
                "transacted_account": "oaccount~9d9806fa92aa0c4fdb34eaffac6e830181b5d47e64fbce752195e83024125ca0",
                "transaction_type": "APPROVE_MINT",
                "transacted_org_id": "CB",
                "transacted_user_id'": "creator_user_cb"
            },
            {
                "transaction_id": "otransaction~6237a759422bd9fb112742e8cd7e6450df5a74a32236d9b1005571afed8904a4",
                "transacted_amount": 10,
                "timestamp": "2024-12-11T13:36:18.000Z",
                "balance": 540,
                "onhold_balance": 10,
                "token_id": "USD",
                "category": "category value",
                "description": "description value",
                "transacted_account": "oaccount~9d9806fa92aa0c4fdb34eaffac6e830181b5d47e64fbce752195e83024125ca0",
                "transaction_type": "REQUEST_MINT",
                "transacted_org_id": "CB",
                "transacted_user_id'": "creator_user_cb"
            },
            {
                "transaction_id": "otransaction~06b35071415d74aa1a7c18449149c937d886cae76a832c44cf8d98e84586e76e",
                "transacted_amount": 10,
                "timestamp": "2024-12-11T13:35:46.000Z",
                "balance": 540,
                "onhold_balance": 10,
                "token_id": "USD",
                "category": "category value",
                "description": "description value",
                "transacted_account": "oaccount~9d9806fa92aa0c4fdb34eaffac6e830181b5d47e64fbce752195e83024125ca0",
                "transaction_type": "REQUEST_MINT",
                "transacted_org_id": "CB",
                "transacted_user_id'": "creator_user_cb"
            }
 ]
getAccountTransactionHistoryWithFilters
This method returns a filtered array of account transaction history details for a specified user and token.
@GetMethod()
@Validator(yup.string(), yup.string(), yup.string(), yup.object().nullable())
public async getAccountTransactionHistoryWithFilters(token_id: string, org_id: string, user_id: string, filters?: Filters) {
const account_id = await this.Ctx.Account.generateAccountId(token_id, org_id, user_id);
await this.Ctx.Auth.checkAuthorization("ACCOUNT.getAccountTransactionHistoryWithFilters", "TOKEN", { account_id });
return await this.Ctx.Account.getAccountTransactionHistoryWithFilters(account_id, org_id, user_id.toLowerCase(), filters);
}
Parameters:
  • token_id: string – The ID of the token.
  • org_id: string – The membership service provider (MSP) ID of the user in the current organization.
  • user_id: string – The user name or email ID of the user.
  • filters: string – An optional parameter. If empty, all records are returned. The PageSize property determines the number of records to return. If PageSize is 0, the default page size is 20. The Bookmark property determines the starting index of the records to return. For more information, see the Hyperledger Fabric documentation. The StartTime and EndTime properties must be specified in RFC-3339 format.
Return Value Example:
[
            {
                "transaction_id": "otransaction~64c5a4830949eae1424600f3d4a438c6f603a7c3ea31a68e374b899803999e22",
                "transacted_amount": 10,
                "timestamp": "2024-12-11T13:37:28.000Z",
                "balance": 550,
                "onhold_balance": 10,
                "token_id": "USD",
                "category": "category value",
                "description": "description value",
                "transacted_account": "oaccount~9d9806fa92aa0c4fdb34eaffac6e830181b5d47e64fbce752195e83024125ca0",
                "transaction_type": "REJECT_MINT",
                "transacted_org_id": "CB",
                "transacted_user_id'": "creator_user_cb"
            },
            {
                "transaction_id": "otransaction~a4537ef34a955b023b7c205b9abf06a6c79e4fdd761fb24f41b8eb34126b66c0",
                "transacted_amount": 10,
                "timestamp": "2024-12-11T13:36:32.000Z",
                "balance": 550,
                "onhold_balance": 10,
                "token_id": "USD",
                "description": "description value",
                "transacted_account": "oaccount~9d9806fa92aa0c4fdb34eaffac6e830181b5d47e64fbce752195e83024125ca0",
                "transaction_type": "APPROVE_MINT",
                "transacted_org_id": "CB",
                "transacted_user_id'": "creator_user_cb"
            },
            {
                "transaction_id": "otransaction~6237a759422bd9fb112742e8cd7e6450df5a74a32236d9b1005571afed8904a4",
                "transacted_amount": 10,
                "timestamp": "2024-12-11T13:36:18.000Z",
                "balance": 540,
                "onhold_balance": 10,
                "token_id": "USD",
                "category": "category value",
                "description": "description value",
                "transacted_account": "oaccount~9d9806fa92aa0c4fdb34eaffac6e830181b5d47e64fbce752195e83024125ca0",
                "transaction_type": "REQUEST_MINT",
                "transacted_org_id": "CB",
                "transacted_user_id'": "creator_user_cb"
            },
            {
                "transaction_id": "otransaction~06b35071415d74aa1a7c18449149c937d886cae76a832c44cf8d98e84586e76e",
                "transacted_amount": 10,
                "timestamp": "2024-12-11T13:35:46.000Z",
                "balance": 540,
                "onhold_balance": 10,
                "token_id": "USD",
                "category": "category value",
                "description": "description value",
                "transacted_account": "oaccount~9d9806fa92aa0c4fdb34eaffac6e830181b5d47e64fbce752195e83024125ca0",
                "transaction_type": "REQUEST_MINT",
                "transacted_org_id": "CB",
                "transacted_user_id'": "creator_user_cb"
            }
 ]

Go Methods with Modified Outputs

The following methods return the relevant organization and user IDs when you use the enhanced version of Blockchain App Builder.

GetAccountTransactionHistory
This method returns an array of account transaction history details for a specified user and token.
func (t *Controller) GetAccountTransactionHistory(token_id string, org_id string, user_id string) (interface{}, error) {
account_id, err := t.Ctx.Account.GenerateAccountId(token_id, org_id, user_id)
if err != nil {
return nil, err
}
auth, err := t.Ctx.Auth.CheckAuthorization("Account.GetAccountTransactionHistory", "TOKEN", map[string]string{"account_id": account_id})
if err != nil && !auth {
return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
}



transactionArray, err := t.Ctx.Account.GetAccountTransactionHistory(account_id, org_id, user_id)
return transactionArray, err
}
Parameters:
  • token_id: string – The ID of the token.
  • org_id: string – The membership service provider (MSP) ID of the user in the current organization.
  • user_id: string – The user name or email ID of the user.
Return Value Example:
[
            {
                "transaction_id": "otransaction~64c5a4830949eae1424600f3d4a438c6f603a7c3ea31a68e374b899803999e22",
                "transacted_amount": 10,
                "timestamp": "2024-12-11T13:37:28.000Z",
                "balance": 550,
                "onhold_balance": 10,
                "token_id": "USD",
                "category": "category value",
                "description": "description value",
                "transacted_account": "oaccount~9d9806fa92aa0c4fdb34eaffac6e830181b5d47e64fbce752195e83024125ca0",
                "transaction_type": "REJECT_MINT",
                "transacted_org_id": "CB",
                "transacted_user_id'": "creator_user_cb"
            },
            {
                "transaction_id": "otransaction~a4537ef34a955b023b7c205b9abf06a6c79e4fdd761fb24f41b8eb34126b66c0",
                "transacted_amount": 10,
                "timestamp": "2024-12-11T13:36:32.000Z",
                "balance": 550,
                "onhold_balance": 10,
                "token_id": "USD",
                "description": "description value",
                "transacted_account": "oaccount~9d9806fa92aa0c4fdb34eaffac6e830181b5d47e64fbce752195e83024125ca0",
                "transaction_type": "APPROVE_MINT",
                "transacted_org_id": "CB",
                "transacted_user_id'": "creator_user_cb"
            },
            {
                "transaction_id": "otransaction~6237a759422bd9fb112742e8cd7e6450df5a74a32236d9b1005571afed8904a4",
                "transacted_amount": 10,
                "timestamp": "2024-12-11T13:36:18.000Z",
                "balance": 540,
                "onhold_balance": 10,
                "token_id": "USD",
                "category": "category value",
                "description": "description value",
                "transacted_account": "oaccount~9d9806fa92aa0c4fdb34eaffac6e830181b5d47e64fbce752195e83024125ca0",
                "transaction_type": "REQUEST_MINT",
                "transacted_org_id": "CB",
                "transacted_user_id'": "creator_user_cb"
            },
            {
                "transaction_id": "otransaction~06b35071415d74aa1a7c18449149c937d886cae76a832c44cf8d98e84586e76e",
                "transacted_amount": 10,
                "timestamp": "2024-12-11T13:35:46.000Z",
                "balance": 540,
                "onhold_balance": 10,
                "token_id": "USD",
                "category": "category value",
                "description": "description value",
                "transacted_account": "oaccount~9d9806fa92aa0c4fdb34eaffac6e830181b5d47e64fbce752195e83024125ca0",
                "transaction_type": "REQUEST_MINT",
                "transacted_org_id": "CB",
                "transacted_user_id'": "creator_user_cb"
            }
 ]
GetAccountTransactionHistoryWithFilters
This method returns a filtered array of account transaction history details for a specified user and token.
func (t *Controller) GetAccountTransactionHistoryWithFilters(token_id string, filters ...account.AccountHistoryFilters) (interface{}, error) {
org_id, err := t.Ctx.Model.GetTransientMapKeyAsString(constants.OrgIdCC)
if err != nil {
return nil, err
}
user_id, err := t.Ctx.Model.GetTransientMapKeyAsString(constants.UserIdCC)
if err != nil {
return nil, err
}
account_id, err := t.Ctx.Account.GenerateAccountId(token_id, org_id, user_id)
if err != nil {
return nil, err
}
auth, err := t.Ctx.Auth.CheckAuthorization("Account.GetAccountTransactionHistoryWithFilters", "TOKEN", map[string]string{"account_id": account_id})
if err != nil && !auth {
return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
}



// sample format of filter: []string{"3", "", "2022-01-16T15:16:36+00:00", "2022-01-17T15:16:36+00:00"}
transactionArray, err := t.Ctx.Account.GetReconciledTransactionHistory(account_id, org_id, user_id, filters...)
return transactionArray, err
}
Parameters:
  • token_id: string – The ID of the token.
  • org_id: string – The membership service provider (MSP) ID of the user in the current organization.
  • user_id: string – The user name or email ID of the user.
  • filters: string – An optional parameter. If empty, all records are returned. The PageSize property determines the number of records to return. If PageSize is 0, the default page size is 20. The Bookmark property determines the starting index of the records to return. For more information, see the Hyperledger Fabric documentation. The StartTime and EndTime properties must be specified in RFC-3339 format.
Return Value Example:
[
            {
                "transaction_id": "otransaction~64c5a4830949eae1424600f3d4a438c6f603a7c3ea31a68e374b899803999e22",
                "transacted_amount": 10,
                "timestamp": "2024-12-11T13:37:28.000Z",
                "balance": 550,
                "onhold_balance": 10,
                "token_id": "USD",
                "category": "category value",
                "description": "description value",
                "transacted_account": "oaccount~9d9806fa92aa0c4fdb34eaffac6e830181b5d47e64fbce752195e83024125ca0",
                "transaction_type": "REJECT_MINT",
                "transacted_org_id": "CB",
                "transacted_user_id'": "creator_user_cb"
            },
            {
                "transaction_id": "otransaction~a4537ef34a955b023b7c205b9abf06a6c79e4fdd761fb24f41b8eb34126b66c0",
                "transacted_amount": 10,
                "timestamp": "2024-12-11T13:36:32.000Z",
                "balance": 550,
                "onhold_balance": 10,
                "token_id": "USD",
                "description": "description value",
                "transacted_account": "oaccount~9d9806fa92aa0c4fdb34eaffac6e830181b5d47e64fbce752195e83024125ca0",
                "transaction_type": "APPROVE_MINT",
                "transacted_org_id": "CB",
                "transacted_user_id'": "creator_user_cb"
            },
            {
                "transaction_id": "otransaction~6237a759422bd9fb112742e8cd7e6450df5a74a32236d9b1005571afed8904a4",
                "transacted_amount": 10,
                "timestamp": "2024-12-11T13:36:18.000Z",
                "balance": 540,
                "onhold_balance": 10,
                "token_id": "USD",
                "category": "category value",
                "description": "description value",
                "transacted_account": "oaccount~9d9806fa92aa0c4fdb34eaffac6e830181b5d47e64fbce752195e83024125ca0",
                "transaction_type": "REQUEST_MINT",
                "transacted_org_id": "CB",
                "transacted_user_id'": "creator_user_cb"
            },
            {
                "transaction_id": "otransaction~06b35071415d74aa1a7c18449149c937d886cae76a832c44cf8d98e84586e76e",
                "transacted_amount": 10,
                "timestamp": "2024-12-11T13:35:46.000Z",
                "balance": 540,
                "onhold_balance": 10,
                "token_id": "USD",
                "category": "category value",
                "description": "description value",
                "transacted_account": "oaccount~9d9806fa92aa0c4fdb34eaffac6e830181b5d47e64fbce752195e83024125ca0",
                "transaction_type": "REQUEST_MINT",
                "transacted_org_id": "CB",
                "transacted_user_id'": "creator_user_cb"
            }
 ]