React SVM Example
React SPA example using the Solana wallet adapter.
Next.js SVM Example
Next.js example with server-side token management.
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 alongsideSonarProvider:
Configuration
You’ll need three sale-specific values alongside the standard Sonar config:| Variable | Description |
|---|---|
PROGRAM_ID | The Sonar settlement sale program: 3XxHCh947y1PAMK5y8oecBtaLU7TtTj9r4yMYwzFbJYs |
PAYMENT_TOKEN_MINT | The SPL token mint address accepted as payment |
SALE_UUID | Your sale’s UUID from the Echo founder dashboard |
Committing funds to the sale
Submitting a bid on Solana requires a two-instruction transaction:- An Ed25519 signature verification instruction (proving the purchase permit was signed by Sonar)
- The
place_bidprogram instruction
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 theentityState account:
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