A complete step-by-step guide to deploy your first “Hello, Solayer!” contract on Solayer Mainnet (with devnet testing options) using the latest stable toolchain.
Prerequisites
-
System: macOS, Linux, or Windows with WSL
-
Basic terminal knowledge: Running commands in terminal
Step 1: Install Rust (if not already installed)
If you don’t have Rust installed:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
Verify Rust installation:
Step 2: Install Latest Solana CLI
Install the latest Solana CLI 3.0.0 from Anza:
curl -sSfL https://release.anza.xyz/edge/install | sh
Add Solana CLI to your PATH:
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
Verify installation:
You should see: solana-cli 3.0.0 (src:21f770aa; feat:2900245688, client:Agave)
Step 3: Create Hello Solayer Project
Create a new Rust library project:
cargo init --lib hello
cd hello
Add the latest Solana program dependency:
Update Edition: Modern cargo defaults to edition “2024”. For Solana programs, we need to enable the edition2024 feature.
Update your Cargo.toml:
cargo-features = ["edition2024"]
[package]
name = "hello"
version = "0.1.0"
edition = "2024"
[dependencies]
solana-program = "2.3.0"
[lib]
crate-type = ["cdylib", "lib"]
Note: This uses the latest edition 2024 with the required feature flag for Solana compatibility.
Step 4: Write the Hello Solayer Program
Replace the contents of src/lib.rs with:
use solana_program::{
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult,
pubkey::Pubkey, msg,
};
entrypoint!(process_instruction);
fn process_instruction(
_program_id: &Pubkey,
_accounts: &[AccountInfo],
_instruction_data: &[u8],
) -> ProgramResult {
msg!("Hello, Solayer!");
Ok(())
}
Step 5: Generate Keypairs
Navigate back to your project root:
Generate a keypair for your program:
solana-keygen new -o program-keypair.json --no-bip39-passphrase
Generate a keypair for your wallet:
solana-keygen new -o wallet-keypair.json --no-bip39-passphrase
Important: Save the displayed seed phrases securely. You’ll need them to recover your keypairs.
Get your program ID (you’ll need this later):
solana address -k program-keypair.json
For Production (Mainnet)
Set Solana CLI to use Solayer mainnet:
solana config set --url https://mainnet-rpc.solayer.org
For Testing and Development (Devnet)
Set Solana CLI to use Solayer devnet (for testing):
solana config set --url https://devnet-rpc.solayer.org
The devnet RPC endpoint (https://devnet-rpc.solayer.org) is specifically for devnet and testing purposes only. Use the mainnet RPC endpoint (https://mainnet-rpc.solayer.org) for production applications.
Set your wallet as the default keypair:
solana config set -k ./wallet-keypair.json
Verify your configuration:
For devnet, you should see:
- RPC URL:
https://devnet-rpc.solayer.org
- Keypair Path:
./wallet-keypair.json
For mainnet, you should see:
- RPC URL:
https://mainnet-rpc.solayer.org
- Keypair Path:
./wallet-keypair.json
Step 7: Fund Your Wallet
The following steps are for devnet testing only. On mainnet, you’ll need to fund your wallet with real SOL through exchanges or other methods.
Check your current balance:
Request test SOL from the Solayer devnet faucet (devnet only):
Wait a few seconds, then check if you need more funding:
If you have less than 0.2 SOL, request more:
Note: Solayer devnet has a limit of 1 SOL per airdrop request. This airdrop feature is only available on devnet for testing purposes.
Step 8: Build Your Program
Navigate to your hello directory and build the program:
Clean any existing build files:
rm -rf target/ Cargo.lock
Build the Solana program:
cargo build-sbf --sbf-out-dir=../dist
Navigate back to project root:
Verify the build output:
You should see hello.so in the dist directory.
Step 9: Deploy to Solayer Devnet
Deploy your program to Solayer devnet:
solana program deploy \
--use-rpc \
--program-id ./program-keypair.json \
--upgrade-authority ./wallet-keypair.json \
./dist/hello.so
Success! You should see output like:
Program Id: <YOUR_PROGRAM_ID>
Step 10: Verify Deployment
Check your program is deployed:
For devnet:
solana program show <YOUR_PROGRAM_ID> --url https://devnet-rpc.solayer.org
For mainnet:
solana program show <YOUR_PROGRAM_ID> --url https://mainnet-rpc.solayer.org
Check your remaining balance:
The deployment should have cost approximately 0.13 SOL.
Congratulations! 🎉
You have successfully deployed your first Hello Solayer contract to Solayer Devnet!