How to get nft transfers
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 transfers
In order to get nft transfers, Blocklens provides you a getNftTransfers endpoint to do so.
import Blocklens from "blocklens-sdk";
const blocklens = new Blocklens();
blocklens.init({ apiKey: "YOUR_API_KEY" });
const runApis = async () => {
const response = await blocklens.ETH_MAINNET.getNftTransfers();
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:
{
"page": 1,
"limit": 20,
"cursor": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjB4ZmZjNTU4QmMyZkVGMEQ0Mjk1ZDdjRTk1RTM3OTUxOEVBQTY3ODlFM181NzBfMHhhY2QyOWY2Njk0YmYwNWM1ZDA4YzczZDdiMzZiYTgwOWMyYWUwNzJlZDA4NGY1YTQ1NmZmZTZhMzBlYWFjNTEzXzI0NSIsInBhZ2UiOjEsImlhdCI6MTY5NzA4NTA4OX0.3iqR0jKiF4V_JLyWl6JTbXDGTOC1HvH6Q108LDdLbMk",
"total_items": 1,
"data": [
{
"token_address": "0xfffb5474f5B2E4801fFBC2155275a0E8dDC615FE",
"contract_type": "ERC721",
"token_id": "3",
"block_hash": "0x958f7d11ad3b9dbe1a076e05db9973705e18b9c9279a31edeef10c2457048dff",
"block_number": 18245652,
"transaction_hash": "0xd886f808cae3d6e9f94c0781a5fa3aafe4ef9a8ea32b4d74c5a6a50c367bdbd2",
"log_index": 201,
"from": "0x0000000000000000000000000000000000000000",
"to": "0xb0bf6F6Fd3C8bD194d94d39a41FcB99FdFfb5273",
"amount": "1",
"operator": null,
"timestamp": 1696042235
}
]
}
Congratulations 🥳 you just found the get nft transfers 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.