# QUIC SDK

### Objective

This SDK is designed to make it easy to submit transactions to bloXroute Trader API over QUIC protocol using the Rust programming language.

Using QUIC to submit transactions provides several advantages:

* Reduced serialization overhead from sending raw bytes
* Improved handling of head-of-line blocking through independent stream multiplexing
* Faster connection setup times

{% embed url="<https://github.com/bloXroute-Labs/solana-trader-quic-client-rust>" %}

{% hint style="info" %}
Although our official QUIC submission SDK is built in Rust, customers can use any programming language to submit transactions over QUIC, provided they adhere to the same connection and submission protocol.
{% endhint %}

### Requirements

Unlike HTTP/WebSocket/gRPC, QUIC authenticates using **mTLS**, which requires passing a certificate on connection establishment. These credentials are easily downloadable within your bloXroute portal.

1. Visit the bloXroute portal and log in at <https://portal.bloxroute.com/login>
2. Navigate to the *Account* Tab
3. Under the *Setup Instructions* panel, click the hyperlink to "Download the artifacts", which include your certificate and secret hash.

<figure><img src="/files/KfeTrPtwe0r6jPwgUEYo" alt=""><figcaption></figcaption></figure>

### Support

Trader API supports QUIC submission across three QUIC paradigms:

* Bidirectional streams *(with response)*
* Unidirectional streams *(no response)*
* Datagram *(no response)*

We recommend starting with bidirectional streams when testing your initial setup, as they provide responses to help verify that connections and submissions are working correctly. Once propagation is confirmed, you can switch to unidirectional streams or QUIC datagrams to achieve lower overhead and reduced latency.

{% hint style="info" %}
QUIC transaction submission is currently supported only on regional endpoints and is not yet available on the global edge endpoint. Support for the global edge endpoint is coming soon.
{% endhint %}

### Usage

Once you have downloaded your credentials (certificate and key file), you can initialize our SDK client by passing the file paths to these credentials. The initialized client should be re-used for all transaction submissions, and has keep-alive configurations managed for you to ensure a long-lived healthy connection.

```rust
// client configuration
let config = TraderApiQuicClientConfig::new_from_pem_files(
	BlxEndpoint::XYZ, // replace with desired endpoint
	"/path/to/external_gateway_cert.pem",
	"/path/to/external_gateway_key.pem",
)?;

// create client and connect
let client = TraderApiQuicClient::connect(config).await?;
```

To submit a transaction, pass the raw signed transaction bytes (not base64) to any of the supported submission methods — **one stream/datagram per transaction**.

**Datagram:**

```rust
client.send_transaction_datagram(&tx_bytes)?;
```

**Unidirectional stream:**

```rust
client.send_transaction_uni(&tx_bytes).await?;
```

**Bidirectional stream:**

```rust
let signature = client.send_transaction_bi(&tx_bytes).await?;
let signature = std::str::from_utf8(&signature)?;
```

The repository also includes a runable example.

```zsh
cargo run --example quic_submit_example -- \
  --mode uni \
  --tx-file /tmp/txBase64.txt \
  --client-cert /path/to/external_gateway_cert.pem \
  --client-key /path/to/external_gateway_key.pem
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bloxroute.com/solana/trader-api/quick-start/quic-sdk.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
