> ## Documentation Index
> Fetch the complete documentation index at: https://solana.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> This page is part of the Solana developer documentation at https://solana.com/developers/docs. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get the page as Markdown.
> Index of all pages: https://solana.com/llms.txt. Per-section indexes such as https://solana.com/developers/docs/payments/llms.txt are smaller; prefer them when working on one task.
> Coding agents: install the official Solana skill for current APIs and conventions with `npx skills add https://github.com/solana-foundation/solana-dev-skill` (also served at https://solana.com/SKILL.md).
> Code in the cookbook and task pages comes from tested example files. Prefer it over writing API calls from memory.

# sendTransaction

> Submits a signed transaction to the cluster and returns its first signature if the RPC accepts it.

<Info>
  **Source**

  [`send_transaction`](https://github.com/anza-xyz/agave/blob/v4.3.2/rpc/src/rpc.rs#L3893)
</Info>

This method does not alter the transaction in any way; it relays the transaction
created by clients to the node as-is.

If the node's rpc service receives the transaction, this method immediately
succeeds, without waiting for any confirmations. A successful response from this
method does not guarantee the transaction is processed or confirmed by the
cluster.

While the rpc service will reasonably retry to submit it, the transaction could
be rejected if transaction's `recent_blockhash` expires before it lands.

Use [`getSignatureStatuses`](/developers/docs/rpc/http/getsignaturestatuses) to ensure a
transaction is processed and confirmed.

Before submitting, the following preflight checks are performed:

1. The transaction signatures are verified
2. The transaction is simulated against the state at the preflight commitment.
   On failure an error will be returned. Preflight checks may be disabled if
   desired. It is recommended to specify the same commitment and preflight
   commitment to avoid confusing behavior.

When preflight simulation fails, the error data uses the same
[Simulation Results](/developers/docs/rpc/json-structures#simulation-results) structure
documented for [`simulateTransaction`](/developers/docs/rpc/http/simulatetransaction).

The returned signature is the first signature in the transaction, which is used
to identify the transaction
([transaction id](/developers/docs/references/terminology#transaction-id)). This identifier
can be easily extracted from the transaction data before submission.

The Kit, web3.js, and Rust examples sign a new transfer with a recent blockhash,
using the Solana CLI keypair at `~/.config/solana/id.json`. Fund it with devnet
SOL from the [Solana Faucet](https://faucet.solana.com) first. The cURL example
sends a signed transfer whose blockhash has expired: with `skipPreflight` the
node still returns its signature, but the cluster drops the transaction.

<RequestExample>
  ```bash cURL
  curl https://api.devnet.solana.com -s -X POST \
    -H "Content-Type: application/json" \
    -d '
    {
      "jsonrpc": "2.0",
      "id": 1,
      "method": "sendTransaction",
      "params": [
        "AX9ymHgILTd01GtdBsbQZ9by5D4z4UWh+1Tsh6LDuPHuZk/Z8LrIwoKZRp3le2RTb5lywL1xcJGQ8u3M3U0tyAgBAAEDXCL+JarHftfP5QgsRxpEsr+/YiRWQeCz7PI3jfzeppEvUc61u+TNHri9ChQdLN2evWGx+1O3MwbPFKV5rIqlxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAvOdVbvGn3R+uBkugNCq8C/Texc7ILBoYjbn4aVQV0OgBAgIAAQwCAAAAQEIPAAAAAAA=",
        {
          "encoding": "base64",
          "skipPreflight": true
        }
      ]
    }
  '
  ```

  ```ts Kit
  import { readFile } from "node:fs/promises";
  import { homedir } from "node:os";
  import {
    address,
    appendTransactionMessageInstruction,
    createKeyPairSignerFromBytes,
    createSolanaRpc,
    createTransactionMessage,
    getBase64EncodedWireTransaction,
    lamports,
    pipe,
    setTransactionMessageFeePayerSigner,
    setTransactionMessageLifetimeUsingBlockhash,
    signTransactionMessageWithSigners
  } from "@solana/kit";
  import { getTransferSolInstruction } from "@solana-program/system";

  const rpc_url = "https://api.devnet.solana.com";
  const rpc = createSolanaRpc(rpc_url);

  // The Solana CLI keypair, funded from https://faucet.solana.com
  const keypairFile = await readFile(`${homedir()}/.config/solana/id.json`, "utf8");
  const sender = await createKeyPairSignerFromBytes(
    new Uint8Array(JSON.parse(keypairFile))
  );

  const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();

  const transactionMessage = pipe(
    createTransactionMessage({ version: 0 }),
    (m) => setTransactionMessageFeePayerSigner(sender, m),
    (m) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, m),
    (m) =>
      appendTransactionMessageInstruction(
        getTransferSolInstruction({
          source: sender,
          destination: address("devFqxUpdo1sYETcWTXT12JE8V53MG2hRsXNMx2bYhA"),
          amount: lamports(1_000_000n)
        }),
        m
      )
  );

  const signedTransaction =
    await signTransactionMessageWithSigners(transactionMessage);
  const base64Tx = getBase64EncodedWireTransaction(signedTransaction);

  const signature = await rpc
    .sendTransaction(base64Tx, { encoding: "base64" })
    .send();

  console.log(signature);
  ```

  ```ts web3.js
  import { readFileSync } from "node:fs";
  import { homedir } from "node:os";
  import {
    Connection,
    Keypair,
    PublicKey,
    SystemProgram,
    TransactionMessage,
    VersionedTransaction,
    clusterApiUrl
  } from "@solana/web3.js";

  const connection = new Connection(clusterApiUrl("devnet"), "confirmed");

  // The Solana CLI keypair, funded from https://faucet.solana.com
  const keypairFile = readFileSync(`${homedir()}/.config/solana/id.json`, "utf8");
  const sender = await Keypair.fromSecretKey(
    Uint8Array.from(JSON.parse(keypairFile))
  );

  const { blockhash } = await connection.getLatestBlockhash();

  const message = new TransactionMessage({
    payerKey: sender.publicKey,
    recentBlockhash: blockhash,
    instructions: [
      SystemProgram.transfer({
        fromPubkey: sender.publicKey,
        toPubkey: new PublicKey("devFqxUpdo1sYETcWTXT12JE8V53MG2hRsXNMx2bYhA"),
        lamports: 1_000_000
      })
    ]
  }).compileToV0Message();

  let tx = new VersionedTransaction(message);
  await tx.sign([sender]);

  let sig = await connection.sendTransaction(tx);

  console.log(sig);
  ```

  ```rs Rust
  use anyhow::{anyhow, Result};
  use solana_client::{nonblocking::rpc_client::RpcClient, rpc_config::RpcSendTransactionConfig};
  use solana_commitment_config::{CommitmentConfig, CommitmentLevel};
  use solana_sdk::{
      pubkey,
      signature::{read_keypair_file, Signer},
      transaction::Transaction,
  };
  use solana_system_interface::instruction::transfer;
  use solana_transaction_status_client_types::UiTransactionEncoding;

  #[tokio::main]
  async fn main() -> Result<()> {
      let client = RpcClient::new_with_commitment(
          String::from("https://api.devnet.solana.com"),
          CommitmentConfig::confirmed(),
      );

      // The Solana CLI keypair, funded from https://faucet.solana.com
      let keypair_path = format!("{}/.config/solana/id.json", std::env::var("HOME")?);
      let sender = read_keypair_file(&keypair_path).map_err(|e| anyhow!("{e}"))?;
      let recipient = pubkey!("devFqxUpdo1sYETcWTXT12JE8V53MG2hRsXNMx2bYhA");

      let blockhash = client.get_latest_blockhash().await?;
      let tx = Transaction::new_signed_with_payer(
          &[transfer(&sender.pubkey(), &recipient, 1_000_000)],
          Some(&sender.pubkey()),
          &[&sender],
          blockhash,
      );

      let config = RpcSendTransactionConfig {
          preflight_commitment: Some(CommitmentLevel::Confirmed),
          encoding: Some(UiTransactionEncoding::Base64),
          ..Default::default()
      };

      let signature = client.send_transaction_with_config(&tx, config).await?;

      println!("Transaction Signature: {}", signature);

      Ok(())
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Response
  {
    "jsonrpc": "2.0",
    "result": "2id3YC2jK9G5Wo2phDx4gJVAew8DcY5NAojnVuao8rkxwPYPe8cSwE5GzhEgJA2y8fVjDEo6iR6ykBvDxrTQrtpb",
    "id": 1
  }
  ```
</ResponseExample>

## Parameters

<ParamField body="transaction" type="string" required>
  Fully-signed Transaction, as encoded string.
</ParamField>

<ParamField body="config" type="object">
  Configuration object containing the following fields:

  <Expandable title="properties" defaultOpen>
    <ParamField body="encoding" type="string" default="base58">
      Values: `binary`, `base58`, `base64`

      Encoding used for the transaction data.

      | Encoding | Notes                                                                          |
      | -------- | ------------------------------------------------------------------------------ |
      | `base64` | Recommended                                                                    |
      | `base58` | Slow                                                                           |
      | `binary` | ⚠️ Deprecated. Legacy alias for `base58`, retained for backwards compatibility |

      The default `base58` encoding is capped at 1,232 bytes and cannot carry a
      [v1 transaction](/developers/docs/core/transactions/versioned-transactions#v1-format)
      larger than that — use `base64` for transactions over 1,232 bytes.
    </ParamField>

    <ParamField body="skipPreflight" type="bool" default="false">
      Values: `true`, `false`

      When `true`, skip the preflight transaction checks. Default: `false`.

      ```json Example
      { "skipPreflight": true }
      ```
    </ParamField>

    <ParamField body="preflightCommitment" type="string" default="finalized">
      Values: `processed`, `confirmed`, `finalized`

      Commitment level to use for preflight when `skipPreflight` is `false`. Default
      `finalized`. When `skipPreflight` is `true`, this field is ignored and the RPC
      node uses `processed` internally.

      Solana RPC uses the following commitment levels:

      | Value       | Description                                                                                                                                                                               |
      | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
      | `processed` | Return data from the highest slot this node has processed. This is the newest view, but the block can still be skipped.                                                                   |
      | `confirmed` | Return data from the same slot as `finalized`. Kept for compatibility and planned for removal in a later release.                                                                         |
      | `finalized` | Return data from the highest slot with a finalization certificate, from votes by 80% of stake in one round or 60% of stake in each of two rounds. This is the strongest commitment level. |

      ```json Example
      { "preflightCommitment": "confirmed" }
      ```
    </ParamField>

    <ParamField body="maxRetries" type="usize">
      Maximum number of times for the RPC node to retry sending the transaction to the
      leader. If this parameter not provided, the RPC node will retry the transaction
      until it is finalized or until the blockhash expires.

      ```json Example
      { "maxRetries": 5 }
      ```
    </ParamField>

    <ParamField body="minContextSlot" type="number">
      Set the minimum slot at which to perform preflight transaction checks

      ```json Example
      { "minContextSlot": 341197000 }
      ```
    </ParamField>
  </Expandable>
</ParamField>

## Result

<ResponseField name="result" type="string">
  First Transaction Signature embedded in the transaction, as base-58 encoded
  string ([transaction id](/developers/docs/references/terminology#transaction-id))
</ResponseField>
