-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature/airdrop contract & scripts (#90)
* create airdrop contract & scripts --------- Co-authored-by: Suraj Kohli <[email protected]>
- Loading branch information
1 parent
095a386
commit 681310b
Showing
15 changed files
with
1,402 additions
and
839 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ artifacts/ | |
deployments/localhost/ | ||
.vscode | ||
.* | ||
gas-report.txt | ||
gas-report.txt | ||
utils/Airdrop.xlsx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"]; |
Large diffs are not rendered by default.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
deployments/goerli/solcInputs/61b0a4130b163e0e667be7609d5f7a40.json
Large diffs are not rendered by default.
Oops, something went wrong.
188 changes: 188 additions & 0 deletions
188
deployments/goerli/solcInputs/ab50ec945daa8796ee208c7bd379e17e.json
Large diffs are not rendered by default.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
deployments/goerli/solcInputs/bae2f893e769194641c1f47892dcdc52.json
Large diffs are not rendered by default.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
deployments/goerli/solcInputs/e96fd935730ea57cca17eee492896adf.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.