Adam Jaco

Adam Jaco

1639617889

How to Build SmartContracts with Solana and Rust

This is Video I in a Series on Solana. This video will demonstrate how Smart Contracts in Solana work and the rules around programming them. We will also take a look at a sample project explaining each line of code, and finally refactoring the code to send data to the smart contract and retrieving it.

Here's the source code on github https://github.com/jsoneaday/solana-example-helloworld

#rust #smartcontracts  #solana 

What is GEEK

Buddha Community

How to Build SmartContracts with Solana and Rust
Aylin Hazel

Aylin Hazel

1648532804

Solana price moons past $100 as SOL bulls set their eyes on $150

#Solana price moons past $100 as #SOL bulls set their eyes on $150

#Solana price is looking promising

#Solana price has ascended into the mid $110 zone to start this week's trading session. It was mentioned in last week's neutral thesis that a breach above the triangle's C wave at $106 could be the ultimate catalyst to a 40% rally. This weekend, The bulls pushed Solana price through the trigger level, printing two bullish engulfing candles on the 9-hour chart.

#Solana price will likely continue rising as five wave impulses typically follow triangle breakouts. #Solana price has completed the first impulse into the trigger level at $106 and will need two more impulsive waves to justify the validity of the triangle consolidation.

It's also worth noting that the volume profile is increasing with large buy orders from investors, indicating strength and confidence in the current trend. Traders should consider looking for entries on smaller time frames as the price is likely to chop around the trigger zone.

Adam Jaco

Adam Jaco

1639617889

How to Build SmartContracts with Solana and Rust

This is Video I in a Series on Solana. This video will demonstrate how Smart Contracts in Solana work and the rules around programming them. We will also take a look at a sample project explaining each line of code, and finally refactoring the code to send data to the smart contract and retrieving it.

Here's the source code on github https://github.com/jsoneaday/solana-example-helloworld

#rust #smartcontracts  #solana 

Solana Rbpf: Rust Virtual Machine and JIT Compiler for EBPF Programs

solana_rbpf

Rust (user-space) virtual machine for eBPF

Description

This is a fork of RBPF by Quentin Monnet.

This crate contains a virtual machine for eBPF program execution. BPF, as in Berkeley Packet Filter, is an assembly-like language initially developed for BSD systems, in order to filter packets in the kernel with tools such as tcpdump so as to avoid useless copies to user-space. It was ported to Linux, where it evolved into eBPF (extended BPF), a faster version with more features. While BPF programs are originally intended to run in the kernel, the virtual machine of this crate enables running it in user-space applications; it contains an interpreter, an x86_64 JIT-compiler for eBPF programs, as well as an assembler, disassembler and verifier.

The crate is supposed to compile and run on Linux, MacOS X, and Windows, although the JIT-compiler does not work with Windows at this time.

Link to the crate

This crate is available from crates.io, so it should work out of the box by adding it as a dependency in your Cargo.toml file:

[dependencies]
solana_rbpf = "0.2.26"

You can also use the development version from this GitHub repository. This should be as simple as putting this inside your Cargo.toml:

[dependencies]
solana_rbpf = { git = "https://github.com/solana-labs/rbpf", branch = "main" }

Of course, if you prefer, you can clone it locally, possibly hack the crate, and then indicate the path of your local version in Cargo.toml:

[dependencies]
solana_rbpf = { path = "path/to/solana_rbpf" }

Then indicate in your source code that you want to use the crate:

extern crate solana_rbpf;

API

The API is pretty well documented inside the source code. You should also be able to access an online version of the documentation from here, automatically generated from the crates.io version (may not be up-to-date with master branch). Examples, unit tests and performance benchmarks should also prove helpful.

Here are the steps to follow to run an eBPF program with rbpf:

  1. Create an executable, either from the bytecode or an ELF.
  2. Create a syscall-registry, add some syscalls and put it in the executable.
  3. If you want a JIT-compiled program, compile it.
  4. Create a memory mapping, consisting of multiple memory regions.
  5. Create the config and a virtual machine using all of the previous steps. You can also pass a readonly memory here which will be mapped as packet data in the eBPF programs register at index one.
  6. If you registered syscall functions then bind their context objects.
  7. Create an instruction meter.
  8. Execute your program: Either run the interpreter or call the JIT-compiled function.

Download Details:
Author: solana-labs
Source Code: https://github.com/solana-labs/rbpf
License: View license

#solana #rust  #blockchain  #smartcontract #rust 

Serde Rust: Serialization Framework for Rust

Serde

*Serde is a framework for serializing and deserializing Rust data structures efficiently and generically.*

You may be looking for:

Serde in action

Click to show Cargo.toml. Run this code in the playground.

[dependencies]

# The core APIs, including the Serialize and Deserialize traits. Always
# required when using Serde. The "derive" feature is only required when
# using #[derive(Serialize, Deserialize)] to make Serde work with structs
# and enums defined in your crate.
serde = { version = "1.0", features = ["derive"] }

# Each data format lives in its own crate; the sample code below uses JSON
# but you may be using a different one.
serde_json = "1.0"

 

use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize, Debug)]
struct Point {
    x: i32,
    y: i32,
}

fn main() {
    let point = Point { x: 1, y: 2 };

    // Convert the Point to a JSON string.
    let serialized = serde_json::to_string(&point).unwrap();

    // Prints serialized = {"x":1,"y":2}
    println!("serialized = {}", serialized);

    // Convert the JSON string back to a Point.
    let deserialized: Point = serde_json::from_str(&serialized).unwrap();

    // Prints deserialized = Point { x: 1, y: 2 }
    println!("deserialized = {:?}", deserialized);
}

Getting help

Serde is one of the most widely used Rust libraries so any place that Rustaceans congregate will be able to help you out. For chat, consider trying the #rust-questions or #rust-beginners channels of the unofficial community Discord (invite: https://discord.gg/rust-lang-community), the #rust-usage or #beginners channels of the official Rust Project Discord (invite: https://discord.gg/rust-lang), or the #general stream in Zulip. For asynchronous, consider the [rust] tag on StackOverflow, the /r/rust subreddit which has a pinned weekly easy questions post, or the Rust Discourse forum. It's acceptable to file a support issue in this repo but they tend not to get as many eyes as any of the above and may get closed without a response after some time.

Download Details:
Author: serde-rs
Source Code: https://github.com/serde-rs/serde
License: View license

#rust  #rustlang 

Joshua Yates

Joshua Yates

1652409401

How to Build Smart Contracts on Solana with Rust Programming

Rust and Solana Programming 101 - Moralis Academy

Do you want to develop dApps on Solana, but you don't have any Rust knowledge? Don't worry. In this course, you will learn how to build smart contracts on Solana from complete basics. No prior Rust knowledge is required.

About the Course

The goal of this course is to introduce you to the basics of Rust and allow you to build smart contracts on Solana even if you didn't have any prior Rust knowledge. This is the perfect course for anyone that wants to get into Solana development.

JOIN NOW

Course Content

1 - Introduction

  • Welcome to the Course!
  • Introduction to Forum
  • How to post code in the Forum
  • Disclaimer

2 - Rust Fundamentals

  • Introduction to Rust Fundamentals
  • Rust Installation
  • Visual Studio Code extensions
  • Hello world – Rust Compiler
  • Cargo Package Manager
  • Exercise – Compare and contrast Cargo with npm
  • Mutable and Immutable Variables, Integers
  • Floating Points
  • Characters, Booleans, Constants
  • Arithmetic Operations
  • println and Format Macros
  • Tuples
  • Arrays
  • Exercise – Research Stack and Heap
  • Strings
  • If-else
  • Match
  • If-else and match with branch values
  • Ranges in Match Statements
  • Loops – part 1
  • Loops – part 2
  • Exercises – Rust Fundamentals
  • Solution – Loops
  • Functions
  • Exercises – Functions
  • Quiz – Rust Fundamentals 1 Quiz 
  • Summary

3 - Advanced Rust

  • Introduction to Advanced Rust
  • Different Memory Management Approaches
  • Passing Value Types and Blocks Scope
  • Ownership Borrowing
  • Ownership and Functions
  • Borrowing
  • Mutable Borrowing
  • Structs
  • Traits
  • Vectors
  • Vectors – Referencing Dereferencing
  • Vectors – Constructor Indexing and Safe Reading
  • Removing Elements From A Vectors
  • The Enum Type and Optionality
  • Handling Errors
  • Module Syntax in Rust
  • Exercise – Modules
  • Testing in Rust
  • Quiz – Advanced Rust 1 Quiz 

4 - Introduction to Rust and Solana

  • Introduction to Rust and Solana section
  • Solana Introduction
  • Windows Subsystem for Linux Installation
  • Rust Installation for the WSL Subsystem
  • Solana Command Line Interface
  • Phantom Wallet
  • Airdropping Solana Test Tokens to our Phantom Wallet

Your instructor

Zsolt Nagy started as a Backend Web Developer in 2006, but turned to Frontend development some years later. Zsolt has spent the last ten years working with JavaScript. As a team lead, tech lead, and engineering manager, he has conducted hundreds of tech interviews and has hired multiple world class engineers. Besides coding in JavaScript, Zsolt is also a mentor and bootcamp instructor at various coding schools. His tech blog on zsoltnagy.eu focuses on developing maintainable web applications.

JOIN NOW

#rust #solana #programming #blockchain #web3 #moralis #dapp #smartcontracts