July 3, 2022

How to Build on Web3 in Minutes

Table of Contents

Are you looking for the easiest and cheapest way to build on Web3? If this is the case, then you definitely want to check out Moralis – the industry’s leading Web3 API provider. With our top-tier Web3 APIs, you can effortlessly fetch and integrate on-chain data into your projects with only single lines of code. Also, as we enrich all API responses with metadata, transaction labels, market data, and more from multiple sources, we can provide the industry’s most comprehensive Web3 APIs!

To immediately highlight the accessibility and comprehensiveness of Moralis’ APIs, check out our token balances with prices endpoint below. With this single endpoint, you can seamlessly fetch a wallet’s token balances – along with metadata, prices, and much more – with just one call:

import fetch from 'node-fetch';

const options = {
 method: 'GET',
 headers: {
   accept: 'application/json',
   'X-API-Key': 'YOUR_API_KEY'
 },
};

fetch('https://deep-index.moralis.io/api/v2.2/wallets/0xcB1C1FdE09f811B294172696404e88E658659905/tokens?chain=eth', options)
 .then(response => response.json())
 .then(response => console.log(response))
 .catch(err => console.error(err));

Simply replace YOUR_API_KEY with your Moralis API key and configure the parameters to fit your query, and you’re ready to go. Here’s an example of what the response might look like:

{
   //...
  "result": [
    {
      "token_address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
      "symbol": "USDC",
      "name": "USD Coin",
      "logo": "https://cdn.moralis.io/eth/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.png",
      "thumbnail": "https://cdn.moralis.io/eth/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48_thumb.png",
      "decimals": 6,
      "balance": "4553447",
      "possible_spam": false,
      "verified_contract": true,
      "balance_formatted": "4.553447",
      "usd_price": 1.001818879776249,
      "usd_price_24hr_percent_change": 0.1818879776249283,
      "usd_price_24hr_usd_change": 0.0018221880998897314,
      "usd_value": 4.561729172660522,
      "usd_value_24hr_usd_change": 0.008297236936878599,
      "native_token": false,
      "portfolio_percentage": 100
    },
    //...
  ]
}

By enriching our API responses with all the necessary data, you need fewer endpoints to query the data you need, resulting in a more accessible developer experience. If you’d like to learn more about this and explore other endpoints, check out our official Moralis documentation or join us in this guide!

Also, if you want to build on Web3 yourself with our APIs, don’t forget to sign up with Moralis. You can create an account free of charge, and you’ll gain instant access to all our premier development tools! 

Want to Use the Industry's
Leading Web3 APIs?

Overview 

The blockchain development space is proliferating, making now a better time than ever to build on Web3. However, building Web3 projects is easier said than done, as you, from a conventional perspective, have been forced to deal with a lot of underlying complexities. Fortunately, there are now tools and platforms that can aid you in your development endeavors. That said, what is the the easiest and cheapest way to build in Web3? 

Graphic art design - Moralis logo on white background

In this article, we’ll introduce you to Moralis’ suite of Web3 APIs. With tools like the Token API, NFT API, and Wallet API, you can bypass many of the complexities associated with Web3 development. As such, it doesn’t matter if you’re looking to build a portfolio tracker, NFT marketplace, cryptocurrency wallet, or any other project; this read is for you. Let’s dive straight into it! 

Why Build on Web3? 

Web3 has been growing rapidly over the past decade, and we’re currently seeing a lot of new users entering the space. This makes Web3 an exciting industry to tackle, as there are a lot of opportunities for newcomers and startups to gain substantial market shares. Also, this means that now is a better time than ever to build on Web3! 

Graphic art image illustrating a city that is built on Web3 technology

However, while the space presents a lot of opportunities, the barriers to entry have been high for new devs trying to enter the market. In addition to proficiency in traditional programming languages such as JavaScript, HTML, and CSS, you’re also required to know how to communicate with a blockchain network, which is one of the most challenging tasks for developers entering the Web3 space. 

Communicating with a blockchain network like Ethereum requires an underlying blockchain infrastructure, which is both difficult and time-consuming to set up. Fortunately, you can now bypass the associated hurdles using an API provider to build on Web3. 

But what exactly are Web3 APIs?

A Web3 API (application programming interface) is a set of methods, protocols, and rules for interacting with a blockchain network. In essence, APIs are interfaces that allow you to seamlessly query and integrate blockchain data into your projects. As such, they take care of the underlying complexities of querying on-chain data, making it much easier for you to build on Web3. 

But which is the best Web3 API provider? And what is the easiest and cheapest way to build on Web3?

Exploring the Easiest and Cheapest Way to Build on Web3 

The easiest and cheapest way to build on Web3 is to leverage Moralis. Moralis is the industry’s leading Web3 API provider, and our development tools currently power blockchain and crypto projects for millions of users worldwide! 

Graphic art design banner - Build on Web3 Using Moralis

In Moralis’ suite of premier APIs, you’ll find multiple use-case-specific tools designed with the outcome in mind. Some prominent examples include the Token API, NFT API, and Wallet API. With these industry-leading interfaces, you can seamlessly fetch and integrate on-chain data into your dapps with only single lines of code. As such, when using Moralis, it’s possible to build everything from token explorers to cryptocurrency wallets with ease. 

So, what are the benefits of building on Web3 with Moralis? 

  • Comprehensive: Moralis enriches all API responses with address labels, market data, transaction decodings, metadata, and more from multiple sources. In doing so, we’re able to offer the industry’s most comprehensive Web3 APIs. 
  • Simplified and Cross-Chain: Request and response structures follow the same standards and patterns across all Moralis APIs, making it easy for you to fetch and integrate on-chain data into your projects. All our APIs are also chain agnostic, meaning you can seamlessly build cross-chain compatible dapps when working with Moralis. 
  • Trusted: Moralis is trusted by hundreds of thousands of developers and large enterprises, including MetaMask, Blockchain.com, Delta, Polygon, and Opera.
Highlighting 5 blockchain businesses that build on Web3 using Moralis: MetaMask, Blockchain.com, Delta, Polygon, and Opera Browser

To further highlight the benefits of Moralis, let’s see how our APIs stack up against the competition! 

Competitor Comparison – Why Build on Web3 With Moralis? 

To underscore the benefits of Moralis, we compared our industry-leading Web3 APIs to two prominent competitors: Alchemy and QuickNode. In doing so, we used each provider’s Web3 APIs to fetch the data needed to build a portfolio view of Vitalik Buterin’s ERC-20 tokens. This allows us to systematically compare the number of calls and the cost of fetching the same on-chain resources with each provider’s APIs. 

Here are the results of our test: 

Graph showing how fast you can fetch tokens and build on Web3 using Moralis vs Alchemy and QuickNode
Graph highlighting how Moralis offers the cheapest way to build in Web3. Showing actual costs and compares Moralis, Alchemy, and QuickNode

By quickly analyzing the charts above, we can immediately determine that Moralis stands out as a clear winner. With only 18 calls at a cost of $0.000882, we were able to fetch the balance, metadata, prices, and more of Vitalik’s ERC-20 tokens when using Moralis. In comparison, the same task demanded 4,760 calls at a total cost of $0.0163091 with QuickNode. And 4,963 calls at a total price of $0.0049189 with Alchemy. 

But why are the results so different? 

The secret lies in the richness of our API responses. Since Moralis’ API responses include metadata, market data, and more, you only need one single endpoint to fetch all the information for building a portfolio view of a wallet. 

When using Alchemy or QuickNode, however, you must first use one endpoint to fetch a wallet’s token balances. From there, you then need to query each individual token for metadata, resulting in thousands of extra calls. Lastly, you also need to use a third-party provider like CoinMarketCap or CoinGecko to fetch the prices for each token. 

So, by enriching our API responses with a lot of data, we’re able to provide you with a more compelling and straightforward developer experience. To learn more about this, check out our guide comparing the industry’s leading Web3 API providers!

Moralis’ Web3 API Suite – The Best and Cheapest Way to Build Web3 Applications

Now, with an overview of Moralis, let’s dive a bit deeper into our Web3 API suite. In doing so, we’ll cover the following three APIs: 

  • Token API
  • NFT API
  • Wallet API

If you’d like to explore all our top-tier interfaces, check out the official Web3 API page! 

Token API 

Moralis’ Token API is the industry’s most comprehensive API for token data. This tool supports every single token across ten+ EVM blockchains. This includes altcoins, meme coins like Shiba Inu, stablecoins like USDT, and everything in between! 

TokeN API Marketing Banner

With only single lines of code, you can seamlessly use the Token API to fetch and integrate token balances, transactions, metadata, and much more from any wallet. As such, when using the Token API, you can effortlessly build everything from portfolio trackers to token explorers without breaking a sweat. 

To showcase the power of the Token API, check out our token balances with prices endpoint in action:

import fetch from 'node-fetch';

const options = {
 method: 'GET',
 headers: {
   accept: 'application/json',
   'X-API-Key': 'YOUR_API_KEY'
 },
};

fetch('https://deep-index.moralis.io/api/v2.2/wallets/0xcB1C1FdE09f811B294172696404e88E658659905/tokens?chain=eth', options)
 .then(response => response.json())
 .then(response => console.log(response))
 .catch(err => console.error(err));

When calling the endpoint above, you get the token balances of the address in question along with metadata, prices, price changes over time, and much more. Check out an example of what the response looks like down below:

{
   //...
  "result": [
    {
      "token_address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
      "symbol": "USDC",
      "name": "USD Coin",
      "logo": "https://cdn.moralis.io/eth/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.png",
      "thumbnail": "https://cdn.moralis.io/eth/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48_thumb.png",
      "decimals": 6,
      "balance": "4553447",
      "possible_spam": false,
      "verified_contract": true,
      "balance_formatted": "4.553447",
      "usd_price": 1.001818879776249,
      "usd_price_24hr_percent_change": 0.1818879776249283,
      "usd_price_24hr_usd_change": 0.0018221880998897314,
      "usd_value": 4.561729172660522,
      "usd_value_24hr_usd_change": 0.008297236936878599,
      "native_token": false,
      "portfolio_percentage": 100
    },
    //...
  ]
}

NFT API 

The NFT API is the ultimate tool for NFT data. This interface supports more than three million NFT collections. This includes everything from established projects like Pudgy Penguins to tokens that dropped just seconds ago. What’s more, the NFT API is fully cross-chain compatible, allowing you to build NFT-based projects on Ethereum, Polygon, Solana, and many other networks! 

NFT API Marketing Banner

With the NFT API, you only need single lines of code to query NFT balances, metadata, on-chain price data, optimized image previews, and more. So, when working with Moralis, you can seamlessly build everything from NFT marketplaces to games with ease. 

To highlight the power of the Token API, check out the example below of how to call the getWalletNFTs() endpoint:

import Moralis from 'moralis';

try {
  await Moralis.start({
    apiKey: "YOUR_API_KEY"
  });

  const response = await Moralis.EvmApi.nft.getWalletNFTs({
    "chain": "0x1",
    "address": "0xff3879b8a363aed92a6eaba8f61f1a96a9ec3c1e"
  });

  console.log(response.raw);
} catch (e) {
  console.error(e);
}

Calling the endpoint above gives you a list of the wallet’s NFT balance. It will look something like this:

  "result": [
    {
      "amount": "1",
      "token_id": "5021",
      "token_address": "0xfff54e6fe44fd47c8814c4b1d62c924c54364ad3",
      "contract_type": "ERC721",
      "owner_of": "0xff3879b8a363aed92a6eaba8f61f1a96a9ec3c1e",
      "last_metadata_sync": null,
      "last_token_uri_sync": "2024-02-21T11:59:49.268Z",
      "metadata": null,
      "block_number": "14647390",
      "block_number_minted": "14647390",
      "name": "Youtopia",
      "symbol": "Youtopia",
      "token_hash": "d4719eaf84eabcf443065b0a463f5886",
      "token_uri": "http://api.youtopia-official.xyz/ipfs/5021",
      "minter_address": "0x13f11fd2c7c7be94674651386370d02b7aac9653",
      "verified_collection": false,
      "possible_spam": true,
      "collection_logo": "https://i.seadn.io/gae/e3uNxyaqT0FfnhcF9SuMqCZd3pdF36wgcnpRJ0VDjLOP71g_LwrFRgLweNNCMvsMqR5ZZ4dh5Wble12PBzvncmpLbtmdVdjr5zMy8w?w=500&auto=format",
      "collection_banner_image": "https://i.seadn.io/gae/n9j18OhplkvqP5SOtuYDwpUVkJSwF6WkIV6vZMWjcm0D5qCpbd12cAaVlfZS8-3gjxjYsnjL_tIlVIsjXz28KejPB3D19Jc_MZ9Z?w=500&auto=format"
    },
    //...
  ]

Wallet API 

Moralis’ Wallet API is the perfect tool for integrating wallet functionality into your projects. The Wallet API supports more than 300 million addresses across the biggest blockchains, including Ethereum, Polygon, Solana, and many others! 

Wallet API Marketing Banner

With single API calls, you can use this premier tool to seamlessly fetch wallet balances, transactions, transfers, profile data, and more. So, when using the Wallet API, you can seamlessly build cryptocurrency wallets, portfolio trackers, and everything in between. 

To highlight the accessibility of this tool, check out the getNativeBalance() endpoint in action: 

import Moralis from 'moralis';

try {
  await Moralis.start({
    apiKey: "YOUR_API_KEY"
  });

  const response = await Moralis.EvmApi.balance.getNativeBalance({
    "chain": "0x1",
    "address": "0xDC24316b9AE028F1497c275EB9192a3Ea0f67022"
  });

  console.log(response.raw);
} catch (e) {
  console.error(e);
}

In return for calling the getNativeBalance() endpoint, you’ll get a response displaying the native balance of the wallet in question. It should look something like this: 

{
  "balance": "44573382376487713986330"
}

Build on Web3 Tutorial: How to Query On-Chain Data with Moralis in 3 Steps 

Let’s now show you how to build on Web3 by walking you through a tutorial on how to fetch on-chain data using Moralis’ top-tier APIs. To do so, we’ll be using the getNativeBalance() endpoint as an example and demonstrate how to fetch the native balance of any wallet in three steps: 

  • Step 1: Get a Moralis API Key
  • Step 2: Write a Script Calling Moralis’ API
  • Step 3: Run the Code

However, even though we’ll be using getNativeBalance() as an example, note that you can follow the same steps to call any of Moralis’ endpoints! 

Prerequisites 

Before proceeding, you must deal with a couple of prerequisites. As such, start by installing and setting up the following: 

  • Node.js v14+
  • Npm/Yarn

Step 1: Get a Moralis API Key 

Sign up with Moralis by clicking on the button at the top right of Moralis’ homepage and follow the instructions: 

First step to build on Web3 - Sign up for free with Moralis - Showing sign up button on homepage

Next, go to the ”Settings” tab, scroll down to the ”API Keys” section, and copy your Moralis API key: 

Step 2 - Showing how to copy the Web3 API key

Please keep it for now, as you’ll need it in the next section! 

Step 2: Write a Script Calling Moralis’ API 

Start by setting up a folder in your IDE and run this command in a new terminal to initialize a new project: 

npm init

Next, keep the terminal open and install the Moralis SDK with the following command: 

npm install moralis @moralisweb3/common-evm-utils

You can then open your ”package.json” file and add ”type”: ”module” to the list: 

Opening the ”package.json” file and adding ”type”: ”module” to the code list

From here, create a new ”index.js” file and add the following code: 

import Moralis from 'moralis';

try {
  await Moralis.start({
    apiKey: "YOUR_API_KEY"
  });

  const response = await Moralis.EvmApi.balance.getNativeBalance({
    "chain": "0x1",
    "address": "0xDC24316b9AE028F1497c275EB9192a3Ea0f67022"
  });

  console.log(response.raw);
} catch (e) {
  console.error(e);
}

You then need to configure the code slightly. First, replace YOUR_API_KEY with the key you copied earlier. Next, you also have to configure the address and chain parameters to fit your query: 

Showing in the code base where to paste the API key to build and access Web3

Now that’s it; all that remains from here is running the script!

Step 3: Run the Code 

To execute the code, simply open a new terminal and run the following command in the project’s root folder: 

node index.js

In return, you’ll get a response that looks something like this: 

{
  "balance": "44573382376487713986330"
}

That’s it; getting on-chain data has never been easier! From here, you can now use Moralis to build your next project on Web3 quickly, cheaply, and without breaking a sweat!

What Can You Build on Web3 with Moralis? 

Now that you know how to query blockchain data, let’s explore what you can build on Web3 with Moralis! 

  • Portfolio Trackers: Portfolio trackers are websites and applications that give users an overview of all their digital assets, including fungible tokens and NFTs. Delta is an excellent example of a portfolio tracker that leverages Moralis’ Web3 APIs. They use the Why Did It Move API to not only tell users when the price of a token changes in value but also give them an explanation as to why the price action occurred. 
Portfolio Tracker UI Example Build
  • Token Analytics Platforms: Token analytics platforms are websites giving traders in-depth insights into the performance of cryptocurrencies. A prominent platform here that leverages our APIs is Moralis Money – the industry’s leading token explorer and blockchain data analytics tool. 
Moralis Money - Token Analytics Platform Example Built on Web3
  • Cryptocurrency Wallets: Cryptocurrency wallets are platforms that allow users to store and fully manage their digital assets. A great example of a platform leveraging Moralis Web3 APIs is MetaMask – the industry’s leading and most well-known cryptocurrency wallet provider. 
Want to use the same Web3 APIs as MetaMask?

Summary: Easiest and Cheapest Way to Build on Web3

The easiest and cheapest way to build on Web3 is to leverage Moralis. With our top-tier Web3 APIs, including the Token API, Wallet API, NFT API, etc., you can seamlessly fetch and integrate on-chain data into your projects. So, when using Moralis, you can build everything from portfolio trackers to token analytics platforms with ease! 

But what makes our Web3 APIs the best in the business? 

We make sure to enrich all our API responses with metadata, transaction decodings, market data, and much more from multiple sources. Consequently, when using Moralis, you need fewer endpoints and fewer API calls to get on-chain data compared to when using a provider like Alchemy. 

Through this strategy, we’re able to provide a more seamless developer experience, allowing you to build dapps smarter and more efficiently! 

If you liked this tutorial on how to build on Web3, check out some more content here on the blog. For instance, explore our new crypto portfolio tracker endpoint in more detail. Also, remember to sign up with Moralis. You can register an account free of charge, and you’ll gain instant access to our premier Web3 APIs! 

Market Data API
Build amazing trading and portfolio dapps with this Market Data API. Keep users engaged with up-to-date data!
Market Data API
Related Articles
November 27, 2022

Blockchain Infrastructure Companies – How to Choose the Right Provider

September 15, 2023

NFT Image API – How to Get Images from NFT Collections

November 7, 2023

Etherscan API Alternatives – Easiest Way to Build Similar Sites to Etherscan

December 26, 2023

ETH Gas Tracker – Full Ethereum Gas Tracker Guide

August 3, 2022

Full 2022 Guide to Different Types of DAOs

December 9, 2022

ERC 1155 NFTs – What is the ERC-1155 Standard?

October 23, 2023

Get Transactions – How to Fetch EVM Transactional History

October 4, 2023

Polygon Node Guide: How to Run a Polygon RPC Node

December 16, 2022

How to Call a Smart Contract Function from JavaScript