Documentation Index
Fetch the complete documentation index at: https://turnkey-0e7c1f5b-ethan-captcha-protection.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
SDK Overview
The SDK primarily abstracts three endpoints: eth_send_transaction, get_send_transaction_status, and get_gas_usage.
You can sign and broadcast transactions in two primary ways:
-
Using the React handler (
handleSendTransaction) from @turnkey/react-wallet-kit
This gives you:
- modals
- spinner + chain logo
- success screen
- explorer link
- built-in polling
-
Using low-level functions in
@turnkey/core
You manually call:
ethSendTransaction OR solSendTransaction → submit
pollTransactionStatus → wait for inclusion
-
Using server-side
@turnkey/sdk-server
This is the right choice for Node.js backends. It exposes the same methods via the server SDK client.
This page walks you through the React flow with full code examples. For using @turnkey/core directly, see Sending Sponsored Transactions.
Using handleSendTransaction (React)
This handler wraps everything: intent creation, signing, Turnkey submission, polling, modal UX, and final success UI.
import { TurnkeyProvider } from "@turnkey/react-wallet-kit";
const turnkeyConfig = {
apiBaseUrl: "https://api.turnkey.com",
defaultOrganizationId: process.env.NEXT_PUBLIC_TURNKEY_ORG_ID,
rpId: window.location.hostname,
iframeUrl: "https://auth.turnkey.com",
};
export default function App({ children }) {
return (
<TurnkeyProvider config={turnkeyConfig}>
{children}
</TurnkeyProvider>
);
}
Step 2 — Use handleSendTransaction inside your UI
const { handleSendTransaction, wallets } = useTurnkey();
const walletAccount = wallets[0].accounts[0];
await handleSendTransaction({
transaction: {
from: walletAccount.address,
to: "0xRecipient",
value: "1000000000000000",
data: "0x",
caip2: "eip155:8453",
sponsor: true,
},
});
OR (Solana):
const { handleSendTransaction, wallets } = useTurnkey();
const walletAccount = wallets
.flatMap((w) => w.accounts)
.find((a) => a.addressFormat === "ADDRESS_FORMAT_SOLANA");
if (!walletAccount) {
throw new Error("No Solana wallet account found");
}
await handleSendTransaction({
transaction: {
signWith: walletAccount.address, // Solana address
unsignedTransaction: "<base64-serialized-unsigned-solana-tx>",
caip2: "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1", // devnet
sponsor: true,
// recentBlockhash: "<recent blockhash>", // optional
},
});
- Full React handler implementation here
This automatically:
- opens Turnkey modal
- shows chain logo
- polls until INCLUDED
- displays success page + explorer link
Checking Gas Usage
You can configure gas limits for both sub-orgs and all orgs. We recommend checking sub-org gas usage against the limit on the client side so your application can handle edge cases when approaching or exceeding the gas limit.
You may also want to monitor your all org gas usage regularly to see if you are approaching your gas limit.
const resp = await httpClient?.getGasUsage({})
if (resp?.usageUsd! > resp?.windowLimitUsd!) { // you can also configure this to be a threshold
console.error("Gas usage limit exceeded for sponsored transactions");
return
}
For additional references leveraging these endpoints, check out our Swapping Example and Sweeping Example
EVM Paymaster Example
You may also leverage our own example for setting up EVM paymaster leveraging the above endpoints. This example shows how to send an erc-20 token on EVM networks using Turnkey’s paymaster (gas sponsorship).
Please refer to with-paymaster to see how to setup and manage paymaster for your transaction operations.