Maximum size of smart contract

Hi.
I got this message:

size 1610097 bytes is bigger than the maximum of 65536 bytes

My code is so simple:

use concordium_std::*;
#[derive(SchemaType, Serialize)]
struct ChangeParam {
    state: u32
}

#[derive(Debug, Serialize, PartialEq)]
enum PiggyBankState {
    /// Alive and well, allows for CCD to be inserted.
    Intact,
    /// The piggy bank has been emptied, preventing further CCD to be inserted.
    Smashed,
}

#[init(contract="TestContract2")]
fn init<S: HasStateApi>(_ctx:&impl HasInitContext, state_builder: &mut StateBuilder<S>) -> InitResult<PiggyBankState>{
    Ok(PiggyBankState::Intact)
}

I use concordium-std 3.0. I was using an older version of concordium-client and thought that might be the cause, but that did not seem to be the case.
When I use a newer version of concordium-client, I get this error.

Failed reading: Unrecognized Wasm version number 6386541

It looks like you are not using cargo-concordium to build your contracts. It looks like your contract has a lot of debugging information embedded. Either use cargo-concordium, which strips this information, or use a utility such as wasm-strip.

Regarding the error message, you must use compatible versions of cargo-concordium (2.0.1) and concordium-client (4.*). If you are building your contract manually (without cargo concordium) you have to tell concordium-client which version of the contract your are trying to deploy. This is done using the --contract-version flag.

1 Like

Thank you for replying.
Actually, Iā€™m using cargo-concordium 2.0.1 to build it.
I use this command to deploy:

concordium-client module deploy ./target/concordium/wasm32-unknown-unknown/release/test_ccd.wasm

Is this right file to deploy?

No, it should be the file with a v1 extension.

Note that when building you can supply the flag -o to output the generated contract to a specific file. I recommend you use it to avoid having to search for files in directories.