Creating a Wallet with Coinbase Cloud Node

November 29, 2022

By Gustavo Isturiz

At Coinbase Cloud we’re constantly striving and innovating to produce a robust suite of tools to allow developers like you to build great software. To that end, we’re really excited about the launch of Node which will allow you to build and monitor your Web3 applications from an easy-to-use platform with instant read/write access to blockchains and powerful data indexers to speed up responses.

In this post, we’re going to walk through how to create a Wallet application using Coinbase Cloud’s free version of Node.

We’ll go through: 

  • Creating a free Node project

  • Securing your credentials

  • Making a Sample Wallet

Step 1: Create a Free Node Project

First, we’ll head to coinbase.com/cloud to sign into our account (if you don’t have one, simply create a free account to sign in.) 

Next, once signed into the Coinbase Cloud platform, click on the upper right hand corner “Create new project” button.

This will navigate you to the setup part of your project, where you can choose your plan, Project Name, and network. Let’s go ahead and choose the “Free Plan” giving us access to up to 120,000 requests per day(an API request, or API call, allows one application to request data or services from another application.) I’ve named my project “Coinbase_Cloud_Demo,” but you can choose any name you’d like. Then, choose the Ethereum network you’d like to work on (either Mainnet or the Goerli Testnet.) Lastly, let’s go ahead and hit “Go to project” to spin up our free Node!

After your project setup is complete, a modal will greet you with your API access token in the form of a “Username” and “Password.” 

It is very important that you copy this information and store it somewhere safe as these will be the credentials to authorize your requests. If compromised, you’ll have to delete the project and begin a new one.

It's important to secure your credentials so they’re not stored in plain text within your repository. We’ll be using Python in this tutorial, so we’re going to use the library “python-dotenv” to allow us to reference the .env file when referencing our stored environment variables.

When working on projects, store them as environment variables (“.env” files for example) and include the environment file name in your “gitignore” file so that they aren’t pushed to your repository.

Alright, so our Node resource has spun up, we have our credentials and are ready to hit the endpoint to make calls and create our Wallet!

We’re going to be creating a (simple) wallet for our company moonWorx. Here’s the UI before our Coinbase Cloud Node API returns any information:

So let’s begin by querying our Advanced API to collect the token information linked to an Ethereum address.

The following is a Python code file called “get_balances.py” for making a call to our Advanced API to get to balance of Tether (USDT), USDC, and Polygon (MATIC):

We can now run the file and pass in an Address as the argument the code is expecting:

Here’s an example of the response we would receive:

As we can see in the payload, we have an array in “TokenBalances” which gives us the contract, amount (in hexadecimal), and the decimal places of each token.

This is what our moonWorx Wallet app looks like now:

With one API call to Coinbase Cloud’s Advanced API endpoint we were able to query for all the tokens on the Ethereum network for a given address: Tether (USDT), USDC, and Polygon (MATIC)!

Alright, now that our user can see their token balances, let’s go ahead and get them their transaction history too.

The following is a Python code file called “get_transactions_by_address.py” for making a call to our Advanced API to get Transactions by Address:

We can now run the file and pass in an Address, Block Start, and Block End as the arguments the code is expecting:

Here’s an example of the response we would receive:

As we can see, the payload has an array in “blocks” which contains information including:, Value, To Address, From Address, Block Timestamp (all of which we’ll use in our Wallet), but we also have Gas Price, Gas Used, and other useful information.

With the information contained in the payload about the blocks, our Wallet now looks like this:

With 2 API calls to our Coinbase Cloud API endpoint and the help of Advanced APIs, we were able to create a wallet which spans many tokens and fetches transactions by block segment!

I hope these examples show how you can quickly and easily get started with Coinbase Cloud’s Node product for free. As we constantly strive to innovate and make the barrier to entry easier for the Web3 community, we’re excited to see what developers will build!

For more information about creating your own Coinbase Cloud Node - https://www.coinbase.com/cloud

This document and the information contained herein is not a recommendation or endorsement of any digital asset, protocol, network, or project. However, Coinbase may have, or may in the future have, a significant financial interest in, and may receive compensation for services related to one or more of the digital assets, protocols, networks, entities, projects, and/or ventures discussed herein. The risk of loss in cryptocurrency, including staking, can be substantial and nothing herein is intended to be a guarantee against the possibility of loss.This document and the content contained herein are based on information which is believed to be reliable and has been obtained from sources believed to be reliable, but Coinbase makes no representation or warranty, express, or implied, as to the fairness, accuracy, adequacy, reasonableness, or completeness of such information, and, without limiting the foregoing or anything else in this disclaimer, all information provided herein is subject to modification by the underlying protocol network. Any use of Coinbase’s services may be contingent on completion of Coinbase’s onboarding process and is Coinbase’s sole discretion, including entrance into applicable legal documentation and will be, at all times, subject to and governed by Coinbase’s policies, including without limitation, its terms of service and privacy policy, as may be amended from time to time.