Learn Solana CLI
Wallet types
- file
- paper
- hardware
Create wallet
create wallet (key-pair)
1 | // file wallet |
the public key will display on the terminal
if you didn’t save the pubkey, it’s fine.
we can get the pubkey from private-key
1 | solana-keygen pubkey YOUR-PRIVATE-KEY-FILE-PATH |
Verify key-pair
1 | solana-keygen verify PUBKEY PRIVATE-KEY-FILE-PATH |
Interact with wallet
pubkey
aka.address
aka.wallet address
config
1 | solana config get |
set URL to dev-net for developing
1 | solana config set --url https://api.devnet.solana.com |
send 1 SOL to address
1 | solana airdrop 1 PUBKEY |
get balance of address
1 | solana balance PUBKEY |
transfer
- from
- to
- amount
- fee-payer
1 | solana transfer --from <KEYPAIR> \ |
Stake
create stake account
1 | // first create a keypair for account address |
get account
1 | solana stake-account <STAKE_ACCOUNT_ADDRESS> |
update account auth
1 | solana stake-authorize <STAKE_ACCOUNT_ADDRESS> \ |
Delegate Stake (質押)
list available validators
1 | solana validators |
delegate
1 | solana delegate-stake --stake-authority <KEYPAIR> <STAKE_ACCOUNT_ADDRESS> <VOTE_ACCOUNT_ADDRESS> \ |
deactive
1 | solana deactivate-stake --stake-authority <KEYPAIR> <STAKE_ACCOUNT_ADDRESS> \ |
withdraw sol
only work when the stake-account deactived
1 | solana withdraw-stake --withdraw-authority <KEYPAIR> <STAKE_ACCOUNT_ADDRESS> <RECIPIENT_ADDRESS> <AMOUNT> \ |
split
You may want to delegate stake to additional validators while your existing stake is not eligible for withdrawal. It might not be eligible because it is currently staked, cooling down, or locked up. To transfer tokens from an existing stake account to a new one
1 | solana split-stake --stake-authority <KEYPAIR> <STAKE_ACCOUNT_ADDRESS> <NEW_STAKE_ACCOUNT_KEYPAIR> <AMOUNT> \ |