> For the complete documentation index, see [llms.txt](https://docs.shyft.to/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.shyft.to/solana-apis/transaction-relayer.md).

# Transaction Relayer

It first creates a custodial wallet which gets mapped to your Shyft API key. On creation, it returns the wallet address associated with you SHYFT API key. You have to use this wallet address as,`fee_payer` while constructing your transactions. Then, you can send the transactions that need to be signed on the relayer’s `sign endpoint`. Relayer will retrieve the credentials associated with your API key, sign the transaction and send it to the blockchain.

## Create Relayer

Create a new transaction relayer.

### <mark style="color:blue;">**POST**</mark> /sol/v1/txn\_relayer/create

#### Headers:

* `x-api-key`: Your API key

{% tabs %}
{% tab title="JS" %}
{% code overflow="wrap" %}

```javascript
var myHeaders = new Headers();
myHeaders.append("x-api-key", "<YOUR-API-KEY>");

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("https://api.shyft.to/sol/v1/txn_relayer/create", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

{% endcode %}
{% endtab %}

{% tab title="Response" %}

```json
{
    "success": true,
    "message": "A wallet bound with your API Key",
    "result": {
        "wallet": "GzMBRTvt5iyRsVizd5qKqJrKRJ4F2cyrdisRhUKEevTi"
    }
}
```

{% endtab %}
{% endtabs %}

## Sign Transaction

Sign and send a transaction using the relayer. Takes  `encoded_transaction` and `network` as input request parameters.

### <mark style="color:blue;">**POST**</mark> /sol/v1/txn\_relayer/sign

**Params:**

* `network`**`:`** Solana blockchain environment (testnet/devnet/mainnet-beta)
* `encoded_transaction:` Serialized transaction (base64 string).

{% tabs %}
{% tab title="JS" %}
{% code overflow="wrap" %}

```javascript
var myHeaders = new Headers();
myHeaders.append("x-api-key", "<YOUR-API-KEY>");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
  "network": "devnet",
  "encoded_transaction": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAED7ZA6LXrHCu2nMYL1uyosskVZS/5V3xX/aeLk2dgUQhnJNUkOyHbKRR9ttDUZUf+0UV49qJjw/Iaqn4vwoq/rpQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVPLSs0MqmtWZZIaLQKUkawi9RhixVRLZ4CWP96oToVkBAgIAAQwCAAAAgJaYAAAAAAA="
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://api.shyft.to/sol/v1/txn_relayer/sign", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

{% endcode %}
{% endtab %}

{% tab title="Response" %}

```json
{
    "success": true,
    "message": "Transaction executed successfully",
    "result": {
        "tx": "VSR2TqG5H6223hPMvvarEJTTWLWkGgoD3MxGcQsaUHJ8goSGj66KXC5D3CFRjgbU9A3wwS8B5kc6FnTk4RNZhuB"
    }
}
```

{% endtab %}
{% endtabs %}

## Sign Multiple Transactions

Sign and send multiple transactions using the relayer. Takes  `encoded_transactions` and `network` as input request parameters.

### <mark style="color:blue;">**POST**</mark> /sol/v1/txn\_relayer/sign\_many

**Params:**

* `network`**`:`** Solana blockchain environment (testnet/devnet/mainnet-beta)
* `encoded_transactions:` An array of serialized transactions (base64 string).
* commitment (optional): If the response is needed after a certain commitment level reaches all the transactions, pass the desired commitment level (allowed `processed`, `confirmed`, `finalized`).

{% hint style="info" %}
If the `commitment` level is specified, the response time may increase because the system will wait for all transactions to reach the requested `commitment` level before responding.
{% endhint %}

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

```javascript
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("x-api-key", "YOUR_API_KEY");

var raw = JSON.stringify({
  "network": "devnet",
  "encoded_transactions": [
    "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEDX26hu/mTZjDVkpJ2jU6FftnXFJGy5KcBJoXAaXHIMdpALAeVfwkorAqlrAeN8dOn8Jeu6H4u3ofHzGz4FntQPwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA0ihHHsVZsH9hW04rx4QZ+LTAoGxUuyawjkhtv3ao2aEBAgIAAQwCAAAAQEIPAAAAAAA=",
    "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEDX26hu/mTZjDVkpJ2jU6FftnXFJGy5KcBJoXAaXHIMdosLagmF5c4a6vJhMr74YTUznxniMs9+z4QYlMJ1x2b+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHubOmafFh4bvNPqY+AdQdzrv43WzBksnfAcdQd03Y40BAgIAAQwCAAAAgIQeAAAAA"
  ],
  "commitment": "finalized"
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://api.shyft.to/sol/v1/txn_relayer/sign_many", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

{% endtab %}

{% tab title="Response" %}

```json
{
    "success": true,
    "message": "Transactions executed successfully",
    "result": [
        {
            "id": 1,
            "signature": "5Njh861JEgiEhoSTUiVvR653MohGZrU8LfkmzkuYubCrfRggALyxe1hmVXbYZyAaPuoqeFNzrcZWtfpPpR2L6sT5",
            "status": "finalized"
        },
        {
            "id": 2,
            "error": {
                "code": -32002,
                "message": "Transaction simulation failed: Error processing Instruction 0: invalid instruction data",
                "data": {
                    "accounts": null,
                    "err": {
                        "InstructionError": [
                            0,
                            "InvalidInstructionData"
                        ]
                    },
                    "logs": [
                        "Program 11111111111111111111111111111111 invoke [1]",
                        "Program 11111111111111111111111111111111 failed: invalid instruction data"
                    ],
                    "returnData": null,
                    "unitsConsumed": 0
                }
            },
            "status": null
        }
    ]
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.shyft.to/solana-apis/transaction-relayer.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
