Skip to main content

Overview

0x is a swap platform that allows users to swap various tokens on different chains. In this guide, we’ll walk through how to use Turnkey wallets to sign transactions that interact with 0x, adding an allowance with the Allowance Holder Contract and swapping ETH and USDC. We’ll demonstrate this using the with-0x example, which integrates Turnkey, Ethereum, and 0x for EVM swaps.

Getting started

Before you begin, make sure you’ve followed the Turnkey Quickstart guide.
You should have:
  • A Turnkey organization and Auth Proxy Config ID
  • Once you generate an account with the example, the account funded with ETH
You’ll also need your 0X API key (see the Breeze Developer Portal).

Install dependencies

Setting up the Turnkey wallet

We’ll use the @turnkey/react-wallet-kit package to authenticate and load a Turnkey wallet in the browser.

Setting up 0x

We’ll make calls to the 0x API to retrieve soft prices and firm quotes for the swap transaction. GetPrice is used for a price estimate, where GetQuote signifies to the opposite party that you are committing to the swap and they should reserve these funds.

Creating a Swap after receiving a quote

Setting Allowances

You will need to set an allowance to swap ERC-20 tokens that are not ETH. 0x uses an Allowance Holder Contract to achieve this. This code snippet shows how to check and set the allowance for an address for USDC.

Summary

✅ You’ve now learned how to:
  • Authenticate with Turnkey via @turnkey/react-wallet-kit
  • Set allowances on ERC-20 tokens
  • Interact with 0x to retrieve quotes and swap EVM tokens