Surge Subscription Guide
This guide explains how to subscribe to Switchboard Surge programmatically on Solana, without using the explorer UI. It is intended for AI agents, bots, and automated systems that need to create or manage Surge subscriptions via on-chain transactions.
Overview
Surge subscriptions are managed entirely on Solana via the Surge program (orac1eFjzWL5R3RbbdMV68K9H6TaCVVcL6LjvQQWAbz). The subscription flow is:
Choose a tier
Acquire SWTCH tokens
Call
subscription_initwith a live SWTCH/USDT oracle quoteProgram calculates cost in SWTCH at the live price, transfers tokens to the vault
Subscription PDA is created and active until the end epoch
Wallet (has SWTCH tokens)
→ picks tier (Plug / Pro / Enterprise)
→ calls subscription_init with a fresh SWTCH/USDT oracle quote
→ program calculates cost in SWTCH at live price
→ transfers SWTCH to vault
→ subscription PDA created, active until end epochStep 1: Choose a Tier
Tiers are on-chain PDA accounts with the seed [TIER, tier_id_bytes], created by Switchboard admins. Each tier defines:
cost_per_epoch_usd_cents
Price in USD cents per epoch
max_connections
Maximum concurrent WebSocket connections
max_feeds
Maximum feeds per subscription
max_feeds_per_ix
Maximum feeds per instruction
min_delay_ms
Minimum update delay in milliseconds
is_public
Whether anyone can subscribe
Public tiers (tier IDs 1-9) are open to all wallets. Tier IDs 10+ require admin approval.
Current Tiers
Plug
1
Free
10s
2
1
Pro
2
~$3,000/mo
450ms
100
10
Enterprise
3
~$7,500/mo
0ms
300
15
To read tier details on-chain, derive the tier PDA:
Step 2: Get SWTCH Tokens
All subscription payments must be in SWTCH tokens. The program enforces this check:
Acquire SWTCH tokens via any Solana DEX (e.g., Jupiter, Raydium) before initiating the subscription.
Step 3: Call subscription_init
Send a transaction with the subscription_init instruction. The instruction takes the following parameters:
Parameters
tier_id
u32
Which tier to subscribe to (e.g., 1, 2, 3)
epoch_amount
u16
Number of epochs to pay for (1-146, i.e., up to ~1 year)
contact_name
Option<String>
Optional contact name metadata
contact_email
Option<String>
Optional contact email metadata
Required Accounts
State
The program's global state PDA
Seed: [STATE]
Tier
The chosen tier's PDA
Seed: [TIER, tier_id_bytes]
Owner
The wallet subscribing
Your wallet pubkey
Payer
Signer paying for rent + SWTCH tokens
Typically same as owner
Payment Mint
The SWTCH token mint
Stored in state.swtch_mint
Payer Token Account
Payer's SWTCH associated token account
Standard ATA derivation
Token Vault
Program's vault for the payment mint
PDA from program state
Quote Account
A Switchboard oracle quote with the live SWTCH/USDT price
Fetched from Switchboard oracle
Deriving PDAs
Step 4: On-Chain Pricing
The program does not use a hardcoded SWTCH price. Instead, it reads the live SWTCH/USDT price from a Switchboard oracle quote passed as an account in the transaction.
Pricing Logic
Deserializes the oracle quote account
Validates the feed ID matches the expected
swtch_feed_idstored in program stateExtracts the USD price (e.g., $0.11246 per SWTCH)
Converts tier cost from USD cents to SWTCH lamports:
Multiplies by
epoch_amount * cost_per_epoch_usd_centsTransfers that amount of SWTCH from payer's token account to the program vault
Example Cost Calculation
For a Pro tier at cost_per_epoch_usd_cents = 700 (i.e., $7.00/epoch), buying 40 epochs, with SWTCH at $0.11:
The oracle quote must be fresh — stale quotes will be rejected.
Step 5: Subscription Created
Once the transaction succeeds, a subscription PDA is created at [SUBSCRIPTION, owner_pubkey]. The subscription includes:
Bonus epoch: The current epoch is free — you get +1 epoch on top of what you paid for
Epoch tracking: Subscription validity is tracked via
subscription_start_epochandsubscription_end_epochUser management: Up to 16 authorized users can be added later via
subscription_manage_users
Providing the Oracle Quote
The SWTCH/USDT price quote is the most important piece of the subscription transaction. You need to pass a valid, fresh Switchboard oracle quote for the SWTCH/USDT feed.
Using the Switchboard SDK
Include the quote instruction(s) in the same transaction as subscription_init to ensure the price data is fresh and verified.
Full Transaction Assembly
A complete subscription transaction includes:
Oracle quote verification instruction(s) — ensures fresh SWTCH/USDT price on-chain
subscription_initinstruction — creates the subscription using the verified price
Verifying Your Subscription
After the transaction confirms, read the subscription PDA to verify:
Key Addresses
Surge Program ID
orac1eFjzWL5R3RbbdMV68K9H6TaCVVcL6LjvQQWAbz
SWTCH Token Mint
Stored in program state (state.swtch_mint)
SWTCH/USDT Feed ID
Stored in program state (state.swtch_feed_id)
Notes for AI Agents
Fresh quotes are mandatory: The oracle quote account must contain a recent SWTCH/USDT price. Include the quote verification instruction in the same transaction.
Epoch amounts: Valid range is 1-146 epochs. One Solana epoch is approximately 2-3 days, so 146 epochs covers roughly one year.
Free tier: The Plug tier (tier ID 1) is free but still requires calling
subscription_initwith a valid oracle quote (the transfer amount will be zero).Subscription PDA is unique per wallet: Each wallet can have only one subscription at
[SUBSCRIPTION, owner_pubkey].Managing users: After subscribing, use
subscription_manage_usersto authorize up to 16 additional wallets to use the subscription.
Last updated