Skip to content

Instantly share code, notes, and snippets.

View yongkangc's full-sized avatar
🎃
Focusing

YK yongkangc

🎃
Focusing
View GitHub Profile
@yongkangc
yongkangc / SimpleRewards.sol
Created June 21, 2022 15:28 — forked from Markkop/SimpleRewards.sol
A staking contract using a loop to save rewards data for each staker
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.4;
import "hardhat/console.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./RewardToken.sol";
contract StakingManager is Ownable{
@yongkangc
yongkangc / hashURI.py
Created August 16, 2022 14:11
Python Implementation for Hashing with Salting of URI
import uuid
import hashlib
def hashText(secret, uri):
"""
Basic hashing function for a text using unique secret from the user.
"""
return hashlib.sha256(secret.encode() + text.encode()).hexdigest() + ':' + secret
def matchHashedText(hashedUri, Uri):
@yongkangc
yongkangc / merkle-tree-naive.py
Last active August 22, 2022 10:04
Progression of ZK
import hashlib
from math import log2, ceil
def hash_string(s):
return hashlib.sha256(s.encode()).hexdigest()
class MerkleTree:
"""
A naive Merkle tree implementation using SHA256
"""
@yongkangc
yongkangc / circuit.circom
Last active August 31, 2022 10:10
zkSBT
pragma circom 2.0.6;
include "circomlib/poseidon.circom";
// include "https://github.com/0xPARC/circom-secp256k1/blob/master/circuits/bigint.circom";
template Example () {
signal input a;
signal input b;
signal output c;

Feel free to copy and paste this list into a README, issue or elsewhere in your project.

Audit prep checklist (reference)

  • Documentation (A plain english description of what you are building, and why you are building it. Should indicate the actions and states that should and should not be possible)
    • For the overall system
    • For each unique contract within the system
  • Clean code
  • Fix compiler warnings

Feel free to copy and paste this list into a README, issue or elsewhere in your project.

Audit prep checklist (reference)

  • Documentation (A plain english description of what you are building, and why you are building it. Should indicate the actions and states that should and should not be possible)
    • For the overall system
    • For each unique contract within the system
  • Clean code
  • Fix compiler warnings
@yongkangc
yongkangc / TimeLock.sol
Created July 20, 2023 04:32
TimeLock Contract
// Sources flattened with hardhat v2.17.0 https://hardhat.org
// File @openzeppelin/contracts/utils/introspection/[email protected]
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
@yongkangc
yongkangc / UniswapV3TimeLock.sol
Created July 21, 2023 05:24
UniswapV3 Liquidity Time Lock contract
// File: contracts/interfaces/UniswapInterfaces.sol
// File @uniswap/v3-core/contracts/interfaces/pool/[email protected]
pragma solidity >=0.5.0;
/// @title Pool state that never changes
@yongkangc
yongkangc / Add.sol
Last active August 28, 2023 04:52
Sample Opcode contract
pragma solidity 0.8.7;
contract AddOne {
uint16 private a = 3;
function aPlusOne() external view returns(uint 256) {
unchecked {
return a + 1;
}
}
@yongkangc
yongkangc / Add.sol
Created August 28, 2023 04:24
Add.sol
pragma solidity 0.6.7
contract AddOne {
uint16 private a = 3;
function aPlusOne() external view returns(uint 256) {
return a + 1;
}