Bond Marketplace Model

The enhanced version of Blockchain App Builder includes a model attribute that generates additional methods for the bond marketplace scenario.

If you include the model: bond parameter in the specification file for tokens that use the extended ERC-1155 standard, Blockchain App Builder application-specific chaincode, including the following additional methods for use with the bond marketplace application.

TypeScript Methods for Bond Marketplace

The bond marketplace chaincode includes all methods available in the generic ERC-1155 NFT chaincode. The following additional methods that are specific to the bond marketplace scenario are available.
postToken
This method can be called only by a token creator. The method submits the bond token for listing in the marketplace. When a token is created, its status is initially set to created. This method updates the status to posted. Users can run the getAllTokensWithFilter method to retrieve all NFTs with a posted status.
public async postToken(tokenId: string)
Parameters:
  • tokenId: string – The ID of the token to post.
Return Value Example:
{
         "isValid":true,
         "payload":{
            "tokenMetadata":{
               "ISIN":"ISIN value",
               "Segment":"Segment value",
               "Issuer":"Issuer value",
               "FaceValue":10,
               "IssueSize":999,
               "CouponRate":10,
               "InterestPaymentType":"simple",
               "InterestFrequency":"monthly",
               "IssueDate":"2023-03-28T15:16:36.000Z",
               "MaturityDate":"2023-03-28T15:16:36.000Z"
            },
            "assetType":"otoken",
            "events":true,
            "tokenId":"bond1",
            "tokenName":"bond",
            "tokenDesc":"tokenDesc value",
            "tokenStandard":"erc1155+",
            "tokenType":"nonfungible",
            "tokenUnit":"fractional",
            "behaviors":[
               "divisible",
               "mintable",
               "transferable",
               "burnable",
               "roles"
            ],
            "roles":{
               "minter_role_name":"minter",
               "burner_role_name":"burner"
            },
            "mintable":{
               "max_mint_quantity":0
            },
            "quantity":100,
            "createdBy":"oaccount~276bcf1324b1ad1e493e22432db3b39f7a4b9bb17b8525c0391ea3ba36138e00",
            "creationDate":"2024-12-02T12:42:09.000Z",
            "divisible":{
               "decimal":0
            },
            "isBurned":false,
            "isLocked":false,
            "tokenUri":"tokenUri value",
            "status":"created"
         },
         "message":"Successfully updated asset with ID bond1"
      }
purchaseToken
This method can be called by any account holder to purchase a listed bond NFT. The purchase transfers the bond NFT from the creator's account to the caller's account, and transfers CBDC tokens from the caller's account to the creator's account. Because of this, the method must be run in the context of an atomic transaction. The method also verifies the transfer process, ensuring that the appropriate CBDC chaincode is called with the correct orgId and userId for the transfer. The orgId and userId must correspond to the token creator, and the CBDC token transfer value must be equal to the face value of the bond token multiplied by the quantity being purchased.
public async purchaseToken(tokenId: string, quantity: number, orderId: string, additionalFees: number)
Parameters:
  • tokenId: string – The ID of the token to purchase.
  • quantity: number – The amount of tokens to purchase.
  • orderId: string – The order ID for the purchase operation.
  • additionalFees: number – The additional fees to add to the purchase price.
Return Value Example:
{
   "returnCode":"Success",
   "error":"",
   "result":{
      "transactions":[
         {
            "channel":"test",
            "chaincode":"BondMarketplace",
            "txstatus":"Committed",
            "prepare":{
               "txid":"e969f962df5efda2ea6287380e308cc974efd79dfff3567840ed3844bf936160"
            },
            "commit":{
               "txid":"5544e928d3242291fb39189e8329679a9c81d61d6f72db60ca89135cd20fffef"
            },
            "rollback":{
               
            }
         },
         {
            "channel":"cbdctest",
            "chaincode":"cbdc",
            "txstatus":"Committed",
            "prepare":{
               "txid":"1245885b1a0c7f12c41fa2f2905549b8a5f37ab3a5e094b9dca122cb0611a117"
            },
            "commit":{
               "txid":"3c83e20c7d470cdc9c1b0e2e0ea8d9962d58ada8d1b8f0d2606c8aa1f0ae7741"
            },
            "rollback":{
               
            }
         }
      ],
      "lrc":{
         
      },
      "globalStatus":"Success",
      "globalTxid":"761bb7cc-1d66-4645-aeb2-50e4dbd23d83",
      "txStartTime":"2024-12-05T12:01:21.881988035Z"
   }
}
payInterest
This method can be called only by the token creator or admin to pay the interest earned on the bond token. This method can be called only if the interest frequency of the token is monthly, quarterly, or annually. Interest cannot be paid if the interest frequency is at maturity. Interest is calculated by the chaincode based on the coupon rate of the token. The purchase operation transfers CBDC tokens from the caller's account to the bond owner’s account. Because of this, this method must be run in the context of an atomic transaction. The method also verifies the transfer process, ensuring the appropriate CBDC chaincode is called with the correct orgId and userId for the transfer. The orgId and userId must correspond to the token owner, and the CBDC token transfer value must be equal to the interest calculated by the bond chaincode.
public async payInterest(orgId: string, userId: string, tokenId: string, orderId: string)
Parameters:
  • orgId: string – The membership service provider (MSP) ID of the user.
  • userId: string – The user name or email ID of the user.
  • tokenId: string – The ID of the token.
  • orderId: string – The order ID for the purchase operation.
Return Value Example:
{
   "returnCode":"Success",
   "error":"",
   "result":{
      "transactions":[
         {
            "channel":"test",
            "chaincode":"BondMarketplace",
            "txstatus":"Committed",
            "prepare":{
               "txid":"e969f962df5efda2ea6287380e308cc974efd79dfff3567840ed3844bf936160"
            },
            "commit":{
               "txid":"5544e928d3242291fb39189e8329679a9c81d61d6f72db60ca89135cd20fffef"
            },
            "rollback":{
               
            }
         },
         {
            "channel":"cbdctest",
            "chaincode":"cbdc",
            "txstatus":"Committed",
            "prepare":{
               "txid":"1245885b1a0c7f12c41fa2f2905549b8a5f37ab3a5e094b9dca122cb0611a117"
            },
            "commit":{
               "txid":"3c83e20c7d470cdc9c1b0e2e0ea8d9962d58ada8d1b8f0d2606c8aa1f0ae7741"
            },
            "rollback":{
               
            }
         }
      ],
      "lrc":{
         
      },
      "globalStatus":"Success",
      "globalTxid":"761bb7cc-1d66-4645-aeb2-50e4dbd23d83",
      "txStartTime":"2024-12-05T12:01:21.881988035Z"
   }
}
requestTokenRedemption
This method can be called only by the token owner to raise a request for the redemption of bond tokens after maturity. This method is also involved the calculation of the redemption price by the chaincode. Redemption requests can be raised only on the entire quantity of the bond token that the user owns. Users can raise multiple redemption requests based on different settlement IDs but only one can be approved by the token creator.
public async requestTokenRedemption(settlementId: string, tokenId: string, orderId: string, additionalFees: number)
Parameters:
  • settlementId: string – The settlement ID for the redemption operation.
  • tokenId: string – The ID of the token.
  • orderId: string – The order ID for the purchase operation.
  • additionalFees: number – The additional fees to add to the redemption price.
Return Value Example:
{
         "tokenName":"bond",
         "assetType":"otokenApproval",
         "id":"otokenApproval~9e006057ac96ae997e3964531b1a08ad2316555701c7fe9ec7b88e38e20892bf",
         "settlementId":"op4",
         "userBondDetailsId":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op4",
         "fromAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
         "toAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
         "tokenId":"bond1",
         "quantity":1,
         "status":"PENDING",
         "orderId":"op4",
         "redeemPrice":11

}
approveTokenRedemption
This method can be called only by the token creator to approve a request for the redemption of bond tokens. The approval operation transfers the bond NFT from the owner’s account (the user who raised the request) to the creator’s account, and transfers CBDC tokens from the bond creator’s to the owner’s account. Because of this, this method must be executed in the context of an atomic transaction. The method also verifies the transfer process, ensuring the appropriate CBDC chaincode is called with the correct orgId and userId for the transfer. The orgId and userId must correspond to the account of the token owner who raised the redemption request, and the CBDC token transfer value must be equal to the calculated redemption price that was calculated by the chaincode while raising the redemption request.
public async approveRedemption(fromOrgId: string, fromUserId: string, settlementId: string, tokenId: string)
Parameters:
  • fromOrgId: string – The membership service provider (MSP) ID of the user.
  • fromUserId: string – The user name or email ID of the user.
  • settlementId: string – The settlement ID for the redemption operation.
  • tokenId: string – The ID of the token.
Return Value Example:
{
   "returnCode":"Success",
   "error":"",
   "result":{
      "transactions":[
         {
            "channel":"test",
            "chaincode":"BondMarketplace",
            "txstatus":"Committed",
            "prepare":{
               "txid":"e969f962df5efda2ea6287380e308cc974efd79dfff3567840ed3844bf936160"
            },
            "commit":{
               "txid":"5544e928d3242291fb39189e8329679a9c81d61d6f72db60ca89135cd20fffef"
            },
            "rollback":{
               
            }
         },
         {
            "channel":"cbdctest",
            "chaincode":"cbdc",
            "txstatus":"Committed",
            "prepare":{
               "txid":"1245885b1a0c7f12c41fa2f2905549b8a5f37ab3a5e094b9dca122cb0611a117"
            },
            "commit":{
               "txid":"3c83e20c7d470cdc9c1b0e2e0ea8d9962d58ada8d1b8f0d2606c8aa1f0ae7741"
            },
            "rollback":{
               
            }
         }
      ],
      "lrc":{
         
      },
      "globalStatus":"Success",
      "globalTxid":"761bb7cc-1d66-4645-aeb2-50e4dbd23d83",
      "txStartTime":"2024-12-05T12:01:21.881988035Z"
   }
}
rejectRedemption
The token creator can call this method to reject the redemption request. Token owners can raise a redemption request again by using a different settlement ID.
public async rejectRedemption(fromOrgId: string, fromUserId: string, settlementId: string, tokenId: string)
Parameters:
  • fromOrgId: string – The membership service provider (MSP) ID of the user.
  • fromUserId: string – The user name or email ID of the user.
  • settlementId: string – The settlement ID for the redemption operation.
  • tokenId: string – The ID of the token.
Return Value Example:
{
   "status":"success",
   "msg":"Successfully rejected the token approval request"
}
getAllTokensWithFilters
The admin can call this get method to fetch all the tokens filtered by status, either CREATED or POSTED.
public async getAllTokensWithFilters(status: string, pageSize: number, bookmark: string)
Parameters:
  • status: string – The status of the token, which can either be CREATED or POSTED.
  • pageSize: number – The page size of the returned result.
  • bookmark: string – The bookmark of the returned result.
Return Value Example:
[{
            "tokenMetadata":{
               "ISIN":"ISIN value",
               "Segment":"Segment value",
               "Issuer":"Issuer value",
               "FaceValue":10,
               "IssueSize":999,
               "CouponRate":10,
               "InterestPaymentType":"simple",
               "InterestFrequency":"monthly",
               "IssueDate":"2023-03-28T15:16:36.000Z",
               "MaturityDate":"2023-03-28T15:16:36.000Z"
            },
            "assetType":"otoken",
            "events":true,
            "tokenId":"bond1",
            "tokenName":"bond",
            "tokenDesc":"tokenDesc value",
            "tokenStandard":"erc1155+",
            "tokenType":"nonfungible",
            "tokenUnit":"fractional",
            "behaviors":[
               "divisible",
               "mintable",
               "transferable",
               "burnable",
               "roles"
            ],
            "roles":{
               "minter_role_name":"minter",
               "burner_role_name":"burner"
            },
            "mintable":{
               "max_mint_quantity":0
            },
            "quantity":100,
            "createdBy":"oaccount~276bcf1324b1ad1e493e22432db3b39f7a4b9bb17b8525c0391ea3ba36138e00",
            "creationDate":"2024-12-02T12:42:09.000Z",
            "divisible":{
               "decimal":0
            },
            "isBurned":false,
            "isLocked":false,
            "tokenUri":"tokenUri value",
            "status":"posted"
         }

]
getTokenApprovalRequestByUser
Any account holder can call this get method to get the details of all the token approval requests (redemption requests) they have made.
public async getTokenApprovalRequestByUser(status: string)
Parameters:
  • status: string – The status of the request, which can be PENDING, REJECTED, or APPROVED.
Return Value Example:
[
   {
      "tokenName":"bond",
      "assetType":"otokenApproval",
      "id":"otokenApproval~5b2a94283ae95e3d6e5b76ffd6f75b7bff231e4df270a82cdc1f6badd17dea4b",
      "settlementId":"op1",
      "userBondDetailsId":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op1",
      "fromAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
      "toAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
      "tokenId":"bond1",
      "quantity":2,
      "status":"APPROVED",
      "orderId":"op1",
      "redeemPrice":1,
      "purchasedPrice":11,
      "interestEarned":0
   },
   {
      "tokenName":"bond",
      "assetType":"otokenApproval",
      "id":"otokenApproval~fdf28b2d271ac9c0fbd94a2dedbf365728c77795f3e931e5a4a2dcf48039a989",
      "settlementId":"op3",
      "userBondDetailsId":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op3",
      "fromAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
      "toAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
      "tokenId":"bond1",
      "quantity":1,
      "status":"APPROVED",
      "orderId":"op3",
      "redeemPrice":11,
      "purchasedPrice":11,
      "interestEarned":0
   }
]
getTokenApprovalRequestForUserByStatus
Any account holder can call this get method to get the details of all the token approval requests (redemption requests) they have made.
public async getTokenApprovalRequestForUserByStatus(status: string)
Parameters:
  • status: string – The status of the request, which can be PENDING, REJECTED, or APPROVED.
Return Value Example:
[
   {
      "tokenName":"bond",
      "assetType":"otokenApproval",
      "id":"otokenApproval~5b2a94283ae95e3d6e5b76ffd6f75b7bff231e4df270a82cdc1f6badd17dea4b",
      "settlementId":"op1",
      "userBondDetailsId":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op1",
      "fromAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
      "toAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
      "tokenId":"bond1",
      "quantity":2,
      "status":"APPROVED",
      "orderId":"op1",
      "redeemPrice":1,
      "purchasedPrice":11,
      "interestEarned":0
   },
   {
      "tokenName":"bond",
      "assetType":"otokenApproval",
      "id":"otokenApproval~fdf28b2d271ac9c0fbd94a2dedbf365728c77795f3e931e5a4a2dcf48039a989",
      "settlementId":"op3",
      "userBondDetailsId":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op3",
      "fromAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
      "toAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
      "tokenId":"bond1",
      "quantity":1,
      "status":"APPROVED",
      "orderId":"op3",
      "redeemPrice":11,
      "purchasedPrice":11,
      "interestEarned":0
   }
]
getAccountBondSummary
Any account holder can call this get method to get an account summary that includes the details of purchased or redeemed tokens and the purchase price and redemption price.
public async getAccountBondSummary(orgId: string, userId: string)
Parameters:
  • orgId: string – The membership service provider (MSP) ID of the user.
  • userId: string – The user name or email ID of the user.
Return Value Example:
{

   "userAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
   "orgId":"BondMPTest",
   "userId":"u10",
   "accountSummary":[
      {
         "purchasedQuantity":1,
         "assetType":"oUserBondDetails",
         "id":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op1",
         "tokenId":"bond1",
         "status":"Redeemed",
         "purchasedAmount":11,
         "purchasedDate":"2024-12-02T00:00:00.000Z",
         "purchasedFromAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
         "orderId":"op1"
         "redeemPrice":11,
         "quantityRedeem":1,
         "redeemStatus":"REJECTED"
      },
      {
         "purchasedQuantity":1,
         "assetType":"oUserBondDetails",
         "id":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op2",
         "tokenId":"bond1",
         "status":"Purchased",
         "purchasedAmount":11,
         "purchasedDate":"2024-12-02T00:00:00.000Z",
         "purchasedFromAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
         "orderId":"op2",
         "redeemPrice":11,
         "quantityRedeem":1,
         "redeemStatus":"APPROVED"
      }
   ]
}
getAccountBondSummaryWithPagination
Any account holder can call this get method to get an account summary that includes details of purchased or redeemed tokens and the purchase price and redemption price. This method can return results with pagination based on pagesize and bookmark values, and also filtered by start time and end time.
public async getAccountBondSummaryWithPagination(orgId: string, userId: string, pageSize: number, bookmark?: string)
Parameters:
  • orgId: string – The membership service provider (MSP) ID of the user.
  • userId: string – The user name or email ID of the user.
  • pageSize: number – The page size of the returned result.
  • bookmark: string – The bookmark of the returned result.
Return Value Example:
{

   "userAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
   "orgId":"BondMPTest",
   "userId":"u10",
   "accountSummary":[
      {
         "purchasedQuantity":1,
         "assetType":"oUserBondDetails",
         "id":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op1",
         "tokenId":"bond1",
         "status":"Redeemed",
         "purchasedAmount":11,
         "purchasedDate":"2024-12-02T00:00:00.000Z",
         "purchasedFromAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
         "orderId":"op1"
         "redeemPrice":11,
         "quantityRedeem":1,
         "redeemStatus":"REJECTED"
      },
      {
         "purchasedQuantity":1,
         "assetType":"oUserBondDetails",
         "id":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op2",
         "tokenId":"bond1",
         "status":"Purchased",
         "purchasedAmount":11,
         "purchasedDate":"2024-12-02T00:00:00.000Z",
         "purchasedFromAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
         "orderId":"op2",
         "redeemPrice":11,
         "quantityRedeem":1,
         "redeemStatus":"APPROVED"
      }
   ]
}

Go Methods for Bond Marketplace

The bond marketplace chaincode includes all methods available in the generic ERC-1155 NFT chaincode. The following additional methods that are specific to the bond marketplace scenario are available.
PostToken
This method can be called only by a token creator. The method submits the bond token for listing in the marketplace. When a token is created, its status is initially set to created. This method updates the status to posted. Users can run the getAllTokensWithFilter method to retrieve all NFTs with a posted status.
func (t *Controller) PostToken(tokenId string) (interface{}, error)
Parameters:
  • tokenId: string – The ID of the token to post.
Return Value Example:
{
         "isValid":true,
         "payload":{
            "tokenMetadata":{
               "ISIN":"ISIN value",
               "Segment":"Segment value",
               "Issuer":"Issuer value",
               "FaceValue":10,
               "IssueSize":999,
               "CouponRate":10,
               "InterestPaymentType":"simple",
               "InterestFrequency":"monthly",
               "IssueDate":"2023-03-28T15:16:36.000Z",
               "MaturityDate":"2023-03-28T15:16:36.000Z"
            },
            "AssetType":"otoken",
            "Events":true,
            "TokenId":"bond1",
            "TokenName":"bond",
            "TokenDesc":"tokenDesc value",
            "TokenStandard":"erc1155+",
            "TokenType":"nonfungible",
            "TokenUnit":"fractional",
            "Behaviors":[
               "divisible",
               "mintable",
               "transferable",
               "burnable",
               "roles"
            ],
            "Roles":{
               "minter_role_name":"minter",
               "burner_role_name":"burner"
            },
            "Mintable":{
               "max_mint_quantity":0
            },
            "Quantity":100,
            "CreatedBy":"oaccount~276bcf1324b1ad1e493e22432db3b39f7a4b9bb17b8525c0391ea3ba36138e00",
            "CreationDate":"2024-12-02T12:42:09.000Z",
            "Divisible":{
               "decimal":0
            },
            "IsBurned":false,
            "IsLocked":false,
            "TokenUri":"tokenUri value",
            "Status":"created"
         },
         "message":"Successfully updated asset with ID bond1"
      }
PurchaseToken
This method can be called by any account holder to purchase a listed bond NFT. The purchase transfers the bond NFT from the creator's account to the caller's account, and transfers CBDC tokens from the caller's account to the creator's account. Because of this, the method must be run in the context of an atomic transaction. The method also verifies the transfer process, ensuring that the appropriate CBDC chaincode is called with the correct orgId and userId for the transfer. The orgId and userId must correspond to the token creator, and the CBDC token transfer value must be equal to the face value of the bond token multiplied by the quantity being purchased.
func (t *Controller) PurchaseToken(tokenId string, quantity float64, orderId string, additionalFees float64) (interface{}, error)
Parameters:
  • tokenId: string – The ID of the token to purchase.
  • quantity: number – The amount of tokens to purchase.
  • orderId: string – The order ID for the purchase operation.
  • additionalFees: number – The additional fees to add to the purchase price.
Return Value Example:
{
   "returnCode":"Success",
   "error":"",
   "result":{
      "transactions":[
         {
            "channel":"test",
            "chaincode":"BondMarketplace",
            "txstatus":"Committed",
            "prepare":{
               "txid":"e969f962df5efda2ea6287380e308cc974efd79dfff3567840ed3844bf936160"
            },
            "commit":{
               "txid":"5544e928d3242291fb39189e8329679a9c81d61d6f72db60ca89135cd20fffef"
            },
            "rollback":{
               
            }
         },
         {
            "channel":"cbdctest",
            "chaincode":"cbdc",
            "txstatus":"Committed",
            "prepare":{
               "txid":"1245885b1a0c7f12c41fa2f2905549b8a5f37ab3a5e094b9dca122cb0611a117"
            },
            "commit":{
               "txid":"3c83e20c7d470cdc9c1b0e2e0ea8d9962d58ada8d1b8f0d2606c8aa1f0ae7741"
            },
            "rollback":{
               
            }
         }
      ],
      "lrc":{
         
      },
      "globalStatus":"Success",
      "globalTxid":"761bb7cc-1d66-4645-aeb2-50e4dbd23d83",
      "txStartTime":"2024-12-05T12:01:21.881988035Z"
   }
}
PayInterest
This method can be called only by the token creator or admin to pay the interest earned on the bond token. This method can be called only if the interest frequency of the token is monthly, quarterly, or annually. Interest cannot be paid if the interest frequency is at maturity. Interest is calculated by the chaincode based on the coupon rate of the token. The purchase operation transfers CBDC tokens from the caller's account to the bond owner’s account. Because of this, this method must be run in the context of an atomic transaction. The method also verifies the transfer process, ensuring the appropriate CBDC chaincode is called with the correct orgId and userId for the transfer. The orgId and userId must correspond to the token owner, and the CBDC token transfer value must be equal to the interest calculated by the bond chaincode.
func (t *Controller) PayInterestEarned(orgId string, userId string, tokenId string, orderId string, additionalFees float64) (interface{}, error)
Parameters:
  • orgId: string – The membership service provider (MSP) ID of the user.
  • userId: string – The user name or email ID of the user.
  • tokenId: string – The ID of the token.
  • orderId: string – The order ID for the purchase operation.
Return Value Example:
{
   "returnCode":"Success",
   "error":"",
   "result":{
      "transactions":[
         {
            "channel":"test",
            "chaincode":"BondMarketplace",
            "txstatus":"Committed",
            "prepare":{
               "txid":"e969f962df5efda2ea6287380e308cc974efd79dfff3567840ed3844bf936160"
            },
            "commit":{
               "txid":"5544e928d3242291fb39189e8329679a9c81d61d6f72db60ca89135cd20fffef"
            },
            "rollback":{
               
            }
         },
         {
            "channel":"cbdctest",
            "chaincode":"cbdc",
            "txstatus":"Committed",
            "prepare":{
               "txid":"1245885b1a0c7f12c41fa2f2905549b8a5f37ab3a5e094b9dca122cb0611a117"
            },
            "commit":{
               "txid":"3c83e20c7d470cdc9c1b0e2e0ea8d9962d58ada8d1b8f0d2606c8aa1f0ae7741"
            },
            "rollback":{
               
            }
         }
      ],
      "lrc":{
         
      },
      "globalStatus":"Success",
      "globalTxid":"761bb7cc-1d66-4645-aeb2-50e4dbd23d83",
      "txStartTime":"2024-12-05T12:01:21.881988035Z"
   }
}
RequestTokenRedemption
This method can be called only by the token owner to raise a request for the redemption of bond tokens after maturity. This method is also involved the calculation of the redemption price by the chaincode. Redemption requests can be raised only on the entire quantity of the bond token that the user owns. Users can raise multiple redemption requests based on different settlement IDs but only one can be approved by the token creator.
func (t *Controller) RequestTokenRedemption(settlementId string, tokenId string, orderId string, additionalFees float64) (interface{}, error)
Parameters:
  • settlementId: string – The settlement ID for the redemption operation.
  • tokenId: string – The ID of the token.
  • orderId: string – The order ID for the purchase operation.
  • additionalFees: number – The additional fees to add to the redemption price.
Return Value Example:
{
         "TokenName":"bond",
         "AssetType":"otokenApproval",
         "Id":"otokenApproval~9e006057ac96ae997e3964531b1a08ad2316555701c7fe9ec7b88e38e20892bf",
         "SettlementId":"op4",
         "UserBondDetailsId":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op4",
         "FromAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
         "ToAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
         "TokenId":"bond1",
         "Quantity":1,
         "Status":"PENDING",
         "OrderId":"op4",
         "RedeemPrice":11
}
ApproveTokenRedemption
This method can be called only by the token creator to approve a request for the redemption of bond tokens. The approval operation transfers the bond NFT from the owner’s account (the user who raised the request) to the creator’s account, and transfers CBDC tokens from the bond creator’s to the owner’s account. Because of this, this method must be executed in the context of an atomic transaction. The method also verifies the transfer process, ensuring the appropriate CBDC chaincode is called with the correct orgId and userId for the transfer. The orgId and userId must correspond to the account of the token owner who raised the redemption request, and the CBDC token transfer value must be equal to the calculated redemption price that was calculated by the chaincode while raising the redemption request.
func (t *Controller) ApproveRedemption(fromOrgId string, fromUserId string, settlementId string, tokenId string) (interface{}, error)
Parameters:
  • fromOrgId: string – The membership service provider (MSP) ID of the user.
  • fromUserId: string – The user name or email ID of the user.
  • settlementId: string – The settlement ID for the redemption operation.
  • tokenId: string – The ID of the token.
Return Value Example:
{
   "returnCode":"Success",
   "error":"",
   "result":{
      "transactions":[
         {
            "channel":"test",
            "chaincode":"BondMarketplace",
            "txstatus":"Committed",
            "prepare":{
               "txid":"e969f962df5efda2ea6287380e308cc974efd79dfff3567840ed3844bf936160"
            },
            "commit":{
               "txid":"5544e928d3242291fb39189e8329679a9c81d61d6f72db60ca89135cd20fffef"
            },
            "rollback":{
               
            }
         },
         {
            "channel":"cbdctest",
            "chaincode":"cbdc",
            "txstatus":"Committed",
            "prepare":{
               "txid":"1245885b1a0c7f12c41fa2f2905549b8a5f37ab3a5e094b9dca122cb0611a117"
            },
            "commit":{
               "txid":"3c83e20c7d470cdc9c1b0e2e0ea8d9962d58ada8d1b8f0d2606c8aa1f0ae7741"
            },
            "rollback":{
               
            }
         }
      ],
      "lrc":{
         
      },
      "globalStatus":"Success",
      "globalTxid":"761bb7cc-1d66-4645-aeb2-50e4dbd23d83",
      "txStartTime":"2024-12-05T12:01:21.881988035Z"
   }
}
RejectRedemption
The token creator can call this method to reject the redemption request. Token owners can raise a redemption request again by using a different settlement ID.
func (t *Controller) RejectRedemption(fromOrgId string, fromUserId string, settlementId string, tokenId string) (interface{}, error)
Parameters:
  • fromOrgId: string – The membership service provider (MSP) ID of the user.
  • fromUserId: string – The user name or email ID of the user.
  • settlementId: string – The settlement ID for the redemption operation.
  • tokenId: string – The ID of the token.
Return Value Example:
{
   "status":"success",
   "msg":"Successfully rejected the token approval request"
}
GetAllTokensWithFilter
The admin can call this get method to fetch all the tokens filtered by status, either CREATED or POSTED.
func (t *Controller) GetAllTokensWithFilters(status string, pageSize int32, bookmark string)
Parameters:
  • status: string – The status of the token, which can either be CREATED or POSTED.
  • pageSize: number – The page size of the returned result.
  • bookmark: string – The bookmark of the returned result.
Return Value Example:
[ {

               "ISIN":"ISIN value",
               "Segment":"Segment value",
               "Issuer":"Issuer value",
               "FaceValue":10,
               "IssueSize":999,
               "CouponRate":10,
               "InterestPaymentType":"simple",
               "InterestFrequency":"monthly",
               "IssueDate":"2023-03-28T15:16:36.000Z",
               "MaturityDate":"2023-03-28T15:16:36.000Z"
            },
            "AssetType":"otoken",
            "Events":true,
            "TokenId":"bond1",
            "TokenName":"bond",
            "TokenDesc":"tokenDesc value",
            "TokenStandard":"erc1155+",
            "TokenType":"nonfungible",
            "TokenUnit":"fractional",
            "Behaviors":[
               "divisible",
               "mintable",
               "transferable",
               "burnable",
               "roles"
            ],
            "Roles":{
               "minter_role_name":"minter",
               "burner_role_name":"burner"
            },
            "Mintable":{
               "max_mint_quantity":0
            },
            "Quantity":100,
            "CreatedBy":"oaccount~276bcf1324b1ad1e493e22432db3b39f7a4b9bb17b8525c0391ea3ba36138e00",
            "CreationDate":"2024-12-02T12:42:09.000Z",
            "Divisible":{
               "decimal":0
            },
            "IsBurned":false,
            "IsLocked":false,
            "TokenUri":"tokenUri value",
            "Status":"posted"
         }

]
GetTokenApprovalRequestByUser
Any account holder can call this get method to get the details of all the token approval requests (redemption requests) they have made.
func (t *Controller) GetTokenApprovalRequestByUser(status string) (interface{}, error)
Parameters:
  • status: string – The status of the request, which can be PENDING, REJECTED, or APPROVED.
Return Value Example:
[
   {
      "TokenName":"bond",
      "AssetType":"otokenApproval",
      "Id":"otokenApproval~5b2a94283ae95e3d6e5b76ffd6f75b7bff231e4df270a82cdc1f6badd17dea4b",
      "SettlementId":"op1",
      "UserBondDetailsId":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op1",
      "FromAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
      "ToAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
      "TokenId":"bond1",
      "Quantity":2,
      "Status":"APPROVED",
      "OrderId":"op1",
      "RedeemPrice":1,
      "PurchasedPrice":11,
      "InterestEarned":0
   },
   {
      "TokenName":"bond",
      "AssetType":"otokenApproval",
      "Id":"otokenApproval~fdf28b2d271ac9c0fbd94a2dedbf365728c77795f3e931e5a4a2dcf48039a989",
      "SettlementId":"op3",
      "UserBondDetailsId":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op3",
      "FromAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
      "ToAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
      "TokenId":"bond1",
      "Quantity":1,
      "Status":"APPROVED",
      "OrderId":"op3",
      "RedeemPrice":11,
      "PurchasedPrice":11,
      "InterestEarned":0
   }
]
GetTokenApprovalRequestForUserByStatus
Any account holder can call this get method to get the details of all the token approval requests (redemption requests) they have made.
func (t *Controller) GetTokenApprovalRequestForUserByStatus(status string) (interface{}, error)
Parameters:
  • status: string – The status of the request, which can be PENDING, REJECTED, or APPROVED.
Return Value Example:
[
   {
      "TokenName":"bond",
      "AssetType":"otokenApproval",
      "Id":"otokenApproval~5b2a94283ae95e3d6e5b76ffd6f75b7bff231e4df270a82cdc1f6badd17dea4b",
      "SettlementId":"op1",
      "UserBondDetailsId":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op1",
      "FromAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
      "ToAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
      "TokenId":"bond1",
      "Quantity":2,
      "Status":"APPROVED",
      "OrderId":"op1",
      "RedeemPrice":1,
      "PurchasedPrice":11,
      "InterestEarned":0
   },
   {
      "TokenName":"bond",
      "AssetType":"otokenApproval",
      "Id":"otokenApproval~fdf28b2d271ac9c0fbd94a2dedbf365728c77795f3e931e5a4a2dcf48039a989",
      "SettlementId":"op3",
      "UserBondDetailsId":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op3",
      "FromAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
      "ToAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
      "TokenId":"bond1",
      "Quantity":1,
      "Status":"APPROVED",
      "OrderId":"op3",
      "RedeemPrice":11,
      "PurchasedPrice":11,
      "InterestEarned":0
   }
]
GetAccountBondSummary
Any account holder can call this get method to get an account summary that includes the details of purchased or redeemed tokens and the purchase price and redemption price.
func (t *Controller) GetAccountBondSummary(orgId string, userId string) (interface{}, error)
Parameters:
  • orgId: string – The membership service provider (MSP) ID of the user.
  • userId: string – The user name or email ID of the user.
Return Value Example:
{

   "userAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
   "orgId":"BondMPTest",
   "userId":"u10",
   "accountSummary":[
      {
         "PurchasedQuantity":1,
         "AssetType":"oUserBondDetails",
         "Id":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op1",
         "TokenId":"bond1",
         "Status":"Redeemed",
         "PurchasedAmount":11,
         "PurchasedDate":"2024-12-02T00:00:00.000Z",
         "PurchasedFromAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
         "OrderId":"op1"
         "RedeemPrice":11,
         "QuantityRedeem":1,
         "RedeemStatus":"REJECTED"
      },
      {
         "PurchasedQuantity":1,
         "AssetType":"oUserBondDetails",
         "Id":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op2",
         "TokenId":"bond1",
         "Status":"Purchased",
         "PurchasedAmount":11,
         "PurchasedDate":"2024-12-02T00:00:00.000Z",
         "PurchasedFromAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
         "OrderId":"op2",
         "RedeemPrice":11,
         "QuantityRedeem":1,
         "RedeemStatus":"APPROVED"
      }
   ]
}
GetAccountBondSummaryWithPagination
Any account holder can call this get method to get an account summary that includes details of purchased or redeemed tokens and the purchase price and redemption price. This method can return results with pagination based on pagesize and bookmark values, and also filtered by start time and end time.
func (t *Controller) GetAccountBondSummaryWithPagination(orgId string, userId string, pageSize int32, bookmark string) (interface{}, error)
Parameters:
  • orgId: string – The membership service provider (MSP) ID of the user.
  • userId: string – The user name or email ID of the user.
  • pageSize: number – The page size of the returned result.
  • bookmark: string – The bookmark of the returned result.
Return Value Example:
{

   "userAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
   "orgId":"BondMPTest",
   "userId":"u10",
   "accountSummary":[
      {
         "PurchasedQuantity":1,
         "AssetType":"oUserBondDetails",
         "Id":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op1",
         "TokenId":"bond1",
         "Status":"Redeemed",
         "PurchasedAmount":11,
         "PurchasedDate":"2024-12-02T00:00:00.000Z",
         "PurchasedFromAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
         "OrderId":"op1"
         "RedeemPrice":11,
         "QuantityRedeem":1,
         "RedeemStatus":"REJECTED"
      },
      {
         "PurchasedQuantity":1,
         "AssetType":"oUserBondDetails",
         "Id":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op2",
         "TokenId":"bond1",
         "Status":"Purchased",
         "PurchasedAmount":11,
         "PurchasedDate":"2024-12-02T00:00:00.000Z",
         "PurchasedFromAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
         "OrderId":"op2",
         "RedeemPrice":11,
         "QuantityRedeem":1,
         "RedeemStatus":"APPROVED"
      }
   ]
}

TypeScript SDK Methods for Bond Marketplace

payInterest
The token creator or admin can call this method to pay the interest earned on a bond token. This method can be called only if the interest frequency of the token is monthly, quarterly, or annually. Interest cannot be paid if the interest frequency is at maturity. Interest is calculated by the chaincode itself based on the coupon rate of the token. The purchase operation transfers CBDC tokens from the caller's account to the bond owner’s account. Because of this, this method must be run in the context of an atomic transaction. The method also verifies the transfer process, ensuring the appropriate CBDC chaincode is called with the correct orgId and userId for the transfer. The orgId and userId must correspond to the token owner, and the CBDC token transfer value must be equal to the interest that is calculated by the bond chaincode.
this.Ctx.ERC1155AccountBondSummary.payInterest(userAccountId, tokenId, orderId)
Parameters:
  • userAccountId: string – The account ID of the user.
  • tokenId: string – The ID of the token.
  • orderId: string – The order ID for the purchase operation.
Return Value Example:
{
         "purchasedQuantity":1,
         "assetType":"oUserBondDetails",
         "id":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op1",
         "tokenId":"bond1",
         "status":"Redeemed",
         "purchasedAmount":11,
         "purchasedDate":"2024-12-02T00:00:00.000Z",
         "purchasedFromAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
         "orderId":"op1"
         "interestEarned": 11,
         "interestEarnedDate": "2024-12-02T00:00:00.000Z"
}
requestTokenRedemption
This method can be called only by the token owner to raise a request for the redemption of bond tokens after maturity. This method is also involved the calculation of the redemption price by the chaincode. Redemption requests can be raised only on the entire quantity of the bond token that the user owns. Users can raise multiple redemption requests based on different settlement IDs but only one can be approved by the token creator.
this.Ctx.ERC1155TokenApproval.requestTokenRedemption(callerUserAccountId, settlementId, tokenId, orderId, quantity, additionalFees);
Parameters:
  • callerUserAccountId: string – The account ID of the user.
  • settlementId: string – The settlement ID for the redemption operation.
  • tokenId: string – The ID of the token.
  • orderId: string – The order ID for the purchase operation.
  • additionalFees: number – The additional fees to add to the redemption price.
Return Value Example:
{
         "tokenName":"bond",
         "assetType":"otokenApproval",
         "id":"otokenApproval~9e006057ac96ae997e3964531b1a08ad2316555701c7fe9ec7b88e38e20892bf",
         "settlementId":"op4",
         "userBondDetailsId":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op4",
         "fromAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
         "toAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
         "tokenId":"bond1",
         "quantity":1,
         "status":"PENDING",
         "orderId":"op4",
         "redeemPrice":11
}
approveTokenRedemption
This method can be called only by the token creator to approve a request for the redemption of bond tokens. The approval operation transfers the bond NFT from the owner’s account (the user who raised the request) to the creator’s account, and transfers CBDC tokens from the bond creator’s to the owner’s account. Because of this, this method must be executed in the context of an atomic transaction. The method also verifies the transfer process, ensuring the appropriate CBDC chaincode is called with the correct orgId and userId for the transfer. The orgId and userId must correspond to the account of the token owner who raised the redemption request, and the CBDC token transfer value must be equal to the calculated redemption price that was calculated by the chaincode while raising the redemption request.
this.Ctx.ERC1155TokenApproval.approveTokenApprovalRequest(fromUserAccountId, settlementId, tokenId)
Parameters:
  • fromUserAccountId: string – The account ID of the user.
  • settlementId: string – The settlement ID for the redemption operation.
  • tokenId: string – The ID of the token.
Return Value Example:
{
   "status":"success",
   "msg":"Successfully approved the token approval request"
}
rejectRedemption
The token creator can call this method to reject the redemption request. Token owners can raise a redemption request again by using a different settlement ID.
this.Ctx.ERC1155TokenApproval.rejectTokenApprovalRequest(fromUserAccountId, settlementId, tokenId)
Parameters:
  • fromOrgId: string – The membership service provider (MSP) ID of the user.
  • fromUserId: string – The user name or email ID of the user.
  • settlementId: string – The settlement ID for the redemption operation.
  • tokenId: string – The ID of the token.
Return Value Example:
{
   "status":"success",
   "msg":"Successfully rejected the token approval request"
}
getAllTokensWithFilter
The admin can call this get method to fetch all the tokens filtered by status, either CREATED or POSTED.
this.Ctx.ERC1155Token.getAllTokensWithFilters(status, pageSize, bookmark)
Parameters:
  • status: string – The status of the token, which can either be CREATED or POSTED.
  • pageSize: number – The page size of the returned result.
  • bookmark: string – The bookmark of the returned result.
Return Value Example:
[{
            "tokenMetadata":{
               "ISIN":"ISIN value",
               "Segment":"Segment value",
               "Issuer":"Issuer value",
               "FaceValue":10,
               "IssueSize":999,
               "CouponRate":10,
               "InterestPaymentType":"simple",
               "InterestFrequency":"monthly",
               "IssueDate":"2023-03-28T15:16:36.000Z",
               "MaturityDate":"2023-03-28T15:16:36.000Z"
            },
            "assetType":"otoken",
            "events":true,
            "tokenId":"bond1",
            "tokenName":"bond",
            "tokenDesc":"tokenDesc value",
            "tokenStandard":"erc1155+",
            "tokenType":"nonfungible",
            "tokenUnit":"fractional",
            "behaviors":[
               "divisible",
               "mintable",
               "transferable",
               "burnable",
               "roles"
            ],
            "roles":{
               "minter_role_name":"minter",
               "burner_role_name":"burner"
            },
            "mintable":{
               "max_mint_quantity":0
            },
            "quantity":100,
            "createdBy":"oaccount~276bcf1324b1ad1e493e22432db3b39f7a4b9bb17b8525c0391ea3ba36138e00",
            "creationDate":"2024-12-02T12:42:09.000Z",
            "divisible":{
               "decimal":0
            },
            "isBurned":false,
            "isLocked":false,
            "tokenUri":"tokenUri value",
            "status":"posted"
         }

]
getTokenApprovalRequestByUser
Any account holder can call this get method to get the details of all the token approval requests (redemption requests) they have made.
this.Ctx.ERC1155TokenApproval.getAllTokenApprovalRequestByUserByStatus(status)
Parameters:
  • status: string – The status of the request, which can be PENDING, REJECTED, or APPROVED.
Return Value Example:
[
   {
      "tokenName":"bond",
      "assetType":"otokenApproval",
      "id":"otokenApproval~5b2a94283ae95e3d6e5b76ffd6f75b7bff231e4df270a82cdc1f6badd17dea4b",
      "settlementId":"op1",
      "userBondDetailsId":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op1",
      "fromAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
      "toAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
      "tokenId":"bond1",
      "quantity":2,
      "status":"APPROVED",
      "orderId":"op1",
      "redeemPrice":1,
      "purchasedPrice":11,
      "interestEarned":0
   },
   {
      "tokenName":"bond",
      "assetType":"otokenApproval",
      "id":"otokenApproval~fdf28b2d271ac9c0fbd94a2dedbf365728c77795f3e931e5a4a2dcf48039a989",
      "settlementId":"op3",
      "userBondDetailsId":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op3",
      "fromAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
      "toAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
      "tokenId":"bond1",
      "quantity":1,
      "status":"APPROVED",
      "orderId":"op3",
      "redeemPrice":11,
      "purchasedPrice":11,
      "interestEarned":0
   }
]
getTokenApprovalRequestForUserByStatus
Any account holder can call this get method to get the details of all the token approval requests (redemption requests) they have made.
this.Ctx.ERC1155TokenApproval.getAllTokenApprovalRequestForUserByStatus(status)
Parameters:
  • status: string – The status of the request, which can be PENDING, REJECTED, or APPROVED.
Return Value Example:
[
   {
      "tokenName":"bond",
      "assetType":"otokenApproval",
      "id":"otokenApproval~5b2a94283ae95e3d6e5b76ffd6f75b7bff231e4df270a82cdc1f6badd17dea4b",
      "settlementId":"op1",
      "userBondDetailsId":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op1",
      "fromAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
      "toAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
      "tokenId":"bond1",
      "quantity":2,
      "status":"APPROVED",
      "orderId":"op1",
      "redeemPrice":1,
      "purchasedPrice":11,
      "interestEarned":0
   },
   {
      "tokenName":"bond",
      "assetType":"otokenApproval",
      "id":"otokenApproval~fdf28b2d271ac9c0fbd94a2dedbf365728c77795f3e931e5a4a2dcf48039a989",
      "settlementId":"op3",
      "userBondDetailsId":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op3",
      "fromAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
      "toAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
      "tokenId":"bond1",
      "quantity":1,
      "status":"APPROVED",
      "orderId":"op3",
      "redeemPrice":11,
      "purchasedPrice":11,
      "interestEarned":0
   }
]
getAccountBondSummary
Any account holder can call this get method to get an account summary that includes the details of purchased or redeemed tokens and the purchase price and redemption price.
this.Ctx.ERC1155AccountBondSummary.getAllAccountBondSummary(userAccountId)
Parameters:
  • userAccountId: string – The account ID of the user.
Return Value Example:
{

   "userAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
   "orgId":"BondMPTest",
   "userId":"u10",
   "accountSummary":[
      {
         "purchasedQuantity":1,
         "assetType":"oUserBondDetails",
         "id":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op1",
         "tokenId":"bond1",
         "status":"Redeemed",
         "purchasedAmount":11,
         "purchasedDate":"2024-12-02T00:00:00.000Z",
         "purchasedFromAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
         "orderId":"op1"
         "redeemPrice":11,
         "quantityRedeem":1,
         "redeemStatus":"REJECTED"
      },
      {
         "purchasedQuantity":1,
         "assetType":"oUserBondDetails",
         "id":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op2",
         "tokenId":"bond1",
         "status":"Purchased",
         "purchasedAmount":11,
         "purchasedDate":"2024-12-02T00:00:00.000Z",
         "purchasedFromAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
         "orderId":"op2",
         "redeemPrice":11,
         "quantityRedeem":1,
         "redeemStatus":"APPROVED"
      }
   ]
}
getAccountBondSummaryWithPagination
Any account holder can call this get method to get an account summary that includes details of purchased or redeemed tokens and the purchase price and redemption price. This method can return results with pagination based on pagesize and bookmark values, and also filtered by start time and end time.
this.Ctx.ERC1155AccountBondSummary.getAllAccountBondSummaryWithPagination(userAccountId, pageSize, bookmark)
Parameters:
  • userAccountId: string – The account ID of the user.
  • pageSize: number – The page size of the returned result.
  • bookmark: string – The bookmark of the returned result.
Return Value Example:
    {

       "userAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
       "orgId":"BondMPTest",
       "userId":"u10",
       "accountSummary":[
          {
             "purchasedQuantity":1,
             "assetType":"oUserBondDetails",
             "id":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op1",
             "tokenId":"bond1",
             "status":"Redeemed",
             "purchasedAmount":11,
             "purchasedDate":"2024-12-02T00:00:00.000Z",
             "purchasedFromAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
             "orderId":"op1"
             "redeemPrice":11,
             "quantityRedeem":1,
             "redeemStatus":"REJECTED"
          },
          {
             "purchasedQuantity":1,
             "assetType":"oUserBondDetails",
             "id":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op2",
             "tokenId":"bond1",
             "status":"Purchased",
             "purchasedAmount":11,
             "purchasedDate":"2024-12-02T00:00:00.000Z",
             "purchasedFromAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
             "orderId":"op2",
             "redeemPrice":11,
             "quantityRedeem":1,
             "redeemStatus":"APPROVED"
          }
       ]
    }

    	

    On success, it returns a message.

    {

       "userAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
       "orgId":"BondMPTest",
       "userId":"u10",
       "accountSummary":[
          {
             "PurchasedQuantity":1,
             "AssetType":"oUserBondDetails",
             "Id":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op1",
             "TokenId":"bond1",
             "Status":"Redeemed",
             "PurchasedAmount":11,
             "PurchasedDate":"2024-12-02T00:00:00.000Z",
             "PurchasedFromAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
             "OrderId":"op1"
             "RedeemPrice":11,
             "QuantityRedeem":1,
             "RedeemStatus":"REJECTED"
          },
          {
             "PurchasedQuantity":1,
             "AssetType":"oUserBondDetails",
             "Id":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op2",
             "TokenId":"bond1",
             "Status":"Purchased",
             "PurchasedAmount":11,
             "PurchasedDate":"2024-12-02T00:00:00.000Z",
             "PurchasedFromAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
             "OrderId":"op2",
             "RedeemPrice":11,
             "QuantityRedeem":1,
             "RedeemStatus":"APPROVED"
          }
       ]
    }

Go SDK Methods for Bond Marketplace

PayInterest
The token creator or admin can call this method to pay the interest earned on a bond token. This method can be called only if the interest frequency of the token is monthly, quarterly, or annually. Interest cannot be paid if the interest frequency is at maturity. Interest is calculated by the chaincode itself based on the coupon rate of the token. The purchase operation transfers CBDC tokens from the caller's account to the bond owner’s account. Because of this, this method must be run in the context of an atomic transaction. The method also verifies the transfer process, ensuring the appropriate CBDC chaincode is called with the correct orgId and userId for the transfer. The orgId and userId must correspond to the token owner, and the CBDC token transfer value must be equal to the interest that is calculated by the bond chaincode.
t.Ctx.ERC1155AccountBondSummary.PayInterestEarned(userAccountId, tokenId, orderId, additionalFees)
Parameters:
  • userAccountId: string – The account ID of the user.
  • tokenId: string – The ID of the token.
  • orderId: string – The order ID for the purchase operation.
Return Value Example:
{
         "PurchasedQuantity":1,
         "AssetType":"oUserBondDetails",
         "Id":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op1",
         "TokenId":"bond1",
         "Status":"Redeemed",
         "PurchasedAmount":11,
         "PurchasedDate":"2024-12-02T00:00:00.000Z",
         "PurchasedFromAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
         "OrderId":"op1"
         "InterestEarned": 11,
         "InterestEarnedDate": "2024-12-02T00:00:00.000Z"

}
RequestTokenRedemption
This method can be called only by the token owner to raise a request for the redemption of bond tokens after maturity. This method is also involved the calculation of the redemption price by the chaincode. Redemption requests can be raised only on the entire quantity of the bond token that the user owns. Users can raise multiple redemption requests based on different settlement IDs but only one can be approved by the token creator.
t.Ctx.ERC1155TokenApproval.RequestTokenRedemption(callerUserAccountId, settlementId, tokenId, orderId, quantity, additionalFees)
Parameters:
  • callerUserAccountId: string – The account ID of the user.
  • settlementId: string – The settlement ID for the redemption operation.
  • tokenId: string – The ID of the token.
  • orderId: string – The order ID for the purchase operation.
  • additionalFees: number – The additional fees to add to the redemption price.
Return Value Example:
{
         "TokenName":"bond",
         "AssetType":"otokenApproval",
         "Id":"otokenApproval~9e006057ac96ae997e3964531b1a08ad2316555701c7fe9ec7b88e38e20892bf",
         "SettlementId":"op4",
         "UserBondDetailsId":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op4",
         "FromAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
         "ToAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
         "TokenId":"bond1",
         "Quantity":1,
         "Status":"PENDING",
         "OrderId":"op4",
         "RedeemPrice":11
}
ApproveTokenRedemption
This method can be called only by the token creator to approve a request for the redemption of bond tokens. The approval operation transfers the bond NFT from the owner’s account (the user who raised the request) to the creator’s account, and transfers CBDC tokens from the bond creator’s to the owner’s account. Because of this, this method must be executed in the context of an atomic transaction. The method also verifies the transfer process, ensuring the appropriate CBDC chaincode is called with the correct orgId and userId for the transfer. The orgId and userId must correspond to the account of the token owner who raised the redemption request, and the CBDC token transfer value must be equal to the calculated redemption price that was calculated by the chaincode while raising the redemption request.
t.Ctx.ERC1155TokenApproval.ApproveTokenApprovalRequest(fromUserAccountId, settlementId, tokenId)
Parameters:
  • fromUserAccountId: string – The account ID of the user.
  • settlementId: string – The settlement ID for the redemption operation.
  • tokenId: string – The ID of the token.
Return Value Example:
{
   "status":"success",
   "msg":"Successfully approved the token approval request"
}
RejectRedemption
The token creator can call this method to reject the redemption request. Token owners can raise a redemption request again by using a different settlement ID.
t.Ctx.ERC1155TokenApproval.RejectTokenApprovalRequest(fromUserAccountId, settlementId, tokenId)
Parameters:
  • fromOrgId: string – The membership service provider (MSP) ID of the user.
  • fromUserId: string – The user name or email ID of the user.
  • settlementId: string – The settlement ID for the redemption operation.
  • tokenId: string – The ID of the token.
Return Value Example:
{
   "status":"success",
   "msg":"Successfully rejected the token approval request"
}
GetAllTokensWithFilter
The admin can call this get method to fetch all the tokens filtered by status, either CREATED or POSTED.
t.Ctx.ERC1155Token.GetAllTokensWithFilters(status, pageSize, bookmark)
Parameters:
  • status: string – The status of the token, which can either be CREATED or POSTED.
  • pageSize: number – The page size of the returned result.
  • bookmark: string – The bookmark of the returned result.
Return Value Example:
[ {

               "ISIN":"ISIN value",
               "Segment":"Segment value",
               "Issuer":"Issuer value",
               "FaceValue":10,
               "IssueSize":999,
               "CouponRate":10,
               "InterestPaymentType":"simple",
               "InterestFrequency":"monthly",
               "IssueDate":"2023-03-28T15:16:36.000Z",
               "MaturityDate":"2023-03-28T15:16:36.000Z"
            },
            "AssetType":"otoken",
            "Events":true,
            "TokenId":"bond1",
            "TokenName":"bond",
            "TokenDesc":"tokenDesc value",
            "TokenStandard":"erc1155+",
            "TokenType":"nonfungible",
            "TokenUnit":"fractional",
            "Behaviors":[
               "divisible",
               "mintable",
               "transferable",
               "burnable",
               "roles"
            ],
            "Roles":{
               "minter_role_name":"minter",
               "burner_role_name":"burner"
            },
            "Mintable":{
               "max_mint_quantity":0
            },
            "Quantity":100,
            "CreatedBy":"oaccount~276bcf1324b1ad1e493e22432db3b39f7a4b9bb17b8525c0391ea3ba36138e00",
            "CreationDate":"2024-12-02T12:42:09.000Z",
            "Divisible":{
               "decimal":0
            },
            "IsBurned":false,
            "IsLocked":false,
            "TokenUri":"tokenUri value",
            "Status":"posted"
         }
]
GetTokenApprovalRequestByUser
Any account holder can call this get method to get the details of all the token approval requests (redemption requests) they have made.
t.Ctx.ERC1155TokenApproval.GetAllTokenApprovalRequestByUserByStatus(status)
Parameters:
  • status: string – The status of the request, which can be PENDING, REJECTED, or APPROVED.
Return Value Example:
[
   {
      "TokenName":"bond",
      "AssetType":"otokenApproval",
      "Id":"otokenApproval~5b2a94283ae95e3d6e5b76ffd6f75b7bff231e4df270a82cdc1f6badd17dea4b",
      "SettlementId":"op1",
      "UserBondDetailsId":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op1",
      "FromAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
      "ToAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
      "TokenId":"bond1",
      "Quantity":2,
      "Status":"APPROVED",
      "OrderId":"op1",
      "RedeemPrice":1,
      "PurchasedPrice":11,
      "InterestEarned":0
   },
   {
      "TokenName":"bond",
      "AssetType":"otokenApproval",
      "Id":"otokenApproval~fdf28b2d271ac9c0fbd94a2dedbf365728c77795f3e931e5a4a2dcf48039a989",
      "SettlementId":"op3",
      "UserBondDetailsId":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op3",
      "FromAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
      "ToAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
      "TokenId":"bond1",
      "Quantity":1,
      "Status":"APPROVED",
      "OrderId":"op3",
      "RedeemPrice":11,
      "PurchasedPrice":11,
      "InterestEarned":0
   }
]
GetTokenApprovalRequestForUserByStatus
Any account holder can call this get method to get the details of all the token approval requests (redemption requests) they have made.
t.Ctx.ERC1155TokenApproval.GetAllTokenApprovalRequestForUserByStatus(status)
Parameters:
  • status: string – The status of the request, which can be PENDING, REJECTED, or APPROVED.
Return Value Example:
[
   {
      "TokenName":"bond",
      "AssetType":"otokenApproval",
      "Id":"otokenApproval~5b2a94283ae95e3d6e5b76ffd6f75b7bff231e4df270a82cdc1f6badd17dea4b",
      "SettlementId":"op1",
      "UserBondDetailsId":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op1",
      "FromAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
      "ToAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
      "TokenId":"bond1",
      "Quantity":2,
      "Status":"APPROVED",
      "OrderId":"op1",
      "RedeemPrice":1,
      "PurchasedPrice":11,
      "InterestEarned":0
   },
   {
      "TokenName":"bond",
      "AssetType":"otokenApproval",
      "Id":"otokenApproval~fdf28b2d271ac9c0fbd94a2dedbf365728c77795f3e931e5a4a2dcf48039a989",
      "SettlementId":"op3",
      "UserBondDetailsId":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op3",
      "FromAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
      "ToAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
      "TokenId":"bond1",
      "Quantity":1,
      "Status":"APPROVED",
      "OrderId":"op3",
      "RedeemPrice":11,
      "PurchasedPrice":11,
      "InterestEarned":0
   }
]
GetAccountBondSummary
Any account holder can call this get method to get an account summary that includes the details of purchased or redeemed tokens and the purchase price and redemption price.
t.Ctx.ERC1155AccountBondSummary.GetAllAccountBondSummary(userAccountId)
Parameters:
  • userAccountId: string – The account ID of the user.
Return Value Example:
{

   "userAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
   "orgId":"BondMPTest",
   "userId":"u10",
   "accountSummary":[
      {
         "PurchasedQuantity":1,
         "AssetType":"oUserBondDetails",
         "Id":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op1",
         "TokenId":"bond1",
         "Status":"Redeemed",
         "PurchasedAmount":11,
         "PurchasedDate":"2024-12-02T00:00:00.000Z",
         "PurchasedFromAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
         "OrderId":"op1"
         "RedeemPrice":11,
         "QuantityRedeem":1,
         "RedeemStatus":"REJECTED"
      },
      {
         "PurchasedQuantity":1,
         "AssetType":"oUserBondDetails",
         "Id":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op2",
         "TokenId":"bond1",
         "Status":"Purchased",
         "PurchasedAmount":11,
         "PurchasedDate":"2024-12-02T00:00:00.000Z",
         "PurchasedFromAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
         "OrderId":"op2",
         "RedeemPrice":11,
         "QuantityRedeem":1,
         "RedeemStatus":"APPROVED"
      }
   ]
}
GetAccountBondSummaryWithPagination
Any account holder can call this get method to get an account summary that includes details of purchased or redeemed tokens and the purchase price and redemption price. This method can return results with pagination based on pagesize and bookmark values, and also filtered by start time and end time.
t.Ctx.ERC1155AccountBondSummary.GetAllAccountBondSummaryWithPagination(userAccountId, pageSize, bookmark)
Parameters:
  • userAccountId: string – The account ID of the user.
  • pageSize: number – The page size of the returned result.
  • bookmark: string – The bookmark of the returned result.
Return Value Example:
{

   "userAccountId":"ouaccount~df36ebaeb728c7768c0d5a3ecab435985c506ff57fd582212029b6f3c9cabf14",
   "orgId":"BondMPTest",
   "userId":"u10",
   "accountSummary":[
      {
         "PurchasedQuantity":1,
         "AssetType":"oUserBondDetails",
         "Id":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op1",
         "TokenId":"bond1",
         "Status":"Redeemed",
         "PurchasedAmount":11,
         "PurchasedDate":"2024-12-02T00:00:00.000Z",
         "PurchasedFromAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
         "OrderId":"op1"
         "RedeemPrice":11,
         "QuantityRedeem":1,
         "RedeemStatus":"REJECTED"
      },
      {
         "PurchasedQuantity":1,
         "AssetType":"oUserBondDetails",
         "Id":"ouserbonddetails~ed3aaa9979bfe6302dcc83b1b903bd383fda60ff17747ca25af3369e26289747~bond1~op2",
         "TokenId":"bond1",
         "Status":"Purchased",
         "PurchasedAmount":11,
         "PurchasedDate":"2024-12-02T00:00:00.000Z",
         "PurchasedFromAccountId":"ouaccount~e76f696c0d6c626b24d35b3ac21de377a6da24c1bfdab1411f6702a507003a15",
         "OrderId":"op2",
         "RedeemPrice":11,
         "QuantityRedeem":1,
         "RedeemStatus":"APPROVED"
      }
   ]
}