There are many ways to read data from a transaction or a block in Ethereum. Etherscan is one block explorer and analytics platform for Ethereum. In this recipe, you will learn about the platform and how you can make use of it.
Using block explorer
How to do it...
- Go to https://etherscan.io/ to access the block explorer. You will see a dashboard that displays the network state:
- On the top left, you can see a card that displays the current Ethereum market share along with the exchange rate. You can also see a transaction history chart for the last 14 days.
- Search for a block number or select it from the recent blocks list to view the contents of the block. You can see details such as time, miner, hash, transactions, size, gas, and so on:
- By searching a transaction, you can view transaction details such as from address, to address, the value transferred, gas, and other details.
- Etherscan also offers a details page for both Externally Owned Addresses (EOA) and contract addresses. To see the balance, list of transactions, and even tokens owned by that address, navigate to the EOA details page.
- The contract page also shows the balance, transactions, and even a contract code if it is a verified contract. To interact with verified contracts through Etherscan, use this page.
- The platform also offers charts for analytics. Use the charts to get an idea about the currency, network, mining, blocks, transactions, and other general information.
- Click the MISC tab to use tools such as the mining calculator, bytecode converter, and transaction broadcaster.
- Etherscan also has a free to use API for reading data from Ethereum. Sign up to Etherscan to use the API and use the free API key that can be generated from the portal itself. Make sure that you are not making more than five requests per second. You will be blocked if this is exceeded.
- Signing up with Etherscan will allow you to watch specific addresses and create email alerts. You can even add a private note for each transaction.
There's more...
Eth-netstats is a visual interface for tracking an Ethereum network status. To access the public status page, go to https://ethstats.net/. Note that the portal does not represent the entire state of the Ethereum main net. This is because of the voluntary listing of nodes in the portal.
You can use netstats to visualize your private Ethereum network:
- Download the source code from the repository. Make sure to verify the license:
git clone https://github.com/cubedro/eth-netstats
- Install the dependencies:
sudo npm install -g grunt-cli
cd eth-netstats
npm install
- Build the project using grunt and use npm to run it:
grunt
npm start