Quickstart
This guide will help you get started with@coinbase/cdp-core. You’ll learn how to install the package,
initialize the SDK, and make your first API call.
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
Initialize the SDK
Before calling any methods in the SDK, you must first initialize it:Analytics Opt-Out
By default the SDK will emit usage analytics to help us improve the SDK. If you would like to opt-out, you can do so by setting thedisableAnalytics configuration option to true.
Account Configuration
You can configure the SDK to create different types of accounts for new users: Smart Account Configuration:ethereum.createOnLogin is set to "smart", the SDK will:
- Create an EOA (Externally Owned Account) first
- Use that EOA as the owner to create a Smart Account
- Both accounts will be available on the user object
solana.createOnLogin is set to true, the SDK will:
- Create a Solana account for new users
- The Solana account will be available on the
solanaAccountsproperty
Sign In a User
You’re now ready to start calling the APIs provided by the package! The following code signs in an end user:Link Additional Authentication Methods
Once a user is authenticated, you can link additional authentication methods to their account. This allows users to sign in using multiple methods (email, SMS, OAuth providers) with the same embedded wallet.Link an Email Address
Link a Phone Number
Link a Google Account
Link an Apple Account
Link Any OAuth Provider
View User Information
Once the end user has signed in, you can display their information in your application:Send an EVM Transaction
We support signing and sending an EVM transaction in a single call on the following networks:- Base
- Base Sepolia
- Ethereum
- Ethereum Sepolia
- Avalanche
- Arbitrum
- Optimism
- Polygon
viem to broadcast the transaction.
Smart Account Operations
Smart Accounts provide advanced account abstraction features, including user operations and paymaster support.Create Spend Permissions
Spend permissions allow Smart Accounts to delegate spending authority to other accounts within specified limits and time periods. This enables use cases like subscription payments, automated DeFi strategies, and automatic topping up of AI agent funds.periodInDays for a more human-friendly API:
List Spend Permissions
Retrieve all spend permissions for a Smart Account:Revoke Spend Permissions
Revoke a spend permission for a Smart Account:Sign a Solana Transaction
When your application is configured withsolana: { createOnLogin: true }, you can sign Solana transactions:
Sign a Solana Message
You can also sign arbitrary messages with Solana accounts:Send a Solana Transaction
You can sign and send a Solana transaction in a single call on the following Solana networks:- Solana Mainnet
- Solana Devnet
Send User Operations
Send user operations from a Smart Account:Get User Operation Status
After sending a user operation, you can get its status and retrieve the result:Sign Messages and Typed Data
End users can sign EVM messages, hashes, and typed data to generate signatures for various onchain applications.Export Private Keys
End users can export their private keys from their embedded wallet, allowing them to import them into compatible wallets of their choice.Export EVM Private Key
Export Solana Private Key
When your application is configured withsolana: { createOnLogin: true }, you can export Solana private keys:
EIP-1193 Provider
The core package includes an EIP-1193 compatible provider. This provider can be used to sign and send transactions. The provider is created by callingcreateCDPEmbeddedWallet, which exposes a .provider attribute. createCDPEmbeddedWallet must be called with the desired chains to support as well as the transports for these chains.
The provider will initially connect to the first chain in the chains array. The transports are typically HTTP RPC endpoints, which are used internally for broadcasting non-Base transactions. For more information on transports, see Wagmi’s createConfig setup.
Viem Accounts
The core package includes atoViemAccount utility function that enables wrapping an embedded wallet into a Viem account compatible interface. This allows the account to act as a drop-in replacement for any library or framework that accepts Viem accounts.