This repository contains a collection of code examples and starter templates for building applications on the Sonic blockchain. These examples demonstrate various capabilities of the SonicSVM ecosystem and provide developers with practical starting points for their own projects.
- Basic Sonic Operations
- SPL Token Operations
- NFT Operations
- Pyth Integration
- Agent Kit
- Rush ECS Framework
Simple examples for interacting with the Sonic blockchain:
- Fetch Balance - Get the SOL balance of an account
- Send Transaction - Transfer SOL between accounts
- Add Priority Fees - Set compute unit price for transactions
- Memo Program - Add memo data to transactions
Examples for working with SPL tokens on Sonic:
- Mint SPL Token - Create and mint a new SPL token
- Send SPL Token - Transfer SPL tokens between accounts
- Fetch Token Balance - Get the token balance of an account
Examples for NFT operations:
- Mint NFT - Create and mint a new NFT using Metaplex
Examples for integrating with Pyth Network price feeds:
- Get Price Feed - Fetch price data from Pyth Network
A complete example of using the Sonic Agent Kit to create AI agents that can interact with the Sonic blockchain:
- Agent Kit Example - Create an AI agent that can perform onchain actions
Examples of using the Rush ECS Framework for onchain game development:
- Rush Quickstart - A simple Bevy game demonstrating how to convert a game to use the Rush ECS framework
- Position Example - Example of storing and updating entity positions onchain
-
Clone this repository:
git clone https://github.com/your-username/sonic-code-examples.git cd sonic-code-examples
-
Install dependencies:
npm install
-
Set up your environment variables in a
.env
file:RPC_URL=https://api.testnet.v1.sonic.game SONIC_PRIVATE_KEY=your_private_key_here OPENAI_API_KEY=your_openai_api_key_here (for Agent Kit examples)
-
Run an example:
npx ts-node ts/basic/fetch-balance.ts