How do you calculate an AssetId from a contract & sub-id?

If I have a contract and the sub-id of an asset, how do I calculate the Asset ID? Is there an equivelant of the Rust SDK’s ContractIdExt::asset_id()?

Hello, @FossilFrank. You can achieve this with getMintedAssetId. This helper is exported from fuels

import { getMintedAssetId } from 'fuels'

// subId example
const subId = '0x4a778acfad1abc155a009dc976d2cf0db6197d3d360194d74b1fb92b96986b00';

const assetId = getMintedAssetId(contractInstance.id.toB256(), subId)
1 Like

Hi @FossilFrank and @Torres-ssf ,

The Fuel Specifications may also be helpful here:

1 Like