Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
AAYUSH-GUPTA-coder committed Aug 9, 2022
0 parents commit 2da348d
Show file tree
Hide file tree
Showing 24 changed files with 38,036 additions and 0 deletions.
11 changes: 11 additions & 0 deletions hardhat/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
node_modules
.env
coverage
coverage.json
typechain
typechain-types

#Hardhat files
cache
artifacts

13 changes: 13 additions & 0 deletions hardhat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Sample Hardhat Project

This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a script that deploys that contract.

Try running some of the following tasks:

```shell
npx hardhat help
npx hardhat test
GAS_REPORT=true npx hardhat test
npx hardhat node
npx hardhat run scripts/deploy.js
```
39 changes: 39 additions & 0 deletions hardhat/contracts/Whitelist.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

error ONLY_OWNER_CAN_ACT();
error ALREADY_MEMBER();

contract Whitelist {
// Create a mapping of whitelistedAddresses
// if an address is whitelisted, we would set it to true, it is false by default for all other addresses.
mapping(address => bool) public whitelistedAddresses;

// numAddressesWhitelisted would be used to keep track of how many addresses have been whitelisted
uint16 public numAddressesWhitelisted; // 65,536
address public owner;

constructor(address _ownerAddr) {
owner = _ownerAddr;
}

modifier onlyOwner() {
if (msg.sender != owner) {
revert ONLY_OWNER_CAN_ACT();
}
_;
}

/**
addAddressToWhitelist - This function adds the address of the sender to the
whitelist
*/
function addAddressToWhitelist(address _address) public onlyOwner {
if (whitelistedAddresses[_address]) {
revert ALREADY_MEMBER();
}
whitelistedAddresses[_address] = true;
// Increase the number of whitelisted addresses
numAddressesWhitelisted += 1;
}
}
24 changes: 24 additions & 0 deletions hardhat/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require("@nomiclabs/hardhat-waffle");
require("@nomiclabs/hardhat-etherscan");
require("dotenv").config({ path: ".env" });

const ALCHEMY_API_KEY_URL = process.env.ALCHEMY_API_KEY_URL;

const MUMBAI_PRIVATE_KEY = process.env.MUMBAI_PRIVATE_KEY;

const POLYGONSCAN_KEY = process.env.POLYGONSCAN_KEY;

module.exports = {
solidity: "0.8.4",
networks: {
mumbai: {
url: ALCHEMY_API_KEY_URL,
accounts: [MUMBAI_PRIVATE_KEY],
},
},
etherscan: {
apiKey: {
polygonMumbai: POLYGONSCAN_KEY,
},
},
};
Loading

0 comments on commit 2da348d

Please sign in to comment.