Skip to content

Commit

Permalink
whitelist contract complete code
Browse files Browse the repository at this point in the history
  • Loading branch information
chandrakumarreddy committed Jun 5, 2022
0 parents commit 1dedb7c
Show file tree
Hide file tree
Showing 9 changed files with 27,026 additions and 0 deletions.
9 changes: 9 additions & 0 deletions hardhat-tutorial/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
.env
coverage
coverage.json
typechain

#Hardhat files
cache
artifacts
4 changes: 4 additions & 0 deletions hardhat-tutorial/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# steps to compile and deploy

1. npx hardhat compile
2. npx hardhat run scripts/deploy.js --network rinkeby
27 changes: 27 additions & 0 deletions hardhat-tutorial/contracts/Whitelist.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

contract Whitelist {
uint8 public maxWhitelistedAddresses;

uint8 public numAddressesWhitelisted;

mapping(address => bool) public whitelistedAddresses;

constructor(uint8 _maxWhitelistedAddresses) {
maxWhitelistedAddresses = _maxWhitelistedAddresses;
}

function addToWhitelist() public {
require(
!whitelistedAddresses[msg.sender],
"Sender has already been whitelisted"
);
require(
numAddressesWhitelisted < maxWhitelistedAddresses,
"More addresses cant be added, limit reached"
);
whitelistedAddresses[msg.sender] = true;
numAddressesWhitelisted += 1;
}
}
17 changes: 17 additions & 0 deletions hardhat-tutorial/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require("@nomiclabs/hardhat-waffle");

require("dotenv").config({ path: ".env" });

const ALCHEMY_API_KEY_URL = process.env.ALCHEMY_API_KEY_URL;

const RINKEBY_PRIVATE_KEY = process.env.RINKEBY_PRIVATE_KEY;

module.exports = {
solidity: "0.8.4",
networks: {
rinkeby: {
url: ALCHEMY_API_KEY_URL,
accounts: [RINKEBY_PRIVATE_KEY],
},
},
};
Loading

0 comments on commit 1dedb7c

Please sign in to comment.