遵循《将Pallet添加到Runtime》教程添加nicks Pallet后调用setName extrinsic失败问题排查咨询
setName Failure with Nicks Pallet in Substrate Runtime Hey there, let's walk through how to figure out why your setName extrinsic is failing with that system:ExtrinsicFailed error. The Module(index:9, error:0) code gives us a clear starting point—here are the key areas to check:
Map the error code to the Nicks pallet's specific issue
First, confirm that module index 9 is assigned to the Nicks pallet in yourconstruct_runtime!macro (that's where each pallet gets its unique index). Then, look at the Nicks pallet'sErrorenum—error code 0 is almost always the first variant, which for Nicks is typicallyInvalidName. This triggers if the name you're trying to set breaks the pallet's rules: maybe it's too long, contains invalid characters, or is empty. Double-check the name you're submitting against the pallet'sMaxLengthparameter and allowed character set.Validate your Nicks pallet runtime configuration
Make sure you've correctly set up the Nicks pallet's required traits in your runtime. Specifically:- The
Currencytype is properly linked to your runtime's currency pallet (Nicks needs this to hold the name deposit). - The
ReservationCurrencyis configured if you're using that feature. - The
MaxLengthparameter is set to a value that makes sense for your use case—if your name exceeds this length, the extrinsic will fail.
- The
Check the signer's balance and extrinsic parameters
ThesetNamecall requires a deposit to reserve funds from the signer's account. If the account you're using doesn't have enough free balance to cover this deposit, that could cause a failure (even if it's a different error code, it's worth ruling out). Also, double-check the name parameter you're passing: ensure it's not empty, and doesn't include any characters the pallet blocks (like whitespace or special symbols, depending on your setup).Confirm your runtime build is up-to-date
Sometimes cached builds can leave you running an outdated version of your runtime. Try runningcargo cleanto clear old build artifacts, then rebuild your node. Also, verify that the commit you referenced (with your Nicks pallet additions) is actually the version running on your node—you can check this via thesystem_versionRPC call in Polkadot JS Apps.Get a human-readable error message
The raw error code doesn't tell the whole story. In Polkadot JS Apps, after the failed transaction, click on the error entry to expand it—you should see a human-friendly message that explicitly states why the extrinsic failed (like "Invalid name length" or "Insufficient balance"). You can also use thesystem_dispatchErrorRPC call to decode the error code into a readable format.
内容的提问来源于stack exchange,提问作者Larry Dixon

