See Securing a Wallet to learn how to protect your wallets.
What You’ll Learn
- How to install the CDP SDK
- How to create a Developer-Managed Wallet and view its default address
- How to fund your wallet with testnet ETH
- How to transfer funds between wallets
- How to trade assets in a wallet
Requirements
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:Installation
Clone CDP SDK quickstart template
The CDP SDK provides a quickstart template to get started with the SDK. Clone the repository and navigate to the quickstart template directory:index.js
contains the code to perform your first transfer with the CDP SDK. Let’s break down the content of this file.Creating a Wallet
The following instructions illustrate how to create a Developer-Managed (1-of-1) Wallet from scratch, using the CDP SDK.- Create a CDP Secret API key
- Initialize the CDP SDK by passing your downloaded API key file
- Create a new Developer-Managed (1-of-1) wallet
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:
index.js
index.js
index.js
index.js
In a production environment, we recommend turning on IP Whitelisting and using the 2-of-2 Coinbase-Managed Wallet for additional security.
Importing a Wallet
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.- Create a CDP Secret API key
- Initialize the CDP SDK by passing your downloaded API key file
- Create a new Developer-Managed (1-of-1) wallet using your BIP-39 mnemonic seed phrase
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:
index.js
index.js
index.js
index.js
In a production environment, we recommend turning on IP Whitelisting and using the 2-of-2 Coinbase-Managed Wallet for additional security.
Funding a Wallet
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.Transferring Funds
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.
Trading Assets
Onbase-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 See Trades for more information.
trade.js
for a complete example of trading assets.trade_assets.js
The Developer-Managed Wallets created in the above quickstart are not persisted.
We recommend Coinbase-Managed Wallets in production environments.