Now that we understand how to read data from SOON Network, let’s learn how to write data to it. On SOON, we interact with the network by sending transactions made up of instructions, just like on Solana. However, these transactions benefit from SOON’s Layer 2 architecture, offering faster finality and lower costs while maintaining Ethereum’s security guarantees.Let’s walk through two common operations - transferring SOL and creating a token - to understand how transactions work on SOON Network.
First, let’s send a simple SOL transfer from your wallet to another account. This requires invoking the transfer instruction on the System Program. Open this example in Solana Playground:
Copy
Ask AI
import { LAMPORTS_PER_SOL, SystemProgram, Transaction, sendAndConfirmTransaction, Keypair,} from "@solana/web3.js";// Get our sender's keypair from the playground walletconst sender = pg.wallet.keypair;// Generate a new keypair for the receiverconst receiver = new Keypair();// Create the transfer instructionconst transferInstruction = SystemProgram.transfer({ fromPubkey: sender.publicKey, toPubkey: receiver.publicKey, lamports: 0.01 * LAMPORTS_PER_SOL, // Transfer 0.01 SOL});// Add the instruction to a new transactionconst transaction = new Transaction().add(transferInstruction);// Send and confirm the transactionconst transactionSignature = await sendAndConfirmTransaction( pg.connection, transaction, [sender],);// Log the transaction URL - note we use SOON's explorerconsole.log( "Transaction Signature:", `https://explorer.fc.devnet.soo.network/tx/${transactionSignature}`);
This code demonstrates several key concepts:
Creating an instruction (the transfer)
Building a transaction from that instruction
Sending and confirming the transaction
Using SOON’s explorer to verify the result
When you run this code, you’ll see the transaction signature and a link to view it in SOON’s explorer. Click the link to see details about your transaction, including its rapid confirmation time - a benefit of SOON’s Layer 2 architecture.
Now let’s try something more complex - creating a new token. This requires multiple instructions working together. Open this example in Solana Playground:
Copy
Ask AI
import { MINT_SIZE, TOKEN_2022_PROGRAM_ID, createInitializeMint2Instruction, getMinimumBalanceForRentExemptMint,} from "@solana/spl-token";// Generate a new keypair for the mint accountconst mint = new Keypair();// Calculate rent-exempt balance for mint accountconst rentLamports = await getMinimumBalanceForRentExemptMint(pg.connection);// Create instruction for new accountconst createAccountInstruction = SystemProgram.createAccount({ fromPubkey: pg.wallet.publicKey, newAccountPubkey: mint.publicKey, space: MINT_SIZE, lamports: rentLamports, programId: TOKEN_2022_PROGRAM_ID,});// Create instruction to initialize the mintconst initializeMintInstruction = createInitializeMint2Instruction( mint.publicKey, // mint account 2, // decimals pg.wallet.publicKey, // mint authority pg.wallet.publicKey, // freeze authority TOKEN_2022_PROGRAM_ID);// Combine both instructions into one transactionconst transaction = new Transaction().add( createAccountInstruction, initializeMintInstruction);// Send and confirm the transactionconst transactionSignature = await sendAndConfirmTransaction( pg.connection, transaction, [pg.wallet.keypair, mint] // Both keypairs needed);console.log( "\nTransaction Signature:", `https://explorer.fc.devnet.soo.network/tx/${transactionSignature}`);console.log( "\nMint Account:", `https://explorer.fc.devnet.soo.network/address/${mint.publicKey}`);
This example shows how to:
Calculate space and rent for a new account
Create and initialize a mint account
Combine multiple instructions in one transaction
Sign with multiple keypairs
When you run the code, you’ll get two links:
One for the transaction details
One for the newly created mint account
Examining these in SOON’s explorer shows how our Layer 2 processes complex transactions with multiple instructions efficiently.
On SOON Network, transactions confirm quickly thanks to our Layer 2 architecture, but they inherit Ethereum’s security through our rollup design. When you see "confirmed" status, it means:
The transaction has been processed by SOON’s network
The transaction is included in a rollup batch
The transaction data is available for verification
This gives you both speed and security - fast confirmations backed by Ethereum’s consensus.