# Trait "Hash" is not implemented for type "AssetId" error

**URL:** <https://forum.fuel.network/t/trait-hash-is-not-implemented-for-type-assetid-error/3112>\
**Category:** Sway\
**Created:** [September 23, 2023, 11:38am UTC](https://forum.fuel.network/t/trait-hash-is-not-implemented-for-type-assetid-error/3112 "2023-09-23T11:38:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fuel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/fuel/32/1677_2.png) [@fuel](https://forum.fuel.network/u/fuel)\
**Post date:** [September 23, 2023, 11:38am UTC](https://forum.fuel.network/t/trait-hash-is-not-implemented-for-type-assetid-error/3112/1 "2023-09-23T11:38:45Z")

</div>

# Trait “Hash” is not implemented for type “AssetId” error

Hi guys, last week we finally released our swaylend on testnet beta 4, and today I sat down to fix a bug and found out that the contract is not building with an error that never happened before, I want to note that this code was building successfully last week and there were no errors (otherwise how would we release it?).

```auto
error
  --> /Users/alexey/projects/fuel/sway-lend/contracts/market/src/main.sw:41:79
   |
39 | 
40 | storage {
41 | collateral_configurations: StorageMap<AssetId, CollateralConfiguration> = StorageMap {}, 
   | ^^^^^^^^^^^^^ Trait "Hash" is not implemented for type "AssetId".
42 | collateral_configurations_keys: StorageVec<AssetId> = StorageVec {},
43 | pause_config: PauseConfiguration = PauseConfiguration::default(),
   |

```

```auto

error
   --> /Users/alexey/.forc/git/checkouts/std-9be0d6062747ea7/e75f14b03636bc96751a6760304a1a6d3eb5937d/sway-lib-std/src/hash.sw:322:41
    |
320 | 
321 | #![inline(never)]
322 | pub fn sha256<T>(s: T) -> b256 where T: Hash {
    | ^^^^ Could not find symbol "Hash" in this scope.
323 | let mut hasher = Hasher::new();
324 | s.hash(hasher);
    |
____

error
   --> /Users/alexey/.forc/git/checkouts/std-9be0d6062747ea7/e75f14b03636bc96751a6760304a1a6d3eb5937d/sway-lib-std/src/hash.sw:322:41
    |
320 | 
321 | #![inline(never)]
322 | pub fn sha256<T>(s: T) -> b256 where T: Hash {
    | ^^^^ Cannot find trait "Hash" in this scope.
323 | let mut hasher = Hasher::new();
324 | s.hash(hasher);
    |
____

```

Can you please help me figure out how to fix this?

## Toolchain

```auto
Default host: aarch64-apple-darwin
fuelup home: /Users/alexey/.fuelup

installed toolchains
--------------------
beta-3-aarch64-apple-darwin
beta-4-rc.2-aarch64-apple-darwin
latest-aarch64-apple-darwin (default)
hotfix
my-custom-toolchain

active toolchain
-----------------
latest-aarch64-apple-darwin (default)
  forc : 0.46.0
    - forc-client
      - forc-deploy : 0.46.0
      - forc-run : 0.46.0
    - forc-doc : 0.46.0
    - forc-explore : 0.28.1
    - forc-fmt : 0.46.0
    - forc-index : 0.20.10
    - forc-lsp : 0.46.0
    - forc-tx : 0.46.0
    - forc-wallet : 0.3.0
  fuel-core : 0.20.5
  fuel-core-keygen : Error getting version string
  fuel-indexer : 0.20.10

fuels versions
---------------
forc : 0.45
forc-wallet : 0.45

```

## How to reproduce

```auto
git clone https://github.com/compolabs/sway-lend.git
cd sway-lend    
git checkout beta-4   
cd contracts/market/
forc build   

```

---

<div class="post-metadata">

**Author:** ![calldelegation](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/calldelegation/32/1484_2.png) [@calldelegation](https://forum.fuel.network/u/calldelegation)\
**Post date:** [September 23, 2023, 1:39pm UTC](https://forum.fuel.network/t/trait-hash-is-not-implemented-for-type-assetid-error/3112/2 "2023-09-23T13:39:13Z")

</div>

Hey @fuel please refer to the [breaking changes announcement](https://forum.fuel.network/t/september-2023-beta-4-breaking-changes-update/3103)!

In your main.sw simply add the import `use std::hash::Hash;`

You have an additional error for mismatched types which can be solved by adding `AssetId::from(b256)`

```auto
fn get_reward_token_asset_id() -> AssetId {
    AssetId::from(sha256((contract_id(), ZERO_B256)))
}

```

---

<div class="post-metadata">

**Author:** ![fuel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/fuel/32/1677_2.png) [@fuel](https://forum.fuel.network/u/fuel)\
**Post date:** [September 23, 2023, 6:07pm UTC](https://forum.fuel.network/t/trait-hash-is-not-implemented-for-type-assetid-error/3112/3 "2023-09-23T18:07:20Z")

</div>

Oh cool, thanks!!!  
Even the lines are normal now, great!

---

<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 14, 2023, 2:07pm UTC](https://forum.fuel.network/t/trait-hash-is-not-implemented-for-type-assetid-error/3112/4 "2023-10-14T14:07:34Z")

</div>

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