Quickstart
This guide will help you get started with@coinbase/cdp-wagmi
. You’ll learn how to install the package, set up the provider, and render your first component.
Installation
First, add the package to your project using your preferred package manager.Gather your CDP Project information
- Sign in or create an account on the CDP Portal
- On your dashboard, select a project from the dropdown at the at the top, and copy the Project ID
Allowlist your local app
- Navigate to the Embedded Wallet Configuration in CDP Portal, and click Add origin to include your local app
- Enter the origin of your locally running app - e.g.,
http://localhost:3000
- Click Add origin again to save your changes
Setup Provider
Next, you must configure your WagmiProvider with theCDPEmbeddedWalletConnector
.
CDPEmbeddedWalletConnector
provides the necessary context 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.
Sign in and connection
In order to connect the CDP Embedded Wallet, the end application user must first go through the 2 step sign in flow. As a result, the consumer has 3 options:- Use @coinbase/cdp-core’s
signInWithEmail
+verifyEmailOTP
- Use @coinbase/cdp-hooks’
useSignInWithEmail
+useVerifyEmailOTP
- Use @coinbase/cdp-react
<SignIn />
component
Call Wagmi Hooks
Now, your application should be able to successfully call Wagmi hooks. For example:Smart Accounts
This package has Smart Account support for the WagmiuseSendCalls
, useCallsStatus
and useCapabilities
hooks. It requires a different CDP Config than for EOA wallets:
Functions
createCDPEmbeddedWalletConnector()
Parameters
Parameter | Type | Description |
---|---|---|
parameters | { cdpConfig : Config ; providerConfig : CDPEmbeddedWalletConfig ; } | Configuration parameters for the connector |
parameters.cdpConfig | Config | - CDP core SDK configuration |
parameters.providerConfig | CDPEmbeddedWalletConfig | - Configuration for the EIP1193 provider |
Returns
CreateConnectorFn
<unknown
>
A wagmi-compatible connector that wraps the EIP1193 provider