This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity 0.8.0; | |
contract Staking { | |
event Stake(address user, uint amount); | |
uint256 deadline = block.timestamp + 5 minutes; | |
mapping(address => uint) balances; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Collect funds in a payable `stake()` function and track individual `balances` with a mapping: | |
// ( Make sure to add a `Stake(address,uint256)` event and emit) | |
// After some `deadline` allow anyone to call an `execute()` function | |
// If the deadline has passed and the threshold is met, it should call `exampleExternalContract.complete{value: address(this).balance}()` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity 0.8.0; | |
contract Counter { | |
uint256 count; | |
uint256 restrictionTime = block.timestamp + 30; | |
function add() public { | |
require(block.timestamp < restrictionTime, "restriction time reached"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8.4; | |
/// ogbeni | |
error Unauthorized(); | |
/// @custom:experimental This is an experimental contract. | |
contract VendingMachine { | |
address payable owner = payable(msg.sender); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8; | |
// create a timer for increement and decreement but they should only work after 30secs | |
contract counter { | |
uint256 count; | |
uint256 lastRun; | |
function add() external { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT; | |
pragma solidity ^0.8.7; | |
contract Counter{ | |
uint public count; | |
uint timer = 0; | |
error timeNotReached(string); | |
bool reached = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
contract TypeCasting { | |
bytes32 public x = "This is the beginning of Adddddd"; | |
string public y = "This is the beginning of Adddddd"; | |
function convertByteToString() public view returns(string memory) { | |
string memory result = string(abi.encodePacked(x)); | |
return result; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity 0.8.0; | |
contract RevStake { | |
event Stake(address sender, uint256 value); | |
mapping(address => uint) balances; | |
uint deadline = block.timestamp + 5 minutes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.13; | |
contract ByteCodeManager { | |
function getBytecode(address _owner, uint _foo) public pure returns (bytes memory) { | |
bytes memory bytecode = type(TestContract).creationCode; | |
return abi.encodePacked(bytecode, abi.encode(_owner, _foo)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity 0.8.0; | |
contract Deposit { | |
mapping(address => uint) balances; | |
function deposit() public payable { | |
require(msg.value > 0, "No value sent"); | |
balances[msg.sender] += msg.value; |
OlderNewer