Skip to main content
Turnkey provides institutional-grade key management for your applications. This guide shows you how to combine Turnkey’s secure signing with Biconomy’s MEE using the AbstractJS SDK for gasless, cross-chain transactions.

What We’re Building

By the end of this tutorial, you’ll have a backend service that can:
  1. Securely manage private keys with Turnkey
  2. Execute transactions without holding ETH for gas
  3. Perform operations across multiple chains
How it works: Turnkey stores and manages private keys in secure enclaves. When you need to sign a transaction, Turnkey signs it without ever exposing the private key. We then route the signed transaction through Biconomy’s MEE for gas abstraction.

Step 1: Install Dependencies

What these packages do:
  • @turnkey/sdk-server — Turnkey’s server SDK for key management
  • @turnkey/viem — Adapter to use Turnkey with viem
  • @biconomy/abstractjs — Biconomy’s SDK for smart accounts and MEE
  • viem — Ethereum library for building transactions

Step 2: Set Up Environment Variables

Create a .env file with your Turnkey credentials:
Never commit API keys to version control. Use environment variables or a secrets manager.

Step 3: Initialize Turnkey Client

Set up the Turnkey client that will handle all signing operations:

Step 4: Create a Wallet Client

Create a viem wallet client using the Turnkey account:
What’s happening here? The createAccount function creates an adapter that lets viem use Turnkey for signing. The actual private key never leaves Turnkey’s secure infrastructure.

Step 5: Sign EIP-7702 Authorization

Sign the authorization that upgrades the EOA to a smart account:
What is this authorization? It’s a signed message saying “I authorize my wallet address to execute code from this smart contract.” This enables smart account features while keeping the same address.

Step 6: Create the Smart Account

Create a Nexus account that works across multiple chains:

Step 7: Create the MEE Client

The MEE client handles transaction execution with gas abstraction:

Step 8: Execute a Gasless Transaction

Now execute a transaction with gas paid in any ERC-20:

Step 9: Wait for Confirmation


Complete Example

Here’s a full Node.js script:

Cross-Chain Execution

Execute on multiple chains with one signature:
The MEE infrastructure handles routing transactions to each chain and managing execution order.

Key Takeaways

  1. Turnkey manages keys securely — Private keys never leave Turnkey’s secure infrastructure
  2. EIP-7702 adds smart features — The wallet gets upgraded without deploying a new contract
  3. MEE handles gas — Pay with any ERC-20 token or sponsor gas entirely
  4. Cross-chain ready — Add chains to chainConfigurations and include them in instructions

Next Steps