Solana CookbookDevelopment
How to Start a Local Validator
Use solana-test-validator
to run your code locally. Install the
Solana CLI and run the following command:
Terminal
$solana-test-validator
Usage
solana-test-validator [FLAGS] [OPTIONS] --ledger <DIR>
Flags
Flag | Description |
---|---|
--clone-feature-set | Copy a feature set from the cluster referenced by the --url argument in the genesis configuration. If the ledger already exists then this parameter is silently ignored |
--help , -h | Prints help information |
--log | Log mode: stream the validator log |
--quiet , -q | Quiet mode: suppress normal output |
--reset , -r | Reset the ledger to genesis if it exists. By default the validator will resume an existing ledger (if present) |
--rpc-pubsub-enable-block-subscription | Enable the unstable RPC PubSub blockSubscribe subscription |
--rpc-pubsub-enable-vote-subscription | Enable the unstable RPC PubSub voteSubscribe subscription |
--version , -V | Prints version information |
Options
Option | Description |
---|---|
--account <ADDRESS> <DUMP.JSON> | Load an account from the provided JSON file (see solana account --help on how to dump an account to file). Files are searched for relatively to CWD and tests/fixtures. If ADDRESS is omitted via the - placeholder, the one in the file will be used. If the ledger already exists then this parameter is silently ignored |
--account-dir <DIRECTORY> | Load all the accounts from the JSON files found in the specified DIRECTORY (see also the --account flag). If the ledger already exists then this parameter is silently ignored |
--account-index <INDEX> | Enable an accounts index, indexed by the selected account field [possible values: program-id, spl-token-owner, spl-token-mint] |
--bind-address <HOST> | IP address to bind the validator ports Default: 0.0.0.0 |
--bpf-program <ADDRESS_OR_KEYPAIR> <SBF_PROGRAM.SO> | Add a SBF program to the genesis configuration with upgrades disabled. If the ledger already exists then this parameter is silently ignored. The first argument can be a pubkey string or path to a keypair |
--clone <ADDRESS> , -c | Copy an account from the cluster referenced by the --url argument the genesis configuration. If the ledger already exists then this parameter is silently ignored |
--clone-upgradeable-program <ADDRESS> | Copy an upgradeable program and its executable data from the cluster referenced by the --url argument the genesis configuration. If the ledger already exists then this parameter is silently ignored |
--compute-unit-limit <COMPUTE_UNITS> | Override the runtime's compute unit limit per transaction |
--config <PATH> , -C | Configuration file to use Default: $HOME/.config/solana/cli/config.yml |
--deactivate-feature <FEATURE_PUBKEY> | Deactivate this feature in genesis |
--dynamic-port-range <MIN_PORT-MAX_PORT> | Range to use for dynamically assigned ports Default: 1024-65535 |
--faucet-port <PORT> | Enable the faucet on this port Default: 9900 |
--faucet-sol <SOL> | Give the faucet address this much SOL in genesis. If the ledger already exists then this parameter is silently ignored Default: 1000000 |
--faucet-per-request-sol-cap <SOL> | Per-request limit for faucet requests, in SOL |
--faucet-per-time-sol-cap <SOL> | Per-time slice limit for faucet requests, in SOL |
--faucet-time-slice-secs <SECS> | Time slice (in secs) over which to limit faucet requests Default: 60 |
--geyser-plugin-config <FILE> | Specify the configuration file for the Geyser plugin |
--gossip-host <HOST> | Gossip DNS name or IP address for the validator to advertise in gossip Default: 127.0.0.1 |
--gossip-port <PORT> | Gossip port number for the validator |
--ledger <DIR> , -l | Use DIR as ledger location Default: test-ledger |
--limit-ledger-size <SHRED_COUNT> | Keep this amount of shreds in root slots Default: 10000 |
--log-messages-bytes-limit <BYTES> | Maximum number of bytes written to the program log before truncation |
--maybe-clone <ADDRESS> | Copy an account from the cluster referenced by the --url argument, skipping it if it doesn't exist. If the ledger already exists then this parameter is silently ignored |
--mint <PUBKEY> | Address of the mint account that will receive tokens created at genesis. If the ledger already exists then this parameter is silently ignored Default: client keypair |
--rpc-port <PORT> | Enable JSON RPC on this port, and the next port for the RPC websocket Default: 8899 |
--slots-per-epoch <SLOTS> | Override the number of slots in an epoch. If the ledger already exists then this parameter is silently ignored |
--ticks-per-slot <TICKS> | The number of ticks in a slot |
--transaction-account-lock-limit <NUM_ACCOUNTS> | Override the runtime's account lock limit per transaction |
--upgradeable-program <ADDRESS_OR_KEYPAIR> <SBF_PROGRAM.SO> <UPGRADE_AUTHORITY> | Add an upgradeable SBF program to the genesis configuration. If the ledger already exists then this parameter is silently ignored. First and third arguments can be a pubkey string or path to a keypair. Upgrade authority set to "none" disables upgrades |
--url <URL_OR_MONIKER> , -u | URL for Solana's JSON RPC or moniker (or their first letter): [mainnet-beta, testnet, devnet, localhost] |
--warp-slot <WARP_SLOT> , -w | Warp the ledger to WARP_SLOT after starting the validator. If no slot is provided then the current slot of the cluster referenced by the --url argument will be used |
Is this page helpful?