Closed 0xLucca closed 8 months ago
@0xLucca I reproduced the error. The problem is with too old cargo contract tool. The recent version (4.x) adds additional information to the bundle (including the missing staticBufferSize
field).
When I rerun the experiment with newest cargo contract, your main
works well.
For updating cargo contract I use:
cargo install cargo-contract --force --locked --version 4.0.0-rc.1
Hey @pmikolajczyk41!
Thanks for looking into this further! You were correct - upgrading to the latest cargo-contract (v4.x) resolved the issues I was seeing when trying to load my external flipper.contract file.
One followup question - many existing contract bundles created with older cargo-contract versions will be missing some of this newer metadata added in v4.x. Is there a recommended way to handle loading/decoding contracts with these older bundle formats?
if you are asking about handling these bundles with drink, then I guess the easiest way is to use some older version of drink (as far as I remember versions around 0.8.x
should work fine with ink 4)
however, if feasible, I would recompile the contract with newer cargo-contract
I have created a standalone Rust project that attempts to load and use a Flipper smart contract located in an external flipper.contract file, rather than bundling the contract within the crate itself. When trying to load the flipper.contract, the following error is thrown:
The versions of the relevant tools I am using are:
Below is a snippet of my code for loading the contract:
The flipper.contract file has the following contents:
I have done some more debugging and found that trying to load the contract directly using the drink transcoder also results in the same error. So the issue seems to be around how the contract file is getting decoded, rather than just the way I am trying to load it in my project.
Let me know if any other details would be helpful!