首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何通过Algorand TypeScript SDK获取帐户信息?

如何通过Algorand TypeScript SDK获取帐户信息?
EN

Stack Overflow用户
提问于 2022-08-08 10:52:41
回答 1查看 66关注 0票数 2

所以基本上我是想弄到账户信息。

方法:Algodv2accountInformation

返回AccountInformation类型,但在调用.do()之后

.i.e

代码语言:javascript
复制
Algodv2accountInformation.do()

返回类型是更通用的。

代码语言:javascript
复制
<Promise<Record<string, any>>

什么是正确的方式来进行这个api调用,但让它返回正确的信息。

<AccountInformation>

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-08-08 11:09:08

我刚检查了他们的文档,因为docs说它返回了

<AccountInformation>

这是连接到文档的链接

<AccountInformation>正在封装请求,而不是响应。

您所能做的是利用类,因为它扩展了基类,它使用Record作为输入。

因此,您从运行.do()时获得的JSON。

代码语言:javascript
复制
accountInformation(account.addr).do():
{
  address: 'LFNDB6ADWN7M3HFA7TSBKW4ZV7Q3TAJ2TWAGHH35WFGQAVGTJGFVJXQASI',
  amount: 10000000,
  'amount-without-pending-rewards': 10000000,
  'apps-local-state': [],
  'apps-total-schema': { 'num-byte-slice': 0, 'num-uint': 0 },
  assets: [],
  'created-apps': [],
  'created-assets': [],
  'min-balance': 100000,
  'pending-rewards': 0,
  'reward-base': 0,
  rewards: 0,
  round: 32,
  status: 'Offline',
  'total-apps-opted-in': 0,
  'total-assets-opted-in': 0,
  'total-created-apps': 0,
  'total-created-assets': 0
}

可以将传递到帐户(Record),如下所示:

代码语言:javascript
复制
new algosdk.modelsv2.Account(info):
Account {
  address: 'LFNDB6ADWN7M3HFA7TSBKW4ZV7Q3TAJ2TWAGHH35WFGQAVGTJGFVJXQASI',
  amount: 10000000,
  amountWithoutPendingRewards: undefined,
  minBalance: undefined,
  pendingRewards: undefined,
  rewards: 0,
  round: 32,
  status: 'Offline',
  totalAppsOptedIn: undefined,
  totalAssetsOptedIn: undefined,
  totalCreatedApps: undefined,
  totalCreatedAssets: undefined,
  appsLocalState: undefined,
  appsTotalExtraPages: undefined,
  appsTotalSchema: undefined,
  assets: [],
  authAddr: undefined,
  createdApps: undefined,
  createdAssets: undefined,
  participation: undefined,
  rewardBase: undefined,
  sigType: undefined,
  attribute_map: {
    address: 'address',
    amount: 'amount',
    amountWithoutPendingRewards: 'amount-without-pending-rewards',
    minBalance: 'min-balance',
    pendingRewards: 'pending-rewards',
    rewards: 'rewards',
    round: 'round',
    status: 'status',
    totalAppsOptedIn: 'total-apps-opted-in',
    totalAssetsOptedIn: 'total-assets-opted-in',
    totalCreatedApps: 'total-created-apps',
    totalCreatedAssets: 'total-created-assets',
    appsLocalState: 'apps-local-state',
    appsTotalExtraPages: 'apps-total-extra-pages',
    appsTotalSchema: 'apps-total-schema',
    assets: 'assets',
    authAddr: 'auth-addr',
    createdApps: 'created-apps',
    createdAssets: 'created-assets',
    participation: 'participation',
    rewardBase: 'reward-base',
    sigType: 'sig-type'
  }
}

和!沃利亚!你有你的账户模型对象!

实际上应该有一些方法.getModel(),我将创建一个PR,因为这应该是SDK的一部分。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73276736

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档