SOAR is a program that provides a seamless solution for managing leaderboards, achievements, players’ profiles and automatic rewards distribution on the Solana blockchain. Currently supporting invocation from a TypeScript client, the integration in Solana.Unity-SDK will be coming soon.


Quick start

import { SoarProgram, GameType, Genre } from "@magicblock-labs/soar-sdk";

const provider = anchor.AnchorProvider.env();

const client = SoarProgram.get(provider);

let game = Keypair.generate();
let title = "Game1";
let description = "Description";
let genre = Genre.Action;
let gameType = GameType.Web; 
let nftMeta = Keypair.generate().publicKey;
let _auths = => keypair.publicKey);

// Retrieve the bundled transaction.
let { newGame, transaction } = await client.initializeNewGame(game.publicKey, title, description, genre, gameType, nftMeta, _auths);
// Send and confirm the transaction with the game keypair as signer. 
await client.sendAndConfirmTransaction(transaction, [game]);



The SoarProgram class gives client access to every instruction in the on-chain SOAR program.

It also gives utility functions for deriving PDAs:

const user = Keypair.generate().publicKey;
const playerAddress = client.utils.derivePlayerAddress(user)[0],

fetching an account:

const account = await client.fetchLeaderBoardAccount(address);

and fetching multiple accounts:

const accounts = await client.fetchAllLeaderboardAccounts([]);


The GameClient provides a more specific set of functions tailored to a single Game account.

import { GameClient } from "@soar/sdk";

Get an instance representing an existing on-chain Game account:

const soar = SoarProgram.get(provider);
const gameClient = new GameClient(soar, address);

Register a new game:

const soar = SoarProgram.get(provider);
const game = new GameClient.register(soar, ...);
// Create a new leaderboard:
await game.addLeaderboard(....);

// Access the game's state.
await game.init();

// Refresh the game's state.
await game.refresh();

// Get the most recently-created achievement for a game
const achievement = game.recentAchievementAddress();


import { InstructionBuilder } from "@soar/sdk"

Provides a set of methods for conveniently bundling transactions.

const transaction = await this.builder
      .andInitializePlayer({username, nftMeta}, user)
      .and(/*some other transaction*/)
      .then((builder) =>;


Test files are located in client/tests/*. To run the tests, enter anchor test from the repository’s root directory.

Was this page helpful?