Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions submissions/Emmanuel-Greg-Ameh/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
node_modules
.env

# Hardhat files
/cache
/artifacts

# TypeChain files
/typechain
/typechain-types

# solidity-coverage files
/coverage
/coverage.json

# Hardhat Ignition default folder for deployments against a local node
ignition/deployments/chain-31337
13 changes: 13 additions & 0 deletions submissions/Emmanuel-Greg-Ameh/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 Hardhat Ignition module that deploys that contract.

Try running some of the following tasks:

```shell
npx hardhat help
npx hardhat test
REPORT_GAS=true npx hardhat test
npx hardhat node
npx hardhat ignition deploy ./ignition/modules/Lock.js
```
34 changes: 34 additions & 0 deletions submissions/Emmanuel-Greg-Ameh/contracts/Lock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.28;

// Uncomment this line to use console.log
// import "hardhat/console.sol";

contract Lock {
uint public unlockTime;
address payable public owner;

event Withdrawal(uint amount, uint when);

constructor(uint _unlockTime) payable {
require(
block.timestamp < _unlockTime,
"Unlock time should be in the future"
);

unlockTime = _unlockTime;
owner = payable(msg.sender);
}

function withdraw() public {
// Uncomment this line, and the import of "hardhat/console.sol", to print a log in your terminal
// console.log("Unlock time is %o and block timestamp is %o", unlockTime, block.timestamp);

require(block.timestamp >= unlockTime, "You can't withdraw yet");
require(msg.sender == owner, "You aren't the owner");

emit Withdrawal(address(this).balance, block.timestamp);

owner.transfer(address(this).balance);
}
}
38 changes: 38 additions & 0 deletions submissions/Emmanuel-Greg-Ameh/contracts/erc20.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract AccessToken is ERC20 {

address public owner;

modifier onlyOwner {
require(msg.sender == owner, "BlockToken:: Unauthorized User");
_;
}

modifier notAmount0(uint256 _amount){
require(_amount != 0, "BlockToken:: Zero amount not supported");
_;
}
constructor(string memory _name, string memory _symbol, address _owner) ERC20(_name, _symbol) {
require(_owner != address(0), "BlockToken:: Zero address not supported");
owner = _owner;
}

function mint(uint256 _amount, address _recepient) onlyOwner notAmount0(_amount) external {
_mint(_recepient, _amount);
}

function burn(uint256 _amount) notAmount0(_amount) external {
_burn(msg.sender, _amount);
}

function burnFrom(address _user, uint256 _amount) onlyOwner notAmount0(_amount) external {
_burn(_user, _amount);
}


}

16 changes: 16 additions & 0 deletions submissions/Emmanuel-Greg-Ameh/contracts/erc721.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: SEE LICENSE IN LICENSE
pragma solidity ^0.8.28;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";

contract BlockNft is ERC721{
uint256 public tokenID;
constructor() ERC721("BlockNft", "BKN"){}

function mint(address recepient) external returns(uint256){
tokenID++;
uint256 tokenId = tokenID;
_mint(recepient, tokenId);
return tokenId;
}
}
46 changes: 46 additions & 0 deletions submissions/Emmanuel-Greg-Ameh/contracts/membership.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

interface IAccessToken {
function balanceOf(address account) external view returns (uint256);
}

interface IMembershipNFT {
function mint(address to) external;
}

import "@openzeppelin/contracts/access/Ownable.sol";

contract MembershipManager {
IAccessToken public accessToken;
IMembershipNFT public membershipNFT;
uint256 public minTokenThreshold = 1000 * 1e18;
address public owner;

constructor(address _token, address _nft,address _owner) {
accessToken = IAccessToken(_token);
membershipNFT = IMembershipNFT(_nft);
owner=_owner;
}


modifier onlyOwner {
require(msg.sender == owner, "BlockToken:: Unauthorized User");
_;
}



function setMinTokenThreshold(uint256 newThreshold) external onlyOwner {
minTokenThreshold = newThreshold;
}

function claimMembership() external {
require(
accessToken.balanceOf(msg.sender) >= minTokenThreshold,
"Insufficient token balance"
);

membershipNFT.mint(msg.sender);
}
}
6 changes: 6 additions & 0 deletions submissions/Emmanuel-Greg-Ameh/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require("@nomicfoundation/hardhat-toolbox");

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: "0.8.28",
};
18 changes: 18 additions & 0 deletions submissions/Emmanuel-Greg-Ameh/ignition/modules/Lock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// This setup uses Hardhat Ignition to manage smart contract deployments.
// Learn more about it at https://hardhat.org/ignition

const { buildModule } = require("@nomicfoundation/hardhat-ignition/modules");

const JAN_1ST_2030 = 1893456000;
const ONE_GWEI = 1_000_000_000n;

module.exports = buildModule("LockModule", (m) => {
const unlockTime = m.getParameter("unlockTime", JAN_1ST_2030);
const lockedAmount = m.getParameter("lockedAmount", ONE_GWEI);

const lock = m.contract("Lock", [unlockTime], {
value: lockedAmount,
});

return { lock };
});
Loading