Git Product home page Git Product logo

solana-cli-template's Introduction

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

solana-cli-template's People

Contributors

cluutch avatar joncinque avatar mvines avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

solana-cli-template's Issues

PR Potential

@mvines Wanted run the PR idea by you

  1. Add a program source directory to the template that demonstrates exercising various program instructions, account state (data) management, etc.
  2. Add a keys directory to support faux program wallets and account keys
  3. Add a tests directory with multiple test run scenarios (i.e. "no batteries required", etc.)

I realize there are lots of sample programs but my thoughts are that the intent of the template is to kick start others CLI implementations with boiler plate simplicity.

Thoughts?

And, if you agree its a worthy addition, are we doing Draft PR's with incremental updates for review before finalizing? Or...?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.