1/5
## Deploying a Merkle Airdrop Contract We've built our Merkle airdrop contract, and now we're going to deploy it to a test network so we can interact with it and experiment with the functionality. We will be writing some deployment scripts and tests to ensure that the deployment process works as expected. ### Deploying the Merkle Airdrop Contract Let's create a new file called `deploy_merkle.py`. ```python from src import snek_token from eth_utils import to_wei from script.make_merkle import generate_merkle_tree INITIAL_SUPPLY = to_wei(100, "ether") def deploy_merkle(): token = snek_token.deploy(INITIAL_SUPPLY) _root = generate_merkle_tree() airdrop_contract = merkle_airdrop.deploy(root, token.address) token.transfer(airdrop_contract.address, INITIAL_SUPPLY) print(f"Deployed airdrop contract at {airdrop_contract.address}") return airdrop_contract def moccasin_main(): return deploy_merkle() ``` This script will first deploy the token contract with an initial supply of 100 Ether. Then, it will generate the Merkle tree and deploy the Merkle airdrop contract, providing the root of the tree and the token contract address to the deployment function. Lastly, the script will transfer the initial token supply to the airdrop contract's address. ### Testing the Deployment We can now test the deployment script by running the following command in our terminal: ```bash mox run deploy_merkle ``` This will execute the `deploy_merkle` function and display the address of the deployed airdrop contract. This testing process allows us to ensure the functionality of the deployment script and verify that all the necessary steps are completed correctly.
A comprehensive guide to deploying a Merkle Airdrop contract with Python. The lesson covers deploying the ERC20 token, generating a Merkle tree, deploying the airdrop contract, and testing the deployed contract with Mox.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
How to build a DeFi stablecoin and customized NFT
How to deploy your smart contract on ZKsync with Moccasin
Advanced testing techniques like stateful and stateless Python fuzzing
How to write algorithmic trading scripts in Python
Hashing signatures, proxies, delegate calls, upgradable contracts, random numbers, and more!
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
On-chain Data Analyst
$59,000 - $139,000 (avg. salary)
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on April 21, 2025
Duration: 2h 21min
Duration: 1h 58min
Duration: 2h 55min
Duration: 1h 55min
Duration: 46min
Course Overview
About the course
How to build a DeFi stablecoin and customized NFT
How to deploy your smart contract on ZKsync with Moccasin
Advanced testing techniques like stateful and stateless Python fuzzing
How to write algorithmic trading scripts in Python
Hashing signatures, proxies, delegate calls, upgradable contracts, random numbers, and more!
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
On-chain Data Analyst
$59,000 - $139,000 (avg. salary)
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on April 21, 2025