Starting to learn blockchain development? Let’s building a simple wallet that reads current account balance and transactions.
Tutorial: Getting Account Balance & Transactions
We’re going to build a simple Ethereum wallet utilizing two data sets:
- Current Balance — The latest Ether amount for an account
- Address Transactions — Historical transactions for an account
What kind of super powers does this give me?
- Instantly view any address balance on Ethereum without a third party
- No need to run or sync a node or client
- Integrate into a dApp you are building without a fuss
Let’s get started in a few steps:
0. Get an Amberdata API key, to make calls to gas data endpoints
1. Call the first endpoint: Account Balance
2. Call the second endpoint: Transaction History
Step 0: Get a Free Amberdata API Key
Step 1: Get Account Balance
From the response above, there are a couple key data items:
1. “blockNumber” — This is the latest number of the blockchain, the block checkpoint that returned the address balance.
2. “timestamp” — Epoch timestamp using UTC, including Nanoseconds if the blockchain supports it. (In this example, Ethereum does not.)
3. “value” — The Ether amount the address owns. This is the balance amount the address owner spend or HODL.
Step 2: Get Transaction History
Using a similar request as account balance, let’s get the address transaction history:
Each transaction is returned in the “records” array. In the snippet above, the “value” key is the Ether amount transacted (sent or received). You could even use the value field to generate a chart!
Step 3: Testing & Fun
Here are some fun addresses to test, each containing very different return values! Can you guess which address is CryptoKitties?
Time to add an Ethereum wallet to your dApp or project! If you integrate, send us a link and we’ll showcase your integration!
This is just one of many ways to build using the Amberdata API. In the coming weeks we will be sharing more tutorials, stay tuned!