What you’ll learn
- How to install the v2 CDP SDK
- How to create an EVM account
- How to fund your account with testnet ETH
- How to create an EVM smart account
- How to transfer funds between accounts
- How to create and use a Solana account
Requirements
Make sure that your developer environment satisfies all of the requirements before proceeding through the quickstart.
The CDP SDK requires Node.js v18.x or higher. You can run the following command in your terminal to check your local Node.js version:
Installation
Environment Setup
Follow these instructions to set up your environment to use the v2 Wallet API. Make sure to set up your environment variables before running the code snippets.- Create a CDP Secret API key
- Generate a Wallet Secret
- Export these variables in your shell
Follow these steps to run the code snippets in this quickstart:
- Initialize a new project by running
- Add
"type": "module"
to yourpackage.json
file that was created in the previous step
- Install the CDP SDK
- Create a new file called
main.ts
- Copy and paste the example code you’d like to run into
main.ts
- Execute
main.ts
Create an EVM Account
The following code illustrate how to create an EVM account managed by the v2 Wallet API.main.ts
In a production environment, we recommend turning on IP Whitelisting.
Fund an EVM Account
Accounts do not have funds on them to start. We provide a Faucet API to fund your account with testnet ETH.main.ts
Create an EVM Smart Account
Smart accounts are smart contracts on EVM blockchains that offer advanced functionality such as gas sponsorships and spend permissions. Smart accounts require an owner account to sign on its behalf. In this example, we will use the previously created EVM account as the owner.main.ts
Transfer Funds
Now that your faucet transaction has successfully completed, you can send the funds in your original account to your smart account.Install Run the following code snippet
viem
to send transactions on EVMmain.ts
Use Solana Accounts
Solana accounts are similar to EVM accounts in that they are used to send and receive funds, except on the Solana blockchain. The code below demonstrates creating an account, requesting faucet funds, and sending a transaction.Install Run the following code snippet
@solana/web3.js
to send transactions on Solanamain.ts