@polkadot/types/interfaces#AccountData TypeScript Examples

The following examples show how to use @polkadot/types/interfaces#AccountData. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: api.ts    From community-repo with GNU General Public License v3.0 6 votes vote down vote up
getAccounts = async (
  api: ApiPromise
): Promise<AccountBalance[]> => {
  let accounts: AccountBalance[] = [];
  const entries = await api.query.system.account.entries();
  for (const account of entries) {
    const accountId = String(account[0].toHuman());
    const balance = account[1].data.toJSON() as unknown as AccountData;
    accounts.push({ accountId, balance });
  }
  return accounts;
}