Skip to main content

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:
  1. Using the React handler (handleSendTransaction) from @turnkey/react-wallet-kit This gives you:
    • modals
    • spinner + chain logo
    • success screen
    • explorer link
    • built-in polling
  2. Using low-level functions in @turnkey/core You manually call:
    • ethSendTransaction → submit
    • pollTransactionStatus → wait for inclusion
  3. 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.

Step 1 — Configure the Provider

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,
  },
});
  • 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.