3

I'm running into an issue where I cannot deploy contracts to my chain, any help is appreciated.

I'm using the same setup as: https://github.com/paritytech/substrate/blob/632b32300eb9376767c2ae7b38e79b3f7f5329b1/bin/node/runtime/src/lib.rs#L887-L903 (as referenced in the guide here: https://docs.substrate.io/how-to-guides/v3/pallet-design/contracts-pallet/) to integrate with the contracts pallet and rpc (using version 4.0.0-dev) and regardless of the funds held by an account (using 1 << 60 as default balance in my chain spec), I receive the "NewContractNotFunded" error when trying to deploy any contract.

Is this an issue with version 4.0.0-dev, or an issue with my setup? Is a rebase required or is there something else I can do?

My runtime config is here: https://github.com/driemworks/substrate/blob/1fabe26f239166e210f723756812d7eca069e41e/bin/node-template/runtime/src/lib.rs#L270

My initial thoughts were that I need to upgrade my fork to the latest Substrate master branch. However, a dependency in my fork (rust-ipfs) requires an older version of libp2p (0.39.1) that brings in an older version of libp2p-noise (0.32.0). With the changes made to the master branch, compilation fails with:

    error[E0282]: type annotations needed
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/libp2p-noise-0.32.0/src/protocol/x25519.rs:221:45
    |
221 |         curve25519_sk.copy_from_slice(&hash.as_ref()[..32]);
    |                                        -----^^^^^^--
    |                                        |    |
    |                                        |    cannot infer type for type parameter `T` declared on the trait `AsRef`
    |                                        this method call resolves to `&T`
    |
    = note: type must be known at this point

I've tried downgrading libp2p back to 0.39.1, however, I encounter the issue regardless.

3
  • Is your contract constructor payable? Is the gas limit high enough for the constructor to be executed? Can you share your contract deploy code?
    – forgetso
    Mar 4, 2022 at 11:57
  • It looks like in the example code that a value of 1 is being passed to the contract as a deposit. Maybe this needs to be increased?
    – forgetso
    Mar 4, 2022 at 14:07
  • 1
    My contract code is available here github.com/driemworks/contracts/blob/dev/test/lib.rs. I made the contract constructor payable AND IT WORKED! Thank you!
    – Tony
    Mar 4, 2022 at 18:19

1 Answer 1

2

The answer here was to make the contract payable.

This is a fairly recent change to ink contracts that requires the constructors to be decorated with payable if it's intended for them to receive value (i.e. tokens).

e.g.

impl Dapp {
    /// Creates a new payable contract
    #[ink(constructor, payable)]
    pub fn new(initial_supply: Balance) -> Self {
        ...
    }

Source: https://github.com/paritytech/ink/blob/07a8ed9b14a768b87f69dfcd6fedc580c7f36e0e/RELEASES.md#constructors-got-a-new-field-payable-bool

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.