Skip to content

mvines/solana-cli-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quick start

  1. Install Rust from https://rustup.rs/
  2. cargo run

Want Batteries Included?

This template is intentionally minimal. For a template that's more functional out of the box, try https://github.com/hashblock/solana-cli-program-template

About

solana-cli-template is a sample app demonstrating the creation of a minimal CLI application written in Rust to interact with Solana. It provides three pieces of functionality:

  • ping: Creates a transaction sending 0 SOL from the signer's account to the signer's account. Returns the signature of the transaction.
  • balance: Returns the account's balance.
  • help: Tips for using the app. This is an off-chain operation.

Local step-by-step

  1. Prepare account:
  • Start a local node: run solana-test-validator.
  • Generate a keypair: solana-keygen new -o test.json.
  • Add 100 SOL to the corresponding account solana airdrop --url http://127.0.0.1:8899 --keypair test.json 100.
  1. Build app: cargo run.

  2. Ping:

$ cargo run -- ping --url http://127.0.0.1:8899 --keypair test.json
Signature: 2Y863JX96RTqbeGfcvQowVt1V91Dgs2LZfVgQ3mGJPmYu24sUTYmfkArHAAgj4uFqP75bm9GXU9DYjiMFxahQJUC
  1. Balance:
$ cargo run -- balance --url http://127.0.0.1:8899 --keypair test.json
3dSRGE3wYCcGWFrxAsQs5PaBqtJzzxdTzY2ypXNFUji9 has a balance of ◎99.999995000 // balance less than 100 because of ping operation above
  1. Run help for the complete list of options:
$ cargo run -- --help
cli-template 0.1.0


USAGE:
    cli-template [FLAGS] [OPTIONS] <SUBCOMMAND>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information
    -v, --verbose    Show additional information

OPTIONS:
    -C, --config <PATH>        Configuration file to use [default: /Users/user/.config/solana/cli/config.yml]
        --url <URL>            JSON RPC URL for the cluster [default: value from configuration file]
        --keypair <KEYPAIR>    Filepath or URL to a keypair [default: client keypair]

SUBCOMMANDS:
    balance    Get balance
    help       Prints this message or the help of the given subcommand(s)
    ping       Send a ping transaction

About

Solana command-line tool template

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •