Choose a path
Use the first path that matches your situation:- New traders using the Phoenix UI should onboard in the Phoenix app at phoenix.trade.
- New traders or SDK integrations with a valid referral code should register the trader account with the user’s wallet, then use
/v1/referral/activate-txto apply the referral. - Large integrations onboarding more than 100 users should ask Phoenix for a finite-use delegated signer. The integration can decide whether it or its users pay rent.
- Protocols that want permissionless onboarding should ask Phoenix to grant onboarding privileges to a program PDA controlled by the protocol’s on-chain program.
Referral activation transaction
Most users should onboard through the Phoenix app at phoenix.trade. Use/v1/referral/activate-tx when you are building an SDK or integration flow for a trader with a valid referral code.
/v1/referral/activate-tx does not create the trader account. Register the trader’s default cross-margin account first with the trader’s wallet, or another payer controlled by your app. The endpoint only validates the referral code, adds the Phoenix onboarder signature to the activation transaction, submits it, and records the referral claim.
The flow is:
- Ensure the trader account exists at
traderPdaIndex = 0andtraderSubaccountIndex = 0. If it is missing, register it first. - Fetch the current referral activation accounts from
GET /v1/referral/activation-permission. - Build the referral activation transaction. This transaction contains the delegated onboarding instruction, not
RegisterTrader. - Have the trader authority sign the transaction. If you use a separate fee payer, that payer signs too.
- Submit the partially signed transaction to
POST /v1/referral/activate-tx. - Phoenix validates the referral code and transaction, signs the delegated activation, submits the transaction, and returns the transaction signature and trader PDA.
status can be activated, submitted, or already_activated. A submitted response means the transaction was confirmed and the referral claim was recorded, but Phoenix did not observe the trader account before the API timeout.
Phoenix does not sponsor this flow. Trader account rent is paid when your app registers the trader account, and the activation transaction fee is paid by the transaction signer.
rust/examples/referral_activation_tx.rs.
Builder delegated signer
Use a builder delegated signer when a team expects to onboard more than 100 traders, such as a wallet, bot, protocol, or campaign integration. In this model, the builder reaches out to Phoenix and receives a finite-use delegated onboarding grant. The grant allows a specific signer to onboard a limited number of traders. The builder then owns the onboarding UX and chooses the payer model:- the builder can pay transaction fees and trader-account rent for users
- the user can pay rent from their own wallet
- the builder can support both modes depending on product needs
/v1/referral/activate-tx, does not want to route every user through a referral-code API call, or expects a large number of activations.
Builder responsibilities:
- keep the delegated signer secure
- track remaining onboarding uses
- make onboarding idempotent for retries
- confirm the trader account is active before marking the user onboarded
- request a new grant or use-budget increase before the grant is exhausted
Program PDA onboarding
Use program PDA onboarding when a builder wants permissionless onboarding through its own on-chain program. In this model, Phoenix grants trader-onboarding privileges to a PDA controlled by the builder’s program. Users call the builder program, and the program uses its PDA as the delegated Phoenix signer. The program can enforce the builder’s own rules before spending an onboarding use. The high-level flow is:- Phoenix grants onboarding privileges to the program PDA.
- A user calls the builder program to onboard.
- The builder program registers the Phoenix trader account if needed, then activates it using its PDA authority.
- The resulting Phoenix trader account is owned by the trader authority, not by the builder program.
- onboarding should happen without a backend-held signer
- the builder wants on-chain rules for who can onboard
- users should be able to onboard directly through the builder program
- the builder wants its program, not a keypair, to hold the delegated authority
programs/trader-onboarder example that demonstrates this pattern.
At a high level, the program instruction looks like:
Rust
After onboarding
Registration creates the trader’s default cross-margin account attraderPdaIndex = 0 and traderSubaccountIndex = 0. Referral activation and delegated onboarding then make that account eligible to trade. For account indexes and isolated subaccounts, see Trader Accounts.