Get Assets by Owner

Get a list of assets owned by an address.

Overview

This method is the fastest way to return all assets belonging to a wallet. Supported assets include NFTs, compressed NFTs (regular DAS), fungible tokens, and Token22.

The page parameter in starts at 1

Use Cases

Using getAssetsByOwner to return all tokens from a user wallet enables the creation of:

  • A wallet tracker.

  • A portfolio viewer for both fungible and non-fungible tokens.

  • A token-gated dApp.

The Fungible Token Extension also returns the USD prices of token holdings.

Code Examples

Get NFTs & compressed NFTs from the toly.sol wallet
const url = `https://mainnet.helius-rpc.com/?api-key=<api_key>`

const getAssetsByOwner = async () => {
  const response = await fetch(url, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      jsonrpc: '2.0',
      id: 'my-id',
      method: 'getAssetsByOwner',
      params: {
        ownerAddress: '86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY',
        page: 1, // Starts at 1
        limit: 1000,
      },
    }),
  });
  const { result } = await response.json();
  console.log("Assets by Owner: ", result.items);
};
getAssetsByOwner(); 
Get ALL assets from the toly.sol wallet

const getAssetsByOwner = async () => {
  const response = await fetch(url, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      jsonrpc: '2.0',
      id: 'my-id',
      method: 'getAssetsByOwner',
      params: {
        ownerAddress: '86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY',
        page: 1, // Starts at 1
        limit: 1000,
	displayOptions: {
	    showFungible: true //return both fungible and non-fungible tokens
	}
      },
    }),
  });
  const { result } = await response.json();
  console.log("Assets by Owner: ", result.items);
};
getAssetsByOwner(); 
Searching for all assets (including native balance)
const url = `https://mainnet.helius-rpc.com/?api-key=<api_key>`

const getAssetsWithNativeBalance = async () => {
    const response = await fetch(url, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
        },
        body: JSON.stringify({
            jsonrpc: '2.0',
            id: 'my-id',
            method: 'getAssetsByOwner',
            params: {
                ownerAddress: '86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY',
                displayOptions: {
                    showFungible: true,
                    showNativeBalance: true,
                },
            },
        }),
    });

    const { result } = await response.json();
    console.log(result.nativeBalance.lamports); // 1479920100
};
getAssetsWithNativeBalance();
Show inscriptions & SPL-20 data
const url = `https://mainnet.helius-rpc.com/?api-key=<api-key>`;

const getAssetsWithInscriptions = async () => {
    const response = await fetch(url, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
        },
        body: JSON.stringify({
            jsonrpc: '2.0',
            id: 'my-id',
            method: 'getAssetsByOwner',
            params: {
                ownerAddress: '6GmTFg5SCs4zGfDEidUAJjS5pSrXEPwW8Rpfs3RHrbc5',
                displayOptions: {
                    showInscription: true, // display inscription & spl-20 data
                },
            },
        }),
    });

    const { result } = await response.json();
    console.log(result.items.map((i) => [i.id, i.inscription, i.spl20]));
};
getAssetsWithInscriptions();

// Example output:
// [
//     [
//         'AKo9P7S8FE9NYeAcrtZEpimwQAXJMp8Lrt8p4dMkHkY2',
//         {
//             order: 308332,
//             size: 52,
//             contentType: 'application/text',
//             encoding: 'base64',
//             validationHash: '907e00a18f952ade319c21b90764e5d0a08ec31c92e792f806a995e8524535ca',
//             inscriptionDataAccount: '9qM9ThkVPxjq4TyBjCs1qpY15VYVim2Qh7uR5yG1Da3T',
//         },
//         { p: 'spl-20', op: 'mint', tick: 'helius', amt: '1' },
//     ],
// ];

Last updated