waves_logo Docs
  • Overview
    Overview
  • How-to Guides
    • Reading Blockchain Data
      Reading Blockchain Data
    • Creating & Broadcasting Transactions
      Creating & Broadcasting Transactions
    • Tokenization
      Tokenization
    • Airdrop
      Airdrop
    • Payments
      Payments
    • Exchange Tokens
      Exchange Tokens
    • Simple Voting
      Simple Voting
    • List as argument
      List as argument
    How-to Guides
  • Waves Smart Contracts
    Waves Smart Contracts
  • dApp
    • Creating & Launching dApp
      Creating & Launching dApp
    dApp
  • Smart Account
    • Creating smart account
      Creating smart account
    • Creating and deploying a script manually
      Creating and deploying a script manually
    • Video tutorials
      • Introduction to the Waves blockchain, Waves Smart Accounts and Waves Smart Assets
        Introduction to the Waves blockchain, Waves Smart Accounts and Waves Smart Assets
      • Waves Smart Account with multisignature
        Waves Smart Account with multisignature
      • Waves Smart Account with escrow service
        Waves Smart Account with escrow service
      • Creating multisignature account via Waves IDE tools
        Creating multisignature account via Waves IDE tools
      • Creating multisignature account via Waves Client
        Creating multisignature account via Waves Client
      • Waves console explained
        Waves console explained
      Video tutorials
    Smart Account
  • Smart Asset
    Smart Asset
  • Developer Tools
    • Waves IDE
      Waves IDE
    • Visual Studio Code Extension
      Visual Studio Code Extension
    • Surfboard
      Surfboard
    • Ride REPL
      Ride REPL
    Developer Tools
  • Signer ◆
    Signer ◆
  • Waves API
    • Data Service API
      Data Service API
    • Node REST API
      Node REST API
    • Node gRPC Server
      Node gRPC Server
    • Blockchain Updates
      Blockchain Updates
    Waves API
  • Client Libraries
    • Waves C#
      • Install SDK
        Install SDK
      • Run Code Sample
        • Send Transactions
          Send Transactions
        • Use Crypto Utilities
          Use Crypto Utilities
        • Interact With Node
          Interact With Node
        • Set Up Smart Contracts
          Set Up Smart Contracts
        Run Code Sample
      Waves C#
    • Gowaves
      • Install SDK
        Install SDK
      • Run Code Sample
        • Send Transactions
          Send Transactions
        • Use Crypto Utilities
          Use Crypto Utilities
        • Interact With Node
          Interact With Node
        • Set Up Smart Contracts
          Set Up Smart Contracts
        Run Code Sample
      Gowaves
    • WavesJ
      • Install SDK
        Install SDK
      WavesJ
    • Ts-lib-crypto
      • Install SDK
        Install SDK
      Ts-lib-crypto
    • Waves-PHP
      • Install SDK
        Install SDK
      Waves-PHP
    • PyWaves-CE
      • Install SDK
        Install SDK
      PyWaves-CE
    • Waves-rust
      • Install SDK
        Install SDK
      Waves-rust
    Client Libraries
      • English
      • Русский
      On this page
      waves_logo Docs

          # Airdrop

          Airdrop is sending tokens simultaneously to multiple addresses. As a rule, the airdrop is used as a part of a marketing campaign to promote a project, increase its recognition, and attract investors.

          You can transfer your token to all the active Waves addresses. In this example, we make a list of addresses as follows:

          • get last N blocks from the blockchain;
          • get sender public keys from transactions in these blocks;
          • delete duplicates;
          • convert public keys to addresses.

          Please keep in mind that Waves public nodes have limitations listed in the API limitations of the pool of public nodes article. We recommend to use your own node to perform airdrop.

          Make sure that your account has enough WAVES to pay the fee for asset transfers.

          import requests
          import time
          import pywaves as pw
          
          node_url = 'https://nodes-testnet.wavesnodes.com'
          pw.setNode(node = node_url, chain = 'testnet')
          
          seed = 'insert your seed here'
          my_address = pw.Address(seed=seed)
          
          my_asset = pw.Asset('Ax54puR69NHfxqCE73DkyGHUiRb7Z6tHJZvx6ywWS49')
          airdrop_amount = 100
          
          sender_public_keys = []
          addresses = []
          
          depth = 10000
          
          # Get blockchain height
          blockchain_height = requests.get(f'{node_url}/blocks/height').json()['height']
          
          # Iterate through the last blocks
          for i in range(blockchain_height - depth, blockchain_height):
          
              # Get all the transactions of the block
              try:
                  response =  requests.get(f'{node_url}/blocks/at/{i}')
                  transactions = response.json()['transactions']
              except ValueError:
                  print('Error retrieving block ', i, '\nHTTP response code: ', response)
          
              # Extract public keys
              for transaction in transactions:
                  if transaction['senderPublicKey'] not in sender_public_keys:
                      sender_public_keys.append(transaction['senderPublicKey'])
          
              # time.sleep(1) # Only 1 block per second if you use public Mainnet nodes
          
          # Convert public keys to address
          for public_key in sender_public_keys:
              try:
                  response = requests.get(f'{node_url}/addresses/publicKey/{public_key}')
                  addresses.append(response.json()['address'])
              except ValueError:
                  print('Error getting address from public key ', public_key, '\nHTTP response code: ', response)
          
          # Send token to the addresses
          for address in addresses:
              address_obj = pw.Address(address)
              my_address.sendAsset(address_obj, my_asset, airdrop_amount)
          
          Tokenization
          Payments
          Tokenization
          Payments