Skip to content

Instantly share code, notes, and snippets.

View casweeney's full-sized avatar
👨‍💻
Building Platforms

Coding Cas casweeney

👨‍💻
Building Platforms
View GitHub Profile
@casweeney
casweeney / JesseCountRestriction.sol
Created August 1, 2022 17:58
Jesserc Implementation
// SPDX-License-Identifier: MIT;
pragma solidity ^0.8.7;
contract Counter{
uint public count;
uint timer = 0;
error timeNotReached(string);
bool reached = false;
@casweeney
casweeney / KokocodesCount.sol
Created August 1, 2022 17:56
Count implementation by Koko codes
// 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 {
@casweeney
casweeney / CustomErrorNatspec.sol
Created August 1, 2022 17:52
Using custom errors with NATSPEC
// 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);
@casweeney
casweeney / Counter.sol
Last active August 1, 2022 17:55
Class Test
// 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");
@casweeney
casweeney / StakingAssignment.sol
Created August 1, 2022 12:43
Assignment given by Kevin at Web3Bridge
// 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}()`
@casweeney
casweeney / Staking.sol
Last active August 4, 2022 16:51
Staking Contract
// 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;