# AssetId generation mismatch?

**URL:** <https://forum.fuel.network/t/assetid-generation-mismatch/3185>\
**Category:** Sway\
**Created:** [October 5, 2023, 9:20pm UTC](https://forum.fuel.network/t/assetid-generation-mismatch/3185 "2023-10-05T21:20:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![diyahir](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/diyahir/32/1075_2.png) [@diyahir](https://forum.fuel.network/u/diyahir)\
**Post date:** [October 5, 2023, 9:20pm UTC](https://forum.fuel.network/t/assetid-generation-mismatch/3185/1 "2023-10-05T21:20:41Z")

</div>

Continuing the discussion from [Trait "Hash" is not implemented for type "AssetId" error](https://forum.fuel.network/t/trait-hash-is-not-implemented-for-type-assetid-error/3112/2):

I have

```auto
pub fn get_default_asset_id(contract_id: ContractId) -> AssetId {
    sha256((contract_id, ZERO_B256))
}

```

Yet, gives me the error that I am not sending the right token in regression tests

```auto
#[storage(read)]
fn require_valid_asset() {
    require(msg_asset_id() == get_default_asset_id(storage.token_contract.read()), "Invalid asset being transfered");
}

```

Despite using

```auto
mint_to(address, ZERO_B256, amount);

```

when minting

I should also mention the tokens are infact being minted properly which i checked using:

```auto
let asset_id = asset
            .contract_id()
            .asset_id(&BASE_ASSET_ID.into())
            .into(),

```

---

<div class="post-metadata">

**Author:** ![diyahir](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/diyahir/32/1075_2.png) [@diyahir](https://forum.fuel.network/u/diyahir)\
**Post date:** [October 5, 2023, 9:26pm UTC](https://forum.fuel.network/t/assetid-generation-mismatch/3185/2 "2023-10-05T21:26:12Z")

</div>

Should I just pass the AssetId as well as the ContractId to the contract when initializing it, or is there something going wrong here?

---

<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:** [October 6, 2023, 10:01am UTC](https://forum.fuel.network/t/assetid-generation-mismatch/3185/3 "2023-10-06T10:01:46Z")

</div>

At a first glance, I don’t see anything wrong. Could you provide the full code or a minimal reproduction to debug?

---

<div class="post-metadata">

**Author:** ![sandusky](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/sandusky/32/1313_2.png) [@sandusky](https://forum.fuel.network/u/sandusky)\
**Post date:** [October 6, 2023, 3:14pm UTC](https://forum.fuel.network/t/assetid-generation-mismatch/3185/4 "2023-10-06T15:14:25Z")

</div>

David’s right! The full code will be very helpful!  
Remember to add the output of “fuelup show” so we can have more information on your environment.

🌴

---

<div class="post-metadata">

**Author:** ![diyahir](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/diyahir/32/1075_2.png) [@diyahir](https://forum.fuel.network/u/diyahir)\
**Post date:** [October 6, 2023, 6:16pm UTC](https://forum.fuel.network/t/assetid-generation-mismatch/3185/5 "2023-10-06T18:16:09Z")

</div>

Interesting, I was not able to recreate it in a new project, must be passing in some variable improperly somewhere, very strange.

---

<div class="post-metadata">

**Author:** ![diyahir](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/diyahir/32/1075_2.png) [@diyahir](https://forum.fuel.network/u/diyahir)\
**Post date:** [October 6, 2023, 6:45pm UTC](https://forum.fuel.network/t/assetid-generation-mismatch/3185/6 "2023-10-06T18:45:49Z")

</div>

I am seeing the hash:

e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

which if you look it up this is the 0 length hash, so something much stranger is happening on the sha function on my working repo vs the dummy one I made trying to recreate the issue

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex022/uploads/fuel/original/2X/5/57d5a345cc15a64b636e0d56e042857f8a0e80b1.png) [@system](https://forum.fuel.network/u/system)\
**Post date:** [October 27, 2023, 2:46pm UTC](https://forum.fuel.network/t/assetid-generation-mismatch/3185/7 "2023-10-27T14:46:01Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
