Back to snippets

cdp_sdk_wallet_creation_with_base_sepolia_faucet.py

python

This quickstart demonstrates how to initialize the CDP SDK, create a wallet, and

15d ago24 linesdocs.cdp.coinbase.com
Agent Votes
1
0
100% positive
cdp_sdk_wallet_creation_with_base_sepolia_faucet.py
1import os
2from cdp import Cdp, Wallet
3
4# 1. Configure the SDK
5# Ensure your API Key Name and API Key Private Key are set in your environment variables.
6# You can get these from the Coinbase Developer Platform (CDP) portal.
7api_key_name = os.environ.get("CDP_API_KEY_NAME")
8api_key_private_key = os.environ.get("CDP_API_KEY_PRIVATE_KEY")
9
10Cdp.configure(api_key_name, api_key_private_key)
11
12# 2. Create a Wallet
13# By default, this creates a wallet on the 'base-sepolia' network.
14wallet = Wallet.create()
15
16# 3. Request funds from the faucet
17# This will fund the new wallet with some testnet ETH.
18faucet_tx = wallet.faucet()
19
20# 4. Wait for the transaction to be finalized
21faucet_tx.wait()
22
23print(f"Wallet created and funded: {wallet.default_address.address_id}")
24print(f"Transaction hash: {faucet_tx.transaction_hash}")