トークン・タクソノミ・フレームワーク用のスキャフォールド済TypeScriptプロジェクト

ブロックチェーン・アプリケーション・ビルダーは、トークン仕様ファイルから入力を受け取り、完全に機能するスキャフォールド済チェーンコード・プロジェクトを生成します。

プロジェクトは、CRUDおよび非CRUDメソッドを含むトークン・ライフサイクル・クラスおよび関数を自動的に生成します。引数の検証、マーシャリング/アンマーシャリングおよび透過的永続性機能はすべて自動的にサポートされます。

トークンに直接関連しない、スキャフォールドされたプロジェクトおよびメソッドの詳細は、「スキャフォールド済TypeScriptチェーンコード・プロジェクト」を参照してください。

モデル

すべてのトークン化されたモデル・クラスはTokenクラスを拡張し、OchainModelクラスを拡張します。Tokenクラスは、../lib/tokenからインポートされます。透過的永続性機能(または簡略化されたORM)は、OchainModelクラスで取得されます。

import * as yup from 'yup';
import { Id, Mandatory, Validate, ReadOnly } from '../lib/decorators';
import { Token } from '../lib/token';
 
@Id('token_id')
export class Digicur extends Token<Digicur> {
 
    public readonly assetType = 'otoken';
 
    @Mandatory()
    @Validate(yup.string().required().matches(/^[A-Za-z0-9][A-Za-z0-9_-]*$/).max(16))
    public token_id: string;
 
    @ReadOnly('digicur')
    public token_name: string;
 
    @Validate(yup.string().trim().max(256))
    public token_desc: string;
 
    @ReadOnly('fungible')
    public token_type: string;
 
    @ReadOnly(["divisible","mintable","transferable","burnable","holdable","roles"])
    public behaviors: string[];
 
    @ReadOnly({minter_role_name: "minter", burner_role_name: "burner", notary_role_name: "notary"})
    public roles: object;
 
    @ReadOnly({max_mint_quantity: 20000})
    public mintable: object;
 
    @ReadOnly({decimal: 1})
    public divisible: object;
 
    @Validate(yup.number())
    public token_to_currency_ratio: number;
 
    @Validate(yup.string())
    public currency_representation: string;
 
}

コントローラ

メイン・コントローラ・クラスは、OchainControllerクラスを拡張します。メインコントローラは1つのみです。

export class DigiCurrCCController extends OchainController{

クラス、関数またはファイルはいくつでも作成できますが、メイン・コントローラ・クラスで定義されたメソッドのみが呼出し可能です。その他のメソッドは非表示です。

トークンSDKメソッドを使用して、ビジネス・アプリケーションのカスタム・メソッドを記述できます。

自動生成されたトークン・メソッド

ブロックチェーン・アプリケーション・ビルダーは、トークンおよびトークン・ライフサイクルをサポートするメソッドを自動的に生成します。これらのメソッドを使用して、トークンの初期化、ロールとアカウントの管理、およびその他のトークン・ライフサイクル・タスクを追加コーディングなしで行えます。コントローラ・メソッドを呼び出すには、@Validator(...params)デコレータが必要です。

アクセス制御管理のメソッド

addTokenAdmin
このメソッドは、ユーザーをチェーンコードのToken Adminとして追加します。このメソッドは、チェーンコードのToken Adminのみがコールできます。
@Validator(yup.string(), yup.string())
public async addTokenAdmin(org_id: string, user_id: string) {
    await this.Ctx.Auth.checkAuthorization('ADMIN.addAdmin', 'TOKEN');
    return await this.Ctx.Admin.addAdmin(org_id, user_id);
}
パラメータ:
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、チェーンコードのToken Adminとして追加されたユーザーの詳細を含むメッセージ。
戻り値の例:
{"msg":"Successfully added Admin (Org_Id: Org1MSP, User_Id: User1)"}
removeTokenAdmin
このメソッドは、チェーンコードのToken Adminであるユーザーを削除します。このメソッドは、チェーンコードのToken Adminのみがコールできます。
@Validator(yup.string(), yup.string())
public async removeTokenAdmin(org_id: string, user_id: string) {
    await this.Ctx.Auth.checkAuthorization('ADMIN.removeAdmin', 'TOKEN');
    return await this.Ctx.Admin.removeAdmin(org_id, user_id);
}
パラメータ:
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、チェーンコードのToken Adminとして削除されたユーザーの詳細を含むメッセージ。
戻り値の例:
{"msg": "Successfully removed Admin (Org_Id: Org1MSP, User_Id: User1)"}
isTokenAdmin
このメソッドは、関数のコール元がToken Adminの場合はブール値trueを返して、それ以外の場合はfalseを返します。Token AdminまたはOrg Adminは、ブロックチェーン・ネットワーク内の他のユーザーに対してこの関数をコールできます。他のユーザーは、自分のアカウントに対してのみこのメソッドをコールできます。
@Validator(yup.string(), yup.string())
  public async isTokenAdmin(org_id: string, user_id: string) {
    await this.Ctx.Auth.checkAuthorization("ADMIN.isUserTokenAdmin", "TOKEN");
    return await this.Ctx.Auth.isUserTokenAdmin(org_id, user_id);
  }
パラメータ:
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • コール元がToken Adminの場合はtrueを返し、そうでない場合はfalseを返します。
getAllTokenAdmins
このメソッドは、チェーンコードのToken Adminであるすべてのユーザーのリストを返します。このメソッドは、Token Adminまたはチェーンコードの任意のOrg Adminのみがコールできます。
@Validator()
public async getAllTokenAdmins() {
    await this.Ctx.Auth.checkAuthorization('ADMIN.getAllAdmins', 'TOKEN');
    return await this.Ctx.Admin.getAllAdmins();
}
パラメータ:
  • なし
戻り値:
  • 成功の場合、orgIdおよびuserIdオブジェクトを含むJSON形式のadmins配列。
戻り値の例:
{"admins":[{"org_id":"Org1MSP","user_id":"admin"}]}
addOrgAdmin
このメソッドは、ユーザーを組織のOrg Adminとして追加します。このメソッドは、チェーンコードのToken Adminまたは指定された組織のOrg Adminのみがコールできます。
@Validator(yup.string(), yup.string())
  public async addOrgAdmin(org_id: string, user_id: string) {
    await this.Ctx.Auth.checkAuthorization("ADMIN.addOrgAdmin", "TOKEN", { org_id });
    return await this.Ctx.Admin.addOrgAdmin(org_id, user_id);
  }
パラメータ:
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、組織のOrg Adminとして追加されたユーザーの詳細を含むメッセージ。
戻り値の例:
{
    "msg": "Successfully added Org Admin (Org_Id: Org1MSP, User_Id: orgAdmin)"
}
removeOrgAdmin
このメソッドは、組織のOrg Adminであるユーザーを削除します。このメソッドは、チェーンコードのToken Adminまたは指定された組織のOrg Adminのみがコールできます。
@Validator(yup.string(), yup.string())
  public async removeOrgAdmin(org_id: string, user_id: string) {
    await this.Ctx.Auth.checkAuthorization("ADMIN.removeOrgAdmin", "TOKEN", { org_id });
    return await this.Ctx.Admin.removeOrgAdmin(org_id, user_id);
  }
パラメータ:
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、組織のOrg Adminとして削除されたユーザーの詳細を含むメッセージ。
戻り値の例:
{
  "msg": "Successfully removed Org Admin (Org_Id Org1MSP User_Id orgAdmin)"
}
getOrgAdmins
このメソッドは、組織のOrg Adminであるすべてのユーザーのリストを返します。このメソッドは、チェーンコードのToken Adminまたは任意の組織のOrg Adminのみがコールできます。
  @Validator()
  public async getOrgAdmins() {
    await this.Ctx.Auth.checkAuthorization("ADMIN.getOrgAdmins", "TOKEN");
    return await this.Ctx.Admin.getAllOrgAdmins();
  }
パラメータ:
  • なし
戻り値:
  • 成功の場合、orgIdおよびuserIdオブジェクトを含むJSON形式の配列。
戻り値の例:
{
    "admins": [
        {
            "org_id": "Org1MSP",
            "user_id": "orgadmin"
        },
        {
            "org_id": "Org1MSP",
            "user_id": "orgadmin1"
        },
        {
            "org_id": "Org1MSP",
            "user_id": "orgadmin2"
        }
    ]
}
addTokenAdmin
このメソッドは、ユーザーをチェーンコードのToken Adminとして追加します。このメソッドは、チェーンコードのToken Adminのみがコールできます。
@Validator(yup.string(), yup.string())
public async addTokenAdmin(org_id: string, user_id: string) {
    await this.Ctx.Auth.checkAuthorization('ADMIN.addAdmin', 'TOKEN');
    return await this.Ctx.Admin.addAdmin(org_id, user_id);
}
パラメータ:
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、チェーンコードのToken Adminとして追加されたユーザーの詳細を含むメッセージ。
戻り値の例:
{"msg":"Successfully added Admin (Org_Id: Org1MSP, User_Id: User1)"}
removeTokenAdmin
このメソッドは、チェーンコードのToken Adminであるユーザーを削除します。このメソッドは、チェーンコードのToken Adminのみがコールできます。
@Validator(yup.string(), yup.string())
public async removeTokenAdmin(org_id: string, user_id: string) {
    await this.Ctx.Auth.checkAuthorization('ADMIN.removeAdmin', 'TOKEN');
    return await this.Ctx.Admin.removeAdmin(org_id, user_id);
}
パラメータ:
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、チェーンコードのToken Adminとして削除されたユーザーの詳細を含むメッセージ。
戻り値の例:
{"msg": "Successfully removed Admin (Org_Id: Org1MSP, User_Id: User1)"}
isTokenAdmin
このメソッドは、関数のコール元がToken Adminの場合はブール値trueを返して、それ以外の場合はfalseを返します。Token AdminToken Auditor、任意のOrg Adminまたは任意のOrg Auditorは、ブロックチェーン・ネットワーク内の他のユーザーに対してこの関数をコールできます。他のユーザーは、自分のアカウントに対してのみこのメソッドをコールできます。
@Validator(yup.string(), yup.string())
  public async isTokenAdmin(org_id: string, user_id: string) {
    await this.Ctx.Auth.checkAuthorization("ADMIN.isUserTokenAdmin", "TOKEN");
    return await this.Ctx.Auth.isUserTokenAdmin(org_id, user_id);
  }
パラメータ:
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • コール元がToken Adminの場合はtrueを返し、そうでない場合はfalseを返します。
getAllTokenAdmins
このメソッドは、チェーンコードのToken Adminであるすべてのユーザーのリストを返します。このメソッドは、チェーンコードのToken AdminまたはToken Auditorのみがコールできます。
@Validator()
public async getAllTokenAdmins() {
    await this.Ctx.Auth.checkAuthorization('ADMIN.getAllAdmins', 'TOKEN');
    return await this.Ctx.Admin.getAllAdmins();
}
パラメータ:
  • なし
戻り値:
  • 成功の場合、orgIdおよびuserIdオブジェクトを含むJSON形式のadmins配列。
戻り値の例:
{"admins":[{"org_id":"Org1MSP","user_id":"admin"}]}
addOrgAdmin
このメソッドは、ユーザーを組織のOrg Adminとして追加します。このメソッドは、チェーンコードのToken Adminまたは指定された組織のOrg Adminのみがコールできます。
@Validator(yup.string(), yup.string())
  public async addOrgAdmin(org_id: string, user_id: string) {
    await this.Ctx.Auth.checkAuthorization("ADMIN.addOrgAdmin", "TOKEN", { org_id });
    return await this.Ctx.Admin.addOrgAdmin(org_id, user_id);
  }
パラメータ:
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、組織のOrg Adminとして追加されたユーザーの詳細を含むメッセージ。
戻り値の例:
{
    "msg": "Successfully added Org Admin (Org_Id: Org1MSP, User_Id: orgAdmin)"
}
removeOrgAdmin
このメソッドは、組織のOrg Adminであるユーザーを削除します。このメソッドは、チェーンコードのToken Adminまたは指定された組織のOrg Adminのみがコールできます。
@Validator(yup.string(), yup.string())
  public async removeOrgAdmin(org_id: string, user_id: string) {
    await this.Ctx.Auth.checkAuthorization("ADMIN.removeOrgAdmin", "TOKEN", { org_id });
    return await this.Ctx.Admin.removeOrgAdmin(org_id, user_id);
  }
パラメータ:
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、組織のOrg Adminとして削除されたユーザーの詳細を含むメッセージ。
戻り値の例:
{
  "msg": "Successfully removed Org Admin (Org_Id Org1MSP User_Id orgAdmin)"
}
getOrgAdmins
このメソッドは、組織のOrg Adminであるすべてのユーザーのリストを返します。このメソッドは、Token AdminToken Auditor、任意のOrg Adminまたは任意のOrg Auditorのみがコールできます。
  @Validator()
  public async getOrgAdmins() {
    await this.Ctx.Auth.checkAuthorization("ADMIN.getOrgAdmins", "TOKEN");
    return await this.Ctx.Admin.getAllOrgAdmins();
  }
パラメータ:
  • なし
戻り値:
  • 成功の場合、orgIdおよびuserIdオブジェクトを含むJSON形式の配列。
戻り値の例:
{
    "admins": [
        {
            "org_id": "Org1MSP",
            "user_id": "orgadmin"
        },
        {
            "org_id": "Org1MSP",
            "user_id": "orgadmin1"
        },
        {
            "org_id": "Org1MSP",
            "user_id": "orgadmin2"
        }
    ]
}
addTokenAuditor
このメソッドは、ユーザーをチェーンコードのToken Auditorとして追加します。このメソッドは、チェーンコードのToken Adminのみがコールできます。
public async addTokenAuditor(org_id: string, user_id: string)
パラメータ:
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、チェーンコードのToken Auditorとして追加されたユーザーの詳細を含むメッセージ。
戻り値の例:
{
    "returnCode": "Success",
    "error": "",
    "result": {
        "txid": "cd81f6c4c9e7c18ece357dbf5c139ef66ef2d6566be3b14de5f6d0a3fd4bb2f0",
        "payload": {
            "msg": "Successfully added Token Auditor (Org_Id: CB, User_Id: cb)"
        },
        "encode": "JSON",
        "sourceURL": "cb-oabcs1-bom.blockchain.ocp.example.com:20009",
        "blockNumber": 196
    }
}
removeTokenAuditor
このメソッドは、チェーンコードのToken Auditorであるユーザーを削除します。このメソッドは、チェーンコードのToken Adminのみがコールできます。
public async removeTokenAuditor(org_id: string, user_id: string)
パラメータ:
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、チェーンコードのToken Auditorとして削除されたユーザーの詳細を含むメッセージ。
戻り値の例:
{
    "returnCode": "Success",
    "error": "",
    "result": {
        "txid": "a886a6040fbc76374a3c78c89ab0ffc9f7b8391cc5239b169bf3b878cf40c67b",
        "payload": {
            "msg": "Successfully removed Token Auditor (Org_Id: CB, User_Id: cb)"
        },
        "encode": "JSON",
        "sourceURL": "cb-oabcs1-bom.blockchain.ocp.example.com:20010",
        "blockNumber": 219
    }
}
getTokenAuditors
このメソッドは、チェーンコードのすべてのToken Auditorsを返します。このメソッドは、チェーンコードのToken AdminまたはToken Auditorのみがコールできます。
public async getTokenAuditors()
戻り値の例:
{
    "returnCode": "Success",
    "error": "",
    "result": {
        "payload": {
            "auditors": [
                {
                    "org_id": "CB",
                    "user_id": "auditor_user_cb"
                }
            ]
        },
        "encode": "JSON"
    }
}
addOrgAuditor
このメソッドは、チェーンコードのOrg Auditorとしてユーザーを追加します。このメソッドは、チェーンコードのToken AdminまたはOrg Adminのみがコールできます。
public async addOrgAuditor(org_id: string, user_id: string)
パラメータ:
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、チェーンコードのOrg Auditorとして追加されたユーザーの詳細を含むメッセージ。
戻り値の例:
{
    "returnCode": "Success",
    "error": "",
    "result": {
        "txid": "44bbad35a1478cb714e32f7cfd551897868a203520aab9cea5771d3aadc1cf03",
        "payload": {
            "msg": "Successfully added Org Auditor (Org_Id: CB, User_Id: cb)"
        },
        "encode": "JSON",
        "sourceURL": "cb-oabcs1-bom.blockchain.ocp.example.com:20009",
        "blockNumber": 198
    }
}
removeOrgAuditor
このメソッドは、チェーンコードのOrg Auditorとしてユーザーを削除します。このメソッドは、チェーンコードのToken AdminまたはOrg Adminのみがコールできます。
public async removeOrgAuditor(org_id: string, user_id: string)
パラメータ:
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、チェーンコードのOrg Auditorとして削除されたユーザーの詳細を含むメッセージ。
戻り値の例:
{
    "returnCode": "Success",
    "error": "",
    "result": {
        "txid": "c3bc720461004a53b37c68d4bb264858b88d980bc093a0a3ebb62a32974fb306",
        "payload": {
            "msg": "Successfully removed Org Auditor (Org_Id: CB, User_Id: cb)"
        },
        "encode": "JSON",
        "sourceURL": "cb-oabcs1-bom.blockchain.ocp.example.com:20010",
        "blockNumber": 221
    }
}
getOrgAuditors
このメソッドは、チェーンコードのすべてのOrg Auditorsを返します。このメソッドは、Token AdminToken AuditorOrg AdminまたはOrg Auditorのみがコールできます。
public async getOrgAuditors()
戻り値の例:
{
    "returnCode": "Success",
    "error": "",
    "result": {
        "payload": {
            "auditors": [
                {
                    "org_id": "FI1",
                    "user_id": "auditor_user_fi1"
                },
                {
                    "org_id": "FI2",
                    "user_id": "auditor_user_fi2"
                }
            ]
        },
        "encode": "JSON"
    }
}

トークン構成管理のメソッド

init
このメソッドは、チェーンコードがデプロイまたはアップグレードされるときにコールされます。すべてのToken Adminは、必須のadminListパラメータのuser_idおよびorg_id情報によって識別されます。user_idは、インスタンス所有者またはインスタンスにログインしているユーザーのユーザー名および電子メールIDです。org_idは、現在のネットワーク組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) IDです。
Token Adminユーザーは、addAdminおよびremoveAdminメソッドをコールして、他のToken Adminユーザーを追加および削除できます。
public async init(adminList: TokenAdminAsset[]) {
    await this.Ctx.Admin.initAdmin(adminList);
    return;
}
パラメータ:
  • adminList array – トークン管理者のリストを指定する{user_id, org_id}情報の配列。adminList配列は必須パラメータです。
パラメータの例(macOSおよびLinux CLI):
'[{"user_id":"userid", "org_id":"OrgMSPId"}]'
パラメータの例(Microsoft Windows CLI):
"[{\"user_id\":\"userid\", \"org_id\":\"OrgMSPId\"}]"
パラメータの例(Oracle Blockchain Platformコンソール):
["[{\"user_id\":\"userid\", \"org_id\":\"OrgMSPId\"}]"]
initialize<Token Name>Token
このメソッドはトークンを作成し、トークン・プロパティを初期化します。アセットとそのプロパティは、状態データベースに保存されます。このメソッドは、チェーンコードのToken Adminのみがコールできます。
@Validator(Digicur)
    public async initializeDigicurToken(token_asset: Digicur) {
        await this.Ctx.Auth.checkAuthorization('TOKEN.save', 'TOKEN');
        return await this.Ctx.Token.save(token_asset)
    }
パラメータ:
  • asset <Token Class> – トークン・アセットがこのメソッドにパラメータとして渡されます。トークン・アセットのプロパティは異なる場合があり、トークン仕様ファイルに記述されています。仕様ファイルに読取り専用としてマークされたパラメータは含めないでください。

    Visual Studio CodeとCLIまたはPostmanコレクションを使用している場合は、assetパラメータを別の形式で指定します。

    Visual Studio Code: GUIを使用して、トークン・クラス・フィールドに対応する個々のパラメータを渡します。

    CLI / Postman: 次の例に示すように、トークン指定フィールドを含むシリアライズされたJSON文字列を渡します。

    "{\"token_id\":\"USD\",\"token_desc\":\"token_desc value\",\"Currency_Name\":\"Currency_Name value\"}"

戻り値:
  • 成功の場合、作成されたトークン・アセットのJSON表現。
戻り値の例:
{
    "assetType": "otoken",
    "token_id": "digiCurr101",
    "token_name": "digicur",
    "token_type": "fungible",
    "behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "burnable",
        "roles"
    ],
    "roles": {
        "minter_role_name": "minter"
    },
    "mintable": {
        "max_mint_quantity": 1000
    },
    "divisible": {
        "decimal": 2
    },
    "currency_name": "DOLLAR",
    "token_to_currency_ratio": 1
}
update<Token Name>Token
このメソッドは、トークン・プロパティを更新します。トークン・アセットの作成後は、token_descプロパティおよびカスタム・プロパティのみを更新できます。このメソッドは、チェーンコードのToken Adminのみがコールできます。
@Validator(Digicur)
public async updateDigicurToken(token_asset: Digicur) {
    await this.Ctx.Auth.checkAuthorization('TOKEN.update', 'TOKEN');
    return await this.Ctx.Token.update(token_asset);
}
パラメータ:
  • asset <Token Class> – トークン・アセットがこのメソッドにパラメータとして渡されます。トークン・アセットのプロパティは異なる場合があり、トークン仕様ファイルに記述されています。仕様ファイルに読取り専用としてマークされたパラメータは含めないでください。

    Visual Studio CodeとCLIまたはPostmanコレクションを使用している場合は、assetパラメータを別の形式で指定します。

    Visual Studio Code: GUIを使用して、トークン・クラス・フィールドに対応する個々のパラメータを渡します。

    CLI / Postman: 次の例に示すように、トークン指定フィールドを含むシリアライズされたJSON文字列を渡します。

    "{\"token_id\":\"USD\",\"token_desc\":\"token_desc value\",\"Currency_Name\":\"Currency_Name value\"}"

戻り値:
  • 成功の場合、トークン・アセットの更新されたJSON表現。
戻り値の例:
{
    "assetType": "otoken",
    "token_id": "digiCurr101",
    "token_name": "digicur",
    "token_desc": "Digital Currency equiv of dollar",
    "token_type": "fungible",
    "behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "burnable",
        "roles"
    ],
    "roles": {
        "minter_role_name": "minter"
    },
    "mintable": {
        "max_mint_quantity": 1000
    },
    "divisible": {
        "decimal": 2
    },
    "currency_name": "DOLLAR",
    "token_to_currency_ratio": 1
}
getTokenDecimals
このメソッドは、フラクショナル・トークンに対して構成された小数点以下の桁数を返します。トークンに対してdivisible動作が指定されなかった場合、デフォルト値は0です。このメソッドは、チェーンコードのToken AdminまたはOrg Adminのみがコールできます。
@Validator(yup.string())
public async getTokenDecimals(token_id: string) {
    const token_asset = await this.getTokenObject(token_id);
    await this.Ctx.Auth.checkAuthorization('TOKEN.getDecimals', 'TOKEN');
    return {
        msg: `Token Id: ${token_id} has ${this.Ctx.Token.getDecimals(token_asset)} decimal places.`
    };
}
パラメータ:
  • token_id: string – トークンのID。
戻り値:
  • 成功の場合、トークンの小数点以下の桁数を示すJSON文字列。
戻り値の例:
{"msg":"Token Id: digiCurr101 has 1 decimal places."}
getTokenById
このメソッドは、状態データベースに存在する場合、トークン・オブジェクトを返します。このメソッドは、チェーンコードのToken AdminまたはOrg Adminのみがコールできます。
@Validator(yup.string())
public async getTokenById(token_id: string) {
    await this.Ctx.Auth.checkAuthorization('TOKEN.get', 'TOKEN');
    const token = await this.getTokenObject(token_id);
    return token;
}
パラメータ:
  • token_id: string – トークンのID。
戻り値:
  • 成功の場合、トークン・アセットを表すJSONオブジェクト。
戻り値の例:
{
    "assetType": "otoken",
    "token_id": "digiCurr101",
    "token_name": "digicur",
    "token_desc": "Digital Currency equiv of dollar",
    "token_type": "fungible",
    "behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "burnable",
        "roles"
    ],
    "roles": {
        "minter_role_name": "minter"
        "burner_role_name": "burner",
        "notary_role_name": "notary"
    },
    "mintable": {
        "max_mint_quantity": 2000
    },
    "divisible": {
        "decimal": 1
    },
    "currency_name": "DOLLAR",
    "token_to_currency_ratio": 1
}
getTokenHistory
このメソッドは、指定されたトークンIDのトークン履歴を返します。すべてのユーザーがこのメソッドをコールできます。
  @Validator(yup.string())
  public async getTokenHistory(tokenId: string) {
    await this.Ctx.Auth.checkAuthorization("TOKEN.getTokenHistory", "TOKEN");
    return await this.Ctx.Token.history(tokenId);
  }
パラメータ:
  • tokenId: string – トークンのID。
戻り値:
  • 成功の場合、トークン履歴を表すJSONオブジェクト。
戻り値の例:

[
    {
        "trxId": "0d75f09446a60088afb948c6aca046e261fddcd43df416076201cdc5565f1a35",
        "timeStamp": "2023-09-01T16:48:41.000Z",
        "value": {
            "assetType": "otoken",
            "token_id": "token",
            "token_name": "fiatmoneytok",
            "token_desc": "updatedDesc",
            "token_standard": "ttf+",
            "token_type": "fungible",
            "token_unit": "fractional",
            "behaviors": [
                "divisible",
                "mintable",
                "transferable",
                "burnable",
                "roles"
            ],
            "roles": {
                "minter_role_name": "minter"
            },
            "mintable": {
                "max_mint_quantity": 1000
            },
            "divisible": {
                "decimal": 2
            }
        }
    },
    {
        "trxId": "3666344878b043b65d5b821cc79c042ba52aec467618800df5cf14eac69f72fa",
        "timeStamp": "2023-08-31T20:24:55.000Z",
        "value": {
            "assetType": "otoken",
            "token_id": "token",
            "token_name": "fiatmoneytok",
            "token_standard": "ttf+",
            "token_type": "fungible",
            "token_unit": "fractional",
            "behaviors": [
                "divisible",
                "mintable",
                "transferable",
                "burnable",
                "roles"
            ],
            "roles": {
                "minter_role_name": "minter"
            },
            "mintable": {
                "max_mint_quantity": 1000
            },
            "divisible": {
                "decimal": 2
            }
        }
    }
]
getAllTokens
このメソッドは、状態データベースに格納されているすべてのトークンを返します。このメソッドは、チェーンコードのToken AdminまたはOrg Adminのみがコールできます。このメソッドでは、Berkeley DB SQLリッチ問合せが使用され、リモートOracle Blockchain Platformネットワークに接続されている場合にのみコールできます。
@Validator()
public async getAllTokens() {
    await this.Ctx.Auth.checkAuthorization('TOKEN.getAllTokens', 'TOKEN');
    return await this.Ctx.Token.getAllTokens();
}
パラメータ:
  • なし
戻り値:
  • 成功の場合、すべてのトークン・アセットを表すJSONオブジェクト。
getTokensByName
このメソッドは、指定された名前のすべてのトークン・オブジェクトを返します。このメソッドは、チェーンコードのToken AdminまたはOrg Adminのみがコールできます。このメソッドでは、Berkeley DB SQLリッチ問合せが使用され、リモートOracle Blockchain Platformネットワークに接続されている場合にのみコールできます。
@Validator(yup.string())
public async getTokensByName(token_name: string) {
    await this.Ctx.Auth.checkAuthorization('TOKEN.getTokensByName', 'TOKEN');
    return await this.Ctx.Token.getTokensByName(token_name);
}
パラメータ:
  • token_name: string – 取得するトークンの名前。この名前は、仕様ファイルのtoken_nameプロパティに対応します。値は、トークンのクラス名です。
戻り値:
  • 成功の場合、名前と一致するすべてのトークン・アセットのJSONオブジェクト。
init
このメソッドは、チェーンコードがデプロイまたはアップグレードされるときにコールされます。すべてのToken Adminは、必須のadminListパラメータのuser_idおよびorg_id情報によって識別されます。user_idは、インスタンス所有者またはインスタンスにログインしているユーザーのユーザー名および電子メールIDです。org_idは、現在のネットワーク組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) IDです。
Token Adminユーザーは、addAdminおよびremoveAdminメソッドをコールして、他のToken Adminユーザーを追加および削除できます。
public async init(adminList: TokenAdminAsset[]) {
    await this.Ctx.Admin.initAdmin(adminList);
    return;
}
パラメータ:
  • adminList array – トークン管理者のリストを指定する{user_id, org_id}情報の配列。adminList配列は必須パラメータです。
パラメータの例(macOSおよびLinux CLI):
'[{"user_id":"userid", "org_id":"OrgMSPId"}]'
パラメータの例(Microsoft Windows CLI):
"[{\"user_id\":\"userid\", \"org_id\":\"OrgMSPId\"}]"
パラメータの例(Oracle Blockchain Platformコンソール):
["[{\"user_id\":\"userid\", \"org_id\":\"OrgMSPId\"}]"]
initialize<Token Name>Token
このメソッドはトークンを作成し、トークン・プロパティを初期化します。アセットとそのプロパティは、状態データベースに保存されます。このメソッドは、チェーンコードのToken Adminのみがコールできます。
@Validator(Digicur)
    public async initializeDigicurToken(token_asset: Digicur) {
        await this.Ctx.Auth.checkAuthorization('TOKEN.save', 'TOKEN');
        return await this.Ctx.Token.save(token_asset)
    }
パラメータ:
  • asset <Token Class> – トークン・アセットがこのメソッドにパラメータとして渡されます。トークン・アセットのプロパティは異なる場合があり、トークン仕様ファイルに記述されています。仕様ファイルに読取り専用としてマークされたパラメータは含めないでください。

    Visual Studio CodeとCLIまたはPostmanコレクションを使用している場合は、assetパラメータを別の形式で指定します。

    Visual Studio Code: GUIを使用して、トークン・クラス・フィールドに対応する個々のパラメータを渡します。

    CLI / Postman: 次の例に示すように、トークン指定フィールドを含むシリアライズされたJSON文字列を渡します。

    "{\"token_id\":\"USD\",\"token_desc\":\"token_desc value\",\"Currency_Name\":\"Currency_Name value\"}"

戻り値:
  • 成功の場合、作成されたトークン・アセットのJSON表現。
戻り値の例:
{
    "assetType": "otoken",
    "token_id": "digiCurr101",
    "token_name": "digicur",
    "token_type": "fungible",
    "behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "burnable",
        "roles"
    ],
    "roles": {
        "minter_role_name": "minter"
    },
    "mintable": {
        "max_mint_quantity": 1000
    },
    "divisible": {
        "decimal": 2
    },
    "currency_name": "DOLLAR",
    "token_to_currency_ratio": 1
}
update<Token Name>Token
このメソッドは、トークン・プロパティを更新します。トークン・アセットの作成後は、token_descプロパティおよびカスタム・プロパティのみを更新できます。このメソッドは、チェーンコードのToken Adminのみがコールできます。
@Validator(Digicur)
public async updateDigicurToken(token_asset: Digicur) {
    await this.Ctx.Auth.checkAuthorization('TOKEN.update', 'TOKEN');
    return await this.Ctx.Token.update(token_asset);
}
パラメータ:
  • asset <Token Class> – トークン・アセットがこのメソッドにパラメータとして渡されます。トークン・アセットのプロパティは異なる場合があり、トークン仕様ファイルに記述されています。仕様ファイルに読取り専用としてマークされたパラメータは含めないでください。

    Visual Studio CodeとCLIまたはPostmanコレクションを使用している場合は、assetパラメータを別の形式で指定します。

    Visual Studio Code: GUIを使用して、トークン・クラス・フィールドに対応する個々のパラメータを渡します。

    CLI / Postman: 次の例に示すように、トークン指定フィールドを含むシリアライズされたJSON文字列を渡します。

    "{\"token_id\":\"USD\",\"token_desc\":\"token_desc value\",\"Currency_Name\":\"Currency_Name value\"}"

戻り値:
  • 成功の場合、トークン・アセットの更新されたJSON表現。
戻り値の例:
{
    "assetType": "otoken",
    "token_id": "digiCurr101",
    "token_name": "digicur",
    "token_desc": "Digital Currency equiv of dollar",
    "token_type": "fungible",
    "behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "burnable",
        "roles"
    ],
    "roles": {
        "minter_role_name": "minter"
    },
    "mintable": {
        "max_mint_quantity": 1000
    },
    "divisible": {
        "decimal": 2
    },
    "currency_name": "DOLLAR",
    "token_to_currency_ratio": 1
}
getTokenDecimals
このメソッドは、フラクショナル・トークンに対して構成された小数点以下の桁数を返します。トークンに対してdivisible動作が指定されなかった場合、デフォルト値は0です。このメソッドは、Token AdminToken AuditorOrg AdminまたはOrg Auditorのみがコールできます。
@Validator(yup.string())
public async getTokenDecimals(token_id: string) {
    const token_asset = await this.getTokenObject(token_id);
    await this.Ctx.Auth.checkAuthorization('TOKEN.getDecimals', 'TOKEN');
    return {
        msg: `Token Id: ${token_id} has ${this.Ctx.Token.getDecimals(token_asset)} decimal places.`
    };
}
パラメータ:
  • token_id: string – トークンのID。
戻り値:
  • 成功の場合、トークンの小数点以下の桁数を示すJSON文字列。
戻り値の例:
{"msg":"Token Id: digiCurr101 has 1 decimal places."}
getTokenById
このメソッドは、状態データベースに存在する場合、トークン・オブジェクトを返します。このメソッドは、Token AdminToken AuditorOrg AdminまたはOrg Auditorのみがコールできます。
@Validator(yup.string())
public async getTokenById(token_id: string) {
    await this.Ctx.Auth.checkAuthorization('TOKEN.get', 'TOKEN');
    const token = await this.getTokenObject(token_id);
    return token;
}
パラメータ:
  • token_id: string – トークンのID。
戻り値:
  • 成功の場合、トークン・アセットを表すJSONオブジェクト。
戻り値の例:
{
    "assetType": "otoken",
    "token_id": "digiCurr101",
    "token_name": "digicur",
    "token_desc": "Digital Currency equiv of dollar",
    "token_type": "fungible",
    "behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "burnable",
        "roles"
    ],
    "roles": {
        "minter_role_name": "minter"
        "burner_role_name": "burner",
        "notary_role_name": "notary"
    },
    "mintable": {
        "max_mint_quantity": 2000
    },
    "divisible": {
        "decimal": 1
    },
    "currency_name": "DOLLAR",
    "token_to_currency_ratio": 1
}
getTokenHistory
このメソッドは、指定されたトークンIDのトークン履歴を返します。このメソッドは、Token AdminToken AuditorOrg AdminまたはOrg Auditorのみがコールできます。
  @Validator(yup.string())
  public async getTokenHistory(tokenId: string) {
    await this.Ctx.Auth.checkAuthorization("TOKEN.getTokenHistory", "TOKEN");
    return await this.Ctx.Token.history(tokenId);
  }
パラメータ:
  • tokenId: string – トークンのID。
戻り値:
  • 成功の場合、トークン履歴を表すJSONオブジェクト。
戻り値の例:

[
    {
        "trxId": "0d75f09446a60088afb948c6aca046e261fddcd43df416076201cdc5565f1a35",
        "timeStamp": "2023-09-01T16:48:41.000Z",
        "value": {
            "assetType": "otoken",
            "token_id": "token",
            "token_name": "fiatmoneytok",
            "token_desc": "updatedDesc",
            "token_standard": "ttf+",
            "token_type": "fungible",
            "token_unit": "fractional",
            "behaviors": [
                "divisible",
                "mintable",
                "transferable",
                "burnable",
                "roles"
            ],
            "roles": {
                "minter_role_name": "minter"
            },
            "mintable": {
                "max_mint_quantity": 1000
            },
            "divisible": {
                "decimal": 2
            }
        }
    },
    {
        "trxId": "3666344878b043b65d5b821cc79c042ba52aec467618800df5cf14eac69f72fa",
        "timeStamp": "2023-08-31T20:24:55.000Z",
        "value": {
            "assetType": "otoken",
            "token_id": "token",
            "token_name": "fiatmoneytok",
            "token_standard": "ttf+",
            "token_type": "fungible",
            "token_unit": "fractional",
            "behaviors": [
                "divisible",
                "mintable",
                "transferable",
                "burnable",
                "roles"
            ],
            "roles": {
                "minter_role_name": "minter"
            },
            "mintable": {
                "max_mint_quantity": 1000
            },
            "divisible": {
                "decimal": 2
            }
        }
    }
]
getAllTokens
このメソッドは、状態データベースに格納されているすべてのトークンを返します。このメソッドは、Token AdminToken AuditorOrg AdminまたはOrg Auditorのみがコールできます。このメソッドでは、Berkeley DB SQLリッチ問合せが使用され、リモートOracle Blockchain Platformネットワークに接続されている場合にのみコールできます。
@Validator()
public async getAllTokens() {
    await this.Ctx.Auth.checkAuthorization('TOKEN.getAllTokens', 'TOKEN');
    return await this.Ctx.Token.getAllTokens();
}
パラメータ:
  • なし
戻り値:
  • 成功の場合、すべてのトークン・アセットを表すJSONオブジェクト。
getTokensByName
このメソッドは、指定された名前のすべてのトークン・オブジェクトを返します。このメソッドは、Token AdminToken AuditorOrg AdminまたはOrg Auditorのみがコールできます。このメソッドでは、Berkeley DB SQLリッチ問合せが使用され、リモートOracle Blockchain Platformネットワークに接続されている場合にのみコールできます。
@Validator(yup.string())
public async getTokensByName(token_name: string) {
    await this.Ctx.Auth.checkAuthorization('TOKEN.getTokensByName', 'TOKEN');
    return await this.Ctx.Token.getTokensByName(token_name);
}
パラメータ:
  • token_name: string – 取得するトークンの名前。この名前は、仕様ファイルのtoken_nameプロパティに対応します。値は、トークンのクラス名です。
戻り値:
  • 成功の場合、名前と一致するすべてのトークン・アセットのJSONオブジェクト。

アカウント管理のメソッド

createAccount
このメソッドは、指定されたユーザーおよびトークンのアカウントを作成します。任意の時点でトークンを持つすべてのユーザーに対してアカウントを作成する必要があります。アカウントは、残高、保留残高およびトランザクション履歴を追跡します。アカウントIDは英数字のセットです。アカウントIDは、oaccount~<token asset name>~が先頭付き、インスタンス所有者およびインスタンスにログインしているユーザーのユーザー名または電子メールID (user_id)と現在のネットワーク組織内のユーザーの会員サービス・プロバイダID (org_id)のハッシュが続きます。このメソッドは、チェーンコードのToken Adminまたは指定された組織のOrg Adminのみがコールできます。
  @Validator(yup.string(), yup.string(), yup.string())
  public async createAccount(org_id: string, user_id: string, token_type: string) {
    await this.Ctx.Auth.checkAuthorization("ACCOUNT.createAccount", "TOKEN", { org_id });
    return await this.Ctx.Account.createAccount(org_id, user_id, token_type);
  }
パラメータ:
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
  • token_type: string – トークンのタイプ。fungibleである必要があります。
戻り値:
  • 成功の場合、作成されたアカウントのJSONオブジェクト。bapAccountVersionパラメータは、内部使用のためにアカウント・オブジェクトで定義されます。
戻り値の例:
{
  "assetType": "oaccount",
  "account_id": "oaccount~abc74791148b761352b98df58035601b6f5480448ac2b4a3a7eb54bdbebf48eb",
  "bapAccountVersion": 0,
  "user_id": "admin",
  "org_id": "Org1MSP",
  "token_type": "fungible",
  "token_id": "",
  "token_name": "",
  "balance": 0,
  "onhold_balance": 0
}
associateTokenToAccount
このメソッドは、代替可能トークンをアカウントに関連付けます。このメソッドは、チェーンコードのToken Adminまたは関連する組織のOrg Adminのみがコールできます。
  @Validator(yup.string(), yup.string())
  public async associateTokenToAccount(account_id: string, token_id: string) {
    await this.Ctx.Auth.checkAuthorization("ACCOUNT.associateToken", "TOKEN", { account_id });
    return await this.Ctx.Account.associateToken(account_id, token_id);
  }
パラメータ:
  • account_id: string – アカウントのID。
  • token_id: string – トークンのID。
戻り値:
  • 成功の場合、更新されたアカウントのJSONオブジェクト。bapAccountVersionパラメータは、内部使用のためにアカウント・オブジェクトで定義されます。
戻り値の例:
{
    "assetType": "oaccount",
    "account_id": "oaccount~abc74791148b761352b98df58035601b6f5480448ac2b4a3a7eb54bdbebf48eb",
    "bapAccountVersion": 0,
    "user_id": "admin",
    "org_id": "Org1MSP",
    "token_type": "fungible",
    "token_id": "fungible",
    "token_name": "fiatmoneytok",
    "balance": 0,
    "onhold_balance": 0
}
getAccount
このメソッドは、指定されたユーザーおよびトークンのアカウント詳細を返します。このメソッドは、チェーンコードのToken Admin、指定された組織のOrg AdminまたはアカウントのAccountOwnerのみがコールできます。
@Validator(yup.string(), yup.string(), yup.string())
public async getAccount(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.getAccount", "TOKEN", { account_id });
  return await this.Ctx.Account.getAccountWithStatus(account_id);
}
パラメータ:
  • token_id: string – トークンのID。
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、次のプロパティを含むJSONアカウント・オブジェクト:
  • account_id – ユーザー・アカウントのID。
  • user_id – ユーザーのユーザー名または電子メールID。
  • org_id – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • token_id – トークンのID。
  • token_name – トークンの名前。
  • balance – アカウントの現在の残高。
  • onhold_balance – アカウントの現在の保留残高。
  • bapAccountVersion – 内部使用のためのアカウント・オブジェクト・パラメータ。
  • status– ユーザー・アカウントの現在のステータス。
戻り値の例:
{
  "bapAccountVersion": 0,
  "assetType": "oaccount",
  "status": "active",
  "account_id": "oaccount~2de8db6b91964f8c9009136831126d3cfa94e1d00c4285c1ea3e6d1f36479ed4",
  "user_id": "idcqa",
  "org_id": "appdev",
  "token_type": "fungible",
  "token_id": "t1",
  "token_name": "obptok",
  "balance": 0,
  "onhold_balance": 0
}
getAccountHistory
このメソッドは、指定されたユーザーおよびトークンのアカウント履歴の詳細を返します。このメソッドは、チェーンコードのToken AdminまたはアカウントのAccountOwnerのみがコールできます。
  @Validator(yup.string(), yup.string(), yup.string())
  public async getAccountHistory(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.history", "TOKEN", { account_id });
    return await this.Ctx.Account.history(account_id);
  }
パラメータ:
  • token_id: string – トークンのID。
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、次のプロパティを含むJSONアカウント・オブジェクトの配列:
  • trxId – 台帳によって返されるトランザクションのトランザクションID。
  • timeStamp - トランザクションの時間。
  • value– アカウント・オブジェクトのJSON文字列。
戻り値の例:
[
    {
      "trxId":"2gsdh17fff222467e5667be042e33ce18e804b3e065cca15de306f837e416d7c3e",
      "timeStamp":1629718288,
      "value":{
         "assetType":"oaccount",
         "account_id":"oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f",
         "user_id":"user1",
         "org_id":"Org1MSP",
         "token_id":"digiCurr101",
         "token_name":"digicur",
         "balance":100,
         "onhold_balance":0,
         "bapAccountVersion": 1
   },
   {
      "trxId":"9fd07fff222467e5667be042e33ce18e804b3e065cca15de306f837e416d7c3e",
      "timeStamp":1629718288,
      "value":{
         "assetType":"oaccount",
         "account_id":"oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f",
         "user_id":"user1",
         "org_id":"Org1MSP",
         "token_id":"digiCurr101",
         "token_name":"digicur",
         "balance":0,
         "onhold_balance":0,
         "bapAccountVersion": 0
      }
   }
]
getAccountOnHoldBalance
このメソッドは、指定されたアカウントおよびトークンの現在の保留残高を返します。このメソッドは、チェーンコードのToken Admin、指定された組織のOrg AdminまたはアカウントのAccountOwnerのみがコールできます。
  @Validator(yup.string(), yup.string(), yup.string())
  public async getAccountOnHoldBalance(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.getAccountOnHoldBalance", "TOKEN", { account_id });
    return await this.Ctx.Account.getAccountOnHoldBalance(account_id);
  }
パラメータ:
  • token_id: string – トークンのID。
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、現在の保留残高のJSON表現。
戻り値の例:
{"msg":"Total Holding Balance is: 0","holding_balance":0}
getAllAccounts
このメソッドは、すべてのアカウントのリストを返します。このメソッドは、チェーンコードのToken Adminのみがコールできます。このメソッドでは、Berkeley DB SQLリッチ問合せが使用され、リモートOracle Blockchain Platformネットワークに接続されている場合にのみコールできます。
@Validator()
public async getAllAccounts() {
    await this.Ctx.Auth.checkAuthorization('ACCOUNT.getAllAccounts', 'TOKEN');
    return await this.Ctx.Account.getAllAccounts();
}
パラメータ:
  • なし
戻り値:
  • 成功の場合、すべてのアカウントのJSON配列。
getUserByAccountId
このメソッドは、指定されたアカウントのユーザー詳細(org_idおよびuser_id)を返します。このメソッドは、チェーンコードの任意のユーザーがコールできます。
@Validator(yup.string())
public async getUserByAccountId(account_id: string) {
    return await this.Ctx.Account.getUserByAccountId(account_id);
}
パラメータ:
  • account_id: string – アカウントのID。
戻り値:
  • 成功の場合、ユーザー詳細(org_idtoken_idおよびuser_id)のJSONオブジェクト。
戻り値の例:
{
    "token_id": "digiCurr101",
    "user_id": "user1",
    "org_id": "Org1MSP"
}
getAccountBalance
このメソッドは、指定されたアカウントおよびトークンの現在の残高を返します。このメソッドは、チェーンコードのToken Admin、指定された組織のOrg AdminまたはアカウントのAccountOwnerのみがコールできます。
  @Validator(yup.string(), yup.string(), yup.string())
  public async getAccountBalance(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.getAccountBalance", "TOKEN", { account_id });
    return await this.Ctx.Account.getAccountBalance(account_id);
  }
パラメータ:
  • token_id: string – トークンのID。
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、現在のアカウントの残高のJSON表現。
戻り値の例:
{"msg":"Current Balance is: 0","user_balance":0}
getAllOrgAccounts
このメソッドは、指定された組織に属するすべてのトークン・アカウントのリストを返します。このメソッドは、チェーンコードのToken Adminまたは指定された組織のOrg Adminのみがコールできます。
  @Validator(yup.string())
  public async getAllOrgAccounts(org_id: string) {
    await this.Ctx.Auth.checkAuthorization("ACCOUNT.getAllOrgAccounts", "TOKEN", { org_id });
    return await this.Ctx.Account.getAllOrgAccounts(org_id);
  }
パラメータ:
  • org_id: string – 組織のメンバーシップ・サービス・プロバイダ(MSP) ID。
戻り値:
  • 成功の場合、指定した組織のすべてのアカウントのリスト。
戻り値の例:
[
    {
        "key": "oaccount~2de8db6b91964f8c9009136831126d3cfa94e1d00c4285c1ea3e6d1f36479ed4",
        "valueJson": {
            "bapAccountVersion": 0,
            "assetType": "oaccount",
            "account_id": "oaccount~2de8db6b91964f8c9009136831126d3cfa94e1d00c4285c1ea3e6d1f36479ed4",
            "user_id": "idcqa",
            "org_id": "appdev",
            "token_type": "fungible",
            "token_id": "token",
            "token_name": "fiatmoneytok",
            "balance": 0,
            "onhold_balance": 0
        }
    },
    {
        "key": "oaccount~620fcf5deb5fd5a65c0b5b10fda129de0f629ccd232c5891c130e24a574df50a",
        "valueJson": {
            "bapAccountVersion": 0,
            "assetType": "oaccount",
            "account_id": "oaccount~620fcf5deb5fd5a65c0b5b10fda129de0f629ccd232c5891c130e24a574df50a",
            "user_id": "example_minter",
            "org_id": "appdev",
            "token_type": "fungible",
            "token_id": "token",
            "token_name": "fiatmoneytok",
            "balance": 0,
            "onhold_balance": 0
        }
    }
]
createAccount
このメソッドは、指定されたユーザーおよびトークンのアカウントを作成します。任意の時点でトークンを持つすべてのユーザーに対してアカウントを作成する必要があります。アカウントは、残高、保留残高およびトランザクション履歴を追跡します。アカウントIDは英数字のセットです。アカウントIDは、oaccount~<token asset name>~が先頭付き、インスタンス所有者およびインスタンスにログインしているユーザーのユーザー名または電子メールID (user_id)と現在のネットワーク組織内のユーザーの会員サービス・プロバイダID (org_id)のハッシュが続きます。このメソッドは、チェーンコードのToken Adminまたは指定された組織のOrg Adminのみがコールできます。
@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);
}
パラメータ:
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
  • token_type: string – トークンのタイプ。fungibleである必要があります。
  • daily_limits: JSON– 毎日トランザクションで使用できるトークンの最大量(max_daily_amount)および毎日完了できるトランザクションの最大数(max_daily_transactions)を指定するオブジェクト。

    Visual Studio CodeとCLIまたはPostmanコレクションを使用している場合は、daily_limitsパラメータを別の形式で指定します。

    Visual Studioコード: { "max_daily_amount": 1000, "max_daily_transactions": 100 }

    CLI /ポストマン: "{\"max_daily_amount\":1000,\"max_daily_transactions\":100}"

戻り値:
  • 成功の場合、作成されたアカウントのJSONオブジェクト。bapAccountVersionパラメータは、内部使用のためにアカウント・オブジェクトで定義されます。
戻り値の例:
{
  "assetType": "oaccount",
  "account_id": "oaccount~abc74791148b761352b98df58035601b6f5480448ac2b4a3a7eb54bdbebf48eb",
  "bapAccountVersion": 0,
  "user_id": "admin",
  "org_id": "Org1MSP",
  "token_type": "fungible",
  "token_id": "",
  "token_name": "",
  "balance": 0,
  "onhold_balance": 0,
  "onhold_burn_balance": 0,
  "max_daily_amount": 1000,
  "max_daily_transactions": 100
}
associateTokenToAccount
このメソッドは、代替可能トークンをアカウントに関連付けます。このメソッドは、チェーンコードのToken Adminまたは関連する組織のOrg Adminのみがコールできます。
  @Validator(yup.string(), yup.string())
  public async associateTokenToAccount(account_id: string, token_id: string) {
    await this.Ctx.Auth.checkAuthorization("ACCOUNT.associateToken", "TOKEN", { account_id });
    return await this.Ctx.Account.associateToken(account_id, token_id);
  }
パラメータ:
  • account_id: string – アカウントのID。
  • token_id: string – トークンのID。
戻り値:
  • 成功の場合、更新されたアカウントのJSONオブジェクト。bapAccountVersionパラメータは、内部使用のためにアカウント・オブジェクトで定義されます。
戻り値の例:
{
    "assetType": "oaccount",
    "account_id": "oaccount~abc74791148b761352b98df58035601b6f5480448ac2b4a3a7eb54bdbebf48eb",
    "bapAccountVersion": 0,
    "user_id": "admin",
    "org_id": "Org1MSP",
    "token_type": "fungible",
    "token_id": "fungible",
    "token_name": "fiatmoneytok",
    "balance": 0,
    "onhold_balance": 0
}
getAccount
このメソッドは、指定されたユーザーおよびトークンのアカウント詳細を返します。このメソッドは、Token AdminまたはToken Auditor、指定された組織のOrg AdminまたはOrg Auditor、またはアカウントのAccountOwnerのみがコールできます。
@Validator(yup.string(), yup.string(), yup.string())
public async getAccount(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.getAccount", "TOKEN", { account_id });
  return await this.Ctx.Account.getAccountWithStatus(account_id);
}
パラメータ:
  • token_id: string – トークンのID。
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、次のプロパティを含むJSONアカウント・オブジェクト:
  • account_id – ユーザー・アカウントのID。
  • user_id – ユーザーのユーザー名または電子メールID。
  • org_id – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • token_id – トークンのID。
  • token_name – トークンの名前。
  • balance – アカウントの現在の残高。
  • onhold_balance – アカウントの現在の保留残高。
  • bapAccountVersion – 内部使用のためのアカウント・オブジェクト・パラメータ。
  • status– ユーザー・アカウントの現在のステータス。
戻り値の例:
{
  "bapAccountVersion": 0,
  "assetType": "oaccount",
  "status": "active",
  "account_id": "oaccount~2de8db6b91964f8c9009136831126d3cfa94e1d00c4285c1ea3e6d1f36479ed4",
  "user_id": "idcqa",
  "org_id": "appdev",
  "token_type": "fungible",
  "token_id": "t1",
  "token_name": "obptok",
  "balance": 0,
  "onhold_balance": 0
}
getAccountHistory
このメソッドは、指定されたユーザーおよびトークンのアカウント履歴の詳細を返します。このメソッドは、チェーンコードのToken AdminまたはアカウントのAccountOwnerのみがコールできます。
  @Validator(yup.string(), yup.string(), yup.string())
  public async getAccountHistory(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.history", "TOKEN", { account_id });
    return await this.Ctx.Account.history(account_id);
  }
パラメータ:
  • token_id: string – トークンのID。
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、次のプロパティを含むJSONアカウント・オブジェクトの配列:
  • trxId – 台帳によって返されるトランザクションのトランザクションID。
  • timeStamp - トランザクションの時間。
  • value– アカウント・オブジェクトのJSON文字列。
戻り値の例:
[
    {
      "trxId":"2gsdh17fff222467e5667be042e33ce18e804b3e065cca15de306f837e416d7c3e",
      "timeStamp":1629718288,
      "value":{
         "assetType":"oaccount",
         "account_id":"oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f",
         "user_id":"user1",
         "org_id":"Org1MSP",
         "token_id":"digiCurr101",
         "token_name":"digicur",
         "balance":100,
         "onhold_balance":0,
         "bapAccountVersion": 1
   },
   {
      "trxId":"9fd07fff222467e5667be042e33ce18e804b3e065cca15de306f837e416d7c3e",
      "timeStamp":1629718288,
      "value":{
         "assetType":"oaccount",
         "account_id":"oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f",
         "user_id":"user1",
         "org_id":"Org1MSP",
         "token_id":"digiCurr101",
         "token_name":"digicur",
         "balance":0,
         "onhold_balance":0,
         "bapAccountVersion": 0
      }
   }
]
getAccountOnHoldBalance
このメソッドは、指定されたアカウントおよびトークンの現在の保留残高を返します。このメソッドは、Token AdminまたはToken Auditor、指定された組織のOrg AdminまたはOrg Auditor、またはアカウントのAccountOwnerのみがコールできます。
  @Validator(yup.string(), yup.string(), yup.string())
  public async getAccountOnHoldBalance(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.getAccountOnHoldBalance", "TOKEN", { account_id });
    return await this.Ctx.Account.getAccountOnHoldBalance(account_id);
  }
パラメータ:
  • token_id: string – トークンのID。
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、現在の保留残高のJSON表現。
戻り値の例:
{"msg":"Total Holding Balance is: 0","holding_balance":0}
getAllAccounts
このメソッドは、すべてのアカウントのリストを返します。このメソッドは、Token AdminまたはToken Auditorのみがコールできます。このメソッドでは、Berkeley DB SQLリッチ問合せが使用され、リモートOracle Blockchain Platformネットワークに接続されている場合にのみコールできます。
@Validator()
public async getAllAccounts() {
    await this.Ctx.Auth.checkAuthorization('ACCOUNT.getAllAccounts', 'TOKEN');
    return await this.Ctx.Account.getAllAccounts();
}
パラメータ:
  • なし
戻り値:
  • 成功の場合、すべてのアカウントのJSON配列。
getUserByAccountId
このメソッドは、指定されたアカウントのユーザー詳細(org_idおよびuser_id)を返します。このメソッドは、Token AdminまたはToken Auditor、または指定された組織のOrg AdminまたはOrg Auditorによってコールできます。
@Validator(yup.string())
public async getUserByAccountId(account_id: string) {
    return await this.Ctx.Account.getUserByAccountId(account_id);
}
パラメータ:
  • account_id: string – アカウントのID。
戻り値:
  • 成功の場合、ユーザー詳細(org_idtoken_idおよびuser_id)のJSONオブジェクト。
戻り値の例:
{
    "token_id": "digiCurr101",
    "user_id": "user1",
    "org_id": "Org1MSP"
}
getAccountBalance
このメソッドは、指定されたアカウントおよびトークンの現在の残高を返します。このメソッドは、Token AdminまたはToken Auditor、指定された組織のOrg AdminまたはOrg Auditor、またはアカウントのAccountOwnerのみがコールできます。
  @Validator(yup.string(), yup.string(), yup.string())
  public async getAccountBalance(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.getAccountBalance", "TOKEN", { account_id });
    return await this.Ctx.Account.getAccountBalance(account_id);
  }
パラメータ:
  • token_id: string – トークンのID。
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、現在のアカウントの残高のJSON表現。
戻り値の例:
{"msg":"Current Balance is: 0","user_balance":0}
getAllOrgAccounts
このメソッドは、指定された組織に属するすべてのトークン・アカウントのリストを返します。このメソッドは、Token AdminまたはToken Auditor、あるいは指定された組織のOrg AdminまたはOrg Auditorによってのみコールできます。
  @Validator(yup.string())
  public async getAllOrgAccounts(org_id: string) {
    await this.Ctx.Auth.checkAuthorization("ACCOUNT.getAllOrgAccounts", "TOKEN", { org_id });
    return await this.Ctx.Account.getAllOrgAccounts(org_id);
  }
パラメータ:
  • org_id: string – 組織のメンバーシップ・サービス・プロバイダ(MSP) ID。
戻り値:
  • 成功の場合、指定した組織のすべてのアカウントのリスト。
戻り値の例:
[
    {
        "key": "oaccount~2de8db6b91964f8c9009136831126d3cfa94e1d00c4285c1ea3e6d1f36479ed4",
        "valueJson": {
            "bapAccountVersion": 0,
            "assetType": "oaccount",
            "account_id": "oaccount~2de8db6b91964f8c9009136831126d3cfa94e1d00c4285c1ea3e6d1f36479ed4",
            "user_id": "idcqa",
            "org_id": "appdev",
            "token_type": "fungible",
            "token_id": "token",
            "token_name": "fiatmoneytok",
            "balance": 0,
            "onhold_balance": 0
        }
    },
    {
        "key": "oaccount~620fcf5deb5fd5a65c0b5b10fda129de0f629ccd232c5891c130e24a574df50a",
        "valueJson": {
            "bapAccountVersion": 0,
            "assetType": "oaccount",
            "account_id": "oaccount~620fcf5deb5fd5a65c0b5b10fda129de0f629ccd232c5891c130e24a574df50a",
            "user_id": "example_minter",
            "org_id": "appdev",
            "token_type": "fungible",
            "token_id": "token",
            "token_name": "fiatmoneytok",
            "balance": 0,
            "onhold_balance": 0
        }
    }
]

ロール管理のメソッド

addRole
このメソッドは、指定されたユーザーおよびトークンにロールを追加します。このメソッドは、チェーンコードのToken Adminまたは指定されたロールも保持する指定された組織のOrg Adminのみがコールできます。
  @Validator(yup.string(), yup.string(), yup.string(), yup.string())
  public async addRole(token_id: string, role: string, org_id: string, user_id: string) {
    const token_asset = await this.getTokenObject(token_id);
    const account_id = await this.Ctx.Account.generateAccountId(token_id, org_id, user_id);
    await this.Ctx.Auth.checkAuthorization("TOKEN.addRoleMember", "TOKEN", { token_id, org_id, role });
    return await this.Ctx.Token.addRoleMember(role, account_id, token_asset);
  }
パラメータ:
  • token_id: string – トークンのID。
  • role: string – 指定したユーザーに追加するロールの名前。mintableおよびburnableの動作は、仕様ファイルのminter_role_nameおよびburner_role_nameプロパティに対応します。同様に、notaryロールは、仕様ファイルのnotary_role_nameプロパティに対応します。
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、アカウント詳細を含むメッセージ。
戻り値の例:
{"msg":"Successfully added role 'minter' to Account Id: oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f (Org-Id: Org1MSP, User-Id: user1)"}
removeRole
このメソッドは、指定されたユーザーおよびトークンからロールを削除します。このメソッドは、チェーンコードのToken Adminまたは指定されたロールも保持する指定された組織のOrg Adminのみがコールできます。
  @Validator(yup.string(), yup.string(), yup.string(), yup.string())
  public async removeRole(token_id: string, role: string, org_id: string, user_id: string) {
    const token_asset = await this.getTokenObject(token_id);
    const account_id = await this.Ctx.Account.generateAccountId(token_id, org_id, user_id);
    await this.Ctx.Auth.checkAuthorization("TOKEN.removeRoleMember", "TOKEN", { token_id, org_id, role });
    return await this.Ctx.Token.removeRoleMember(role, account_id, token_asset);
  }
パラメータ:
  • token_id: string – トークンのID。
  • role: string – 指定したユーザーから削除するロールの名前。mintableおよびburnableの動作は、仕様ファイルのminter_role_nameおよびburner_role_nameプロパティに対応します。同様に、notaryロールは、仕様ファイルのnotary_role_nameプロパティに対応します。
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、アカウント詳細を含むメッセージ。
戻り値の例:
{"msg":"Successfully removed role 'minter' from Account Id: oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f (Org-Id: Org1MSP, User-Id: user1)"}
getAccountsByRole
このメソッドは、指定されたロールおよびトークンのすべてのアカウントIDのリストを返します。このメソッドは、チェーンコードのToken Adminのみがコールできます。
@Validator(yup.string(), yup.string())
public async getAccountsByRole(token_id: string, role: string) {
   await this.Ctx.Auth.checkAuthorization('ROLE.getAccountsByRole', 'TOKEN');
   return await this.Ctx.Role.getAccountsByRole(token_id, role);
}
パラメータ:
  • token_id: string – トークンのID。
  • role: string – 検索するロールの名前。
戻り値:
  • 成功の場合、アカウントIDのJSON配列。
戻り値の例:
{"accounts":["oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f"]}
getAccountsByUser
このメソッドは、指定された組織IDとユーザーIDのすべてのアカウントIDのリストを返します。このメソッドは、チェーンコードのToken Admin、指定された組織のOrg Admin、またはパラメータで指定されたAccount Ownerのみがコールできます。
  @Validator(yup.string(), yup.string())
  public async getAccountsByUser(org_id: string, user_id: string) {
    await this.Ctx.Auth.checkAuthorization("ACCOUNT.getAccountsByUser", "TOKEN", { org_id, user_id });
    return await this.Ctx.Account.getAccountsByUser(org_id, user_id);
  }
パラメータ:
  • org_id string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、アカウントIDのJSON配列。
戻り値の例:
{"accounts":["oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f"]}
getUsersByRole
このメソッドは、指定されたロールおよびトークンのすべてのユーザーのリストを返します。このメソッドは、チェーンコードのToken Adminのみがコールできます。
@Validator(yup.string(), yup.string())
public async getUsersByRole(token_id: string, role: string) {
    await this.Ctx.Auth.checkAuthorization('ROLE.getUsersByRole', 'TOKEN');
    return await this.Ctx.Role.getUsersByRole(token_id, role);
}
パラメータ:
  • token_id: string – トークンのID。
  • role: string – 検索するロールの名前。
戻り値:
  • 成功の場合、ユーザー・オブジェクトのJSON配列(org_idtoken_idおよびuser_id)。
戻り値の例:
{"users":[{"token_id":"digiCurr101","user_id":"user1","org_id":"Org1MSP"}]}
isInRole
このメソッドは、ユーザーとトークンに指定したロールがあるかどうかを示すブール値を返します。このメソッドは、チェーンコードのToken Admin、アカウントのAccountOwnerまたは指定した組織のOrg Adminのみがコールできます。
  @Validator(yup.string(), yup.string(), yup.string(), yup.string())
  public async isInRole(token_id: string, org_id: string, user_id: string, role: string) {
    const token_asset = await this.getTokenObject(token_id);
    const account_id = await this.Ctx.Account.generateAccountId(token_id, org_id, user_id);
    await this.Ctx.Auth.checkAuthorization("TOKEN.isInRole", "TOKEN", { account_id });
    return { result: await this.Ctx.Token.isInRole(role, account_id, token_asset) };
  }
パラメータ:
  • token_id: string – トークンのID。
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
  • role: string – 検索するロールの名前。
戻り値:
  • 成功の場合、ブール値の結果のJSON文字列。
戻り値の例:
{"result":"false"}
getOrgAccountsByRole
このメソッドは、指定された組織内の指定されたロールを持つすべてのアカウントに関する情報を返します。このメソッドは、チェーンコードのToken Adminまたは指定された組織のOrg Adminのみがコールできます。
   @Validator(yup.string(), yup.string(), yup.string())
  public async getOrgAccountsByRole(token_id: string, role: string, org_id: string) {
    await this.Ctx.Auth.checkAuthorization("ROLE.getOrgAccountsByRole", "TOKEN", { org_id });
    return await this.Ctx.Role.getOrgAccountsByRole(token_id, role, org_id);
  }
パラメータ:
  • token_id: string – トークンのID。
  • role: string – チェックするロールの名前。
  • org_id: string – 組織のメンバーシップ・サービス・プロバイダ(MSP) ID。
戻り値:
  • 成功の場合、指定した組織内の指定したロールを持つすべてのアカウントのリスト。
戻り値の例:
{
    "accounts": [
        "oaccount~abc74791148b761352b98df58035601b6f5480448ac2b4a3a7eb54bdbebf48eb",
        "oaccount~9c650574af9025a6106c8d12a801b079eda9ae2e3399fc2fbd5bd683d738a850"
    ]
}
getOrgUsersByRole
このメソッドは、指定された組織内の指定されたロールを持つすべてのユーザーに関する情報を返します。このメソッドは、チェーンコードのToken Adminまたは指定された組織のOrg Adminのみがコールできます。
  @Validator(yup.string(), yup.string(), yup.string())
  public async getOrgUsersByRole(token_id: string, role: string, org_id: string) {
    await this.Ctx.Auth.checkAuthorization("ROLE.getOrgUsersByRole", "TOKEN", { org_id });
    return await this.Ctx.Role.getOrgUsersByRole(token_id, role, org_id);
  }
パラメータ:
  • token_id: string – トークンのID。
  • role: string – チェックするロールの名前。
  • org_id: string – 組織のメンバーシップ・サービス・プロバイダ(MSP) ID。
戻り値:
  • 成功の場合、指定した組織内の指定したロールを持つすべてのユーザーのリスト。
戻り値の例:
{
    "users": [
        {
            "token_id": "token",
            "user_id": "admin",
            "org_id": "Org1MSP"
        },
        {
            "token_id": "token",
            "user_id": "orgAdmin",
            "org_id": "Org1MSP"
        }
    ]
}
addRole
このメソッドは、指定されたユーザーおよびトークンにロールを追加します。このメソッドは、チェーンコードのToken Adminまたは指定されたロールも保持する指定された組織のOrg Adminのみがコールできます。
  @Validator(yup.string(), yup.string(), yup.string(), yup.string())
  public async addRole(token_id: string, role: string, org_id: string, user_id: string) {
    const token_asset = await this.getTokenObject(token_id);
    const account_id = await this.Ctx.Account.generateAccountId(token_id, org_id, user_id);
    await this.Ctx.Auth.checkAuthorization("TOKEN.addRoleMember", "TOKEN", { token_id, org_id, role });
    return await this.Ctx.Token.addRoleMember(role, account_id, token_asset);
  }
パラメータ:
  • token_id: string – トークンのID。
  • role: string – 指定したユーザーに追加するロールの名前。mintableおよびburnableの動作は、仕様ファイルのminter_role_nameおよびburner_role_nameプロパティに対応します。同様に、notaryロールは、仕様ファイルのnotary_role_nameプロパティに対応します。
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、アカウント詳細を含むメッセージ。
戻り値の例:
{"msg":"Successfully added role 'minter' to Account Id: oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f (Org-Id: Org1MSP, User-Id: user1)"}
removeRole
このメソッドは、指定されたユーザーおよびトークンからロールを削除します。このメソッドは、チェーンコードのToken Adminまたは指定されたロールも保持する指定された組織のOrg Adminのみがコールできます。
  @Validator(yup.string(), yup.string(), yup.string(), yup.string())
  public async removeRole(token_id: string, role: string, org_id: string, user_id: string) {
    const token_asset = await this.getTokenObject(token_id);
    const account_id = await this.Ctx.Account.generateAccountId(token_id, org_id, user_id);
    await this.Ctx.Auth.checkAuthorization("TOKEN.removeRoleMember", "TOKEN", { token_id, org_id, role });
    return await this.Ctx.Token.removeRoleMember(role, account_id, token_asset);
  }
パラメータ:
  • token_id: string – トークンのID。
  • role: string – 指定したユーザーから削除するロールの名前。mintableおよびburnableの動作は、仕様ファイルのminter_role_nameおよびburner_role_nameプロパティに対応します。同様に、notaryロールは、仕様ファイルのnotary_role_nameプロパティに対応します。
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、アカウント詳細を含むメッセージ。
戻り値の例:
{"msg":"Successfully removed role 'minter' from Account Id: oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f (Org-Id: Org1MSP, User-Id: user1)"}
getAccountsByRole
このメソッドは、指定されたロールおよびトークンのすべてのアカウントIDのリストを返します。このメソッドは、Token AdminまたはToken Auditorのみがコールできます。
@Validator(yup.string(), yup.string())
public async getAccountsByRole(token_id: string, role: string) {
   await this.Ctx.Auth.checkAuthorization('ROLE.getAccountsByRole', 'TOKEN');
   return await this.Ctx.Role.getAccountsByRole(token_id, role);
}
パラメータ:
  • token_id: string – トークンのID。
  • role: string – 検索するロールの名前。
戻り値:
  • 成功の場合、アカウントIDのJSON配列。
戻り値の例:
{"accounts":["oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f"]}
getAccountsByUser
このメソッドは、指定された組織IDとユーザーIDのすべてのアカウントIDのリストを返します。このメソッドは、Token AdminまたはToken Auditor、指定した組織のOrg AdminまたはOrg Auditor、またはパラメータで指定されたAccount Ownerのみがコールできます。
  @Validator(yup.string(), yup.string())
  public async getAccountsByUser(org_id: string, user_id: string) {
    await this.Ctx.Auth.checkAuthorization("ACCOUNT.getAccountsByUser", "TOKEN", { org_id, user_id });
    return await this.Ctx.Account.getAccountsByUser(org_id, user_id);
  }
パラメータ:
  • org_id string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、アカウントIDのJSON配列。
戻り値の例:
{"accounts":["oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f"]}
getUsersByRole
このメソッドは、指定されたロールおよびトークンのすべてのユーザーのリストを返します。このメソッドは、Token AdminまたはToken Auditorのみがコールできます。
@Validator(yup.string(), yup.string())
public async getUsersByRole(token_id: string, role: string) {
    await this.Ctx.Auth.checkAuthorization('ROLE.getUsersByRole', 'TOKEN');
    return await this.Ctx.Role.getUsersByRole(token_id, role);
}
パラメータ:
  • token_id: string – トークンのID。
  • role: string – 検索するロールの名前。
戻り値:
  • 成功の場合、ユーザー・オブジェクトのJSON配列(org_idtoken_idおよびuser_id)。
戻り値の例:
{"users":[{"token_id":"digiCurr101","user_id":"user1","org_id":"Org1MSP"}]}
isInRole
このメソッドは、ユーザーとトークンに指定したロールがあるかどうかを示すブール値を返します。このメソッドは、Token AdminまたはToken Auditor、アカウントのAccountOwner、または指定された組織のOrg AdminまたはOrg Auditorのみがコールできます。
  @Validator(yup.string(), yup.string(), yup.string(), yup.string())
  public async isInRole(token_id: string, org_id: string, user_id: string, role: string) {
    const token_asset = await this.getTokenObject(token_id);
    const account_id = await this.Ctx.Account.generateAccountId(token_id, org_id, user_id);
    await this.Ctx.Auth.checkAuthorization("TOKEN.isInRole", "TOKEN", { account_id });
    return { result: await this.Ctx.Token.isInRole(role, account_id, token_asset) };
  }
パラメータ:
  • token_id: string – トークンのID。
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
  • role: string – 検索するロールの名前。
戻り値:
  • 成功の場合、ブール値の結果のJSON文字列。
戻り値の例:
{"result":"false"}
getOrgAccountsByRole
このメソッドは、指定された組織内の指定されたロールを持つすべてのアカウントに関する情報を返します。このメソッドは、Token AdminToken AuditorOrg AdminまたはOrg Auditorのみがコールできます。
   @Validator(yup.string(), yup.string(), yup.string())
  public async getOrgAccountsByRole(token_id: string, role: string, org_id: string) {
    await this.Ctx.Auth.checkAuthorization("ROLE.getOrgAccountsByRole", "TOKEN", { org_id });
    return await this.Ctx.Role.getOrgAccountsByRole(token_id, role, org_id);
  }
パラメータ:
  • token_id: string – トークンのID。
  • role: string – チェックするロールの名前。
  • org_id: string – 組織のメンバーシップ・サービス・プロバイダ(MSP) ID。
戻り値:
  • 成功の場合、指定した組織内の指定したロールを持つすべてのアカウントのリスト。
戻り値の例:
{
    "accounts": [
        "oaccount~abc74791148b761352b98df58035601b6f5480448ac2b4a3a7eb54bdbebf48eb",
        "oaccount~9c650574af9025a6106c8d12a801b079eda9ae2e3399fc2fbd5bd683d738a850"
    ]
}
getOrgUsersByRole
このメソッドは、指定された組織内の指定されたロールを持つすべてのユーザーに関する情報を返します。このメソッドは、指定された組織のOrg AdminまたはOrg Auditorによって、Token AdminまたはToken Auditorのみがコールできます。
  @Validator(yup.string(), yup.string(), yup.string())
  public async getOrgUsersByRole(token_id: string, role: string, org_id: string) {
    await this.Ctx.Auth.checkAuthorization("ROLE.getOrgUsersByRole", "TOKEN", { org_id });
    return await this.Ctx.Role.getOrgUsersByRole(token_id, role, org_id);
  }
パラメータ:
  • token_id: string – トークンのID。
  • role: string – チェックするロールの名前。
  • org_id: string – 組織のメンバーシップ・サービス・プロバイダ(MSP) ID。
戻り値:
  • 成功の場合、指定した組織内の指定したロールを持つすべてのユーザーのリスト。
戻り値の例:
{
    "users": [
        {
            "token_id": "token",
            "user_id": "admin",
            "org_id": "Org1MSP"
        },
        {
            "token_id": "token",
            "user_id": "orgAdmin",
            "org_id": "Org1MSP"
        }
    ]
}

トランザクション履歴管理のメソッド

getAccountTransactionHistory
このメソッドは、指定されたユーザーおよびトークンのアカウント・トランザクション履歴詳細の配列を返します。このメソッドは、チェーンコードのToken Admin、指定された組織のOrg AdminまたはアカウントのAccountOwnerのみがコールできます。
 @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。
戻り値:
  • 成功の場合、次のプロパティを含むJSONアカウント・トランザクション・オブジェクトの配列:
  • transaction_id – トランザクションのID。
  • transacted_account – トランザクションが発生したアカウント。
  • transaction_type – トランザクションのタイプ。
  • transacted_amount – トランザクションの金額。
  • timestamp – トランザクションの時間。
  • balance – トランザクション時のアカウント残高。
  • onhold_balance – トランザクション時の保留残高。
  • token_id – トークンのID。
  • holding_idholdTokensメソッドによって返される一意の識別子。
戻り値の例:
[
    {
        "transaction_id": "otransaction~68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775",
        "transacted_amount": 20,
        "timestamp": "2021-08-17T06:04:24.000Z",
        "balance": 930,
        "onhold_balance": 0,
        "token_id": "digiCurr101",
        "transaction_type": "BULKTRANSFER",
        "sub_transactions": [
            {
                "transacted_account": "oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f",
                "transaction_type": "DEBIT",
                "transaction_id": "otransaction~68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775~c4ca4238a0b923820dcc509a6f75849b",
                "transacted_amount": 10
            },
            {
                "transacted_account": "oaccount~digicur~38848e87296d67c8a90918f78cf55f9c9baab2cdc8c928535471aaa1210c706e",
                "transaction_type": "DEBIT",
                "transaction_id": "otransaction~68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775~c81e728d9d4c2f636f067f89cc14862c",
                "transacted_amount": 10
            }
        ]
    },
    {
        "transaction_id": "otransaction~757864d5369bd0539d044caeb3bb4898db310fd7aa740f45a9938771903d43da",
        "transacted_amount": 50,
        "timestamp": "2021-08-17T06:02:44.000Z",
        "balance": 950,
        "onhold_balance": 0,
        "token_id": "digiCurr101",
        "transacted_account": "oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f",
        "transaction_type": "DEBIT"
    }
]
getAccountTransactionHistoryWithFilters
このメソッドは、指定されたユーザーおよびトークンのアカウント・トランザクション履歴詳細の配列を返します。このメソッドは、チェーンコードのToken Admin、指定された組織のOrg AdminまたはアカウントのAccountOwnerのみがコールできます。このメソッドは、リモートOracle Blockchain Platformネットワークに接続されている場合にのみコールできます。
  @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形式で指定する必要があります。
次に例を示します:

ochain invoke GetAccountTransactionHistoryWithFilters 'token1' 'appbuilder12' 'user_minter' '{"PageSize":10,"Bookmark":"1","StartTime":"2022-01-25T17:41:42Z","EndTime":"2022-01-25T17:59:10Z"}'

[
  {
    "transaction_id": "otransaction~672897b5a4fa78b421c000e4d6d4f71f3d46529bfbb5b4be10bf5471dc35ce89",
    "transacted_amount": 5,
    "timestamp": "2022-04-20T15:46:04.000Z",
    "token_id": "tokenId",
    "transacted_account": "oaccount~16c38d804413ebabf416360d374f76c973d4e71c74adfde73cc40c7c274883b8",
    "transaction_type": "DEBIT",
    "balance": 90,
    "onhold_balance": 0
  },
  {
    "transaction_id": "otransaction~467bb67a33aaffca4487f33dcd46c9844efdb5421a2e7b6aa2d53152eb2c6d85",
    "transacted_amount": 5,
    "timestamp": "2022-04-20T15:45:47.000Z",
    "token_id": "tokenId",
    "transacted_account": "oaccount~fbf95683b21bbc91a22205819ac1e2e9c90355d536821ed3fe22b7d23915c248",
    "transaction_type": "DEBIT",
    "balance": 95,
    "onhold_balance": 0
  },
  {
    "transaction_id": "otransaction~c6d56ce54a9bbe24597d1d10448e39316dc6f16328bf3c5b0c8ef10e1dfeb397",
    "transacted_amount": 100,
    "timestamp": "2022-04-20T15:44:26.000Z",
    "token_id": "tokenId",
    "transacted_account": "oaccount~deb5fb0906c40506f6c2d00c573b774e01a53dd91499e651d92ac4778b6add6a",
    "transaction_type": "MINT",
    "balance": 100,
    "onhold_balance": 0
  }
]
getSubTransactionsById
このメソッドは、指定されたユーザーおよびトークンのアカウント・トランザクション履歴詳細の配列を返します。このメソッドは、チェーンコードのToken AdminまたはアカウントのAccountOwnerのみがコールできます。
  @Validator(yup.string())
  public async getSubTransactionsById(transaction_id: string) {
    await this.Ctx.Auth.checkAuthorization("ACCOUNT.getSubTransactionsById", "TOKEN", { transaction_id });
    return await this.Ctx.Account.getSubTransactionsById(transaction_id);
  }
パラメータ:
  • transaction_id: string – 一括転送トランザクションのID。
戻り値:
  • 指定された一括転送トランザクションIDのJSON形式のアカウント・サブトランザクション・オブジェクトの配列。
次に例を示します:

ochain invoke GetAccountSubTransactionHistory 'otransaction~21972b4d206bd52ea77924efb259c67217edb23b4386580d1bee696f6f864b9b'

[
    {
        "transacted_account": "oaccount~16c38d804413ebabf416360d374f76c973d4e71c74adfde73cc40c7c274883b8",
        "transaction_type": "DEBIT",
        "transaction_id": "otransaction~6e0f8fe4a6430322170b9c619b04b6c9f1c8d257923f611b866bdf69d7fe6cb8~c81e728d9d4c2f636f067f89cc14862c",
        "transacted_amount": 5,
        "timestamp": "2022-04-20T15:52:21.000Z",
        "token_id": "token1",
        "balance": 80,
        "onhold_balance": 0
    },
    {
        "transacted_account": "oaccount~fbf95683b21bbc91a22205819ac1e2e9c90355d536821ed3fe22b7d23915c248",
        "transaction_type": "DEBIT",
        "transaction_id": "otransaction~6e0f8fe4a6430322170b9c619b04b6c9f1c8d257923f611b866bdf69d7fe6cb8~c4ca4238a0b923820dcc509a6f75849b",
        "transacted_amount": 5,
        "timestamp": "2022-04-20T15:52:21.000Z",
        "token_id": "token1",
        "balance": 85,
        "onhold_balance": 0
    }
]
getSubTransactionsByIdWithFilters
このメソッドは、指定されたトランザクションのアカウント・サブトランザクション履歴詳細の配列を返します。
  @Validator(yup.string(), yup.object().nullable())
  public async getSubTransactionsByIdWithFilters(transaction_id: string, filters?: SubTransactionFilters) {
    await this.Ctx.Auth.checkAuthorization("ACCOUNT.getSubTransactionsByIdWithFilters", "TOKEN", { transaction_id });
    return await this.Ctx.Account.getSubTransactionsByIdWithFilters(transaction_id, filters);
  } 
パラメータ:
  • transaction_id: string – トランザクションのID。
  • filters: string – オプション・パラメータ。空の場合は、すべてのレコードが返されます。PageSizeプロパティは、返すレコード数を決定します。PageSizeが0の場合、デフォルトのページ・サイズは20です。Bookmarkプロパティは、返されるレコードの開始索引を決定します。詳細は、Hyperledger Fabricのドキュメントを参照してください。StartTimeおよびEndTimeプロパティは、RFC-3339形式で指定する必要があります。
戻り値:
  • 指定された一括転送トランザクションIDのJSON形式のアカウント・サブトランザクション・オブジェクトの配列。
次に例を示します:

ochain invoke GetAccountSubTransactionHistoryWithFilters 'otransaction~21972b4d206bd52ea77924efb259c67217edb23b4386580d1bee696f6f864b9b' '{"PageSize":10,"Bookmark":"1"}'

[
  {
    "transaction_id": "otransaction~6e0f8fe4a6430322170b9c619b04b6c9f1c8d257923f611b866bdf69d7fe6cb8~c81e728d9d4c2f636f067f89cc14862c",
    "transacted_amount": 5,
    "timestamp": "2022-04-20T15:52:21.000Z",
    "token_id": "tokenId",
    "transacted_account": "oaccount~16c38d804413ebabf416360d374f76c973d4e71c74adfde73cc40c7c274883b8",
    "transaction_type": "DEBIT",
    "balance": 80,
    "onhold_balance": 0
  },
  {
    "transaction_id": "otransaction~6e0f8fe4a6430322170b9c619b04b6c9f1c8d257923f611b866bdf69d7fe6cb8~c4ca4238a0b923820dcc509a6f75849b",
    "transacted_amount": 5,
    "timestamp": "2022-04-20T15:52:21.000Z",
    "token_id": "tokenId",
    "transacted_account": "oaccount~fbf95683b21bbc91a22205819ac1e2e9c90355d536821ed3fe22b7d23915c248",
    "transaction_type": "DEBIT",
    "balance": 85,
    "onhold_balance": 0
  }
]
getTransactionById
このメソッドは、Transactionアセットの履歴を返します。
@Validator(yup.string())
    public async getTransactionById(transaction_id: string) {
        return await this.Ctx.Transaction.getTransactionById(transaction_id);
    }
パラメータ:
  • transaction_id string– トランザクション・アセットのID。
戻り値:
  • 成功の場合、トランザクションの履歴のJSON配列。
戻り値の例:
{
    "transaction_id": "otransaction~68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775",
    "history": [
        {
            "trxId": "68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775",
            "timeStamp": 1629180264,
            "value": {
                "assetType": "otransaction",
                "transaction_id": "otransaction~68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775",
                "token_id": "digiCurr101",
                "from_account_id": "oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df",
                "to_account_id": "",
                "transaction_type": "BULKTRANSFER",
                "amount": 20,
                "timestamp": "2021-08-17T06:04:24.000Z",
                "number_of_sub_transactions": 2,
                "holding_id": ""
            }
        }
    ],
    "sub_transactions": [
        {
            "transaction_id": "otransaction~68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775~c4ca4238a0b923820dcc509a6f75849b",
            "history": [
                {
                    "trxId": "68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775",
                    "timeStamp": 1629180264,
                    "value": {
                        "assetType": "otransaction",
                        "transaction_id": "otransaction~68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775~c4ca4238a0b923820dcc509a6f75849b",
                        "token_id": "digiCurr101",
                        "from_account_id": "oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df",
                        "to_account_id": "oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f",
                        "transaction_type": "TRANSFER",
                        "amount": 10,
                        "timestamp": "2021-08-17T06:04:24.000Z",
                        "number_of_sub_transactions": 0,
                        "holding_id": ""
                    }
                }
            ]
        },
        {
            "transaction_id": "otransaction~68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775~c81e728d9d4c2f636f067f89cc14862c",
            "history": [
                {
                    "trxId": "68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775",
                    "timeStamp": 1629180264,
                    "value": {
                        "assetType": "otransaction",
                        "transaction_id": "otransaction~68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775~c81e728d9d4c2f636f067f89cc14862c",
                        "token_id": "digiCurr101",
                        "from_account_id": "oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df",
                        "to_account_id": "oaccount~digicur~38848e87296d67c8a90918f78cf55f9c9baab2cdc8c928535471aaa1210c706e",
                        "transaction_type": "TRANSFER",
                        "amount": 10,
                        "timestamp": "2021-08-17T06:04:24.000Z",
                        "number_of_sub_transactions": 0,
                        "holding_id": ""
                    }
                }
            ]
        }
    ]
}
deleteHistoricalTransactions
このメソッドは、状態データベースから古いトランザクションを削除します。
@Validator(yup.date())
    public async deleteHistoricalTransactions(time_to_expiration: Date) {
        await this.Ctx.Auth.checkAuthorization('TRANSACTION.deleteTransactions', 'TOKEN');
        return await this.Ctx.Transaction.deleteTransactions(time_to_expiration);
    }
パラメータ:
  • time_to_expiration Date – トランザクションを削除するタイミングを示すタイムスタンプ。指定した時間より古いトランザクション・アセットが削除されます。
戻り値の例:
"payload": {
    "msg": "Successfuly deleted transaction older than date: Thu Aug 19 2021 11:19:36 GMT+0000 (Coordinated Universal Time).",
    "transactions": [
        "otransaction~ec3366dd48b4ce2838f820f2f138648e6e55a07226713e59b411ff31b0d21058"
    ]
}
getAccountTransactionHistoryWithFiltersFromRichHistDB
リッチ履歴データベースにデータを同期し、チェーンコードAPIコールを使用してデータをフェッチできます。このメソッドは、リッチ履歴データベースからトランザクション履歴をフェッチします。この方法を使用する前に、Oracle Blockchain Platform Digital Assets EditionOracle Database View Definitions for Wholesale CBDCの説明に従って、Oracle REST Data Services (ORDS)およびOAuthを有効にしてOracle Autonomous Databaseを実行する必要があります。
@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 – ミントするトークンの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形式で指定する必要があります。
getAccountTransactionHistory
このメソッドは、指定されたユーザーおよびトークンのアカウント・トランザクション履歴詳細の配列を返します。このメソッドは、Token AdminまたはToken Auditor、指定された組織のOrg AdminまたはOrg Auditor、またはアカウントのAccountOwnerのみがコールできます。
@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
このメソッドは、指定されたユーザーおよびトークンのアカウント・トランザクション履歴詳細のフィルタされた配列を返します。このメソッドは、Token AdminまたはToken Auditor、指定された組織のOrg AdminまたはOrg Auditor、またはアカウントのAccountOwnerのみがコールできます。
@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"
            }
 ]
getSubTransactionsById
このメソッドは、指定されたユーザーおよびトークンのアカウント・トランザクション履歴詳細の配列を返します。このメソッドは、トランザクションをコールしたToken AdminToken AuditorまたはAccountOwnerによってのみコールできます。
  @Validator(yup.string())
  public async getSubTransactionsById(transaction_id: string) {
    await this.Ctx.Auth.checkAuthorization("ACCOUNT.getSubTransactionsById", "TOKEN", { transaction_id });
    return await this.Ctx.Account.getSubTransactionsById(transaction_id);
  }
パラメータ:
  • transaction_id: string – 一括転送トランザクションのID。
戻り値:
  • 指定された一括転送トランザクションIDのJSON形式のアカウント・サブトランザクション・オブジェクトの配列。
次に例を示します:

ochain invoke GetAccountSubTransactionHistory 'otransaction~21972b4d206bd52ea77924efb259c67217edb23b4386580d1bee696f6f864b9b'

[
    {
        "transacted_account": "oaccount~16c38d804413ebabf416360d374f76c973d4e71c74adfde73cc40c7c274883b8",
        "transaction_type": "DEBIT",
        "transaction_id": "otransaction~6e0f8fe4a6430322170b9c619b04b6c9f1c8d257923f611b866bdf69d7fe6cb8~c81e728d9d4c2f636f067f89cc14862c",
        "transacted_amount": 5,
        "timestamp": "2022-04-20T15:52:21.000Z",
        "token_id": "token1",
        "balance": 80,
        "onhold_balance": 0
    },
    {
        "transacted_account": "oaccount~fbf95683b21bbc91a22205819ac1e2e9c90355d536821ed3fe22b7d23915c248",
        "transaction_type": "DEBIT",
        "transaction_id": "otransaction~6e0f8fe4a6430322170b9c619b04b6c9f1c8d257923f611b866bdf69d7fe6cb8~c4ca4238a0b923820dcc509a6f75849b",
        "transacted_amount": 5,
        "timestamp": "2022-04-20T15:52:21.000Z",
        "token_id": "token1",
        "balance": 85,
        "onhold_balance": 0
    }
]
getSubTransactionsByIdWithFilters
このメソッドは、指定されたトランザクションのアカウント・サブトランザクション履歴詳細の配列を返します。
  @Validator(yup.string(), yup.object().nullable())
  public async getSubTransactionsByIdWithFilters(transaction_id: string, filters?: SubTransactionFilters) {
    await this.Ctx.Auth.checkAuthorization("ACCOUNT.getSubTransactionsByIdWithFilters", "TOKEN", { transaction_id });
    return await this.Ctx.Account.getSubTransactionsByIdWithFilters(transaction_id, filters);
  } 
パラメータ:
  • transaction_id: string – トランザクションのID。
  • filters: string – オプション・パラメータ。空の場合は、すべてのレコードが返されます。PageSizeプロパティは、返すレコード数を決定します。PageSizeが0の場合、デフォルトのページ・サイズは20です。Bookmarkプロパティは、返されるレコードの開始索引を決定します。詳細は、Hyperledger Fabricのドキュメントを参照してください。StartTimeおよびEndTimeプロパティは、RFC-3339形式で指定する必要があります。
戻り値:
  • 指定された一括転送トランザクションIDのJSON形式のアカウント・サブトランザクション・オブジェクトの配列。
次に例を示します:

ochain invoke GetAccountSubTransactionHistoryWithFilters 'otransaction~21972b4d206bd52ea77924efb259c67217edb23b4386580d1bee696f6f864b9b' '{"PageSize":10,"Bookmark":"1"}'

[
  {
    "transaction_id": "otransaction~6e0f8fe4a6430322170b9c619b04b6c9f1c8d257923f611b866bdf69d7fe6cb8~c81e728d9d4c2f636f067f89cc14862c",
    "transacted_amount": 5,
    "timestamp": "2022-04-20T15:52:21.000Z",
    "token_id": "tokenId",
    "transacted_account": "oaccount~16c38d804413ebabf416360d374f76c973d4e71c74adfde73cc40c7c274883b8",
    "transaction_type": "DEBIT",
    "balance": 80,
    "onhold_balance": 0
  },
  {
    "transaction_id": "otransaction~6e0f8fe4a6430322170b9c619b04b6c9f1c8d257923f611b866bdf69d7fe6cb8~c4ca4238a0b923820dcc509a6f75849b",
    "transacted_amount": 5,
    "timestamp": "2022-04-20T15:52:21.000Z",
    "token_id": "tokenId",
    "transacted_account": "oaccount~fbf95683b21bbc91a22205819ac1e2e9c90355d536821ed3fe22b7d23915c248",
    "transaction_type": "DEBIT",
    "balance": 85,
    "onhold_balance": 0
  }
]
getTransactionById
このメソッドは、Transactionアセットの履歴を返します。このメソッドは、Token AdminまたはToken Auditor、指定された組織のOrg AdminまたはOrg Auditor、またはトランザクション参加者(送信者、受信者または公証人)によってのみコールできます。
@Validator(yup.string())
    public async getTransactionById(transaction_id: string) {
        return await this.Ctx.Transaction.getTransactionById(transaction_id);
    }
パラメータ:
  • transaction_id string– トランザクション・アセットのID。
戻り値:
  • 成功の場合、トランザクションの履歴のJSON配列。
戻り値の例:
{
    "transaction_id": "otransaction~68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775",
    "history": [
        {
            "trxId": "68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775",
            "timeStamp": 1629180264,
            "value": {
                "assetType": "otransaction",
                "transaction_id": "otransaction~68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775",
                "token_id": "digiCurr101",
                "from_account_id": "oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df",
                "to_account_id": "",
                "transaction_type": "BULKTRANSFER",
                "amount": 20,
                "timestamp": "2021-08-17T06:04:24.000Z",
                "number_of_sub_transactions": 2,
                "holding_id": ""
            }
        }
    ],
    "sub_transactions": [
        {
            "transaction_id": "otransaction~68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775~c4ca4238a0b923820dcc509a6f75849b",
            "history": [
                {
                    "trxId": "68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775",
                    "timeStamp": 1629180264,
                    "value": {
                        "assetType": "otransaction",
                        "transaction_id": "otransaction~68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775~c4ca4238a0b923820dcc509a6f75849b",
                        "token_id": "digiCurr101",
                        "from_account_id": "oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df",
                        "to_account_id": "oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f",
                        "transaction_type": "TRANSFER",
                        "amount": 10,
                        "timestamp": "2021-08-17T06:04:24.000Z",
                        "number_of_sub_transactions": 0,
                        "holding_id": ""
                    }
                }
            ]
        },
        {
            "transaction_id": "otransaction~68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775~c81e728d9d4c2f636f067f89cc14862c",
            "history": [
                {
                    "trxId": "68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775",
                    "timeStamp": 1629180264,
                    "value": {
                        "assetType": "otransaction",
                        "transaction_id": "otransaction~68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775~c81e728d9d4c2f636f067f89cc14862c",
                        "token_id": "digiCurr101",
                        "from_account_id": "oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df",
                        "to_account_id": "oaccount~digicur~38848e87296d67c8a90918f78cf55f9c9baab2cdc8c928535471aaa1210c706e",
                        "transaction_type": "TRANSFER",
                        "amount": 10,
                        "timestamp": "2021-08-17T06:04:24.000Z",
                        "number_of_sub_transactions": 0,
                        "holding_id": ""
                    }
                }
            ]
        }
    ]
}
deleteHistoricalTransactions
このメソッドは、状態データベースから古いトランザクションを削除します。
@Validator(yup.date())
    public async deleteHistoricalTransactions(time_to_expiration: Date) {
        await this.Ctx.Auth.checkAuthorization('TRANSACTION.deleteTransactions', 'TOKEN');
        return await this.Ctx.Transaction.deleteTransactions(time_to_expiration);
    }
パラメータ:
  • time_to_expiration Date – トランザクションを削除するタイミングを示すタイムスタンプ。指定した時間より古いトランザクション・アセットが削除されます。
戻り値の例:
"payload": {
    "msg": "Successfuly deleted transaction older than date: Thu Aug 19 2021 11:19:36 GMT+0000 (Coordinated Universal Time).",
    "transactions": [
        "otransaction~ec3366dd48b4ce2838f820f2f138648e6e55a07226713e59b411ff31b0d21058"
    ]
}

トークン動作管理のメソッド- ミント可能動作

issueTokens
このメソッドはトークンをミントし、その後、メソッドのコール元がそれらのトークンを所有します。コール元には、アカウントとミンターのロールが必要です。ミント可能なトークンの数は、仕様ファイルのmintable動作のmax_mint_quantityプロパティによって制限されます。max_mint_quantityプロパティを指定しない場合、無制限の数のトークンをミントできます。数量は、仕様ファイルのdivisible動作のdecimalパラメータで指定された10進数値内にする必要があります。このメソッドは、ミンター・ロールを持つアカウントのAccountOwnerのみがコールできます。
@Validator(yup.string(), yup.number().positive())
public async issueTokens(token_id: string, quantity: number) {
    const token_asset = await this.getTokenObject(token_id);
    return await this.Ctx.Token.mint(quantity, token_asset);
}
パラメータ:
  • token_id: string – トークンのID。
  • quantity – ミントするトークンの数。
戻り値:
  • 成功の場合、アカウント詳細を含むメッセージ。
戻り値の例:
{
    "msg": "Successfully minted 1000 tokens to Account Id: \
oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df (Org-Id: Org1MSP, User-Id: user1)  ",
}
getTotalMintedTokens
このメソッドは、指定されたトークンのミントされたトークンの合計数を返します。このメソッドは、チェーンコードのToken AdminまたはOrg Adminのみがコールできます。
@Validator(yup.string())
 public async getTotalMintedTokens(token_id: string) {
     const token_asset = await this.getTokenObject(token_id);
     await this.Ctx.Auth.checkAuthorization('TOKEN.getTotalMintedTokens', 'TOKEN');
     const totalMintedTokens = await this.Ctx.Token.getTotalMintedTokens(token_asset);
     return {
         msg: `Total minted token for Token Id: ${token_id} is ${totalMintedTokens} tokens.`,
         quantity: totalMintedTokens
     };
 }
パラメータ:
  • token_id: string – トークンのID。
戻り値:
  • 成功の場合、トークンの合計数を示すJSON文字列。
戻り値の例:
{"msg":"Total minted token for Token Id: digiCurr101 is 100 tokens.","quantity":100}
getNetTokens
このメソッドは、指定されたトークンに対してシステムで使用可能なトークンの合計正味数を返します。正味トークン合計は、トークンのバーン後に残っているトークンの量です。等式では、正味トークン = ミントされたトークンの合計 - バーンされたトークンの合計です。トークンがバーンされていない場合、正味トークン数は、ミントされたトークンの合計と等しくなります。このメソッドは、チェーンコードのToken AdminまたはOrg Adminのみがコールできます。
@Validator(yup.string())
public async getNetTokens(token_id: string) {
	const token_asset = await this.getTokenObject(token_id);
	await this.Ctx.Auth.checkAuthorization('TOKEN.getNetTokens', 'TOKEN');
	const netTokens = await this.Ctx.Token.getNetTokens(token_asset);
	return {
		msg: `Net supply of token for Token Id: ${token_id} is ${netTokens} tokens.`,
		quantity: netTokens
	};
}
パラメータ:
  • token_id: string – トークンのID。
戻り値:
  • 成功の場合、トークンの正味数を示すJSON文字列。
戻り値の例:
{"msg":"Net supply of token for Token Id: digiCurr101 is 0 tokens.","quantity":0}
requestMint
このメソッドは、指定された量のトークンを作成するために、ミニター公証書にリクエストを送信するためにミニターから呼び出すことができます。
@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 – ミントするトークンの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)を指定するオブジェクト。

    Visual Studio CodeとCLIまたはPostmanコレクションを使用している場合は、info_detailsパラメータを別の形式で指定します。

    Visual Studioコード: { "category": "category value", "description": "description value" }

    CLI /ポストマン: "{\"category\":\"category value\",\"description\":\"description value\"}"

戻り値の例:
{
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 – ミントするトークンのID。
  • operation_id: string– ミント・リクエストを表す一意の操作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 – ミントするトークンのID。
  • operation_id: string– ミント・リクエストを表す一意の操作ID。
戻り値の例:
{
 msg: "Successfully rejected mint request with Operation Id 'operation1' to mint 100 tokens of token id token"
}
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 – ミントするトークンの数。
  • info_details: JSON– リクエストのカテゴリ(category)および説明(description)を指定するオブジェクト。

    Visual Studio CodeとCLIまたはPostmanコレクションを使用している場合は、info_detailsパラメータを別の形式で指定します。

    Visual Studioコード: { "category": "category value", "description": "description value" }

    CLI /ポストマン: "{\"category\":\"category value\",\"description\":\"description value\"}"

戻り値の例:
{
msg:
"Successfully minted 100 tokens to Account Id: oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (Org-Id: Org1MSP, User-Id: admin)"
}
getTotalMintedTokens
このメソッドは、指定されたトークンのミントされたトークンの合計数を返します。このメソッドは、Token AdminToken AuditorOrg AdminまたはOrg Auditorのみがコールできます。
@Validator(yup.string())
 public async getTotalMintedTokens(token_id: string) {
     const token_asset = await this.getTokenObject(token_id);
     await this.Ctx.Auth.checkAuthorization('TOKEN.getTotalMintedTokens', 'TOKEN');
     const totalMintedTokens = await this.Ctx.Token.getTotalMintedTokens(token_asset);
     return {
         msg: `Total minted token for Token Id: ${token_id} is ${totalMintedTokens} tokens.`,
         quantity: totalMintedTokens
     };
 }
パラメータ:
  • token_id: string – トークンのID。
戻り値:
  • 成功の場合、トークンの合計数を示すJSON文字列。
戻り値の例:
{"msg":"Total minted token for Token Id: digiCurr101 is 100 tokens.","quantity":100}
getNetTokens
このメソッドは、指定されたトークンに対してシステムで使用可能なトークンの合計正味数を返します。正味トークン合計は、トークンのバーン後に残っているトークンの量です。等式では、正味トークン = ミントされたトークンの合計 - バーンされたトークンの合計です。トークンがバーンされていない場合、正味トークン数は、ミントされたトークンの合計と等しくなります。このメソッドは、Token AdminToken AuditorOrg AdminまたはOrg Auditorのみがコールできます。
@Validator(yup.string())
public async getNetTokens(token_id: string) {
	const token_asset = await this.getTokenObject(token_id);
	await this.Ctx.Auth.checkAuthorization('TOKEN.getNetTokens', 'TOKEN');
	const netTokens = await this.Ctx.Token.getNetTokens(token_asset);
	return {
		msg: `Net supply of token for Token Id: ${token_id} is ${netTokens} tokens.`,
		quantity: netTokens
	};
}
パラメータ:
  • token_id: string – トークンのID。
戻り値:
  • 成功の場合、トークンの正味数を示すJSON文字列。
戻り値の例:
{"msg":"Net supply of token for Token Id: digiCurr101 is 0 tokens.","quantity":0}

トークン動作管理のメソッド- 転送可能動作

transferTokens
このメソッドは、トークンをコール元から指定されたアカウントに転送します。メソッドのコール元にはアカウントが必要です。数量は、仕様ファイルのdivisible動作のdecimalパラメータで指定された10進数値内にする必要があります。このメソッドは、アカウントのAccountOwnerのみがコールできます。
@Validator(yup.string(), yup.string(), yup.string(), yup.number().positive())
public async transferTokens(token_id: string, to_org_id: string, to_user_id: string, quantity: number) {
   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);
}
パラメータ:
  • token_id: string – トークンのID。
  • to_org_id: string – 現在の組織内の受信者(受取人)のメンバーシップ・サービス・プロバイダ(MSP) ID。
  • to_user_id: string – 受信者のユーザー名または電子メールID。
  • quantity: number – 転送するトークンの数。
戻り値:
  • 成功の場合、支払者および受取人アカウントの両方の詳細を含むメッセージ。
戻り値の例:
{
    "msg": "Successfully transferred 400 tokens from account id: oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df (Org-Id: Org1MSP, User-Id: user1) to account id: oaccount~digicur~682bb71de419602af74e3f226345ef308445ca51010737900c112435f676152df (Org-Id: Org1MSP, User-Id: user2) ",
}
bulkTransferTokens
このメソッドは、トークンを呼出し元アカウントからflowオブジェクトで指定されたアカウントに一括で転送します。The quantities must be within the decimal values specified by the decimal parameter of the divisible behavior in the specification file.The caller of this method must have an account already created.このメソッドは、アカウントのAccountOwnerのみがコールできます。
@Validator(yup.string(), yup.array().of(yup.object()))
public async bulkTransferTokens(token_id: string, flow: object[]) {
     const token_asset = await this.getTokenObject(token_id);
     return await this.Ctx.Token.bulkTransfer(flow, token_asset);
}
パラメータ:
  • token_id: string – トークンのID。
  • flow : object[] – 受信者と数量を指定するJSONオブジェクトの配列。
    • to_orgId: string – 現在の組織内の受信者のメンバーシップ・サービス・プロバイダ(MSP) ID。
    • userId: string – 受信者のユーザー名または電子メールID。
    • quantity: number – 転送するトークンの数。
    Visual Studio CodeとCLIまたはPostmanコレクションを使用している場合は、flowパラメータを別の形式で指定します。
    Visual Studio Code:
    [
      { "to_org_id": "Org1MSP", "to_user_id": "user1", "quantity": 10 },
      { "to_org_id": "Org1MSP", "to_user_id": "user2", "quantity": 10 }
    ]
    
    CLI/Postman:
    "[{ \"to_org_id\": \"Org1MSP\", \"to_user_id\": \"user1\", \"quantity\": 10 }, { \"to_org_id\": \"Org1MSP\", \"to_user_id\": \"user2\", \"quantity\": 10 }]"
戻り値:
  • 成功を示すメッセージ。
戻り値の例:
{
    "msg": "Successfully transferred 20 tokens from Account Id           'oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df' (Org-Id: Org1MSP, User-Id: admin).",
    "from_account_id": "oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df",
    "sub_transactions": [
        {
            "to_account_id": "oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f",
            "amount": 10
        },
        {
            "to_account_id": "oaccount~digicur~38848e87296d67c8a90918f78cf55f9c9baab2cdc8c928535471aaa1210c706e",
            "amount": 10
        }
    ]
}
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)を指定するオブジェクト。

    Visual Studio CodeとCLIまたはPostmanコレクションを使用している場合は、info_detailsパラメータを別の形式で指定します。

    Visual Studioコード: { "category": "category value", "description": "description value" }

    CLI /ポストマン: "{\"category\":\"category value\",\"description\":\"description value\"}"

戻り値の例:
{
 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)",
}
bulkTransferTokens
このメソッドは、トークンを呼出し元アカウントからflowオブジェクトで指定されたアカウントに一括で転送します。The quantities must be within the decimal values specified by the decimal parameter of the divisible behavior in the specification file.The caller of this method must have an account already created.このメソッドは、アカウントのAccountOwnerのみがコールできます。
@Validator(yup.string(), yup.array().of(yup.object()))
public async bulkTransferTokens(token_id: string, flow: object[]) {
     const token_asset = await this.getTokenObject(token_id);
     return await this.Ctx.Token.bulkTransfer(flow, token_asset);
}
パラメータ:
  • token_id: string – トークンのID。
  • flow : object[] – 受信者と数量を指定するJSONオブジェクトの配列。
    • to_orgId: string – 現在の組織内の受信者のメンバーシップ・サービス・プロバイダ(MSP) ID。
    • userId: string – 受信者のユーザー名または電子メールID。
    • quantity: number – 転送するトークンの数。
    Visual Studio CodeとCLIまたはPostmanコレクションを使用している場合は、flowパラメータを別の形式で指定します。
    Visual Studio Code:
    [
      { "to_org_id": "Org1MSP", "to_user_id": "user1", "quantity": 10 },
      { "to_org_id": "Org1MSP", "to_user_id": "user2", "quantity": 10 }
    ]
    
    CLI/Postman:
    "[{ \"to_org_id\": \"Org1MSP\", \"to_user_id\": \"user1\", \"quantity\": 10 }, { \"to_org_id\": \"Org1MSP\", \"to_user_id\": \"user2\", \"quantity\": 10 }]"
戻り値:
  • 成功を示すメッセージ。
戻り値の例:
{
    "msg": "Successfully transferred 20 tokens from Account Id           'oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df' (Org-Id: Org1MSP, User-Id: admin).",
    "from_account_id": "oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df",
    "sub_transactions": [
        {
            "to_account_id": "oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f",
            "amount": 10
        },
        {
            "to_account_id": "oaccount~digicur~38848e87296d67c8a90918f78cf55f9c9baab2cdc8c928535471aaa1210c706e",
            "amount": 10
        }
    ]
}

トークン動作管理メソッド- 保留可能動作

holdTokens
このメソッドは、to_account_idアカウントを持つトークンの所有者のかわりに保留を作成します。保留の完了または解除を担当する公証人アカウントが指定されます。保留が作成されると、支払者から指定されたトークン残高が保留になります。保留残高は、保留が完了または解除されるまで転送できません。このメソッドのコール元には、すでにアカウントが作成されている必要があります。このメソッドは、アカウントのAccountOwnerのみがコールできます。
@Validator(yup.string(), yup.string(), yup.string(), yup.string(), yup.string(), yup.string(), yup.number().positive(), yup.date())
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
) {
    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);
}
パラメータ:
  • 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です。
戻り値:
  • 成功の場合、コール元のアカウントおよび保留詳細を含むメッセージ。
戻り値の例:
{
  "msg":"AccountId oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df (Org-Id: Org1MSP , User-Id: admin) is   successfully holding 10 tokens"
}
executeHoldTokens
このメソッドはトークンの保留を完了します。トークン所有者が以前に保留にした数量のトークンが受信者に転送されます。quantity値が実際の保留値より小さい場合、残りはトークンの元の所有者が再度使用できます。このメソッドは、指定された操作IDのnotaryロールを持つAccountOwner IDのみがコールできます。保留は公証人のみが完了できます。
@Validator(yup.string(), yup.string(), yup.number().positive())
public async executeHoldTokens(token_id: string, operation_id: string, quantity: number) {
    const token_asset = await this.getTokenObject(token_id);
    return await this.Ctx.Token.executeHold(operation_id, quantity, token_asset);
}
パラメータ:
  • token_id: string – トークンのID。
  • operation_id: string – 保留操作を識別する一意のID。通常、このIDはクライアント・アプリケーションによって渡されます。
  • quantity: number – 転送する保留トークンの数。
戻り値:
  • 成功の場合、コール元のアカウントIDとトランザクションの数量を含むメッセージ。
戻り値の例:
{
 "msg":"Account Id: oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df (Org-Id: Org1MSP, User-Id: admin) is successfully executed '10' tokens from Operation Id 'opr_121'."
}
releaseHoldTokens
このメソッドは、トークンの保留を解除します。転送は行われず、すべての保留トークンは元の所有者が再度使用できます。このメソッドは、指定された時間制限内はnotaryロールを持つAccountOwner IDが、指定された時間制限後は支払者、受取人または公証員がコールできます。
@Validator(yup.string(), yup.string())
public async releaseHoldTokens(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。通常、このIDはクライアント・アプリケーションによって渡されます。
戻り値:
  • 成功の場合、保留が解除されたことを示すメッセージが表示されます。
戻り値の例:
{
 "msg":"Successfully released '10' tokens from Operation Id 'opr_121' to Account Id: oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df (Org-Id: Org1MSP, User-Id: user1)."
}
getOnHoldIds
このメソッドは、指定されたアカウントのすべての保留IDのリストを返します。このメソッドは、チェーンコードのToken Admin、指定された組織のOrg AdminまたはアカウントのAccountOwnerがコールできます。
  @Validator(yup.string(), yup.string(), yup.string())
  public async getOnHoldIds(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.getOnHoldIds", "TOKEN", { account_id });
    return await this.Ctx.Account.getOnHoldIds(account_id);
  }
パラメータ:
  • token_id: string – トークンのID。
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、保留IDのJSONリスト。
戻り値の例:
{"msg":"Holding Ids are: ohold~digicur~digiCurr101~opr_121","holding_ids":["ohold~digicur~digiCurr101~opr_121"]}
getOnHoldDetailsWithOperationId
このメソッドは、指定された操作IDおよびトークンの保留トランザクション詳細を返します。このメソッドは、だれでも呼び出すことができます。
@Validator(yup.string(), yup.string())
public async getOnHoldDetailsWithOperationId(token_id: string, operation_id: string) {
    return await this.Ctx.Hold.getOnHoldDetailsWithOperationId(token_id, operation_id);
}
パラメータ:
  • token_id: string – トークンのID。
  • operation_id: string – 保留操作を識別する一意のID。通常、このIDはクライアント・アプリケーションによって渡されます。
戻り値:
  • 成功の場合、次のプロパティを含むJSON保留オブジェクト:
  • holding_id – トランザクションの保留ID。
  • operation_id: string – 保留操作を識別する一意のID。通常、このIDはクライアント・アプリケーションによって渡されます。
  • from_account_id – 保留トークンの現在の所有者のアカウントID。
  • to_account_id – 受信者のアカウントID。
  • notary_account_id – 公証人のアカウントID。
  • token_id: string– 保存されたトークンのID。
  • quantity – 保留IDに対して保留されているトークンの量。
  • time_to_expiration– 保留が期限切れになるまでの期間。
戻り値の例:
{
    "assetType": "ohold",
    "holding_id": "ohold~digicur~digiCurr101~opr_121",
    "operation_id": "opr_121",
    "token_name": "digicur",
    "from_account_id": "oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df",
    "to_account_id": "oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f",
    "notary_account_id": "oaccount~digicur~38848e87296d67c8a90918f78cf55f9c9baab2cdc8c928535471aaa1210c706e",
    "token_id": "digiCurr101",
    "quantity": 10,
    "time_to_expiration": "2022-08-01T18:30:00.000Z"
}
getOnHoldBalanceWithOperationId
このメソッドは、指定された操作IDおよびトークンの保留残高を返します。このメソッドは、だれでも呼び出すことができます。
@Validator(yup.string(), yup.string())
public async getOnHoldBalanceWithOperationId(token_id: string, operation_id: string) {
    return await this.Ctx.Hold.getOnHoldBalanceWithOperationId(token_id, operation_id);
}
パラメータ:
  • token_id: string – トークンのID。
  • operation_id: string – 保留操作を識別する一意のID。通常、このIDはクライアント・アプリケーションによって渡されます。
戻り値:
  • 成功の場合、保留残高を示すJSON文字列。
戻り値の例:
{
	"msg": "Current Holding Balance of Operation 'opr_121' for token 'digiCurr101' is: 10",
	"holding_balance": 10
}
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)を指定するオブジェクト。

    Visual Studio CodeとCLIまたはPostmanコレクションを使用している場合は、info_detailsパラメータを別の形式で指定します。

    Visual Studioコード: { "category": "category value", "description": "description value" }

    CLI /ポストマン: "{\"category\":\"category value\",\"description\":\"description value\"}"

戻り値の例:
{
msg:
"AccountId oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (Org-Id: Org1MSP, User-Id: admin) is successfully holding 100 tokens",
}
executeHoldTokens
このメソッドはトークンの保留を完了します。トークン所有者が以前に保留にした数量のトークンが受信者に転送されます。quantity値が実際の保留値より小さい場合、残りはトークンの元の所有者が再度使用できます。このメソッドは、指定された操作IDのnotaryロールを持つAccountOwner IDのみがコールできます。保留は公証人のみが完了できます。
@Validator(yup.string(), yup.string(), yup.number().positive())
public async executeHoldTokens(token_id: string, operation_id: string, quantity: number) {
    const token_asset = await this.getTokenObject(token_id);
    return await this.Ctx.Token.executeHold(operation_id, quantity, token_asset);
}
パラメータ:
  • token_id: string – トークンのID。
  • operation_id: string – 保留操作を識別する一意のID。通常、このIDはクライアント・アプリケーションによって渡されます。
  • quantity: number – 転送する保留トークンの数。
戻り値:
  • 成功の場合、コール元のアカウントIDとトランザクションの数量を含むメッセージ。
戻り値の例:
{
 "msg":"Account Id: oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df (Org-Id: Org1MSP, User-Id: admin) is successfully executed '10' tokens from Operation Id 'opr_121'."
}
releaseHoldTokens
このメソッドは、トークンの保留を解除します。転送は行われず、すべての保留トークンは元の所有者が再度使用できます。このメソッドは、指定された時間制限内はnotaryロールを持つAccountOwner IDが、指定された時間制限後は支払者、受取人または公証員がコールできます。
@Validator(yup.string(), yup.string())
public async releaseHoldTokens(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。通常、このIDはクライアント・アプリケーションによって渡されます。
戻り値:
  • 成功の場合、保留が解除されたことを示すメッセージが表示されます。
戻り値の例:
{
 "msg":"Successfully released '10' tokens from Operation Id 'opr_121' to Account Id: oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df (Org-Id: Org1MSP, User-Id: user1)."
}
getOnHoldIds
このメソッドは、指定されたアカウントのすべての保留IDのリストを返します。このメソッドは、チェーンコードのToken AdminまたはToken Auditor、指定された組織のOrg AdminまたはOrg Auditor、またはアカウントのAccountOwnerによってコールできます。
  @Validator(yup.string(), yup.string(), yup.string())
  public async getOnHoldIds(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.getOnHoldIds", "TOKEN", { account_id });
    return await this.Ctx.Account.getOnHoldIds(account_id);
  }
パラメータ:
  • token_id: string – トークンのID。
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、保留IDのJSONリスト。
戻り値の例:
{"msg":"Holding Ids are: ohold~digicur~digiCurr101~opr_121","holding_ids":["ohold~digicur~digiCurr101~opr_121"]}
getOnHoldDetailsWithOperationId
このメソッドは、指定された操作IDおよびトークンの保留トランザクション詳細を返します。このメソッドは、チェーンコードのToken AdminまたはToken Auditor、またはトランザクション参加者(送信者、受信者、公証人)によってコールできます。
@Validator(yup.string(), yup.string())
public async getOnHoldDetailsWithOperationId(token_id: string, operation_id: string) {
    return await this.Ctx.Hold.getOnHoldDetailsWithOperationId(token_id, operation_id);
}
パラメータ:
  • token_id: string – トークンのID。
  • operation_id: string – 保留操作を識別する一意のID。通常、このIDはクライアント・アプリケーションによって渡されます。
戻り値:
  • 成功の場合、次のプロパティを含むJSON保留オブジェクト:
  • holding_id – トランザクションの保留ID。
  • operation_id: string – 保留操作を識別する一意のID。通常、このIDはクライアント・アプリケーションによって渡されます。
  • from_account_id – 保留トークンの現在の所有者のアカウントID。
  • to_account_id – 受信者のアカウントID。
  • notary_account_id – 公証人のアカウントID。
  • token_id: string– 保存されたトークンのID。
  • quantity – 保留IDに対して保留されているトークンの量。
  • time_to_expiration– 保留が期限切れになるまでの期間。
戻り値の例:
{
    "assetType": "ohold",
    "holding_id": "ohold~digicur~digiCurr101~opr_121",
    "operation_id": "opr_121",
    "token_name": "digicur",
    "from_account_id": "oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df",
    "to_account_id": "oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f",
    "notary_account_id": "oaccount~digicur~38848e87296d67c8a90918f78cf55f9c9baab2cdc8c928535471aaa1210c706e",
    "token_id": "digiCurr101",
    "quantity": 10,
    "time_to_expiration": "2022-08-01T18:30:00.000Z"
}
getOnHoldBalanceWithOperationId
このメソッドは、指定された操作IDおよびトークンの保留残高を返します。このメソッドは、チェーンコードのToken AdminまたはToken Auditor、またはトランザクション参加者(送信者、受信者、公証人)によってコールできます。
@Validator(yup.string(), yup.string())
public async getOnHoldBalanceWithOperationId(token_id: string, operation_id: string) {
    return await this.Ctx.Hold.getOnHoldBalanceWithOperationId(token_id, operation_id);
}
パラメータ:
  • token_id: string – トークンのID。
  • operation_id: string – 保留操作を識別する一意のID。通常、このIDはクライアント・アプリケーションによって渡されます。
戻り値:
  • 成功の場合、保留残高を示すJSON文字列。
戻り値の例:
{
	"msg": "Current Holding Balance of Operation 'opr_121' for token 'digiCurr101' is: 10",
	"holding_balance": 10
}

トークン動作管理のメソッド- バーン可能動作

burnTokens
このメソッドは、トランザクション・コール元のアカウントからトークンを非アクティブ化またはバーンします。このメソッドのコール元には、アカウントとバーナー・ロールが必要です。数量は、仕様ファイルのdivisible動作のdecimalパラメータで指定された10進数値内にする必要があります。このメソッドは、バーナー・ロールを持つアカウントのAccountOwnerがコールできます。
@Validator(yup.string(), yup.number().positive())
public async burnTokens(token_id: string, quantity: number) {
    const token_asset = await this.getTokenObject(token_id);
    return await this.Ctx.Token.burn(quantity, token_asset);
}
パラメータ:
  • token_id: string – トークンのID。
  • quantity – バーンするトークンの数。
戻り値:
  • 成功の場合、バーンしたトークンの数量とアカウントIDを含む成功メッセージ。
戻り値の例:
{
    "msg": "Successfully burned 10 tokens from account id: oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df (Org-Id: Org1MSP, User-Id: admin)"
}
requestBurn
このメソッドは、バーナーからコールして、指定した量のトークンを破棄するリクエストをバーナー公証書に送信できます。このトークンは、使用可能な残高以下である必要があります。バーン・リクエストが開始されると、指定された金額が使用可能な残高から即座に差し引かれ、onhold_burn_balanceフィールドに追加されます。リクエストが承認されると、トークンは書き込まれます。リクエストが拒否された場合、トークンはonhold_burn_balanceフィールドから使用可能な残高に返されます。
@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)を指定するオブジェクト。

    Visual Studio CodeとCLIまたはPostmanコレクションを使用している場合は、info_detailsパラメータを別の形式で指定します。

    Visual Studioコード: { "category": "category value", "description": "description value" }

    CLI /ポストマン: "{\"category\":\"category value\",\"description\":\"description value\"}"

戻り値の例:
{
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",
}
getAccountOnHoldBurnBalance
このメソッドは、指定されたユーザーの保留バーン・バランスを返します。このメソッドは、Token AdminToken AuditorOrg AdminOrg Auditorまたはアカウント所有者によってのみコールできます。
@GetMethod()
@Validator(yup.string(), yup.string(), yup.string())
public async getAccountOnHoldBurnBalance(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.getAccountOnHoldBurnBalance", "TOKEN", { account_id });
  return await this.Ctx.Account.getAccountOnHoldBurnBalance(account_id);
}
パラメータ:
  • token_id: string– 書き込むトークンのID。
  • org_id string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id string – ユーザーのユーザー名または電子メールID。
戻り値の例:
{
  "msg": "Total On Hold Burning Balance is: 10",
  "onhold_burn_balance": 10
}
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)を指定するオブジェクト。

    Visual Studio CodeとCLIまたはPostmanコレクションを使用している場合は、info_detailsパラメータを別の形式で指定します。

    Visual Studioコード: { "category": "category value", "description": "description value" }

    CLI /ポストマン: "{\"category\":\"category value\",\"description\":\"description value\"}"

戻り値の例:
{
msg:
"Successfully burned 100 tokens from account id: oaccount~95be539b4e1e4136dd86a806020c97a930909325340481b8fd88d339874fa699 (Org-Id: Org1MSP, User-Id: admin)"
}

カスタム・メソッド

トークンSDKメソッドを使用して、ビジネス・アプリケーションのカスタム・メソッドを記述できます。

二重支出を回避するために、状態データベース内の同じキーと値のペアに作用する複数の非同期関数を組み合せないでください。かわりに、bulkTransferTokensメソッドを使用して、1つのメソッドで複数の転送を行います。

次の例は、カスタム・メソッドでトークンSDKメソッドを使用する方法を示しています。buyTicketメソッドがコールされると、20個のトークンがコール元のアカウントから販売者のアカウントに転送され、転送のトランザクション・メッセージが返されます。

@Validator(yup.string(), yup.string(), yup.string(), yup.string(), yup.string())
public async buyTicket(token_id: string, seller_org_id: string, seller_user_id: string) {
	const token = await this.getTokenObject(token_id);

	/**
	* The following method this.Ctx.Account.generateAccountId(token_id, seller_org_id, seller_user_id) generates account id of the seller.
	*/
	const seller_account_id = await this.Ctx.Account.generateAccountId(token_id, seller_org_id, seller_user_id);

	/**
	* The following method this.Ctx.Token.transfer(seller_account_id, 20, token) transfers the quantity 20 from caller's
	* account & to seller's account.
	*/
	const transaction = await this.Ctx.Token.transfer(seller_account_id, 20, token);

	return transaction;
}

カスタム・メソッドで複数のトークンSDKメソッドを使用する場合は、状態データベースの同じキーと値のペアに影響するメソッドを使用しないでください。次の例は、複数の転送を行う誤った方法を示しています:

@Validator(yup.string(), yup.string(), yup.string(), yup.string(), yup.string())
public async sendTokens(token_id: string, user1_org_id: string, user1_user_id: string, user2_org_id: string, user2_user_id: string) {
    const token = await this.getTokenObject(token_id);
    const user1_account_id = await Account.generateAccountId(token_id, user1_org_id, user1_user_id);
    const user2_account_id = await Account.generateAccountId(token_id, user2_org_id, user2_user_id);
    await token.transfer(user1_account_id, 20);
    await token.transfer(user2_account_id, 30);
}

かわりに、次のコード・スニペットに示すように、bulkTransferTokensメソッドを使用して、コール元アカウントから複数の勘定科目に転送します。

bulkTransferTokens(token_id: string, flow: object[])

ノート:

状態データベースの同じキーと値のペアに影響を与える可能性がある複数のトークンSDKメソッドをカスタム・メソッドで使用する場合は、トークン・チェーンコードのMVCC最適化を有効にします。詳細は、「MVCCの最適化」を参照してください。

トークンSDKメソッド

アクセス制御管理のメソッド

トークンSDKはアクセス制御機能を提供します。一部のメソッドは、トークンのToken AdminOrg AdminまたはAccountOwnerのみがコールできます。この機能を使用すると、目的のユーザーのみが操作を実行するようにできます。認可されていないアクセスではエラーが発生します。アクセス制御機能を使用するには、../lib/authモジュールからAuthorizationクラスをインポートします。
import { Authorization } from '../lib/auth';
addAdmin
このメソッドは、トークン・チェーンコードのToken Adminとしてユーザーを追加します。
Ctx.Admin.addAdmin(org_id: string, user_id: string)
パラメータ:
  • user_id – ユーザーのユーザー名または電子メールID。
  • org_id – 現在のネットワーク組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
戻り値:
  • 成功の場合、トークン・チェーンコードのToken Adminとして追加されたユーザーの詳細をリストするJSONオブジェクトを含むpromiseメッセージ。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
    "msg": "Successfully added Admin (Org_Id: Org1MSP, User_Id: user1)"
}
removeAdmin
このメソッドは、トークン・チェーンコードのToken Adminであるユーザーを削除します。
Ctx.Admin.removeAdmin(org_id: string, user_id: string)
パラメータ:
  • user_id – ユーザーのユーザー名または電子メールID。
  • org_id – 現在のネットワーク組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
戻り値:
  • 成功の場合、トークン・チェーンコードのToken Adminではなくなったユーザーの詳細をリストするJSONオブジェクトを含むpromiseメッセージ。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
    "msg": "Successfully removed Admin (Org_Id: Org1MSP, User_Id: user1)"
}
isUserTokenAdmin
このメソッドは、関数のコール元がToken Adminの場合、ブール値trueを返します。それ以外の場合、このメソッドはfalseを返します。
Ctx.Auth.isUserTokenAdmin()
パラメータ:
  • user_id – ユーザーのユーザー名または電子メールID。
  • org_id – 現在のネットワーク組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
戻り値:
  • ブール値のレスポンスおよびエラーが発生した場合、エラー・メッセージ。
getAllAdmins
このメソッドは、トークン・チェーンコードのToken Adminであるすべてのユーザーのリストを返します。
Ctx.Admin.getAllAdmins()
パラメータ:
  • なし
戻り値:
  • 成功の場合、トークン・チェーンコードのToken Adminであるすべてのユーザーの詳細をリストするJSONオブジェクトを持つpromise。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
    "admins": [
        {
            "orgId": "Org1MSP",
            "userId": "admin"
        }
    ]
}
checkAuthorization
このメソッドは、操作にアクセス制御チェックを追加するために使用します。特定のトークン・メソッドは、トークンのToken AdminまたはAccountOwner、または複数のアカウントを持つユーザーのMultipleAccountOwnerのみが実行できます。アクセス制御マッピングは、../lib/constant.tsファイルに記述されています。アクセス制御を変更するには、../lib/constant.tsファイルを編集します。独自のアクセス制御を使用したり、アクセス制御を無効にするには、自動生成されたコントローラ・メソッドおよびカスタム・メソッドからアクセス制御コードを削除します。
export const TOKENACCESS = {
  ADMIN: {
    isUserTokenAdmin: ["Admin", "OrgAdmin"],
    addTokenAdmin: ["Admin"],
    removeTokenAdmin: ["Admin"],
    getAllAdmins: ["Admin", "OrgAdmin"],
    addOrgAdmin: ["Admin", "OrgAdminForOrgId"],
    removeOrgAdmin: ["Admin", "OrgAdminForOrgId"],
    getOrgAdmins: ["Admin", "OrgAdmin"],
  },
  TOKEN: {
    save: ["Admin"],
    getAllTokens: ["Admin", "OrgAdmin"],
    get: ["Admin", "OrgAdmin"],
    update: ["Admin"],
    getDecimals: ["Admin", "OrgAdmin"],
    getTokensByName: ["Admin", "OrgAdmin"],
    addRoleMember: ["Admin", "OrgAdminRoleCheck"],
    removeRoleMember: ["Admin", "OrgAdminRoleCheck"],
    isInRole: ["Admin", "OrgAdminForAccountId", "AccountOwner"],
    getTotalMintedTokens: ["Admin", "OrgAdmin"],
    getNetTokens: ["Admin", "OrgAdmin"],
    getTokenHistory: ["Admin", "OrgAdmin"],
  },
  ROLE: {
    getAccountsByRole: ["Admin"],
    getOrgAccountsByRole: ["Admin", "OrgAdminForOrgId"],
    getUsersByRole: ["Admin"],
    getOrgUsersByRole: ["Admin", "OrgAdminForOrgId"],
  },
  TRANSACTION: {
    deleteTransactions: ["Admin"],
  },ACCOUNT: {
    createAccount: ["Admin", "OrgAdminForOrgId"],
    associateToken: ["Admin", "OrgAdminForAccountId"],
    getAllAccounts: ["Admin"],
    getAllOrgAccounts: ["Admin", "OrgAdminForOrgId"],
    getAccountsByUser: ["Admin", "OrgAdminForOrgId", "MultipleAccountOwner"],
    getAccount: ["Admin", "OrgAdminForAccountId", "AccountOwner"],
    history: ["Admin", "AccountOwner"],
    getAccountTransactionHistory: ["Admin", "OrgAdminForAccountId", "AccountOwner"],
    getAccountTransactionHistoryWithFilters: ["Admin", "OrgAdminForAccountId", "AccountOwner"],
    getSubTransactionsById: ["Admin", "TransactionInvoker"],
    getSubTransactionsByIdWithFilters: ["Admin", "TransactionInvoker"],
    getAccountBalance: ["Admin", "OrgAdminForAccountId", "AccountOwner"],
    getAccountOnHoldBalance: ["Admin", "OrgAdminForAccountId", "AccountOwner"],
    getOnHoldIds: ["Admin", "OrgAdminForAccountId", "AccountOwner"],
    getConversionHistory: ["Admin", "OrgAdminForAccountId", "AccountOwner"],
  },
  ACCOUNT_STATUS: {
    get: ["Admin", "OrgAdminForAccountId", "AccountOwner"],
    history: ["Admin", "OrgAdminForAccountId", "AccountOwner"],
    activateAccount: ["Admin", "OrgAdminForOrgId"],
    suspendAccount: ["Admin", "OrgAdminForOrgId"],
    deleteAccount: ["Admin", "OrgAdminForOrgId"],
  },
  TOKEN_CONVERSION: {
    initializeExchangePoolUser: ["Admin"],
    addConversionRate: ["Admin"],
    updateConversionRate: ["Admin"],
    getConversionRate: ["Admin", "OrgAdmin", "AnyAccountOwner"],
    getConversionRateHistory: ["Admin", "OrgAdmin", "AnyAccountOwner"],
    tokenConversion: ["Admin", "AnyAccountOwner"],
    getExchangePoolUser: ["Admin"],
  },
}
await this.Ctx.Auth.checkAuthorization(<parameters>);
パラメータ:
  • classFuncName: string – クラスとメソッドの間のマップ値(../lib/constant.tsファイルを参照)。
  • ...args – 可変引数。args[0]には定数'TOKEN'を指定し、args[1]には、AccountOwnerのアクセス制御チェックを追加する場合、account_idパラメータを指定します。MultipleAccountOwnerのアクセス制御チェックを追加するには、args[1]org_idを指定し、args[2]user_idを指定します。
戻り値:
  • 成功の場合、promise。エラーの場合、エラー・メッセージ付きの拒否。
addOrgAdmin
このメソッドは、ユーザーを組織のOrg Adminとして追加します。
Ctx.Admin.addOrgAdmin(org_id, user_id)
パラメータ:
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、組織のOrg Adminとして追加されたユーザーの詳細を含むメッセージ。
戻り値の例:
{
    "msg": "Successfully added Org Admin (Org_Id: Org1MSP, User_Id: orgAdmin)"
}
removeOrgAdmin
このメソッドは、組織のOrg Adminであるユーザーを削除します。
Ctx.Admin.removeOrgAdmin(org_id, user_id)
パラメータ:
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、組織のOrg Adminとして削除されたユーザーの詳細を含むメッセージ。
戻り値の例:
{
  "msg": "Successfully removed Org Admin (Org_Id Org1MSP User_Id orgAdmin)"
}
getOrgAdmins
このメソッドは、組織のOrg Adminであるすべてのユーザーのリストを返します。
Ctx.Admin.getAllOrgAdmins()
パラメータ:
  • なし
戻り値:
  • 成功の場合、orgIdおよびuserIdオブジェクトを含むJSON形式の配列。
戻り値の例:
{
    "admins": [
        {
            "org_id": "Org1MSP",
            "user_id": "orgadmin"
        },
        {
            "org_id": "Org1MSP",
            "user_id": "orgadmin1"
        },
        {
            "org_id": "Org1MSP",
            "user_id": "orgadmin2"
        }
    ]
}
addAdmin
このメソッドは、トークン・チェーンコードのToken Adminとしてユーザーを追加します。
Ctx.Admin.addAdmin(org_id: string, user_id: string)
パラメータ:
  • user_id – ユーザーのユーザー名または電子メールID。
  • org_id – 現在のネットワーク組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
戻り値:
  • 成功の場合、トークン・チェーンコードのToken Adminとして追加されたユーザーの詳細をリストするJSONオブジェクトを含むpromiseメッセージ。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
    "msg": "Successfully added Admin (Org_Id: Org1MSP, User_Id: user1)"
}
removeAdmin
このメソッドは、トークン・チェーンコードのToken Adminであるユーザーを削除します。
Ctx.Admin.removeAdmin(org_id: string, user_id: string)
パラメータ:
  • user_id – ユーザーのユーザー名または電子メールID。
  • org_id – 現在のネットワーク組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
戻り値:
  • 成功の場合、トークン・チェーンコードのToken Adminではなくなったユーザーの詳細をリストするJSONオブジェクトを含むpromiseメッセージ。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
    "msg": "Successfully removed Admin (Org_Id: Org1MSP, User_Id: user1)"
}
isUserTokenAdmin
このメソッドは、関数のコール元がToken Adminの場合、ブール値trueを返します。それ以外の場合、このメソッドはfalseを返します。
Ctx.Auth.isUserTokenAdmin()
パラメータ:
  • user_id – ユーザーのユーザー名または電子メールID。
  • org_id – 現在のネットワーク組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
戻り値:
  • ブール値のレスポンスおよびエラーが発生した場合、エラー・メッセージ。
getAllAdmins
このメソッドは、トークン・チェーンコードのToken Adminであるすべてのユーザーのリストを返します。
Ctx.Admin.getAllAdmins()
パラメータ:
  • なし
戻り値:
  • 成功の場合、トークン・チェーンコードのToken Adminであるすべてのユーザーの詳細をリストするJSONオブジェクトを持つpromise。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
    "admins": [
        {
            "orgId": "Org1MSP",
            "userId": "admin"
        }
    ]
}
checkAuthorization
このメソッドは、操作にアクセス制御チェックを追加するために使用します。特定のトークン・メソッドは、トークンのToken AdminまたはAccountOwner、または複数のアカウントを持つユーザーのMultipleAccountOwnerのみが実行できます。アクセス制御マッピングは、../lib/constant.tsファイルに記述されています。アクセス制御を変更するには、../lib/constant.tsファイルを編集します。独自のアクセス制御を使用したり、アクセス制御を無効にするには、自動生成されたコントローラ・メソッドおよびカスタム・メソッドからアクセス制御コードを削除します。
export const TOKENACCESS = {
  ADMIN: {
    isUserTokenAdmin: ["Admin", "OrgAdmin"],
    addTokenAdmin: ["Admin"],
    removeTokenAdmin: ["Admin"],
    getAllAdmins: ["Admin", "OrgAdmin"],
    addOrgAdmin: ["Admin", "OrgAdminForOrgId"],
    removeOrgAdmin: ["Admin", "OrgAdminForOrgId"],
    getOrgAdmins: ["Admin", "OrgAdmin"],
  },
  TOKEN: {
    save: ["Admin"],
    getAllTokens: ["Admin", "OrgAdmin"],
    get: ["Admin", "OrgAdmin"],
    update: ["Admin"],
    getDecimals: ["Admin", "OrgAdmin"],
    getTokensByName: ["Admin", "OrgAdmin"],
    addRoleMember: ["Admin", "OrgAdminRoleCheck"],
    removeRoleMember: ["Admin", "OrgAdminRoleCheck"],
    isInRole: ["Admin", "OrgAdminForAccountId", "AccountOwner"],
    getTotalMintedTokens: ["Admin", "OrgAdmin"],
    getNetTokens: ["Admin", "OrgAdmin"],
    getTokenHistory: ["Admin", "OrgAdmin"],
  },
  ROLE: {
    getAccountsByRole: ["Admin"],
    getOrgAccountsByRole: ["Admin", "OrgAdminForOrgId"],
    getUsersByRole: ["Admin"],
    getOrgUsersByRole: ["Admin", "OrgAdminForOrgId"],
  },
  TRANSACTION: {
    deleteTransactions: ["Admin"],
  },ACCOUNT: {
    createAccount: ["Admin", "OrgAdminForOrgId"],
    associateToken: ["Admin", "OrgAdminForAccountId"],
    getAllAccounts: ["Admin"],
    getAllOrgAccounts: ["Admin", "OrgAdminForOrgId"],
    getAccountsByUser: ["Admin", "OrgAdminForOrgId", "MultipleAccountOwner"],
    getAccount: ["Admin", "OrgAdminForAccountId", "AccountOwner"],
    history: ["Admin", "AccountOwner"],
    getAccountTransactionHistory: ["Admin", "OrgAdminForAccountId", "AccountOwner"],
    getAccountTransactionHistoryWithFilters: ["Admin", "OrgAdminForAccountId", "AccountOwner"],
    getSubTransactionsById: ["Admin", "TransactionInvoker"],
    getSubTransactionsByIdWithFilters: ["Admin", "TransactionInvoker"],
    getAccountBalance: ["Admin", "OrgAdminForAccountId", "AccountOwner"],
    getAccountOnHoldBalance: ["Admin", "OrgAdminForAccountId", "AccountOwner"],
    getOnHoldIds: ["Admin", "OrgAdminForAccountId", "AccountOwner"],
    getConversionHistory: ["Admin", "OrgAdminForAccountId", "AccountOwner"],
  },
  ACCOUNT_STATUS: {
    get: ["Admin", "OrgAdminForAccountId", "AccountOwner"],
    history: ["Admin", "OrgAdminForAccountId", "AccountOwner"],
    activateAccount: ["Admin", "OrgAdminForOrgId"],
    suspendAccount: ["Admin", "OrgAdminForOrgId"],
    deleteAccount: ["Admin", "OrgAdminForOrgId"],
  },
  TOKEN_CONVERSION: {
    initializeExchangePoolUser: ["Admin"],
    addConversionRate: ["Admin"],
    updateConversionRate: ["Admin"],
    getConversionRate: ["Admin", "OrgAdmin", "AnyAccountOwner"],
    getConversionRateHistory: ["Admin", "OrgAdmin", "AnyAccountOwner"],
    tokenConversion: ["Admin", "AnyAccountOwner"],
    getExchangePoolUser: ["Admin"],
  },
}
await this.Ctx.Auth.checkAuthorization(<parameters>);
パラメータ:
  • classFuncName: string – クラスとメソッドの間のマップ値(../lib/constant.tsファイルを参照)。
  • ...args – 可変引数。args[0]には定数'TOKEN'を指定し、args[1]には、AccountOwnerのアクセス制御チェックを追加する場合、account_idパラメータを指定します。MultipleAccountOwnerのアクセス制御チェックを追加するには、args[1]org_idを指定し、args[2]user_idを指定します。
戻り値:
  • 成功の場合、promise。エラーの場合、エラー・メッセージ付きの拒否。
addOrgAdmin
このメソッドは、ユーザーを組織のOrg Adminとして追加します。
Ctx.Admin.addOrgAdmin(org_id, user_id)
パラメータ:
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、組織のOrg Adminとして追加されたユーザーの詳細を含むメッセージ。
戻り値の例:
{
    "msg": "Successfully added Org Admin (Org_Id: Org1MSP, User_Id: orgAdmin)"
}
removeOrgAdmin
このメソッドは、組織のOrg Adminであるユーザーを削除します。
Ctx.Admin.removeOrgAdmin(org_id, user_id)
パラメータ:
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、組織のOrg Adminとして削除されたユーザーの詳細を含むメッセージ。
戻り値の例:
{
  "msg": "Successfully removed Org Admin (Org_Id Org1MSP User_Id orgAdmin)"
}
getOrgAdmins
このメソッドは、組織のOrg Adminであるすべてのユーザーのリストを返します。
Ctx.Admin.getAllOrgAdmins()
パラメータ:
  • なし
戻り値:
  • 成功の場合、orgIdおよびuserIdオブジェクトを含むJSON形式の配列。
戻り値の例:
{
    "admins": [
        {
            "org_id": "Org1MSP",
            "user_id": "orgadmin"
        },
        {
            "org_id": "Org1MSP",
            "user_id": "orgadmin1"
        },
        {
            "org_id": "Org1MSP",
            "user_id": "orgadmin2"
        }
    ]
}
addTokenAuditor
このメソッドは、ユーザーをチェーンコードのToken Auditorとして追加します。
this.Ctx.Admin.addTokenAuditor(org_id, user_id)
パラメータ:
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、チェーンコードのToken Auditorとして追加されたユーザーの詳細を含むメッセージ。
戻り値の例:
{
    "returnCode": "Success",
    "error": "",
    "result": {
        "txid": "cd81f6c4c9e7c18ece357dbf5c139ef66ef2d6566be3b14de5f6d0a3fd4bb2f0",
        "payload": {
            "msg": "Successfully added Token Auditor (Org_Id: CB, User_Id: cb)"
        },
        "encode": "JSON",
        "sourceURL": "cb-oabcs1-bom.blockchain.ocp.example.com:20009",
        "blockNumber": 196
    }
}
removeTokenAuditor
このメソッドは、チェーンコードのToken Auditorであるユーザーを削除します。
this.Ctx.Admin.removeTokenAuditor(org_id, user_id)
パラメータ:
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、チェーンコードのToken Auditorとして削除されたユーザーの詳細を含むメッセージ。
戻り値の例:
{
    "returnCode": "Success",
    "error": "",
    "result": {
        "txid": "a886a6040fbc76374a3c78c89ab0ffc9f7b8391cc5239b169bf3b878cf40c67b",
        "payload": {
            "msg": "Successfully removed Token Auditor (Org_Id: CB, User_Id: cb)"
        },
        "encode": "JSON",
        "sourceURL": "cb-oabcs1-bom.blockchain.ocp.example.com:20010",
        "blockNumber": 219
    }
}
getTokenAuditors
このメソッドは、チェーンコードのすべてのToken Auditorsを返します。
this.Ctx.Admin.getAllTokenAuditors()
戻り値の例:
{
    "returnCode": "Success",
    "error": "",
    "result": {
        "payload": {
            "auditors": [
                {
                    "org_id": "CB",
                    "user_id": "auditor_user_cb"
                }
            ]
        },
        "encode": "JSON"
    }
}
addOrgAuditor
このメソッドは、チェーンコードのOrg Auditorとしてユーザーを追加します。
this.Ctx.Admin.addOrgAuditor(org_id, user_id)
パラメータ:
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、チェーンコードのOrg Auditorとして追加されたユーザーの詳細を含むメッセージ。
戻り値の例:
{
    "returnCode": "Success",
    "error": "",
    "result": {
        "txid": "44bbad35a1478cb714e32f7cfd551897868a203520aab9cea5771d3aadc1cf03",
        "payload": {
            "msg": "Successfully added Org Auditor (Org_Id: CB, User_Id: cb)"
        },
        "encode": "JSON",
        "sourceURL": "cb-oabcs1-bom.blockchain.ocp.example.com:20009",
        "blockNumber": 198
    }
}
removeOrgAuditor
このメソッドは、チェーンコードのOrg Auditorとしてユーザーを削除します。
this.Ctx.Admin.removeOrgAuditor(org_id, user_id)
パラメータ:
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、チェーンコードのOrg Auditorとして削除されたユーザーの詳細を含むメッセージ。
戻り値の例:
{
    "returnCode": "Success",
    "error": "",
    "result": {
        "txid": "c3bc720461004a53b37c68d4bb264858b88d980bc093a0a3ebb62a32974fb306",
        "payload": {
            "msg": "Successfully removed Org Auditor (Org_Id: CB, User_Id: cb)"
        },
        "encode": "JSON",
        "sourceURL": "cb-oabcs1-bom.blockchain.ocp.example.com:20010",
        "blockNumber": 221
    }
}
getOrgAuditors
このメソッドは、チェーンコードのすべてのOrg Auditorsを返します。
this.Ctx.Admin.getAllOrgAuditors()
戻り値の例:
{
    "returnCode": "Success",
    "error": "",
    "result": {
        "payload": {
            "auditors": [
                {
                    "org_id": "FI1",
                    "user_id": "auditor_user_fi1"
                },
                {
                    "org_id": "FI2",
                    "user_id": "auditor_user_fi2"
                }
            ]
        },
        "encode": "JSON"
    }
}

トークン構成管理のメソッド

save
このメソッドはトークンを作成し、そのプロパティを状態データベースに保存します。
Ctx.Token.save(token: <Instance of Token Class>,extraMetadata?:any)
パラメータ:
  • token: <Instance of Token Class> – 操作するトークン・アセット。
戻り値:
  • 成功の場合、トークン詳細を含むpromiseメッセージ。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
   "assetType":"otoken",
   "token_id":"digiCurr101",
   "token_name":"digicur",
   "token_type":"fungible",
   "behaviors":[
      "divisible",
      "mintable",
      "transferable",
      "burnable",
      "roles"
   ],
   "roles":{
      "minter_role_name":"minter"
   },
   "mintable":{
      "max_mint_quantity":1000
   },
   "divisible":{
      "decimal":2
   },
   "currency_name":"DOLLAR",
   "token_to_currency_ratio":1
}
update
このメソッドは、トークン・プロパティを更新します。トークン・アセットの作成後、token_desc値とそのカスタム・プロパティのみを更新します。
Ctx.Token.update(token: <Instance of Token Class>)
パラメータ:
  • token: <Instance of Token Class> – 操作するトークン・アセット。
戻り値:
  • 成功の場合、トークン詳細を含むpromiseメッセージ。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
   "assetType":"otoken",
   "token_id":"digiCurr101",
   "token_name":"digicur",
   "token_desc":"Digital Currency equiv of dollar",
   "token_type":"fungible",
   "behaviors":[
      "divisible",
      "mintable",
      "transferable",
      "burnable",
      "roles"
   ],
   "roles":{
      "minter_role_name":"minter"
   },
   "mintable":{
      "max_mint_quantity":1000
   },
   "divisible":{
      "decimal":2
   },
   "currency_name":"DOLLAR",
   "token_to_currency_ratio":1
}
getTokenDecimals
このメソッドは、フラクショナル・トークンで使用可能な小数点以下の桁数を返します。divisible動作が指定されていない場合、デフォルト値は0です。
Ctx.Token.getTokenDecimals(token_id: string)
パラメータ:
  • token_id: string – トークンのID。
戻り値:
  • 成功の場合、トークンの小数点以下桁数(数値データ型)。エラー時には、エラー・メッセージが返されます。
戻り値の例:
1
get
このメソッドは、状態データベースに存在する場合、トークン・オブジェクトを返します。
Ctx.Token.get(token_id: string)
パラメータ:
  • token_id: string – 返すトークンのID。
戻り値:
  • 成功の場合、トークンのJSON表現を含むpromise。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
    "assetType": "otoken",
    "token_id": "token1",
    "token_name": "account",
    "token_desc": "Token 1",
    "token_type": "fungible",
    "behaviors": [
        "divisible",
        "mintable",
        "transferable",
        "burnable",
        "holdable",
        "roles"
    ],
    "roles": {
        "minter_role_name": "minter",
        "burner_role_name": "burner",
        "notary_role_name": "notary"
    },
    "mintable": {
        "max_mint_quantity": 20000
    },
    "divisible": {
        "decimal": 1
    },
    "token_to_currency_ratio": 2,
    "currency_representation": "EURO"
}
history
このメソッドは、指定されたトークンの履歴を返します。
Ctx.Token.history(tokenId)
パラメータ:
  • tokenId: string – トークンのID。
戻り値:
  • 成功の場合、指定されたトークンのアカウント履歴詳細の配列を含むpromise。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
[
    {
        "trxId": "0d75f09446a60088afb948c6aca046e261fddcd43df416076201cdc5565f1a35",
        "timeStamp": "2023-09-01T16:48:41.000Z",
        "value": {
            "assetType": "otoken",
            "token_id": "token",
            "token_name": "fiatmoneytok",
            "token_desc": "updatedDesc",
            "token_standard": "ttf+",
            "token_type": "fungible",
            "token_unit": "fractional",
            "behaviors": [
                "divisible",
                "mintable",
                "transferable",
                "burnable",
                "roles"
            ],
            "roles": {
                "minter_role_name": "minter"
            },
            "mintable": {
                "max_mint_quantity": 1000
            },
            "divisible": {
                "decimal": 2
            }
        }
    },
    {
        "trxId": "3666344878b043b65d5b821cc79c042ba52aec467618800df5cf14eac69f72fa",
        "timeStamp": "2023-08-31T20:24:55.000Z",
        "value": {
            "assetType": "otoken",
            "token_id": "token",
            "token_name": "fiatmoneytok",
            "token_standard": "ttf+",
            "token_type": "fungible",
            "token_unit": "fractional",
            "behaviors": [
                "divisible",
                "mintable",
                "transferable",
                "burnable",
                "roles"
            ],
            "roles": {
                "minter_role_name": "minter"
            },
            "mintable": {
                "max_mint_quantity": 1000
            },
            "divisible": {
                "decimal": 2
            }
        }
    }
]
getAllTokens
このメソッドは、状態データベースに保存されたすべてのトークン・アセットを返します。このメソッドでは、Berkeley DB SQLリッチ問合せが使用され、リモートOracle Blockchain Platformネットワークに接続されている場合にのみコールできます。
Ctx.Token.getAllTokens()
パラメータ:
  • なし
戻り値:
  • 成功の場合、すべてのトークン・アセットを含むpromiseが返されます。エラーの場合、エラー・メッセージが返されます。
戻り値の例:
{
    "returnCode": "Success",
    "error": "",
    "result": {
        "txid": "98e0a0a115803d25b843d630e6b23c435a192a03eb0a301fc9375f05da49a8b2",
        "payload": [
            {
                "key": "token1",
                "valueJson": {
                    "assetType": "otoken",
                    "token_id": "token1",
                    "token_name": "vtok",
                    "token_type": "fungible",
                    "behaviours": [
                        "divisible",
                        "mintable",
                        "transferable",
                        "burnable",
                        "holdable",
                        "roles"
                    ],
                    "roles": {
                        "burner_role_name": "burner",
                        "notary_role_name": "notary"
                    },
                    "mintable": {
                        "max_mint_quantity": 0
                    },
                    "divisible": {
                        "decimal": 1
                    }
                }
            }
        ],
        "encode": "JSON"
    }
}
getTokensByName
このメソッドは、指定された名前のすべてのトークン・アセットを返します。このメソッドでは、Berkeley DB SQLリッチ問合せが使用され、リモートOracle Blockchain Platformネットワークに接続されている場合にのみコールできます。
Ctx.Token.getTokensByName(token_name: string)
パラメータ:
  • token_name: string – トークンの名前。これはモデルのToken_nameプロパティに対応します。値は、トークンのクラス名です。
戻り値:
  • 指定された名前のすべてのトークン・アセットの配列をJSON形式で返します。
戻り値の例:
{
    "returnCode": "Success",
    "error": "",
    "result": {
        "txid": "98e0a0a115803d25b843d630e6b23c435a192a03eb0a301fc9375f05da49a8b2",
        "payload": [
            {
                "key": "token1",
                "valueJson": {
                    "assetType": "otoken",
                    "token_id": "token1",
                    "token_name": "vtok",
                    "token_type": "fungible",
                    "behaviours": [
                        "divisible",
                        "mintable",
                        "transferable",
                        "burnable",
                        "holdable",
                        "roles"
                    ],
                    "roles": {
                        "burner_role_name": "burner",
                        "notary_role_name": "notary"
                    },
                    "mintable": {
                        "max_mint_quantity": 0
                    },
                    "divisible": {
                        "decimal": 1
                    }
                }
            }
        ],
        "encode": "JSON"
    }
}
isTokenType
このメソッドは、指定されたIDのトークン・アセットが存在するかどうかを示します。
Ctx.Token.isTokenType(token_id: string)
パラメータ:
  • token_id: string – チェックするトークンのID。
戻り値:
  • 成功の場合(指定したIDのトークン・アセットが存在する場合は)、trueを含むpromise。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
true
getByRange
このメソッドは、fabricのgetStateByRangeメソッドを内部的にコールします。指定されたIDを持つアセットが台帳から返されても、このメソッドはアセットをコール元のアセット・タイプにキャストします。
<Token ClassCtx.Token.getByRange(start_token_id: string, end_token_id: string, token_class_reference?: <Instance of Token Class> )
パラメータ:
  • startId: string– 範囲の開始キー。このキーは範囲に含まれます。
  • endId: string– 範囲の終了キー。このキーは範囲から除外されます。
  • token: <Instance of Token Class> – 操作するトークン・アセット。
戻り値:
  • 成功の場合、<Token Class>の配列を含むpromise。エラーの場合、エラー・メッセージ付きの拒否。
次に例を示します:
@validator(yup.string(), yup.string())
public async getDigiCurrGetByRange(start_token_id: string, end_token_id: string) {
   return await this.Ctx.Token.getByRange(start_token_id, end_token_id, DigiCurr);
}
戻り値の例:
[
    {
        "assetType": "otoken",
        "token_id": "token1",
        "token_name": "digicur",
        "token_desc": "Token 1",
        "token_type": "fungible",
        "behaviors": [
            "divisible",
            "mintable",
            "transferable",
            "burnable",
            "holdable",
            "roles"
        ],
        "roles": {
            "minter_role_name": "minter",
            "burner_role_name": "burner",
            "notary_role_name": "notary"
        },
        "mintable": {
            "max_mint_quantity": 20000
        },
        "divisible": {
            "decimal": 0
        },
        "token_to_currency_ratio": 1.5,
        "currency_representation": "USD"
    },
    {
        "assetType": "otoken",
        "token_id": "token2",
        "token_name": "digicur",
        "token_desc": "Token2",
        "token_type": "fungible",
        "behaviors": [
            "divisible",
            "mintable",
            "transferable",
            "burnable",
            "holdable",
            "roles"
        ],
        "roles": {
            "minter_role_name": "minter",
            "burner_role_name": "burner",
            "notary_role_name": "notary"
        },
        "mintable": {
            "max_mint_quantity": 20000
        },
        "divisible": {
            "decimal": 0
        },
        "token_to_currency_ratio": 1,
        "currency_representation": "EURO"
    }
]

アカウント管理のメソッド

getCallerAccountId
このメソッドは、コール元のアカウントIDを返します。
Ctx.Account.getCallerAccountId(token_id: string)
パラメータ:
  • tokenId: string – トークンのID。
戻り値:
  • 成功の場合、コール元のアカウントIDを含むpromise。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f
generateAccountId
このメソッドは、アカウントIDを返します。アカウントIDは英数字のセットです。アカウントIDは、oaccount~<token asset name>~が先頭に付き、インスタンス所有者およびインスタンスにログインしているユーザーのユーザー名または電子メールID (user_id)、現在のネットワーク組織内のユーザーの会員サービス・プロバイダID (org_id)および一意のトークンID (token_id)のハッシュが続きます。
Ctx.Account.generateAccountId(token_id: string, org_id: string, user_id: string)
パラメータ:
  • tokenId: string – トークンのID。
  • orgId: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • userId: string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、生成されたアカウントIDを含むpromise。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f
createAccount
このメソッドは、指定されたユーザーおよびトークンのアカウントを作成します。いずれかの時点でトークンを保有するすべてのユーザーはアカウントを持っている必要があります。アカウントは、ユーザーの残高、保留残高およびトランザクション履歴を追跡します。アカウントIDは英数字のセットです。アカウントIDは、oaccount~<token asset name>~が先頭付き、インスタンス所有者およびインスタンスにログインしているユーザーのユーザー名または電子メールID (user_id)と現在のネットワーク組織内のユーザーの会員サービス・プロバイダID (org_id)のハッシュが続きます。このメソッドは、チェーンコードのToken Adminまたは指定された組織のOrg Adminのみがコールできます。
this.Ctx.Account.createAccount(org_id: string, user_id: string, token_type: string)
パラメータ:
  • org_id: string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id: string – ユーザーのユーザー名または電子メールID。
  • token_type: string – トークンのタイプ。fungibleである必要があります。
戻り値:
  • 成功の場合、JSON形式の新しいアカウント・オブジェクト。
戻り値の例:
{
  "assetType": "oaccount",
  "bapAccountVersion": 0,
  "account_id": "oaccount~abc74791148b761352b98df58035601b6f5480448ac2b4a3a7eb54bdbebf48eb",
  "user_id": "admin",
  "org_id": "Org1MSP",
  "token_type": "fungible",
  "token_id": "",
  "token_name": "",
  "balance": 0,
  "onhold_balance": 0
}
associateTokenToAccount
このメソッドは、代替可能トークンをアカウントに関連付けます。このメソッドは、チェーンコードのToken Adminまたは関連する組織のOrg Adminのみがコールできます。
async associateTokenToAccount(account_id: string, token_id: string)
パラメータ:
  • account_id: string – アカウントのID。
  • token_id: string – トークンのID。
戻り値:
  • 成功の場合、更新されたアカウントのJSONオブジェクト。
戻り値の例:
{
    "assetType": "oaccount",
    "bapAccountVersion": 0,
    "account_id": "oaccount~abc74791148b761352b98df58035601b6f5480448ac2b4a3a7eb54bdbebf48eb",
    "user_id": "admin",
    "org_id": "Org1MSP",
    "token_type": "fungible",
    "token_id": "fungible",
    "token_name": "fiatmoneytok",
    "balance": 0,
    "onhold_balance": 0
}
getAccountWithStatus
このメソッドは、指定されたアカウントのアカウントの詳細(アカウント・ステータスを含む)を返します。
Ctx.Account.getAccountWithStatus(account_id: string)
パラメータ:
  • account_id: string – アカウントのID。
戻り値:
  • 成功の場合、アカウント詳細を含むpromise。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
  "bapAccountVersion": 0,
  "assetType": "oaccount",
  "status": "active",
  "account_id": "oaccount~2de8db6b91964f8c9009136831126d3cfa94e1d00c4285c1ea3e6d1f36479ed4",
  "user_id": "idcqa",
  "org_id": "appdev",
  "token_type": "fungible",
  "token_id": "t1",
  "token_name": "obptok",
  "balance": 0,
  "onhold_balance": 0
}
getAccount
このメソッドは、指定されたアカウントのアカウントの詳細を返します。
Ctx.Account.getAccount(account_id: string)
パラメータ:
  • account_id: string – アカウントのID。
戻り値:
  • 成功の場合、アカウント詳細を含むpromise。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
   "assetType":"oaccount",
   "bapAccountVersion": 0,
   "account_id":"oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f",
   "user_id":"user1",
   "org_id":"Org1MSP",
   "token_id":"digiCurr101",
   "token_name":"digicur",
   "balance":0,
   "onhold_balance":0
}
history
このメソッドは、指定されたアカウントのアカウント履歴詳細の配列を返します。
Ctx.Account.history(account_id: string)
パラメータ:
  • account_id: string – アカウントのID。
戻り値:
  • 成功の場合、アカウント履歴詳細の配列を含むpromise。エラーの場合、エラー・メッセージ付きの拒否。戻り値は、getAccountHistoryメソッドと同じです。
戻り値の例:
[
    {
      "trxId":"2gsdh17fff222467e5667be042e33ce18e804b3e065cca15de306f837e416d7c3e",
      "timeStamp":1629718288,
      "value":{
         "assetType":"oaccount",
         "account_id":"oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f",
         "user_id":"user1",
         "org_id":"Org1MSP",
         "token_id":"digiCurr101",
         "token_name":"digicur",
         "balance":100,
         "onhold_balance":0,
         "bapAccountVersion": 1
   },
   {
      "trxId":"9fd07fff222467e5667be042e33ce18e804b3e065cca15de306f837e416d7c3e",
      "timeStamp":1629718288,
      "value":{
         "assetType":"oaccount",
         "account_id":"oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f",
         "user_id":"user1",
         "org_id":"Org1MSP",
         "token_id":"digiCurr101",
         "token_name":"digicur",
         "balance":0,
         "onhold_balance":0,
         "bapAccountVersion": 0
      }
   }
]
getAccountOnHoldBalance
このメソッドは、指定されたアカウントの保留残高を返します。
Ctx.Account.getAccountOnHoldBalance(account_id: string)
パラメータ:
  • account_id: string – アカウントのID。
戻り値:
  • 成功の場合、指定したアカウントの保留残高を表示するJSONオブジェクトを含むpromise。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
   "holding_balance":0,
   "msg":"Total Holding Balance of Account Id oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f (org_id: Org1MSP, user_id: user1) is 0"
}
getAllAccounts
このメソッドは、すべてのアカウントのリストを返します。このメソッドでは、Berkeley DB SQLリッチ問合せが使用され、リモートOracle Blockchain Platformネットワークに接続されている場合にのみコールできます。
Ctx.Account.getAllAccounts()
パラメータ:
  • なし
戻り値:
  • 成功の場合、すべてのアカウントをリストするJSONオブジェクトを含むpromise。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
[
           {
               "key": "oaccount~digicur~2e2ef3375ae347cbd7b4d3d7be5cece803f9c36a184aaf2b8d332c5d2dcead52",
               "valueJson": {
                   "assetType": "oaccount",
                   "account_id": "oaccount~digicur~2e2ef3375ae347cbd7b4d3d7be5cece803f9c36a184aaf2b8d332c5d2dcead52",
                   "user_id": "admin",
                   "org_id": "Org1MSP",
                   "token_id": "digiCurr101",
                   "token_name": "digicur",
                   "bapAccountVersion": 0,
                   "balance": 0,
                   "onhold_balance": 0
               }
           },
           {
               "key": "oaccount~digicur~30080c7e5ba94035af57fbbccbbb495e92515e4b2b3dbcd476eb1c0343e4da65",
               "valueJson": {
                   "assetType": "oaccount",
                   "account_id": "oaccount~digicur~30080c7e5ba94035af57fbbccbbb495e92515e4b2b3dbcd476eb1c0343e4da65",
                   "bapAccountVersion": 0,
                   "user_id": "user1",
                   "org_id": "Org1MSP",
                   "token_id": "digiCurr101",
                   "token_name": "digicur",
                   "balance": 0,
                   "onhold_balance": 0
               }
           },
           {
               "key": "oaccount~digicur~cbde438258cb01a82f71a9a9f8029243c40c6d836a505432120529c2b3c2ff0c",
               "valueJson": {
                   "assetType": "oaccount",
                   "account_id": "oaccount~digicur~cbde438258cb01a82f71a9a9f8029243c40c6d836a505432120529c2b3c2ff0c",
                   "bapAccountVersion": 0,
                   "user_id": "user2",
                   "org_id": "Org1MSP",
                   "token_id": "digiCurr101",
                   "token_name": "digicur",
                   "balance": 0,
                   "onhold_balance": 0
               }
           },
           {
               "key": "oaccount~digicur~ecbc3aefcc562d3049c988717940195b30297e95012b7824bbd33a57ca50a626",
               "valueJson": {
                   "assetType": "oaccount",
                   "account_id": "oaccount~digicur~ecbc3aefcc562d3049c988717940195b30297e95012b7824bbd33a57ca50a626",
                   "bapAccountVersion": 0,
                   "user_id": "user3",
                   "org_id": "Org1MSP",
                   "token_id": "digiCurr101",
                   "token_name": "digicur",
                   "balance": 500,
                   "onhold_balance": 0
               }
           }
       ]
getUserByAccountId
このメソッドは、指定されたアカウントのユーザー詳細を返します。
Ctx.Account.getUserByAccountId(account_id: string)
パラメータ:
  • account_id: string – アカウントのID。
戻り値:
  • 成功の場合、3つのプロパティを含むJSONオブジェクトを含むpromise:
    • user_id – ユーザーのユーザー名または電子メールID。
    • org_id – 現在のネットワーク組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
    • token_id – トークンのID。
  • エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
   "token_id": "digiCurr101",
   "user_id": "user1",
   "org_id": "Org1MSP"
}
getAccountBalance
このメソッドは、指定されたアカウントのアカウント残高を返します。
Ctx.Account.getAccountBalance(account_id: string)
パラメータ:
  • account_id: string – アカウントのID。
戻り値:
  • 成功の場合、2つのプロパティを含むJSONオブジェクトを含むpromiseメッセージ:
    • msg– 現在の残高を示すメッセージ。
    • user_balance– 現在の残高の数値。
  • エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
    "msg": "Current Balance is: 200",
    "user_balance": 200
}
getAllOrgAccounts
このメソッドは、指定された組織に属するすべてのトークン・アカウントのリストを返します。
Ctx.Account.getAllOrgAccounts(org_id: string) 
パラメータ:
  • org_id: string – 組織のメンバーシップ・サービス・プロバイダ(MSP) ID。
戻り値:
  • 成功の場合、指定した組織のすべてのアカウントのリスト。
戻り値の例:
[
    {
        "key": "oaccount~2de8db6b91964f8c9009136831126d3cfa94e1d00c4285c1ea3e6d1f36479ed4",
        "valueJson": {
            "bapAccountVersion": 0,
            "assetType": "oaccount",
            "account_id": "oaccount~2de8db6b91964f8c9009136831126d3cfa94e1d00c4285c1ea3e6d1f36479ed4",
            "user_id": "idcqa",
            "org_id": "appdev",
            "token_type": "fungible",
            "token_id": "token",
            "token_name": "fiatmoneytok",
            "balance": 0,
            "onhold_balance": 0
        }
    },
    {
        "key": "oaccount~620fcf5deb5fd5a65c0b5b10fda129de0f629ccd232c5891c130e24a574df50a",
        "valueJson": {
            "bapAccountVersion": 0,
            "assetType": "oaccount",
            "account_id": "oaccount~620fcf5deb5fd5a65c0b5b10fda129de0f629ccd232c5891c130e24a574df50a",
            "user_id": "example_minter",
            "org_id": "appdev",
            "token_type": "fungible",
            "token_id": "token",
            "token_name": "fiatmoneytok",
            "balance": 0,
            "onhold_balance": 0
        }
    }
]

ロール管理のメソッド

addRoleMember
このメソッドは、指定されたユーザーおよびトークンにロールを追加します。
Ctx.Token.addRoleMember(role: string, account_id: string, token: <Instance of Token Class>)
パラメータ:
  • role: string – 指定したユーザーに追加するロールの名前。mintableおよびburnableの動作は、仕様ファイルのminter_role_nameおよびburner_role_nameプロパティに対応します。同様に、notaryロールは、仕様ファイルのnotary_role_nameプロパティに対応します。
  • account_id: number – ロールを追加するアカウントID。
  • token: <Instance of Token Class> – 操作するトークン・アセット。
戻り値:
  • 成功の場合、成功メッセージを含むpromise。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
    "msg":"Successfully added role minter to oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f (org_id :          Org1MSP, user_id : user1)"
}
removeRoleMember
このメソッドは、指定されたユーザーおよびトークンからロールを削除します。
Ctx.Token.removeRoleMember(role: string, account_id: string, token: <Instance of Token Class>)
パラメータ:
  • role: string – 指定したユーザーから削除するロールの名前。mintableおよびburnableの動作は、仕様ファイルのminter_role_nameおよびburner_role_nameプロパティに対応します。同様に、notaryロールは、仕様ファイルのnotary_role_nameプロパティに対応します。
  • account_id: number – ロールを削除するアカウントID。
  • token: <Instance of Token Class> – 操作するトークン・アセット。
戻り値:
  • 成功の場合、成功メッセージを含むpromise。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
  "msg":"successfully removed member_id oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f (org_id : Org1MSP, user_id : user1) from role minter"
}
getAccountsByRole
このメソッドは、指定されたロールおよびトークンのすべてのアカウントのリストを返します。
Ctx.Role.getAccountsByRole(token_id: string, role: string)
パラメータ:
  • token_id: string – トークンのID。
  • role: string – 検索するロールの名前。
戻り値:
  • 成功の場合、指定されたロールおよびトークンのすべてのアカウントをリストするJSONオブジェクトを含むpromise。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
    "accounts": [
        "oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df",
        "oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f"
    ]
}
getAccountsByUser
このメソッドは、指定されたユーザーのすべてのアカウントIDのリストを返します。
async getAccountsByUser(org_id: string, user_id: string)
パラメータ:
  • org_id string – 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • user_id string – ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功の場合、アカウントIDのJSON配列。
戻り値の例:
{"accounts":["oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f"]}
getUsersByRole
このメソッドは、指定されたロールおよびトークンのすべてのユーザーのリストを返します。
Ctx.Role.getUsersByRole(token_id: string, role: string)
パラメータ:
  • token_id: string – トークンのID。
  • role: string – 検索するロールの名前。
戻り値:
  • 成功の場合、指定されたロールおよびトークンのすべてのユーザーをリストするJSONオブジェクトを含むpromise。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
   "users":[
      {
         "token_id":"digiCurr101",
         "user_id":"user1",
         "org_id":"Org1MSP"
      }
   ]
}
isInRole
このメソッドは、ユーザーおよびトークンに指定されたロールがあるかどうかを示します。
Ctx.Token.isInRole(role: string, account_id: string, token: <Instance of Token Class>)
パラメータ:
  • role: string – チェックするロールの名前。
  • account_id: number– チェックするアカウントID。
  • token: <Instance of Token Class> – 操作するトークン・アセット。
戻り値:
  • 成功の場合、ユーザーに役割がある場合はtrue、ユーザーに役割がない場合はfalseのpromise。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{"result":"true"}
getOrgAccountsByRole
このメソッドは、指定された組織内の指定されたロールを持つすべてのアカウントに関する情報を返します。
Ctx.Role.getOrgAccountsByRole(token_id: string, role: string, org_id: string)
パラメータ:
  • token_id: string – トークンのID。
  • role: string – チェックするロールの名前。
  • org_id: string – 組織のメンバーシップ・サービス・プロバイダ(MSP) ID。
戻り値:
  • 成功の場合、指定した組織内の指定したロールを持つすべてのアカウントのリスト。
戻り値の例:
{
    "accounts": [
        "oaccount~abc74791148b761352b98df58035601b6f5480448ac2b4a3a7eb54bdbebf48eb",
        "oaccount~9c650574af9025a6106c8d12a801b079eda9ae2e3399fc2fbd5bd683d738a850"
    ]
}
getOrgUsersByRole
このメソッドは、指定された組織内の指定されたロールを持つすべてのユーザーに関する情報を返します。
Ctx.Role.getOrgUsersByRole(token_id: string, role: string, org_id: string)
パラメータ:
  • token_id: string – トークンのID。
  • role: string – チェックするロールの名前。
  • org_id: string – 組織のメンバーシップ・サービス・プロバイダ(MSP) ID。
戻り値:
  • 成功の場合、指定した組織内の指定したロールを持つすべてのユーザーのリスト。
戻り値の例:
{
    "users": [
        {
            "token_id": "token",
            "user_id": "admin",
            "org_id": "Org1MSP"
        },
        {
            "token_id": "token",
            "user_id": "orgAdmin",
            "org_id": "Org1MSP"
        }
    ]
}
roleCheck
このメソッドは、指定されたアカウントIDがいずれかのロールのメンバーかどうかをチェックします。
Ctx.Token.roleCheck(account_id: string, token: <Instance of Token Class>)
パラメータ:
  • account_id: string– チェックするアカウントID。
  • token: <Instance of Token Class> – 操作するトークン・アセット。
戻り値:
  • アカウントIDがいずれかのロールの一部である場合は、trueを返します。それ以外の場合は、falseを戻します。
戻り値の例:
{ result: true }

トランザクション履歴管理のメソッド

getAccountTransactionHistory
このメソッドは、指定されたアカウントのトランザクション履歴詳細の配列を返します。
Ctx.Account.getAccountTransactionHistory(account_id: string)
パラメータ:
  • account_id: string – アカウントのID。
戻り値:
  • 戻り値は、getAccountTransactionHistoryメソッドと同じです。
  • 成功の場合、アカウント・トランザクション・オブジェクトの配列を含むpromise:
    • transaction_id – トランザクションのID。
    • transacted_account – トランザクションが発生したアカウント。
    • transaction_type – トランザクションのタイプ。
    • transacted_amount – トランザクションの金額。
    • timestamp – トランザクションの時間。
    • balance – トランザクション時のアカウント残高。
    • onhold_balance – トランザクション時の保留残高。
    • sub_transactions– 一括転送の場合のみ、一括転送の一部であるトランザクションのリスト。
    • holding_idholdTokensメソッドによって返される一意の識別子。
    • token_id – トークンのID。
  • エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
[
   {
      "transaction_id":"otransaction~68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775",
      "transacted_amount":20,
      "timestamp":"2021-08-17T06:04:24.000Z",
      "balance":60,
      "onhold_balance":0,
      "token_id":"digiCurr101",
      "transaction_type":"BULKTRANSFER",
      "sub_transactions":[
         {
            "transacted_account":"oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df",
            "transaction_type":"CREDIT",
            "transaction_id":"otransaction~68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775~c4ca4238a0b923820dcc509a6f75849b",
            "transacted_amount":10
         }
      ]
   },
   {
      "transaction_id":"otransaction~757864d5369bd0539d044caeb3bb4898db310fd7aa740f45a9938771903d43da",
      "transacted_amount":50,
      "timestamp":"2021-08-17T06:02:44.000Z",
      "balance":50,
      "onhold_balance":0,
      "token_id":"digiCurr101",
      "transacted_account":"oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df",
      "transaction_type":"CREDIT"
   }
]
getAccountTransactionHistoryWithFilters
このメソッドは、指定されたアカウントのトランザクション履歴詳細の配列を返します。このメソッドは、リモートOracle Blockchain Platformネットワークに接続されている場合にのみコールできます。
await this.Ctx.Account.getAccountTransactionHistoryWithFilters(account_id: string, filters?: Filters)
パラメータ:
  • account_id: string – アカウントのID。
  • filters: string – オプション・パラメータ。空の場合は、すべてのレコードが返されます。PageSizeプロパティは、返すレコード数を決定します。PageSizeが0の場合、デフォルトのページ・サイズは20です。Bookmarkプロパティは、返されるレコードの開始索引を決定します。詳細は、Hyperledger Fabricのドキュメントを参照してください。StartTimeおよびEndTimeプロパティは、RFC-3339形式で指定する必要があります。
次に例を示します:

ochain invoke getAccountTransactionHistoryWithFilters 'token1' 'appbuilder12' 'user_minter' '{"PageSize":10,"Bookmark":"1","StartTime":"2022-01-25T17:41:42Z","EndTime":"2022-01-25T17:59:10Z"}'

[
    {
        "transaction_id": "otransaction~672897b5a4fa78b421c000e4d6d4f71f3d46529bfbb5b4be10bf5471dc35ce89",
        "transacted_amount": 5,
        "timestamp": "2022-04-20T15:46:04.000Z",
        "token_id": "token1",
        "transacted_account": "oaccount~16c38d804413ebabf416360d374f76c973d4e71c74adfde73cc40c7c274883b8",
        "transaction_type": "DEBIT",
        "balance": 90,
        "onhold_balance": 0
    },
    {
        "transaction_id": "otransaction~467bb67a33aaffca4487f33dcd46c9844efdb5421a2e7b6aa2d53152eb2c6d85",
        "transacted_amount": 5,
        "timestamp": "2022-04-20T15:45:47.000Z",
        "token_id": "token1",
        "transacted_account": "oaccount~fbf95683b21bbc91a22205819ac1e2e9c90355d536821ed3fe22b7d23915c248",
        "transaction_type": "DEBIT",
        "balance": 95,
        "onhold_balance": 0
    },
    {
        "transaction_id": "otransaction~c6d56ce54a9bbe24597d1d10448e39316dc6f16328bf3c5b0c8ef10e1dfeb397",
        "transacted_amount": 100,
        "timestamp": "2022-04-20T15:44:26.000Z",
        "token_id": "token1",
        "transacted_account": "oaccount~deb5fb0906c40506f6c2d00c573b774e01a53dd91499e651d92ac4778b6add6a",
        "transaction_type": "MINT",
        "balance": 100,
        "onhold_balance": 0
    }
]
getSubTransactionHistory
このメソッドは、指定されたトランザクションのトランザクション履歴詳細の配列を返します。
await this.Ctx.Account.getSubTransactionHistory(transaction_id)
パラメータ:
  • transaction_id: string – 一括転送トランザクションのID。
次に例を示します:

ochain invoke GetAccountSubTransactionHistory 'otransaction~21972b4d206bd52ea77924efb259c67217edb23b4386580d1bee696f6f864b9b'

[
    {
        "transacted_account": "oaccount~16c38d804413ebabf416360d374f76c973d4e71c74adfde73cc40c7c274883b8",
        "transaction_type": "DEBIT",
        "transaction_id": "otransaction~6e0f8fe4a6430322170b9c619b04b6c9f1c8d257923f611b866bdf69d7fe6cb8~c81e728d9d4c2f636f067f89cc14862c",
        "transacted_amount": 5,
        "timestamp": "2022-04-20T15:52:21.000Z",
        "token_id": "token1",
        "balance": 80,
        "onhold_balance": 0
    },
    {
        "transacted_account": "oaccount~fbf95683b21bbc91a22205819ac1e2e9c90355d536821ed3fe22b7d23915c248",
        "transaction_type": "DEBIT",
        "transaction_id": "otransaction~6e0f8fe4a6430322170b9c619b04b6c9f1c8d257923f611b866bdf69d7fe6cb8~c4ca4238a0b923820dcc509a6f75849b",
        "transacted_amount": 5,
        "timestamp": "2022-04-20T15:52:21.000Z",
        "token_id": "token1",
        "balance": 85,
        "onhold_balance": 0
    }
]
getSubTransactionHistoryWithFilters
このメソッドは、指定されたトランザクションのサブトランザクション履歴詳細の配列を返します。
await this.Ctx.Account.getSubTransactionHistoryWithFilters(transaction_id: string, filters?: SubTransactionFilters)
パラメータ:
  • transaction_id: string – 一括転送トランザクションのID。
  • filters: string – オプション・パラメータ。空の場合は、すべてのレコードが返されます。PageSizeプロパティは、返すレコード数を決定します。PageSizeが0の場合、デフォルトのページ・サイズは20です。Bookmarkプロパティは、返されるレコードの開始索引を決定します。詳細は、Hyperledger Fabricのドキュメントを参照してください。StartTimeおよびEndTimeプロパティは、RFC-3339形式で指定する必要があります。
次に例を示します:

ochain invoke GetAccountSubTransactionHistoryWithFilters 'otransaction~21972b4d206bd52ea77924efb259c67217edb23b4386580d1bee696f6f864b9b' '{"PageSize":10,"Bookmark":"1"}'

[
    {
        "transaction_id": "otransaction~6e0f8fe4a6430322170b9c619b04b6c9f1c8d257923f611b866bdf69d7fe6cb8~c81e728d9d4c2f636f067f89cc14862c",
        "transacted_amount": 5,
        "timestamp": "2022-04-20T15:52:21.000Z",
        "token_id": "token1",
        "transacted_account": "oaccount~16c38d804413ebabf416360d374f76c973d4e71c74adfde73cc40c7c274883b8",
        "transaction_type": "DEBIT",
        "balance": 80,
        "onhold_balance": 0
    },
    {
        "transaction_id": "otransaction~6e0f8fe4a6430322170b9c619b04b6c9f1c8d257923f611b866bdf69d7fe6cb8~c4ca4238a0b923820dcc509a6f75849b",
        "transacted_amount": 5,
        "timestamp": "2022-04-20T15:52:21.000Z",
        "token_id": "token1",
        "transacted_account": "oaccount~fbf95683b21bbc91a22205819ac1e2e9c90355d536821ed3fe22b7d23915c248",
        "transaction_type": "DEBIT",
        "balance": 85,
        "onhold_balance": 0
    }
]
getTransactionById
このメソッドは、Transactionアセットの履歴を返します。
async getTransactionById(transaction_id: string)
パラメータ:
  • transaction_id: string– トランザクション・アセットのID。
戻り値:
  • 成功の場合、トランザクション・アセットの履歴。
戻り値の例:
{
    "transaction_id": "otransaction~68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775",
    "history": [
        {
            "trxId": "68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775",
            "timeStamp": 1629180264,
            "value": {
                "assetType": "otransaction",
                "transaction_id": "otransaction~68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775",
                "token_id": "digiCurr101",
                "from_account_id": "oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df",
                "to_account_id": "",
                "transaction_type": "BULKTRANSFER",
                "amount": 20,
                "timestamp": "2021-08-17T06:04:24.000Z",
                "number_of_sub_transactions": 2,
                "holding_id": ""
            }
        }
    ],
    "sub_transactions": [
        {
            "transaction_id": "otransaction~68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775~c4ca4238a0b923820dcc509a6f75849b",
            "history": [
                {
                    "trxId": "68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775",
                    "timeStamp": 1629180264,
                    "value": {
                        "assetType": "otransaction",
                        "transaction_id": "otransaction~68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775~c4ca4238a0b923820dcc509a6f75849b",
                        "token_id": "digiCurr101",
                        "from_account_id": "oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df",
                        "to_account_id": "oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f",
                        "transaction_type": "TRANSFER",
                        "amount": 10,
                        "timestamp": "2021-08-17T06:04:24.000Z",
                        "number_of_sub_transactions": 0,
                        "holding_id": ""
                    }
                }
            ]
        },
        {
            "transaction_id": "otransaction~68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775~c81e728d9d4c2f636f067f89cc14862c",
            "history": [
                {
                    "trxId": "68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775",
                    "timeStamp": 1629180264,
                    "value": {
                        "assetType": "otransaction",
                        "transaction_id": "otransaction~68f46c90d0d8d6b93d827e6b9e0152b4845e6e42a61965e63a9bbf1d8e0fc775~c81e728d9d4c2f636f067f89cc14862c",
                        "token_id": "digiCurr101",
                        "from_account_id": "oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df",
                        "to_account_id": "oaccount~digicur~38848e87296d67c8a90918f78cf55f9c9baab2cdc8c928535471aaa1210c706e",
                        "transaction_type": "TRANSFER",
                        "amount": 10,
                        "timestamp": "2021-08-17T06:04:24.000Z",
                        "number_of_sub_transactions": 0,
                        "holding_id": ""
                    }
                }
            ]
        }
    ]
}
deleteHistoricalTransactions
このメソッドは、指定されたアカウントのトランザクション履歴詳細の配列を返します。
async deleteHistoricalTransactions(time_to_expiration: Date)
パラメータ:
  • time_to_expiration: Date – トランザクションを削除するタイミングを示すタイムスタンプ。指定した時間より古いトランザクション・アセットが削除されます。
戻り値:
  • 戻り値は、getAccountTransactionHistoryメソッドと同じです。
  • 成功の場合、アカウント・トランザクション・オブジェクトの配列を含むpromise:
    • transaction_id – トランザクションのID。
    • transacted_account – トランザクションが発生したアカウント。
    • transaction_type – トランザクションのタイプ。
    • transacted_amount – トランザクションの金額。
    • timestamp – トランザクションの時間。
    • balance – トランザクション時のアカウント残高。
    • onhold_balance – トランザクション時の保留残高。
    • sub_transactions– 一括転送の場合のみ、一括転送の一部であるトランザクションのリスト。
    • holding_idholdTokensメソッドによって返される一意の識別子。
    • token_id – トークンのID。
  • エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
"payload": {
            "msg": "Successfuly deleted transaction older than date: Thu Aug 19 2021 11:19:36 GMT+0000 (Coordinated Universal Time).",
            "transactions": [
                "otransaction~ec3366dd48b4ce2838f820f2f138648e6e55a07226713e59b411ff31b0d21058"
            ]
        }

トークン動作の管理

トークン・ライフサイクル管理方法は、トークン・タクソノミ・フレームワークの標準に基づいています。トークン・ライフサイクル・メソッドを使用するには、../lib/tokenモジュールからTokenクラスをインポートします。
import { Token } from '../lib/token';

トークン動作管理のメソッド- ミント可能動作

mint
このメソッドはある数量のトークンをミントします。その後、メソッドのコール元がそれらのトークンの所有になります。コール元には、アカウントとミンターのロールが必要です。数量は、仕様ファイルのdivisible動作のdecimalパラメータで指定された10進数値内にする必要があります。
Ctx.Token.mint(quantity: number, token: <Instance of Token Class>)
パラメータ:
  • quantity: number – ミントするトークンの合計数。
  • token: <Instance of Token Class> – ミントするトークン・アセット。
戻り値:
  • 成功の場合、成功メッセージとtoAccountの詳細を含むpromise。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
  "msg":"Successfully minted 1000 tokens to Account Id: oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df (Org-Id: Org1MSP, User-Id: admin)"
}
getTotalMintedTokens
このメソッドは、ミントされたトークンの合計数を返します。
Ctx.Token.getTotalMintedTokens(token: <Instance of Token Class>)
パラメータ:
  • token: <Instance of Token Class> – 操作するトークン・アセット。
戻り値:
  • 成功の場合、数値データ型のミントされたトークンの量。エラー時には、エラー・メッセージが返されます。
戻り値の例:
4000
getNetTokens
このメソッドは、システムで使用可能なトークンの正味数量を返します。正味トークンは、トークンのバーン後に残存するトークンの数量です。等式では、正味トークン = ミントされたトークンの合計 - バーンされたトークンの合計です。トークンがバーンされていない場合、正味トークン数は、ミントされたトークンの合計と等しくなります。
Ctx.Token.getNetTokens(token: <Instance of Token Class>)
パラメータ:
  • token: <Instance of Token Class> – 操作するトークン・アセット。
戻り値:
  • 成功の場合、数値データ型の正味トークン数量。エラー時には、エラー・メッセージが返されます。
戻り値の例:
2000
getMaxMintQuantity
このメソッドは、トークンの最大ミント可能量を返します。max_mint_quantity動作が指定されていない場合、デフォルト値は0で、任意の数のトークンをミントできます。
Ctx.Token.getMaxMintQuantity(token: <Instance of Token Class>)
パラメータ:
  • token: <Instance of Token Class> – 操作するトークン・アセット。
戻り値:
  • 成功の場合、トークンの最大ミント可能量(数値データ型)。エラー時には、エラー・メッセージが返されます。
戻り値の例:
20000

トークン動作管理のメソッド- 転送可能動作

transfer
このメソッドは、トークンをトランザクション・コール元からto_account_idアカウントに転送します。このメソッドのコール元にはアカウントが必要で、数量は仕様ファイルのdivisible動作のdecimalパラメータで指定された10進数値の範囲内である必要があります。
Ctx.Token.transfer(to_account_id: string, quantity: number, token: <Instance of Token Class>)
パラメータ:
  • to_account_id: string – トークンを受け取るアカウントID。
  • quantity: number – 転送するトークンの合計数。
戻り値:
  • 成功の場合、成功メッセージを含むpromise。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
 "msg":"Successfully transferred 50 tokens from account id: oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df (Org-Id: Org1MSP, User-Id: admin) to account id: oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f (Org-Id: Org1MSP, User-Id: user1)"
}
bulkTransfer
このメソッドは、トークンを呼出し元アカウントからflowオブジェクトで指定されたアカウントに一括で転送します。このメソッドのコール元には、すでにアカウントが作成されている必要があります。
Ctx.Token.bulkTransfer(flow: object[], token: <Instance of Token Class>)
パラメータ:
  • flow: object[] – 受信者の詳細および数量を指定するJSONオブジェクトの配列。数量は、仕様ファイルのdivisible動作のdecimalパラメータで指定された10進数値内にする必要があります。たとえば:
    [{
    	"to_org_id": "Org1MSP",
    	"to_user_id": "user1",
    	"quantity": 10
    }, {
    	"to_org_id": "Org1MSP",
    	"to_user_id": "user2",
    	"quantity": 10
    }]
  • token: <Instance of Token Class> – 操作するトークン・アセット。
戻り値:
  • 成功の場合、成功メッセージとアカウント情報を含むpromise。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
    "from_account_id": "oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f",
    "msg": "Successfully transferred 2 tokens from Account Id oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f (Org-Id: Org1MSP, User-Id: user1)",
    "sub_transactions": [
        {
            "amount": 1,
            "to_account_id": "oaccount~digicur~38848e87296d67c8a90918f78cf55f9c9baab2cdc8c928535471aaa1210c706e"
        },
        {
            "amount": 1,
            "to_account_id": "oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df"
        }
    ]
}

トークン動作管理メソッド- 保留可能動作

hold
このメソッドは、to_account_idアカウントを持つトークンの所有者のかわりに保留を作成します。保留の完了または解除を担当する公証人アカウントが指定されます。保留が作成されると、支払者から指定されたトークン残高が保留になります。保留残高は、保留が完了または解除されるまで転送できません。このメソッドのコール元には、すでにアカウントが作成されている必要があります。
Ctx.Token.hold(operation_id: string, to_account_id: string, notary_account_id: string, quantity: number, time_to_expiration: Date, token: <Instance of Token Class>)
パラメータ:
  • operation_id: string – 保留操作を識別する一意のID。通常、このIDはクライアント・アプリケーションによって渡されます。
  • to_account_id: string – トークンを受け取るアカウントのID。
  • notary__account_id: string– 公証人アカウントのID。
  • quantity: number – 保留にするトークンの合計数。
  • time_to_expiration: Date – 保留が期限切れになるまでの期間。永続的な保留の場合は0を指定します。それ以外の場合は、RFC-3339形式を使用します。たとえば、2021-06-02T12です。
  • token: <Instance of Token Class> – 保持するトークン・アセット。
戻り値:
  • 成功の場合、成功メッセージを含むpromise。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
 "msg": "account id: oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df (org_id : Org1MSP, user_id : user1) is successfully holding 10 tokens",
}
executeHold
このメソッドはトークンの保留を完了し、以前に保留にされていたトークンの指定数量を受信者に転送します。quantity値が実際の保留値より小さい場合、残りはトークンの元の所有者が再度使用できます。このメソッドは、指定された操作IDのnotaryロールを持つAccountOwner IDのみがコールできます。保留は公証人のみが完了できます。
Ctx.Token.executeHold(operation_id: string, quantity: number, token: <Instance of Token Class>)
パラメータ:
  • operation_id: string – 保留操作を識別する一意のID。通常、このIDはクライアント・アプリケーションによって渡されます。
  • quantity: number – 保留を完了するトークンの合計数。
  • token: <Instance of Token Class> – 保留を完了するトークン・アセット。
戻り値:
  • 成功の場合、成功メッセージを含むpromise。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
 "msg": "user with accountId: oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df (org_id : Org1MSP, user_id : user1) has successfully executed 5  tokens(digiCurr101) from the hold with Operation Id opr_121",
}
releaseHold
このメソッドは、トークンの保留を解除します。転送は行われず、すべての保留トークンは元の所有者が再度使用できます。このメソッドは、指定された時間制限内はnotaryロールを持つAccountOwner IDが、指定された時間制限後は支払者、受取人または公証員がコールできます。
Ctx.Token.releaseHold(operation_id: string, token: <Instance of Token Class>)
パラメータ:
  • operation_id: string – 保留操作を識別する一意のID。通常、このIDはクライアント・アプリケーションによって渡されます。
  • token: <Instance of Token Class> – 保留を解除するトークン・アセット。
戻り値:
  • 成功の場合、成功メッセージを含むpromise。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
  "msg": "Successfully released 5 tokens from Operation Id opr_121 to Account Id: oaccount~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df (org_id : Org1MSP, user_id : user1)",
}
getOnHoldIds
このメソッドは、指定されたアカウントのすべての保留IDのリストを返します。
Ctx.Account.getOnHoldIds(account_id: string)
パラメータ:
  • account_id: string – アカウントのID。
戻り値:
  • 成功の場合、指定されたアカウントのすべての保留IDをリストするJSONオブジェクトを含むpromise。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
   "msg":"Holding Ids are: ohold~digicur~digiCurr101~opr_121",
   "holding_ids":[
      "ohold~digicur~digiCurr101~opr_121"
   ]
}
getOnHoldDetailsWithOperationId
このメソッドは、指定された操作IDおよびトークンの保留トランザクション詳細を返します。
Ctx.Hold.getOnHoldDetailsWithOperationId(token_id: string, operation_id: string)
パラメータ:
  • token_id: string – トークンのID。
  • operation_id: string – 保留操作を識別する一意のID。通常、このIDはクライアント・アプリケーションによって渡されます。
戻り値:
  • 成功の場合、次のプロパティを含む保留オブジェクト:
    • holding_id – トランザクションの保留ID。
    • operation_id: string – 保留操作を識別する一意のID。通常、このIDはクライアント・アプリケーションによって渡されます。
    • from_account_id – 保留トークンの現在の所有者のアカウントID。
    • to_account_id – 受信者のアカウントID。
    • notary_account_id – 公証人のアカウントID。
    • token_id: string– 保存されたトークンのID。
    • quantity – 保留IDに対して保留されているトークンの量。
    • time_to_expiration– 保留が期限切れになるまでの期間。
  • エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
    "assetType": "ohold",
    "holding_id": "ohold~digicur~digiCurr101~opr_121",
    "operation_id": "opr_121",
    "token_name": "digicur",
    "from_account_id": "oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df",
    "to_account_id": "oaccount~digicur~b4f45440aa2a7942db64443d047027e9d714d62cba5c3d546d64f368642f622f",
    "notary_account_id": "oaccount~digicur~38848e87296d67c8a90918f78cf55f9c9baab2cdc8c928535471aaa1210c706e",
    "token_id": "digiCurr101",
    "quantity": 10,
    "time_to_expiration": "2022-08-01T18:30:00.000Z"
}
getOnHoldBalanceWithOperationId
このメソッドは、指定された操作IDおよびトークンの保留残高を返します。このメソッドは、だれでも呼び出すことができます。
Ctx.Hold.getOnHoldBalanceWithOperationId(token_id: string, operation_id: string)
パラメータ:
  • token_id: string – トークンのID。
  • operation_id: string – 保留操作を識別する一意のID。通常、このIDはクライアント・アプリケーションによって渡されます。
戻り値:
  • 成功の場合、指定した操作IDおよびトークンの保留残高を含むpromiseオブジェクト。エラーの場合、エラーメッセージ付きの拒否
戻り値の例:
{
    "msg": "Current Holding Balance of Operation 'op1' for token 'token1' is: 10",
    "holding_balance": 10
}

トークン動作管理のメソッド- バーン可能動作

burn
このメソッドは、トランザクション・コール元のアカウントからトークンを非アクティブ化またはバーンします。このメソッドのコール元には、アカウントとバーナー・ロールが必要です。数量は、仕様ファイルのdivisible動作のdecimalパラメータで指定された10進数値内にする必要があります。
Ctx.Token.burn(quantity: number, token: <Instance of Token Class>)
パラメータ:
  • quantity: number – バーンするトークンの合計数。
  • token: <Instance of Token Class> – バーンするトークン・アセット。
戻り値:
  • 成功の場合、成功メッセージを含むpromise。エラーの場合、エラー・メッセージ付きの拒否。
戻り値の例:
{
 "msg":"Successfully burned 10 tokens from account id: oaccount~digicur~682bb71de419602af74e3f226345ae308445ca51010737900c1d85f0376152df (Org-Id: Org1MSP, User-Id: admin)"
}