# Contract\_id relation with Asset\_id

**URL:** <https://forum.fuel.network/t/contract-id-relation-with-asset-id/6683>\
**Category:** Sway\
**Created:** [September 24, 2024, 4:24pm UTC](https://forum.fuel.network/t/contract-id-relation-with-asset-id/6683 "2024-09-24T16:24:50Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![DevilAsap](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/devilasap/32/3588_2.png) [@DevilAsap](https://forum.fuel.network/u/DevilAsap)\
**Post date:** [September 24, 2024, 4:24pm UTC](https://forum.fuel.network/t/contract-id-relation-with-asset-id/6683/1 "2024-09-24T16:24:50Z")

</div>

If I have the `contract_id` of the contract that minted a particular asset (associated with an `Asset ID`), how can I verify whether that specific `contract_id` minted the given `Asset ID`?

This issue could be resolved if there was a method to derive the `contract_id` of the minter contract directly from the `Asset ID`.

Could you please guide me on how to achieve this?

**P.S.:** I need the `contract_id` to call the SRC20 ABI functions.

```auto
#[storage(read, write), payable]
    fn list_nft(nft_contract_id: ContractId, asset_id: AssetId, price: u64, quantity: u64, standard: NFTStandard) {
        let sender = msg_sender().unwrap();
        let amount = msg_amount();
        let asset = msg_asset_id();

        require(asset == asset_id && amount == quantity, "Asset or Amount is invalid");
        require(price > 0, "Price is invalid");

        let nft_b256: b256 = nft_contract_id.into();
        let nft_contract = abi(SRC20, nft_b256);
        let decimals = match nft_contract.decimals(asset_id) {
            Some(d) => d,
            None => {
                require(false, "Contract ID is not valid");
                0 
            },
        };

        require(decimals == 0, "Not valid NFT or Semi Fungible Asset");

        match standard {
            NFTStandard::NFT => require(quantity == 1, "Not valid NFT"),
            _ => {},
        }

```

- How can I validate that the `nft_contract_id` is the minter of a given `asset_id`?

---

<div class="post-metadata">

**Author:** ![shealtielanz](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@shealtielanz](https://forum.fuel.network/u/shealtielanz)\
**Post date:** [September 24, 2024, 6:05pm UTC](https://forum.fuel.network/t/contract-id-relation-with-asset-id/6683/2 "2024-09-24T18:05:22Z")

</div>

> [@DevilAsap](#):
>
> asset

the `asset_id` is a hash of the `contractID` and `subID`, with the way hashs work, where `x * y = xy`, you can’t get `x` or `y`, with just `xy`, but to validate you can do so given, the `subID` of the `asset_id` and the `contractID` and check if it returns the `assetId`, if it doesn’t equal to the `assetID,` then it’s not from that contract. hope this helps

---

<div class="post-metadata">

**Author:** ![DevilAsap](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/devilasap/32/3588_2.png) [@DevilAsap](https://forum.fuel.network/u/DevilAsap)\
**Post date:** [September 25, 2024, 3:56am UTC](https://forum.fuel.network/t/contract-id-relation-with-asset-id/6683/3 "2024-09-25T03:56:19Z")

</div>

Yes, I can implement that. However, users are unable to provide the Sub ID directly, as it’s not visible in their wallet — they can only see the Asset ID. Is there any way to retrieve the Sub ID? Thanks for your help!

---

<div class="post-metadata">

**Author:** ![naz3eh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/naz3eh/32/2025_2.png) [@naz3eh](https://forum.fuel.network/u/naz3eh)\
**Post date:** [September 25, 2024, 9:51am UTC](https://forum.fuel.network/t/contract-id-relation-with-asset-id/6683/4 "2024-09-25T09:51:09Z")

</div>

A SHA-256 hash is used to derive the AssetId from the `ContractId` and `SubId`. though, directly retrieving the `ContractId` from an `AssetId` is difficult because it requires reversing a hash function, which is computationally impractical.

Instead, you can usually track the mapping between `ContractId` and `AssetId` during the contract deployment or asset creation process. If you have this mapping saved somewhere, you can use it to find the `ContractId` for a specific `AssetId`.

We are working on a POC for a library that should get name/symbol from AssetIds, and furthermore how we should go about converting AssetId into ContractId.

---

<div class="post-metadata">

**Author:** ![DevilAsap](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/devilasap/32/3588_2.png) [@DevilAsap](https://forum.fuel.network/u/DevilAsap)\
**Post date:** [September 25, 2024, 10:06am UTC](https://forum.fuel.network/t/contract-id-relation-with-asset-id/6683/5 "2024-09-25T10:06:02Z")

</div>

Thank you! I really appreciate your help.

---

<div class="post-metadata">

**Author:** ![DevilAsap](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/devilasap/32/3588_2.png) [@DevilAsap](https://forum.fuel.network/u/DevilAsap)\
**Post date:** [October 15, 2024, 6:33am UTC](https://forum.fuel.network/t/contract-id-relation-with-asset-id/6683/6 "2024-10-15T06:33:50Z")

</div>

Could you please provide a timeline for this ? Also it would be really helpful if we get decimals info too with the help of asset id without the need of contract id

---

<div class="post-metadata">

**Author:** ![naz3eh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/naz3eh/32/2025_2.png) [@naz3eh](https://forum.fuel.network/u/naz3eh)\
**Post date:** [October 15, 2024, 8:48am UTC](https://forum.fuel.network/t/contract-id-relation-with-asset-id/6683/7 "2024-10-15T08:48:27Z")

</div>

We are prioritizing the launch currently, thus all the other tasks are on lower priority right now. I will update you here as soon as it is ready.

---

<div class="post-metadata">

**Author:** ![naz3eh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/naz3eh/32/2025_2.png) [@naz3eh](https://forum.fuel.network/u/naz3eh)\
**Post date:** [October 24, 2024, 4:55am UTC](https://forum.fuel.network/t/contract-id-relation-with-asset-id/6683/8 "2024-10-24T04:55:29Z")

</div>

Hey, you can use this API to get the contract ID of an asset from its asset ID  
[https://mainnet-explorer.fuel.network/assets/0x286c479da40dc953bddc3bb4c453b608bba2e0ac483b077bd475174115395e6b](https://mainnet-explorer.fuel.network/assets/0x286c479da40dc953bddc3bb4c453b608bba2e0ac483b077bd475174115395e6b)

lmk if this is what you are looking for

---

<div class="post-metadata">

**Author:** ![Daulox92](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/daulox92/32/3779_2.png) [@Daulox92](https://forum.fuel.network/u/Daulox92)\
**Post date:** [December 8, 2024, 7:54pm UTC](https://forum.fuel.network/t/contract-id-relation-with-asset-id/6683/9 "2024-12-08T19:54:40Z")

</div>

Hey! Quick question about NFT minting verification in Fuel - is there a way to check if a specific contract is the actual minter of an asset? I have both IDs but can’t figure out how to validate the relationship. Any help appreciated! 🙏

---

<div class="post-metadata">

**Author:** ![naz3eh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/naz3eh/32/2025_2.png) [@naz3eh](https://forum.fuel.network/u/naz3eh)\
**Post date:** [December 10, 2024, 5:20am UTC](https://forum.fuel.network/t/contract-id-relation-with-asset-id/6683/10 "2024-12-10T05:20:13Z")

</div>

Hey @Daulox92, yes there is a way. `AssetId` of any asset is derived using the hash of the contract ID that minted it and an arbitrary `sub-Id`.  
`let assetId = sha256(contractId + subId);`  
Thus, two different contracts cannot mint the same assets and hence can identify who is the actual minter
