Code Monkey home page Code Monkey logo

airdropsol's Introduction

Airdrop SOL into wallet based on nft count or To send SPL Token to user

A NodeJS Application to airdrop SOL to users wallet based on NFTs Count for a particular collection.

Contact @statikdev for snapshot of wallets for a particular collection

Usecase - If you have a royalty wallet for NFT holders and have snapshot of wallets taken and wants to airdrop SOL then use this repo.

This has been tested on Devnet and Mainnet both but I would recommend you to first do the setup and try on devnet and then try on mainnet.

Must have installed

Solana CLI
Node JS

How to use

  • yarn

  • yarn build

  • solana config get - To check which RPC you are connected to

  • solana config set --url "mainnet-beta" - To connect to mainnet for usage

  • solana config set --url "devnet" - To connect to devnet for usage

How to use commands

  • create_compatible_format -Contact @statikdev for snaphot for the particular collection and then create a folder and use that path to create a compatible format to airdrop or If you have a json file in this format then you can skip the first part and create a folder results and create a json file in below format and name this file as airdrop_pubKeys.json
[
   {
       "pubKey": "8mmvKNsCiUnUXacDaMeoxA7PgtNiHqdsRDpBGPZyvST",
       "count": 4
   },
   {
       "pubKey": "ELPPaNSHKLMUXNEkmRazUonocDHjVVZCJ8NuQiLsGyu",
       "count": 4
   },
   {
       "pubKey": "3UvbPQZJM8vtYg28nRMgbdjfZL3YbGaepNikUwn2tQZ",
       "count": 2
   }
]
  • count_total_items - Counts the total number of items which is generally equals to collection size
  • remove_from_list - Create a JSON file with bunch of addresses which needs to be removed from this before processing. Add secondary wallet addresses

            Digital Eyes - "F4ghBzHFNgJxV4wEQDchU5i7n4XWWMBSaq7CuswGiVsr"
            Magic Eden -   "GUfCR9mK6azb9vcpsxgXyj7XRPAKJd4KMHTTVvtncGgp"
            Solanart -     "3D49QorJyNaL4rcpiynbuS3pRH4Y7EXEM6v6ZGaqfFGK"
    Like this and add addresses which you don't want to aidrop into this file
           [
                  "F4ghBzHFNgJxV4wEQDchU5i7n4XWWMBSaq7CuswGiVsr",
                  "GUfCR9mK6azb9vcpsxgXyj7XRPAKJd4KMHTTVvtncGgp",
                  "3D49QorJyNaL4rcpiynbuS3pRH4Y7EXEM6v6ZGaqfFGK"
           ]
  • count_wallets - Counts the total number of users which are getting airdropped
  • calculate_per_wallet_drop - Calculate the number which each wallet will get generally its (ROYALTY_WALLET_BALANCE / No. Of Items) In SOL
  • verify_balance - Just for verification
  • send_sol - To airdrop users SOL based on NFTs they have. Enter the price in this command which we got from calculate_per_wallet_drop.
  • send_spl - To airdrop users the SPL Token

Commands

1. node build/cli.js create_compatible_format -p {FILE_PATH}
2. node build/cli.js count_total_items
3. node build/cli.js remove_from_list -r {FILE_PATH}
4. node build/cli.js count_total_items
5. node build/cli.js count_wallets
6. node build/cli.js calculate_per_wallet_drop -k {WALLET_PATH} -e "devnet"
7. node build/cli.js verify_balance -k {WALLET_PATH} -e "devnet"
8. node build/cli.js send_sol -p  {PRICE_PER_WALLET_PER_ITEM} -k {WALLET_PATH}
9. node build/cli.js send_spl -p {PATH_TO_FILE_CHECK_EXAMPLE_AIRDOP_SOL} -k {WALLET_PATH}

Logging

  • A results folder would be created which contains the response.json which have all the failed and success tx with signature.

    Contents of response.json file :

    [{
         "pubKey": "2mwMU2WTW5vG6z16xx68Ys5BNkmAe5voU7aHZwLbxdMA",
         "price": 0.01,
         "signature": "\nSignature: 3rtUax1eDJr6w8TJv35cE26qjuvpGfTwGC3xy8MbkEGo9iQeZvVyujpQtDpg6kSuKQxhNYWV3iLXe7TvCPanAmNz\n\n",
         "isSuccess": true
     },
     {
         "pubKey": "2mwMU2WTW5vG6z16xx68Ys5BNkmAe5voU7aHZwLbxdMA",
         "price": 0.000030000000000000004,
         "error": "Command failed: solana transfer -k ./wallet/wallet.json 3tLbZqkECtj66aaLizJUusqbikMNtdi86iSey56L5eEA 4 
             --allow-unfunded-recipient\nError: Account 9vpsmXhZYMpvhCKiVoX5U8b1iKpfwJaFpPEEXF7hRm9N has insufficient funds for spend (4 SOL) + fee (0.000005)",
         "isSuccess": false
     }]
     

Upcoming Changes

  • Snapshot of wallet for particular collection
  • Get metadata for a list of mint
  • Get metadata with token id for all collection
  • Update Metadata for a given collection

Need to work upon

  • Better error handling
  • Use sendTransactionWithRetry

License

MIT

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Tip

If you found out it useful :

solana transfer -k <PATH_TO_YOUR_WALLET_KEYPAIR> DUkwnGBU78HGAmeKrJRt4sjdZoDgxQQN7z6T69rwS9b8 <AMOUNT> 

airdropsol's People

Contributors

heisenberglit avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.