Use StorageMap Error. Trait "Hash" is not implemented for type "Identity"

This is my contract:

contract;

mod errors;
mod interface;

use ::errors::{AccessError, InitError, InputError};
use ::interface::{MintEvent, NFT, TransferEvent};
use std::{
    auth::msg_sender,
    result::Result,
};

storage {
    access_control: bool = false,
    admin: Option<Identity> = Option::None,
    balances: StorageMap<Identity, u64> = StorageMap::<Identity, u64> {},
   -> Error: `"Hash" is not implemented for type "Identity".`
    max_supply: u64 = 0,
    owners: StorageMap<u64, Option<Identity>> = StorageMap {},
    total_supply: u64 = 0,
}

This is the output of fuelup show:

Default host: x86_64-unknown-linux-gnu
fuelup home: /home/lopo/.fuelup

installed toolchains
--------------------
latest-x86_64-unknown-linux-gnu (default)

active toolchain
----------------
latest-x86_64-unknown-linux-gnu (default)
  forc : 0.49.3
    - forc-client
      - forc-deploy : 0.49.3
      - forc-run : 0.49.3
    - forc-crypto : 0.49.3
    - forc-doc : 0.49.3
    - forc-explore : 0.28.1
    - forc-fmt : 0.49.3
    - forc-lsp : 0.49.3
    - forc-tx : 0.49.3
    - forc-wallet : 0.4.3
  fuel-core : 0.22.1
  fuel-core-keygen : 0.22.1

fuels versions
--------------
forc : 0.54.0
forc-wallet : 0.54.0

How do I use this StorageMap?

Hi this is a known error we are addressing. For now please add hash::Hash to your imports:

use std::{
    auth::msg_sender,
    result::Result,
    hash::Hash,
};

It also looks like you are creating an NFT, we have an Asset standard that applies to NFTs that can be found here. A basic implementation example of an NFT can be found here.

3 Likes

:smile: thanks,That’s all right.

1 Like

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