Nft Market Place Error

I’ve been receiving this error from cis2-market contract on Build and I got this contract from GitHub.
here is the link :

Will it be okay if I remove State Clone and proceed without it?

Hi @hassan,

Yes, the StateClone has been removed in Concordium-std version 8. So you should remove it.
I do not know the tutorial you seem to be following, but it is at least not fully up to date.
We have our official guides and tutorials on https://academy.concordium.software/ and https://developer.concordium.software/.

Have a nice day :blush:
/ Kasper

1 Like

Thanks I appreciate your response.

Contract Add Error on Cis2-MarketPlace

As shown in the picture above this error occurred when I was trying to add my nft on the marketplace with the error code -1 it says that the parameters were wrong in some way but I tried different option yet still came to the conclusion that these parameter formats were correct yet still I received the error telling me that it couldn’t parse the parameters. Please help resolve this issue

AddFunction Code :

#[receive(
    contract = "Market-NFT",
    name = "add",
    parameter = "AddParams",
    mutable
)]
fn add<S: HasStateApi>(
    ctx: &impl HasReceiveContext,
    host: &mut impl HasHost<ContractState<S>, StateApiType = S>,
) -> ContractResult<()> {
    let params: AddParams = ctx
        .parameter_cursor()
        .get()
       .map_err(|_e| MarketplaceError::ParseParams)?;

    let sender_account_address: AccountAddress = match ctx.sender() {
        Address::Account(account_address) => Option::Some(account_address),
        Address::Contract(_) => Option::None,
    }
    .ok_or(MarketplaceError::CalledByAContract)?;

    let token_info = TokenInfo {
        address: params.nft_contract_address,
        id: params.token_id,
    };

    ensure_supports_cis2(host, &params.nft_contract_address)?;
    ensure_is_operator(host, ctx, &params.nft_contract_address)?;
    ensure_balance(
        host,
        params.token_id,
        &params.nft_contract_address,
        sender_account_address,
        params.quantity,
    )?;

    host.state_mut().list_token(
        &token_info,
        &sender_account_address,
        params.price,
        params.royalty,
        params.quantity,
    );
    ContractResult::Ok(())
}

Could you please supply the code for the AddParams struct and the MarketplaceError enum?

And please use the “</>” button when inserting code, as it makes it a lot easier to read :wink:

Alternatively if the project is open source, you could also choose to supply a link to the repository along with the location of the relevant files.

Okay I will share more details to you.

ADDPARAMS CODE:

use concordium_std::{
    AccountAddress, Amount, ContractAddress, Deserial, SchemaType, Serial, Serialize,
};

use crate::{state::TokenListItem, ContractTokenAmount, ContractTokenId};

#[derive(Serial, Deserial, SchemaType)]
pub(crate) struct AddParams {
    pub nft_contract_address: ContractAddress,
    pub token_id: ContractTokenId,
    pub price: Amount,
    pub royalty: u16,
    pub quantity: ContractTokenAmount,
}

#[derive(Serial, Deserial, SchemaType)]
pub(crate) struct TransferParams {
    pub nft_contract_address: ContractAddress,
    pub token_id: ContractTokenId,
    pub to: AccountAddress,
    pub owner: AccountAddress,
    pub quantity: ContractTokenAmount,
}

#[derive(Debug, Serialize, SchemaType)]
pub struct TokenList(
    #[concordium(size_length = 2)] pub Vec<TokenListItem<ContractTokenId, ContractTokenAmount>>,
);

#[derive(Serial, Deserial, SchemaType)]
pub struct InitParams {
    pub commission: u16,
}

MARKETPLACE ENUM CODE:

//! Provides error types which can be returned by Marketplace Contract.
//! Read more about errors which can be returned by a Concordium Contract [here](https://developer.concordium.software/en/mainnet/smart-contracts/guides/custom-errors.html)

use concordium_std::*;

#[derive(Serialize, Debug, PartialEq, Eq, Reject)]
pub enum MarketplaceError {
    ParseParams,
    CalledByAContract,
    TokenNotListed,
    Cis2ClientError(Cis2ClientError),
    CollectionNotCis2,
    InvalidAmountPaid,
    InvokeTransferError,
    NoBalance,
    NotOperator,
    InvalidCommission,
    InvalidTokenQuantity,
}

#[derive(Serialize, Debug, PartialEq, Eq, Reject)]
pub enum Cis2ClientError {
    InvokeContractError,
    ParseParams,
    ParseResult,
}

Could you please also share the command you use when you try to add the token to the contract? As in the concordium-client contract update ... command.

I just tried calling concordium-client contract show 7420, which printed the following in the terminal:

Contract:        Market-NFT
Owner:           '4dgSpWaZf4Z5yDFE5hb6XpaioDv6kao7UF3wvZiMbFkynSdh1A'
ModuleReference: '1dd4231548b2ae49bcf27d648ce851a601ed37b4b8392029fb22f14ee840c2a5'
Balance:         0.000000 CCD
Methods:
- add
- list
- transfer

This tells me that the contract has no schema embedded, and as such you need to pass the schema to the concordium client command if you want to use contract parameters as JSON. Again, to fully understand what’s going on, I would need to the command used to perform the contract update.

As we have addressed this issue in a call, can you confirm that is resolved? @hassan

Yes thankyou I really appreciate that