Icon HelpCircleForumIcon Link

⌘K

Icon HelpCircleForumIcon Link

Icon LinkAsset API

The Asset API is a RESTful API that allows you to query the assets on the Fuel blockchain. We allow for querying the Asset API on both the Mainnet and Testnet.

For more information about the API, please refer to the Wiki Icon Link page.

Icon LinkAsset by ID

We can request information about an asset by its asset ID, using the getAssetById function. This will leverage the endpoint /assets/<assetId> to fetch the asset information.

import type { AssetInfo } from 'fuels';
import { getAssetById } from 'fuels';
 
const asset: AssetInfo | null = await getAssetById({
  assetId: '0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07',
});
 
console.log('AssetInfo', asset);
// AssetInfo { ... }

By default, we will request the asset information for mainnet. If you want to request the asset information from other networks, you can pass the network parameter (this is the same for the getAssetsByOwner function).

await getAssetById({
  assetId: '0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07',
  network: 'testnet',
});

Icon LinkAssets by Owner

We can request information about an asset by its owner, using the getAssetsByOwner function. This will leverage the endpoint /accounts/<owner>/assets to fetch the asset information.

import type { AssetsByOwner } from 'fuels';
import { getAssetsByOwner } from 'fuels';
 
const assets: AssetsByOwner = await getAssetsByOwner({
  owner: '0x0000000000000000000000000000000000000000000000000000000000000000',
});
 
console.log('AssetsByOwner', assets);
// AssetsByOwner { data: [], pageInfo: { count: 0 } }

You can change the pagination parameters to fetch more assets (up to 100 assets per request).

await getAssetsByOwner({
  owner: '0x0000000000000000000000000000000000000000000000000000000000000000',
  pagination: { last: 100 },
});