I want to run and build contract by thia command :

Step 1: cargo contract new my_contract

Step 2: cargo contract build

when i want to run Step 2 and i faced this error :

ERROR: cargo-contract cannot build using the "stable" channel. Switch to nightly. See https://github.com/paritytech/cargo-contract#build-requires-the-nightly-toolchain

rustc Version :

    cargo 1.69.0-nightly (82c3bb79e 2023-02-04)
release: 1.69.0-nightly
commit-hash: 82c3bb79e3a19a5164e33819ef81bfc2c984bc56
commit-date: 2023-02-04
host: x86_64-unknown-linux-gnu
libgit2: 1.5.0 (sys:0.16.0 vendored)
libcurl: 7.86.0-DEV (sys:0.4.59+curl-7.86.0 vendored ssl:OpenSSL/1.1.1q)
os: Ubuntu 22.04 (jammy) [64-bit]

whats the problem ? how can i solve this ?

1 Answer 1


It depends on the cargo-contract version. Pre 2.0.0 versions of cargo-contract use the nightly toolchain of rust. You can get it with rustup toolchain add nightly and then build with cargo +nightly contract build. You can omit the +nightly if you set the nightly toolchain as default with rustup default nightly.

ink! contracts where version < 4.0.0 need to be built with cargo-contract version < 2.0.0, therefore also with the nightly toolchain.

ink! 4 contracts need to be built with cargo-contract version 2 and can be built with both the stable and nightly toolchain.

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.