How do I airdrop a large list of addresses on Stacks?

Carole
Carole
  • Updated

Please note that this process only applies to public and edition collections launched on the Gamma site.

Because of the transaction size limit in Stacks transactions, you can't airdrop a large list of addresses through our launchpad when you deploy your contract.

There isn't a typical way to deal with this, but here's one way: You can do it by making custom contract calls.

Overview: Since contract owners can admin-mint, we'll use that to mint and transfer the NFT to your airdrop list by deploying a custom contract.

 

1. Visit https://create.gamma.io 

2. Select your desired collection

3. (Important) During the mint step, make sure to disable the minting status.

Contract owner can mint even the collection is paused.

4. (Important) Please set the current price to zero.


If you're adding a mint price after the airdrop, you can later adjust the mint price using the contract manager: https://support.gamma.io/hc/en-us/articles/6011061378963-How-can-I-manage-my-Stacks-collection-deployed-from-the-Collection-Mint-Page#h_01FSPY1Y96T31004DMT3ZPSJEE 

 

5. Submit your collection and wait for approval.

6. While waiting for approval, prepare your list of airdrops.

Below is the predefined structure for the airdrop contract. Please modify only the necessary variables as instructed below:

```

(define-private (airdrop (id uint) (recipient principal))

    (begin

        (try! (contract-call? '[CONTRACT ID] claim))

        (try! (contract-call? '[CONTRACT ID] transfer id tx-sender recipient))

        (ok true)

    )

)





(airdrop u1 '[AIRDROP ADDRESS])

(airdrop u2 '[AIRDROP ADDRESS])




...

..

.

and so on




```


[CONTRACT ID]is your collection contract. You can find it on your collection details page by clicking the contract link under the collection description.

[AIRDROP ADDRESS]will be your airdrop Stacks address.

Please take note of the `'` and please don't remove it.

 

u1, u2 and etc are NFT IDs to be minted. These must be set incrementally based on the NFT you want to airdrop and must not exceed your total collection size.

 

In the example above, we created a sample public mint with 10 NFTs and distributed them to different addresses.

Collection link: https://stacks.gamma.io/collections/blobs-airdrop
Collection contract: https://explorer.hiro.so/txid/SP2XMGYYTA1KRBKBYJHTW8CFWB2QYZKZE4BMHG3PJ.blobs-airdrop

Collection contract id: SP2XMGYYTA1KRBKBYJHTW8CFWB2QYZKZE4BMHG3PJ.blobs-airdrop

We replace [CONTRACT ID] with the collection contract ID, which is SP2XMGYYTA1KRBKBYJHTW8CFWB2QYZKZE4BMHG3PJ.blobs-airdrop and replace [AIRDROP ADDRESS] with the Stacks address for the airdrop.

```
(define-private (airdrop (id uint) (recipient principal))

    (begin

        (try! (contract-call? 'SP2XMGYYTA1KRBKBYJHTW8CFWB2QYZKZE4BMHG3PJ.blobs-airdrop claim))

        (try! (contract-call? 'SP2XMGYYTA1KRBKBYJHTW8CFWB2QYZKZE4BMHG3PJ.blobs-airdrop transfer id tx-sender recipient))

        (ok true)

    )

)




(airdrop u1 'SPFBZVVVN43EF1TFES2PTSYWFT5827GCPV3TZ7ZY)

(airdrop u2 'SP2NHANKC8ENVBC788X7WJRA411TW293EVFMX5NFK)

(airdrop u3 'SP3WBND6QBPX9V9G9W7W0X2BMAW1ZRGQ09K3DYJV4)

(airdrop u4 'SP1DED2GN8CRRT6A29NTEP16BW15VC8VVGHVS9973)

(airdrop u5 'SP1QPDY8KDJZA86E8DK0CAFZ90DNYSTDJ8DK0SPJV)

(airdrop u6 'SP161VKTTXKPF2MCNTTZR4455WAZFFAMM8VAFW9XX)

(airdrop u7 'SP161VKTTXKPF2MCNTTZR4455WAZFFAMM8VAFW9XX)

(airdrop u8 'SPXCHF753FXEPQTN1B0C6TCY8Q1MA5TQ8X89V5J3)

(airdrop u9 'SPXCHF753FXEPQTN1B0C6TCY8Q1MA5TQ8X89V5J3)

(airdrop u10 'SPXCHF753FXEPQTN1B0C6TCY8Q1MA5TQ8X89V5J3)




```

Here's the link to the deployed custom contract: https://explorer.hiro.so/txid/SP2XMGYYTA1KRBKBYJHTW8CFWB2QYZKZE4BMHG3PJ.blobs-demo-airdrop?chain=mainnet 

Notice that there are repeating addresses. These are useful if you want to airdrop multiple NFTs to a single address. If you're unsure about your custom contract and want to double-check before putting it out there, you can reach us on Discord at https://discord.gamma.io

7. Finally, you can now execute and deploy the custom contract.

Visit https://explorer.hiro.so/sandbox/deploy?chain=mainnet

You will be asked to log in to your wallet. Please make sure you use the wallet address that you used to launch your collection.


Once you log in, you'll find the Write & Deploy tab. It will have a pre-filled sample contract name and code. Just clear those out.


Now, copy paste your custom contract code to the editor field.

You can choose any name you want for the contract. In our case, we use "blobs-airdrop-demo".

Finally, click deploy and approve the transaction.





You can download the sample custom contract here and use https://vscode.dev to edit the file.

 

If you're airdropping thousands of addresses, you might need to batch them and deploy multiple custom contracts if the contract deployment is failing.

 

For example:

Contract 1 will distribute NFT tokens from u1 to u1000

Contract 2 will distribute NFT tokens from u1001 to u2000

and so on...

In closing, if you're doing lots of airdrops, you'll have to pay more for gas fees. You can check the suggested fee for a function call here.

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.