Error raised when validating WASM module

Hi, thank you for all your help.
This time I have a question about deploying module with sdk(I’m using node-sdk and rust-sdk).
First of all, I can deploy modules regardless of the version without any problems when using concordium-client. And also am able to deploy version 0 contract using both sdk.

When deploying version 1 contract with sdk, the transaction is sent successfully but it seems to be rejected by the node with Error raised when validating WASM module.
I followed this example(node-sdk#deploy-module), except for the version.

const deployModule: DeployModulePayload = {
        content: wasmFileBuffer,
        version: 1,
};

I have tried with rust-sdk and got the same result.
Is there anything that you think might be the cause?

What network are you doing this on?

Version 1 smart contracts are not yet enabled on mainnet, only on testnet.

I`m using testnet.
I can deploy when using concordium-client, so I guess the error comes from the SDK side.

And I’ve found I cannot update contract from sdk because serializeUpdateContractParameters doesn’t work, which assumes only version0 schema.

Which version of cargo-concordium are you using, and how are you producing the module to deploy?

cargo-concordium version 2 produces “versioned modules” already which concordium-client.

Concretely something like this should work for cargo-concordium version 2.

let module: WasmModule = from_bytes(&std::fs::read("contract.wasm.v1")?)?;
...
let tx = send::deploy_module(&account_keys, address, nonce, expiry, module);

cargo-concordium version 1 only produces the “module source”, so you have to add the version yourself.

An alternative if you produced your contract with cargo-concordium version 2 is to strip the first 8 bytes of the file. Then you should be able to do what you posted originally.

1 Like

I’m using cargo-concordium version 2. so I just removed the first 8 bytes and then deployed successfully.
Thank you for answering!

1 Like