トークン・タクソノミ・フレームワークの拡張機能

ブロックチェーン・アプリケーション・ビルダーの拡張バージョンには、拡張トークン・タクソノミ・フレームワーク標準に関連する新機能が含まれています。

日次トランザクション限度

アカウントが毎日完了できるトランザクションの数、および処理可能なトークンの数を制限できます。createAccountメソッドへのmax_daily_amountおよびmax_daily_transactions入力パラメータによって、この動作が制御されます。これらのパラメータはオプションです。

アカウントの日次トランザクション制限を設定しないと、より高いスループットを実現できます。

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);
}
追加パラメータ:
  • daily_limits: JSON– 次の例に示すように、毎日トランザクションで使用できるトークンの最大量(max_daily_amount)および毎日完了できるトランザクションの最大数(max_daily_transactions)を指定するオブジェクト。
    {
         "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...)
}
追加パラメータ:
  • daily_limits: JSON– 次の例に示すように、MaxDailyAmountパラメータ(毎日トランザクションで使用できるトークンの最大量)およびMaxDailyTransactionsパラメータ(毎日完了できるトランザクションの最大数)を含むJSONオブジェクト。
    {
         "MaxDailyAmount": 100000
         "MaxDailyTransactions": 10000
     }
戻り値:
  • 成功すると、作成されたアカウントのJSONオブジェクト。BapAccountVersionパラメータは、内部使用のためにアカウント・オブジェクトで定義されます。
戻り値の例:
{ 
   "AssetType":"oaccount",
   "AccountId":"oaccount~a73085a385bc96c4a45aa2dff032e7dede82c0664dee5f396b7c5854eeafd4bd",
   "BapAccountVersion": 0,
   "UserId":"user1",
   "OrgId":"Org1MSP",
   "AccountType":"fungible",
   "TokenId":"",
   "TokenName":"",
   "Balance":0,
   "BalanceOnHold":0
}

ミントとバーニングの承認要件

トークンをミントまたはバーナー・ロールを持つユーザーがトークンを直接ミントまたはバーニングするのではなく、承認者にリクエストを送信するように、トークンのミントおよびバーニングの承認を設定できます。承認者は、トークンをミントまたは書き込むリクエストを受け入れるか拒否できます。ミントおよび書込みの承認を有効にするには、mint_approval_requiredおよびburn_approval_requiredパラメータを使用します。次に、次の例に示すように、mint_approver_role_nameおよびburn_approval_role_nameの値も指定する必要があります。

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
次のメソッドは、ミント・トークンおよびバーン・トークンの承認のリクエスト、受入れおよび拒否をサポートします。

TypeScript承認のMintおよびBurningメソッド

requestMint
このメソッドは、minterがリクエストを送信して、指定した量のトークンを作成するためにminter notaryに送信できます。
@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);

}
パラメータ:
  • token_id: string–mintへのトークンのID。
  • operation_id: string–mintリクエストを表す一意の操作ID。
  • notary_org_id: string– リクエストを処理するミナー公証人のメンバーシップ・サービス・プロバイダ(MSP)ID。
  • notary_user_id: string– リクエストを処理する鉱夫のユーザー名または電子メールID。
  • quantity: number–mintへのトークンの量。
  • time_to_expiration– ミント・リクエストが期限切れになり、有効ではなくなった時間。
  • info_details: JSON– 次の例に示すように、リクエストのカテゴリ(category)および説明(description)を指定するオブジェクト。
    {
         "category" : "category input",
         "description" : "description input"
    }
戻り値の例:
{
msg:
"AccountId oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (Org-Id: Org1MSP, User-Id: admin) has successfully submitted request to mint 100 tokens",
}
approveMint
このメソッドは、ミント・リクエストを承認するために、ミント・ノータリーからコールできます。
@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);
}
パラメータ:
  • token_id: string–mintへのトークンのID。
  • operation_id: string–mintリクエストを表す一意の操作ID。
戻り値の例:
{
msg:
"Successfully minted 100 tokens to Account Id: oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (Org-Id: Org1MSP, User-Id: admin)"
}
rejectMint
このメソッドは、ミント・リクエストを拒否するために、ミント・ノータリーによってコールできます。
@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);
}
パラメータ:
  • token_id: string–mintへのトークンのID。
  • operation_id: string–mintリクエストを表す一意の操作ID。
戻り値の例:
{
 msg: "Successfully rejected mint request with Operation Id 'operation1' to mint 100 tokens of token id token"
}
requestBurn
このメソッドは、バーナーがコールして、指定された量のトークンを破棄する要求をバーナー公証に送信できます。
@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);
}
パラメータ:
  • token_id: string– 書き込むトークンのID。
  • operation_id: string– 書込みリクエストを表す一意の操作ID。
  • notary_org_id: string– リクエストを処理するバーナー公証人のメンバーシップ・サービス・プロバイダ(MSP)ID。
  • notary_user_id: string– リクエストを処理するバーナー・ノータリーのユーザー名または電子メールID。
  • quantity: number– 書き込むトークンの量。
  • time_to_expiration– 書き込み要求が期限切れになり、有効ではなくなった時間。
  • info_details: JSON– 次の例に示すように、リクエストのカテゴリ(category)および説明(description)を指定するオブジェクト。
    {
         "category" : "category input",
         "description" : "description input"
    }
戻り値の例:
{
msg:
"AccountId oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (Org-Id: Org1MSP, User-Id: admin) has successfully submitted request to mint 100 tokens",
}
approveBurn
バーナー公証人がこのメソッドを呼び出して、書き込み要求を承認できます。
@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);
}
パラメータ:
  • token_id: string– 書き込むトークンのID。
  • operation_id: string– 書込みリクエストを表す一意の操作ID。
戻り値の例:
{
msg:
"Successfully burned 100 tokens from account id: oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (Org-Id: Org1MSP, User-Id: admin)"
}
rejectBurn
バーナー公証人がこのメソッドを呼び出して、書き込み要求を拒否できます。
@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);
}
パラメータ:
  • token_id: string– 書き込むトークンのID。
  • operation_id: string– 書込みリクエストを表す一意の操作ID。
戻り値の例:
{
 msg: "Successfully rejected burn request with Operation Id 'operation1' to burn 100 tokens of token id token",
}

承認をミントおよびバーニングするためのGoメソッド

RequestMint
このメソッドは、minterがリクエストを送信して、指定した量のトークンを作成するためにminter notaryに送信できます。
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...)
}
パラメータ:
  • token_id: string–mintへのトークンのID。
  • operation_id: string–mintリクエストを表す一意の操作ID。
  • notary_org_id: string– リクエストを処理するミナー公証人のメンバーシップ・サービス・プロバイダ(MSP)ID。
  • notary_user_id: string– リクエストを処理する鉱夫のユーザー名または電子メールID。
  • quantity: number–mintへのトークンの量。
  • TimeToExpiration– ミント・リクエストが期限切れになり、有効ではなくなった時間。
  • info_details: JSON– 次の例に示すように、リクエストのカテゴリ(category)および説明(description)を指定するオブジェクト。
    {
         "Category" : "category input",
         "Description" : "description input"
    }
戻り値の例:
{
msg:
"AccountId oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (org_id: Org1MSP, user_id: admin) has successfully submitted request to mint 100 tokens",
}
ApproveMint
このメソッドは、ミント・リクエストを承認するために、ミント・ノータリーからコールできます。
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())
}
パラメータ:
  • token_id: string–mintへのトークンのID。
  • operation_id: string–mintリクエストを表す一意の操作ID。
戻り値の例:
{
msg:
"Successfully minted 100 tokens to Account Id: oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (org_id: Org1MSP, user_id: admin)"
}
RejectMint
このメソッドは、ミント・リクエストを拒否するために、ミント・ノータリーによってコールできます。
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())
}
パラメータ:
  • token_id: string–mintへのトークンのID。
  • operation_id: string–mintリクエストを表す一意の操作ID。
戻り値の例:
{
 msg: "Successfully rejected mint request with Operation Id 'operation1' to mint 100 tokens of token id token"
}
RequestBurn
このメソッドは、バーナーがコールして、指定された量のトークンを破棄する要求をバーナー公証に送信できます。
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...)
}
パラメータ:
  • token_id: string– 書き込むトークンのID。
  • operation_id: string– 書込みリクエストを表す一意の操作ID。
  • notary_org_id: string– リクエストを処理するバーナー公証人のメンバーシップ・サービス・プロバイダ(MSP)ID。
  • notary_user_id: string– リクエストを処理するバーナー・ノータリーのユーザー名または電子メールID。
  • quantity: number– 書き込むトークンの量。
  • time_to_expiration– 書き込み要求が期限切れになり、有効ではなくなった時間。
  • info_details: JSON– 次の例に示すように、リクエストのカテゴリ(category)および説明(description)を指定するオブジェクト。
    {
         "category" : "category input",
         "description" : "description input"
    }
戻り値の例:
{
msg:
"AccountId oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (org_id: Org1MSP, user_id: admin) has successfully submitted request to mint 100 tokens",
}
ApproveBurn
バーナー公証人がこのメソッドを呼び出して、書き込み要求を承認できます。
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())
}
パラメータ:
  • token_id: string– 書き込むトークンのID。
  • operation_id: string– 書込みリクエストを表す一意の操作ID。
戻り値の例:
{
msg:
"Successfully burned 100 tokens from account id: oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (org_id: Org1MSP, user_id: admin)"
}
RejectBurn
バーナー公証人がこのメソッドを呼び出して、書き込み要求を拒否できます。
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())
}
パラメータ:
  • token_id: string– 書き込むトークンのID。
  • operation_id: string– 書込みリクエストを表す一意の操作ID。
戻り値の例:
{
 msg: "Successfully rejected burn request with Operation Id 'operation1' to burn 100 tokens of token id token",
}

リッチ履歴データベースからのトランザクション履歴のフェッチ

データをリッチ履歴データベースに同期し、チェーンコードAPIコールを使用してデータをフェッチできます。TypeScriptおよびGoに示されている次のメソッドは、リッチ履歴データベースからトランザクション履歴をフェッチします。これらの方法を使用する前に、卸売CBDCのOracle Databaseビュー定義の説明に従って、Oracle REST Data Services (ORDS)およびOAuthを有効にしてOracle Autonomous Databaseを実行する必要があります。
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);
}
パラメータ:
  • token_id: string–mintへのトークンのID。
  • org_id: string– 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP)ID。
  • user_id: string– ユーザーのユーザー名または電子メールID。
  • custom_endpoint– リッチ履歴データベースのRESTfulサービス・エンドポイント。
  • bearer_token– RESTfulサービス・エンドポイントのアクセス認可トークン。
  • filters: string– オプション・パラメータ。空の場合は、すべてのレコードが返されます。PageSizeプロパティは、戻すレコード数を決定します。PageSizeが0の場合、デフォルトのページ・サイズは20です。Bookmarkプロパティは、返されるレコードの開始索引を決定します。詳細は、Hyperledger Fabricのドキュメントを参照してください。StartTimeおよびEndTimeプロパティは、RFC-3339形式で指定する必要があります。
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
}
パラメータ:
  • token_id: string–mintへのトークンのID。
  • org_id: string– 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP)ID。
  • user_id: string– ユーザーのユーザー名または電子メールID。
  • custom_endpoint– リッチ履歴データベースのRESTfulサービス・エンドポイント。
  • bearer_token– RESTfulサービス・エンドポイントのアクセス認可トークン。
  • filters: string– オプション・パラメータ。空の場合は、すべてのレコードが返されます。PageSizeプロパティは、戻すレコード数を決定します。PageSizeが0の場合、デフォルトのページ・サイズは20です。Bookmarkプロパティは、返されるレコードの開始索引を決定します。詳細は、Hyperledger Fabricのドキュメントを参照してください。StartTimeおよびEndTimeプロパティは、RFC-3339形式で指定する必要があります。

トランザクション・オブジェクトのカテゴリおよび摘要属性

  • カテゴリおよび説明属性は、コントローラ・ファイルのtransferTokensholdTokensissueTokensrequestMintrequestBurnburnTokensおよびrejectBurnメソッドに含める必要があります。対応するSDKメソッドには、カテゴリおよび説明属性も含める必要があります。
  • カテゴリおよび説明属性の入力は、次の例に示すように、info_detailsという名前のJSONオブジェクトの形式になります。
    {
         "category" : "category input",
         "description" : "description input"
    }
  • info_detailsフィールドはオプションです。必要に応じて、カテゴリまたは摘要のみを渡すことができます。
  • transferTokensholdTokensexecuteHoldreleaseHoldrequestMintapproveMintrejectMintrequestBurnapproveBurnおよびrejectBurnのトランザクションに関連するGETメソッドは、カテゴリ属性および説明属性が存在する場合、ペイロード・レスポンスに含める必要があります。
  • カテゴリ・フィールドは20文字に制限されており、摘要フィールドは250文字に制限されています。

TypeScript変更された入力を持つメソッド

ブロックチェーン・アプリケーション・ビルダーの拡張バージョンを使用する場合、次のメソッドはオプションのカテゴリおよび説明属性をサポートします。

transferTokens
このメソッドは、トークンをコール元から指定されたアカウントに転送します。
@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);
}
パラメータ:
  • token_id: string– トークンのID。
  • to_org_id: string– 現在の組織内の受信者(受取人)のメンバーシップ・サービス・プロバイダ(MSP)ID。
  • to_user_id: string– 受信者のユーザー名または電子メールID。
  • quantity: number– 転送するトークンの数。
  • info_details: JSON– 次の例に示すように、リクエストのカテゴリ(category)および説明(description)を指定するオブジェクト。
    {
         "category" : "category input",
         "description" : "description input"
    }
戻り値の例:
{
 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
このメソッドは、to_account_idアカウントを持つトークンの所有者のかわりに保留を作成します。
@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);
  }
パラメータ:
  • token_id: string– トークンのID。
  • operation_id: string– 保留操作を識別する一意のID。通常、このIDはクライアント・アプリケーションによって渡されます。
  • to_org_id: string– 現在の組織内の受信者のメンバーシップ・サービス・プロバイダ(MSP)ID。
  • to_user_id: string– 受信者のユーザー名または電子メールID。
  • notary_org_id: string– 現在の組織の公証人のメンバーシップ・サービス・プロバイダ(MSP)ID。
  • notary_user_id: string– 公証人のユーザー名または電子メールID。
  • quantity: number– 保留にするトークンの数。
  • time_to_expiration– 保留が失効する時間。永続的な保留の場合は 0を指定します。それ以外の場合は、RFC-3339形式を使用します。たとえば、2021-06-02T12:46:06Zです。
  • info_details: JSON– 次の例に示すように、リクエストのカテゴリ(category)および説明(description)を指定するオブジェクト。
    {
         "category" : "category input",
         "description" : "description input"
    }
戻り値の例:
{
msg:
"AccountId oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (Org-Id: Org1MSP, User-Id: admin) is successfully holding 100 tokens",
}
issueTokens
このメソッドは、メソッドのコール元が所有するトークンをミントします。
@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);
}
パラメータ:
  • token_id: string– トークンのID。
  • quantity–mintするトークンの数。
  • info_details: JSON– 次の例に示すように、リクエストのカテゴリ(category)および説明(description)を指定するオブジェクト。
    {
         "category" : "category input",
         "description" : "description input"
    }
戻り値の例:
{
msg:
"Successfully minted 100 tokens to Account Id: oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (Org-Id: Org1MSP, User-Id: admin)"
}
burnTokens
このメソッドは、トランザクション・コール元のアカウントからトークンを非アクティブ化またはバーンします。
@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);
}
パラメータ:
  • token_id: string– トークンのID。
  • quantity– 書き込むトークンの数。
  • info_details: JSON– 次の例に示すように、リクエストのカテゴリ(category)および説明(description)を指定するオブジェクト。
    {
         "category" : "category input",
         "description" : "description input"
    }
戻り値の例:
{
msg:
"Successfully burned 100 tokens from account id: oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (Org-Id: Org1MSP, User-Id: admin)"
}

変更された入力のあるGoメソッド

ブロックチェーン・アプリケーション・ビルダーの拡張バージョンを使用する場合、次のメソッドはオプションのカテゴリおよび説明属性をサポートします。

TransferTokens
このメソッドは、トークンをコール元から指定されたアカウントに転送します。
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...)
}
パラメータ:
  • token_id: string– トークンのID。
  • to_org_id: string– 現在の組織内の受信者(受取人)のメンバーシップ・サービス・プロバイダ(MSP)ID。
  • to_user_id: string– 受信者のユーザー名または電子メールID。
  • quantity: number– 転送するトークンの数。
  • info_details: JSON– 次の例に示すように、リクエストのカテゴリ(category)および説明(description)を指定するオブジェクト。
    {
         "category" : "category input",
         "description" : "description input"
    }
戻り値の例:
{
 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
このメソッドは、to_account_idアカウントを持つトークンの所有者のかわりに保留を作成します。
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...)
}
パラメータ:
  • token_id: string– トークンのID。
  • operation_id: string– 保留操作を識別する一意のID。通常、このIDはクライアント・アプリケーションによって渡されます。
  • to_org_id: string– 現在の組織内の受信者のメンバーシップ・サービス・プロバイダ(MSP)ID。
  • to_user_id: string– 受信者のユーザー名または電子メールID。
  • notary_org_id: string– 現在の組織の公証人のメンバーシップ・サービス・プロバイダ(MSP)ID。
  • notary_user_id: string– 公証人のユーザー名または電子メールID。
  • quantity: number– 保留にするトークンの数。
  • time_to_expiration– 保留が失効する時間。永続的な保留の場合は 0を指定します。それ以外の場合は、RFC-3339形式を使用します。たとえば、2021-06-02T12:46:06Zです。
  • info_details: JSON– 次の例に示すように、リクエストのカテゴリ(category)および説明(description)を指定するオブジェクト。
    {
         "category" : "category input",
         "description" : "description input"
    }
戻り値の例:
{
msg:
"AccountId oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (Org-Id: Org1MSP, User-Id: admin) is successfully holding 100 tokens",
}
IssueTokens
このメソッドは、メソッドのコール元が所有するトークンをミントします。
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...)
}
パラメータ:
  • token_id: string– トークンのID。
  • quantity–mintするトークンの数。
  • info_details: JSON– 次の例に示すように、リクエストのカテゴリ(category)および説明(description)を指定するオブジェクト。
    {
         "category" : "category input",
         "description" : "description input"
    }
戻り値の例:
{
msg:
"Successfully minted 100 tokens to Account Id: oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (Org-Id: Org1MSP, User-Id: admin)"
}
BurnTokens
このメソッドは、トランザクション・コール元のアカウントからトークンを非アクティブ化またはバーンします。
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...)
}
パラメータ:
  • token_id: string– トークンのID。
  • quantity– 書き込むトークンの数。
  • info_details: JSON– 次の例に示すように、リクエストのカテゴリ(category)および説明(description)を指定するオブジェクト。
    {
         "category" : "category input",
         "description" : "description input"
    }
戻り値の例:
{
msg:
"Successfully burned 100 tokens from account id: oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (Org-Id: Org1MSP, User-Id: admin)"
}

変更された出力を含むTypeScriptメソッド

次のメソッドは、ブロックチェーン・アプリケーション・ビルダーの拡張バージョンを使用すると、関連する組織およびユーザーIDを返します。

getAccountTransactionHistory
このメソッドは、指定されたユーザーおよびトークンのアカウント・トランザクション履歴詳細の配列を返します。
@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());
}
パラメータ:
  • token_id: string – トークンのID。
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値の例:
[
            {
                "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
このメソッドは、指定されたユーザーおよびトークンのアカウント・トランザクション履歴詳細のフィルタ済配列を返します。
@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);
}
パラメータ:
  • token_id: string – トークンのID。
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
  • filters: string – オプション・パラメータ。空の場合は、すべてのレコードが返されます。PageSizeプロパティは、返すレコード数を決定します。PageSizeが0の場合、デフォルトのページ・サイズは20です。Bookmarkプロパティは、返されるレコードの開始索引を決定します。詳細は、Hyperledger Fabricのドキュメントを参照してください。StartTimeおよびEndTimeプロパティは、RFC-3339形式で指定する必要があります。
戻り値の例:
[
            {
                "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メソッド

次のメソッドは、ブロックチェーン・アプリケーション・ビルダーの拡張バージョンを使用すると、関連する組織およびユーザーIDを返します。

GetAccountTransactionHistory
このメソッドは、指定されたユーザーおよびトークンのアカウント・トランザクション履歴詳細の配列を返します。
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
}
パラメータ:
  • token_id: string – トークンのID。
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値の例:
[
            {
                "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
このメソッドは、指定されたユーザーおよびトークンのアカウント・トランザクション履歴詳細のフィルタ済配列を返します。
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
}
パラメータ:
  • token_id: string – トークンのID。
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
  • filters: string – オプション・パラメータ。空の場合は、すべてのレコードが返されます。PageSizeプロパティは、返すレコード数を決定します。PageSizeが0の場合、デフォルトのページ・サイズは20です。Bookmarkプロパティは、返されるレコードの開始索引を決定します。詳細は、Hyperledger Fabricのドキュメントを参照してください。StartTimeおよびEndTimeプロパティは、RFC-3339形式で指定する必要があります。
戻り値の例:
[
            {
                "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"
            }
 ]