Solana Helpers
Transaction signing, position tracking, and redemption utilities
Solana Helpers
The SDK provides utility functions for common Solana operations including transaction signing, position tracking, and redemption calculations.
Transaction Functions
signAndSendTransaction
Sign and send a transaction to the network.
waitForConfirmation
Wait for a transaction to be confirmed.
signSendAndConfirm
Combine signing, sending, and confirming in one call.
Returns: TransactionConfirmation
Position Functions
getTokenBalances
Get all token balances for a wallet. Queries both the standard Token Program and Token-2022 Program.
Returns: TokenBalance[]
This function queries both the standard Token Program and Token-2022 Program to find all token holdings. It returns only tokens with non-zero balances.
getUserPositions
Get all prediction market positions for a wallet.
Returns: UserPosition[]
Redemption Functions
isRedemptionEligible
Check if a position is eligible for redemption.
Redemption eligibility rules:
- Market status must be
determinedorfinalized - Redemption status must be
open - Position must be on the winning side (YES if result is 'yes', NO if result is 'no')
- For scalar markets, both sides may be eligible
calculateScalarPayout
Calculate payout for scalar market positions.
Scalar markets settle at a percentage between 0-100%. For example, if Bitcoin ends at $95,000 in a $90,000-$100,000 range market, YES tokens might pay 50%.
Complete Example
Commitment Levels
When confirming transactions, choose the appropriate commitment:
| Level | Description | Use Case |
|---|---|---|
processed | Fastest, less reliable | Debugging |
confirmed | Good balance of speed/safety | Most trades |
finalized | Most secure, slower | Critical operations |