ethers.js to query the Ethereum blockchain, but you can use any JSON-RPC compatible library.
Prerequisites
- Node.js installed on your machine.
- A Moralis Node URL. If you haven’t created one yet, see Get Your API Key.
Step 1: Install Dependencies
Create a new project and install the required packages:Step 2: Set Up Environment Variables
Create a.env file in your project root and add your Moralis Node URL:
Step 3: Write the Code
Create a file calledindex.js:
- ethers.js
- curl
- Python
Step 4: Run the Script
Using Extended RPC Methods
Moralis provides extended RPC methods that offer richer data beyond standard JSON-RPC. These methods map to Moralis API endpoints:| Method | Description |
|---|---|
eth_getTransactions | Get native transactions by wallet address |
eth_getDecodedTransactions | Get decoded wallet history |
eth_getTokenBalances | Get ERC20 token balances by wallet |
eth_getTokenPrice | Get ERC20 token price |
eth_getTokenMetadata | Get ERC20 token metadata |
eth_getNFTBalances | Get NFTs by wallet address |
eth_getNFTCollections | Get NFT collections by wallet |
Extended RPC methods have higher compute unit costs than standard methods. See Pricing for details.
Next Steps
- Pricing — Understand compute unit costs for each RPC method.
- Batch Requests — Combine multiple requests into a single API call.
- Rate Limits — Learn about throughput limits per plan.

