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
11 changes: 11 additions & 0 deletions contracts/BlockHeaderToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ contract BlockToken is ERC20{
_burn(_user, _amount);
}

function tokenTransfer(address _recepient, uint256 _amount) notAmount0(_amount) external {
_transfer(msg.sender, _recepient, _amount);
}

function transferTokenFrom(address _sender, address _recepient, uint256 _amount) notAmount0(_amount) external {
_transfer(_sender, _recepient, _amount);
}

function tokenApprove(address spender, uint256 _amount) notAmount0(_amount) external{
_approve(msg.sender, spender, _amount);
}

}

38 changes: 19 additions & 19 deletions 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.0;

interface ICounter {
function setCount(uint256 _count) external;
Expand All @@ -25,24 +25,24 @@ contract Counter is ICounter {
}


// contract F {
// // Initializing interface IC
// IC public _ic;
// // Initializing the contract address
// address public contractCAddress;
// // 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);
// }
// // 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 setCount(uint256 _count) public {
// _ic.setCount(_count);
// }
// // function setCount(uint256 _count) public {
// // _ic.setCount(_count);
// // }

// function getCount() public view returns(uint256) {
// return _ic.getCount();
// }
// }
// // function getCount() public view returns(uint256) {
// // return _ic.getCount();
// // }
// // }
63 changes: 63 additions & 0 deletions contracts/CounterV2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface MeCounterV2 {
function resetCount() external;
function setCount(uint256 _count) external;
function decreaseCount() external;
function increaseCountByOne() external;
function getCount() external view returns(uint256);

}

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

constructor() {
owner = msg.sender;
}

function setCount(uint256 _count) public {
require(_count > 0, "Cannot pass in 0 value as argument");
require(msg.sender == owner, "Unauthorized User: Only owner can alter the count");
count = _count;
}


function increaseCountByOne() public {
require(msg.sender == owner, "Unauthorized User");
count += 1;
}

function getCount() public view returns(uint256) {
// require(msg.sender == owner, "Unauthorized User");
return count;
}

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

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

contract CounterV2Caller{
MeCounterV2 public _MeCounterV2;
address public contractCountV2Add;

constructor (address _contractCountV2Add) {
contractCountV2Add = _contractCountV2Add;
_MeCounterV2 = MeCounterV2 (_contractCountV2Add);
}

function decreementCaller() external {
_MeCounterV2.decreaseCount();
}

}
50 changes: 25 additions & 25 deletions contracts/Lock.sol
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.28;
// // SPDX-License-Identifier: UNLICENSED
// pragma solidity ^0.8.28;

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

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

event Withdrawal(uint amount, uint when);
// event Withdrawal(uint amount, uint when);

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

unlockTime = _unlockTime;
owner = payable(msg.sender);
}
// 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);
// 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");
// 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);
// emit Withdrawal(address(this).balance, block.timestamp);

owner.transfer(address(this).balance);
}
}
// owner.transfer(address(this).balance);
// }
// }
13 changes: 5 additions & 8 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "hardhat-project",
"devDependencies": {
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
"@types/minimatch": "^5.1.2",
"hardhat": "^2.26.1"
},
"scripts": {
Expand Down
Loading