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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol";
contract StakingToken is ERC20("Staking Token", "STK") {
address public owner;
constructor() {
owner = msg.sender;
#![cfg_attr(not(feature = "std"), no_std, no_main)]
#[ink::contract]
mod setter_getter_contract {
use ink::prelude::string::String;
/// Defines the storage of your contract.
/// Add new fields to the below struct in order
/// to add new static storage fields to your contract.
#[ink(storage)]
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
// original code
// https://github.com/optionality/clone-factory/blob/master/contracts/CloneFactory.sol
contract MinimalProxy {
function clone(address target) external returns (address result) {
// convert address to 20 bytes
bytes20 targetBytes = bytes20(target);
@casweeney
casweeney / AtomicStaking.sol
Last active February 21, 2023 23:25
Staking Rewards contract with multiple staking positions for a particular user (address)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import "./IERC20.sol";
contract AtomicStaking {
IERC20 public rewardToken;
IERC20 public stakingToken;
address owner;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
contract StakingRewards {
IERC20 public immutable stakingToken;
IERC20 public immutable rewardsToken;
address public owner;
// Duration of rewards to be paid out (in seconds)
@casweeney
casweeney / Safemoon.sol
Created December 15, 2022 22:51
This is a well commented safemoon token contract for easy understanding
/**
#BEE
#LIQ+#RFI+#SHIB+#DOGE = #BEE
#SAFEMOON features:
3% fee auto add to the liquidity pool to locked forever when selling
2% fee auto distribute to all holders
I created a black hole so #Bee token will deflate itself in supply with every transaction
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract TypeCasting {
event Converted(address owner, string message);
bytes32 public x = "This is the beginning of Adddddd";
bytes32 public value = "100";
string public y = "This is the beginning of Adddddd";
@casweeney
casweeney / git_workflow_best_practices.md
Created November 28, 2022 08:24 — forked from calaway/git_workflow_best_practices.md
Git Workflow Best Practices

Git Branch Merging Best Practices

  1. After you've selected a feature to work on, create a branch in your local repo to build it in.
    • $ git checkout -b calaway/short_description_of_feature
  2. Implement the requested feature, make sure all tests are passing, and commit all changes in the new branch.
  3. Checkout the master branch locally.
    • $ git checkout master
  4. Pull down the master branch from GitHub to get the most up to date changes from others. If you practice git workflow as described here you should never have a merge conflict at this step.
    • $ git pull origin master
  5. Make sure all tests are passing on master and then checkout your new branch.
  • $ git checkout calaway/short_description_of_feature
// SPDX-License-Identifier: MIT
// An example of a consumer contract that relies on a subscription for funding.
pragma solidity ^0.8.7;
import '@chainlink/contracts/src/v0.8/interfaces/VRFCoordinatorV2Interface.sol';
import '@chainlink/contracts/src/v0.8/VRFConsumerBaseV2.sol';
import '@chainlink/contracts/src/v0.8/ConfirmedOwner.sol';
/**
* Request testnet LINK and ETH here: https://faucets.chain.link/
@casweeney
casweeney / orderSwap.sol
Last active September 27, 2022 06:09
Smart contract that implements swapping different tokens using order book.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol";
contract Swap {
struct Order {
address orderOwner;
address fromToken;
address toToken;