According to this page(Initialize a smart contract instance — Concordium documentation),
you can pass parameters in binary format.
But I could not find a page about creating my_parameter.bin
with client.
Is there any examples to do that?
The contents of the binary parameter file is passed directly to the contract as a parameter.
Thus it is up to you to construct it according to the parameter your contract expects. There are no specific tools for this since in general it is just a byte array that is passed.
If your parameter has specific structure and your contract is developed using concordium-std then the recommended way is to specify the parameter as a JSON file and use the schema. This allows cargo-concordium to do all the serialization behind the scenes for you.
Would that suit you, or do you need to pass a binary parameter?
Thank you for your reply!
Yes, I usually use json as a parameter with cargo-concordium. I wanted to know more about how it is serialized because I had a problem sending parameters with node-sdk(v0.5.1).
But now that I’ve noticed that sdk has been updated, I’ll try to read the code, thanks!
Serialization is ultimately defined by the smart contract and the only way to know how to serialize is to look at the contract itself.
However if the contract is developed using concordium-std there are some common standards. For example the following contract
has this type https://github.com/Concordium/concordium-rust-smart-contracts/blob/main/examples/erc721/src/lib.rs#L60 as a parameter type. concordium-std
defines a specific serialization of Sets (Serial in concordium_std - Rust) and u64’s (TokenIds).
I hope this makes some sense.