Skip to content

Commit

Permalink
feature/airdrop contract & scripts (#90)
Browse files Browse the repository at this point in the history
* create airdrop contract & scripts
---------

Co-authored-by: Suraj Kohli <[email protected]>
  • Loading branch information
RojhatToptamus and KohliSuraj authored Mar 23, 2023
1 parent 095a386 commit 681310b
Show file tree
Hide file tree
Showing 15 changed files with 1,402 additions and 839 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ artifacts/
deployments/localhost/
.vscode
.*
gas-report.txt
gas-report.txt
utils/Airdrop.xlsx
41 changes: 41 additions & 0 deletions contracts/ClayDistributor.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";

contract ClayDistributor {
using SafeERC20 for IERC20;

address public immutable token;
bytes32 public immutable merkleRoot;
uint256 public immutable dropAmount;

mapping(address => bool) public isClaimed;

constructor(address token_, bytes32 merkleRoot_, uint256 dropAmount_) {
token = token_;
merkleRoot = merkleRoot_;
dropAmount = dropAmount_;
}

event Claimed(address indexed user);

function claim(bytes32[] calldata merkleProof) public {
require(isClaimed[msg.sender] == false, "Already Claimed!");

// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(msg.sender));

require(
MerkleProof.verify(merkleProof, merkleRoot, node),
"Invalid Proof!"
);

// Mark it claimed and send the token.
isClaimed[msg.sender] = true;
IERC20(token).safeTransfer(msg.sender, dropAmount);

emit Claimed(msg.sender);
}
}
25 changes: 25 additions & 0 deletions deploy/011_deploy_clay_distributor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* This script deploys the Clay Distributor Contract
*
*/
const func = async function (hre) {
const { deployments, getNamedAccounts } = hre;
const { deploy } = deployments;

const { deployer } = await getNamedAccounts();

const Clay = await deployments.get("ClayToken");
// run build-merkle task to generate Merkle Tree Root
const MerkleTreeRoot = "0x33ec19caac80a438ca65f6149174a5ecdc4ed6fbf4a70858405fa0cff9d58fd6";
const DropAmount = "100";
const DropAmountInWei = ethers.utils.parseUnits(DropAmount, 18);

await deploy("ClayDistributor", {
from: deployer,
args: [Clay.address, MerkleTreeRoot, DropAmountInWei],
log: true,
skipIfAlreadyDeployed: false,
});
};
module.exports = func;
func.tags = ["ClayDistributor"];
158 changes: 158 additions & 0 deletions deployments/goerli/ClayDistributor.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

188 changes: 188 additions & 0 deletions deployments/goerli/solcInputs/ab50ec945daa8796ee208c7bd379e17e.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ require("./tasks/emp-request-withdrawal");
require("./tasks/add-impl-to-finder");
require("./tasks/create-lp");
require("./tasks/setup-finder");
require("./tasks/build-merkle");
require("./tasks/clay-claim");
require("./tasks/transfer-clayToken-ownership");
require("./tasks/transfer-contract-ownership");
require("./tasks/transfer-all-ownerships");
Expand Down
Loading

0 comments on commit 681310b

Please sign in to comment.