Cargo concordium could not build contract

Hello

We have developed a smart contract, however we get the following error when running cargo concordium build.

Error: Could not build smart contract.

Caused by:
0: Could not validate resulting smart contract module.
1: Unknown value type byte 0x7c

What does this error mean? We are able to build the piggy bank example. We thought it might be because of our dependencies, but we dont know.

1 Like

Hi Honro,

And welcome to the Concordium support forum!

I understand your confusion. It is not the easiest error message to decipher. 0x7c is the byte code for the f64 type in WASM. So your contract uses floating-point numbers, which are not allowed in Concordium smart contracts. This limitation is explained in our documenation.

I hope that you can find a way around using floats in your contract. If not, let us know, and we can try to help you out.

Best regards,
Kasper

2 Likes

I’ve created an issue, so we can improve the error message when using floats in the future :slight_smile:

1 Like

Thanks for the reply Kasper.

We don’t use floats, however one of our libraries might. So I guess we have to look them through and find which one does.

Good idea improving the error message hehe.

Hello again.

So we have found that the crate ‘curv kzen’ is causing the problem. We are using it to implement elliptic curve cryptograhpy. Is there some sort of workaround, or do you know any other crates for cryptography that are compatible?

Thanks :slight_smile:

How can I find the library that is using f64 easily? Any tips on that one? Thanks :blush:

You cannot. Floating point operations are not allowed on the chain due to determinism issues.

I know. What I tried to convey: is there an easy way to find out where floating point variables are used in your libraries?

Right.

I think none of our libraries (concordium-std, concordium-cis2) use floating points. So it’d have to be some other dependency that you added.

I don’t have concrete advice on how you would go about this other than removing one dependency at a time and seeing if it compiles.

If you can share a bit more details perhaps we can help more concretely.