This guide demonstrates how to use the Neynar SDK to fetch all mint actions relevant to a contract address (and optionally tokenId for ERC1155s) given a user’s Ethereum address.
// npm i @neynar/nodejs-sdk
import { NeynarAPIClient } from "@neynar/nodejs-sdk";
// make sure to set your NEYNAR_API_KEY .env
// don't have an API key yet? get one at neynar.com
const client = new NeynarAPIClient(process.env.NEYNAR_API_KEY);
const FID = 3;
const response = await client.lookupCustodyAddressForUser(FID);
const custodyAddress = response.result.custodyAddress;
// Farcats contract address
const contractAddress = "0x9340204616750cb61e56437befc95172c6ff6606";
const relevantMints = await client.fetchRelevantMints(
custodyAddress,
contractAddress
);
console.log(relevantMints);
{
"mints": [
{
"minter": {
"object": "user",
"fid": 129,
"custody_address": "0xf6fd7deec77d7b1061435585df1d7fdfd4682577",
"username": "phil",
"display_name": "phil",
"pfp_url": "https://i.imgur.com/sx6qqM7.jpg",
"profile": {
"bio": {
"text": "Building @brightmoments - an IRL NFT gallery DAO. https://brightmoments.io | @purple #15",
"mentioned_profiles": []
}
},
"follower_count": 14867,
"following_count": 1146,
"verifications": [
"0x18b7511938fbe2ee08adf3d4a24edb00a5c9b783",
"0x925afeb19355e289ed1346ede709633ca8788b25"
],
"active_status": "active"
},
"tx_hash": "0x2ed2ebb4b048677133eda3a8609bae694d2ba730c7fa2082691f508e711b6075",
"block_number": 17610874,
"contract_address": "0x9340204616750cb61e56437befc95172c6ff6606",
"token_id": "353"
},
// other mints
]
}
Was this page helpful?