Skip to main content
Turnkey offers flexible infrastructure to create and manage wallets with built-in gas sponsorship. By combining Turnkey’s secure key infrastructure with native gas abstraction, developers can deliver gasless transaction experiences on Base without requiring users to hold ETH for fees.

Setting up gasless transactions on Base

Turnkey provides native gas sponsorship for Base (EIP-155:8453) and Base Sepolia (EIP-155:84532). Unlike traditional paymaster setups, Turnkey handles transaction construction, signing, gas estimation, and broadcast in a single API call. You toggle sponsorship with a single parameter.
To access gas sponsorship, ensure it is enabled within your Turnkey dashboard. Then use the corresponding chain ID in the caip2 parameter.

How it works

Turnkey’s ethSendTransaction endpoint handles the full transaction lifecycle:
  1. Transaction construction: You provide the minimal payload (recipient, value, calldata). Turnkey fills in nonce, gas estimates, and tip fees.
  2. Signing: The transaction is signed within Turnkey’s secure enclave using the sender’s private key.
  3. Broadcast and monitoring: Turnkey submits the signed transaction to Base and monitors it until inclusion or failure.
With sponsor: true, Turnkey covers the gas fees. Your users never need to hold ETH on Base.

Getting started

Set up your Turnkey organization and account by following the Quickstart guide. You should have:
  • A root user with a public/private API key pair within the Turnkey parent organization
  • An organization ID
  • A wallet with an Ethereum account created within this organization

Install dependencies

npm i @turnkey/sdk-server

Option 1: Using @turnkey/sdk-server

For backend services and Node.js applications.

Step 1: Create a client

import { Turnkey } from "@turnkey/sdk-server";

const client = new Turnkey({
  apiBaseUrl: "https://api.turnkey.com/",
  apiPrivateKey: process.env.TURNKEY_API_PRIVATE_KEY,
  apiPublicKey: process.env.TURNKEY_API_PUBLIC_KEY,
  defaultOrganizationId: process.env.TURNKEY_ORGANIZATION_ID,
}).apiClient();

Step 2: Submit a sponsored transaction

const sendTransactionStatusId = await client.ethSendTransaction({
  transaction: {
    from: walletAccount.address,
    to: "0xRecipient",
    caip2: "eip155:8453", // Base mainnet
    sponsor: true,
    value: "0",
    data: "0x",
    nonce: "0",
  },
});
Set sponsor: false (or omit the field) to send a standard EIP-1559 transaction where the sender pays gas.

Step 3: Poll for inclusion

const pollResult = await client.pollTransactionStatus({
  sendTransactionStatusId,
});

const txHash = pollResult?.eth?.txHash;
console.log("Transaction:", `https://basescan.org/tx/${txHash}`);

Transaction statuses

StatusDescription
INITIALIZEDTransaction constructed and signed, not yet broadcast
BROADCASTINGActively broadcasting to the network, awaiting inclusion
INCLUDEDTransaction included in a block
FAILEDTransaction could not be included and will not be retried

Option 2: Using @turnkey/react-wallet-kit

For React applications, handleSendTransaction provides a complete UI experience with modals, loading states, and explorer links.
npm i @turnkey/react-wallet-kit
import { useTurnkey } from "@turnkey/react-wallet-kit";

const { handleSendTransaction } = useTurnkey();

const txHash = await handleSendTransaction({
  to: "0xRecipient",
  value: "1000000000000000", // 0.001 ETH in wei
  caip2: "eip155:8453", // Base mainnet
  sponsor: true,
});
For the full React walkthrough, see Sending Sponsored Transactions (React).

Checking gas usage

You can configure gas limits at both the sub-org and organization level. Monitor usage to handle edge cases when approaching your limit:
const resp = await client.getGasUsage({});
if (resp?.usageUsd! > resp?.windowLimitUsd!) {
  console.error("Gas usage limit exceeded for sponsored transactions");
  return;
}

Smart contract interactions

Sponsored transactions support arbitrary EVM operations, not just simple sends. You can interact with smart contracts by passing calldata:
const sendTransactionStatusId = await client.ethSendTransaction({
  transaction: {
    from: walletAccount.address,
    to: "0xContractAddress",
    caip2: "eip155:8453",
    sponsor: true,
    value: "0",
    data: "0xa9059cbb...", // encoded contract call
    nonce: "0",
  },
});

Security

Turnkey’s gas sponsorship is designed to prevent replay attacks. Transaction construction happens inside secure enclaves, and as long as the request includes the relevant nonce, only one transaction can be created from it. The user’s authenticator signs requests and the enclave verifies signatures, so a malicious actor cannot modify or replay the request.

Resources