# How to get assetid from a single SRC20 contract without knowing the subid?

**URL:** <https://forum.fuel.network/t/how-to-get-assetid-from-a-single-src20-contract-without-knowing-the-subid/7180>\
**Category:** Sway\
**Tags:** faqs\
**Created:** [December 8, 2024, 5:40am UTC](https://forum.fuel.network/t/how-to-get-assetid-from-a-single-src20-contract-without-knowing-the-subid/7180 "2024-12-08T05:40:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eesheng](https://avatars.discourse-cdn.com/v4/letter/e/2bfe46/32.png) [@eesheng](https://forum.fuel.network/u/eesheng)\
**Post date:** [December 8, 2024, 5:40am UTC](https://forum.fuel.network/t/how-to-get-assetid-from-a-single-src20-contract-without-knowing-the-subid/7180/1 "2024-12-08T05:40:45Z")

</div>

How do we get an assetId from a different contract that uses a particular SRC20?

Contract A has token A and B. How do I get token A or token B? Similar to `IERC20(tokena).balanceOf(ContractA)`.

Do we need to know their subId? When can we use the default subId?

It is confusing where in SRC6 Example it uses, `new`:

```auto
/// Returns the vault shares assetid for the given assets assetid and the vaults sub id
fn vault_assetid() -> AssetId {
    let share_asset_id = AssetId::new(ContractId::this(), PRE_CALCULATED_SHARE_VAULT_SUB_ID);
    share_asset_id
}

```

While in other pages of the documentation `from` is used to get assetId? [In the case where the `b256` value of an asset is already known, you may call the `from()` function with the `b256` value.](https://docs.fuel.network/docs/sway/blockchain-development/native_assets/#from)

```auto
let asset_id: AssetId = AssetId::from(0x0000000000000000000000000000000000000000000000000000000000000000);

```

Side Question:  
Should we replace PRE\_CALCULATED\_SHARE\_VAULT\_SUB\_ID with any SubID such as `b256 = Bytes32::zeroed();`?

---

<div class="post-metadata">

**Author:** ![david](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/david/32/32_2.png) [@david](https://forum.fuel.network/u/david)\
**Post date:** [December 9, 2024, 6:22am UTC](https://forum.fuel.network/t/how-to-get-assetid-from-a-single-src20-contract-without-knowing-the-subid/7180/2 "2024-12-09T06:22:24Z")

</div>

Hey @eesheng, you can use `AssetId::new()` when you know the contract ID and the sub-ID, and want to use those to calculate the Asset ID. If you already know the Asset ID, you can pass it to `AssetId::from()`.

---

<div class="post-metadata">

**Author:** ![eesheng](https://avatars.discourse-cdn.com/v4/letter/e/2bfe46/32.png) [@eesheng](https://forum.fuel.network/u/eesheng)\
**Post date:** [December 9, 2024, 7:21am UTC](https://forum.fuel.network/t/how-to-get-assetid-from-a-single-src20-contract-without-knowing-the-subid/7180/3 "2024-12-09T07:21:30Z")

</div>

> [@eesheng](#):
>
> Side Question:  
> Should we replace PRE\_CALCULATED\_SHARE\_VAULT\_SUB\_ID with any SubID such as `b256 = Bytes32::zeroed();`?

Hi @david I think this was overlooked. Do we need to take precautions about the SubID for Single Vault?  
Should we replace PRE\_CALCULATED\_SHARE\_VAULT\_SUB\_ID with any SubID such as `b256 = Bytes32::zeroed();` ?
