3

I'm working with the node template and I want a particular type of extrinsic to not have to pay a fee. I followed these instructions but whenever I add another value to the "pallet::weight(10_000)" tuple after the weight data and do "cargo build --release", I get this error.

error: unexpected token
  --> pallets/wavefunction/src/lib.rs:71:32
   |
71 |         #[pallet::weight(10_000, Pays::No)]
   |  

You can't see it here but in my terminal there's a caret pointing to the comma between "10_000" and "Pays::No". Clearly it doesn't like the comma but the documentation says that it's fine. I've tried it with a fresh template and with different types of weight values (10_000, 1000, etc. ) and the build works fine. I only get this error when I try to add an additional value to the tuple like the dispatch class or whether or not a fee should be paid. I've tried it without using any commas but I just get another error.

This is the version of the Rust toolchain I'm using

active toolchain
----------------

stable-x86_64-unknown-linux-gnu (default)
rustc 1.59.0 (9d1b2106e 2022-02-23)

1 Answer 1

4

I think this is a mistake in the docs, rather than:

#[pallet::weight(10_000, Pays::No)]

it should be as a tuple:

#[pallet::weight((10_000, Pays::No))]

I agree it would be nicer if this wasn't the case... but for now I'll fix the instructions.

2
  • 2
    PR to fix the docs: github.com/substrate-developer-hub/substrate-docs/pull/953 (Thank you for spotting this and bringing attention to it)
    – Squirrel
    Apr 15, 2022 at 12:52
  • Thanks @Squirrel. I discovered this solution as well in the middle of the night and came back to post this answer. I've encountered this exact same missing tuple parentheses discrepancy in the documentation of other languages/frameworks too.
    – arx12
    Apr 15, 2022 at 18:08

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.