Solana / SVM
Switchboard Randomness for Solana and SVM applications
Prerequisites
Basic understanding of Solana development and Anchor Framework.
A working Solana development environment (Solana tool suite, Anchor).
Solana CLI connected to the devnet.
Enough SOL tokens for devnet transactions.
Tooling:
Install Switchboard On-Demand in your program.
Install Switchboard On-Demand in your Javascript Client file:
Step 1: Coin Flip Program (Solana)
Define the Player State
Make sure to store the user's randomness_account in your program.
Commit to a Future Slot
Commit to the game by locking the
randomness_account
.Settle the Flip
Resolve randomness through the
settle_flip
function.
Step 2: TypeScript Client
Setup and Environment Configuration:
Creating a Randomness Account: Before flipping that coin, start with a clean
randomness
account.
Committing to Randomness: Use randomness account to commit to the oracle.
Revealing the Vision: Once the slot is generated, invoke to generate randomness for the committed slot.
Note: here is an optional way to save the revealIx()
transaction .
Settling the Flip: Finally, record the coin flip in the randomness account.
You've just integrated randomness into your Solana application.
For more details, refer to the example repository
Last updated