Uncategorized

Detailed Guide on Etherscan Ethereum Developers APIs

etherscan-logo-big

There are many ways you can get started with Ethereum. One way is to use the application programming interface(APIs )available online. There are many platforms that offer great APIs for developers to take advantage of their platform’s services.

One such platform is Etherscan. It is a Block Explorer, API, Search and Analytics Platform for Ethereum. 

Etherscan also defines itself as a decentralized smart contracts platform. They are popular for their easy-to-use block explorer, but if you are a developer, then their APIs is what you should be interested in.

That’s why we are going to go through the Etherscan Ethereum Developers APIs tutorial. In this tutorial, we will go through its useful APIs. This will help you understand their APIs and use them in your Ethereum dApp.

H3xadecimal, in this project, “How to build your own Ethereum Network,” also advocates the use of APIs whenever possible. It improves your dApp functionality without re-inventing the wheel.

Detailed Guide on Etherscan Ethereum Developers APIs

Before we get started with the small guide, let’s list the benefits of utilizing Etherscan Ethereum Developers APIs.

Etherscan Ethereum Developers APIs Features

1. Accessing blockchain data

By using the APIs, you can easily access Ethereum blockchain data including balance, internal or external transactions, events and so on.

2. Building dApps

The APIs let you build dApps on Ethereum. This is extremely useful for a developer. As a developer, you can use the APIs to include the basic functionalities in your app. 

3. Verifying contracts

You can verify contracts and help automate parts of your dApp.

4. Community-driven

The APIs is part of Etherscan’s community-driven effort. It doesn’t come with any warranty and that’s why as a developer, you should only use what you need. 

Creating your Free API-key Token

Before you can start using the API, you need to create your own Free API-Key Token. 

To do so, you need to go the register page and create a new account: https://etherscan.io/register

You also need to confirm your account before you can use it. 

Once you login into the account, you can find a tab on the left which reads as “API-KEYs.”

APIs

Click on it, and you can see that you can create a maximum of three Api-Key Token. Next, click on the “Create a new API-KEY token” option.

2

After you click on it, a popup window will open up asking you for AppName.

3

You are now ready to use your API-Key Token.

4

How to use Etherscan Ethereum Developers APIs

Account APIs

Getting Ether Balance

To get the Ether Balance you need to use the following API. You can click on the link below to see the reply from the network.

Single Address

https://api.etherscan.io/api?module=account&action=balance&address=0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a&tag=latest&apikey=YourApiKeyToken

The above API offers the following parameters for use.

Module = account

Action = balance

Address = the address you want to infer information from

Tag = latest, so that you get the latest balance

Key = Your APIKeyToken that you generated just a while ago.

Multiple Address

In similar fashion, you can utilize also utilize the account API to get Ether balance. The API at the time of writing, it supports 20 accounts in one single query.

https://api.etherscan.io/api?module=account&action=balancemulti&address=0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a,0x63a9975ba31b0b9626b34300f7f627147df1f526,0x198ef1ec325a96cc354c7266a038be8b5c558f67&tag=latest&apikey=YourApiKeyToken

Each address, needs to be separated by a single comma. 

Getting a list of normal transactions done by Address

If you need to know more about the Address transactions, then you also use the following API to get Normal transaction list.

http://api.etherscan.io/api?module=account&action=txlist&address=0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a&startblock=0&endblock=99999999&sort=asc&apikey=YourApiKeyToken

Getting Internal Transactions List

Similarly, you can also get access to internal transactional list from a single Ether address.

http://api.etherscan.io/api?module=account&action=txlistinternal&address=0x2c1ba59d6f58433fb1eaee7d20b26ed83bda51a3&startblock=0&endblock=2702578&sort=asc&apikey=YourApiKeyToken

In addition, you can also utilize optional parameters which is the startblock and the endblock.

It returns up to 10000 transactions only.

You can check more about the Accounts API here: https://etherscan.io/apis#accounts

Contracts API

If you work with contracts, then you can find the contracts API to be useful. Ethereum supports smart contracts. However, a smart contract contains different functions. As a dApp developer, you need to be sure which function to call. 

Contract ABI ensure that you can specify a function and invoke it. The use of contract ABI also means that data return is guaranteed. ABI stands for application binary interface. 

In technical terms, it acts as an interface between two program modules. Out of these two modules, one is at a machine code level. Through this interface, the data encoding/decoding is done. 

The simple API for getting Contract ABI.

https://api.etherscan.io/api?module=contract&action=getabi&address=0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413&apikey=YourApiKeyToken

To learn more about the Contracts API, check here: https://etherscan.io/apis#contracts

Transactions API

Transactions API can be used for following purposes.

  • Contract Execution Status
  • Transaction Receipt Status

For contract execution status, you need can use the following API

https://api.etherscan.io/api?module=transaction&action=getstatus&txhash=0x15f8e5ea1079d9a0bb04a4c58ae5fe7654b5b2b4463375ff7ffb490aa0032f3a&apikey=YourApiKeyToken

It can return 0 or 1 value of isError variable. The 0 stands for pass and 1 for error.

If you are looking to check transaction receipt, then you need to use the API as below.

https://api.etherscan.io/api?module=transaction&action=gettxreceiptstatus&txhash=0x513c1ba0bebf66436b5fed86ab668452b7805593c05073eb2d51d3a52f480a76&apikey=YourApiKeyToken

It returns 1 for pass and 0 for a loss.

Blocks API

The Etherescan Ethereum Developers API only offers on operation using their blocks API. It is as below.

https://api.etherscan.io/api?module=block&action=getblockreward&blockno=2165403&apikey=YourApiKeyToken

It is used to know Uncle Rewards and Block by BlockNo

Events API

Events API is an important part of the whole API package. It also acts as the native eth_getLogs.

You can read more about the Events API here: https://etherscan.io/apis#logs

More APIs

There are other types of APIs offered by the Etherscan Ethereum APIs. We recommend checking their official APIs list to know more about them.

Conclusion

This leads us to the end of the Etherscan Ethereum Developers APIs. So, what do you think about it? Comment below and let us know.

About author

LiveEdu.tv is a platform where you can take your skills to the next level by watching experts build real products from the fields of programming, game development, data analytics, design, augmented reality, virtual reality, cyber security, artificial intelligence, and cryptocurrencies. Students on LiveEdu use LEDU tokens to buy subscriptions to watch projects, download projects and ask experts questions.
Related posts
BusinessesFrontpage

Education Ecosystem Announces Second Giveaway!

BusinessesFrontpage

Education Ecosystem to Distribute $1 Million Grants to Developers

Uncategorized

Top 10 Projects on Education Ecosystem

Uncategorized

Education Ecosystem Announces Giveaways!