
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600× Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
@polkadot/api-cli
Advanced tools
A simple cli interface to the @polkadot/api.
Commands are of the form,
yarn run:api [options] <type> <...params>
Where type is the type of query to be made, this takes the form of <type>.<section>.<method>
where type
is one of consts
, derive
, query
, rpc
tx
(mapping to the API) and the section
and method
are available calls.
For instance to make a query to retrieve Alice's balances, you can do
yarn run:api query.system.account 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
To do the same, running as a subscription and streaming results
yarn run:api query.system.account 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY --sub
To make a transfer from Alice to Bob, the following can be used -
yarn run:api tx.balances.transfer 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty 12345 --seed "//Alice"
You can pass complex parameters as JSON which will be automatically parsed into the correct data structure
yarn run:api --sudo tx.validatorManager.registerValidators '["5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY","5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty"]'
It is often desirable to include large binary blobs as transaction parameters. These blobs are often already present in the local filesystem. Therefore, the CLI has special syntax to make life easier: any transaction parameter whose initial character is @
is treated as a path to a binary file; its contents are automatically converted into appropriate hex form before sending the tx.
The sudo
example demonstrates this.
Some transactions require superuser access. For example, to change the runtime code, you can do
yarn run:api --sudo --seed "//Alice" tx.system.setCode @test.wasm
In all cases when sudoing, the seed provided should be that of the superuser. For most development nets, that is "//Alice"
.
Transactions can now be submitted using an encoded hex call. This is useful for complex extrinsics that are difficult to craft manually via the CLI. Instead, build the transaction using the Polkadot-JS Apps UI, copy the encoded call, and execute it via CLI.
yarn run:api --encodedCall <encoded_call> --seed "<seed>" --ws <ws_endpoint>
yarn run:api --encodedCall 0x050300fe580ec5fe0e9569d645375acecf5aa19bc0b3188ddd2e2ffc68f6548590d61e0700e8764817 --seed "//Alice" --ws wss://paseo-rpc.dwellir.com
$ yarn global add @polkadot/api-cli
$ polkadot-js-api ...
The --ws
param can be used to connect to other Websocket endpoints, when submitting transactions, you can use the --seed <seed>
to specify an account seed. To read documentation on a call, use the --info
command.
To specify types for a specific chain, you can use the --types <types.json>
param, injecting the specified types into the API on construction.
To specify RPC types for a specific chain, you can use the --rpc <rpc.json>
param, injecting the specified RPC types into the API on construction.
For a complete list of available commands, you can use --help
FAQs
A commandline API interface for interacting with a chain
We found that @polkadot/api-cli demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.