2

I was looking to implement smart-contract into substrate-node-template as I do not want to use substrate-contracts-node. I was trying to follow this guide - https://substrate-developer-hub.github.io/substrate-how-to-guides/docs/pallet-design/add-contracts-pallet/

However, I went into this error the moment I've insert the dependencies and tried cargo build.

# Contracts specific packages
pallet-contracts = { git = "https://github.com/paritytech/substrate", package = "pallet-contracts", default-features = false, branch = "polkadot-v0.9.42" }
pallet-contracts-primitives = { git = "https://github.com/paritytech/substrate", package = "pallet-contracts-primitives", default-features = false, branch = "polkadot-v0.9.42" }

There are a total of 11 errors and these are two of most common ones.

error: cannot find macro `vec` in this scope
   --> /home/<name>/.cargo/git/checkouts/substrate-7e08433d4c370a21/3bb3882/frame/contracts/src/lib.rs:549:6
    |
549 |                     vec![T::Hashing::hash_of(&dest), code_hash, contract.code_hash],

error: cannot find macro `thread_local` in this scope
   --> /home/<name>/.cargo/git/checkouts/substrate-7e08433d4c370a21/3bb3882/frame/contracts/src/lib.rs:975:3
    |
975 |         environmental!(executing_contract: bool);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

My current setup is vanilla, cloned from - https://github.com/substrate-developer-hub/substrate-node-template

This is my current rustc version

rustup 1.26.0 (5af9b9484 2023-04-05)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.71.0-nightly (74c482104 2023-05-04)`

Things I tried to do:

Side note: is there any updated tutorial on implementing smart contract into substrate node template?

1 Answer 1

2

This is a good basic tutorial on adding a pallet (I am sure you are aware of it):

Generally speaking, whenever I want to add a pallet, I refer to the "kitchensink" runtime, as it has a conglomerate of pallets already configured:

I also put together a repo for you. It is the substrate-node-template with pallet contracts. You can follow the commits to see how I added it.

Keep in mind this is for demo purposes and the you may want to change the contracts pallet config to your liking.

2

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.