ZeroCopyZeroCopy
SWQoS

Tips

Choose a tip amount, find a live tip account and pay in SOL, USDC, USDT or WSOL, or declare a tip

Each submission must meet your key's tip requirement. Add a SOL transfer or a USDC, USDT or WSOL transfer to the transaction, or use a declared tip if support has enabled it for your key.

Minimums, refusal fields, declared tips and the tip floor are in lamports. One SOL is 1,000,000,000 lamports. Token tips are in the token's base units and count at their SOL value.

Live accounts

Call getTipAccounts and choose any returned address.

Do not store a fixed list of addresses. Cache the list for up to 15 minutes, then fetch it again. Fetch it sooner after a missing_tip response whose found is lower than you expected, because an address that has left the list no longer counts as a tip. If the list is empty, wait and try again; submissions return not_ready with waiting_for: tip_vaults.

Cache tip accounts

These helpers cache the list for 15 minutes. Pass refresh after a missing_tip response whose found is lower than expected. The Rust and Go versions are files in the example project.

src/quickstart_tip_accounts.rs
use std::sync::{Mutex, PoisonError};
use std::time::{Duration, Instant};

use serde_json::{Value, json};

use crate::swqos::Result;

const CACHE_FOR: Duration = Duration::from_secs(15 * 60);
static CACHE: Mutex<Option<(Instant, Vec<String>)>> = Mutex::new(None);

pub async fn get_tip_accounts(api_key: &str, refresh: bool) -> Result<Vec<String>> {
    if !refresh {
        let cache = CACHE.lock().unwrap_or_else(PoisonError::into_inner);
        if let Some((at, accounts)) = cache.as_ref() {
            if at.elapsed() < CACHE_FOR {
                return Ok(accounts.clone());
            }
        }
    }
    let response = reqwest::Client::new()
        .post("https://sol.zerocopy.sh")
        .header("x-api-key", api_key)
        .json(&json!({ "jsonrpc": "2.0", "id": 1, "method": "getTipAccounts" }))
        .send()
        .await?;
    if !response.status().is_success() {
        return Err(format!(
            "Tip discovery failed: HTTP {}",
            response.status().as_u16()
        )
        .into());
    }
    let mut body: Value = response.json().await?;
    let result = body
        .get_mut("result")
        .ok_or("Tip discovery did not return an account list")?
        .take();
    let accounts: Vec<String> = serde_json::from_value(result)
        .map_err(|_| "Tip discovery did not return an account list")?;
    if accounts.is_empty() {
        return Err("No tip account is available".into());
    }
    *CACHE.lock().unwrap_or_else(PoisonError::into_inner) =
        Some((Instant::now(), accounts.clone()));
    Ok(accounts)
}

If discovery returns an empty list or not_ready, wait until it succeeds instead of sending to a remembered account.

What counts

A tip is one of these transfers, placed directly in the transaction outside any program invocation:

  • A System Program Transfer of SOL to a live tip account.
  • A Token Program Transfer or TransferChecked of USDC, USDT or WSOL to a live tip account's token account.

The recipient can be one of the transaction's static account keys or, in a v0 transaction, a writable address loaded from an address lookup table.

CPI transfers, transferWithSeed and Token-2022 instructions do not count. Multiple qualifying transfers add together, SOL and tokens alike, including across a bundle's members.

The qualifying total, at its SOL value, must not exceed 2 SOL per transaction or bundle. A larger total returns malformed with problem: tip_too_large; an unsigned 64 bit sum overflow returns problem: tip_overflow.

The tip transfers only if the transaction executes successfully. Solana network fees are separate and can still be charged when execution fails.

Tip in tokens

You can pay a tip in USDC, USDT or WSOL. Transfer the token from your own token account to a tip account's token account with the Token Program's Transfer or TransferChecked instruction. Amounts are in the token's base units:

TokenMintDecimalsExample amount
USDCEPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v60.25 USDC is 250,000
USDTEs9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB60.25 USDT is 250,000
WSOLSo1111111111111111111111111111111111111111290.001 WSOL is 1,000,000

Other mints do not count. For WSOL, wrap SOL into your WSOL token account first. The fee payer still pays Solana's network fees in SOL. The token transfer example builds and sends one.

Value

A token tip counts at its SOL value:

  • WSOL counts 1:1 with SOL: 1,000,000 base units count as 1,000,000 lamports.
  • USDC and USDT count at their SOL price, from a cached Pyth price. SWQoS uses the conservative end of the price's confidence interval, so a token tip can count for slightly less than its market value. Tip a little above your key's minimum.
  • Your key's minimum, the 2 SOL limit, engine minimums and the tip floor use the total SOL value of your SOL and token tips.
  • When no recent USDC or USDT price is available, that token counts as zero. If the rest of the tip is below your minimum, the submission returns not_ready with waiting_for: token_price. Retry shortly, or tip in SOL or WSOL.

Token tips count toward rebates at the SOL their conversion yields. ZeroCopy converts USDC and USDT tips to SOL shortly after they land; WSOL counts 1:1. The SOL a conversion yields can differ from the value counted when you sent the tip.

Block engines

Block engines are paid in SOL. A tip that includes tokens takes block engine routes only while its total value is at most 0.1 SOL. Above that, or while engine capacity for token tips is briefly short, a transaction goes to leaders directly and a bundle returns not_ready with waiting_for: block_engine. Pay larger tips in SOL; a SOL tip has no such limit.

Token accounts

Call getTipTokenAccounts. Each entry gives a token account, the tip account that owns it (wallet), the mint, its symbol and its decimals. Use the entry's account as the transfer's destination. Cache the list for up to 15 minutes, like the tip-account list, and fetch it again after a missing_tip response whose found is lower than you expected.

An empty list means token tips are not available for your key, as for keys that tip a partner's tip accounts. Tip in SOL instead.

To derive a token account yourself, take the associated token address of a live tip account and the mint under the Token Program. Tip accounts are program-derived addresses, off the ed25519 curve, so allow an off-curve owner: with @solana/spl-token, call getAssociatedTokenAddressSync(mint, tipAccount, true). A derived address counts only while getTipTokenAccounts lists it.

Lookup tables

In a v0 transaction, the recipient of a SOL or token tip can come from an address lookup table. Add the tip account, or its token account, to your table and load it as writable. It counts only while the tip account is live or getTipTokenAccounts lists the token account.

SWQoS reads the table to find the recipient and caches it. The first submission that uses a table SWQoS has not read yet can wait for one extra read. If the read does not finish in time, the submission returns not_ready with waiting_for: lookup_table; retry shortly. On a QUIC stream without a reply, SWQoS does not wait: it refuses that first submission and reads the table for later ones.

A tip to a static account key needs no table read.

Through the local agent

The local agent checks SOL tips to static account keys itself and leaves token tips and lookup-table recipients to the region. Agent releases that predate token tips refuse a transaction whose SOL tip to static keys is below your minimum with missing_tip, even when a token tip or a lookup-table recipient would cover it. Agents update automatically.

Minimum tip

The minimum is set per key. Its default is 1,000,000 lamports (0.001 SOL), but your key may differ. The minimum field of a missing_tip response is authoritative. found is the SOL value SWQoS counted inside your transaction or bundle, token tips included; token_value is the part of found that came from token tips.

If qualifying transfers meet the key minimum, any declared tip value is ignored. Otherwise, a declaration must meet the minimum on its own; the two amounts are not added. Avoid a partial transfer plus a declaration unless you intend to make both payments.

Engine minimums

Bundles must also meet the minimum for an available block engine. Token tips count toward it at their SOL value.

Tip floor

Use getTipFloor or GET /tip_floor to see landed tip percentiles at an edge in lamports. Token tips count at their SOL value. The percentiles describe tips that already landed and do not predict landing. Your key's minimum still applies. Query a hosted edge; the local agent does not serve the floor.

Declared tips

A declared tip supplies an amount alongside a signed transaction or bundle instead of a transfer inside it. When the submission is billed, the charge is the full declared amount.

Declared tips are off by default. Use Requests in the console to ask us to enable your key and arrange payment before using them. See Billing for account payment guidance.

Declare an amount

Set tip in the options for sendTransaction or sendBundle. A bundle has one declaration for all members. For raw HTTP, QUIC and IPC, follow the payload envelope reference.

Send with a declared tip
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "sendTransaction",
  "params": [
    "YOUR_SIGNED_BASE64_TRANSACTION",
    { "encoding": "base64", "skipPreflight": true, "tip": 1000000 }
  ]
}

Use a positive integer in lamports that meets your key's minimum. In JavaScript, stay within Number.MAX_SAFE_INTEGER. The fee payer still needs SOL for network fees. The minimum tip rules explain how a declaration interacts with transfers already in the transaction.

Submission requirements

Your key must have declared tips enabled and credit available. missing_tip means the amount or key permissions do not qualify. not_ready means the service cannot accept that submission right now.

Charges and repeat submissions

Acceptance alone is not a billing event. Keep the declared amount with the transaction signature or bundle id so you can reconcile billed usage.

Repeating the same signed transaction with the same key and declaration does not charge the same amount again. Raising the declaration can increase the charge, even after an earlier amount was billed. Do not raise it on a retry unless you intend to pay more.

Payment required

An overdue payment can suspend submissions with the key. They return payment_required with unpaid_lamports. Queries remain available. Resolve the outstanding payment through your agreed billing setup or ask for help on Discord. Adding a tip transfer does not bypass a payment suspension.

Add a transfer

This example discovers a live account, reads a blockhash from your Solana read RPC, signs a tip transfer and submits it. In your application, append your other instructions before signing. TIP_LAMPORTS is the amount you choose, at least your key's minimum.

src/bin/tip_and_send.rs
use base64::{Engine, prelude::BASE64_STANDARD};
use serde::Deserialize;
use serde_json::json;
use solana_address::Address;
use solana_hash::Hash;
use solana_keypair::Keypair;
use solana_message::{VersionedMessage, v0};
use solana_signer::Signer;
use solana_system_interface::instruction::transfer;
use solana_transaction::versioned::VersionedTransaction;
use swqos_examples::swqos::{Result, call, request, required};

#[derive(Deserialize)]
struct BlockhashReply {
    value: Lifetime,
}

#[derive(Deserialize)]
struct Lifetime {
    blockhash: String,
}

#[tokio::main]
async fn main() -> Result<()> {
    let read_rpc = required("SOLANA_RPC_URL")?;
    let keypair_bytes: Vec<u8> =
        serde_json::from_slice(&tokio::fs::read(required("KEYPAIR_FILE")?).await?)?;
    let payer = Keypair::try_from(keypair_bytes.as_slice())?;
    let accounts: Vec<String> = call("getTipAccounts", None).await?;
    let tip_account = accounts
        .first()
        .ok_or("no live tip account; retry shortly")?;
    let lifetime: BlockhashReply = request(
        &read_rpc,
        None,
        "getLatestBlockhash",
        Some(json!([{ "commitment": "confirmed" }])),
    )
    .await?;
    let blockhash = lifetime.value.blockhash.parse::<Hash>()?;
    let instruction = transfer(
        &payer.pubkey(),
        &tip_account.parse::<Address>()?,
        required("TIP_LAMPORTS")?.parse::<u64>()?,
    );
    let message =
        v0::Message::try_compile(&payer.pubkey(), &[instruction], &[], blockhash)?;
    let transaction =
        VersionedTransaction::try_new(VersionedMessage::V0(message), &[&payer])?;
    let signature: String = call(
        "sendTransaction",
        Some(json!([
            BASE64_STANDARD.encode(wincode::serialize(&transaction)?),
            { "encoding": "base64", "skipPreflight": true }
        ])),
    )
    .await?;
    println!("{signature}");
    Ok(())
}

KEYPAIR_FILE names a Solana CLI keypair JSON file. call from the example project keeps structured refusals. After acceptance, confirm the signature through your read RPC.

Add a token transfer

This example finds a token account for TIP_TOKEN (USDC, USDT or WSOL), reads a blockhash from your Solana read RPC, signs a TransferChecked from your own token account for that mint and submits it. TIP_AMOUNT is in the token's base units; choose an amount whose SOL value is a little above your key's minimum. The Rust version uses the example project's spl-token-interface and spl-associated-token-account-interface crates; TypeScript uses @solana-program/token.

src/bin/token_tip_and_send.rs
use base64::{Engine, prelude::BASE64_STANDARD};
use serde::Deserialize;
use serde_json::json;
use solana_address::Address;
use solana_hash::Hash;
use solana_keypair::Keypair;
use solana_message::{VersionedMessage, v0};
use solana_signer::Signer;
use solana_transaction::versioned::VersionedTransaction;
use spl_associated_token_account_interface::address::get_associated_token_address;
use spl_token_interface::instruction::transfer_checked;
use swqos_examples::swqos::{Result, call, request, required};

#[derive(Deserialize)]
struct TipTokenAccount {
    account: String,
    mint: String,
    symbol: String,
    decimals: u8,
}

#[derive(Deserialize)]
struct BlockhashReply {
    value: Lifetime,
}

#[derive(Deserialize)]
struct Lifetime {
    blockhash: String,
}

#[tokio::main]
async fn main() -> Result<()> {
    let read_rpc = required("SOLANA_RPC_URL")?;
    let keypair_bytes: Vec<u8> =
        serde_json::from_slice(&tokio::fs::read(required("KEYPAIR_FILE")?).await?)?;
    let payer = Keypair::try_from(keypair_bytes.as_slice())?;
    let symbol = required("TIP_TOKEN")?;
    let accounts: Vec<TipTokenAccount> = call("getTipTokenAccounts", None).await?;
    let tip = accounts
        .iter()
        .find(|entry| entry.symbol == symbol)
        .ok_or("no token account for TIP_TOKEN; tip in SOL or retry shortly")?;
    let mint = tip.mint.parse::<Address>()?;
    let lifetime: BlockhashReply = request(
        &read_rpc,
        None,
        "getLatestBlockhash",
        Some(json!([{ "commitment": "confirmed" }])),
    )
    .await?;
    let blockhash = lifetime.value.blockhash.parse::<Hash>()?;
    let instruction = transfer_checked(
        &spl_token_interface::ID,
        &get_associated_token_address(&payer.pubkey(), &mint),
        &mint,
        &tip.account.parse::<Address>()?,
        &payer.pubkey(),
        &[],
        required("TIP_AMOUNT")?.parse::<u64>()?,
        tip.decimals,
    )?;
    let message =
        v0::Message::try_compile(&payer.pubkey(), &[instruction], &[], blockhash)?;
    let transaction =
        VersionedTransaction::try_new(VersionedMessage::V0(message), &[&payer])?;
    let signature: String = call(
        "sendTransaction",
        Some(json!([
            BASE64_STANDARD.encode(wincode::serialize(&transaction)?),
            { "encoding": "base64", "skipPreflight": true }
        ])),
    )
    .await?;
    println!("{signature}");
    Ok(())
}

The token account you send from must exist and hold the amount. A missing_tip response whose token_value is lower than you expected means the token counted for less than its market value; raise TIP_AMOUNT.