Rust & Solana

Overview

Rust & Solana

Rust

=-=-=-=-=-=-=-=

Installation

  1. create a virtual env (pipenv/conda). I am using conda

    • conda create -n rust
    • conda activate rust
  2. visit Rust home page [https://www.rust-lang.org/learn/get-started]

    • run curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
    • check the installation by running.
      • which cargo
      • which rustc
    • install vscode (or editor of your choice)
      • install crates pkg (dependency in rust are managed by Cargo.toml)
      • install rust

Introduction

  1. Notes
  • 3.1 - first program

    • run cargo new hello-world --bin creates a folder
    • the src folder contains main.rs file
      • ! is a macro different from function (fn) macro writes more code
    • cd hello-world
    • compile by running cargo run or rustc main.rs
    • compiled code is in target/debug/ -> ./hello-world
  • 3.2 variables

    • let a = 10 - this is immutable by default, reassiging will throw error
    • let mut a = 20 - reassign to 20
  • 3.3 types

    • let var: i32 = 200 - 32 bit integer
    • rust is statically typed - the variable types cannot be changes
    • int have signed and unsigned and are represented by i8, i16, i32,i64 etc
    • float represented by f32, f64 etc
    • char are utf8 or ascii
    • bool - true or false * composite types*
      • tuples have multiple data types
        • let tup = (10, "hi", true) access by a.0 etc
        • let (t1, t2, _ ) = tup
      • array - same data type (mutability rule gets applied here)
        • let arr = [10, 20, 30] access by arr[0] etc
        • let arr = [1; 5] for printing 1s 5 times {:?}
        • let arr : [f32; 5] = [1; 5] for delaring the type
    • Conditions, loops & iterators
      • if - else if - else
      • loop { if... } | loop { while... }
      • for
      • for y in 0..10 - prints from 0 to 9
      • for y in 0..=10 - prints including 10
      • for x in arr when arr = ['a', 'b', 'c']
    • match - combination of switch statment + if condition
      • match x { }
      • match (x, y) {}
You might also like...
A framework for creating PoC's for Solana Smart Contracts in a painless and intuitive way

Solana PoC Framework DISCLAIMER: any illegal usage of this framework is heavily discouraged. Most projects on Solana offer a more than generous bug bo

Generate Nice Solana Address By Template

Yes, I know about GPU generators. https://smith-mcf.medium.com/solana-vanity-address-using-gpus-5a68ad94d1d4 ./solana-nice-address --help solana-nice-

The Voting example based on MoonZoon and Solana + Anchor framework.
The Voting example based on MoonZoon and Solana + Anchor framework.

The Voting example based on MoonZoon and Solana + Anchor framework.

The Solana Program Library (SPL) is a collection of on-chain programs targeting the Sealevel parallel runtime.

Solana Program Library The Solana Program Library (SPL) is a collection of on-chain programs targeting the Sealevel parallel runtime. These programs a

sandbox to play around numerous functionalities on Solana

Solana Sandbox This sandbox is for verifying smart contracts(programs) implemented on Solana for a self-study purpose. Programs Currently implemented

A suite of programs for Solana key management and security.
A suite of programs for Solana key management and security.

🔑 goki Goki is a suite of programs for Solana key management and security. It currently features: Goki Smart Wallet: A wallet loosely based on the Se

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

Solana NFT generative artwork program

resin Solana NFT generative artwork program Installation Depends on imagemagick for art generation, which can be installed here: https://imagemagick.o

Examples of Solana on-chain programs

spl-examples List of Solana on-chain programs which demonstrate different aspects of Solana architecture. 01__state It's a counter program. Each user

Owner
null
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

Blockchain*Lover* 5 Mar 10, 2022
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

ono 6 Jan 30, 2022
Rust & Solana

Rust & Solana Rust =-=-=-=-=-=-=-= Installation create a virtual env (pipenv/conda). I am using conda conda create -n rust conda activate rust visit R

null 0 Dec 24, 2021
Making Token Exchange program with Solana(Rust), Web3, and Vue

Escrow program for Solana blockchain Tech stack Program (Smart Contract) Rust crates: solana-program, spl-token Solana CLI for test validator UI Types

Hoon Wee 3 May 10, 2022
Galleries of NFTs using Solana and Rust for contracts

About this Package created to simplify the process of parsing NFTs on Solana. It consists of: Package basic things like fetch all NFTs for specific wa

Andrew Scott 1 Jan 28, 2022
Demonstrating how to use Rust to interact with the Solana blockchain.

Solana Scripts This is a library of Rust scripts for specific purposes: Generate a new wallet Create an SPL token Mint an SPL token Get an associated

Rónán 40 May 28, 2023
Ore Pool Miner coded in Rust for the Ore v2 program on Solana!

Ore Pool Miner Ore Pool Miner coded in Rust for the Ore v2 program on Solana Default Ore Mining Pool Alvarium Mining Pool is operated by Bifrost and i

Bifrost Inc 11 Oct 7, 2024
⚓ Solana Sealevel Framework

Anchor ⚓ Anchor is a framework for Solana's Sealevel runtime providing several convenient developer tools. Rust eDSL for writing Solana programs IDL s

Project Serum 2.6k Jan 2, 2023
Metaplex is a protocol built on top of Solana that allows: Creating/Minting non-fungible tokens;

Metaplex is a protocol built on top of Solana that allows: Creating/Minting non-fungible tokens; Starting a variety of auctions for primary/secondary

Metaplex Foundation 3.2k Jan 4, 2023
⛏ An open protocol for launching liquidity mining programs on Solana.

⛏ Quarry An open protocol for launching liquidity mining programs on Solana. Background Quarry was built with the intention of helping more Solana pro

Quarry Protocol 207 Dec 19, 2022