The CDP SDK allows you to create wallets and send funds onchain within minutes. In this quickstart, you will learn how to create a wallet, fund it with testnet ETH, transfer funds between wallets, and trade assets.
See Securing a Wallet to learn how to protect your wallets.
Make sure that your developer environment satisfies all of the requirements before proceeding through the quickstart.
Node.js 18+
The Coinbase server-side SDK requires Node.js version 18 or higher and npm version 9.7.2 or higher. To view your currently installed versions of Node.js, run the following from the command-line:
We recommend installing and managing Node.js and npm versions with nvm
.
See Installing and Updating in the nvm
README for instructions on how to install nvm
.
Once nvm
has been installed, you can install and use the latest versions of Node.js and npm by running the following commands:
The CDP SDK provides a quickstart template to get started with the SDK. Clone the repository and navigate to the quickstart template directory:
Install the dependencies:
The file index.js
contains the code to perform your first transfer with the CDP SDK. Let’s break down the content of this file.
The following instructions illustrate how to create a Developer-Managed (1-of-1) Wallet from scratch, using the CDP SDK.
This quickstart creates wallets on Base Sepolia testnet. You can create wallets across various EVM networks, including Base, Ethereum L1, and Polygon.
Initialize the SDK by passing your API key information:
Another way to initialize the SDK is by sourcing the API key from the JSON file that contains your secret API key, downloaded from the CDP portal:
Now create a wallet:
Wallets are initialized with a single default Address, accessible via getDefaultAddress:
In a production environment, we recommend turning on IP Whitelisting and using the 2-of-2 Coinbase-Managed Wallet for additional security.
The wallet created should be persisted to avoid losing access to it. Refer to Persisting a wallet section for more information.
The following instructions illustrate how to bring your own wallet into the CDP ecosystem, as a Developer-Managed (1-of-1) Wallet, using the CDP SDK.
This quickstart creates wallets on Base Sepolia testnet. You can create wallets across various EVM networks, including Base, Ethereum L1, and Polygon.
Initialize the SDK by passing your API key information:
Another way to initialize the SDK is by sourcing the API key from the JSON file that contains your secret API key, downloaded from the CDP portal:
Now import your wallet:
Wallets are initialized with a single default Address, accessible via getDefaultAddress:
In a production environment, we recommend turning on IP Whitelisting and using the 2-of-2 Coinbase-Managed Wallet for additional security.
Once initialized, your imported wallet should be stored as a Wallet data object, for easy re-instantiation. Refer to Persisting a wallet section for more information.
Wallets do not have funds on them to start. For Base Sepolia and Ethereum Sepolia testnets, we provide a faucet method to fund your wallet with testnet ETH.
Now that your faucet transaction has successfully completed, you can send the funds in your wallet to another wallet. The code below creates another wallet, and sends testnet ETH from the first wallet to the second:
Creating multiple transactions simultaneously can lead to failures.
All transfers, excluding gasless transfers, do not support concurrent transactions. We recommend running sequential calls and waiting for the previous transaction to confirm before continuing.
See Processing multiple transfers for same address as an example. If you need more assistance, reach out to us on Discord in #wallet-api.
See Transfers for more information.
You can create your wallet, fund it with testnet tokens and perform your first transfer by running the following command:
On base-mainnet
you can trade between different assets from your wallet. Since trading is only supported on mainnet wallets, wallet should be funded with real assets before trading. The code below creates a wallet and trades some ETH to USDC and then all of the USDC to WETH:
Refer to trade.js
for a complete example of trading assets.
See Trades for more information.
The Developer-Managed Wallets created in the above quickstart are not persisted. We recommend Coinbase-Managed Wallets in production environments.