# sendTransaction

The `sendTransaction` RPC method in **CoinVera** submits a **signed transaction** to the Solana network for processing. This is the primary method used to send payments, execute instructions, interact with smart contracts, and perform any on-chain action.

Once sent, the transaction is forwarded to the leader node for inclusion in a block. The method returns a **transaction signature** that can be used to monitor confirmation status.

***

#### ✅ Common Use Cases

* **SOL Transfers**\
  Sending SOL from one wallet to another.
* **SPL Token Transfers**\
  Sending tokens between token accounts.
* **Smart Contract Calls**\
  Invoking on-chain programs with custom instructions.
* **Batch or Multi-instruction Transactions**\
  Grouping multiple actions (e.g., transfer + memo) into one atomic transaction.
* **DeFi & DEX Integrations**\
  Submitting transactions to liquidity pools, AMMs, lending protocols, and other dApps.

***

#### 🧾 Request Parameters

```ts
[
  encodedTransaction: string,      // Required – base64-encoded signed transaction
  options?: {
    encoding?: string,             // Optional – "base58" or "base64" (default: "base64")
    preflightCommitment?: string,  // Optional – pre-submission simulation ("processed", "confirmed", "finalized")
    skipPreflight?: boolean,       // Optional – skip simulation step (default: false)
    maxRetries?: number,           // Optional – retry count on leader forwarding failure
    minContextSlot?: number        // Optional – minimum slot for node context
  }
]
```

**Key Fields:**

* **encodedTransaction** (required):\
  The fully signed transaction in **base64** format.
* **encoding**:\
  Format of the encoded transaction (default is `"base64"`).
* **skipPreflight**:\
  If `true`, skips preflight simulation. Use with caution.
* **preflightCommitment**:\
  The level of commitment to simulate the transaction before sending. Recommended: `"confirmed"`.
* **maxRetries**:\
  How many times to retry sending if the leader node doesn’t respond.

***

#### 📦 Response Structure

Returns a base-58 encoded transaction signature if accepted:

```json
{
  "result": "5nqPU3r5evAMY3Q6E3gZHmRMAsi67k1nRxkk2eJyxJKZPFnQvEvMG4oKXKDLfhVzevY5LfkuNqYz2T3uCkvVQUrh"
}
```

* Use this signature with `getSignatureStatuses`, `getTransaction`, or `confirmTransaction` to track the transaction.

***

#### 🧪 Example

**Send a Signed Transaction (Base64-encoded)**

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "sendTransaction",
  "params": [
    "Base64EncodedSignedTransactionHere",
    {
      "preflightCommitment": "confirmed",
      "skipPreflight": false
    }
  ]
}
```

***

**Code Examples**

{% tabs %}
{% tab title="Nodejs" %}

```javascript
const fetch = require('node-fetch');

async function sendTransaction(rpcUrl) {
  try {
    const response = await fetch(rpcUrl, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        jsonrpc: '2.0',
        id: 1,
        method: 'sendTransaction',
        "params": [

            "4hXTCkRzt9WyecNzV1XPgCDfGAZzQKNxLXgynz5QDuWWPSAZBZSHptvWRL3BjCvzUXRdKvHL2b7yGrRQcWyaqsaBCncVG7BFggS8w9snUts67BSh3EqKpXLUm5UMHfD7ZBe9GhARjbNQMLJ1QD3Spr6oMTBU6EhdB4RD8CP2xUxr2u3d6fos36PD98XS6oX8TQjLpsMwncs5DAMiD4nNnR8NBfyghGCWvCVifVwvA8B8TJxE1aiyiv2L429BCWfyzAme5sZW8rDb14NeCQHhZbtNqfXhcp2tAnaAT"
     
          ]
      }),
    });

    const data = await response.json();
    
    // Print the exact full response
    console.log('Full RPC Response:');
    console.log(JSON.stringify(data, null, 2));
    
    return data;
  } catch (error) {
    console.error('Error getting health:', error.message);
    return null;
  }
}

// Example usage
const RPC_URL = 'https://rpc.coinvera.io/?x-api-key=your-coinvera-x-api-key';

sendTransaction(RPC_URL);
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

def send_transaction(rpc_url):
    try:
        response = requests.post(
            rpc_url,
            headers={
                'Content-Type': 'application/json',
            },
            json={
                'jsonrpc': '2.0',
                'id': 1,
                'method': 'sendTransaction',
                'params': [
                    '4hXTCkRzt9WyecNzV1XPgCDfGAZzQKNxLXgynz5QDuWWPSAZBZSHptvWRL3BjCvzUXRdKvHL2b7yGrRQcWyaqsaBCncVG7BFggS8w9snUts67BSh3EqKpXLUm5UMHfD7ZBe9GhARjbNQMLJ1QD3Spr6oMTBU6EhdB4RD8CP2xUxr2u3d6fos36PD98XS6oX8TQjLpsMwncs5DAMiD4nNnR8NBfyghGCWvCVifVwvA8B8TJxE1aiyiv2L429BCWfyzAme5sZW8rDb14NeCQHhZbtNqfXhcp2tAnaAT'
                ]
            }
        )
        
        data = response.json()
        
        # Print the exact full response
        print('Full RPC Response:')
        print(json.dumps(data, indent=2))
        
        return data
        
    except Exception as error:
        print(f'Error getting health: {error}')
        return None

# Example usage
RPC_URL = 'https://rpc.coinvera.io/?x-api-key=your-coinvera-x-api-key'
send_transaction(RPC_URL)
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "jsonrpc": "2.0",
  "result": "2id3YC2jK9G5Wo2phDx4gJVAew8DcY5NAojnVuao8rkxwPYPe8cSwE5GzhEgJA2y8fVjDEo6iR6ykBvDxrTQrtpb",
  "id": 1
}
```

***

#### 💡 Developer Tips

* **Preflight Simulation**\
  Enabled by default, it helps catch errors early—e.g., insufficient funds, missing signatures, or compute budget overruns.
* **Set `maxRetries` for Resilience**\
  Helps handle leader-forwarding issues or temporary network disruptions.
* **Confirm Transaction**\
  Use `confirmTransaction`, `getSignatureStatuses`, or `getTransaction` to verify that the transaction was finalized on-chain.
* **Use `base64` Encoding**\
  Always encode the transaction as base64 unless your RPC explicitly supports base58.
* **Handle Versioned Transactions**\
  When working with versioned transactions (e.g., v0), ensure all required address lookup tables are properly included and resolved before sending.

***

The `sendTransaction` method is the gateway to executing real actions on Solana. Whether you're transferring SOL, interacting with DeFi protocols, or calling custom programs, this method—backed by **CoinVera**—ensures reliable and performant transaction submission.


---

# 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.coinvera.io/integration/solana/rpc/sendtransaction.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.
