Skip to main content

Overview

Wagmi is a TypeScript library for Ethereum development that provides a collection of React Hooks for interacting with Ethereum-compatible blockchains. It’s built on top of viem and offers a modern, developer-friendly API for building dapps. The @coinbase/cdp-wagmi package is a bridge that connects Coinbase’s CDP (Coinbase Developer Platform) Wallets to the wagmi ecosystem—bringing CDP-powered wallet functionality into React apps using wagmi hooks. You’ll learn how to install the package, set up the provider, and render your first component.
Check out the CDP Web SDK reference for comprehensive method signatures, types, and examples.

Prerequisites

  • Node.js 22+ installed
  • A node package manager installed (i.e., npm, pnpm, or yarn)
  • A free CDP Portal account
  • Basic familiarity with React and Wagmi

1. Install Wagmi and CDP packages

Add the required packages to your project using your preferred package manager.
If you plan on using CDP’s pre-built UI components, install @coinbase/cdp-react instead of @coinbase/cdp-core.

2. Get your CDP Project ID

  1. Sign in to your CDP Portal account
  2. Select a project from the dropdown menu in the top-left
  3. Click the gear icon to view project settings
  4. Copy the Project ID for use in the next step

3. Configure WagmiProvider

Configure your WagmiProvider with the CDPEmbeddedWalletConnector. CDPEmbeddedWalletConnector provides the necessary context for Wagmi to work correctly with the CDP Frontend SDK. The providerConfig must be provided and is responsible for configuring the EIP-1193 provider’s transports which are used to broadcast non-Base transactions.
main.tsx
If you’d like to use CDP’s pre-built UI components, install @coinbase/cdp-react and use the CDPReactProvider component instead of CDPHooksProvider.

4. Sign in the user

Before using Wagmi hooks, users need to be signed in using either CDP React components or hooks. When the user verifies their OTP and is signed in, they will automatically be connected with wagmi. You can use either approach: Option 1: Using React Components
Option 2: Using React Hooks
Once signed in, the user’s wallet is automatically available to wagmi.

5. Use Wagmi hooks

Your application can now call Wagmi hooks. Here’s an example component that demonstrates wagmi’s useSendTransaction hook:
WagmiTransaction.tsx
The main difference is using CDPEmbeddedWalletConnector instead of traditional wallet connectors. This connector:
  1. Handles CDP wallet creation and authentication
  2. Manages the secure connection to CDP’s infrastructure
  3. Provides seamless integration with CDP’s user wallet features
  4. Eliminates the need for browser extensions or external wallet apps

Using Tempo with wagmi

Tempo is a stablecoin payments blockchain that is fully compatible with the CDP wagmi connector. Because Tempo uses its own native account abstraction model, you must configure createOnLogin: "eoa" as ERC-4337 smart accounts are not supported on Tempo. Tempo transactions cannot be sent via useSendEvmTransaction because Tempo is not a CDP-managed network. Instead, sign the transaction with useSignEvmTransaction and broadcast it yourself using a viem public client configured for Tempo.
See the Tempo Integration guide for a step-by-step walkthrough and a full code example.