1
Initialize the Server Client
Copy
Ask AI
import { Turnkey } from "@turnkey/sdk-server";
const turnkeyClient = new Turnkey({
apiBaseUrl: "https://api.turnkey.com",
defaultOrganizationId: process.env.TURNKEY_ORGANIZATION_ID,
apiPrivateKey: process.env.API_PRIVATE_KEY,
apiPublicKey: process.env.API_PUBLIC_KEY,
});
2
Initialize an Ethers Provider and Turnkey Signer
Copy
Ask AI
import { ethers } from "ethers";
import { TurnkeySigner } from "@turnkey/ethers";
const provider = new ethers.JsonRpcProvider(<provider api url>);
const turnkeySigner = new TurnkeySigner({
client: turnkeyClient.apiClient(),
organizationId: process.env.ORGANIZATION_ID!,
signWith: process.env.SIGN_WITH!,
});
3
Call `sendTransaction` with the Turnkey Signer
Copy
Ask AI
const transactionRequest = {
to: "<destination address>",
value: ethers.parseEther("<amount to send>"),
type: 2,
};
const sendTransaction =
await connectedSigner.sendTransaction(transactionRequest);