Skip to main content

Introduction

In this tutorial, you’ll learn how to retrieve native token balances (like ETH, MATIC, or BNB) for any wallet address using the Moralis API. This works for both externally owned accounts (EOAs) and smart contract wallets like Safe or Argent. We’ll use the following Moralis API endpoint:

Prerequisites

Step 1: Set Up Your Project

Create a new directory for your project and initialize it:

Step 2: Create the Script

Create a file called index.js and add the following code:
Replace YOUR_API_KEY with your actual Moralis API key.

Step 3: Run the Script

Execute the script to fetch the native balance:

Example Response

Understanding the Response

To convert to a human-readable format, divide by 10^18:

Next Steps