Learn how to get all Farcaster users who own a specific token, NFT, or POAP, or a min amount of that token. Get combinations of NFTs or POAPs + Farcaster, e.g. Has POAP1 and POAP2 and has Farcaster
đĨ Token Holders
Airstack provides easy-to-use APIs for enriching Farcaster applications and integrating on-chain and off-chain data with Farcaster.
In this tutorial, you will learn how to fetch all Farcaster users who own a specific ERC20 token, NFT (ERC721 and ERC1155), or POAPs.
In addition, you will also learn how to fetch common Farcaster users that hold two different assets at the same time, e.g. Farcaster users that hold both EthLisbon and EthCC[6] POAP.
Table Of Contents
In this guide you will learn how to use Airstack to:
defformat_function(data): result = []if data and'TokenBalances'in data and'TokenBalance'in data['TokenBalances']:for item in data['TokenBalances']['TokenBalance']:if'owner'in item and'socials'in item['owner']and item['owner']['socials'] isnotNone: result.append(item['owner']['socials']) result = [item for sublist in result for item in sublist]return result
The final result will the the list of all common holders in an array:
[ {"profileName":"vbuterin","userId":"5650","userAssociatedAddresses": ["0xadd746be46ff36f10c81d6e3ba282537f4c68077","0xd8da6bf26964af9d7eed9e03e53415d37aa96045" ] }// ... other token holders]
Get Holders of NFT That Has Farcaster
Fetching
You can get all holders of NFT that has Farcaster:
defformat_function(data): result = []if data and'TokenBalances'in data and'TokenBalance'in data['TokenBalances']:for item in data['TokenBalances']['TokenBalance']:if'owner'in item and'socials'in item['owner']and item['owner']['socials'] isnotNone: result.append(item['owner']['socials']) result = [item for sublist in result for item in sublist]return result
The final result will the the list of all common holders in an array:
[ {"profileName":"durtis","userId":"11926","userAssociatedAddresses": ["0xcb0b3404b7d5db8622511427c09a1bba450d3c0f","0xe5ca890a0ef2f128eb3267e4711c6bf3306ec024" ] }// ... other token holders]
Get Holders of POAP That Has Farcaster
Fetching
You can get all holders of POAP that has Farcaster:
defformat_function(data): result = []if data and'Poaps'in data and'Poap'in data['Poaps']:for item in data['Poaps']['Poap']:if'owner'in item and'socials'in item['owner']and item['owner']['socials'] isnotNone: result.append(item['owner']['socials']) result = [item for sublist in result for item in sublist]return result
The final result will the the list of all common holders in an array:
[ {"profileName":"megankaspar","userId":"7361","userAssociatedAddresses": ["0xadf37a0d500c748edb1c689a1be26472e583dcb5","0x4455951fa43b17bd211e0e8ae64d22fb47946ade","0xfaedb341b0faced023099d7b0ccd23c2ec5ed7a5" ] }// ... other token holders]
Get Holders That Held Specific Amount of ERC20 Token
Fetching
You can get all holders of an ERC20 token that have a minimum amount held in their balances which also have Farcaster:
defformat_function(data): result = []if data and'TokenBalances'in data and'TokenBalance'in data['TokenBalances']:for item in data['TokenBalances']['TokenBalance']:if'owner'in item and'socials'in item['owner']and item['owner']['socials'] isnotNone: result.append(item['owner']['socials']) result = [item for sublist in result for item in sublist]return result
The final result will the the list of all common holders in an array:
[ {"profileName":"durtis","userId":"11926","userAssociatedAddresses": ["0xcb0b3404b7d5db8622511427c09a1bba450d3c0f","0xe5ca890a0ef2f128eb3267e4711c6bf3306ec024" ] }// ... other token holders]
Get Common Holders of 2 ERC20 Tokens That Has Farcaster
Fetching
You can fetch the common holders of two given ERC20, e.g. USDT and USDC:
defformat_function(data): result = []if data and'TokenBalances'in data and'TokenBalance'in data['TokenBalances']:for item in data['TokenBalances']['TokenBalance']:if'owner'in item and'tokenBalances'in item['owner']:for token_balance in item['owner']['tokenBalances']:if'owner'in token_balance and'socials'in token_balance['owner']andlen(token_balance['owner']['socials'])>0: result.append(token_balance['owner']['socials']) result = [item for sublist in result for item in sublist]return result
The final result will the the list of all common holders in an array:
[ {"profileName":"vbuterin","userId":"5606","userAssociatedAddresses": ["0xadd746be46ff36f10c81d6e3ba282537f4c68077","0xd8da6bf26964af9d7eed9e03e53415d37aa96045" ] }// ... other token holders]
Get Common Holders of Two POAPs and That Has Farcaster
defformat_function(data): result = []if data and'Poaps'in data and'Poap'in data['Poaps']:for poap in data['Poaps']['Poap']:if'owner'in poap and'poaps'in poap['owner']and poap['owner']['poaps'] isnotNone:for owner_poap in poap['owner']['poaps']:if'owner'in owner_poap and'socials'in owner_poap['owner']and owner_poap['owner']['socials'] isnotNone: result.append(owner_poap['owner']['socials']) result = [item for sublist in result for item in sublist]return result
The final result will the the list of all common holders in an array:
defformat_function(data): result = []if data isnotNoneand'TokenBalances'in data and'TokenBalance'in data['TokenBalances']:for item in data['TokenBalances']['TokenBalance']:if'owner'in item and'poaps'in item['owner']and item['owner']['poaps'] isnotNone:for poap in item['owner']['poaps']:if'owner'in poap and'socials'in poap['owner']and poap['owner']['socials'] isnotNone: result.append(poap['owner']['socials']) result = [item for sublist in result for item in sublist]return result
The final result will the the list of all common holders in an array: