Skip to main content

Overview

The Sonar settlement sale program is an Anchor-based Solana program for token sales. It follows the same commitment, cancellation, and settlement lifecycle as the EVM SettlementSale contract, adapted for Solana’s account model. Participants commit SPL tokens during the commitment stage. Clearing mechanics and final allocations are computed offchain by Sonar; accepted amounts and refunds are settled onchain.
For standard sale configurations, Sonar deploys and manages this program for you.
Program ID: 3XxHCh947y1PAMK5y8oecBtaLU7TtTj9r4yMYwzFbJYs Source code: solana/

Program Derived Addresses

All program state lives in PDAs. Seeds use raw bytes — not the UUID string representation.
AccountSeedsDescription
SettlementSale["settlement_sale", sale_uuid]Top-level sale state
EntityState["entity_state", sale_pda, entity_id]Per-entity commitment state
WalletBinding["wallet_binding", sale_pda, bidder_pubkey]Binds a wallet to an entity
Vault["vault", sale_pda]Holds committed SPL tokens
sale_uuid and entity_id are 16-byte raw UUID values. Entity IDs from the Sonar API may arrive as 0x-prefixed hex or UUID-formatted strings. Strip the 0x prefix; if hyphens are present, parse as a UUID, otherwise decode as raw hex.

Instructions

place_bid

Places or updates a bid. Handles first bids and bid increases with the same call. The instruction verifies the purchase permit signature via instruction introspection of the Ed25519 program. The Ed25519 verify instruction must be the immediately preceding instruction in the same transaction. See the integration guide for a complete code example. Arguments:
ArgumentTypeDescription
permitPurchasePermitV3Borsh-encoded permit from Sonar’s API
amountu64Payment tokens to commit, in the token’s base unit
priceu64Bid price (for auctions; pass 0 for fixed-price sales)
lockupboolWhether the entity opts into token lockup
Accounts:
AccountWritableSignerDescription
bidderYesYesThe participant’s wallet
saleYesNoThe SettlementSale PDA
entity_stateYesNoThe EntityState PDA for this entity
wallet_bindingYesNoThe WalletBinding PDA for this wallet
bidder_token_accountYesNoBidder’s associated token account for the payment mint
vaultYesNoThe vault PDA that holds committed tokens
payment_token_mintNoNoThe payment SPL token mint
token_programNoNoSPL Token program
system_programNoNoSystem program
instructionsNoNoSysvar1nstructions — required for Ed25519 introspection
Bid constraints:
  • Amount can only increase, never decrease
  • Price can only increase, never decrease
  • Lockup can be enabled but not disabled once set
  • The permit must not be expired and the current time must fall within the opens_at/closes_at window
  • The bidder’s wallet must match the wallet encoded in the permit

Account Types

SettlementSale

Top-level sale configuration and state. Fetch this account to retrieve permit_signer and vault before constructing a transaction.
FieldTypeDescription
sale_uuid[u8; 16]The sale UUID (used as a PDA seed)
permit_signerPublicKeyEd25519 public key that signs purchase permits
vaultPublicKeyThe vault token account address
payment_token_mintPublicKeyThe accepted payment SPL token mint
stageSaleStageCurrent sale stage
pausedboolWhether the sale is currently paused

EntityState

Per-entity commitment state. One account per entity per sale. Created on the entity’s first bid.
FieldTypeDescription
entity_id[u8; 16]The sale-specific entity ID
current_amountu64Total tokens committed by this entity
current_priceu64Current bid price
lockupboolWhether the entity has opted into lockup
refundedboolWhether this entity has been refunded
Use program.account.entityState.fetchNullable(entityStatePDA) to read commitment progress. A null result means no bid has been placed; treat current_amount as zero.

WalletBinding

Associates a bidder wallet with an entity. Created on the wallet’s first bid; one wallet is bound to exactly one entity per sale.
FieldTypeDescription
entity_id[u8; 16]The entity this wallet is bound to
salePublicKeyThe SettlementSale PDA

Sale Stages

The program follows the same stage progression as the EVM contract: Stage transitions are managed by Sonar. Participants can call place_bid during the Commitment stage, cancel during the Cancellation stage, and claim refunds when available. Settlement and pushed refunds are handled by Sonar.

Roles & Permissions

The SVM program uses authority accounts to control privileged operations. Unlike the EVM contract’s named roles, Solana programs express authority as specific signer accounts verified at instruction time.
AuthorityHeld ByOperations
permit_signerSonarSigns purchase permits that authorize participation
Stage managerSonarTransitions the sale between stages (CommitmentCancellationSettlementDone)
SettlerSonarWrites final allocations on-chain after offchain computation
RefunderSonarPushes refunds to participants; participants may also claim refunds directly

Permit Signing

Solana sales use Ed25519 signatures rather than the ECDSA signatures used by EVM sales. The permit is Borsh-encoded using the PurchasePermitV3 type from the program IDL. The permit_signer field on the SettlementSale account holds the Ed25519 public key used to verify permits. This key is controlled by Sonar.

PurchasePermitV3 type

FieldTypeDescription
sale_specific_entity_id[u8; 16]Sale-specific entity ID
sale_uuid[u8; 16]Sale UUID
wallet[u8; 32]Bidder’s wallet public key bytes
expires_ati64Unix timestamp when the permit expires
min_amountu64Minimum commitment amount
max_amountu64Maximum commitment amount
min_priceu64Minimum bid price
max_priceu64Maximum bid price
opens_ati64Unix timestamp when the permit becomes valid
closes_ati64Unix timestamp when the permit closes
payloadbytesArbitrary payload (may be empty)

See Also

Frontend Integration (SVM)

Step-by-step Solana integration guide with code examples

SettlementSale (EVM)

EVM equivalent contract reference

Purchase Permits

How Sonar authorizes participation

Sale Lifecycle

End-to-end sale process