Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tkhq/sdk/llms.txt
Use this file to discover all available pages before exploring further.
@turnkey/solana provides a TurnkeySigner class compatible with @solana/web3.js. It supports signing legacy transactions, versioned transactions, and raw messages using Turnkey’s EdDSA signing infrastructure.
Installation
npm install @turnkey/solana
Usage
Create a Turnkey client
import { TurnkeyClient } from "@turnkey/http";
import { ApiKeyStamper } from "@turnkey/api-key-stamper";
const turnkeyClient = new TurnkeyClient(
{ baseUrl: "https://api.turnkey.com" },
new ApiKeyStamper({
apiPublicKey: "your-api-public-key",
apiPrivateKey: "your-api-private-key",
}),
);
Initialize TurnkeySigner
import { TurnkeySigner } from "@turnkey/solana";
const turnkeySigner = new TurnkeySigner({
organizationId: "your-organization-id",
client: turnkeyClient,
});
Sign a transaction
Pass a Transaction or VersionedTransaction from @solana/web3.js along with the Solana address to sign with.import {
Connection,
SystemProgram,
Transaction,
PublicKey,
clusterApiUrl,
} from "@solana/web3.js";
const connection = new Connection(clusterApiUrl("devnet"), "confirmed");
const fromAddress = "your-solana-address";
const { blockhash } = await connection.getLatestBlockhash();
const transaction = new Transaction().add(
SystemProgram.transfer({
fromPubkey: new PublicKey(fromAddress),
toPubkey: new PublicKey("recipient-address"),
lamports: 1_000_000, // 0.001 SOL
}),
);
transaction.recentBlockhash = blockhash;
transaction.feePayer = new PublicKey(fromAddress);
const signedTx = await turnkeySigner.signTransaction(transaction, fromAddress);
const txSignature = await connection.sendRawTransaction(signedTx.serialize());
console.log(`Transaction sent: ${txSignature}`);
TurnkeySigner constructor options
Your Turnkey organization ID (or sub-organization ID).
client
TurnkeyClient | TurnkeyBrowserClient | TurnkeyServerClient | TurnkeySDKClientBase
required
A Turnkey client instance.
Available methods
| Method | Description |
|---|
signTransaction(tx, fromAddress, organizationId?) | Signs a Transaction or VersionedTransaction and returns the signed transaction object. |
addSignature(tx, fromAddress, organizationId?) | Adds a Turnkey signature to an existing transaction in place. |
signAllTransactions(txs, fromAddress, organizationId?) | Signs an array of transactions in a single batch request. |
signMessage(message, fromAddress, organizationId?) | Signs a raw Uint8Array message. Returns the signature as a Uint8Array. |
Solana uses EdDSA (Ed25519). Unlike ECDSA, EdDSA does not support signing pre-hashed digests — Turnkey always signs the full message payload.
Examples
with-solana: create a new Solana address, then sign and broadcast a transaction on Solana devnet