Ethereum is the current leader of all programmable blockchains, and new projects want to follow suit, either as layer-2 (L2) solutions or built as new networks with EVM compatibility. Therefore, it is of utmost importance that Web3 developers seeking to create Ethereum-related projects utilize a proper Ethereum API that is not only easily accessible but can also support numerous networks. Thanks to the best EVM API from Moralis, developers can create not just next-gen dapps (decentralized applications) but also develop dapps that are cross-chain by default. If you’d like to know more about this API, read on as we explore the best Ethereum API in 2023!
However, before we dive deeper into this ultimate dapp development tool, we need to get you all up to speed. As such, we’ll first explain what Ethereum is. This is where you’ll also learn what ether and EVM are. We’ll also ensure you know what an Ethereum API is and what makes it so important and practical. Then, we’ll focus on exploring the best Ethereum API in 2023. This is where you’ll get acquainted with Moralis – the ultimate Web3 API provider. Nonetheless, you’ll also have a chance to explore how to get started using Moralis’ Ethereum API. Moreover, we’ll take a closer look at some popular EVM API endpoints and the power they bring to the table.
While this article primarily focuses on the theory behind one of the core tools for dapp development on Ethereum and other EVM-compatible chains, if you prefer to dive straight into building dapps, create your free Moralis account and tackle our Web3 tutorials in the Moralis docs.
What is Ethereum?
Ethereum was the first fully programmable blockchain, and it came to life in the summer of 2015. Furthermore, the Ethereum blockchain is a decentralized public ledger that verifies and records transactions on its network. Thanks to its programmability, Ethereum became more than a digital ledger – it became the leading decentralized network. In turn, Ethereum and the network’s EVM (Ethereum Virtual Machine) also added what Bitcoin couldn’t to the foundation of Web3. Moreover, it is worth mentioning that this decentralized network was conceived by Vitalik Buterin, Gavin Wood, Charles Hoskinson, Anthony Di Iorio, and Joseph Lubin.
Ethereum.org explains that Ethereum provides open access to digital money and data-friendly services. The latter is available for basically anyone with an internet connection, regardless of their geographical location. Ethereum is community-built technology and already “hosts” countless dapps.
Of course, the Ethereum network also allows users to send and receive crypto assets. The latter include Ethereum’s native coin, fungible tokens, and non-fungible tokens (NFTs). This applies to tokens that follow Ethereum’s ERC standards. Essentially, anyone with an active ETH address becomes their own bank for free. These addresses in users’ wallets also serve as the keys to access all sorts of dapps running on Ethereum. Moreover, smart contracts – on-chain software – are the foundation of dapps and cryptocurrencies on this decentralized network. These contracts can trigger specific, predefined actions when certain predefined conditions have been met. They also have the power to eliminate countless intermediary services.
Ethereum’s first mover advantage formed a large, worldwide community of devs and users who believe in a decentralized future. As long as Ethereum maintains this extensive community, it will remain a properly decentralized network and the base of Web3.
What is Ether?
Ether, or ETH, is the native cryptocurrency, also known as the native coin of Ethereum. Its main purpose is to support the network’s security. However, it is used mainly to pay for transaction fees on the Ethereum network (“gas”). In addition, just like BTC (Bitcoins’ native coin), ETH may also serve as a store of value or as a form of money to pay for goods and services from merchants that accept this payment method. Furthermore, anyone with an Ethereum address can easily receive and send ETH. After all, “ethereum.org” refers to ether as “currency for our digital future”. This website also explains ETH as digital, global money.
At first glance, ether may not have much to do with today’s topic. However, as you develop dapps, you’ll want to execute on-chain transactions (if nothing for testing), and at that point, you will need ETH. Moreover, as you will learn herein, one of the Ethereum API endpoints focuses on fetching this native currency balance.
What is EVM?
EVM is short for Ethereum Virtual Machine. This is a Turing-complete virtual machine that runs the Ethereum chain. In a big-picture overview, we look at EVM as the entire Ethereum blockchain ecosystem with all connected computers running Ethereum clients. In that perspective, EVM is an environment in which all Ethereum accounts and smart contracts exist. Additionally, this virtual machine defines all the rules required for valid states of the Ethereum chain.
Note: If this is your first time hearing about virtual machines, make sure to check out our article explaining the question “what is Ethereum Virtual Machine?” in more detail.
What is an Ethereum API?
If you want to understand what an Ethereum API is, you need to know what APIs are in the first place. Thus, it’s worth repeating that an application programming interface (API) facilitates communication between software. It does so by translating instructions for mutual understanding. Basically, APIs provide a reliable and consistent supply of functions and requests. As such, APIs ensure reliable programming in a safe and controlled development environment.
Furthermore, in the context of Ethereum and the decentralized web, a proper API ensures communication between blockchain nodes and backend scripts. So, as a developer, you get to utilize an Ethereum API to use existing snippets of code to fetch the data you want. This obviously makes Ethereum development significantly more accessible and time-efficient. Moreover, a proper Ethereum API eliminates the need to reinvent the wheel, and you can instead focus on the unique features of your dapp.
Exploring the Best Ethereum API in 2023
It’s no secret that Moralis offers the best Ethereum API and will continue to do so in 2023 and beyond. Of course, there are other Ethereum API providers; however, the scope, reliability, and speed cannot compare with Moralis’ EVM API. Furthermore, this ultimate Web3 API provider focuses on bridging the development gap between Web2 and Web3. It does so by incorporating cross-platform interoperability, enabling you to join the Web3 revolution with your legacy skills and tools. Hence, you can create dapps with any of your favorite programming languages.
Furthermore, Moralis is also cross-chain interoperable. Accordingly, it supports all leading blockchains and adds support for new reputable chains on an ongoing basis. In turn, you can deploy multi-chain dapps or easily switch between chains. What’s more, you can do so by simply tweaking a single line of code. Moreover, cross-chain interoperability future-proofs your work as you are never stuck to any particular chain. Ethereum may still be the king today; however, the blockchain industry is evolving fast, and who knows how things will evolve.
Moralis’ Web3 API Fleet
So, what does the best Ethereum API have in store for you? Here’s a list of Moralis products that focus on the Ethereum chain and the rest of the EVM-compatible gang:
- Web3 Auth API – Essentially, every dapp starts with Web3 authentication. The latter should be smooth to onboard users easily. It should also be compatible with OpenID, OAuth, DIDs, and other standards. Fortunately, the Moralis Web3 Auth API enables you to solve the Web3 authentication hassle.
- NFT API – Non-fungible tokens are among the most popular blockchain use cases. Thus, you want to be able to build all sorts of dapps around these unique crypto assets effortlessly. So, whether your goal entails building an NFT game, an NFT marketplace, an NFT tracker, or any other NFT dapp, Moralis’ NFT API is your go-to option.
- Token API – In case you want to focus on DeFi dapps, you’ll want to work with data regarding fungible tokens, such as ERC-20. In that case, the Token API will make a world of difference for your development. Make sure to learn more about the ultimate ERC20 token API from one of our past articles.
- Streams API – This fantastic tool lets you leave Web3.js and ethers.js JavaScript (JS) libraries in your rearview mirror. With the Streams API, you can easily listen to the blockchain and use on-chain events as all sorts of triggers for your dapps. Learn more about Moralis’ Streams API by checking out the “ethers.js vs Web3 streams” comparison.
Moralis’ Ethereum API Breakdown
For your convenience, the most popular API endpoints of the above-presented products are compiled under the same umbrella – the EVM API. As you can further explore in the EVM API documentation, there are multiple EVM API subgroups. These include:
- NFT API
- Token API
- Balance API
- Transaction API
- Events API
- Block API
- Resolve API
- DeFi API
- IPFS API
The above APIs and the endpoints they include provide you with many out-of-the-box functionalities. As such, you can fetch native, token, and NFT portfolio balances, NFT collections and metadata, token and NFT transfers, resolve ENS and Unstoppable Domain names, upload folders to the IPFS network, and much more.
So, whether you want to build an NFT marketplace, an NFT auction site, NFT-gated websites, portfolio tracker dapps, metaverse games, or DeFi dapps, the best Ethereum API is the ultimate tool!
How to Get Started Using Moralis’ Ethereum API
You must create your free Moralis account to start using the above-presented Ethereum API. You can do this by using the “free Moralis account” link in the introduction or by visiting the Moralis homepage and hitting the “Start for Free” button, as demonstrated in the image above. Once you create your account, you can access your Moralis admin area. There, you’ll be able to obtain your Web3 API key, use the neat UI to create new Streams, and more.
With your account up and running and your Web3 API key at your disposal, you are ready to take on our tutorial, which will teach you all you need to know to develop a dapp the easy way.
Prerequisites
Aside from creating your free Moralis account, you must also have some other tools ready to make the most out of Moralis’ Ethereum API. For one, you will want to install and set up a code editor or an IDE of your choice. However, it might be worth pointing out that since we prefer to use Visual Studio Code (VSC), our tutorials focus on that tool. You’ll also want to install the latest version of NodeJS and create a NodeJS dapp with the “npm init” command. You’ll usually also want to start with an Express server, and you’ll definitely need to initiate Moralis. Hence, the “npm install moralis express” command will come in handy.
Furthermore, as you proceed onto more advanced stuff, such as deploying smart contracts and testing your dapps, you’ll want to expand your toolbox. For one, you’ll definitely want to have a Web3 wallet, such as MetaMask, set up and ready to go. To learn about other useful Web3 development tools, make sure to check out our article exploring blockchain infrastructure.
Ethereum API Endpoints
As you can imagine, many Ethereum API endpoints exist between all previously-listed EVM API subgroups. Consequently, we won’t be going through all of them herein. That said, you can use the Moralis docs to do that on your own. However, to make your experience as smooth as possible, let’s look at two of the most popular Ethereum API endpoints – “getNativeBalance” and “getWalletTokenBalances“. The former belongs to the “balance” subgroup, and the latter to the “token” subgroup. The following are the snippets of code that you’ll need to implement to use these two endpoints with the NodeJS framework:
- Implementing “getNativeBalance”:
const response = await Moralis.EvmApi.balance.getNativeBalance({ address, chain, });
- Implementing “getWalletTokenBalances”:
const response = await Moralis.EvmApi.token.getWalletTokenBalances({ address, chain, });
In either case, the above-presented code snippets will become active once you initialize Moralis. Hence, you’ll want to have the following lines of code at the top of your JS script:
import Moralis from 'moralis'; import { EvmChain } from '@moralisweb3/evm-utils'; const address = 'Paste_address_here; const chain = EvmChain.ETHEREUM; await Moralis.start({ apiKey: 'YOUR_API_KEY', // ...and any other configuration });
In order to make no mistakes when implementing these lines of code, we recommend you try and get all ERC20 tokens owned by an address following our step-by-step tutorial.
The Best Ethereum API in 2023 – Ultimate Guide – Summary
In today’s article, you had a chance to go from a complete beginner to a developer who knows how to fetch native and token balances for any address. After all, we started our discussion with the basics, where we explained what Ethereum is. This is also where you discovered what ether and EVM are. We also provided you with a simple explanation of what an Ethereum API is. Then, we moved on to exploring the best Ethereum API in 2023, which you now know is brought to you by Moralis. Furthermore, you learned about Moralis’ Web3 API fleet and its EVM API subgroups. As we moved on, we explained how to get started using these powerful APIs. Last but not least, we looked closely at the “getNativeBalance” and “getWalletTokenBalances” endpoints.
As mentioned a couple of times throughout the article, the best way to master building dapps using Moralis’ Ethereum APIs is by taking on the tutorials inside the Moralis docs. However, you can also upgrade your crypto-knowledge database by visiting the Moralis YouTube channel and the Moralis blog. These outlets provide excellent topics. For example, some of the latest topics show you how to get NFT collections using Python and React, how to use Python for Ethereum development, and explores web3.storage.
On the other hand, you may also enroll in Moralis Academy and become blockchain certified. Countless courses are waiting for you there; however, it’s usually best to start with blockchain and Bitcoin fundamentals.
What is ERC-4337? Full EIP-4337 Guide