Skip to content

Simple ERC20 dApp Wallet


TLDR; ERC20 Tokens are all the rage, but are they hard to add to your dApp? Not anymore!

How do I #Buidl an Ethereum Lite Wallet? — Tutorial Part 1
Starting to learn blockchain development? Let’s building a simple wallet that reads current account balance and…

If you haven’t already, check out last weeks Part 1! ❤️

Tutorial Part 2: Get ERC20 Balance & Transfers

We’re going to build updates to our wallet utilizing a few data sets:

  1. Token Balances — All tokens for an account
  2. Historical Token Balances — Previous token amounts held over time
  3. Token Transfers — Historical transactions for an account


View Current Token Balances

Step 1: Get Current Token Balances

Using Axios & Amberdata API it is easy to request an Ethereum address token balance. See the following snippet:

The response above returns current token holdings:
1. “address” — This is the contract address of the token.
2. “holder” —The address for the token holder
3. “amount” — The token amount the address owns. This is the balance amount the address owner can spend or HODL.

NOTE: You can also know if the token is an ERC20 or NFT based on the booleans for that token. If “isERC721” is true, then it is an NFT (non-fungible token) which could be utilizing digitally rare artwork like in or!

View Historical Token Balances

Step 2: Get Historical Token Balances

Most users want to see their balance over time. This is achieved using the historical holdings endpoint:

The response from the endpoint has a couple things to understand:
1. “metadata” — This contains developer context. In this example, “columns” returns the human readable naming for the keys/values in data array.
2. “data” — The array containing items where each item is a single day aggregation of the address token holdings.

You can use the data array to generate a chart like we did!
You could also use this data to understand the holdings for several addresses at once! Very helpful if you have a contract and want to understand historical usage of your contract.

Token Transfers for an Ethereum Address

Step 3: Get Token Transfers

Last important piece — token transfers allow users to understand the flow and balance change for their account. This is easily achieved in a similar request to address transactions, see this example:

The response has several important features:
1. “amount” — The token amount transferred either to or from this address
2. “decimals” — Represent the amount using decimals, to accurately annotate the balance.
3. “tokenAddress” — The token contract address, used with name & symbol you can easily represent the token in a human-readable fashion.

All Done!

Now you have a comprehensive wallet functionality you can add to your dApp or project! If you integrate, send us a link and we’ll showcase your integration!