Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tkhq/sdk/llms.txt
Use this file to discover all available pages before exploring further.
@turnkey/cosmjs provides TurnkeyDirectWallet, a drop-in replacement for CosmJS’s DirectSecp256k1Wallet. It conforms to the OfflineDirectSigner interface, so it works with any CosmJS SigningStargateClient or compatible client.
This package is experimental. Cosmos chain support is functional but the API may evolve.
Installation
Usage
Initialize TurnkeyDirectWallet
Use If
TurnkeyDirectWallet.init to create the wallet. Pass a Bech32 prefix to match the target chain.signWith is a UUID (private key ID), init fetches the public key from the Turnkey API. If it is a hex public key, compression is handled locally without a network call.TurnkeyDirectWallet.init options
config.client
TurnkeyClient | TurnkeyBrowserClient | TurnkeyServerClient | TurnkeySDKClientBase
required
A Turnkey client instance.
Your Turnkey organization ID (or sub-organization ID).
A wallet account public key (uncompressed hex) or a private key ID (UUID). If a UUID is provided, the public key is fetched from the Turnkey API.
The Bech32 address prefix for the target chain (e.g.,
"cosmos", "celestia", "osmo"). Defaults to "cosmos".Synchronous initialization
If you already have an uncompressed public key and want to avoid an async API call, useTurnkeyDirectWallet.initWithPublicKey:
Available methods
TurnkeyDirectWallet implements the OfflineDirectSigner interface:
| Method | Description |
|---|---|
getAccounts() | Returns an array with a single AccountData entry containing the address, algorithm (secp256k1), and public key. |
signDirect(address, signDoc) | Signs a Cosmos SignDoc using Turnkey and returns a DirectSignResponse. |
Supported chains
TurnkeyDirectWallet works with any Cosmos SDK chain that supports secp256k1 signing and the SIGN_MODE_DIRECT signing mode. Examples include:
- Cosmos Hub (
cosmos) - Celestia (
celestia) - Osmosis (
osmo) - Any chain with a custom Bech32 prefix
Examples
with-cosmjs: create a new Cosmos address, then sign and broadcast a transaction on Celestia testnet via CosmJS