Skip to main content

React SVM Example

React SPA example using the Solana wallet adapter.

Next.js SVM Example

Next.js example with server-side token management.
This guide covers the Solana-specific parts of a Sonar integration. The Sonar API calls (authentication, entities, pre-purchase checks, purchase permits) work the same way as in the EVM guides. Only the wallet adapter and contract interaction differ.
Follow the Frontend-only guide for a React SPA, or the Frontend with Backend guide for Next.js, to handle Sonar OAuth and API calls. Then use this guide for the Solana transaction layer.

Installation

Provider setup

Wrap your app with the Solana connection and wallet providers alongside SonarProvider:

Configuration

You’ll need three sale-specific values alongside the standard Sonar config:

Committing funds to the sale

Submitting a bid on Solana requires a two-instruction transaction:
  1. An Ed25519 signature verification instruction (proving the purchase permit was signed by Sonar)
  2. The place_bid program instruction
Both instructions must be in the same transaction with the Ed25519 instruction immediately preceding place_bid. The program validates the permit signature via instruction introspection.

Deriving PDAs

The program uses Program Derived Addresses for all state. Derive these before building the transaction:

Encoding the permit

The purchase permit must be Borsh-encoded using the program IDL to produce the message bytes for Ed25519 verification. Copy the IDL from the example app into your project.

Building and submitting the transaction

Reading committed amounts

To show a participant their current committed amount, poll the entityState account:
A null result means the entity hasn’t placed a bid yet; treat the committed amount as zero.

Further reading

SettlementSale (SVM)

Program reference: PDAs, instructions, and account types

Frontend-only

React SPA auth and Sonar API patterns

Frontend with Backend

Next.js server-side auth patterns

Purchase Permits

How Sonar authorizes participation