When executing the following command, an error occurred.

cargo contract build
ERROR: Mismatching versions of `parity-scale-codec` were found!
Please ensure that your contract and your ink! dependencies use a compatible version of this package.


  • OS: Ubuntu 20.04 wsl
  • cargo-contract: 2.0.0-alpha.3-unknown-x86_64-unknown-linux-gnu
  • ink:
    ink = { version = "4.0.0-alpha.3", default-features = false }
    scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
    scale-info = { version = "2", default-features = false, features = ["derive"], optional = true }
  • rustc: 1.66.0-nightly


The template code

cargo contract new alpha403

I have checked the version of parity-scale-codec, it is version 3 in both my ink! project and in the ink package of version 4.0.0-alpha.3.

  • I have same Environment as yours except OS: macOS Monterey and I haven't faced issue.
    – go11li
    Commented Sep 29, 2022 at 11:18

2 Answers 2


Your problem is that you're using a nightly compiler to build your contract. With the recent alphas it is now possible to build contracts using the stable toolchain.

If you run cargo +stable contract build everything should work as expected.


check out cargo tree, than just:

$ cargo tree | grep scale-codec

To find out if you have multiple dependencies with different versions in the repo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.