sendTransaction
Submit one signed transaction.
{
"jsonrpc": "2.0",
"id": 1,
"method": "sendTransaction",
"params": ["SIGNED_TRANSACTION", { "encoding": "base64" }]
}Params
params holds one or two elements.
| Position | Type | Content |
|---|---|---|
| 0 | string | One fully signed wire transaction, encoded as specified by options.encoding. |
| 1 | object, optional | Options, below. |
Options
| Field | Type | Default | Meaning |
|---|---|---|---|
encoding | string | "base58" | "base58" or "base64". Any other value is refused as malformed, problem unknown_encoding. |
skipPreflight | boolean | true | false simulates the transaction before sending it. Solana RPC defaults to false; SWQoS does not. |
preflightCommitment | string | "finalized" | "processed", "confirmed" or "finalized". Read only when skipPreflight is false. |
minContextSlot | integer | none | Passed to the simulation. Read only when skipPreflight is false. |
maxRetries | integer | none | Accepted and ignored. SWQoS does not periodically resubmit. |
tip | integer, lamports | none | A declared tip. Used only when the transaction's own tip is below your minimum and your key may declare tips. |
Fields not listed are ignored. A listed field of the wrong type is refused as invalid_request, problem invalid_options.
Size limits
| Encoding | Longest string | Largest transaction |
|---|---|---|
| base58 | 1,683 characters | 1,232 bytes, any version |
| base64, legacy and v0 | 1,644 characters | 1,232 bytes |
| base64, v1 | 5,464 characters | 4,096 bytes |
A v1 transaction over 1,232 bytes needs base64 here, or raw bytes through /binary, QUIC or the agent's IPC. Transactions covers formats and the checks SWQoS makes.
Result
The base58 encoding of the transaction's first signature, as a string, with HTTP 200.
{"jsonrpc":"2.0","result":"BASE58_SIGNATURE","id":1}A result acknowledges acceptance, not landing. Confirm the signature with your Solana RPC provider. A duplicate can return the same result without being sent again.
Submission requirements
The transaction must be fully signed, meet the size limits and satisfy your key's tip requirement. Each submission counts against the send rate.
Errors
| Reason | HTTP | Code | When |
|---|---|---|---|
unauthorized | 401 | -32000 | The key is missing, unknown or revoked. |
invalid_request | 200 | see codes | The request is not a valid sendTransaction call. problem names the cause. |
malformed | 200 | -32602 | The string does not decode to a transaction. problem names the cause. |
too_large | 200 | -32602 | Over a size limit. limit and, when known, size are in bytes. |
unsigned | 200 | -32602 | The first signature is all zeros. |
signature_count | 200 | -32602 | The signatures do not match the number the message requires. |
payment_required | 402 | -32003 | The key is suspended until its overdue invoice is paid. |
rate_limited | 429 | -32001 | Over the key's send rate, with per_second and retry_after_ms; or the same signature is being sent right now, without numbers. |
missing_tip | 200 | -32602 | The tip is below your minimum and no usable declaration covers it. |
credit_exhausted | 200 | -32602 | Credit is unavailable for this declared-tip submission. |
not_ready | 503 | -32603 | waiting_for is tip_vaults, declared_tips or leader_route. |
simulation_failed | 200 | -32002 | The preflight simulation returned an error. Solana's fields are in data. |
preflight_unavailable | 503 | -32603 | The simulation could not run within 150 ms, or the node was behind. |
overloaded | 503 | -32603 | The region is temporarily busy. |
forward_failed | 503 | -32603 | The transaction could not be dispatched. |
internal | 503 | -32603 | An internal error. |
Examples
Each example sends a transaction you signed. These calls go to SWQoS; read the blockhash you sign with from your own Solana RPC provider.
curl -sS "https://sol.zerocopy.sh" \
-H "x-api-key: $SWQOS_API_KEY" \
-H 'content-type: application/json' \
--data "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"sendTransaction\",\"params\":[\"$(base64 -w0 signed-tx.bin)\",{\"encoding\":\"base64\"}]}"With @solana/kit, pass encoding: 'base64'; Kit's wire helper produces base64 and SWQoS defaults to base58. Kit reports refusals with limited detail, as Solana client libraries explains.
import { readFile } from 'node:fs/promises'
import {
createSolanaRpc,
getBase64EncodedWireTransaction,
getTransactionDecoder,
} from '@solana/kit'
import { required, url } from './swqos.ts'
// A fully signed transaction in wire format, from your signing flow.
const transaction = getTransactionDecoder().decode(await readFile(required('SIGNED_TX_FILE')))
const swqos = createSolanaRpc(url, { headers: { 'x-api-key': required('SWQOS_API_KEY') } })
const signature = await swqos
.sendTransaction(getBase64EncodedWireTransaction(transaction), { encoding: 'base64' })
.send()
console.log(signature)With the client helper, a refusal keeps its reason and fields. This call asks for a preflight simulation at confirmed commitment.
import { readFile } from 'node:fs/promises'
import { call, required, SwqosError } from './swqos.ts'
const transaction = (await readFile(required('SIGNED_TX_FILE'))).toString('base64')
try {
const signature = await call<string>('sendTransaction', [
transaction,
{ encoding: 'base64', skipPreflight: false, preflightCommitment: 'confirmed' },
])
console.log('accepted', signature)
} catch (error) {
if (!(error instanceof SwqosError) || !error.rejection) throw error
const { reason, retryable, message } = error.rejection
console.error(error.status, reason, retryable, message)
if (reason === 'simulation_failed') console.error(error.rejection.logs)
}A key with declared tips enabled can declare the tip instead of carrying it. The tip value is in lamports.
import { readFile } from 'node:fs/promises'
import { call, required } from './swqos.ts'
const transaction = (await readFile(required('SIGNED_TX_FILE'))).toString('base64')
const tip = Number(required('DECLARED_TIP_LAMPORTS'))
if (!Number.isSafeInteger(tip) || tip <= 0) throw new Error('tip must be a positive safe integer')
const signature = await call<string>('sendTransaction', [
transaction,
{ encoding: 'base64', tip },
])
console.log(signature)