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
51 changes: 51 additions & 0 deletions contracts/BlockToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// 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 _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);
}

function transfer(address _owner, uint256 _amount) public notAmount0(_amount) override returns (bool){
require(_owner != address(0), "BlockToken:: Zero address not supported");
_transfer(msg.sender, _owner, _amount);
}

// function transferFrom(address _owner, address _recepient, uint256 _amount) public notAmount0(_amount) override returns (bool){
// require(_recepient != address(0), "BlockToken:: Zero address not supported");
// _transfer(_owner, _recepient, _amount);
// uint256 currentAllowance = allowance(_owner, msg.sender);
// require(currentAllowance >= _amount, "BlockToken:: Transfer amount exceeds allowance");
// _approve(_owner, msg.sender, currentAllowance - _amount);
// return true;
// }


}
52 changes: 17 additions & 35 deletions contracts/Counter.sol
Original file line number Diff line number Diff line change
@@ -1,48 +1,30 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;
// // SPDX-License-Identifier: MIT

interface ICounter {
function setCount(uint256 _count) external;
function increaseCountByOne() external;
function getCount() external view returns(uint256);
// pragma solidity ^0.8.28;

}
// interface ICounter {
// function increaseCountByOne() external;
// function setCount(uint256 _count) external;

contract Counter is ICounter {
uint256 public count;
// function getCount() external view returns(uint256);
// //function resetCount() external
// }

function setCount(uint256 _count) external {
count = _count;
}

function increaseCountByOne() public {
count += 1;
}
// contract Counter is ICounter {
// uint256 public count;

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


// contract F {
// // Initializing interface IC
// IC public _ic;
// // Initializing the contract address
// address public contractCAddress;

// constructor(address _contractCAddress) {
// // Set the contract address to the state variable contract address
// contractCAddress = _contractCAddress;
// // Passing the contract address into interface using the address instance of another contract
// _ic = IC(_contractCAddress);
// }
// function increaseCountByOne() public {
// count += 1;
// }

// function setCount(uint256 _count) public {
// _ic.setCount(_count);
// count = _count;
// }

// function getCount() public view returns(uint256) {
// return _ic.getCount();
// return count;
// }


// }
54 changes: 54 additions & 0 deletions contracts/CounterV2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// // SPDX-License-Identifier: MIT

// pragma solidity ^0.8.19;

// interface ICounterV2{
// function setCount(uint256 _count) external;

// function getCount() external view returns(uint256);

// function increaseCountByOne() external;

// function resetCount() external;

// function decreaseCountByOne() external;
// }

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

// constructor(){
// owner = msg.sender;
// }

// function setCount(uint256 _count) public {
// require(_count > 0, "Count must be greater than 0");
// require(msg.sender == owner, "You are unauthorised");
// count = _count;
// }

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

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

// function increaseCountByOne() public {
// require(msg.sender == owner, "You are unauthorised");
// count+=1;
// }

// function resetCount() public {
// require(count > 0,"Cannot reset value , It's already at default");
// require(msg.sender == owner, "You are Unauthorised");
// count = 0;
// }

// function decreaseCountByOne() public {
// require(msg.sender == owner, "You are unauthorised");
// count-=1;
// }
// }
9 changes: 9 additions & 0 deletions package-lock.json

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

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
"devDependencies": {
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
"hardhat": "^2.26.1"
},
},
"scripts": {
"test": "npx hardhat test",
"compile": "npx hardhat compile",
"test": "npx hardhat test",
"compile": "npx hardhat compile",
"node": "npx hardhat node"
},
"dependencies": {
"@openzeppelin/contracts": "^5.4.0"
}
}
Loading