ZeroCopyZeroCopy
ReferenceHTTP

Send base64 text

POST
/plaintext

Send a signed transaction or bundle as base64 text over HTTP, using the same payload envelope as the raw-byte route.

Authorization

headerx-api-key<token>

Send the SWQoS API key in this header. See the authentication reference for compatibility forms and precedence.

Request Body

The same payload as /binary, encoded as base64 text. Maximum body 21,888 bytes; decoded payload at most 16,403 bytes, received within 2 seconds. There is no encoding option or preflight simulation. The same tip, send rate and transaction rules apply as for JSON-RPC. Uses the same hosts, ports and authentication as JSON-RPC.

body*stringtext/plain

Standard base64 with padding, on one line. Whitespace before and after it is ignored.

Lengthlength <= 21888

Response Body

Returns the transaction's first signature in base58 or the bundle ID as 64 hex characters, in plain text. Acceptance does not mean landing; confirm signatures through your Solana RPC provider.

response?stringtext/plain

Base58 transaction signature or 64-character hex bundle id.

Example request
// src/bin/http_plaintext_send.rs
// Builds on the example project (/reference/json-rpc#example-project).
use base64::{Engine, prelude::BASE64_STANDARD};
use swqos_examples::{payload::bundle_payload, swqos::{Result, required, url}};

#[tokio::main]
async fn main() -> Result<()> {
    // Signed transaction files, in bundle order (1 to 4 files).
    let mut transactions = Vec::new();
    for file in std::env::args().skip(1) {
        transactions.push(tokio::fs::read(file).await?);
    }
    let payload = bundle_payload(&transactions, None)?;
    let mut endpoint = reqwest::Url::parse(&url())?;
    endpoint.set_path("/plaintext");
    endpoint.set_query(None);
    let response = reqwest::Client::new().post(endpoint)
        .header("x-api-key", required("SWQOS_API_KEY")?)
        .header("Content-Type", "text/plain")
        .body(BASE64_STANDARD.encode(payload))
        .send().await?;
    let status = response.status();
    let body = response.text().await?;
    if !status.is_success() {
        return Err(format!("HTTP {status}: {body}").into());
    }
    println!("bundle {body}");
    Ok(())
}
Rust (payload encoder)
Rust (payload encoder)
// Builds on the example project (/reference/json-rpc#example-project).
// src/payload.rs
use crate::swqos::Result;

pub fn transaction_payload(transaction: &[u8], declared_tip: Option<u64>) -> Vec<u8> {
    let mut payload = Vec::with_capacity(
        transaction.len() + usize::from(declared_tip.is_some()) * 10,
    );
    if let Some(tip) = declared_tip {
        payload.extend_from_slice(&[0x00, 0x01]);
        payload.extend_from_slice(&tip.to_le_bytes());
    }
    payload.extend_from_slice(transaction);
    payload
}

pub fn bundle_payload(
    transactions: &[Vec<u8>],
    declared_tip: Option<u64>,
) -> Result<Vec<u8>> {
    if !(1..=4).contains(&transactions.len()) {
        return Err("a bundle holds 1 to 4 transactions".into());
    }
    let size = 3
        + usize::from(declared_tip.is_some()) * 8
        + transactions
            .iter()
            .map(|transaction| 2 + transaction.len())
            .sum::<usize>();
    let mut payload = Vec::with_capacity(size);
    payload
        .extend_from_slice(&[0x00, if declared_tip.is_some() { 0x03 } else { 0x02 }]);
    if let Some(tip) = declared_tip {
        payload.extend_from_slice(&tip.to_le_bytes());
    }
    payload.push(transactions.len() as u8);
    for transaction in transactions {
        payload.extend_from_slice(&(transaction.len() as u16).to_le_bytes());
        payload.extend_from_slice(transaction);
    }
    Ok(payload)
}
Example response
BASE58_SIGNATURE