News BlockFin
  • bitcoinBitcoin(BTC)$105,381.001.21%
  • ethereumEthereum(ETH)$2,609.004.69%
  • tetherTether(USDT)$1.000.02%
  • rippleXRP(XRP)$2.223.18%
  • binancecoinBNB(BNB)$664.161.91%
  • solanaSolana(SOL)$161.074.53%
  • usd-coinUSDC(USDC)$1.000.00%
  • dogecoinDogecoin(DOGE)$0.1955192.95%
  • tronTRON(TRX)$0.2700840.78%
  • cardanoCardano(ADA)$0.693.04%
  • Home
  • Bitcoin
  • Crypto Updates
    • Crypto Updates
    • Altcoin
    • Ethereum
    • Crypto Exchanges
  • Blockchain
  • NFT
  • Metaverse
  • Web3
  • Analysis
  • Regulations
  • Scams
No Result
View All Result
News BlockFin
  • Home
  • Bitcoin
  • Crypto Updates
    • Crypto Updates
    • Altcoin
    • Ethereum
    • Crypto Exchanges
  • Blockchain
  • NFT
  • Metaverse
  • Web3
  • Analysis
  • Regulations
  • Scams
No Result
View All Result
News BlockFin
No Result
View All Result

How to Get NFT Balances with One RPC Call – Moralis Web3

Home Web3
0
SHARES
0
VIEWS
Share on FacebookShare on Twitter


Do you know that with Moralis’ next-generation nodes, you will get NFT balances with only one RPC name? Our Prolonged RPC Strategies and the eth_getNFTBalances endpoint make fetching NFT balances a breeze. Wanting to study the way it works? Take a look at the endpoint in motion under:

import fetch from ‘node-fetch’;

const choices = {
methodology: ‘POST’,
headers: {
settle for: ‘software/json’,
‘content-type’: ‘software/json’
},
physique: JSON.stringify({
“jsonrpc”: “2.0”,
“id”: 1,
“methodology”: “eth_getNFTBalances”,
“params”: [
{
“address”: “0xDc597929101c2DE50c97D43C8EA3A372Bf55fdc0”,
“limit”: 10,
}
]
})
};

fetch(‘YOUR_NODE_URL’, choices)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));

By calling the script above, you’ll obtain the NFT balances of the desired pockets, enriched with metadata, addresses, assortment knowledge, and extra. Right here’s what it would appear to be:

{
jsonrpc: ‘2.0’,
id: 1,
consequence: {
//…
consequence: [
{
amount: ‘1’,
token_id: ‘1919’,
token_address: ‘0xbd3531da5cf5857e7cfaa92426877b022e612cf8’,
contract_type: ‘ERC721’,
owner_of: ‘0xdc597929101c2de50c97d43c8ea3a372bf55fdc0’,
last_metadata_sync: ‘2024-08-25T23:35:51.384Z’,
last_token_uri_sync: ‘2024-08-25T23:35:50.893Z’,
metadata: ‘{“attributes”:[{“trait_type”:”Background”,”value”:”Mint”},{“trait_type”:”Skin”,”value”:”Olive Green”},{“trait_type”:”Body”,”value”:”Turtleneck Pink”},{“trait_type”:”Face”,”value”:”Eyepatch”},{“trait_type”:”Head”,”value”:”Wizard Hat”}],”description”:”A set 8888 Cute Chubby Pudgy Penquins sliding round on the freezing ETH blockchain.”,”picture”:”ipfs://QmNf1UsmdGaMbpatQ6toXSkzDpizaGmC9zfunCyoz1enD5/penguin/1919.png”,”title”:”Pudgy Penguin #1919″}’,
block_number: ‘19754671’,
block_number_minted: null,
title: ‘PudgyPenguins’,
image: ‘PPG’,
token_hash: ‘cbd8bd0901f422afb88e76615e3d2a1a’,
token_uri: ‘https://ipfs.moralis.io:2053/ipfs/bafybeibc5sgo2plmjkq2tzmhrn54bk3crhnc23zd2msg4ea7a4pxrkgfna/1919’,
minter_address: null,
verified_collection: true,
possible_spam: false,
collection_logo: ‘https://i.seadn.io/gae/yNi-XdGxsgQCPpqSio4o31ygAV6wURdIdInWRcFIl46UjUQ1eV7BEndGe8L661OoG-clRi7EgInLX4LPu9Jfw4fq0bnVYHqg7RFi?w=500&auto=format’,
collection_banner_image: ‘https://i.seadn.io/gcs/recordsdata/8a26e3de0f309089cbb1e5ab969fc0bc.png?w=500&auto=format’
},
//…
]
}
}

That’s it! Fetching NFT balances requires just one RPC name when leveraging Moralis and our top-tier nodes. To study extra, be part of us on this tutorial or go to the eth_getNFTBalances documentation web page.

You can too watch the Moralis YouTube video under to learn to get the NFT balances of a pockets utilizing ethers.js:

Prepared to begin utilizing our Prolonged RPC Strategies? Join a free account with Moralis at the moment!

Overview

Fetching the NFT balances of a pockets utilizing RPC requests generally is a bothersome and time-consuming job. With typical strategies, comparable to eth_call, it takes many requests, in depth handbook knowledge aggregation, and quite a lot of effort to get the info you want. Thankfully, there’s now a greater various: Moralis’ Prolonged RPC Strategies. 

However what precisely are our Prolonged RPC Strategies? And the way can they aid you get NFT balances with only one RPC request? For the solutions to those questions, be part of us on this article as we lay all of it out for you. Let’s dive straight in! 

Moralis’ Subsequent-Technology RPC Nodes – The Greatest Method to Get NFT Balances

Moralis is a outstanding supplier of top-tier, next-generation RPC nodes. With our intuitive person interface, you possibly can arrange nodes for all main chains with the clicking of some buttons. Some supported chains embrace Ethereum, Polygon, BNB Sensible Chain (BSC), Optimism, and Base. 

Moralis RPC nodes.

However why do you have to select Moralis as your node supplier?

Velocity: With response instances from 70 ms, we set the trade benchmark for velocity. 

Reliability: Our nodes boast a powerful 99.9% uptime, supplying you with top-tier reliability. 

Safe: Shield your organization’s knowledge by selecting Moralis as your trusted SOC 2 Kind 2 associate. 

Along with excessive velocity, spectacular reliability, and enterprise-grade safety, Moralis additionally gives Prolonged RPC Strategies.

However what are they? And the way do they work? 

Be part of us within the subsequent part to seek out out!

Prolonged RPC Strategies

Our Prolonged RPC Strategies make it simple so that you can fetch decoded, human-readable knowledge through RPC nodes. A single name provides you NFT balances, decoded transactions, token costs, metadata, and rather more. As such, when leveraging our next-generation nodes, you possibly can streamline your developer expertise and fetch on-chain knowledge through RPC-style requests with out breaking a sweat. 

Moralis Extended RPC Methods.

What strategies can be found? 

eth_getNFTBalances: Fetch the NFT stability of a pockets. 

eth_getNFTCollections: Get the collections held by a pockets.

eth_getTransactions: Question the native transaction historical past of a pockets. 

eth_getDecodedTransactions: Get a pockets’s full transaction historical past. 

eth_getTokenBalances: Fetch the ERC-20 balances of a pockets.

eth_getTokenMetadata: Get ERC-20 token metadata. 

eth_getTokenPrice: Entry the value of any ERC-20 token. 

All in all, with the strategies above, you possibly can effortlessly fetch decoded, human-readable knowledge utilizing RPC-style requests.

eth_getNFTBalances – Best Method to Get NFT Balances with One RPC Name

The eth_getNFTBalances methodology is your go-to selection for those who’re in search of a simple strategy to get NFT balances with only one RPC name. This methodology gives a full record of the desired pockets’s NFTs, enriched with metadata, addresses, symbols, assortment knowledge, and rather more. As such, it has by no means been simpler to get the NFT balances of a pockets utilizing RPC nodes. 

Wallet surrounded by NFT and tokens.

However how precisely does this work? And what does an precise response appear to be? For the solutions to those questions, be part of us within the subsequent part, the place we’ll stroll you thru a full tutorial on methods to get NFT balances of a pockets with only one RPC request! 

Full Tutorial: Get the NFT Balances of a Pockets with One RPC Name

With our Prolonged RPC Strategies and the eth_getNFTBalances endpoint, you possibly can seamlessly get NFT Balances in three easy steps: 

Enroll with Moralis & arrange a node.

Write a script calling eth_getNFTBalances.

Run the code.

Nevertheless, earlier than we will get going, it’s essential to deal with a number of stipulations.

Stipulations

Earlier than you will get going with the tutorial, be sure you have the next prepared: 

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

Hit the ”Begin for Free” button on the prime proper and join a free account with Moralis: 

Red arrow pointing at "Start for Free" button.

Log in, go to the ”Nodes” tab, and click on ”+ Create Node” to arrange a node: 

Red arrows pointing at "Nodes" tab and "+ Create Node" button.

Choose ”Ethereum,” adopted by ”Mainnet,” and click on ”Create Node”: 

Ethereum node configurations.

Copy and preserve certainly one of your node URLs, as you’ll want it within the subsequent step: 

Red arrows pointing at copy button for RPC node URLs.

Step 2: Write a Script Calling eth_getNFTBalances

Create a folder in your built-in growth surroundings (IDE), open a brand new terminal, and run this command to initialize a brand new venture:

npm init

Set up the required dependencies with these terminal instructions:

npm set up node-fetch –save
npm set up moralis @moralisweb3/common-evm-utils

Open your “package deal.json” file and add “kind”: “module” to the record:

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

Arrange a brand new “index.js” file and add the next code:

import fetch from ‘node-fetch’;

const choices = {
methodology: ‘POST’,
headers: {
settle for: ‘software/json’,
‘content-type’: ‘software/json’
},
physique: JSON.stringify({
“jsonrpc”: “2.0”,
“id”: 1,
“methodology”: “eth_getNFTBalances”,
“params”: [
{
“address”: “0xDc597929101c2DE50c97D43C8EA3A372Bf55fdc0”,
“limit”: 10,
}
]
})
};

fetch(‘YOUR_NODE_URL’, choices)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));

Change YOUR_NODE_URL with the URL you copied throughout step one, and configure the deal with parameter to suit your request:

Red arrows pointing at address and YOUR_NODE_URL parameters in code editor.

Step 3: Run the Code

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

node index.js

By working the script, you’ll obtain an array of all tokens owned by the desired deal with. The response is enriched with metadata, addresses, symbols, assortment knowledge, and extra for every factor. Right here’s a pattern response:

{
jsonrpc: ‘2.0’,
id: 1,
consequence: {
//…
consequence: [
{
amount: ‘1’,
token_id: ‘1919’,
token_address: ‘0xbd3531da5cf5857e7cfaa92426877b022e612cf8’,
contract_type: ‘ERC721’,
owner_of: ‘0xdc597929101c2de50c97d43c8ea3a372bf55fdc0’,
last_metadata_sync: ‘2024-08-25T23:35:51.384Z’,
last_token_uri_sync: ‘2024-08-25T23:35:50.893Z’,
metadata: ‘{“attributes”:[{“trait_type”:”Background”,”value”:”Mint”},{“trait_type”:”Skin”,”value”:”Olive Green”},{“trait_type”:”Body”,”value”:”Turtleneck Pink”},{“trait_type”:”Face”,”value”:”Eyepatch”},{“trait_type”:”Head”,”value”:”Wizard Hat”}],”description”:”A set 8888 Cute Chubby Pudgy Penquins sliding round on the freezing ETH blockchain.”,”picture”:”ipfs://QmNf1UsmdGaMbpatQ6toXSkzDpizaGmC9zfunCyoz1enD5/penguin/1919.png”,”title”:”Pudgy Penguin #1919″}’,
block_number: ‘19754671’,
block_number_minted: null,
title: ‘PudgyPenguins’,
image: ‘PPG’,
token_hash: ‘cbd8bd0901f422afb88e76615e3d2a1a’,
token_uri: ‘https://ipfs.moralis.io:2053/ipfs/bafybeibc5sgo2plmjkq2tzmhrn54bk3crhnc23zd2msg4ea7a4pxrkgfna/1919’,
minter_address: null,
verified_collection: true,
possible_spam: false,
collection_logo: ‘https://i.seadn.io/gae/yNi-XdGxsgQCPpqSio4o31ygAV6wURdIdInWRcFIl46UjUQ1eV7BEndGe8L661OoG-clRi7EgInLX4LPu9Jfw4fq0bnVYHqg7RFi?w=500&auto=format’,
collection_banner_image: ‘https://i.seadn.io/gcs/recordsdata/8a26e3de0f309089cbb1e5ab969fc0bc.png?w=500&auto=format’
},
//…
]
}
}

Past The right way to Get NFT Balances with One RPC Name – Exploring Different Prolonged RPC Strategies

Fetching the NFT balances of a pockets is barely one of many many issues you are able to do with our Prolonged RPC Strategies. As such, let’s take a deeper dive into three different strategies: 

eth_getTransactions

eth_getDecodedTransactions

eth_getTokenBalances

eth_getTransactions

With the eth_getTransactions methodology, now you can simply get pockets transactions utilizing RPC nodes with only one name. This implies you not should trouble with limitless requests, supplying you with a considerably extra streamlined developer expertise. Right here’s an instance exhibiting the strategy in motion: 

import fetch from ‘node-fetch’;

const choices = {
methodology: ‘POST’,
headers: {
settle for: ‘software/json’,
‘content-type’: ‘software/json’
},
physique: JSON.stringify({
“jsonrpc”: “2.0”,
“id”: 1,
“methodology”: “eth_getTransactions”,
“params”: [
{
“address”: “0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045”,
“limit”: 100,
}
]
})
};

fetch(‘YOUR_NODE_URL’, choices)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));

In return for working the script above, you’ll get an inventory of the pockets’s previous native transactions. Moreover, every transaction is enriched with timestamps, deal with labels, gasoline costs, and extra. Right here’s what it would appear to be: 

{
//…
consequence: [
{
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’
},
//…
]
}
}

eth_getDecodedTransactions

The eth_getDecodedTransactions methodology permits you to simply get decoded pockets historical past utilizing an RPC node. With only one request, you possibly can seamlessly fetch any pockets’s full historical past, together with native transactions, ERC-20 transfers, NFT transfers, and extra. Right here’s a script exhibiting how eth_getDecodedTransactions works in follow: 

import fetch from ‘node-fetch’;

const choices = {
methodology: ‘POST’,
headers: {
settle for: ‘software/json’,
‘content-type’: ‘software/json’
},
physique: JSON.stringify({
“jsonrpc”: “2.0”,
“id”: 1,
“methodology”: “eth_getDecodedTransactions”,
“params”: [
{
“address”: “0xda74Ac6b69Ff4f1B6796cdDf61fBDd4A5f68525f”,
}
]
})
};

fetch(‘YOUR_NODE_URL’, choices)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));

In return for executing the script above, you’ll get the pockets’s full historical past. What’s extra, every transaction is enriched with class tags, occasion summaries, deal with labels, and different helpful info. Right here’s a pattern response: 

{
//…
“consequence”: [
{
“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”: “switch”,
“native_transfers”: [],
“abstract”: “Despatched 50,000 USDT to Binance 14”,
“possible_spam”: false,
“class”: “token ship”
},
//…
}
]
}

eth_getTokenBalances

With Moralis’ eth_getTokenBalances methodology, you possibly can effortlessly get ERC-20 token balances utilizing RPC nodes. This implies you not should make a number of requests and sew the info collectively your self. One request and also you get all the knowledge you want. Right here’s an instance exhibiting the strategy in motion:

import fetch from ‘node-fetch’;

const choices = {
methodology: ‘POST’,
headers: {
settle for: ‘software/json’,
‘content-type’: ‘software/json’
},
physique: JSON.stringify({
“jsonrpc”: “2.0”,
“id”: 1,
“methodology”: “eth_getTokenBalances”,
“params”: [
{
“address”: “0xcB1C1FdE09f811B294172696404e88E658659905”,
}
]
})
};

fetch(‘YOUR_NODE_URL’, choices)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));

Calling the script above provides you the ERC-20 token balances of the desired deal with. Furthermore, all tokens within the record will likely be enriched with logos, decimals, spam indicators, thumbnails, and extra. Right here’s a pattern response: 

{
//…
consequence: [
{
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
},
//…
]
}

To study extra about all our strategies, please go to the official Prolonged RPC Strategies documentation web page. 

Diving Deeper Into Moralis’ Web3 APIs

Moralis is the trade’s main Web3 knowledge supplier, and along with our Prolonged RPC Strategies, we provide a complete suite of Web3 APIs, such because the Pockets API, Token API, Streams API, and extra. With Moralis, you get all crypto knowledge in a single place.

Moralis logo.

However what makes our Web3 APIs distinctive?

One Name – All Information: Our APIs are outcome-oriented, offering extra knowledge with fewer requests. Get token balances, a pockets’s full historical past, NFT metadata, and rather more with a single name.

Cross-Chain: Moralis provides full function parity throughout main chains, together with Ethereum, Polygon, Optimism, BSC, Base, and others.

Safety & Reliability: Moralis is SOC 2 Kind 2 licensed, highlighting our dedication to offering enterprise-grade safety and reliability.

To study extra about our suite of main growth instruments, let’s dive into three of our outstanding APIs!

Pockets API

Moralis’ Pockets API is the final word software for those who’re seeking to construct wallets or combine pockets performance into your dapps. With this premier interface, you possibly can effortlessly get a pockets’s full historical past, token balances, NFT balances, internet price, profitability, and rather more. 

Wallet API.

To focus on the facility of this software, let’s check out certainly one of our endpoints in motion. For example, that is how simple it’s to fetch the online price of a pockets: 

import fetch from ‘node-fetch’;

const choices = {
methodology: ‘GET’,
headers: {
settle for: ‘software/json’,
‘X-API-Key’: ‘YOUR_API_KEY’
},
};

fetch(‘https://deep-index.moralis.io/api/v2.2/wallets/0x1f9090aaE28b8a3dCeaDf281B0F12828e676c326/net-worth’, choices)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));

In return for calling the script above, you’ll get the overall internet price of the desired pockets, together with particular person chain breakdowns. Right here’s a pattern response: 

{
total_networth_usd: ‘9906.41’,
chains: [
{
chain: ‘eth’,
native_balance: ‘3138317588449827590’,
native_balance_formatted: ‘3.13831758844982759’,
native_balance_usd: ‘8069.70’,
token_balance_usd: ‘1836.70’,
networth_usd: ‘9906.41’
}
]
}

So, for those who’re in search of a powerful array of options, top-tier flexibility, and unparalleled scalability, make certain to take a look at the Pockets API! 

Token API

The Token API is your go-to software for ERC-20 knowledge. This premier interface covers all tokens throughout all the most important chains, together with stablecoins like USDC, meme cash like Shiba Inu, and all the things in between. 

Token API.

With the Token API, you possibly can seamlessly fetch token balances, costs, transfers, metadata, and rather more. To showcase the accessibility of this software, right here’s a pattern script exhibiting you the way simple it’s to get the value of a token: 

import fetch from ‘node-fetch’;

const choices = {
methodology: ‘GET’,
headers: {
settle for: ‘software/json’,
‘X-API-Key’: ‘YOUR_API_KEY’
},
};

fetch(‘https://deep-index.moralis.io/api/v2.2/erc20/0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0/value?chain=eth&embrace=percent_change’, choices)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));

In return for calling the script above, you’ll get the value of the token denominated in each the native foreign money and USD. Right here’s what it would appear to be: 

{
tokenName: ‘Matic Token’,
tokenSymbol: ‘MATIC’,
tokenLogo: ‘https://emblem.moralis.io/0x1_0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0_89c931b3fcf74fe39db7a195bf8a3aa5′,
tokenDecimals: ’18’,
nativePrice: {
worth: ‘172371569340575’,
decimals: 18,
title: ‘Ether’,
image: ‘ETH’,
deal with: ‘0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2’
},
usdPrice: 0.44344021067602557,
usdPriceFormatted: ‘0.443440210676025551’,
exchangeName: ‘Uniswap v3’,
exchangeAddress: ‘0x1F98431c8aD98523631AE4a59f267346ea31F984’,
tokenAddress: ‘0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0’,
priceLastChangedAtBlock: ‘20634460’,
blockTimestamp: ‘1724937179000’,
possibleSpam: false,
verifiedContract: true,
pairAddress: ‘0x290a6a7460b308ee3f19023d2d00de604bcf5b42’,
pairTotalLiquidityUsd: ‘1592811.47’,
’24hrPercentChange’: ‘-1.1406370639269006’,
securityScore: 55
}

In the event you’re seeking to construct platforms like DEXs, token explorers, or different comparable tasks, make certain to begin utilizing the Token API! 

NFT API

Moralis’ NFT API is the final word interface for NFT knowledge, masking over three million NFT collections and counting throughout all main chains, together with Ethereum, Polygon, BSC, Base, and lots of extra. With this premier interface, you solely want single strains of code to get NFT balances, metadata, costs, and so on. 

NFT API.

To focus on the facility of this software, take a look at the instance script under, exhibiting you the way simple it’s to get the metadata of an NFT: 

import fetch from ‘node-fetch’;

const choices = {
methodology: ‘GET’,
headers: {
settle for: ‘software/json’,
‘X-API-Key’: ‘YOUR_API_KEY’
},
};

fetch(‘https://deep-index.moralis.io/api/v2.2/nft/0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB/200?chain=eth’, choices)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));

In return for executing the code above, you’ll get the metadata of the desired NFT, enriched with addresses, assortment knowledge, rarity indicators, and rather more. Right here’s what it would appear to be: 

{
quantity: ‘1’,
token_id: ‘200’,
token_address: ‘0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb’,
contract_type: ‘CRYPTOPUNKS’,
owner_of: ‘0xa858ddc0445d8131dac4d1de01f834ffcba52ef1’,
last_metadata_sync: ‘2024-08-29T17:03:32.616Z’,
last_token_uri_sync: ‘2024-08-29T17:03:32.302Z’,
metadata: ‘{“picture”:”https://www.larvalabs.com/cryptopunks/cryptopunk200.png”,”title”:”CryptoPunk 200″,”attributes”:[“Wild Hair”],”description”:”Feminine”}’,
block_number: ‘14401717’,
block_number_minted: null,
title: ‘CRYPTOPUNKS’,
image: ‘Ďľ’,
token_hash: ‘dec72aa6108829bae90dc826a9204c24’,
token_uri: ‘Invalid uri’,
minter_address: null,
rarity_rank: 469,
rarity_percentage: 4.69,
rarity_label: ‘Prime 5%’,
verified_collection: true,
possible_spam: false,
collection_logo: ‘https://i.seadn.io/gae/BdxvLseXcfl57BiuQcQYdJ64v-aI8din7WPk0Pgo3qQFhAUH-B6i-dCqqc_mCkRIzULmwzwecnohLhrcH8A9mpWIZqA7ygc52Sr81hE?w=500&auto=format’,
collection_banner_image: ‘https://i.seadn.io/gae/48oVuDyfe_xhs24BC2TTVcaYCX7rrU5mpuQLyTgRDbKHj2PtzKZsQ5qC3xTH4ar34wwAXxEKH8uUDPAGffbg7boeGYqX6op5vBDcbA?w=500&auto=format’
}

With the NFT API, you possibly can seamlessly combine NFT knowledge into your NFT market, Web3 recreation, or different platform that wants this info! 

If you wish to discover all our premier interfaces, please take a look at our official Web3 API web page! 

Abstract: The right way to Get NFT Balances with One RPC Name 

Querying the NFT balances of a pockets generally is a time-consuming and resource-intensive course of. With typical strategies, it takes a number of requests and quite a lot of handbook knowledge aggregation, making it a bothersome job. Thankfully, you now have the choice to streamline your developer expertise utilizing Moralis’ Prolonged RPC Strategies. 

Wallet with NFTs and tokens on a platform.

Our Prolonged RPC Strategies make querying decoded knowledge utilizing RPC nodes a breeze. With single RPC requests, now you can fetch NFT balances, token balances, decoded transactions, token costs, and rather more. 

For example, take a look at our eth_getNFTBalances methodology in motion, exhibiting you the way simple it’s to get NFT balances with only one RPC name: 

import fetch from ‘node-fetch’;

const choices = {
methodology: ‘POST’,
headers: {
settle for: ‘software/json’,
‘content-type’: ‘software/json’
},
physique: JSON.stringify({
“jsonrpc”: “2.0”,
“id”: 1,
“methodology”: “eth_getNFTBalances”,
“params”: [
{
“address”: “0xDc597929101c2DE50c97D43C8EA3A372Bf55fdc0”,
“limit”: 10,
}
]
})
};

fetch(‘YOUR_NODE_URL’, choices)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));

In return for calling the script above, you’ll get the total NFT stability of the desired pockets, enriched with metadata, assortment knowledge, and rather more. Right here’s what it would appear to be: 

{
jsonrpc: ‘2.0’,
id: 1,
consequence: {
//…
consequence: [
{
amount: ‘1’,
token_id: ‘1919’,
token_address: ‘0xbd3531da5cf5857e7cfaa92426877b022e612cf8’,
contract_type: ‘ERC721’,
owner_of: ‘0xdc597929101c2de50c97d43c8ea3a372bf55fdc0’,
last_metadata_sync: ‘2024-08-25T23:35:51.384Z’,
last_token_uri_sync: ‘2024-08-25T23:35:50.893Z’,
metadata: ‘{“attributes”:[{“trait_type”:”Background”,”value”:”Mint”},{“trait_type”:”Skin”,”value”:”Olive Green”},{“trait_type”:”Body”,”value”:”Turtleneck Pink”},{“trait_type”:”Face”,”value”:”Eyepatch”},{“trait_type”:”Head”,”value”:”Wizard Hat”}],”description”:”A set 8888 Cute Chubby Pudgy Penquins sliding round on the freezing ETH blockchain.”,”picture”:”ipfs://QmNf1UsmdGaMbpatQ6toXSkzDpizaGmC9zfunCyoz1enD5/penguin/1919.png”,”title”:”Pudgy Penguin #1919″}’,
block_number: ‘19754671’,
block_number_minted: null,
title: ‘PudgyPenguins’,
image: ‘PPG’,
token_hash: ‘cbd8bd0901f422afb88e76615e3d2a1a’,
token_uri: ‘https://ipfs.moralis.io:2053/ipfs/bafybeibc5sgo2plmjkq2tzmhrn54bk3crhnc23zd2msg4ea7a4pxrkgfna/1919’,
minter_address: null,
verified_collection: true,
possible_spam: false,
collection_logo: ‘https://i.seadn.io/gae/yNi-XdGxsgQCPpqSio4o31ygAV6wURdIdInWRcFIl46UjUQ1eV7BEndGe8L661OoG-clRi7EgInLX4LPu9Jfw4fq0bnVYHqg7RFi?w=500&auto=format’,
collection_banner_image: ‘https://i.seadn.io/gcs/recordsdata/8a26e3de0f309089cbb1e5ab969fc0bc.png?w=500&auto=format’
},
//…
]
}
}

That’s it; it doesn’t should be tougher to get NFT balances utilizing RPC nodes. 

In the event you favored this tutorial on methods to get NFT balances with one RPC name, contemplate testing extra content material right here on the weblog. For instance, discover our Blockchain Deal with Labeling API. 

Additionally, for those who want to begin utilizing our Prolonged RPC Strategies your self, don’t overlook to enroll with Moralis. You possibly can create an account at no cost, supplying you with entry to all our premier growth instruments.



Source link

Tags: BalancesCallMoralisNFTRPCWeb3
Previous Post

Elon Musk and Tesla Triumph in Dogecoin Manipulation Case

Next Post

Macron Denies Any Involvement in Durov’s Visit to France

News BlockFin

News BlockFin

Related Posts

How to Trick ChatGPT and Get Paid ,000
Web3

How to Trick ChatGPT and Get Paid $50,000

June 3, 2025
Best Short-Form AI Video Generator? Kling 2.1 vs Google Veo 3
Web3

Best Short-Form AI Video Generator? Kling 2.1 vs Google Veo 3

June 1, 2025
How smart EOAs are redefining the wallet experience
Web3

How smart EOAs are redefining the wallet experience

May 31, 2025
Nigel Farage Pledges to Slash Crypto Capital Gains, Force UK Bitcoin Reserve
Web3

Nigel Farage Pledges to Slash Crypto Capital Gains, Force UK Bitcoin Reserve

May 31, 2025
Ethereum Games ‘Realms of Alurya’ and ‘Wonder Wars’ Latest to Go Offline
Web3

Ethereum Games ‘Realms of Alurya’ and ‘Wonder Wars’ Latest to Go Offline

May 30, 2025
Binance Labs backed Web3 Startup with prominent founders Mario Ho and Jackson Wang to Launch Non-Fungible RWA Protocol Ecosystem
Web3

Binance Labs backed Web3 Startup with prominent founders Mario Ho and Jackson Wang to Launch Non-Fungible RWA Protocol Ecosystem

May 30, 2025
Next Post
Macron Denies Any Involvement in Durov’s Visit to France

Macron Denies Any Involvement in Durov's Visit to France

Fiat Currency vs Cryptocurrency: Key Differences

Fiat Currency vs Cryptocurrency: Key Differences

El Salvador’s Bitcoin Adoption Falls Short, Bukele Admits

El Salvador's Bitcoin Adoption Falls Short, Bukele Admits

Facebook Twitter Youtube Youtube RSS
News BlockFin

News BlockFin delivers the latest cryptocurrency and blockchain news, expert market analysis, and in-depth articles. Stay informed with round-the-clock updates and insights from the world of digital currencies.

CATEGORIES

  • Altcoin
  • Analysis
  • Bitcoin
  • Blockchain
  • Crypto Exchanges
  • Crypto Updates
  • DAO
  • Ethereum
  • Metaverse
  • NFT
  • Regulations
  • Scam Alert
  • Sustainability
  • Uncategorized
  • Web3

SITEMAP

  • About Us
  • Advertise With Us
  • Disclaimer
  • Privacy Policy
  • DMCA
  • Cookie Privacy Policy
  • Terms and Conditions
  • Contact Us

Copyright © 2024 News BlockFin.
News BlockFin is not responsible for the content of external sites.

No Result
View All Result
  • Home
  • Bitcoin
  • Crypto Updates
    • Crypto Updates
    • Altcoin
    • Ethereum
    • Crypto Exchanges
  • Blockchain
  • NFT
  • Metaverse
  • Web3
  • Analysis
  • Regulations
  • Scams

Copyright © 2024 News BlockFin.
News BlockFin is not responsible for the content of external sites.