Skip to content

Instantly share code, notes, and snippets.

@mcchan1
mcchan1 / chainlink-usd-to-eth
Created February 10, 2021 15:55
Use Chainlink to convert US Dollars to ETH
@mcchan1
mcchan1 / lao-nft.sol
Created September 23, 2020 16:59
lao-nft
pragma solidity 0.5.3;
/*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
///-safemath, ownable, reentrancy,et..
//add proxy contracts below
interface ZapInUniSwap2 {
//updated zapIn parameters - replace slippage w/ _minPoolTokkenss
function ZapIn(
address _FromTokenContractAddress,
address _ToUnipoolToken0,
address _ToUnipoolToken1,
@mcchan1
mcchan1 / simple-escrow.sol
Created April 29, 2020 16:08
simple escrow controlled by one owner
pragma solidity ^0.6.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
@mcchan1
mcchan1 / adminFee-5.sol
Last active March 2, 2020 15:42
take 5 adminFee
pragma solidity 0.5.3;
/*
adminFee = userTokenBalances[GUILD][token] / adminFeeDenominator;
if adminFeeDenominator is greater than or equal to 200, then adminFee will be less than or equal to .5%
-- allows LAO to reduce fees if desired, but not required to reduce .
Using OpenZeppelin's Ownable.sol contract to manage who is the service provider. It will be The LAO at launch.
@mcchan1
mcchan1 / adminFee-4.sol
Created January 23, 2020 22:04
take 4 adminFee
pragma solidity 0.5.3;
/*
adminFee = totalLoot+totalShares/adminFeeDenominator
if adminFeeDenominator is greater than or equal to 200, then adminFee will be less than or equal to .5%
-- allows LAO to reduce fees if desired, but not required to reduce .
Using OpenZeppelin's Ownable.sol contract to manage who is the service provider. It will be The LAO at launch.
@mcchan1
mcchan1 / adminFee-3.sol
Last active January 23, 2020 15:47
take 3 adminFee
pragma solidity 0.5.3;
/*
adminFee = totalLoot+totalShares/adminFeeDenominator
if adminFeeDenominator is greater than or equal to 200, then adminFee will be less than or equal to .5%
-- allows LAO to reduce fees if desired, but not required to reduce .
Using OpenZeppelin's Ownable.sol contract to manage who is the service provider. It will be The LAO at launch.
@mcchan1
mcchan1 / adminFee-2.sol
Last active January 21, 2020 20:37
take 2 on adminFee - using ragequit
/*
adminFee = totalLoot+totalShares/adminFeeDenominator
if adminFeeDenominator is greater than or equal to 200, then adminFee <= .5% -- allows LAO to reduce fees
*/
//summoningTime = now/time contract deployed
uint256 public lastPaymentTime = summoningTime + paymentPeriod;
//uint256 paymentPeriod = 90 days; //every quarter.
@mcchan1
mcchan1 / adminFee.sol
Created January 17, 2020 21:40
admin extension LAO
///LAO - ADD ON, only ADMIN can withdraw the admin fee of .5% every 90 days.
uint256 public dueDate = now + paymentPeriod;
uint256 paymentPeriod = 90 days; //every quarter.
function withdrawAdminFee (address escrowAddress) public onlyWhitelisted {
//require > 90 days (dueDate) have passed since last withdrawal
require (now >= dueDate, "90 days have not passed");
@mcchan1
mcchan1 / OpenLaw-Api-App.js
Last active May 22, 2019 15:51
OpenLaw Api Tutorial App.js Gist
import React, { Component } from "react";
import BillOfSaleContract from "./contracts/BillOfSale.json";
import getWeb3 from "./utils/getWeb3";
import { Container,Grid, Button, Form} from 'semantic-ui-react';
import { APIClient, Openlaw } from 'openlaw';
import "./App.css";
//PLEASE SUPPLY YOUR OWN LOGIN CREDENTIALS FOR OPENLAW
const URL = "https://app.openlaw.io"; //url for your openlaw instance eg. "http://myinstancename.openlaw.io"
const TEMPLATE_NAME = "OpenLaw API Tutorial Sale Agreement"; //name of template stored on Openlaw