WDK logoWDK documentation
StartWalletsDeFi & FiatAI & CLITools

Manage Accounts

Work with multiple Tron accounts and custom derivation paths.

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

Accounts derived by one manager share its initialized TRON provider, including failover state. Read-only conversions reuse that provider. Use separate managers for independent RPC settings.

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)

Use a Registered Signer

A manager can use a chain-specific signer as its default root. Use a root at m/44'/195' for the standard indexed paths. With a different root, the index path is appended to that signer's path.

You can also register a signer for an existing account. Here, wallet is an initialized manager and privateKey is the existing account's private key as a Uint8Array.

import { PrivateKeySignerTron } from '@tetherto/wdk-wallet-tron/signers'

const signer = new PrivateKeySignerTron(privateKey)
try {
  wallet.addSigner('treasury', signer)
  const account = await wallet.getAccount('treasury')
  console.log(await account.getAddress())
} finally {
  wallet.dispose()
  signer.dispose()
}

Pass the name as the first argument to use the signer at its own address. For a registered signer that supports derivation, use wallet.getAccount(0, { signerName }) to derive a child. Dispose of caller-owned signers once every account using them has finished.

Iterate Over Multiple Accounts

You can loop 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 })
  }

  return accounts
}

Next Steps

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

On this page