> ## 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.

# signTransaction

> Signs a transaction with the Kora fee payer if the transaction includes necessary payment to the fee payer without broadcasting it.

## JSON-RPC Request

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "signTransaction",
  "params": {
    "transaction": "base64EncodedTransaction"
  }
}
```

## Parameters

| Parameter     | Type    | Required | Description |
| ------------- | ------- | -------- | ----------- |
| `transaction` | string  | Yes      | Base64-encoded transaction, already signed by the user's signers |
| `signer_key`  | string  | No       | Public key of the Kora signer to use. It must be one of the node's signers. Defaults to the signer pool's selection strategy |
| `sig_verify`  | boolean | No       | Verify signatures during Kora's simulation. Defaults to `false`. With `true`, a transaction that still needs Kora's signature fails with `Transaction did not pass signature verification` |

Pass the same `signer_key` to related calls (for example
`estimateTransactionFee` and `signTransaction`) so one signer handles the whole
flow. See
[Specifying a Signer](/developers/docs/tools/kora/operators/signers#specifying-a-signer-client-side).

## JSON-RPC Response

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "signed_transaction": "base64EncodedTransaction",
    "signer_pubkey": "3Z1Ef7YaxK8oUMoi6exf7wYZjZKWJJsrzJXSt1c3qrDE"
  }
}
```

`signTransaction` doesn't broadcast the transaction, so it returns no
`signature` field. The transaction signature is the fee payer's signature
inside `signed_transaction`; decode it as shown below.

## cURL Example

```bash
curl -X POST http://localhost:8080 \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"signTransaction","params":{"transaction":"base64EncodedTransaction"}}'
```

## TypeScript SDK

```typescript
import {
  getBase64Encoder,
  getSignatureFromTransaction,
  getTransactionDecoder,
} from "@solana/kit";

const result = await client.signTransaction({
  transaction: "base64EncodedTransaction",
});
console.log("Signed tx:", result.signed_transaction);
console.log("Kora signer:", result.signer_pubkey);

// The transaction signature is the fee payer's (Kora's) signature
const signedTx = getTransactionDecoder().decode(
  getBase64Encoder().encode(result.signed_transaction),
);
console.log("Signature:", getSignatureFromTransaction(signedTx));
```

## Errors

Under the default margin pricing, the transaction must include a payment
instruction to the Kora payment address. Without it, the method returns a
`-32000` error:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32000,
    "message": "Invalid transaction: Insufficient token payment. Required 11055 lamports"
  }
}
```

Use [`estimateTransactionFee`](/developers/docs/tools/kora/json-rpc-api/estimate-transaction-fee)
or `getPaymentInstruction` to compute the required payment and append it before
calling `signTransaction`.
