Solana BPF Boilerplate Simple template for building smart contract(Rust) and RPC Client(web3.js) on Solana
This boilerplate provides the following.
- Simple smart contract that can be distributed on Solana Online.
- Store data through byte buffer on account what you create.
- RPC Client interacts with distributed smart contracts
- Send transaction about creating an account for store data of the distributed program, and Initializing distributed program.
Prerequisite
- Install node (v14 recommended)
- Install npm
- Install the latest Rust stable from https://rustup.rs/
- Install Solana v1.7.11 or later from https://docs.solana.com/cli/install-solana-cli-tools
Quick Start
- Build Rust
- Setup Solana Config and call test-validator
Build Rust
Build Rust and get .so
file. You should conduct following command on contract
folder
cargo build-bpf
Run test-validator
./solana-test-validator -r --bpf-program 4yBTZXsuz7c1X3PJF4PPCJr8G6HnNAgRvzAWVoFZMncH ${.so}
If you want to get more information about validator.
Use
solana-test-validator -h
Setup Solana
Set CLI config url to localhost cluster
solana config set --url localhost
Create CLI Keypair If this is your first time using the Solana CLI, you will need to generate a new keypair:
solana-keygen new
Run RPC Client
Install the necessary dependencies for running RPC Client. You should conduct following command on web3
folder
npm install
Run RPC Client for interaction with on-chain program what you distributed.
npm run transaction
Further
SmartContract
- Pack & Unpack with Barsh
RPC Client
- Please suggest in issue