<div>
<p><strong>Are you on the lookout for a simple way to access wallet transactions via RPC nodes? You’ve come to the right spot! In this tutorial, we’ll look into Moralis’ Extended RPC Methods and our <code>eth_getTransactions</code> endpoint, which enables you to retrieve any wallet’s native transaction history with just one request. Are you excited to see how it works? Witness the method in action here:</strong></p>
<pre class="EnlighterJSRAW" data-enlighter-language="js" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">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_getTransactions",
"params": [
{
"address": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
"limit": 100,
}
]
})
};
fetch('YOUR_NODE_URL', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));</pre>
<p>Executing the above script will provide you with the native transaction history of the given wallet, complete with timestamps, gas prices, address labels, and more. Here’s a sample response:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="json" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">{
//...
result: [
{
hash: '0xd89b02f289a08ae7b2feead06031fec20777bad8b73fc8d853f9040bc423a6c7',
nonce: '0',
transaction_index: '142',
from_address: '0xda74ac6b69ff4f1b6796cddf61fbdd4a5f68525f',
from_address_label: '',
to_address: '0xdac17f958d2ee523a2206206994597c13d831ec7',
to_address_label: 'Tether USD (USDT)',
value: '0',
gas: '207128',
gas_price: '17020913648',
input: '0xa9059cbb00000000000000000000000028c6c06298d514db089934071355e5743bf21d6000000000000000000000000000000000000000000000000000000017a1df1700',
receipt_cumulative_gas_used: '8270587',
receipt_gas_used: '41309',
receipt_contract_address: null,
receipt_root: null,
receipt_status: '1',
block_timestamp: '2023-01-22T15:00:11.000Z',
block_number: '16463098',
block_hash: '0x2439330d0a282f9a6464b0aceb9f766ac4d7b050c048b4a1322b48544c61e01d',
transaction_fee: '0.000703116921885232'
},
//...
]
}
}</pre>
<p>And that’s all there is to it! Retrieving wallet transactions using RPC nodes is a breeze with Moralis. For a more comprehensive guide, join us in this article or check out the <a href="https://www.youtube.com/@MoralisWeb3">Moralis YouTube</a> video linked below:</p>
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><p>
</p></figure>
<p>Interested in fetching wallet transactions using RPC nodes on your own? Sign up for free at Moralis and gain instant access to all our Extended RPC Methods!</p>
<h3 class="wp-block-heading">Overview</h3>
<p>When building decentralized applications (dapps), such as cryptocurrency wallets, portfolio trackers, tax platforms, or similar projects, you’ll often need to access your users’ native transaction history. However, obtaining this information through RPC nodes can be complex, as it requires multiple requests and a lot of manual data handling. Fortunately, there’s a more efficient way: Moralis’ Extended RPC Methods.</p>
<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="1200" height="360" src="https://moralis.io/wp-content/uploads/2024/05/Blog-Moralis-Logo-1.png" alt="Moralis logo." class="wp-image-140799" srcset="https://moralis.io/wp-content/uploads/2024/05/Blog-Moralis-Logo-1.png 1200w, https://moralis.io/wp-content/uploads/2024/05/Blog-Moralis-Logo-1-300x90.png 300w, https://moralis.io/wp-content/uploads/2024/05/Blog-Moralis-Logo-1-1024x307.png 1024w, https://moralis.io/wp-content/uploads/2024/05/Blog-Moralis-Logo-1-768x230.png 768w" sizes="(max-width: 1200px) 100vw, 1200px"/></figure>
<p>With our Extended RPC Methods, you can obtain the same decoded data that our APIs offer, but through RPC-style requests. A single request can provide wallet transaction history, token prices, token balances, and much more.</p>
<p>Curious how this functions? If you’d like to learn about our Extended RPC Methods, come along in this tutorial. Let’s plunge right in!</p>
<h2 class="wp-block-heading">Introducing Moralis’ Next-Generation RPC Nodes – The Easiest Way to Get Wallet Transactions</h2>
<p>Moralis stands out as the industry’s premier provider of next-generation RPC nodes. With our user-friendly interface, you can access nodes for all major chains effortlessly. Regardless of the network you’re developing on, we have you covered.</p>
<figure class="wp-block-image size-full"><img decoding="async" width="1920" height="1080" src="https://moralis.io/wp-content/uploads/2024/08/Blog-Moralis-RPC-Nodes.jpg" alt="Moralis RPC nodes." class="wp-image-145922" srcset="https://moralis.io/wp-content/uploads/2024/08/Blog-Moralis-RPC-Nodes.jpg 1920w, https://moralis.io/wp-content/uploads/2024/08/Blog-Moralis-RPC-Nodes-300x169.jpg 300w, https://moralis.io/wp-content/uploads/2024/08/Blog-Moralis-RPC-Nodes-1024x576.jpg 1024w, https://moralis.io/wp-content/uploads/2024/08/Blog-Moralis-RPC-Nodes-768x432.jpg 768w, https://moralis.io/wp-content/uploads/2024/08/Blog-Moralis-RPC-Nodes-1536x864.jpg 1536w" sizes="(max-width: 1920px) 100vw, 1920px"/></figure>
<p>What makes our nodes so exceptional?</p>
<ul class="wp-block-list">
<li><strong>Speed:</strong> Our RPC nodes set a new standard for speed, boasting response times as low as 70 ms.</li>
</ul>
<ul class="wp-block-list">
<li><strong>Reliability:</strong> Enjoy the assurance of 99.9% uptime with our node infrastructure.</li>
</ul>
<ul class="wp-block-list">
<li><strong>Extended RPC Methods:</strong> Moralis’ Extended RPC Methods augment our node offerings, allowing for the querying of decoded, human-readable data through RPC-style requests.</li>
</ul>
<p>Now, let’s delve a bit deeper into our Extended RPC Methods that enable you to effortlessly fetch wallet transactions using RPC nodes!</p>
<h3 class="wp-block-heading">Extended RPC Methods</h3>
<p>Moralis’ Extended RPC Methods simplify the process of fetching decoded, human-readable data with RPC nodes. With a single call, you can quickly obtain wallet transactions, NFTs, token prices, metadata, and more. Consequently, utilizing Moralis and our Extended RPC Methods can significantly enhance your development experience.</p>
<figure class="wp-block-image size-full"><img decoding="async" width="1536" height="864" src="https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Moralis-Nodes.jpg" alt="Text: "Extended RPC Methods"" class="wp-image-146110" srcset="https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Moralis-Nodes.jpg 1536w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Moralis-Nodes-300x169.jpg 300w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Moralis-Nodes-1024x576.jpg 1024w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Moralis-Nodes-768x432.jpg 768w" sizes="(max-width: 1536px) 100vw, 1536px"/></figure>
<p>What data can you extract using our Extended RPC Methods?</p>
<ul class="wp-block-list">
<li><strong><code>eth_getTransactions</code></strong>: Retrieve the native transactions of a wallet.</li>
<li><strong><code>eth_getDecodedTransactions</code></strong>: Query the complete transaction history of a wallet.</li>
<li><strong><code>eth_getTokenBalances</code></strong>: Access the ERC-20 balances of a wallet.</li>
<li><strong><code>eth_getTokenMetadata</code></strong>: Get metadata for any ERC-20 token.</li>
<li><strong><code>eth_getTokenPrice</code></strong>: Obtain the price of any ERC-20 token.</li>
<li><strong><code>eth_getNFTBalances</code></strong>: Get the NFT balances for any wallet.</li>
<li><strong><code>eth_getNFTCollections</code></strong>: Fetch the NFT collections held by a wallet.</li>
</ul>
<p>In summary, with our Extended RPC Methods, you can conveniently obtain the same decoded, human-readable data that our APIs offer, but through RPC requests.</p>
<h2 class="wp-block-heading"><code>eth_getTransactions</code> – Retrieve Wallet Transactions Using RPC Nodes with a Single Request</h2>
<p>Using the <code>eth_getTransactions</code> method, you can conveniently access any wallet’s native transaction history with a single RPC request. Each transaction comes fully detailed with additional information, including timestamps, gas prices, address labels, and more. Consequently, utilizing the <code>eth_getTransactions</code> endpoint provides you with decoded data instantly with just one call.</p>
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1781" height="1015" src="https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Method.png" alt="Wallet connected with RPC nodes." class="wp-image-146111" srcset="https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Method.png 1781w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Method-300x171.png 300w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Method-1024x584.png 1024w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Method-768x438.png 768w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Method-1536x875.png 1536w" sizes="(max-width: 1781px) 100vw, 1781px"/></figure>
<p>How does this work? What does an actual response look like? If you want answers to these questions, stick with us in the next section where we demonstrate how to retrieve wallet transactions using RPC nodes in three straightforward steps.</p>
<h2 class="wp-block-heading">Tutorial: How to Get Wallet Transactions Using RPC Nodes</h2>
<p>With our Extended RPC Methods and the <code>eth_getTransactions</code> endpoint, you can access wallet transactions using RPC nodes in three simple steps:</p>
<ol class="wp-block-list">
<li>Sign up with Moralis & obtain a node URL.</li>
<li>Create a script to call <code>eth_getTransactions</code>.</li>
<li>Execute the code.</li>
</ol>
<p>Before we proceed to the tutorial, let’s ensure you’re set up with a few prerequisites.</p>
<h3 class="wp-block-heading">Prerequisites</h3>
<p>Ensure you have the following prepared before moving forward:</p>
<h3 class="wp-block-heading">Step 1: Sign Up with Moralis & Get a Node URL</h3>
<p>Click the ”Start for Free” button on the top right corner and register with Moralis:</p>
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="2906" height="806" src="https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Sign-Up-for-Free.png" alt="Arrow pointing at "Start for Free" button on Moralis website." class="wp-image-146113" srcset="https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Sign-Up-for-Free.png 2906w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Sign-Up-for-Free-300x83.png 300w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Sign-Up-for-Free-1024x284.png 1024w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Sign-Up-for-Free-768x213.png 768w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Sign-Up-for-Free-1536x426.png 1536w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Sign-Up-for-Free-2048x568.png 2048w" sizes="(max-width: 2906px) 100vw, 2906px"/></figure>
<p>Once logged in, head to the ”Nodes” tab and click ”+ Create Node”:</p>
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1536" height="686" src="https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Nodes-Tab.png" alt="Red arrow pointing at "Nodes" tab and "+ Create Node" button" class="wp-image-146114" srcset="https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Nodes-Tab.png 1536w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Nodes-Tab-300x134.png 300w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Nodes-Tab-1024x457.png 1024w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Nodes-Tab-768x343.png 768w" sizes="(max-width: 1536px) 100vw, 1536px"/></figure>
<p>Select ”Ethereum,” then ”Mainnet,” and hit ”Create Node”: </p>
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1536" height="827" src="https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Node-Config-1536x827-1.png" alt="Highlighting configurations for Ethereum node." class="wp-image-146115" srcset="https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Node-Config-1536x827-1.png 1536w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Node-Config-1536x827-1-300x162.png 300w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Node-Config-1536x827-1-1024x551.png 1024w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Node-Config-1536x827-1-768x414.png 768w" sizes="(max-width: 1536px) 100vw, 1536px"/></figure>
<p>Be sure to copy and save one of your node URLs; you’ll need it for the next step:</p>
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1536" height="693" src="https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Copy-URLS.png" alt="Arrows pointing at copy button for RPC nodes." class="wp-image-146116" srcset="https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Copy-URLS.png 1536w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Copy-URLS-300x135.png 300w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Copy-URLS-1024x462.png 1024w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Copy-URLS-768x347.png 768w" sizes="(max-width: 1536px) 100vw, 1536px"/></figure>
<h3 class="wp-block-heading">Step 2: Write a Script Calling <code>eth_getTransactions</code></h3>
<p>Open your IDE, create a new folder, then launch a terminal and initialize a project by running the following command:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">npm init</pre>
<p>Install the necessary dependencies with the command below:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">npm install node-fetch --save
npm install moralis @moralisweb3/common-evm-utils</pre>
<p>You’ll need to open your ”package.json” file and include <code>”type”: ”module”</code> in the list:</p>
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1024" height="556" src="https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Type-Module.png" alt=""type": "module" highlighted in code editor." class="wp-image-146117" srcset="https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Type-Module.png 1024w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Type-Module-300x163.png 300w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Type-Module-768x417.png 768w" sizes="(max-width: 1024px) 100vw, 1024px"/></figure>
<p>Create a file named ”index.js” and insert the code shown below:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">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_getTransactions",
"params": [
{
"address": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
"limit": 100,
}
]
})
};
fetch('YOUR_NODE_URL', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));</pre>
<p>Now, make slight adjustments to the code. Replace <code>YOUR_NODE_URL</code> with the node URL you copied from the first step. Modify the <code>address</code> parameter according to your request:</p>
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1624" height="1296" src="https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Configure-Code.png" alt="Arrows pointing at YOUR_NODE_URL and address in code editor." class="wp-image-146118" srcset="https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Configure-Code.png 1624w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Configure-Code-300x239.png 300w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Configure-Code-1024x817.png 1024w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Configure-Code-768x613.png 768w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Configure-Code-1536x1226.png 1536w" sizes="(max-width: 1624px) 100vw, 1624px"/></figure>
<h3 class="wp-block-heading">Step 3: Execute the Code</h3>
<p>Open a new terminal and execute the following command in the root folder of your project:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">node index.js</pre>
<p>In response, you’ll receive a list of the wallet’s previous native transactions, enriched with timestamps, gas prices, address labels, and more for each transaction. Here’s an example of a response you may receive:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="json" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">{
//...
result: [
{
hash: '0xd89b02f289a08ae7b2feead06031fec20777bad8b73fc8d853f9040bc423a6c7',
nonce: '0',
transaction_index: '142',
from_address: '0xda74ac6b69ff4f1b6796cddf61fbdd4a5f68525f',
from_address_label: '',
to_address: '0xdac17f958d2ee523a2206206994597c13d831ec7',
to_address_label: 'Tether USD (USDT)',
value: '0',
gas: '207128',
gas_price: '17020913648',
input: '0xa9059cbb00000000000000000000000028c6c06298d514db089934071355e5743bf21d6000000000000000000000000000000000000000000000000000000017a1df1700',
receipt_cumulative_gas_used: '8270587',
receipt_gas_used: '41309',
receipt_contract_address: null,
receipt_root: null,
receipt_status: '1',
block_timestamp: '2023-01-22T15:00:11.000Z',
block_number: '16463098',
block_hash: '0x2439330d0a282f9a6464b0aceb9f766ac4d7b050c048b4a1322b48544c61e01d',
transaction_fee: '0.000703116921885232'
},
//...
]
}
}</pre>
<p>This is all it takes; obtaining wallet transactions using RPC nodes with Moralis is super simple!</p>
<p>To delve deeper into this topic, check out the official <code>eth_getTransactions</code> documentation page.</p>
<h2 class="wp-block-heading">Applications for Wallet Transaction Data</h2>
<p>Having learned how to effortlessly retrieve wallet transactions using RPC nodes, let’s examine some significant use cases for this data. Below are three key examples:</p>
<ul class="wp-block-list">
<li><strong>Cryptocurrency Wallets:</strong> Wallets need transaction access to showcase past transfers, offering users a clear view of their historical activities.</li>
</ul>
<ul class="wp-block-list">
<li><strong>Portfolio Trackers:</strong> Portfolio trackers require past transfer data to accurately monitor the performance of users’ assets.</li>
</ul>
<ul class="wp-block-list">
<li><strong>Tax Platforms:</strong> Tax platforms must have a comprehensive overview of users’ trading history in order to generate precise tax reports.</li>
</ul>
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1776" height="1010" src="https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Use-Cases.png" alt="Wallet surrounded by tokens." class="wp-image-146119" srcset="https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Use-Cases.png 1776w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Use-Cases-300x171.png 300w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Use-Cases-1024x582.png 1024w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Use-Cases-768x437.png 768w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Use-Cases-1536x874.png 1536w" sizes="(max-width: 1776px) 100vw, 1776px"/></figure>
<p>Keep in mind that these are just a few examples; wallet transaction data is essential for the majority of dapps!</p>
<h3 class="wp-block-heading">Beyond Wallet Transactions: Exploring Moralis’ Extended RPC Methods</h3>
<p>Now that you’re familiar with accessing wallet transactions via RPC nodes, let’s delve deeper into our other Extended RPC Methods. More specifically, we’ll explore the following three:</p>
<ul class="wp-block-list">
<li><code>eth_getTokenBalances</code></li>
<li><code>eth_getDecodedTransactions</code></li>
<li><code>eth_getTokenPrice</code></li>
</ul>
<p>Let’s kick things off with <code>eth_getTokenBalances</code>!</p>
<h4 class="wp-block-heading"><code>eth_getTokenBalances</code></h4>
<p>With our <code>eth_getTokenBalances</code> method, you can efficiently retrieve ERC-20 token balances using RPC nodes. Instead of making multiple requests and assembling data manually, a single call will do the trick. Here’s the method in action:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">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_getTokenBalances",
"params": [
{
"address": "0xcB1C1FdE09f811B294172696404e88E658659905",
}
]
})
};
fetch('YOUR_NODE_URL', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));</pre>
<p>Calling the <code>eth_getTokenBalances</code> method will return the ERC-20 token balances of the specified wallet. Moreover, all tokens are accompanied by logos, decimals, thumbnails, spam indicators, and a wealth of additional information. Here’s an example of what the response may contain:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="json" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">{
//...
result: [
{
token_address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
name: 'Wrapped Ether',
symbol: 'WETH',
decimals: 18,
logo: 'https://logo.moralis.io/0x1_0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2_a578c5277503e547a072ae32517254ca',
thumbnail: 'https://logo.moralis.io/0x1_0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2_a578c5277503e547a072ae32517254ca',
balance: '10000000000000000',
possible_spam: false,
verified_contract: true,
total_supply: '2746607222348759943423350',
total_supply_formatted: '2746607.22234875994342335',
percentage_relative_to_total_supply: 3.64085549569e-7
},
//...
]
}</pre>
<h4 class="wp-block-heading"><code>eth_getDecodedTransactions</code></h4>
<p>With the <code>eth_getDecodedTransactions</code> method, you can seamlessly acquire decoded wallet history via an RPC node. There’s no need for multiple requests, data aggregation, or decoding manually. When using Moralis, you'll get all the data you need with just one call. Here’s how to call the <code>eth_getDecodedTransactions</code> endpoint:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">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));</pre>
<p>When you call <code>eth_getDecodedTransactions</code>, you will receive the full transaction history for the specified wallet, enriched with automatic category tags, event summaries, address labels, and much more. Here’s a sample of how the response might appear:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="json" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">{
//...
"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"
},
//...
}
]
}</pre>
<h4 class="wp-block-heading"><code>eth_getTokenPrice</code></h4>
<p>The <code>eth_getTokenPrice</code> method enables you to conveniently retrieve the price of any token using RPC-style requests. This way, there's no need to engage third-party API providers when integrating price data into your dapps. Here’s how the <code>eth_getTokenPrice</code> method works:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">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_getTokenPrice",
"params": [
{
"address": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
"include": "percent_change"
}
]
})
};
fetch('YOUR_NODE_URL', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));</pre>
<p>After running the script provided, you'll receive the USD and native prices for the specified token. Moreover, the response will be enriched with token logos, price changes over time, spam indicators, and additional information. Here’s what it might look like:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="json" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">{
//...
result: {
tokenName: 'Tether USD',
tokenSymbol: 'USDT',
tokenLogo: 'https://logo.moralis.io/0x1_0xdac17f958d2ee523a2206206994597c13d831ec7_3282f332c2ac2948929f01fe7d921c51',
tokenDecimals: '6',
nativePrice: {
value: '375760131462618',
decimals: 18,
name: 'Ether',
symbol: 'ETH',
address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
},
usdPrice: 1.0000402502911871,
usdPriceFormatted: '1.000040250291187229',
'24hrPercentChange': '-0.04543241491797881',
exchangeName: 'Uniswap v3',
exchangeAddress: '0x1F98431c8aD98523631AE4a59f267346ea31F984',
tokenAddress: '0xdac17f958d2ee523a2206206994597c13d831ec7',
priceLastChangedAtBlock: '20534105',
possibleSpam: false,
verifiedContract: true,
pairAddress: '0xc7bbec68d12a0d1830360f8ec58fa599ba1b0e9b',
pairTotalLiquidityUsd: '7148031.13'
}
}</pre>
<p>If you're interested in exploring more about our other methods, please visit the official Extended RPC Methods documentation page.</p>
<h2 class="wp-block-heading">Exploring Moralis’ Web3 APIs</h2>
<p>Moralis is the leading data provider in Web3, and besides our next-generation RPC nodes, we offer an extensive suite of Web3 APIs. A notable selection includes the Wallet API, Token API, Streams API, among others. Thus, when utilizing Moralis, you have access to all crypto data consolidated in one platform.</p>
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1865" height="1646" src="https://moralis.io/wp-content/uploads/2024/06/Blog-Moralis-Logo-2.png" alt="Moralis logo." class="wp-image-142702" srcset="https://moralis.io/wp-content/uploads/2024/06/Blog-Moralis-Logo-2.png 1865w, https://moralis.io/wp-content/uploads/2024/06/Blog-Moralis-Logo-2-300x265.png 300w, https://moralis.io/wp-content/uploads/2024/06/Blog-Moralis-Logo-2-1024x904.png 1024w, https://moralis.io/wp-content/uploads/2024/06/Blog-Moralis-Logo-2-768x678.png 768w, https://moralis.io/wp-content/uploads/2024/06/Blog-Moralis-Logo-2-1536x1356.png 1536w" sizes="(max-width: 1865px) 100vw, 1865px"/></figure>
<p>What makes our APIs exceptional?</p>
<ul class="wp-block-list">
<li><strong>Comprehensive:</strong> Our APIs yield the industry's most thorough responses, equipping you with more data with fewer requests. You can acquire token balances, any wallet's transaction history, NFT prices, and more in a single request.</li>
</ul>
<ul class="wp-block-list">
<li><strong>Cross-Chain:</strong> Moralis’ Web3 APIs boast cross-chain compatibility, ensuring feature parity across all major chains, including Ethereum, BSC, Optimism, Base, and many others.</li>
</ul>
<ul class="wp-block-list">
<li><strong>Secure:</strong> Moralis holds a SOC 2 Type 2 certification, confirming our commitment to security and reliability.</li>
</ul>
<p>Now, let’s delve deeper into our Web3 API suite by spotlighting some of our key interfaces!</p>
<h3 class="wp-block-heading">Moralis’ Web3 API Suite</h3>
<p>Within our Web3 API suite, you’ll find various interfaces tailored for different use cases. Below are five prominent examples:</p>
<ul class="wp-block-list">
<li><strong>Wallet API:</strong> Retrieve any wallet's full history, token balances with prices, net worth, profitability, and much more via single requests. This is an ideal tool for anyone aiming to develop Web3 wallets or integrate wallet functions into dapps.</li>
</ul>
<ul class="wp-block-list">
<li><strong>Token API:</strong> Effortlessly fetch token balances with prices, metadata, transactions, and more. This is your go-to solution for ERC-20 data and is beneficial for constructing portfolio trackers and DEXs.</li>
</ul>
<ul class="wp-block-list">
<li><strong>NFT API:</strong> Query NFT balances, prices, up-to-date metadata, transactions, and much more with just a few lines of code. This tool is perfect for those wanting to create NFT marketplaces, Web3 games, or similar platforms.</li>
</ul>
<ul class="wp-block-list">
<li><strong>Price API:</strong> Getting real-time and historical prices for both NFTs and ERC-20 tokens is a breeze. The Price API is the ultimate choice for those looking to incorporate price data into their dapps.</li>
</ul>
<ul class="wp-block-list">
<li><strong>Streams API:</strong> Moralis’ Streams API serves as a real-time data solution, allowing you to establish Web3 data pipelines with just a click. This is the best API for setting up real-time notifications, populating databases with recent on-chain events, or simply integrating current data into your dapps.</li>
</ul>
<p>We encourage you to check out the official Web3 API page for more details on our interfaces!</p>
<h2 class="wp-block-heading">Summary: How to Get Wallet Transactions Using RPC Nodes</h2>
<p>If you're looking to build Web3 projects like portfolio trackers, tax platforms, wallets, or similar dapps, you’ll likely require access to your users’ native transaction history. However, obtaining this data through RPC nodes and traditional methods like <code>eth_getTransactionByHash</code> can be quite laborious, often involving multiple requests and significant manual data assembly. Fortunately, with Moralis’ Extended RPC Methods, you can now retrieve this data using just one call.</p>
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1775" height="1009" src="https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Summary.png" alt="Wallet transactions with tokens." class="wp-image-146120" srcset="https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Summary.png 1775w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Summary-300x171.png 300w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Summary-1024x582.png 1024w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Summary-768x437.png 768w, https://moralis.io/wp-content/uploads/2024/08/Blog-Get-Wallet-Transactions-with-RPC-Nodes-Summary-1536x873.png 1536w" sizes="(max-width: 1775px) 100vw, 1775px"/></figure>
<p>With our Extended RPC Methods, you can acquire decoded, human-readable data through RPC-style requests effortlessly. Get wallet transactions, decoded wallet history, token balances, prices, and more with single API calls.</p>
<p>For example, here’s how simple it is to retrieve wallet transactions using RPC nodes while working with Moralis:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">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_getTransactions",
"params": [
{
"address": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
"limit": 100,
}
]
})
};
fetch('YOUR_NODE_URL', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));</pre>
<p>By executing the script above, you’ll receive the native transaction history of the specified wallet, complete with timestamps, gas prices, address labels, and more. Below is a sample response:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="json" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">{
//...
result: [
{
hash: '0xd89b02f289a08ae7b2feead06031fec20777bad8b73fc8d853f9040bc423a6c7',
nonce: '0',
transaction_index: '142',
from_address: '0xda74ac6b69ff4f1b6796cddf61fbdd4a5f68525f',
from_address_label: '',
to_address: '0xdac17f958d2ee523a2206206994597c13d831ec7',
to_address_label: 'Tether USD (USDT)',
value: '0',
gas: '207128',
gas_price: '17020913648',
input: '0xa9059cbb00000000000000000000000028c6c06298d514db089934071355e5743bf21d6000000000000000000000000000000000000000000000000000000017a1df1700',
receipt_cumulative_gas_used: '8270587',
receipt_gas_used: '41309',
receipt_contract_address: null,
receipt_root: null,
receipt_status: '1',
block_timestamp: '2023-01-22T15:00:11.000Z',
block_number: '16463098',
block_hash: '0x2439330d0a282f9a6464b0aceb9f766ac4d7b050c048b4a1322b48544c61e01d',
transaction_fee: '0.000703116921885232'
},
//...
]
}
}</pre>
<p>That's all it takes! You now know how to get wallet transactions using RPC nodes!</p>
<p>If you found this tutorial interesting, consider exploring additional resources on our blog. For example, you can discover how to access DeFi protocol data or delve into the intricacies of QuickNode Streams.</p>
<p>Moreover, if you want to utilize the Extended RPC Methods yourselves, don’t forget to sign up for an account with Moralis. Creating your account is free, and you’ll gain immediate access to all our premium development tools!</p>
</div>
Get Wallet Transactions with RPC Nodes: A Moralis Guide[embed]https://www.youtube.com/watch?v=HJMI8R-aEVI[/embed]
Leave a comment