0

I am performing the (add the contracts pallet to a runtime) substrate tutorial and I am getting this error

error[E0405]: cannot find trait Trait in crate pallet_contracts --> runtime/src/lib.rs:279:24 | 279 | impl pallet_contracts::Trait for Runtime { | ^^^^^ not found in pallet_contracts

can anyone tell me what should I do to solve this error

3 Answers 3

1

There is a Parity repository called substrate-contracts-node, it's a Substrate node configured to include pallet-contracts.

You can take a look at how the trait is implemented here: https://github.com/paritytech/substrate-contracts-node/blob/main/runtime/src/lib.rs#L272-L320.

0

You should implement contracts' Config, not just Trait.
Use impl pallet_contracts::Config for Runtime.
Here is my example of implementation

3
  • I had already tried using Config but then I am getting more errors like error[E0437]: type RentPayment is not a member of trait pallet_contracts::Config error[E0437]: type SignedClaimHandicap is not a member of trait pallet_contracts::Config ` error[E0437]: type TombstoneDeposit is not a member of trait pallet_contracts::Config and many more . Commented Jul 11, 2022 at 14:21
  • Could you share a link to your github repo or pastebin with the code?
    – CREESTL
    Commented Jul 11, 2022 at 16:19
  • This is the link to my runtime/lib.rs file github.com/vitthalagarwal/Pallet-Contracts/blob/main/runtime/… Commented Jul 12, 2022 at 7:04
0

With regards to the naming of the trait,

the Trait name was used for config traits in the older version of substrate. This name has been replaced with Config.

Therefore, instead of using:

impl pallet_contracts::Trait for Runtime {
//define types here
}

you should use:

impl pallet_contracts::Config for Runtime {
//define types here
}

The errors you're getting with regards to the RentPayment and SignedClaimHandicap types are occurring because these types are non-existent. They aren't declared in the contracts pallet's Config trait (they may have been there in older versions, but have been removed).

You should use the up-to-date tutorial here

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.