Are you looking for an easy way to get wallet transactions using RPC nodes? If so, you’re in the right place. In today’s tutorial, we’ll explore Moralis’ Extended RPC Methods and our eth_getTransactions
endpoint, which allows you to fetch any wallet’s native transaction history with just one call. Eager to learn how it works? Check out the method in action here:
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));
By running the script above, you’ll receive the native transaction history of the specified wallet, enriched with timestamps, gas prices, address labels, and more. Here’s a sample response:
{ //... 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' }, //... ] } }
That’s it! It’s easy to retrieve wallet transactions using RPC nodes when working with Moralis. However, for a more detailed tutorial, join us in this article or check out the Moralis YouTube video below:
Want to get wallet transactions using RPC nodes yourself? Sign up for free with Moralis to immediately access all our Extended RPC Methods!
Overview
If you’re looking to build decentralized applications (dapps), whether it’s a cryptocurrency wallet, portfolio tracker, tax platform, or similar projects, you’ll likely need access to your users’ native transaction history. However, if you’re planning on getting this information using RPC nodes, it’s easier said than done, as it requires multiple requests and extensive manual data aggregation. Fortunately, there’s now a better way: Moralis’ Extended RPC Methods.
With our Extended RPC Methods, you can query the same decoded data that our APIs provide, but through RPC-style requests. A single call allows you to retrieve a wallet’s native transaction history, token prices, token balances, and much more.
But how does this work? If you’d like to learn more about our Extended RPC Methods, join us in this tutorial. Let’s dive straight in!
Introducing Moralis’ Next-Generation RPC Nodes – The Easiest Way to Get Wallet Transactions
Moralis is the industry’s leading provider of next-generation RPC nodes. With our intuitive user interface, you can access nodes for all major chains with just a click. As such, no matter what network you’re building on, we’ve got you covered.
But what makes our nodes unique?
- Speed: Our RPC nodes set the benchmark for speed, with response times as low as 70 ms.
- Reliability: With 99.9% uptime, you can trust our node infrastructure.
- Extended RPC Methods: Moralis’ Extended RPC Methods enhance our node offering, allowing you to query decoded, human-readable data via RPC-style requests.
Now, let’s dive a bit deeper into our Extended RPC Methods, which enable you to seamlessly get wallet transactions using RPC nodes!
Extended RPC Methods
Moralis’ Extended RPC Methods make fetching decoded, human-readable data with RPC nodes a breeze. With just one call, you can effortlessly get wallet transactions, NFTs, token prices, metadata, and much more. As such, when using Moralis and our Extended RPC Methods, you can significantly streamline your developer experience.
What data can you fetch with our Extended RPC Methods?
eth_getTransactions
: Get the native transactions of a wallet.eth_getDecodedTransactions
: Query the full transaction history of a wallet.eth_getTokenBalances
: Retrieve the ERC-20 balances of a wallet.eth_getTokenMetadata
: Get the metadata of any ERC-20 token.eth_getTokenPrice
: Access the price of any ERC-20 token.eth_getNFTBalances
: Get the NFT balances of any wallet.eth_getNFTCollections
: Fetch the NFT collections held by a wallet.
In summary, with our Extended RPC Methods, you can seamlessly fetch the same decoded, human-readable data our APIs provide, but through RPC-style requests.
eth_getTransactions
– Get Wallet Transactions Using RPC Nodes with One Request
With the eth_getTransactions
method, you can now seamlessly get any wallet’s native transaction history with just one single RPC request. Each transaction is also fully enriched with additional data, including time stamps, gas prices, address labels, and much more. As such, when using the eth_getTransactions
endpoint, you get decoded data out of the box with just one call.
But how does this work? And what does an actual response look like? If you’re looking for the answers to these questions, join us in the next section, where we show you exactly how to get wallet transactions using RPC nodes in three simple steps.
Tutorial: How to Get Wallet Transactions Using RPC Nodes
With our Extended RPC Methods and the eth_getTransactions
endpoint, you can get wallet transactions using RPC nodes in three simple steps:
- Sign up with Moralis & get a node URL.
- Write a script calling
eth_getTransactions
. - Run the code.
But before we can dive into the tutorial, you need to deal with a few prerequisites.
Prerequisites
Make sure you have the following ready before continuing:
Step 1: Sign Up with Moralis & Get a Node URL
Click the ”Start for Free” button at the top right and sign up with Moralis:
Log in, navigate to the ”Nodes” tab, and click ”+ Create Node”:
Choose ”Ethereum,” then ”Mainnet,” and click ”Create Node”:
Copy and save one of your node URLs, as you’ll need it in the next step:
Step 2: Write a Script Calling eth_getTransactions
Launch your IDE, set up a folder, open a new terminal, and initialize a project with this command:
npm init
Install the required dependencies with the following 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:
Create an ”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_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));
Next, you need to alter the code slightly. Replace YOUR_NODE_URL
with the node URL you copied during the first step. Also, configure the address
parameter so that it fits your request:
Step 3: Run the Code
Open a new terminal and run this command in your project’s root folder:
node index.js
In return, you’ll get a list of the wallet’s past native transactions, enriched with timestamps, gas prices, address labels, and much more data for each event. Here’s a sample response:
{ //... 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' }, //... ] } }
That’s it; it’s easy to get wallet transactions using RPC nodes when working with Moralis!
To learn more about this, check out the official eth_getTransactions
documentation page.
Use Cases for Wallet Transaction Data
Now that you know how to seamlessly get wallet transactions using RPC nodes, let’s explore some prominent use cases for this data. Here are three key examples:
- Cryptocurrency Wallets: Wallets require access to transactions to display past transfers, providing users with a clear overview of their historical activity.
- Portfolio Trackers: Portfolio trackers must access past transfers to accurately track the performance of users’ assets.
- Tax Platforms: Tax platforms need a comprehensive overview of users’ past trading activities to generate accurate tax reports.
Note that these are just a few examples – wallet transaction data is crucial for most dapps!
Beyond How to Get Wallet Transactions Using RPC Nodes – Diving Deeper Into Moralis’ Extended RPC Methods
Now that you know how to get wallet transactions using RPC nodes, we’ll dive a bit deeper into our other Extended RPC Methods. More specifically, we’ll explore the following three:
eth_getTokenBalances
eth_getDecodedTransactions
eth_getTokenPrice
So, let’s kick things off with eth_getTokenBalances
!
eth_getTokenBalances
With our eth_getTokenBalances
method, you can seamlessly get ERC-20 token balances using RPC nodes. Instead of having to make multiple RPC requests and stitching together data on your own, you only need a single call. Here’s the 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_getTokenBalances", "params": [ { "address": "0xcB1C1FdE09f811B294172696404e88E658659905", } ] }) }; fetch('YOUR_NODE_URL', options) .then(response => response.json()) .then(response => console.log(response)) .catch(err => console.error(err));
In response to calling the eth_getTokenBalances
method, you’ll receive the ERC-20 token balances of the specified wallet. What’s more, all tokens are enriched with logos, decimals, thumbnails, spam indicators, and much more. Here’s a sample response:
{ //... result: [ { token_address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', name: 'Wrapped Ether', symbol: 'WETH', decimals: 18, logo: 'https://logo.developers.moralis.com/0x1_0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2_a578c5277503e547a072ae32517254ca', thumbnail: 'https://logo.developers.moralis.com/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 }, //... ] }
eth_getDecodedTransactions
With the eth_getDecodedTransactions
method, you can effortlessly get decoded wallet history using an RPC node. No need to make multiple requests, aggregate data yourself, or decode information. When using Moralis, you get all the data you need with just one call. Here’s an example of how to call the eth_getDecodedTransactions
endpoint:
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 response to calling eth_getDecodedTransactions
, you’ll receive the specified wallet’s full history, enriched with automatic category tags, event summaries, address labels, and more. Here’s an example of what the response 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.developers.moralis.com/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" }, //... } ] }
eth_getTokenPrice
The eth_getTokenPrice
method allows you to seamlessly retrieve the price of any token using RPC-style requests. This eliminates the need to involve third-party API providers when integrating price data into your dapps. Here’s the eth_getTokenPrice
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_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));
In response to running the script above, you’ll receive the USD and native price of the specified token. Additionally, the response is enriched with token logos, price changes over time, spam indicators, and more. Here’s what it might look like:
{ //... result: { tokenName: 'Tether USD', tokenSymbol: 'USDT', tokenLogo: 'https://logo.developers.moralis.com/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' } }
If you’d like to learn more about our other methods, please check out the official Extended RPC Methods documentation page.
Exploring Moralis’ Web3 APIs
Moralis is Web3’s leading data provider, and in addition to next-generation RPC nodes, we also offer a comprehensive suite of Web3 APIs. Some prominent examples here included the Wallet API, Token API, Streams API, and many more. As such, when leveraging Moralis, you get all crypto data in one place.
What makes our APIs special?
- Comprehensive: Our APIs provide the industry’s most comprehensive responses, giving you more data with fewer calls. Get token balances, any wallet’s transaction history, NFT prices, and much more with single requests.
- Cross-Chain: Moralis’ Web3 APIs are cross-chain compatible, providing full feature parity across all major chains, including Ethereum, BSC, Optimism, Base, and many more.
- Secure: Moralis holds a SOC 2 Type 2 certification, demonstrating our commitment to security and reliability.
Now, let’s dive a bit deeper into our Web3 API suite by exploring some of our prominent interfaces!
Moralis’ Web3 API Suite
In our suite of Web3 APIs, you’ll find multiple interfaces tailored for various use cases. Here are five prominent examples:
- Wallet API: Get any wallet’s full history, token balances with prices, net worth, profitability, and much more with single requests. This is the perfect tool for anyone looking to build Web3 wallets or integrate wallet functionality into dapps.
- Token API: Fetch token balances with prices, metadata, transactions, and much more with ease. This is your go-to solution for ERC-20 data, helping you build everything from portfolio trackers to DEXs.
- NFT API: Query NFT balances, prices, up-to-date metadata, transactions, and much more using single lines of code. This tool is excellent for anyone looking to build NFT marketplaces, Web3 games, or other similar platforms.
- Price API: Get real-time and historical prices for both NFTs and ERC-20 tokens. The Price API is the ultimate tool if you’re looking to integrate price data into your dapps.
- Streams API: The Streams API is Moralis’ real-time data solution, allowing you to set up Web3 data pipelines at the click of a button. This is the best API for setting up real-time alerts, populating databases with recent on-chain events, or simply integrating current data into dapps.
Please check out the official Web3 API page to learn more about our interfaces!
Summary: How to Get Wallet Transactions Using RPC Nodes
Suppose you want to build Web3 projects like portfolio trackers, tax platforms, wallets, or other similar dapps. In that case, chances are that you’ll need access to your users’ native transaction history. However, fetching this data using RPC nodes and conventional methods like eth_getTransactionByHash
is quite challenging, as it requires multiple requests and a lot of manual data aggregation. Fortunately, you can now get this data with just one call when using Moralis’ Extended RPC Methods.
With our Extended RPC Methods, you can get decoded, human-readable data through RPC-style requests. Get wallet transactions, decoded wallet history, token balances, prices, and much more with single calls.
For instance, this is how easy it is to get wallet transactions using RPC nodes when building with Moralis:
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));
In return for calling the script above, you get the native transaction history of the specified wallet, enriched with timestamps, gas prices, address labels, and more. Here’s a sample response:
{ //... 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' }, //... ] } }
That’s it! You now know how to get wallet transactions using RPC nodes!
If you found this tutorial interesting, consider checking out more content on the blog. For instance, you can learn how to get DeFi protocol data or explore the ins and outs of QuickNode Streams.
Furthermore, if you want to use the Extended RPC Methods yourself, don’t forget to sign up for an account with Moralis. You can create your account for free, and you’ll get instant access to all our premier development tools!