Build a Claimable Universal Airdrop
Welcome! In this tutorial, you'll build a Universal Airdrop system that revolutionizes cross-chain token distribution. Unlike traditional airdrops that require deploying contracts on every blockchain, this universal approach lets you deploy once on Push Chain and enable users from any blockchain (Ethereum, Solana, Polygon, etc.) to claim their tokens seamlessly.
Why Universal Airdrops?
The beauty of this system lies in its efficiency and cross-chain compatibility:
- Single Deployment: Deploy your airdrop contract once on Push Chain instead of managing multiple contracts across different networks
- Cross-Chain Claims: Users from Ethereum, Solana, Polygon, and other chains can all claim tokens from the same contract
- No Multi-Chain Token Deployment: Keep your ERC-20 token on one chain while enabling universal claiming
- User Simplicity: Recipients can claim their tokens using their preferred wallet on their own chain, making the process seamless and familiar
We'll build the complete flow:
- Generate Merkle proofs with cross-chain recipient data
- Deploy a universal Merkle claim contract to Push Chain
- Create a UI for recipients to claim their tokens from any chain
- Full Application
- Deploy ERC-20 Token
- Deploy Universal Airdrop
- Generate Merkle Tree
Here are the steps to deploy the TestToken
contract on Remix below:
- Set the Solidity compiler version to 0.8.22 in Remix.
- For Environment, choose Injected Provider (connect your wallet to Push Chain Donut Testnet).
- When deploying
TestToken
, pass constructor arguments: token name and symbol (e.g.,TestToken
andTEST
).
Note: If you need
$PC
tokens to deploy the contract, you can get them from the Push Chain Faucet.
Understanding the TestToken
contract
- Inherits from ERC20: Uses OpenZeppelin's battle-tested ERC20 implementation
- Constructor: Mints 1 million tokens to the deployer upon creation
- Mint function: Allows additional tokens to be minted (useful for testing)
- Standard ERC20 features: Transfer, balance checking, approvals, etc.
Here are the steps to deploy the UniversalAirdrop
contract on Remix below:
- Set the Solidity compiler version to 0.8.22 in Remix.
- For Environment, choose Injected Provider (connect your wallet to Push Chain Donut Testnet).
- When deploying
UniversalAirdrop
, pass constructor arguments: token address deployed in the previous step and merkle root you can get from the next step.
Note: If you need
$PC
tokens to deploy the contract, you can get them from the Push Chain Faucet.
Understanding the UniversalAirdrop
contract
- Merkle Proof Verification: Uses OpenZeppelin's
MerkleProof.verify()
to validate inclusion proofs - Universal Support: Accepts any recipient address format (the proof generation handles the conversion)
- Reentrancy Protection: Uses
ReentrancyGuard
to prevent reentrancy attacks - Claim Tracking: Maps claim IDs (address + origin chain) to prevent double claims per recipient per origin chain
- Owner Controls: Allows updating the Merkle root for future airdrop rounds
In this part, we'll create a Merkle proof generator that produces cryptographic proofs for a universal airdrop system. This generator will create a Merkle tree from recipient data and generate proofs that can be verified on-chain.
The dependencies you'll need for the Merkle proof generator:
@openzeppelin/merkle-tree
: Core library for building Merkle trees with cryptographic hashingviem
: Ethereum library providingkeccak256
hashing and ABI encoding utilitiesbs58
: Base58 encoding/decoding library for Solana addresses
Each entry in the array represents a recipient with:
recipient
: Wallet address (format varies by blockchain)chainNamespace
: Blockchain type ("eip155", "solana", "push", etc.)chainId
: Specific chain identifier within that namespaceamount
: Token amount in smallest units (as string to avoid precision issues)
How the Merkle proof works
The proof allows anyone to verify that a specific recipient is included in the airdrop without revealing the entire recipient list. The smart contract can verify the proof by:
- Recalculating the leaf hash from the recipient's data
- Using the provided proof hashes to reconstruct the path to the root
- Comparing the reconstructed root with the stored
merkleRoot
✅ Next steps: You'll use the
merkleRoot
when deploying the UniversalAirdrop contract, and the frontend will use each recipient'sproof
array to submit claims on-chain.
Conclusion
You generated Merkle proofs from an airdrop list, deployed a Universal Merkle‑verified airdrop contract to Push Chain Donut Testnet, and added a claim UI. With this universal airdrop system, users from different chains can claim their tokens seamlessly using Push Chain's Universal External Accounts (UEA) system.