Demonstrating how to use Rust to interact with the Solana blockchain.

Overview

Solana Scripts

This is a library of Rust scripts for specific purposes:

The scripts are found in the src/bin folder. They can be configured using environment variables, which are documented below.

Open an issue if you have any requests or suggestions.


New wallet

cargo run --bin new_wallet | Code

Generates a new wallet and prints the pubkey, Base58 private key, and JSON private key.


Create an SPL token

cargo run --bin create_spl | Code

Creates a new SPL token mint account.

Environment Variable Note
RPC_URL e.g. https://api.mainnet-beta.solana.com
SIGNER_KEYPAIR Base58 encoded keypair, to pay for the transaction.
MINT_KEYPAIR Base58 encoded keypair, representing the new mint account.

Mint SPL tokens

cargo run --bin mint_spl | Code

Mints 10,000 SPL tokens from a specified mint to the associated token account of a specified wallet.

Environment Variable Note
RPC_URL e.g. https://api.mainnet-beta.solana.com
SIGNER_KEYPAIR Base58 encoded keypair, which has mint authority.
MINT_ACCOUNT_PUBKEY The pubkey address of the SPL Token mint account.
RECEIVER_PUBKEY The pubkey address of the wallet you want to fund with the tokens.

Get token balance

cargo run --bin associated_token_balance | Code

Prints the balance of an associated token account, for a specified wallet and mint.

Environment Variable Note
RPC_URL e.g. https://api.mainnet-beta.solana.com
WALLET_PUBKEY The pubkey address of the wallet that owns the tokens.
MINT_ACCOUNT_PUBKEY The pubkey address of the SPL Token mint account.

Get account creation timestamp

cargo run --bin creation_date | Code

Fetches and prints the creation timestamp of a specified account.

Environment Variable Note
RPC_URL e.g. https://api.mainnet-beta.solana.com
ACCOUNT_PUBKEY The pubkey address of the account you want to introspect.

Get NFT owner

cargo run --bin nft_owner | Code

Prints the wallet address that owns a specified NFT.

Environment Variable Note
RPC_URL e.g. https://api.mainnet-beta.solana.com
MINT_ACCOUNT_PUBKEY The pubkey address of the SPL Token mint account.

List NFTs in wallet

cargo run --bin list_nfts | Code

Fetches and prints the mint pubkeys of every NFT in the specified wallet.

Environment Variable Note
RPC_URL e.g. https://api.mainnet-beta.solana.com
WALLET_PUBKEY The pubkey address of the wallet that owns the NFTs.

Print NFT metadata

cargo run --bin print_nft | Code

Fetches, decodes and prints the metadata of the specified NFT.

Environment Variable Note
RPC_URL e.g. https://api.mainnet-beta.solana.com
MINT_ACCOUNT_PUBKEY The pubkey of the NFT's SPL Token mint account.
You might also like...
Rust-native building blocks for the Cardano blockchain ecosystem

Pallas Rust-native building blocks for the Cardano blockchain ecosystem. Introduction Pallas is an expanding collection of modules that re-implements

Simple example for building a blockchain in Rust

rust-blockchain-example Simple example for building a blockchain in Rust Start using RUST_LOG=info cargo run This starts the client locally. The block

A Rust-based CustomVM for the Avalanche blockchain network

A rust-based Custom VM for Avalanche Subnets Curious about how to run Rust-based smart contracts, or just custom VMs for Avalanche blockchain? You're

A secure development tool box and fintech application made with Rust to be used for developing cryptocurrencies on the blockchain.

Crypto Fintech Tools for Rust (CFT) Dependencies Rust MacOS Homebrew # xcode cli tools xcode-select --install # install dependencies using Homebrew b

Rust implementation of Namada, a sovereign proof-of-stake blockchain that enables asset-agnostic private transfers

Namada Overview Namada is a sovereign proof-of-stake blockchain, using Tendermint BFT consensus, that enables multi-asset private transfers for any na

Rust implementation of the Inter-Blockchain Communication (IBC) protocol.

ibc-rs Rust implementation of the Inter-Blockchain Communication (IBC) protocol. This project hosts the ibc rust crate which defines the main data str

[Open Source] Blockchain Decentralized Lightweight VPN in Rust
[Open Source] Blockchain Decentralized Lightweight VPN in Rust

[Open Source] Blockchain Decentralized Lightweight VPN in Rust DCVPN_Rust (Decentralized VPN in Rust) is an open-source initiative started by @anandgo

Solana Escrow Program written by RUST.

Environment Setup Install Rust from https://rustup.rs/ Install Solana from https://docs.solana.com/cli/install-solana-cli-tools#use-solanas-install-to

Simple template for building smart contract(Rust) and RPC Client(web3.js) on Solana (WIP) ⛏👷🚧⚠️
Simple template for building smart contract(Rust) and RPC Client(web3.js) on Solana (WIP) ⛏👷🚧⚠️

Solana BPF Boilerplate Simple template for building smart contract(Rust) and RPC Client(web3.js) on Solana This boilerplate provides the following. Si

Owner
Rónán
Rónán
A simple example demonstrating cross-contract calls in CosmWasm smart contracts

Cross-contract calls This tutorial demonstrates cross-contract calls with CosmWasm v1. Overview An end user calls the reservation contract to register

csli Tools 3 Sep 12, 2022
Testing a smart contract on the Solana blockchain

Environment Setup Install Rust from https://rustup.rs/ Install Solana from https://docs.solana.com/cli/install-solana-cli-tools#use-solanas-install-to

Maurice 1 Oct 25, 2021
A program on solana blockchain to provide escrow services.

Environment Setup Install Rust from https://rustup.rs/ Install Solana from https://docs.solana.com/cli/install-solana-cli-tools#use-solanas-install-to

null 0 Dec 24, 2021
Custom p2p swaps powered by Solana blockchain

Peer to peer, decentralized protocol which allow direct swaps between 2 network participants for custom tokens without liquidity pools on Solana blockchain.

Ilia 3 Mar 18, 2022
Demonstrates Solana data account versioning used in supporting the Solana Cookbook article: Account Data Versioning

versioning-solana This repo demonstrates ONE rudimentary way to upgrade/migrate account data changes with solana program changes. What is data version

Frank V. Castellucci 6 Sep 30, 2022
My attempt at learning Solana program (smart contract) development through RareSkill's Solana course.

60-days-of-solana My attempt at learning Solana program (smart contract) development through RareSkill's Solana course. Originally, I was trying to cr

Jasper 3 Feb 25, 2024
A Rust library to interact with the MPesa API, simplifying B2C payment integrations and more.

MPesa SDK (Rust Library) A Rust library to interact with the MPesa API, simplifying B2C payment integrations and more. Features Configuration manageme

Ismael GraHms 8 Aug 23, 2023
HyperCube is a free and open source blockchain project for everyone to use.

XPZ Public Chain HyperCube is a free and open source blockchain project for everyone to use. 日本語 简体中文 正體中文 HyperCube Wiki Wha is HyperCube HyperCube i

null 949 Dec 31, 2022
A specialized blockchain for testing use cases with the FRAME NFTs Pallet.

Substrate NFTs Node The Substrate NFTs node is a specialized blockchain for testing use cases with the FRAME NFTs Pallet. ?? The purpose of this node

Sacha Lansky 4 May 25, 2023
flow-rust-sdk utilizes the Flow gRPC AccessAPI to make requests on the flow blockchain.

Welcome to the Flow-Rust-SDK! We're glad to have you here. There are a few important items that we should cover real quick before you dive in. Version

null 8 Jul 26, 2022