Welcome to building on SOON Network! In this guide, we’ll walk through creating, deploying, and testing your first project using the Anchor framework.

Create Your Project

Let’s start by setting up a new project in Solana Playground. Open Solana Playground in your browser and follow these steps:

  1. Click the “Create a new project” button on the left-side panel

  2. Enter a project name

  3. Select “Anchor” as your framework

  4. Click “Create”

You’ll see a new project with this starter code in lib.rs:

use anchor_lang::prelude::*;

declare_id!("11111111111111111111111111111111");

#[program]
mod hello_soon {
    use super::*;
    
    pub fn initialize(ctx: Context<Initialize>, data: u64) -> Result<()> {
        // Store the passed data value in our account
        ctx.accounts.new_account.data = data;
        // Log a message that will appear in transaction logs
        msg!("Data initialized to: {}!", data); 
        Ok(())
    }
}

#[derive(Accounts)]
pub struct Initialize<'info> {
    // Account to store our data, will be created with init
    #[account(
        init,
        payer = signer,
        space = 8 + 8  // 8 bytes for discriminator + 8 bytes for data
    )]
    pub new_account: Account<'info, NewAccount>,
    
    // User paying for account creation
    #[account(mut)]
    pub signer: Signer<'info>,
    
    // Required by init to create our account
    pub system_program: Program<'info, System>,
}

#[account]
pub struct NewAccount {
    data: u64
}

This program does something simple but important - it creates an account and stores a number in it. Let’s understand each part:

  1. The initialize function takes a number (data) and stores it in a new account

  2. The Initialize struct defines what accounts our function needs

  3. NewAccount defines the structure of our data storage

Build Your Program

Before deploying to SOON Network, we need to build our program. In the Playground terminal, run:

build

You’ll notice the declare_id!() address updates - this will be your program’s address on SOON Network.

Configure SOON Network

Before deploying, we need to switch to SOON’s network to Faucet Devnet:

  1. Click the network selector dropdown (shows “devnet” by default)

  2. Choose “Custom RPC”

  3. Enter: https://rpc.fc.devnet.soo.network/rpc

Get Test Tokens

Deploying a program requires some SOL to allocate space for the program. Get some test tokens by running:

solana airdrop 2

Deploy Your Program

Now we’re ready to deploy! Run this command in the terminal:

deploy

You should see output indicating your program was deployed successfully. Note that deploying on SOON Network offers several advantages:

  • Faster deployment confirmation thanks to our Layer 2 architecture

  • Lower deployment costs while maintaining security

  • Full Solana program compatibility through our Decoupled SVM

Testing Your Program

The starter project includes a test file in tests/anchor.test.ts. This demonstrates how to interact with your program:

describe("Test", () => {
    it("initialize", async () => {
        // Create a keypair for our test account
        const newAccountKp = new web3.Keypair();
        
        // The data we'll store - let's use 42
        const data = new BN(42);
        
        // Send transaction to initialize our account
        const txHash = await pg.program.methods
            .initialize(data)
            .accounts({
                newAccount: newAccountKp.publicKey,
                signer: pg.wallet.publicKey,
                systemProgram: web3.SystemProgram.programId,
            })
            .signers([newAccountKp])
            .rpc();
            
        // Wait for transaction confirmation
        await pg.connection.confirmTransaction(txHash);
        
        // Fetch our account and verify the data
        const newAccount = await pg.program.account.newAccount.fetch(
            newAccountKp.publicKey,
        );
        
        console.log("On-chain data is:", newAccount.data.toString());
        assert(data.eq(newAccount.data));
    });
});

Run the test with:

test

You should see output indicating the test passed, along with your stored data value.

View Transaction Details

Each transaction on SOON Network can be viewed in our explorer. Just click the transaction signature link that appears in your test output or add it manually to:

https://explorer.fc.devnet.soo.network/tx/[YOUR-SIGNATURE]

Close Your Program

If you want to recover the SOL allocated to your program, you can close it using:

solana program close [PROGRAM-ID]

Replace [PROGRAM-ID] with the address shown in your declare_id!().

Next Steps

Congratulations! You’ve deployed your first program on SOON Network. This is just the beginning - your program is now running on our high-performance Layer 2, ready to power decentralized applications with:

  • Rapid transaction processing through Decoupled SVM

  • Ethereum’s robust security guarantees

  • Cost-effective operation at scale

Ready to build more? Check out our guides on:

  • Creating complex programs with multiple instructions

  • Integrating with other SOON Network programs

  • Optimizing for Layer 2 performance