githubEdit

Account Management

Learn how to work with accounts and addresses.

This guide explains how to access accounts from your registered wallets. An "Account" object in WDK is your interface for inspecting balances and sending transactions on a specific blockchain.

Retrieve Accounts

You can retrieve an account using a simple index or a custom derivation path.

The simplest way to get an account is by its index (starting at 0). This uses the default derivation path for the specified blockchain.

Get Account by Index
// Get the first account (index 0) for Ethereum and TON
const ethAccount = await wdk.getAccount('ethereum', 0)
const tonAccount = await wdk.getAccount('ton', 0)

By Derivation Path (Advanced)

If you need a specific hierarchy, you can request an account by its unique derivation path.

Get Account by Path
// Custom path for Ethereum
const customEthAccount = await wdk.getAccountByPath('ethereum', "0'/0/1")
circle-info

The WDK instance caches accounts. If you call getAccount twice using the same index, the function will return the same Account object instance.

circle-exclamation

View Addresses

Once you have an account object, you can retrieve its public blockchain address using the getAddress function.

Check Balances

You can check the native token balance of any account (e.g., ETH on Ethereum, TON on TON) by using the getBalance() function.

Multi-Chain Balance Check

Because WDK offers a unified interface, you can easily iterate through multiple chains to fetch balances.

The following example:

  1. Iterates over an array of user defined chains.

  2. Retrieves the first account using the respective chain's getAccount(index) function.

  3. Retrieves the first account's balance using the getBalance() function.

  4. Logs the balance to the console.

Next Steps

Now that you can access your accounts, learn how to send transactions.