Funding a wallet means transferring crypto to a wallet address. Having crypto in your wallet is key to many use cases such as using the wallet to make payments, transact onchain, or deploy smart contracts. There are several ways to fund an API Wallet:
Wallet Funding API (Alpha): With CDP SDK, you can fund your wallet from fiat currency in a bank account with a single API call. This method is currently limited to US-based individuals using US debit card (without 3DS verification) payment methods configured in a Coinbase account. We will add support for businesses, and for additional payment methods soon. This method currently supports funding wallets with USDC and ETH, with additional assets coming soon.
Send crypto from an external wallet: If you already have crypto in another wallet, you can fund your API Wallet by transferring crypto from the other wallet to your API Wallet.
Use Coinbase Product APIs: You can use Coinbase Product APIs (Retail / Exchange) to buy and transfer crypto to your API Wallet address.
For this method, you need a Coinbase account with a US debit card (non-3DS) payment method configured. CDP SDK provides methods to get a quote if desired, and call the Wallet Funding API to buy crypto and transfer it to the indicated API Wallet. If you have multiple debit cards set up, this method will use the first non-3DS, active, verified card you added. The sections below walk through how to use these SDK methods.
You can fund your wallet with assets that are supported in the Coinbase App for the applicable network. Not all assets are available to fund on every network; availability in the Wallet Funding API will mirror an asset’s availability in the Coinbase App.
For all of our supported EVM networks eth and usdc will be supported, and you can Trade those assets for your desired asset.
You may want to obtain estimates for the network fee and Coinbase fee (if applicable - save on fees with Coinbase One) associated with your wallet funding operation, before executing it. You can do this by calling the quoteFund method, as shown below. The quoteFund method returns a QuoteID and estimated network and Coinbase fees, as applicable.
Copy
Ask AI
// Obtain a quote for funding a wallet with 100 USDCconst myQuote = await wallet.quoteFund({ amount: 100, assetId: 'usdc' });// Parameters of the quote you can inspect to see if you want to execute it.// Crypto Amount requestedconsole.log(myQuote.getAmount().getAmount());// Crypto Amount converted to Fiat + Buy Feeconsole.log(myQuote.getFiatAmount());// Buy feeconsole.log(myQuote.getBuyFee().amount);// Transfer feeconsole.log(myQuote.getTransferFee().getAmount());
The wallet.fund() method will buy a specified amount of a given crypto asset using your Coinbase account, and transfer it to your API Wallet using the network you configured when creating your wallet. Fees, if applicable, will be charged in addition to the target amount.
If you have already generated a quote, you can simply execute it to initiate wallet funding:
Copy
Ask AI
// Execute the previously quoted wallet funding operationlet fundOperation = await myQuote.execute();// Wait for the funding operation to settleawait fundOperation.wait();
The operation shown above will execute the previously-quoted funding operation - in this example, buying 100 USDC, then transferring the 100 USDC to your API Wallet using the network associated with your API Wallet.
If you want to directly execute a wallet funding operation without first getting a quote, you may directly call the wallet.fund method specifying the amount and crypto asset.
Copy
Ask AI
// Initiate the funding operationconst fundOperation = await wallet.fund(100, 'usdc');// Wait for the funding operation to settleawait fundOperation.wait();
You can fund your API Wallet by receiving crypto from an external wallet. To do this, get the deposit address of the API Wallet by calling the getDefaultAddress API.
Copy
Ask AI
// Get the default_address in the wallet, which will be the deposit address.let address = await wallet.getDefaultAddress();console.log(`Deposit Address: ${address}`);
Once you have the deposit address, you can send crypto to the deposit address from an external wallet.
The first step in using Coinbase products to move funds to your API Wallet is to create a Coinbase account.
If you are an individual, you can use a personal Coinbase App account.
If you are a business, you can use Coinbase Exchange. The onboarding process will involve answering questions about yourself and your business. If you need assistance in business onboarding, reach out to us in the #wallet-api channel of the CDP Discord.