# Tips

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

Source: https://zerocopy.sh/docs/swqos/tips

Each submission must meet your key's tip requirement. Add a SOL transfer or a [USDC, USDT or WSOL transfer](#tip-in-tokens) to the transaction, or use a [declared tip](#declared-tips) 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](#token-value).

## Live accounts [#live-accounts]

Call [`getTipAccounts`](/docs/reference/json-rpc/tip-accounts) 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`](/docs/reference/errors#not_ready) with `waiting_for: tip_vaults`.

### Cache tip accounts [#tip-account-helper]

These helpers cache the list for 15 minutes. Pass `refresh` after a [`missing_tip`](/docs/reference/errors#missing_tip) response whose `found` is lower than expected. The Rust and Go versions are files in the [example project](/docs/reference/json-rpc#example-project).

```rust title="src/quickstart_tip_accounts.rs" tab="Rust" tab-group="language"
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)
}
```

```go title="quickstart_tip_accounts.go" tab="Go" tab-group="language"
package swqos

import (
	"bytes"
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"net/http"
	"sync"
	"time"
)

const tipAccountsCacheFor = 15 * time.Minute

var tipAccountsCache struct {
	sync.Mutex
	accounts []string
	at       time.Time
}

func GetTipAccounts(ctx context.Context, apiKey string, refresh bool) ([]string, error) {
	if !refresh {
		tipAccountsCache.Lock()
		accounts, at := tipAccountsCache.accounts, tipAccountsCache.at
		tipAccountsCache.Unlock()
		if accounts != nil && time.Since(at) < tipAccountsCacheFor {
			return accounts, nil
		}
	}
	body := []byte(`{"jsonrpc":"2.0","id":1,"method":"getTipAccounts"}`)
	request, err := http.NewRequestWithContext(ctx, http.MethodPost, "https://sol.zerocopy.sh", bytes.NewReader(body))
	if err != nil {
		return nil, err
	}
	request.Header.Set("content-type", "application/json")
	request.Header.Set("x-api-key", apiKey)
	response, err := http.DefaultClient.Do(request)
	if err != nil {
		return nil, err
	}
	defer response.Body.Close()
	if response.StatusCode < 200 || response.StatusCode >= 300 {
		return nil, fmt.Errorf("Tip discovery failed: HTTP %d", response.StatusCode)
	}
	var reply struct {
		Result json.RawMessage `json:"result"`
	}
	if err := json.NewDecoder(response.Body).Decode(&reply); err != nil {
		return nil, err
	}
	var values []any
	if len(reply.Result) == 0 || reply.Result[0] != '[' || json.Unmarshal(reply.Result, &values) != nil {
		return nil, errors.New("Tip discovery did not return an account list")
	}
	accounts := make([]string, len(values))
	for i, value := range values {
		account, ok := value.(string)
		if !ok {
			return nil, errors.New("Tip discovery did not return an account list")
		}
		accounts[i] = account
	}
	if len(accounts) == 0 {
		return nil, errors.New("No tip account is available")
	}
	tipAccountsCache.Lock()
	tipAccountsCache.accounts, tipAccountsCache.at = accounts, time.Now()
	tipAccountsCache.Unlock()
	return accounts, nil
}
```

```ts title="tip-accounts.ts" tab="TypeScript" tab-group="language"
const CACHE_MS = 15 * 60 * 1000
let cached: { accounts: string[]; at: number } | undefined

export async function getTipAccounts(apiKey: string, refresh = false): Promise<string[]> {
  if (!refresh && cached && Date.now() - cached.at < CACHE_MS) return cached.accounts
  const response = await fetch('https://sol.zerocopy.sh', {
    method: 'POST',
    headers: { 'content-type': 'application/json', 'x-api-key': apiKey },
    body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'getTipAccounts' }),
  })
  if (!response.ok) throw new Error(`Tip discovery failed: HTTP ${response.status}`)
  const body: unknown = await response.json()
  if (
    !body || typeof body !== 'object' || !('result' in body) ||
    !Array.isArray(body.result) || !body.result.every((value) => typeof value === 'string')
  ) {
    throw new Error('Tip discovery did not return an account list')
  }
  if (body.result.length === 0) throw new Error('No tip account is available')
  cached = { accounts: body.result, at: Date.now() }
  return body.result
}
```

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

## What counts [#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](#live-accounts).
- A Token Program `Transfer` or `TransferChecked` of USDC, USDT or WSOL to a live tip account's [token account](#token-accounts).

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](#lookup-tables).

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`](/docs/reference/errors#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 [#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:

| Token | Mint | Decimals | Example amount |
| --- | --- | --- | --- |
| USDC | `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` | 6 | 0.25 USDC is 250,000 |
| USDT | `Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB` | 6 | 0.25 USDT is 250,000 |
| WSOL | `So11111111111111111111111111111111111111112` | 9 | 0.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](#token-example) builds and sends one.

### Value [#token-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](#engine-minimums) and the [tip floor](#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`](/docs/reference/errors#not_ready) with `waiting_for: token_price`. Retry shortly, or tip in SOL or WSOL.

Token tips count toward [rebates](/docs/account/billing#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 [#token-engines]

Block engines are paid in SOL. A tip that includes tokens takes [block engine routes](/docs/swqos/routing#engines) 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`](/docs/reference/errors#not_ready) with `waiting_for: block_engine`. Pay larger tips in SOL; a SOL tip has no such limit.

### Token accounts [#token-accounts]

Call [`getTipTokenAccounts`](/docs/reference/json-rpc/tip-token-accounts). 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](#live-accounts), 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](/docs/account/white-label#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 [#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`](/docs/reference/errors#not_ready) with `waiting_for: lookup_table`; retry shortly. On a [QUIC stream without a reply](/docs/reference/quic#streams), 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 [#local-agent]

The [local agent](/docs/swqos/agent/local-interfaces#token-tips) 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 [#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`](/docs/reference/errors#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 [#engine-minimums]

Bundles must also meet the [minimum for an available block engine](/docs/swqos/bundles#engine-eligibility). Token tips count toward it at their SOL value.

## Tip floor [#tip-floor]

Use [`getTipFloor`](/docs/reference/json-rpc/tip-floor) or [`GET /tip_floor`](/docs/reference/http/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 [#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](https://console.zerocopy.sh) to ask us to enable your key and arrange payment before using them. See [Billing](/docs/account/billing) for account payment guidance.

### Declare an amount [#declare]

Set `tip` in the options for [`sendTransaction`](/docs/reference/json-rpc/send-transaction) or [`sendBundle`](/docs/reference/json-rpc/send-bundle). A bundle has one declaration for all members. For raw HTTP, QUIC and IPC, follow the [payload envelope reference](/docs/reference/payload-envelope).

```json title="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](#minimum-tip) explain how a declaration interacts with transfers already in the transaction.

### Submission requirements [#admission]

Your key must have declared tips enabled and credit available. [`missing_tip`](/docs/reference/errors#missing_tip) means the amount or key permissions do not qualify. [`not_ready`](/docs/reference/errors#not_ready) means the service cannot accept that submission right now.

### Charges and repeat submissions [#what-is-billed]

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 [#suspension]

An overdue payment can suspend submissions with the key. They return [`payment_required`](/docs/reference/errors#payment_required) with `unpaid_lamports`. Queries remain available. Resolve the outstanding payment through your agreed billing setup or ask for help on [Discord](https://discord.gg/zerocopy). Adding a tip transfer does not bypass a payment suspension.

## Add a transfer [#example]

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.

```rust title="src/bin/tip_and_send.rs" tab="Rust" tab-group="language"
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(())
}
```

```go title="tip_and_send.go" tab="Go" tab-group="language"
package swqos

import (
	"context"
	"encoding/base64"
	"fmt"
	"strconv"

	"github.com/gagliardetto/solana-go"
	"github.com/gagliardetto/solana-go/programs/system"
)

func TipAndSend(ctx context.Context) error {
	rpcURL, err := Required("SOLANA_RPC_URL")
	if err != nil {
		return err
	}
	keypairFile, err := Required("KEYPAIR_FILE")
	if err != nil {
		return err
	}
	payer, err := solana.PrivateKeyFromSolanaKeygenFile(keypairFile)
	if err != nil {
		return err
	}
	accounts, err := Call[[]string](ctx, "getTipAccounts")
	if err != nil {
		return err
	}
	if len(accounts) == 0 {
		return fmt.Errorf("no live tip account; retry shortly")
	}
	tipAccount, err := solana.PublicKeyFromBase58(accounts[0])
	if err != nil {
		return err
	}
	lifetime, err := callAt[struct {
		Value struct {
			Blockhash            solana.Hash `json:"blockhash"`
			LastValidBlockHeight uint64      `json:"lastValidBlockHeight"`
		} `json:"value"`
	}](ctx, rpcURL, "", "getLatestBlockhash", map[string]any{"commitment": "confirmed"})
	if err != nil {
		return err
	}
	value, err := Required("TIP_LAMPORTS")
	if err != nil {
		return err
	}
	amount, err := strconv.ParseUint(value, 10, 64)
	if err != nil {
		return err
	}
	transaction, err := solana.NewTransaction([]solana.Instruction{
		system.NewTransferInstruction(amount, payer.PublicKey(), tipAccount).Build(),
	}, lifetime.Value.Blockhash, solana.TransactionPayer(payer.PublicKey()))
	if err != nil {
		return err
	}
	if _, err := transaction.Message.SetVersion(solana.MessageVersionV0); err != nil {
		return err
	}
	if _, err := transaction.Sign(func(key solana.PublicKey) *solana.PrivateKey {
		if key == payer.PublicKey() {
			return &payer
		}
		return nil
	}); err != nil {
		return err
	}
	wire, err := transaction.MarshalBinary()
	if err != nil {
		return err
	}
	signature, err := Call[string](ctx, "sendTransaction", base64.StdEncoding.EncodeToString(wire),
		map[string]any{"encoding": "base64", "skipPreflight": true})
	if err != nil {
		return err
	}
	fmt.Println(signature)
	return nil
}
```

```ts title="tip-and-send.ts" tab="TypeScript" tab-group="language"
import { readFile } from 'node:fs/promises'
import { getTransferSolInstruction } from '@solana-program/system'
import {
  address,
  appendTransactionMessageInstructions,
  createKeyPairSignerFromBytes,
  createSolanaRpc,
  createTransactionMessage,
  getBase64EncodedWireTransaction,
  pipe,
  setTransactionMessageFeePayerSigner,
  setTransactionMessageLifetimeUsingBlockhash,
  signTransactionMessageWithSigners,
} from '@solana/kit'
import { call, required } from './swqos.ts'

const readRpc = createSolanaRpc(required('SOLANA_RPC_URL'))
const payer = await createKeyPairSignerFromBytes(
  new Uint8Array(JSON.parse(await readFile(required('KEYPAIR_FILE'), 'utf8'))),
)
const [tipAccount] = await call<string[]>('getTipAccounts')
if (!tipAccount) throw new Error('no live tip account; retry shortly')
const { value: lifetime } = await readRpc.getLatestBlockhash({ commitment: 'confirmed' }).send()
const message = pipe(
  createTransactionMessage({ version: 0 }),
  (m) => setTransactionMessageFeePayerSigner(payer, m),
  (m) => setTransactionMessageLifetimeUsingBlockhash(lifetime, m),
  (m) =>
    appendTransactionMessageInstructions(
      [
        getTransferSolInstruction({
          source: payer,
          destination: address(tipAccount),
          amount: BigInt(required('TIP_LAMPORTS')),
        }),
      ],
      m,
    ),
)
const transaction = await signTransactionMessageWithSigners(message)
const signature = await call<string>('sendTransaction', [
  getBase64EncodedWireTransaction(transaction),
  { encoding: 'base64', skipPreflight: true },
])
console.log(signature)
```

`KEYPAIR_FILE` names a Solana CLI keypair JSON file. `call` from the [example project](/docs/reference/json-rpc#example-project) keeps structured refusals. After acceptance, [confirm the signature](/docs/swqos/confirmation) through your read RPC.

## Add a token transfer [#token-example]

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](#token-value) is a little above your key's minimum. The Rust version uses the [example project](/docs/reference/json-rpc#example-project)'s `spl-token-interface` and `spl-associated-token-account-interface` crates; TypeScript uses `@solana-program/token`.

```rust title="src/bin/token_tip_and_send.rs" tab="Rust" tab-group="language"
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(())
}
```

```go title="token_tip_and_send.go" tab="Go" tab-group="language"
package swqos

import (
	"context"
	"encoding/base64"
	"fmt"
	"strconv"

	"github.com/gagliardetto/solana-go"
	"github.com/gagliardetto/solana-go/programs/token"
)

func TokenTipAndSend(ctx context.Context) error {
	rpcURL, err := Required("SOLANA_RPC_URL")
	if err != nil {
		return err
	}
	keypairFile, err := Required("KEYPAIR_FILE")
	if err != nil {
		return err
	}
	payer, err := solana.PrivateKeyFromSolanaKeygenFile(keypairFile)
	if err != nil {
		return err
	}
	symbol, err := Required("TIP_TOKEN")
	if err != nil {
		return err
	}
	accounts, err := Call[[]struct {
		Account  solana.PublicKey `json:"account"`
		Mint     solana.PublicKey `json:"mint"`
		Symbol   string           `json:"symbol"`
		Decimals uint8            `json:"decimals"`
	}](ctx, "getTipTokenAccounts")
	if err != nil {
		return err
	}
	tip := -1
	for i, entry := range accounts {
		if entry.Symbol == symbol {
			tip = i
			break
		}
	}
	if tip < 0 {
		return fmt.Errorf("no %s token account; tip in SOL or retry shortly", symbol)
	}
	destination, mint, decimals := accounts[tip].Account, accounts[tip].Mint, accounts[tip].Decimals
	source, _, err := solana.FindAssociatedTokenAddress(payer.PublicKey(), mint)
	if err != nil {
		return err
	}
	lifetime, err := callAt[struct {
		Value struct {
			Blockhash            solana.Hash `json:"blockhash"`
			LastValidBlockHeight uint64      `json:"lastValidBlockHeight"`
		} `json:"value"`
	}](ctx, rpcURL, "", "getLatestBlockhash", map[string]any{"commitment": "confirmed"})
	if err != nil {
		return err
	}
	value, err := Required("TIP_AMOUNT")
	if err != nil {
		return err
	}
	amount, err := strconv.ParseUint(value, 10, 64)
	if err != nil {
		return err
	}
	transaction, err := solana.NewTransaction([]solana.Instruction{
		token.NewTransferCheckedInstruction(amount, decimals, source, mint, destination, payer.PublicKey(), nil).Build(),
	}, lifetime.Value.Blockhash, solana.TransactionPayer(payer.PublicKey()))
	if err != nil {
		return err
	}
	if _, err := transaction.Message.SetVersion(solana.MessageVersionV0); err != nil {
		return err
	}
	if _, err := transaction.Sign(func(key solana.PublicKey) *solana.PrivateKey {
		if key == payer.PublicKey() {
			return &payer
		}
		return nil
	}); err != nil {
		return err
	}
	wire, err := transaction.MarshalBinary()
	if err != nil {
		return err
	}
	signature, err := Call[string](ctx, "sendTransaction", base64.StdEncoding.EncodeToString(wire),
		map[string]any{"encoding": "base64", "skipPreflight": true})
	if err != nil {
		return err
	}
	fmt.Println(signature)
	return nil
}
```

```ts title="token-tip-and-send.ts" tab="TypeScript" tab-group="language"
import { readFile } from 'node:fs/promises'
import {
  findAssociatedTokenPda,
  getTransferCheckedInstruction,
  TOKEN_PROGRAM_ADDRESS,
} from '@solana-program/token'
import {
  address,
  appendTransactionMessageInstructions,
  createKeyPairSignerFromBytes,
  createSolanaRpc,
  createTransactionMessage,
  getBase64EncodedWireTransaction,
  pipe,
  setTransactionMessageFeePayerSigner,
  setTransactionMessageLifetimeUsingBlockhash,
  signTransactionMessageWithSigners,
} from '@solana/kit'
import { call, required } from './swqos.ts'

type TipTokenAccount = { account: string; mint: string; symbol: string; decimals: number }

const readRpc = createSolanaRpc(required('SOLANA_RPC_URL'))
const payer = await createKeyPairSignerFromBytes(
  new Uint8Array(JSON.parse(await readFile(required('KEYPAIR_FILE'), 'utf8'))),
)
const symbol = required('TIP_TOKEN')
const accounts = await call<TipTokenAccount[]>('getTipTokenAccounts')
const tip = accounts.find((entry) => entry.symbol === symbol)
if (!tip) throw new Error(`no ${symbol} token account; tip in SOL or retry shortly`)
const mint = address(tip.mint)
const [source] = await findAssociatedTokenPda({
  owner: payer.address,
  mint,
  tokenProgram: TOKEN_PROGRAM_ADDRESS,
})
const { value: lifetime } = await readRpc.getLatestBlockhash({ commitment: 'confirmed' }).send()
const message = pipe(
  createTransactionMessage({ version: 0 }),
  (m) => setTransactionMessageFeePayerSigner(payer, m),
  (m) => setTransactionMessageLifetimeUsingBlockhash(lifetime, m),
  (m) =>
    appendTransactionMessageInstructions(
      [
        getTransferCheckedInstruction({
          source,
          mint,
          destination: address(tip.account),
          authority: payer,
          amount: BigInt(required('TIP_AMOUNT')),
          decimals: tip.decimals,
        }),
      ],
      m,
    ),
)
const transaction = await signTransactionMessageWithSigners(message)
const signature = await call<string>('sendTransaction', [
  getBase64EncodedWireTransaction(transaction),
  { encoding: 'base64', skipPreflight: true },
])
console.log(signature)
```

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`.
