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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ node_modules

# Hardhat Ignition default folder for deployments against a local node
ignition/deployments/chain-31337

52 changes: 26 additions & 26 deletions contracts/BlockHeaderToken.sol
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// pragma solidity ^0.8.0;

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

contract BlockToken is ERC20{
// contract BlockToken is ERC20{

address public owner;
// address public owner;

modifier onlyOwner {
require(msg.sender == owner, "BlockToken:: Unauthorized User");
_;
}
// 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;
}
// 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 mint(uint256 _amount, address _recepient) onlyOwner notAmount0(_amount) external {
// _mint(_recepient, _amount);
// }

function burn(uint256 _amount) notAmount0(_amount) external {
_burn(msg.sender, _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);
}
// function burnFrom(address _user, uint256 _amount)onlyOwner notAmount0(_amount) external {
// _burn(_user, _amount);
// }


}
// }

36 changes: 36 additions & 0 deletions contracts/BlockheaderToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

contract BlockToken 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 _recipient) onlyOwner notAmount0(_amount) external {
// require(msg.sender == owner, "BlockToken:: Unauthorized User");
_mint(_recipient, _amount);
}

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

function burnFrom(address _user, uint256 _amount) onlyOwner notAmount0(_amount) external {
_burn(_user, _amount);
}
}
2 changes: 1 addition & 1 deletion contracts/Counter.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;
pragma solidity ^0.8.28;

interface ICounter {
function setCount(uint256 _count) external;
Expand Down
65 changes: 65 additions & 0 deletions contracts/CounterV2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// SPDX-License-Identifier: MIT

pragma solidity >= 0.7.0 < 0.9.0;

interface ICounterV2{
function setCount(uint256 _count) external;
function getCount() external view returns(uint256);
function resetCount() external;
function decrementCount() external;
}

contract CounterV2 is ICounterV2{
address public owner;
uint256 public count;

constructor(){
owner = msg.sender;
}

function setCount(uint256 _count) external {
require(msg.sender == owner, "Unauthorized Caller");
require(_count > 0, "Cannot pass zero value as argument");

count = _count;
}

function getCount() external view returns(uint256) {
return count;
}

function resetCount() external {
require(msg.sender == owner, "Unauthorized Caller");
if (count > 0) {
count = 0;
}
}

function decrementCount() external {
count -= 1;
}

function getOwner() external view returns(address) {
return owner;
}
}

contract CounterV2Caller {
ICounterV2 public _iCounterV2;
address public contractCounterV2Address;

constructor(address _contractCounterV2Address) {
contractCounterV2Address = _contractCounterV2Address;
_iCounterV2 = ICounterV2(_contractCounterV2Address);
}

function callDecrement() external {
_iCounterV2.decrementCount();
}
}

// Reset count (if count > 0, then count =0) and to be called by only owner
// Set count (if count === 0, else cannot pass in zero value as arg) and only owner should set count
// write an Interface
// Decrement function (count by 1)
// Create an instance of counter v2 where it will decrease the counter
53 changes: 6 additions & 47 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
"name": "hardhat-project",
"devDependencies": {
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
"@types/minimatch": "^5.1.2",
"hardhat": "^2.26.1"
},
"scripts": {
"test": "npx hardhat test",
"compile": "npx hardhat compile",
"node": "npx hardhat node"
},
"test": "npx hardhat test",
"compile": "npx hardhat compile",
"node": "npx hardhat node",
"coverage": "npx hardhat coverage"
},
"dependencies": {
"@openzeppelin/contracts": "^5.4.0"
}
Expand Down
Loading