#panic_impl

21 messages · Page 1 of 1 (latest)

random wadi
#

Hi so I am converting my smart contract into a web assembly to integrate into stellar, I ran this command cargo build --target wasm32-unknown-unknown --release. I then receive the error of a "panic_impl", this means i have a duplicate item in my crate. However the dependencies I use is the soroban_sdk and crate-type = ["cdylib"]. Any idea how I can fix this issue?

random wadi
indigo spire
#

that's suspicious; are you just building the example?

random wadi
indigo spire
#

can you make sure the example works for you first?

#

just to be sure there is no issue in your environment

random wadi
#

i ran the example

#

and it works perfectly @indigo spire

indigo spire
#

good. then chances are there is something wrong with your build configuration - hard to tell without having an example

random wadi
#

should i show an example of my cargo.toml?

indigo spire
#

yeah, the whole example would be nice (both contract and cargo)

random wadi
indigo spire
#

you're missing contractimpl from your contract

#

(not sure if that should cause your particular error, but you don't have any real contract to build)

#

also, you have a lot of extra deps, such as stellar sdk, random, etc.

#

I would recommend stripping all the deps and only adding them when needed

#

you're also missing contracttype annotations on your types (and that would break your build as well because you can't use arbitrary types as contracttype)

karmic crest
random wadi
#

Thank you @indigo spire @karmic crest for the input I will take it into account

alpine shore
# random wadi my contract

@random wadi You need to include #![no_std] at the top of your lib.rs. If you don't, the Rust libstd library will be automatically imported into your project, which will cause a duplicate panic_impl to be loaded. The Soroban SDK ships with its own panic_impl which is more efficient in a WASM runtime like the Soroban environment.