Skip to main content

Documentation Index

Fetch the complete documentation index at: https://turnkey-0e7c1f5b-graham-docs-revamp.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Prerequisites

This guide assumes you’ve completed the steps to create an account, organization, and API keypair as described in the account setup section. This guide uses the TypeScript server SDK (@turnkey/sdk-server). For other languages, see Server SDKs.

Installation

Install the server SDK and your preferred Ethereum library:
npm install @turnkey/sdk-server @turnkey/viem viem
This quickstart uses Ethereum, but Turnkey supports all EVM and SVM chains, along with Bitcoin, Tron, and more. To sign Solana transactions, derive a Solana address using ADDRESS_FORMAT_SOLANA with CURVE_ED25519 and use @turnkey/solana or the server SDK’s solSendTransaction method.

Sign your first transaction

1

Initialize the Turnkey client

Add your API credentials to a .env file:
TURNKEY_ORGANIZATION_ID=<your-organization-id>
TURNKEY_API_PRIVATE_KEY=<your-api-private-key>
TURNKEY_API_PUBLIC_KEY=<your-api-public-key>
Then initialize the client in your application:
import { Turnkey } from "@turnkey/sdk-server";

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

Create a wallet

Create a wallet and derive an Ethereum address in a single call:
const { walletId, addresses } = await turnkeyClient.apiClient().createWallet({
  walletName: "default",
  accounts: [
    {
      curve: "CURVE_SECP256K1",
      pathFormat: "PATH_FORMAT_BIP32",
      path: "m/44'/60'/0'/0/0",
      addressFormat: "ADDRESS_FORMAT_ETHEREUM",
    },
  ],
});

const ethereumAddress = addresses[0];
console.log("Ethereum address:", ethereumAddress);
3

Initialize a wallet signer

import { createAccount } from "@turnkey/viem";
import { createWalletClient, http } from "viem";
import { mainnet } from "viem/chains";

const turnkeyAccount = await createAccount({
  client: turnkeyClient.apiClient(),
  organizationId: process.env.TURNKEY_ORGANIZATION_ID!,
  signWith: ethereumAddress,
});

const walletClient = createWalletClient({
  account: turnkeyAccount,
  chain: mainnet,
  transport: http(),
});
4

Send a transaction

import { parseEther } from "viem";

const txHash = await walletClient.sendTransaction({
  to: "<destination address>",
  value: parseEther("<amount to send>"),
});
console.log("Transaction hash:", txHash);

Next steps