The Ultimate EVM API – Full 2022 Guide

This page may contain legacy content

To get our most up-to-date content please access our documentation

Table of Contents

You probably know that Ethereum is the leading programmable chain. As such, it is the network that “hosts” most decentralized applications (dapps) and crypto tokens, including NFTs (non-fungible tokens). In addition, many other reputable blockchains also use the same computation engine, known as Ethereum Virtual Machine or EVM. As such, a quality EVM API makes a world of difference for Web3 developers. In fact, with Moralis’ ultimate EVM API on your side, you can easily create dapps with just basic programming skills. Hence, your JavaScript or Unity proficiency with some Web3 basics can help you become a blockchain developer. Making that possible is our way of helping devs bridging Web2 and Web3. However, before you can start utilizing the EVM API, it can be beneficial to understand what EVM is and how it works. So, this is what we will cover first in today’s article!

After ensuring that we all have a basic understanding of what EVM is and how it works, we will also look at API. This is where you’ll get to learn what an API is and why it’s so important for efficient Web3 programming. After all, given the current Web3 stack, Web3 APIs are one of the key elements that every dev should focus on. And, due to the above-mentioned reasons, an EVM API is the most important piece of the puzzle. After all, it also includes the NFT API, which can help you join the NFT revolution. In case you are not sure what an EVM API is, don’t worry, we will cover that as well. Furthermore, you will have a chance to learn about Moralis and how it can make your Web3 journey a whole lot simpler.  

A Beginner’s Guide to EVM

One of the most common definitions of the Ethereum Virtual Machine goes as follows: EVM is a Turing-complete virtual machine that enables code execution exactly as intended. As such, it is the runtime environment for every smart contract on Ethereum and other EVM-compatible chains.

Looking at the above definition, there are probably some parts that you do not fully understand. For instance, you may not know what a virtual machine is, let alone what a Turing-complete virtual machine is. Moreover, you might not be familiar with smart contracts either. Hence, we must look at these three concepts before we can focus on what an EVM API is.  

What are Virtual Machines?

A virtual machine (VM) is a machine that attempts a higher level of abstraction compared to the usual operating system (OS). We usually differentiate between operating systems like Windows or macOS and virtual machines, as VMs are created on top of the usual operating systems. As such, VMs are able to function much like physical computing machines. It’s thanks to virtual architecture that VMs are able to approximate the computing power of physical machines. Moreover, virtual machines are capable of running on many different types of operating systems and hardware. The latter makes them just the kind of engine a decentralized ecosystem needs.

Another upside of VMs is that one can utilize the resources of other network participants from anywhere in the world. Thus, network users are able to overcome the limitations of physical location or geography. Moreover, one can build, process, and execute all sorts of actions using these resources. It is this aspect that enables EVM to act like a global processor or computer. The latter simply lends its accumulated computing power to participating developers. As such, the developers get to use these resources to create smart contracts and dapps, which enriches the ecosystem. 

The participation Ethereum nodes enable developers to access the EVM from anywhere in the world. Furthermore, it is worth pointing out that lending computing power to the network is voluntary. However, there are several incentives that govern that. With the basic properties of VMs in mind, combined with the need to process all of the data through a voluntary network, the VM type of architecture makes the most sense for Ethereum.

Turing-Complete VMs

If you recall the EVM’s definition, you know that EVM is Turing-complete. As such, we must tell you what Turing-completeness is. This concept is based on ideas determined by computer scientist Alan Turing; hence the capitalization of the “Turing” part. Turing was the one to address what a thinking machine (a hypothetical computer) can do. Moreover, his ideas addressed the difference between the way computers and humans process thoughts. Furthermore, he argued that computers “think” according to a set of data processing rules to solve problems. Alan also talked about how this thinking machine would have to process a reel of tape. The latter has a line of symbols or functions and can be moved forward and backward. 

In addition, Turing’s paper explains that an “a-machine” (automatic machine) is capable of processing a symbol or altering it. Also, this sort of machine can only focus on one “state” at a time (the concept of “statefulness”). This hypothetical reel of tape corresponds to a computer’s memory. And, just like we can add to the length of the virtual reel of tape, we can add memory infinitely. With that in mind, the data applied to a set of instructions that a computer follows is only limited by physical constraints. Hence, Turing-complete VMs are the ones that follow the ideas set in place by Alan Turing.

Smart Contracts Basics

Smart contracts or Web3 contracts are essentially on-chain pieces of software or programs. In the case of EVM-compatible chains, they are written in Solidity programming language. Essentially, smart contracts ensure that dapps, transactions, and other off-chain and on-chain events run according to the rules. Hence, when predefined conditions are met, predefined actions take place. All things aside, every Ethereum smart contract is just a collection of code (functions) and data (state), which is stored at a specific address on the Ethereum chain. The latter is referred to as a smart contract address. 

Furthermore, Web3 contracts are a type of Ethereum account. Hence, they have a balance and can send transactions but they are not controlled by users. Once deployed to the network, they run as programmed. Moreover, user accounts interact with smart contract accounts – they submit transactions that trigger a specific function defined on the contract. Furthermore, interactions with Web3 contracts are irreversible. Also, the contracts cannot be deleted by default.       

Hopefully, now that you know what VMs, Turing-completeness, and smart contracts are, the EVM definition is a lot clearer. Thought, you can explore the “what is Ethereum Virtual Machine?” further on the Moralis’ blog. However, it’s time we shift our attention to the second piece of the “EVM API” puzzle.

What is an API?

An application programming interface or API is an interface that enables software to interact with other pieces of software. It supports that communication by enabling different sets of instruction to be translated or somehow transferred for mutual understanding. As such, APIs allow consistent coding in a stable environment. Hence, every request sent to replicable functions ensures a consistent and predictable response. Obviously, this makes programming a whole lot simpler. Essentially, APIs enable developers to avoid reinventing the wheel and use existing API sets in their applications. 

Moreover, APIs can focus on different spheres. For instance, we have a PC API, a web API, and so on. Here, it’s important to point out that web APIs enable interactions between disparate systems. Though, at their core, web APIs are also just sets of instructions, definitions, and protocols.  

What is an EVM API?

Given that we’ve covered what the EVM and an API are above, you now know that an EVM API is nothing but a set of instructions, definitions, and protocols that enable communication among pieces of software running based on the EVM. This includes communication among different smart contracts, as well as other pieces of code. As such, an EVM API makes working with the Ethereum Virtual Machine possible. Hence, it is a very important tool for devs interested in building Web3 projects on Ethereum or other EVM-compatible chains. 

So, whether you want to create Ethereum, BSC, Polygon, or Avalanche dapps, the ultimate EVM API makes a world of difference. It makes it easy for developers to solve any of their EVM needs. Moreover, since the Moralis’ EVM API is the best and easiest way for any dev to do all their EVM work, we ought to explore it a bit further. 

The Moralis EVM API

Unless you’ve been living under a rock, you know that Moralis is the ultimate Web3 development platform. It excels at e.g. Web3 authentication, Web3 syncs, and providing a comprehensive Web3 API. And, the Moralis’ EVM API is the core of the latter. Furthermore, the ultimate EVM API is neatly divided into various categories, including “native”, “account”, “token”, “resolve”, “defi”, “storage”, and “info”. Moreover, at moralis.io/evm-api/ you can also find a vast range of schemas.

To explore any of the EVM API categories, you just need to click the arrow on the right-hand side. This opens a list of endpoints:

To use any of the endpoints, you simply copy them and paste them into your code:

However, since most endpoints take in specific parameters, it’s smart to first learn more about the endpoint that you want to use. So, just click on the endpoint in question and you will see all the details that may interest you:

As such, you get to learn everything you need to know about the entering parameters. For that purpose, there are also examples. Furthermore, you also get to try the endpoint in question via the “Try it out” button. Then, you can also explore the responses. 

What Can You Do with the Ultimate EVM API?

Here’s the list of actions that the ultimate EVM API gets:

  • Block contents by block hash
  • The closest block of the provided date
  • Address logs
  • NFT transfers by block number or block hash
  • Transaction details by transaction hash
  • Events by topic
  • Native transactions
  • Token balances for a specific address
  • ERC20 token transactions
  • The NFTs owned by a given address
  • NFT transfers to and from a given address
  • The NFTs owned by a given address
  • NFT trades by marketplaces
  • The lowest price found for an NFT token contract
  • Token metadata
  • ERC20 transactions of a token contract
  • The amount which the spender is allowed to withdraw from the owner
  • Token price
  • The NFT data based on a metadata search
  • NFT transfers from a block number to a block number
  • The unique NFTs inside a given contract
  • NFT transfers of a given contract
  • The owners of the NFTs of a given contract
  • Native balance for a specific address
  • The global metadata for a given contract
  • Token metadata
  • The NFT with the given id of a given contract
  • Liquidity pair reserves for a Uniswap-v2-based exchange
  • The owners of NFTs for a given contract
  • A pair address based on token0 and token1 address

It also: 

  • Returns the wWeb3 API version
  • Uploads multiple files and place them in a folder directory
  • Returns the endpoint price list for rate limits and costs
  • Syncs a contract for the NFT index
  • Resolves an Unstoppable domain and returns the address
  • Returns the ENS domain when available (only for ETH)
  • Resyncs the metadata for a given token ID
  • Runs a function of a contract ABI

As you can see, there’s quite a lot you can do with Moralis’ EVM API. As such, make sure to put it to good use. 

The Ultimate EVM API – Full 2022 Guide – Summary

In today’s article, you learned what an EVM API is by putting the meaning of “EVM” and “API” together. Hence, you now know that an EVM API is a set of instructions, definitions, and protocols, which enable communication among smart contracts running based on the EVM. Furthermore, you also learned that the EVM is a Turing-complete virtual machine that enables code execution exactly as intended. As such, the EVM is also the runtime environment for every smart contract on Ethereum and other EVM-compatible chains. In addition, you had a chance to take a closer look at the Moralis’ EVM API and learned that it can help you do basically all that you can think of on Ethereum and other EVM-compatible chains. Thus, you are now ready to start building.

If you already have some of your cool dapp ideas in the pipeline, start building! If you don’t, then you might want to take on some of our example projects first. That way you will learn more about the ultimate EVM API by getting your hands dirty. On Moralis’ Web3 blog and Web3 YouTube channel, you can find a wide range of tutorials. As such, you can create all sorts of dapps, including some amazing Web3 clones of popular Web2 applications. Moreover, you can also dive into Web3 game design using the Moralis’ Unity Web3 SDK. Otherwise, learn from top NFT coders how to e.g. do NFT staking, NFT minting website development, or how to start generating NFTs in minutes!  Nonetheless, if you want to become blockchain certified, Moralis Academy is the place for you. Aside from top-tier crypto courses, this is also the place to get expert mentorship, a personalized study path, and irreplaceable peer support. 

July 25, 2022
Join the Moralis Community
Get the latest Moralis Web3 news and updates via email.
Search
Generic filters
MOralis launched
Streams API
Real-Time blockchain data delivered to your backend via webhooks. Used by the biggest dapps.
Real-Time blockchain data delivered to your backend via webhooks. Used by the biggest dapps.
Follow us on Twitter
Real-Time blockchain data delivered to your backend via webhooks. Used by the biggest dapps.
Related Articles