How to get followers of a channel through Farcaster API and airdrop an NFT to their wallets part 2

filling the blanks and shooting the NFTs

So in the first part, We used Farcaster API, took a snapshot of a channel's followers, and made a query that got the verified addresses of those followers for us. That query had some missing data. Some people, do not have a verified address on Farcaster (mostly new users) or for some reason, their address does not show up on Dune datasets. as you can see here:

I don't like anyone to be left out so, we will use the Farcaster custody address to fill in the blanks. There is a data set called dune.neynar.dataset_farcaster_fnames which contains custody addresses. we join these datasets together with a simple query:

WITH accounts AS (
  SELECT
    fid,
    fname,
    display_name,
    verified_addresses
  FROM dune.neynar.dataset_farcaster_profile_with_addresses
  WHERE
    fid IN (
      SELECT
        fid
      FROM dune.mimg1.dataset_succsess_snapshot_6_11_2024
    )
), custody_address AS (
  SELECT
    fid,
    custody_address
  FROM dune.neynar.dataset_farcaster_fnames
  WHERE
    fid IN (
      SELECT
        fid
      FROM accounts
      WHERE
        verified_addresses = '[]'
    )
)
SELECT
  a.fid,
  a.fname,
  a.display_name,
  a.verified_addresses,
  c.custody_address
FROM accounts AS a
LEFT JOIN custody_address AS c
  ON a.fid = c.fid

I used left outer join because I only wanted custody addresses for accounts that did not have a verified address. For some reason, missing addresses on the farcaster_profile_with_addresses dataset are not NULL, it's just a '[]' (maybe It's null and something is happening and I'm just a noob). Looking at the query results, everything looks okay:

From this point forward, you need to export these results as a CSV and clean them up. Now that we have the addresses we need, We can start looking at options to drop our NFT to these addresses.

There are some options to do that, But for this tutorial, I chose manifold.xyz . after logging in manifold with your wallet, and opening Its studio page, you can click on create and start the dropping process. Manifold gives us some different options as you can see in the picture below:

On the create section, you can make a claim page, a Farcaster mint page, or a burn/redeem page, we don't want to do these, because we want to directly drop the user's address without the user doing anything. What we need is in the mint section. We have only one media, a video Farcaster Artist @n3zz has made for this tutorial, and for that we should either use 1 of 1 or editions. The difference between these two options are evident in the above picture, 1 0f 1 is an ERC-721 token, these tokens are 1 0f 1s and can only have one Holder, So if you mint that to a 1000 addresses, a 1000 unique and numbered tokens will be minted to them. the edition is an ERC-1155 token, each token can have multiple holders. We use Edition for this post.

After choosing editions, you have to either use an existing contract or make a new one, think of the contract as a simple agreement (or protocol) that manages the NFT on the blockchain. we make a new one here.

After clicking on new contract, you can select the network to deploy it, Base is much cheaper to use than the Mainnet so we select that and chose a name and symbol for our contract

On the next page, we have to upload a media file for our NFT:

We just fill in the information and hit save:

On the next page, you can add the recipients of the NFT. I downloaded the template provided on this page, put the addresses in that file, and uploaded it back, you can also change the number of NFTs each address receives in the template file:

Unfortunately manifold only supports 250 addresses for each transaction. So we have to divide our list into 5 files. after hitting the publish key, you have to sign a transaction in your wallet to deploy the smart contract for the first time and right after that sign another transaction to mint the first 250 tokens. after these two transactions are done, you will be directed to this page that shows a summary of your NFT:

from there open the edit tab. In this tab you can edit the media, see the token page on basescan (by clicking on the CA address under contract) and add more recipients ( or in other words, do that second transaction again).

By checking the basescan, I can see that I have indeed sent the NFT to the first 250 addresses.

Now I need to upload the next CSV in the recipients part of the edit page:

and after clicking on publish, another transaction will be initiated in your wallet, when the transaction is done, you can see that the number of holders in the basescan page is increased. This is after my 4th transaction:

These transactions on base cost between 5 to 40 cents each, depending on the number of transfers in the transaction, So if you are getting anything higher like $12, something is probably wrong. I hope you find this two-part tutorial useful, If you have any questions you can find me as @miladgh on farcaster.

Loading...
highlight
Collect this post to permanently own it.
Subscribe to Tinkering Onchain and never miss a post.