August 19, 2024

How to Get Decoded Wallet History Using an RPC Node

Table of Contents

Are you looking for the easiest way to get decoded wallet history using an RPC node? If so, you’ve come to the right place. In this tutorial, we’ll introduce Moralis’ Extended RPC Methods, allowing you to query enriched, human-readable data seamlessly using RPC-style requests. Eager to jump into the code? Check out our eth_getDecodedTransactions method in action:

import fetch from 'node-fetch';

const options = {
 method: 'POST',
 headers: {
   accept: 'application/json',
   'content-type': 'application/json'
 },
 body: JSON.stringify({
   "jsonrpc": "2.0",
   "id": 1,
   "method": "eth_getDecodedTransactions",
   "params": [
     {
       "address": "0xda74Ac6b69Ff4f1B6796cdDf61fBDd4A5f68525f",
     }
   ]
 })
};

fetch('YOUR_NODE_URL', options)
 .then(response => response.json())
 .then(response => console.log(response))
 .catch(err => console.error(err));

By calling the method above, you’ll receive the full history of the specified wallet, enriched with transaction summaries, category tags, addresses, and much more. Here’s an example of what it might look like:

{
  //...
    "result": [
      {
        "block_hash": "0x660274d577cd20b0b82c1bff5f3c5641ba6027544e005f9256d5add9c7447920",
        "block_number": "19868695",
        "block_timestamp": "2024-05-14T14:00:23.000Z",
        "from_address": "0xda74ac6b69ff4f1b6796cddf61fbdd4a5f68525f",
        "from_address_label": null,
        "from_address_entity": null,
        "from_address_entity_logo": null,
        "to_address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
        "to_address_label": "Tether USD (USDT)",
        "to_address_entity": null,
        "to_address_entity_logo": null,
        "gas": "55331",
        "gas_price": "13623172301",
        "hash": "0xc565260238f59fc3f35b74f3011375c7d637db9b075f77d342c30d19f946272e",
        "nonce": "14",
        "receipt_cumulative_gas_used": "13917979",
        "receipt_gas_used": "41309",
        "receipt_status": "1",
        "transaction_fee": "0.000562759624582009",
        "transaction_index": "75",
        "value": "0",
        "receipt_contract_address": null,
        "nft_transfers": [],
        "erc20_transfers": [
          {
            "token_name": "Tether USD",
            "token_symbol": "USDT",
            "token_logo": "https://logo.moralis.io/0x1_0xdac17f958d2ee523a2206206994597c13d831ec7_3282f332c2ac2948929f01fe7d921c51",
            "token_decimals": "6",
            "from_address": "0xda74ac6b69ff4f1b6796cddf61fbdd4a5f68525f",
            "from_address_entity": null,
            "from_address_entity_logo": null,
            "from_address_label": null,
            "to_address": "0x28c6c06298d514db089934071355e5743bf21d60",
            "to_address_label": "Binance 14",
            "to_address_entity": "Binance",
            "to_address_entity_logo": "https://entities-logos.s3.us-east-1.amazonaws.com/binance.png",
            "address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
            "log_index": 338,
            "value": "50000000000",
            "possible_spam": false,
            "verified_contract": true,
            "direction": "send",
            "value_formatted": "50000"
          }
        ],
        "method_label": "transfer",
        "native_transfers": [],
        "summary": "Sent 50,000 USDT to Binance 14",
        "possible_spam": false,
        "category": "token send"
      },
      //...
    }
  ]
}

That’s it! With our Extended RPC Methods, you only need a single request to get decoded wallet history using an RPC node. For a more in-depth tutorial, join us in this guide or check out the Extended RPC Methods documentation page.

Want to get decoded wallet history using an RPC node yourself? Sign up for free with Moralis and gain immediate access to all our top-tier development tools!

Overview

If you’re building a crypto wallet, portfolio tracker, tax platform, or other Web3 projects, you might need an easy way to retrieve your users’ wallet history. Fetching this information using standard RPC methods can be challenging, requiring many requests and extensive manual data aggregation. Fortunately, Moralis’ Extended RPC Methods can streamline this process!

Moralis' Extended RPC Methods.

With our Extended RPC Methods, you get to experience the next generation of RPC nodes. Fetch the full history of any wallet, enriched with transaction summaries, category tags, address labels, and much more – all with a single request. Want to learn more about how this works? Follow along in this tutorial as we lay it all out for you. Let’s dive straight in! 

What is the History of a Crypto Wallet? 

A crypto wallet’s history encompasses its previous interactions across blockchain networks such as Ethereum, Optimism, Base, and BNB Smart Chain (BSC). This history includes native transactions, ERC-20 transfers, contract interactions, NFT trades, deposits, airdrops, and more. In essence, this data provides a comprehensive timeline of a wallet’s past activity.

Wallet History timeline with RPC nodes.

The history of a cryptocurrency wallet is essential when building a wide range of decentralized applications (dapps). Here are three key examples:

  • Cryptocurrency Wallets: Wallets typically display users’ transaction history, giving them insight into their past trading activities for increased retention and engagement.
  • Portfolio Tracker: Portfolio trackers need access to users’ wallet history to accurately track the performance of their assets.
  • Tax Platforms: Tax platforms need a clear timeline of a wallet’s past activity to understand when tokens were bought, sold, and traded to generate accurate tax reports.

So, how can you get wallet history using an RPC node? Well, this is where RPC methods enter the equation!

What are RPC Methods?

RPC is short for “Remote Procedure Call,” and it refers to communication protocols that allow one software system to call and request services from other software on a different device. In the Web3 space, RPC protocols enable dapps to interact with blockchain networks like Ethereum, Polygon, and Optimism.

Text: "What are RPC Methods?"

There are several standardized RPC protocols. A great example is JSON-RPC, which features a set of predefined RPC methods streamlining blockchain interactions, including both reading and writing on-chain data. Here’s a list of common RPC methods:

  • eth_getTransactionByHash: Returns info about a transaction by hash.
  • eth_getBalance: Returns the balance of an account.
  • eth_getBlockNumber: Returns the most recent block number.
  • eth_getChainId: Returns the chain ID.
  • eth_gasPrice: Returns the current gas price.

All in all, RPC methods streamline interactions with blockchains, making it easier for developers to build dapps and other Web3 projects.

Limitations of Standard RPC Methods

While RPC methods make it easier to read and write blockchain data, they have some significant limitations you should consider. For instance, you can’t use standard RPC methods to seamlessly get a wallet’s full history. To get this information, you need to make many requests, stitch together data, and decode the information yourself.

As you can imagine, this takes both a lot of time and resources, which can be better spent on other aspects of Web3 development. However, there is a better solution: Moralis’ Extended RPC Methods.

But what exactly are our Extended RPC Methods? And how do they benefit you as a developer?

For the answers to these questions, join us in the next section. Let’s go!

How to Get Decoded Wallet History Using an RPC Node – Introducing Moralis’ Extended RPC Methods

Moralis’ Extended RPC Methods streamline the process of fetching decoded, human-readable data using RPC nodes. With single requests, you can seamlessly fetch any wallet’s full history, ERC-20 token balances, NFTs, and much more, making dapp development significantly more accessible.

Moralis logo.

What can you get with our Extended RPC Methods:

  • eth_getDecodedTransactions: Get any wallet’s full transaction history.
  • eth_getTransactions: Fetch the native transactions of a wallet.
  • eth_getTokenBalances: Query the ERC-20 balances of any wallet.
  • eth_getTokenMetadata: Get the metadata of a token by address.
  • eth_getTokenPrice: Fetch any token’s price by address.
  • eth_getNFTBalances: Get any wallet’s NFT balances.
  • eth_getNFTCollections: Query the NFT collections held by a wallet.

In essence, our Extended RPC Methods enhance our node offering, allowing you to get the same decoded, human-readable data that our APIs provide, but via RPC-style requests.

eth_getDecodedTransactions – The Simplest Way to Get Decoded Wallet History Using an RPC Node

The focus of today’s guide is eth_getDecodedTransactions. With this premier method, you don’t have to make multiple calls and connect the dots yourself. Instead, you only need a single RPC request to get the decoded history of any wallet, including native transactions, NFT transfers, smart contract interactions, and much more! 

Wallet history timeline with RPC nodes.

Furthermore, the responses provided by the eth_getDecodedTransactions method are fully enriched with automatic transaction summaries, category tags, address labels, and more data for each event. This means you get fully decoded data out of the box with minimal effort. 

So, how does this work? And what do the responses actually look like? If you’re curious, join us in the next section as we walk you through a complete tutorial on how to get decoded wallet history using an RPC node and our eth_getDecodedTransactions method.

3-Step Tutorial: How to Get Decoded Wallet History Using an RPC Node

It’s time to show you how to seamlessly get decoded wallet history using an RPC node. Thanks to the accessibility of our Extended RPC Methods and the eth_getDecodedTransactions endpoint, you can get the data you need in three simple steps: 

  1. Sign up with Moralis & set up a node.
  2. Write a script calling the eth_getDecodedTransactions method.
  3. Execute the code.

However, before jumping into the tutorial, you must deal with a few prerequisites. 

Prerequisites

Before you continue, make sure you have the following ready: 

  • Node.js v14+
  • npm/yarn

Step 1: Sign Up with Moralis & Set Up a Node

Click the “Start for Free” button at the top right and sign up for an account with Moralis:

Arrow pointing at "Start for Free" button at Moralis website.

Log in, go to the “Nodes” tab, and click the “+ Create Node” button:

Moralis nodes tab.

Select “Ethereum,” then “Mainnet,” and hit “Create Node”:

Moralis Ethereum node RPC configurations.

Doing so will create two new node URLs. Copy and keep one of your URLs for now, as you’ll need it in the next step:

Red arrows pointing at URLs for Ethereum RPC node.

Step 2: Write a Script Calling the eth_getDecodedTransactions Method

Set up a project folder in your preferred IDE, open a new terminal, and initialize a project with the given command:

npm init

Install the required dependencies with this terminal command:

npm install node-fetch --save
npm install moralis @moralisweb3/common-evm-utils

Open your “package.json” file and add "type": "module" to the list:

"type": "module" highlighted in code editor.

Create a new “index.js” file and add the code below:

import fetch from 'node-fetch';

const options = {
 method: 'POST',
 headers: {
   accept: 'application/json',
   'content-type': 'application/json'
 },
 body: JSON.stringify({
   "jsonrpc": "2.0",
   "id": 1,
   "method": "eth_getDecodedTransactions",
   "params": [
     {
       "address": "0xda74Ac6b69Ff4f1B6796cdDf61fBDd4A5f68525f",
     }
   ]
 })
};

fetch('YOUR_NODE_URL', options)
 .then(response => response.json())
 .then(response => console.log(response))
 .catch(err => console.error(err));

Replace YOUR_NODE_URL with the URL you copied during the first step:

Red arrow pointing at "YOUR_NODE_URL".

Configure the address parameter to fit your query:

Red arrow pointing at "address" parameter.

Step 3: Execute the Code

Run this terminal command in your project’s root folder to execute the script: 

node index.js

In return, you’ll get the full history of the specified wallet, enriched with human-readable transaction summaries, category tags, addresses, and much more. Here’s a sample response: 

{
  //...
    "result": [
      {
        "block_hash": "0x660274d577cd20b0b82c1bff5f3c5641ba6027544e005f9256d5add9c7447920",
        "block_number": "19868695",
        "block_timestamp": "2024-05-14T14:00:23.000Z",
        "from_address": "0xda74ac6b69ff4f1b6796cddf61fbdd4a5f68525f",
        "from_address_label": null,
        "from_address_entity": null,
        "from_address_entity_logo": null,
        "to_address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
        "to_address_label": "Tether USD (USDT)",
        "to_address_entity": null,
        "to_address_entity_logo": null,
        "gas": "55331",
        "gas_price": "13623172301",
        "hash": "0xc565260238f59fc3f35b74f3011375c7d637db9b075f77d342c30d19f946272e",
        "nonce": "14",
        "receipt_cumulative_gas_used": "13917979",
        "receipt_gas_used": "41309",
        "receipt_status": "1",
        "transaction_fee": "0.000562759624582009",
        "transaction_index": "75",
        "value": "0",
        "receipt_contract_address": null,
        "nft_transfers": [],
        "erc20_transfers": [
          {
            "token_name": "Tether USD",
            "token_symbol": "USDT",
            "token_logo": "https://logo.moralis.io/0x1_0xdac17f958d2ee523a2206206994597c13d831ec7_3282f332c2ac2948929f01fe7d921c51",
            "token_decimals": "6",
            "from_address": "0xda74ac6b69ff4f1b6796cddf61fbdd4a5f68525f",
            "from_address_entity": null,
            "from_address_entity_logo": null,
            "from_address_label": null,
            "to_address": "0x28c6c06298d514db089934071355e5743bf21d60",
            "to_address_label": "Binance 14",
            "to_address_entity": "Binance",
            "to_address_entity_logo": "https://entities-logos.s3.us-east-1.amazonaws.com/binance.png",
            "address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
            "log_index": 338,
            "value": "50000000000",
            "possible_spam": false,
            "verified_contract": true,
            "direction": "send",
            "value_formatted": "50000"
          }
        ],
        "method_label": "transfer",
        "native_transfers": [],
        "summary": "Sent 50,000 USDT to Binance 14",
        "possible_spam": false,
        "category": "token send"
      },
      //...
    }
  ]
}

Congratulations! You now know how to get decoded wallet history using an RPC node. For further information, please check out the official eth_getDecodedTransactions documentation page. 

From here, you can now follow the same steps to call any of our other Extended RPC Methods! 

Exploring the Benefits of eth_getDecodedTransactions

Now that you know how to get decoded wallet history using an RPC node, let’s explore some of the main benefits of the eth_getDecodedTransactions method: 

Wallet history timeline with RPC nodes.
  • One Request – All Data: With Moralis’ next-generation nodes, you can streamline your developer experience, as you only need a single RPC request to get decoded wallet history.
  • Automatic Summaries: The eth_getDecodedTransactions method features automatic summaries for each transaction event. This means you no longer have to connect the dots yourself. 
  • Reduced Complexity: With comprehensive responses, you can now build everything from portfolio trackers to tax platforms without breaking a sweat. 

Beyond How to Get Decoded Wallet History Using an RPC Node – Exploring Moralis Further

Moralis is the #1 Web3 data provider, giving you top-tier tools such as RPC nodes and use case-specific APIs for wallets, tokens, NFTs, DeFi, and much more. As such, when using Moralis, you get all crypto data in one place! 

Moralis logo.

What makes our development tools special? 

  • Comprehensive: Our APIs and Extended RPC Methods are outcome-oriented, giving you more data with fewer calls. Fetch wallet history, token balances with prices, and much more with just single requests. 
  • Multi-Chain: Moralis supports all major chains, including Ethereum, Polygon, BSC, and many more. Experience full feature parity across all the biggest chains so you can streamline your developer experience when building cross-chain dapps. 
  • Secure: Our SOC 2 Type 2 certification highlights Moralis’ commitment to maintaining enterprise-grade security and reliability. 

Nevertheless, let’s explore our RPC nodes and Web3 APIs to further highlight the benefits of Moralis! 

RPC Nodes

Moralis is a top-tier node provider, giving you the tools to seamlessly access next-generation RPC nodes for all major chains. 

Moralis RPC nodes.

What makes our RPC nodes unique? 

  • Speed: Our nodes feature response times from 70 ms, setting the benchmark for speed. 
  • Reliability: With 99.9% uptime, we guarantee high-reliability standards.
  • Extended RPC Methods: With Moralis’ Extended RPC Methods, you can now query decoded, human-readable data using RPC-style requests. 

Check out our RPC nodes page for more information. 

Moralis’ Web3 APIs

Our suite of industry-leading APIs comprises several interfaces tailored to specific use cases. Here are three key examples: 

Moralis logo.
  • Wallet API: Fetch any wallet’s full history, token balances, NFT balances, profitability, net worth, and much more with only single lines of code when using Moralis’ Wallet API. This is the perfect API for building wallets and integrating wallet functionality into dapps. 
  • Token API: Get token balances, prices, metadata, crypto PnL, transfers, and more with just one request when using the Token API. This is your go-to solution for ERC-20 data. 
  • Streams API: Moralis’ Streams API is the industry’s leading real-time data solution. With our intuitive point-and-click interface, you can set up Web3 data pipelines to stream real-time data into your projects without breaking a sweat. 

Check out our Web3 API page to learn more about all our premier interfaces. 

Summary: How to Get Decoded Wallet History Using an RPC Node

Whether you’re building a wallet, portfolio tracker, tax platform, or other similar Web3 projects, you often need access to your users’ wallet history. However, fetching this data using standard RPC methods, such as eth_getBlockByNumber and other endpoints, can be challenging, as you need to make many requests and compile a lot of data yourself. Fortunately, there’s a better alternative: Moralis’ Extended RPC Methods.

With our Extended RPC Methods, you can seamlessly fetch decoded, human-readable data via RPC-style requests. As such, it has never been easier to get decoded wallet history, token balances, token prices, and more via RPC nodes.

So, how can you use this powerful feature to get decoded wallet history using an RPC node? Check out the eth_getDecodedTransactions endpoint in action:

import fetch from 'node-fetch';

const options = {
 method: 'POST',
 headers: {
   accept: 'application/json',
   'content-type': 'application/json'
 },
 body: JSON.stringify({
   "jsonrpc": "2.0",
   "id": 1,
   "method": "eth_getDecodedTransactions",
   "params": [
     {
       "address": "0xda74Ac6b69Ff4f1B6796cdDf61fBDd4A5f68525f",
     }
   ]
 })
};

fetch('YOUR_NODE_URL', options)
 .then(response => response.json())
 .then(response => console.log(response))
 .catch(err => console.error(err));

In return for running the script above, you get the full history of the specified wallet, including automatic summaries, category tags, and much more for each event. Here’s a sample response:

{
  //...
    "result": [
      {
        "block_hash": "0x660274d577cd20b0b82c1bff5f3c5641ba6027544e005f9256d5add9c7447920",
        "block_number": "19868695",
        "block_timestamp": "2024-05-14T14:00:23.000Z",
        "from_address": "0xda74ac6b69ff4f1b6796cddf61fbdd4a5f68525f",
        "from_address_label": null,
        "from_address_entity": null,
        "from_address_entity_logo": null,
        "to_address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
        "to_address_label": "Tether USD (USDT)",
        "to_address_entity": null,
        "to_address_entity_logo": null,
        "gas": "55331",
        "gas_price": "13623172301",
        "hash": "0xc565260238f59fc3f35b74f3011375c7d637db9b075f77d342c30d19f946272e",
        "nonce": "14",
        "receipt_cumulative_gas_used": "13917979",
        "receipt_gas_used": "41309",
        "receipt_status": "1",
        "transaction_fee": "0.000562759624582009",
        "transaction_index": "75",
        "value": "0",
        "receipt_contract_address": null,
        "nft_transfers": [],
        "erc20_transfers": [
          {
            "token_name": "Tether USD",
            "token_symbol": "USDT",
            "token_logo": "https://logo.moralis.io/0x1_0xdac17f958d2ee523a2206206994597c13d831ec7_3282f332c2ac2948929f01fe7d921c51",
            "token_decimals": "6",
            "from_address": "0xda74ac6b69ff4f1b6796cddf61fbdd4a5f68525f",
            "from_address_entity": null,
            "from_address_entity_logo": null,
            "from_address_label": null,
            "to_address": "0x28c6c06298d514db089934071355e5743bf21d60",
            "to_address_label": "Binance 14",
            "to_address_entity": "Binance",
            "to_address_entity_logo": "https://entities-logos.s3.us-east-1.amazonaws.com/binance.png",
            "address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
            "log_index": 338,
            "value": "50000000000",
            "possible_spam": false,
            "verified_contract": true,
            "direction": "send",
            "value_formatted": "50000"
          }
        ],
        "method_label": "transfer",
        "native_transfers": [],
        "summary": "Sent 50,000 USDT to Binance 14",
        "possible_spam": false,
        "category": "token send"
      },
      //...
    }
  ]
}

That’s it! You now know how to get decoded wallet history using an RPC node!

If you found this article interesting, consider checking out more content here on the blog. For instance, learn how to get ERC-20 token balances using RPC nodes or check out our DeFi protocol data tutorial.

Also, if you wish to leverage the next generation of RPC nodes yourself, don’t forget to sign up with Moralis!

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
September 23, 2022

How to Create a Decentralized App in Just 3 Steps

October 20, 2023

Base Goerli Faucet – Get Free Base Testnet Tokens 

August 2, 2022

How to Create an NFT Candy Machine

October 1, 2022

How to Clone Zapper in Less Than 1 Hour

February 28, 2023

Arbitrum Testnet – How to Build and Launch Arbitrum Projects

August 5, 2022

Moralis Projects – Web3 Skyrim Market

February 9, 2024

How to Query Blockchain Data for Transactions, Balances, and More 

December 30, 2022

Essential Web3 Programming Languages for 2023

February 20, 2024

Crypto Portfolio Tracker Endpoint – Get Portfolio Data with a Single API Call 

🔥 LIMITED-TIME OFFER - Get early access to an Enhanced Token Page & boost your token project’s exposure! GET EARLY ACCESS 🔥