WDK logoWDK documentation

Manage Accounts

Work with multiple gas-free Tron accounts and custom derivation paths.

This guide explains how to retrieve accounts by index, use custom derivation paths, and iterate over multiple accounts.

Retrieve Accounts by Index

You can access accounts derived from the default BIP-44 path (m/44'/195') using wallet.getAccount():

Get Accounts by Index
const account = await wallet.getAccount(0)
const address = await account.getAddress()
console.log('Account 0 address:', address)

const account1 = await wallet.getAccount(1)
const address1 = await account1.getAddress()
console.log('Account 1 address:', address1)

Retrieve Account by Custom Derivation Path

You can request an account at a specific BIP-44 derivation path using wallet.getAccountByPath():

Custom Derivation Path
const customAccount = await wallet.getAccountByPath("0'/0/5")
const customAddress = await customAccount.getAddress()
console.log('Custom account address:', customAddress)

Iterate Over Multiple Accounts

You can iterate through multiple accounts using wallet.getAccount() to inspect addresses and balances in bulk:

Multi-Account Iteration
async function listAccounts(wallet) {
  const accounts = []

  for (let i = 0; i < 5; i++) {
    const account = await wallet.getAccount(i)
    const address = await account.getAddress()
    const balance = await account.getBalance()

    accounts.push({ index: i, address, balance })
    console.log(`Account ${i}:`, address)
  }

  return accounts
}

Next Steps

Now that you can access your accounts, learn how to check balances.

On this page