Issue when update state

Dear, everyone.
I am developing contract on Concordium now.
But I faced issues when update state.

this is code.

pub type ContractTokenId = TokenIdU32;

#[derive(SchemaType, Clone, Serialize, PartialEq, Eq, Debug)]

struct TokenInfo {

pub id: ContractTokenId,

pub address: ContractAddress,


impl TokenInfo {

fn new(id: ContractTokenId, address: ContractAddress) -> Self {

    TokenInfo { id, address }



#[derive(SchemaType, Clone, Serialize, Copy, PartialEq, Eq, Debug)]

enum TokenListState {




#[derive(SchemaType, Clone, Serialize, Copy, PartialEq, Eq, Debug)]

enum TokenSaleTypeState {




#[derive(SchemaType, Clone, Serialize, Copy, PartialEq, Eq, Debug)]

struct TokenState {

sale_type: TokenSaleTypeState,

curr_state: TokenListState,

owner: AccountAddress,

expiry: u64,

highest_bidder: AccountAddress,


#[derive(Serial, DeserialWithState, StateClone)]

#[concordium(state_parameter = “S”)]

struct State


tokens: StateMap<TokenInfo, TokenState, S>,



contract = "Market-NFT",

name = "add",

parameter = "AddParams",



fn add<S: HasStateApi>(

ctx: &impl HasReceiveContext,

host: &mut impl HasHost<State<S>, StateApiType = S>,

) → ContractResult<()> {

let params: AddParams = ctx



    .map_err(|_e| MarketplaceError::ParseParams)?;

let info = TokenInfo::new(params.token_id, params.nft_contract_address);

if host.state_mut().tokens.get(&info).is_some() {

    let token_state = host.state().tokens.get(&info).unwrap();

    token_state.highest_bidder = AccountAddress([0u8; 32]);




When call add function, i want to update token_state(type: TokenState).
But I can’t update.
what is the reason?
Hope your help.
Kind regards.

You want to use get_mut and not just .get when looking up a token

See StateMap in concordium_std - Rust