1. Home
  2. /
  3. Solana-rust
  4. /
  5. Rust + Solana Fixed Supply Token

Rust + Solana Fixed Supply Token - Solana-rust Typing CST Test

Loading…

Rust + Solana Fixed Supply Token — Solana-rust Code

A minimal Solana Rust contract implementing a fixed supply token with balances.

use solana_program::{account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, msg, pubkey::Pubkey};
use std::collections::HashMap;

entrypoint!(process_instruction);
fn process_instruction(_program_id: &Pubkey, _accounts: &[AccountInfo], _instruction_data: &[u8]) -> ProgramResult {
	let mut balances: HashMap<&str, u64> = HashMap::new()
	balances.insert("owner", 1000)
	msg!("Owner balance: {}", balances.get("owner").unwrap())
	Ok(())
}

Solana-rust Language Guide

Solana Rust is the primary language used to write smart contracts (called programs) on the Solana blockchain. It leverages Rust’s safety and performance features to build high-throughput, low-latency decentralized applications.

Primary Use Cases

  • ▸Building high-performance DeFi protocols
  • ▸NFT minting, marketplaces, and auctions
  • ▸On-chain gaming logic
  • ▸Cross-program interactions on Solana
  • ▸Real-time data feeds and oracles

Notable Features

  • ▸Memory safety via Rust’s ownership model
  • ▸High-performance programs for parallel execution
  • ▸Low-latency transactions
  • ▸Strong type system prevents many bugs
  • ▸BPF compilation for Solana runtime

Origin & Creator

Rust-based smart contracts on Solana were promoted by Solana Labs around 2017-2018, adopting Rust for its safety, concurrency, and performance benefits.

Industrial Note

Solana Rust programs are preferred in projects requiring high TPS (transactions per second), low fees, and efficient on-chain computation like decentralized exchanges, NFT marketplaces, and real-time gaming.

More Solana-rust Typing Exercises

Rust + Solana Minimal Counter ContractRust + Solana Increment & ResetRust + Solana Greeting ContractRust + Solana Token Balance ReaderRust + Solana Boolean ToggleRust + Solana Simple Key-Value StoreRust + Solana Increment EventRust + Solana Greeting With ParameterRust + Solana Conditional Counter

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher