The Etherscan API is an excellent tool for dapp developers. However, because of its limited functionalities, many devs seek out Etherscan API alternatives to build more complex and scalable Web3 applications. If you recognize yourself here, follow along in today’s article! Moving forward, we introduce you to Moralis’ industry-leading Web3 API suite – the ultimate tool for building sites similar to Etherscan. With our premier APIs, you can seamlessly fetch block data, wallet transactions, token prices, and much mor! If you’re eager to get started, here are three prominent examples of endpoints you can use to build your own blockchain explorer:
getBlock()
– Get the contents of any block by a hash or block number:
const response = await Moralis.EvmApi.block.getBlock({ "chain": "0x1", "blockNumberOrHash": "15863321" });
getTokenPrice()
– Query the native and USD price of any token by address:
const response = await Moralis.EvmApi.token.getTokenPrice({ "chain": "0x1", "address": "0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0" });
getNativeBalance()
– Fetch the native balance of any wallet:
const response = await Moralis.EvmApi.balance.getNativeBalance({ "chain": "0x1", "address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e" });
If you want a more detailed breakdown of our endpoints and how you can use our tools to build sites similar to Etherscan, join us in this article as we take a deep dive into Moralis’ Web3 API suite!
Also, if you want to leverage these Web3 APIs yourself, don’t forget to sign up with Moralis. You can set up an account for free, and you’ll gain immediate access to all our blockchain development tools!
Overview
The Etherscan API is a powerful resource, offering the functionality to get block data, fetch a wallet’s native balance, query transactions, and much more, making it a solid choice for building decentralized applications (dapps). However, while the Etherscan API is a reliable option, there are numerous providers that not only offer similar functionalities but additional APIs as well. And, as you can imagine, using a broader API suite provides many benefits. But what is the best option among all Etherescan API alternatives? And how can you use tools like these to build sites similar to Etherescan? If you’re looking for the answers to these queries, join us in this article as we explore the best Etherscan API alternative!
We’ll kick things off by diving straight into the best Etherscan API alternative: Moralis. In doing so, we’ll explore three prominent APIs from Moralis’ API suite you can leverage to, for instance, build sites similar to Etherscan. Furthermore, after introducing Moralis’ API suite, we’ll show you how to use our interfaces in practice by covering a few prominent endpoints. As such, if you follow along in this article, you’ll learn how to fetch block data, token prices, wallet transactions, balances, and more with single lines of code!
Nevertheless, without further delay, let’s jump straight into the industry’s premier Etherscan API alternative: Moralis!
Introducing Moralis – The Ultimate API for Building Sites Similar to Etherscan
Moralis is an industry-leading Web3 API provider and the best Etherscan API alternative available. Our API suite comprises multiple enterprise-grade interfaces, making Web3 development as seamless and accessible as Web2. Consequently, when working with Moralis, it has never been easier to build everything from decentralized exchanges (DEXs) and Web3 wallets to sites similar to Etherscan!
So, why should you be using our Web3 development tools? To answer this question, let’s look at three prominent benefits of Moralis APIs:
- High Performance: Moralis offers the highest-performing APIs on the market. You can choose any metric, whether you want to judge by speed, reliability, data coverage, etc., our Web3 APIs always blow the competition out of the water.
- Scalability: Moralis’ Web3 APIs are built to scale, meaning you don’t have to worry about performance as your dapps see increased adoption.
- Cross-Chain Compatability: Moralis’ Web3 APIs are cross-chain compatible. This means you can leverage our tools to build dapps on all major blockchain networks, including Ethereum, Solana, Polygon, BNB Smart Chain (BSC), Arbitrum, and many others.
With an overview of Moralis’ Web3 API suite, let’s get more specific and look at three prominent interfaces: the Blockchain API, Wallet API, and Token API. And, without further ado, let’s kick things off by exploring the intricacies of the former!
Blockchain API: Access Blockchain Data and Build Sites Similar to Etherscan
Moralis’ Blockchain API is the ultimate tool for unlocking the power of raw and decoded blockchain data with precision and pace. With this industry-leading tool, you can effortlessly get block data, smart contract logs, events, transactions, and much more with only single lines of code. Consequently, when working with the Blockchain API, it has never been easier to build sites similar to Etherscan, real-time trading platforms, set up real-time alerts, etc.
Let’s look at some of the main benefits of the Blockchain API:
- Scalable: The Blockchain API is built to scale. When your dapps grow, so does the Blockchain API’s capacity to deliver. As such, when building with this interface, you never have to worry about the performance of your Web3 projects.
- Precise: Moralis’ Blockchain API delivers accurate and reliable data, which is paramount when building dependable dapps.
- Real-Time: Our Blockchain API thrives on speed, indexing data in real time, giving you and your Web3 projects immediate access to the most recent blockchain information.
- Organized: The Blockchain API provides detailed and digestible data, organizing blocks into transfers, logs, transactions, etc., giving you the best conditions for effectively navigating the space.
If you want to learn more about this tool, check out our Blockchain API tutorial!
Nevertheless, that covers an overview of our Blockchain API. Let’s now move on to the second interface: the Wallet API!
Wallet API: Build the Next Etherscan with Comprehensive Wallet Data
Moralis’ Wallet API is the industry’s premier tool if you’re looking to integrate wallet data and functionality into your Web3 projects. This tool boasts an array of features, unparalleled scalability, and exceptional flexibility. It also covers over 500 million addresses across multiple blockchain networks, including Ethereum, Polygon, Solana, BSC, and many others!
So, what exactly does the Wallet API do?
- Native Balances: Access historical and real-time native balances for any wallet address.
- ERC-20 Tokens: Get any wallet’s current or historical ERC-20 token balances.
- NFTs: Query all NFTs and collections held by a wallet, including metadata and optimized image previews.
- Transfers: Fetch real-time transfers, swaps, and purchases for any wallet.
- Address Labels: All transfer and transaction endpoints are fully enriched with public address labels, allowing you to seamlessly decode transactions.
- ERC-4337 Compatability: The Wallet API is fully ERC-4337 compatible, allowing you to seamlessly integrate account abstraction functionality into your dapps.
- And more!
That briefly covers the Wallet API; let’s now dive into the last interface for this article: the Token API!
Token API: Get Token Data for Building Sites Similar to Etherscan
The Moralis Token API is the ultimate tool for ERC-20 data, and it covers every single token across ten+ EVM chains and counting. As such, when working with the Token API, it has never been so easy to build sites similar to Etherscan, DEXs, portfolio trackers, or any other Web3 platform!
So, what are some of the Token API’s most prominent features?
- Token Prices: Get any token’s current and historical prices from popular automated market makers (AMMs) like PancakeSwap and Uniswap.
- Transfers: Access token transfers in real-time by wallet or contract. You can also fetch historical transfers for any token instantaneously.
- Balances: Fetch current or historical token balances of any wallet.
- Rich Metadata: Query up-to-date ERC-20 token metadata, including symbols, names, logos, and much more.
- Advanced Spam Detection: Experience enhanced security with advanced spam detection, flagging known scam tokens and suspicious activity.
- Cross-Chain Functionality: The Token API lets you fetch token data across all major EVM chains, including Ethereum, Polygon, BSC, Chiliz, Gnosis, and many others.
- And more!
That covers the three Etherscan API alternatives: Blockchain API, Wallet API, and Token API. However, this is just scratching the surface of Moralis’ Web3 API suite. There are numerous other industry-leading interfaces worth checking out, including the NFT API, Market Data API, etc. And if you’d like to explore them all, check out our Web3 API page!
How to Build Sites Similar to Etherescan with Moralis’ Web3 API Suite
Now that you have familiarized yourself with Moralis’ Web3 API suite, we’ll take this section to explore some prominent endpoints that can come in handy when building sites similar to Etherscan. Moreover, to do so, we need to start by identifying some key features of block explorers!
Etherscan lets you explore most aspects of the Ethereum blockchain, including block data, token prices, wallet transactions, balances, etc. However, let’s look at a couple of concrete examples below:
- Exploring Block Data: A central feature of Etherscan is that you can look up the contents of any block. To do so, click on one of the blocks on the Etherscan landing page:
Doing so displays a bunch of information, including the block’s timestamp, transactions, gas used, gas limit, and much more:
- Look Up Wallet Addresses: Another feature is that you can look up any address using Etherscan. To do so, simply input any address into the search field at the top:
Searching an address on Etherscan takes you to a page looking something like this where you 1) get an overview field showing the native balance, value in USD, and all tokens of the account and 2) can view all transactions, internal transactions, token transfers, NFT transfers, etc.:
All in all, blockchain explorer sites like Etherscan display block data, token prices, native balances, transactions, transfers, and more!
So, how can you get this information?
The easiest way to fetch and integrate data like this into your Web3 projects is to leverage Moralis’ various APIs. And we’ll show you exactly how this works in the following sections!
Get Block Data with the Blockchain API
With the Blockchain API, you can effortlessly get the contents of any block with a single call to the getBlock()
endpoint. All you have to do is specify two parameters: chain
and blockNumberOrHash
:
const response = await Moralis.EvmApi.block.getBlock({ "chain": "0x1", "blockNumberOrHash": "15863321" });
In return for calling the endpoint, you get a response containing the block’s timestamp, number hash, log blooms, transactions, gas used, gas limit, etc. Here’s an example of what the response might look like:
{ "timestamp": "2022-10-30T20:39:11.000Z", "number": "15863321", "hash": "0x4f5d3bb78f0311301ef282b281d23e178ced236a7ae465820fe6edeba609954a", "parent_hash": "0x27e61d430386d7b4a144bee6e120a57010fbdb3cf963ca37e2d20b5452203621", "nonce": "0x0000000000000000", "sha3_uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", "logs_bloom": "0x11e9182//...", "transactions_root": "0x1e0b205c9c48af7dfa3f277c8ec2ba403dc4ab63635a18bbfe532097527fb18e", "state_root": "0xcb1df24273693eb33869961233baac112adbdf51e980e5cf8b8aa7084e8063be", "receipts_root": "0x3a3d89417ad3898d47f66155e0e5fdf3e1efde2a6f389e7b051acf729db28617", "miner": "0x388C818CA8B9251b393131C08a736A67ccB19297", "difficulty": "0", "total_difficulty": "58750003716598352816469", "size": "117595", "extra_data": "0x", "gas_limit": "30000000", "gas_used": "19044124", //... }
Fetch Native Balances with the Wallet API
The Wallet API lets you fetch the native balance of any wallet with a single call to the getNativeBalance()
endpoint. You simply need to add two parameters: chain
and address
:
const response = await Moralis.EvmApi.balance.getNativeBalance({ "chain": "0x1", "address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e" });
Calling the getNativeBalance()
endpoint will give you a simple response showing the native balance of the wallet in question. This is what the response might look like:
{ "balance": "123322" }
Query Token Prices with the Token API
With the Token API, you can get the price of any token with a single call to the getTokenPrice()
endpoint. All you have to do is specify a chain
parameter and add a token’s address to address
:
const response = await Moralis.EvmApi.token.getTokenPrice({ "chain": "0x1", "address": "0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0" });
In return for calling the endpoint above, you’ll get a response with the price denominated in the chain’s native token and USD. This is what it can look like:
{ "tokenName": "Matic Token", "tokenSymbol": "MATIC", "tokenLogo": "https://cdn.moralis.io/eth/0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0.png", "tokenDecimals": "18", "nativePrice": { "value": "407101727793637", "decimals": 18, "name": "Ether", "symbol": "ETH", "address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" }, "usdPrice": 0.7680647947395282, "usdPriceFormatted": "0.768064794739528156", "exchangeName": "Uniswap v3", "exchangeAddress": "0x1F98431c8aD98523631AE4a59f267346ea31F984", "tokenAddress": "0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0" }
Get All Tokens of a Wallet with the Token API
The Token API also lets you get all tokens owned by a specific wallet. All you need to do is call the getWalletTokenBalances()
endpoint while passing along two parameters: chain
and address
:
const response = await Moralis.EvmApi.token.getWalletTokenBalances({ "chain": "0x1", "address": "0x1f9090aaE28b8a3dCeaDf281B0F12828e676c326" });
In return for calling the getWalletTokenBalances()
endpoint, you get an array of all tokens held by the wallet in question. Here’s an example of what it might look like:
[ { "token_address": "0x3c978fc9a42c80a127863d786d8883614b01b3cd", "symbol": "USDT", "name": "USDTOKEN", "logo": null, "thumbnail": null, "decimals": 18, "balance": "10000000000000000000000", "possible_spam": true }, //... ]
The Token API also features advanced spam detection, marking tokens as possible_spam
if they are potential scam coins. This is a neat feature, allowing you to seamlessly filter through the array and remove any suspicious coins so your end user doesn’t have to deal with them:
Query All Transactions of a Wallet with the Wallet API
With the Wallet API, you can seamlessly fetch all transactions of a wallet with a single call to the getWalletTransactions()
endpoint. All you have to do is pass along two parameters: chain
and address
:
const response = await Moralis.EvmApi.transaction.getWalletTransactions({ "chain": "0x1", "address": "0x1f9090aaE28b8a3dCeaDf281B0F12828e676c326" });
In return for calling the endpoint above, you get an array of all transactions of the specified wallet. Here’s an example of what the response might look like:
[ //... { "hash": "0x59034c908cc483eea265dfa359e9cca4d65534f6a27af68c04ae085636b49843", "nonce": "351249", "transaction_index": "167", "from_address": "0x1f9090aae28b8a3dceadf281b0f12828e676c326", "from_address_label": "rsync-builder", "to_address": "0x388c818ca8b9251b393131c08a736a67ccb19297", "to_address_label": "Lido: Execution Layer Rewards Vault", "value": "292138497314265085", "gas": "22111", "gas_price": "35862701891", "input": "0x", "receipt_cumulative_gas_used": "24862993", "receipt_gas_used": "22111", "receipt_contract_address": null, "receipt_root": null, "receipt_status": "1", "block_timestamp": "2023-11-08T12:56:35.000Z", "block_number": "18527378", "block_hash": "0xd0de438f288648120b7172c17108b70071810ee5a8fcbd24bee451c7e2a6dd19", "transfer_index": [ 18527378, 167 ] }, //... ]
Also, all transaction and transfer endpoints have address labels. With this feature, you can significantly improve the user experience of your dapps by effortlessly displaying human-readable labels rather than long, bothersome addresses involved in all transactions:
If you want to learn more about building sites similar to Etherscan with Moralis’ API suite and how to integrate this data into dapps, check out the YouTube video below. In this clip, one of our talented software engineers shows you how to build a basic Etherscan clone in less than 12 minutes:
What’s more, you can learn more about all of Moralis’ various endpoints by checking out the official Web3 API documentation page!
Summary: Best Etherescan API Alternative – Build Similar Sites to Etherscan with Moralis
Today’s article introduced you to Moralis – the ultimate Etherscan API alternative. With our industry-leading Web3 APIs, you can seamlessly build various dapps, including sites similar to Etherscan!
In Moralis’ Web3 API suite, you’ll find prominent interfaces such as the Blockchain API, Token API, Wallet API, NFT API, Market Data API, and many others. With the power of these tools, you can build projects faster and more efficiently, allowing you to save both time and development resources.
If you liked this Etherscan API alternatives article, consider checking out more content here on Moralis. For instance, explore our Base faucet guide or learn about Moralis’ Gnosis API.
Also, if you want access to Moralis’ API suite, don’t forget to create your Moralis account today. You can set up an account for free and immediately leverage the full power of blockchain technology!
Read More: moralis.io