solana-cli-program template is a sample app demonstrating the creation of a minimal CLI application written...

solana-cli-program template is a sample app demonstrating the creation of a minimal CLI application written in Rust to interact with Solana and programs

About

solana-cli-program template is a sample app demonstrating the creation of a minimal CLI application written in Rust to interact with Solana and programs. It provides multiple 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.
  • mint: Mint a key/value pair to an owning account.
  • transfer: Transfer a key, and it's value, from one owning account to another.
  • burn: Burn (delete) a key, and it's value, from an owning account.
  • balance: Returns an account's balance.
  • help: Tips for using the app. This is an off-chain operation.

solana-cli-program template is a derived work inspired by @mvines solana-cli-template

Structure

A functional macro level view

Quick start

  1. Install Rust from https://rustup.rs/
  2. Clone this repo
  3. If running the integration tests or Mint, Transfer, Burn instructions:
cd program
cargo build-bpf
cd ..
  1. cargo run help

Sample keys

The repo includes sample keys for 'owners'. There are two owner accounts predefined User1 and User2, each with two keypairs defined:

  1. An owners 'wallet' account. This is funded by the Solana configurations default account and is used to fund program accounts.
  2. An owners program 'account' which is used by the sample program for mint, transfer and burn operations
  • There is a third account called Service which is used for program instructions that exact a fee for the instruction execution. These are executed as part of the integration tests only

Running locally step-by-step

  1. If not running Mint, Transfer and/or Burn:
  • Start a local node: run solana-test-validator.
  • Optionally generate a keypair: solana-keygen new -o test.json.
  • Optionally add 100 SOL to the corresponding account solana airdrop --url http://127.0.0.1:8899 --keypair test.json 100.
  1. For running Mint, Transfer and/or Burn:
  • Start a local node and load the sample program solana-test-validator --bpf-program SampGgdt3wioaoMZhC6LTSbg4pnuvQnSfJpDYeuXQBv ~/solana-cli-program-template/program/target/bpfel-unknown-unknown/release/solana_cli_template_program_bpf.so --ledger ~/solana-cli-program-template/.ledger --reset
  1. Build app: cargo run.

  2. Ping:

$ cargo run -- ping --url http://127.0.0.1:8899 --keypair test.json
Signature: 2Y863JX96RTqbeGfcvQowVt1V91Dgs2LZfVgQ3mGJPmYu24sUTYmfkArHAAgj4uFqP75bm9GXU9DYjiMFxahQJUC
  1. Mint (no fee):
cargo run -- mint --url http://127.0.0.1:8899 -t User1 -k AKey --value Minted key value pair
User1 to account key/value store {"AKey": "Minted key value pair"}
  1. Transfer (no fee):
cargo run -- transfer --url http://127.0.0.1:8899 -f User1 -t User2 -k AKey
User1 from account key/value store {}
User2 to account key/value store {"AKey": "Minted key value pair"}
  1. Burn (no fee):
cargo run -- burn --url http://127.0.0.1:8899 -f User2 -k AKey
User2 from account key/value store {}
  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
$ cargo run -- balance --url http://127.0.0.1:8899 --keypair keys/accounts/user1_account.json
A94wMjV54C8f8wn7zL8TxNCdNiGoq7XSN7vWGrtd4vwU has a balance of ◎0.008017920 // after first running 'mint'
  1. Run help for the complete list of options:
$ cargo run -- --help
cli-program-template 0.1.0


USAGE:
    cli-program-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
  burn        Burn (delete) a key/value pair from an account
  help        Prints this message or the help of the given subcommand(s)
  mint        Mint a new key/value pair to an account
  ping        Send a ping transaction
  transfer    Transfer a key/value pair from one account to another
Issues

Collection of the latest Issues

Information - Updated Jun 01, 2022

Stars: 35
Forks: 11
Issues: 1

Rust Compiled Templates — ructe

This is my attempt at writing a HTML template system for Rust

Rust Compiled Templates — ructe

Yet Another Rust Template Engine

bytes-buf feature can produce SIGILL

Yet Another Rust Template Engine

Advent of Code Rust Template

Advent of Code Rust template from

Advent of Code Rust Template

rust-parcel-template

Kickstart your Rust, WebAssembly, and Parcel project!

rust-parcel-template

Rust CLI template

A quick and dirty CLI boilerplate template for Rust

Rust CLI template

SixtyFPS Rust Template

A template for a Rust application that's using SixtyFPS for the user interface

SixtyFPS Rust Template

Rust CLI Template

Template for creating Rust-based CLI tools

Rust CLI Template

Embedded Rust Template

This template is based on stm32f4xx-hal

Embedded Rust Template

serverless AWS Rust template

A sample template for bootstrapping serverless framework cli

serverless AWS Rust template

rust-nix-templater

Generates Rust projects which use devshell, supports top-level devshell

rust-nix-templater

serverless AWS Rust template

A sample template for bootstrapping serverless framework cli

serverless AWS Rust template
Facebook Instagram Twitter GitHub Dribbble
Privacy