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/viem provides a Turnkey-backed Custom Account compatible with viem’s WalletClient. It implements all signing APIs expected by viem, including support for legacy, EIP-2930, EIP-1559, EIP-4844, and EIP-7702 transaction types.
Installation
Usage
Create a Turnkey viem account
signWith is a private key ID (not an Ethereum address) and ethereumAddress is not provided, createAccount fetches the address from the Turnkey API automatically.createAccount options
A Turnkey client instance.
Your Turnkey organization ID (or sub-organization ID).
A wallet account address, private key address, or private key ID to sign with.
The Ethereum address to use for this account. Required if
signWith is a private key ID. If omitted, createAccount fetches it from the Turnkey API.Synchronous initialization
UsecreateAccountWithAddress when you already know the Ethereum address and want to avoid an async API call:
Supported transaction types
@turnkey/viem supports all viem transaction types:
| Type | Standard |
|---|---|
| Legacy | Pre-EIP-2930 |
| Type 1 | EIP-2930 (access lists) |
| Type 2 | EIP-1559 (fee market) |
| Type 3 | EIP-4844 (blob transactions) |
| Type 4 | EIP-7702 (set code) |
Error handling
@turnkey/viem exports viem-compatible error classes:
TurnkeyActivityError— thrown when a Turnkey activity returns an unexpected statusTurnkeyConsensusNeededError— thrown when a Turnkey activity requires policy consensus before proceeding
activityId and activityStatus for programmatic handling.
If you need a standard EIP-1193 provider interface (for use with MetaMask-compatible libraries or browser wallets), see
@turnkey/eip-1193-provider.Examples
with-viem: create, sign, and broadcast a transaction on Sepolia using various transaction types