How to get nft mints of collection by block number or hash
Prerequisites
Before getting started, make sure you have the following ready:
- Node v.14+
- NPM
Step 1: Setup Blocklens
First register your Blocklens account and get your Blocklens API Key.
Once you have your Blocklens API Key, install the Blocklens SDK in your project.
npm i blocklens-sdk
Step 2: Get NFT mints of collection by block number or hash
In order to get nft mints of collection by block number or hash, Blocklens provides you a getNftMintsOfCollectionByBlockNumberOrHash endpoint to do so.
Here you'll need parameters: address
, block_number_or_hash
.
Once you've obtained all the address
, block_number_or_hash
, you can copy the following code:
import Blocklens from "blocklens-sdk";
const blocklens = new Blocklens();
blocklens.init({ apiKey: "YOUR_API_KEY" });
const runApis = async () => {
const response = await blocklens.ETH_MAINNET.getNftMintsOfCollectionByBlockNumberOrHash("0x6339e5E072086621540D0362C4e3Cea0d643E114", "0x0517e1369f5159852973c47dc335d28b67ccffb238333542f880abc3fe3ab505");
console.log(response);
};
runApis();
Step 3: Run the script
ts-node index.ts
In your terminal, you should see the following JSON response with the data: In your terminal, you should see the following JSON response with the data blocks:
[
{
"token_address": "0x31225ffF34ebB599D018A22d2430c2e4fdE32eCa",
"contract_type": "ERC721",
"token_id": "1",
"block_hash": "0xd3e6974bd02372a60e60399fe71f9f3972b5cb1d409e7751abfcadb302655e19",
"block_number": 922742,
"transaction_hash": "0xe2e18e8831556beff9e08a9f04e0fd38fe290c9b62a49021cfa6b23cbd8900a3",
"log_index": 0,
"from": "0x8a5847fd0e592B058c026C5fDc322AEE834B87F5",
"amount": "1",
"operator": null,
"timestamp": 1650258658,
"block_time": "2022-04-18 05:10:58.0"
}
]
Congratulations 🥳 you just found the get nft mints of collection by block number or hash on multiple chains with only a few lines of code using the Blocklens Wallet API!
API Reference
If you want to know more details on the endpoint and optional parameters, check out:
Support
If you face any trouble following the tutorial, feel free to reach out to our community engineers in our Discord or Forum to get 24/7 developer support.