ERC-1155 토큰 계정 상태에 대한 이동 방법

Blockchain App Builder는 확장 된 ERC-1155 표준을 사용하는 토큰의 계정 상태를 관리하는 데 사용할 수있는 방법을 자동으로 생성합니다.

다음 방법을 사용하여 토큰 사용자 계정을 활성, 일시 중지됨 또는 삭제됨 상태로 설정할 수 있습니다.

계정이 일시 중지되면 계정 사용자는 알림, 레코딩 및 전송 토큰을 포함하는 쓰기 작업을 완료할 수 없습니다. 또한 다른 사용자는 일시 중지된 계정으로 토큰을 전송할 수 없습니다. 일시 중지된 계정은 여전히 읽기 작업을 완료할 수 있습니다.

토큰 잔액이 0이 아닌 계정은 삭제할 수 없습니다. 계정을 삭제하려면 먼저 계정의 모든 토큰을 전송하거나 레코딩해야 합니다. 계정이 삭제된 상태이면 계정 상태를 다시 활성 또는 일시 중지됨으로 변경할 수 없습니다.

자동으로 생성된 계정 상태 방법

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로만 호출할 수 있습니다. 계정이 삭제된 후에는 계정 업데이트 작업을 완료할 수 없습니다. 삭제된 계정은 최종 상태이므로 다른 상태로 변경할 수 없습니다. 계정을 삭제하려면 계정 잔액이 0이어야 합니다.
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"
}