Node Template
Command-line reference information for the node-template.
The node-template
program provides a working Substrate node with FRAME system pallets and a subset of additional pallets for working with common blockchain functional operations. With its baseline of functional pallets, the node-template
serves as a starter kit for building your own blockchain and developing a custom runtime. You can use the node-template
program to start a Substrate node and to perform the tasks listed in Subcommands.
Basic command usage
The basic syntax for running node-template
commands is:
Depending on the subcommand you specify, additional arguments, options, and flags might apply or be required. To view usage information for a specific node-template
subcommand, specify the subcommand and the --help
flag. For example, to see usage information for node-template key
, you can run the following command:
Flags
You can use the following optional flags with the node-template
command.
Options
You can use the following options with the node-template
command.
Subcommands
You can use the following subcommands with the node-template
command. For reference information and examples that illustrate using these subcommands, select an appropriate command.
benchmark
Use the node-template benchmark
command to analyze the resources required to execute the transactions in extrinsic calls you have configured in runtime pallets. You can analyze individual extrinsic calls in specific pallets or all extrinsic calls in all pallets. With the benchmark
subcommand, you can use additional command-line options to test different execution scenarios and compare the results.
Note that you must compile the node with benchmarking enabled to use all subcommands of node-template benchmark
. To compile the node with benchmarking features enabled, run the following command:
Basic command usage
Depending on the subcommand you specify, additional arguments, options, and flags might apply or be required. To view usage information for a specific benchmark
subcommand, specify the subcommand and the --help
flag. For example, to see usage information for benchmark pallet
, you can run the following command:
Subcommands
You can use the following subcommands with the node-template benchmark
command.
Flags
You can use the following optional flags with the node-template benchmark
command.
Options
You can use all of the common node-template command-line options in combination with node-template benchmark
subcommands. For example, you can use --base-path <path>
to specify a custom directory for blockchain data and --chain <chain-specification>
to specify the chain specification to use with any benchmark
subcommand.
However, there are many command-line options that are specifically for performing benchmarking tasks. For example, the node-template benchmark block
subcommand supports --from
and --to
command-line options for specifying the blocks to analyze.
Because benchmarking FRAME pallets represents the most common benchmarking task, the node-template benchmark pallet
subcommand supports the most task-specific command-line options. For example, you can use the following options with the node-template benchmark pallet
subcommand.
For examples of different benchmarking subcommands and the related command-line options, see Benchmarking examples.
Benchmarking examples
After you have compiled the runtime with benchmarking enabled, you can run a command similar to the following to benchmark all of the function calls in all of the pallets that have runtime-benchmarking configured:
With this command, each function call is executed once with a single value and the resulting weight is recorded in the weights.rs
file.
Depending on the function you want to benchmark, you can add the --steps
and --repeat
command-line options to execute the call multiple times with different values. For example, the following command executes the do_something
function in the pallet_template
and calls the function 20 times to take 10 data points:
With the --list
option, the command displays the following output:
With the --steps
and --repeat
command-line options, the command displays the following benchmarking results:
To measure the average, median, minimum, and maximum execution time per-block and per-extrinsic, you can run the node-template benchmark overhead
subcommand:
The command displays output similar to the following:
By default, the command executes the benchmark 100 times, generates results, and writes the output to the block_weights.rs
and extrinsics_weights.rs
files. You can use command-line options to adjust the calculated weight by adding units or by multiplying the average execution time by some factor.
To measure the storage execution time for the Substrate development chain specification, you can run the following command:
The command displays output similar to the following:
To get benchmarking information for the paritydb
database instead of the default rocksdb
database, use the --db paritydb
command-line option. TO get storage benchmarking information for Polkadot or any other real chain snapshot, use the command-line option --state-version 0
. For more information about using the benchmark storage subcommand, see benchmark storage command.
For more information about how to add benchmarking to the runtime, see Benchmark and Add benchmarks.
build-spec
Use the node-template build-spec
command to create a chain specification file for your runtime.
Basic command usage
Flags
You can use the following optional flags with the node-template build-spec
command.
Options
You can use the following command-line options with the node-template build-spec
command.
Examples
To export the predefined local
chain specification to a file named customSpec.json
, you can run the following command:
If you have previously created a JSON file that contains a custom chain specification, you can specify the path to that file and use the --raw
command-line option to export the chain specification with encoded storage keys that the node uses to reference the data in its local storage.
check-block
Use the node-template check-block
command to validate a specific block. You must specify the block to validate by the block hash or block number.
Basic command usage
Flags
You can use the following optional flags with the node-template check-block
command.
Options
You can use the following command-line options with the node-template check-block
command.
Arguments
You must specify the following command-line argument when you run the node-template check-block
command.
export-blocks
Use the node-template export-blocks
command to export blocks.
Basic command usage
Flags
You can use the following optional flags with the node-template export-blocks
command.
Options
You can use the following command-line options with the node-template export-blocks
command.
Arguments
You can specify the following command-line argument when you run the node-template export-blocks
command.
export-state
Use the node-template export-state
command to export the state of a given block into a chain specification.
Basic command usage
Flags
You can use the following optional flags with the node-template export-state
command.
Options
You can use the following command-line options with the node-template export-state
command.
Arguments
You can specify the following command-line argument when you run the node-template export-state
command.
help
Use the node-template help
command to display usage information for node-template
or a summary of command-line usage information for any node-template
subcommand.
Basic command usage
Examples
To display a summary of usage information for the export-blocks
subcommand, run the following command:
import-blocks
Use the node-template import-blocks
command to import blocks.
Basic command usage
Flags
You can use the following optional flags with the node-template import-blocks
command.
Options
You can use the following command-line options with the node-template import-blocks
command.
Arguments
You can specify the following command-line argument when you run the node-template import-blocks
command.
key
Use the node-template key
command to generate, inspect, and manage private and public key pairs and addresses. The node-template key
command provides convenient access to a subset of key management services that are available in the standalone subkey
program. For complete details about the subcommands and command-line options for most node-template key
subcommands, see subkey
. Although most of the node-template key
subcommands are identical to [subkey
] subcommands, the node-template key insert
subcommand is not a supported [subkey
] subcommand. The node-template key insert
subcommand enables you to add generated keys directly to a node keystore. For information about the command-line options and arguments to use with the node-template key insert
subcommand, see Insert a key on a node or run the following command:
Basic command usage
Flags
You can use the following optional flags with the node-template key
command.
Subcommands
You can use the following subcommands with the node-template key
command.
Insert a key on a node
Use the node-template key insert
command to add the keys used for performing node operations to the node keystore. For example, keys are required to secure peer-to-peer communication between nodes and to enable nodes to act as validating authorities for consensus.
Basic command usage
Flags
You can use the following optional flags with the node-template key insert
command.
Options
You can use the following command-line options with the node-template key insert
command.
purge-chain
Use the node-template purge-chain
command to remove a blockchain and all blockchain-related information.
Basic command usage
Flags
You can use the following optional flags with the node-template purge-chain
command.
| -V
, --version
| Displays version information. -y
| Provides a preemptive yes
response to skip the interactive prompt to confirm that you want to remove the chain.
Options
You can use the following command-line options with the node-template purge-chain
command.
revert
Use the node-template revert
command to revert the chain to a previous state.
Basic command usage
Flags
You can use the following optional flags with the node-template revert
command.
Options
You can use the following command-line options with the node-template rever
command.
Arguments
You can use the following command-line argument with the node-template revert
command.
Last updated