How can I call an extrinsic on a palette using the polkadot-js-api CLI tool? I don't see much documentation on the tool nor does the --help provide much detail. Could I use this tool for this purpose? I would like to call an extrinsic that takes a local file as input using the @ parameter and passes the contents to a custom extrinsic on a custom palette. If not, what are some other tools I could use rather than coding my own?

polkadot-js-api --help   

Usage: [options] <endpoint> <...params>
Example: query.system.account 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKv3gB
Example: query.substrate.code --info
Example: --seed "//Alice" tx.balances.transfer F7Gh 10000

  --help                 Show help                                                                             [boolean]
  --version              Show version number                                                                   [boolean]
  --assetId              The asset id to add to the transaction for payment                                     [number]
  --info                 Shows the meta information for the call                                               [boolean]
  --noWait               After sending a tx return immediately and don't wait until it is included in a block  [boolean]
  --params               Location of file containing space-separated transaction parameters (optional)          [string]
  --rpc                  Add this .json file as RPC types to the API constructor                                [string]
  --seed                 The account seed to use (required for tx.* only)                                       [string]
  --sign                 The account crypto signature to use (required fo tx.* only)
                                      [string] [choices: "ed25519", "sr25519", "ethereum", "ecdsa"] [default: "sr25519"]
  --sub                  With this flag set, perform subscription, running until exited with ^C                [boolean]
  --sudo                 Run this tx as a wrapped sudo.sudo call                                               [boolean]
  --sudoUncheckedWeight  Run this tx as a wrapped sudo.sudoUncheckedWeight call with weight                     [string]
  --tip                  Add a tip to the transction for the block author                                       [number]
  --types                Add this .json file as types to the API constructor                                    [string]
  --ws                   The API endpoint to connect to, e.g. wss://kusama-rpc.polkadot.io

1 Answer 1


Here is an example how to upload a wasm blob as a file by calling setCode of the system module https://github.com/polkadot-js/tools/tree/master/packages/api-cli#files-as-parameters

I suggest trying a similar command with your module's extrinsic.

  • PS I just tried this command with a local node running with a pallet-contracts: polkadot-js-api tx.contracts.uploadCode @test.wasm 1000000 --seed "//Alice" and it worked
    – Lana I
    Sep 9, 2022 at 8:54

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .