Skip to content

getAssets

Requests to get assets for an account from a Wallet.

Usage

example.ts
import { walletClient } from './config'
 
const assets = await walletClient.getAssets({ 
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', 
}) 

Returns

List of assets for the given account.

The 0 key represents the aggregated assets across the returned chains.

type ReturnType = {
  /** Aggregated assets across returned chains. */
  0: readonly {
    address: Address | 'native'
    balance: Hex
    chainIds: readonly number[]
    metadata?: unknown | undefined
    type: 'native' | 'erc20' | 'erc721' | (string & {})
  }[]
  
  /** Assets for each chain. */
  [chainId: number]: readonly {
    address: Address | 'native'
    balance: Hex
    metadata?: unknown | undefined
    type: 'native' | 'erc20' | 'erc721' | (string & {})
  }[]
}

Parameters

account

  • Type: Account | Address

The account to get assets for.

import { walletClient } from './config'
 
const assets = await walletClient.getAssets({ 
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', 
}) 

assets

  • Type: { [chainId: number]: readonly { address: Address | 'native', type: 'native' | 'erc20' | 'erc721' | (string & {}) }[] }

Filter by assets.

import { walletClient } from './config'
 
const assets = await walletClient.getAssets({ 
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  assets: { 
    8453: [{ address: '0x1234567890abcdef1234567890abcdef12345678', type: 'erc20' }], 
  }, 
}) 

assetTypes

  • Type: readonly ('native' | 'erc20' | 'erc721' | (string & {}))[]

Filter by asset types.

import { walletClient } from './config'
 
const assets = await walletClient.getAssets({ 
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  assetTypes: ['erc20'], 
}) 

chainIds

  • Type: readonly number[]

Filter by chain IDs.

import { walletClient } from './config'
 
const assets = await walletClient.getAssets({ 
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  chainIds: [8453], 
}) 

JSON-RPC Methods