Skip to content

Example template program written in Rust with cargo-make

License

Notifications You must be signed in to change notification settings

russellwmy/solana-helloworld

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hello world on Solana

This project demonstrates how to build programs on the Solana blockchain with cargo-make.

The project comprises of:

  • An on-chain hello world program
  • A client that can send a "hello" to an account and get back the number of times "hello" has been sent

Table of Contents

Quick Start

The following dependencies are required to build and run this example, depending on your OS, they may already be installed:

If this is your first time using Rust, these Installation Notes might be helpful.

Configure CLI

If you're on Windows, it is recommended to use WSL to run these commands

  1. Set CLI config url to localhost cluster
solana config set --url localhost
  1. Create CLI Keypair

If this is your first time using the Solana CLI, you will need to generate a new keypair:

solana-keygen new

Start local Solana cluster

This example connects to a local Solana cluster by default.

Start a local Solana cluster:

solana-test-validator

Note: You may need to do some system tuning (and restart your computer) to get the validator to run

Listen to transaction logs:

solana logs

Build the on-chain program

There is both a Rust version of the on-chain program, whichever is built last will be the one used when running the example.

cargo make build

Deploy the on-chain program

cargo make deploy

Customizing the Program

To customize the example, make changes to the files under /src. If you change any files you will need to rebuild the on-chain program and redeploy the program.

Writing the client in Rust

Solana client program can be written in any language. For an example client written in Rust and an accompanying write up see this repo.

Pointing to a public Solana cluster

Solana maintains three public clusters:

  • devnet - Development cluster with airdrops enabled
  • testnet - Tour De Sol test cluster without airdrops enabled
  • mainnet-beta - Main cluster

Use the Solana CLI to configure which cluster to connect to.

To point to devnet:

solana config set --url devnet

To point back to the local cluster:

solana config set --url localhost

Learn about Solana

More information about how Solana works is available in the Solana documentation and all the source code is available on github

Learn about the on-chain program

The on-chain helloworld program is a Rust program compiled to Berkeley Packet Filter (BPF) bytecode and stored as an Executable and Linkable Format (ELF) shared object.

The program is written using:

Programming on Solana

To learn more about Solana programming model refer to the Programming Model Overview.

To learn more about developing programs on Solana refer to the On-Chain Programs Overview

About

Example template program written in Rust with cargo-make

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages