Address derivation

Turnkey supports Cosmos address derivation. The address formats we support follow the Cosmos SDK standard for bech32 addresses.

Transaction construction and signing

To construct and sign Cosmos transactions with Turnkey, we offer:

  • @turnkey/cosmjs: exports a TurnkeyDirectWallet that serves as a drop-in replacement for a CosmJS direct wallet. It includes support for signDirect.

See it in action in our example:

Example

Here’s a minimal example showing how to initialize a Turnkey signer for Cosmos and perform basic operations:

import { Turnkey } from "@turnkey/sdk-server";
import { TurnkeyDirectWallet } from "@turnkey/cosmjs";
import { toHex } from "@cosmjs/encoding";
import { SigningStargateClient } from "@cosmjs/stargate";

// Initialize the Turnkey client
const turnkeyClient = new Turnkey({
  apiBaseUrl: "https://api.turnkey.com",
  apiPrivateKey: process.env.API_PRIVATE_KEY,
  apiPublicKey: process.env.API_PUBLIC_KEY,
  defaultOrganizationId: process.env.ORGANIZATION_ID,
});

const signer = await initializeCosmosSigner(turnkeyClient);

// Connect to a Cosmos chain RPC endpoint
const rpcEndpoint = "https://rpc.celestia-arabica-11.com";
const client = await SigningStargateClient.connectWithSigner(
  rpcEndpoint,
  signer
);

// Get account balance
const balance = await client.getAllBalances(signer.address);

const recipient = "celestia1vsvx8n7f8dh5udesqqhgrjutyun7zqrgehdq2l";
const amount = coins(1000, "utia");
const fee = calculateFee(200000, GasPrice.fromString("0.01usei"));

const result = await client.sendTokens(
  signer.address,
  recipient,
  amount,
  fee,
  "Sent via Turnkey"
);

const result = await signingClient.sendTokens(
  signer.address,
  recipient,
  [{ denom: "utia", amount: transactionAmount }],
  {
    amount: [{ denom: "utia", amount: "20000" }],
    gas: "200000",
  },
  "Hello from Turnkey!"
);

Supported Cosmos Chains

Turnkey supports various Cosmos ecosystem chains for address derivation and signing, including but not limited to:

  • Cosmos Hub (ATOM)
  • Celestia
  • Osmosis
  • Injective
  • Juno
  • Stargaze
  • Akash
  • Secret Network

Key Features

  • Drop-in Replacement: TurnkeyDirectWallet works as a direct replacement for standard CosmJS signers
  • Chain Agnostic: Works with any Cosmos SDK-based chain by changing the prefix
  • Secure Signing: All private keys remain secure in Turnkey’s infrastructure
  • Policy Control: Apply custom signing policies to control transaction approvals

If you are using a Cosmos chain we do not explicitly support, feel free to contact us at hello@turnkey.com, on X, or on Slack.