ERC-1155トークン・アカウント・ステータスのGoメソッド

ブロックチェーン・アプリケーション・ビルダーは、拡張ERC-1155標準を使用するトークンのアカウント・ステータスを管理するために使用できるメソッドを自動的に生成します。

次の方法を使用して、トークン・ユーザー・アカウントをアクティブ、一時停止または削除された状態に設定できます。

アカウントが一時停止されると、アカウント・ユーザーは書込み操作を完了できません。これには、トークンのマイニング、書込みおよび転送が含まれます。また、他のユーザーはトークンを中断されたアカウントに転送できません。中断されたアカウントは、引き続き読取り操作を完了できます。

トークン残高がゼロ以外のアカウントは削除できません。アカウントを削除する前に、アカウント内のすべてのトークンを転送または書き込む必要があります。アカウントが削除済状態になると、アカウントの状態をアクティブまたは一時停止に戻すことはできません。

自動生成された勘定科目ステータス方法

GetAccountStatus
このメソッドは、トークン・アカウントの現在のステータスを取得します。このメソッドは、チェーンコードのToken Adminまたはトークン・アカウント所有者によってコールできます。
func (t *Controller) GetAccountStatus(orgId string, userId string, tokenId ...string) (interface{}, error) {
      userAccountId, err := t.Ctx.ERC1155Account.GenerateAccountId(orgId, userId, constants.UserAccount)
      if err != nil {
            return nil, fmt.Errorf("error in getting the generating accountId of (Org-Id: %s, User-Id: %s)", orgId, userId)
      }
      auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155AccountStatus.Get", "TOKEN", map[string]string{"accountId": userAccountId})
      if err != nil && !auth {
            return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
      }
      tokenAccount, err := t.Ctx.ERC1155Account.Get(userAccountId, tokenId...)
      if err != nil {
            return nil, fmt.Errorf("error in GetAccountStatus. Error: %s", err)
      }
      tokenAccountId, err := util.GetAccountProperty(tokenAccount, constants.AccountId)
      accountStatus, err := t.Ctx.ERC1155AccountStatus.GetAccountStatus(tokenAccountId)
      if err != nil {
            return t.Ctx.ERC1155AccountStatus.GetDefaultAccountStatus(tokenAccountId)
      }
      return accountStatus, nil
}
パラメータ:
  • orgId: string - 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • userId: string - ユーザーのユーザー名または電子メールID。
  • tokenId ...string - 真でないトークン・アカウントの場合、空の文字列。楽しいトークン・アカウントの場合は、トークンID。
戻り値:
  • 成功すると、トークン・アカウント・ステータスのJSON表現。アカウント・ステータス機能が使用可能になる前にアカウントが作成されたためにアカウントの元帳にステータスが見つからない場合、ステータスはレスポンスでactiveとしてリストされます。
戻り値の例:
{
    "AssetType": "oaccountStatus",
    "StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
    "AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
    "Status": "active"
}
GetAccountStatusHistory
このメソッドは、アカウント・ステータスの履歴を取得します。このメソッドは、チェーンコードのToken Adminまたはトークン・アカウント所有者によってコールできます。
func (t *Controller) GetAccountStatusHistory(orgId string, userId string, tokenId ...string) (interface{}, error) {
      userAccountId, err := t.Ctx.ERC1155Account.GenerateAccountId(orgId, userId, constants.UserAccount)
      if err != nil {
            return nil, fmt.Errorf("error in getting the generating accountId of (Org-Id: %s, User-Id: %s)", orgId, userId)
      }
      auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155AccountStatus.Get", "TOKEN", map[string]string{"accountId": userAccountId})
      if err != nil && !auth {
            return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
      }
      tokenAccount, err := t.Ctx.ERC1155Account.Get(userAccountId, tokenId...)
      if err != nil {
            return nil, fmt.Errorf("error in GetAccountStatusHistory. Error: %s", err)
      }
      tokenAccountId, err := util.GetAccountProperty(tokenAccount, constants.AccountId)
      statusId, err := t.Ctx.ERC1155AccountStatus.GenerateAccountStatusId(tokenAccountId)
      if err != nil {
            return nil, err
      }
      accountStatusHistory, err := t.Ctx.ERC1155AccountStatus.History(statusId)
      if err != nil {
            return []map[string]interface{}{}, nil
      }
      return accountStatusHistory, nil
}
パラメータ:
  • orgId: string - 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • userId: string - ユーザーのユーザー名または電子メールID。
  • tokenId ...string - 真でないトークン・アカウントの場合、空の文字列。楽しいトークン・アカウントの場合は、トークンID。
戻り値:
  • 成功すると、JSON形式のアカウント・ステータス履歴が表示されます。
戻り値の例:
[
  {
    "IsDelete": "false",
    "Timestamp": "2022-12-02T16:20:34+05:30",
    "TxId": "af1601c7a14b4becf4bb3b285d85553b39bf234caaf1cd488a284a31a2d9df78",
    "Value": {
      "AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
      "AssetType": "oaccountStatus",
      "Status": "suspended",
      "StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7"
    }
  },
  {
    "IsDelete": "false",
    "Timestamp": "2022-12-02T16:19:15+05:30",
    "TxId": "4b307b989063e43add5357ab110e19174d586b9746cc8a30c9aa3a2b0b48a34e",
    "Value": {
      "AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
      "AssetType": "oaccountStatus",
      "Status": "active",
      "StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7"
    }
  }
]
ActivateAccount
このメソッドは、トークン・アカウントをアクティブ化します。このメソッドは、チェーンコードのToken Adminによってのみコールできます。削除されたアカウントはアクティブ化できません。アカウント・ステータス機能が使用可能になる前に作成されたアカウントの場合は、このメソッドをコールして、アカウント・ステータスをactiveに設定する必要があります。
func (t *Controller) ActivateAccount(orgId string, userId string, tokenId ...string) (interface{}, error) {
    userAccountId, err := t.Ctx.ERC1155Account.GenerateAccountId(orgId, userId, constants.UserAccount)
    if err != nil {
        return nil, fmt.Errorf("error in getting the generating accountId of (Org-Id: %s, User-Id: %s)", orgId, userId)
    }
    auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155AccountStatus.ActivateAccount", "TOKEN")
    if err != nil && !auth {
        return nil, fmt.Errorf("error in authorizing the caller  %s", err.Error())
    }
    tokenAccount, err := t.Ctx.ERC1155Account.Get(userAccountId, tokenId...)
    if err != nil {
        return nil, fmt.Errorf("error in GetAccountTransactionHistory. Error: %s", err)
    }
    tokenAccountId, err := util.GetAccountProperty(tokenAccount, constants.AccountId)
    return t.Ctx.ERC1155Account.ActivateAccount(tokenAccountId)
}
パラメータ:
  • orgId: string - 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • userId: string - ユーザーのユーザー名または電子メールID。
  • tokenId ...string - 真でないトークン・アカウントの場合、空の文字列。楽しいトークン・アカウントの場合は、トークンID。
戻り値:
  • 成功すると、トークン・アカウント・ステータスのJSON表現。
戻り値の例:
{
    "AssetType": "oaccountStatus",
    "StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
    "AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
    "Status": "active"
}
SuspendAccount
このメソッドは、トークン・アカウントを一時停止します。このメソッドは、チェーンコードのToken Adminによってのみコールできます。アカウントが一時停止された後は、アカウントを更新する操作を完了できません。削除されたアカウントは一時停止できません。
func (t *Controller) SuspendAccount(orgId string, userId string, tokenId ...string) (interface{}, error) {
    userAccountId, err := t.Ctx.ERC1155Account.GenerateAccountId(orgId, userId, constants.UserAccount)
    if err != nil {
        return nil, fmt.Errorf("error in getting the generating accountId of (Org-Id: %s, User-Id: %s)", orgId, userId)
    }
    auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155AccountStatus.SuspendAccount", "TOKEN")
    if err != nil && !auth {
        return nil, fmt.Errorf("error in authorizing the caller  %s", err.Error())
    }
    tokenAccount, err := t.Ctx.ERC1155Account.Get(userAccountId, tokenId...)
    if err != nil {
        return nil, fmt.Errorf("error in GetAccountTransactionHistory. Error: %s", err)
    }
    tokenAccountId, err := util.GetAccountProperty(tokenAccount, constants.AccountId)
    return t.Ctx.ERC1155Account.SuspendAccount(tokenAccountId)
}
パラメータ:
  • orgId: string - 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • userId: string - ユーザーのユーザー名または電子メールID。
  • tokenId ...string - 真でないトークン・アカウントの場合、空の文字列。楽しいトークン・アカウントの場合は、トークンID。
戻り値:
  • 成功すると、トークン・アカウント・ステータスのJSON表現。
戻り値の例:
{
    "AssetType": "oaccountStatus",
    "StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
    "AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
    "Status": "suspended"
}
DeleteAccount
このメソッドはトークン・アカウントを削除します。このメソッドは、チェーンコードのToken Adminによってのみコールできます。アカウントの削除後は、アカウントを更新する操作を完了できません。削除されたアカウントは最終状態であり、他の状態に変更できません。勘定科目を削除するには、勘定科目残高がゼロである必要があります。
func (t *Controller) DeleteAccount(orgId string, userId string, tokenId ...string) (interface{}, error) {
    userAccountId, err := t.Ctx.ERC1155Account.GenerateAccountId(orgId, userId, constants.UserAccount)
    if err != nil {
        return nil, fmt.Errorf("error in getting the generating accountId of (Org-Id: %s, User-Id: %s)", orgId, userId)
    }
    auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155AccountStatus.DeleteAccount", "TOKEN")
    if err != nil && !auth {
        return nil, fmt.Errorf("error in authorizing the caller  %s", err.Error())
    }
    tokenAccount, err := t.Ctx.ERC1155Account.Get(userAccountId, tokenId...)
    if err != nil {
        return nil, fmt.Errorf("error in GetAccountTransactionHistory. Error: %s", err)
    }
    tokenAccountId, err := util.GetAccountProperty(tokenAccount, constants.AccountId)
    return t.Ctx.ERC1155Account.DeleteAccount(tokenAccountId)
}
パラメータ:
  • orgId: string - 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • userId: string - ユーザーのユーザー名または電子メールID。
  • tokenId ...string - 真でないトークン・アカウントの場合、空の文字列。楽しいトークン・アカウントの場合は、トークンID。
戻り値:
  • 成功すると、トークン・アカウント・ステータスのJSON表現。
戻り値の例:
{
    "AssetType": "oaccountStatus",
    "StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
    "AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
    "Status": "deleted"
}

アカウント・ステータスSDKメソッド

GetDefaultAccountStatus
このメソッドは、(アカウント・ステータス機能の前にアカウントが作成されたため)元帳にアカウント・ステータスがないアカウントのステータスがactiveであるトークン・アカウントの現在のステータスを取得します。
Ctx.GetDefaultAccountStatus(accountId string) (ERC1155AccountStatus, error)
パラメータ:
  • accountId: string - トークン・アカウントのID。
戻り値:
  • 成功すると、トークン・アカウント・ステータスのJSON表現。
戻り値の例:
{
      "AssetType": "oaccountStatus",
      "StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
      "AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
      "Status": "active"
}
GetAccountStatus
このメソッドは、トークン・アカウントの現在のステータスを取得します。
Ctx.ERC1155AccountStatus.GetAccountStatus(accountId string) (NFTAccountStatus, error)
パラメータ:
  • accountId: string - トークン・アカウントのID。
戻り値:
  • 成功すると、トークン・アカウント・ステータスのJSON表現。アカウント・ステータス機能が使用可能になる前にアカウントが作成されたためにアカウントの元帳にステータスが見つからない場合、ステータスはレスポンスでactiveとしてリストされます。
戻り値の例:
{
    "AssetType": "oaccountStatus",
    "StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
    "AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
    "Status": "active"
}
GetAccountStatusHistory
このメソッドは、アカウント・ステータスの履歴を取得します。
Ctx.ERC1155AccountStatus.History(statusId string) (interface{}, error)
パラメータ:
  • statusId: string - アカウント・ステータス・オブジェクトのID。
戻り値:
  • 成功した場合、アカウント・ステータス履歴のJSON表現。
戻り値の例:
[
  {
    "IsDelete": "false",
    "Timestamp": "2022-12-02T16:20:34+05:30",
    "TxId": "af1601c7a14b4becf4bb3b285d85553b39bf234caaf1cd488a284a31a2d9df78",
    "Value": {
      "AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
      "AssetType": "oaccountStatus",
      "Status": "suspended",
      "StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7"
    }
  },
  {
    "IsDelete": "false",
    "Timestamp": "2022-12-02T16:19:15+05:30",
    "TxId": "4b307b989063e43add5357ab110e19174d586b9746cc8a30c9aa3a2b0b48a34e",
    "Value": {
      "AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
      "AssetType": "oaccountStatus",
      "Status": "active",
      "StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7"
    }
  }
]
ActivateAccount
このメソッドは、トークン・アカウントをアクティブ化します。アカウント・ステータス機能が使用可能になる前に作成されたアカウントの場合は、このメソッドをコールして、アカウント・ステータスをactiveに設定する必要があります。
Ctx.ERC1155Account.ActivateAccount(tokenAccountId string) (interface{}, error)
パラメータ:
  • tokenAccountId: string - トークン・アカウントのID。
戻り値:
  • 成功すると、指定したトークン・アカウントのアカウント・ステータス・オブジェクトのJSON表現。
戻り値の例:
{
    "AssetType": "oaccountStatus",
    "StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
    "AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
    "Status": "active"
}
SuspendAccount
このメソッドは、トークン・アカウントを一時停止します。
Ctx.ERC1155Account.SuspendAccount(tokenAccountId string) (interface{}, error)
パラメータ:
  • tokenAccountId: string - トークン・アカウントのID。
戻り値:
  • 成功すると、指定したトークン・アカウントのアカウント・ステータス・オブジェクトのJSON表現。
戻り値の例:
{
    "AssetType": "oaccountStatus",
    "StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
    "AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
    "Status": "suspended"
}
DeleteAccount
このメソッドはトークン・アカウントを削除します。
Ctx.ERC1155Account.DeleteAccount(tokenAccountId string) (interface{}, error)
パラメータ:
  • tokenAccountId: string - トークン・アカウントのID。
戻り値:
  • 成功すると、指定したトークン・アカウントのアカウント・ステータス・オブジェクトのJSON表現。
戻り値の例:
{
    "AssetType": "oaccountStatus",
    "StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
    "AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
    "Status": "deleted"
}