Skip to content

Instantly share code, notes, and snippets.

View yihuang's full-sized avatar
🏠
Working from home

yihuang yihuang

🏠
Working from home
  • crypto.com
  • Shenzhen, China
View GitHub Profile
// Sources flattened with hardhat v2.4.3 https://hardhat.org
// File @openzeppelin/contracts/token/ERC20/IERC20.sol@v4.2.0
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
@yihuang
yihuang / native-asset-design.md
Last active March 17, 2021 06:50
native asset design patterns

native asset design patterns

Fixed max supply

Problem

You want your token to have fixed max supply (NFT is just token with 1 max supply).

Solution

@yihuang
yihuang / Cargo.toml
Last active February 12, 2021 18:03
smol/tokio simple benchmark
[package]
name = "async-benchmark"
version = "0.1.0"
authors = ["yihuang <yi.codeplayer@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
@yihuang
yihuang / asymmetric-cryptography.md
Last active January 22, 2021 15:41
summary of asymmetric cryptography

Over Simplfied Asymmetric Cryptography

Group

Definitions:

  • Operator: +

  • Unit: 0

@yihuang
yihuang / add_genesis_accounts.py
Last active December 23, 2020 08:31
testnet upgrade scripts
import json
import sys
if len(sys.argv) < 3:
print(
"""add_genesis_accounts.py accounts.json path/to/genesis.json
new genesis file is print to stdout
""",
file=sys.stderr,
@yihuang
yihuang / migrate.py
Created December 9, 2020 01:56
migrate tendermint genesis file
import base64
import json
# import hashlib
import sys
import bech32
def clear_staking(genesis):
@yihuang
yihuang / nix-tutorial.md
Last active January 6, 2023 15:33
nix tutorial

nix introduction

nix-env: the package manager

$ nix-env -i hello
installing 'hello-2.10'
these paths will be fetched (0.02 MiB download, 0.07 MiB unpacked):
  /nix/store/mmlnjqg7gbr4w7xjlwj614z97kk1rvfv-hello-2.10
copying path '/nix/store/mmlnjqg7gbr4w7xjlwj614z97kk1rvfv-hello-2.10' from 'https://cache.nixos.org'...
@yihuang
yihuang / Cargo.toml
Last active April 12, 2024 18:38
build rust project using bindgen with nix
[package]
name = "test-rust"
version = "0.1.0"
authors = ["yihuang <yi.codeplayer@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
@yihuang
yihuang / deps.nix
Last active September 27, 2020 04:01
ultimate go module major version test case
# file generated from go.mod using vgo2nix (https://github.com/adisbladis/vgo2nix)
[
{
goPackagePath = "github.com/cespare/xxhash/v2";
fetch = {
type = "git";
url = "https://github.com/yihuang/test-golang-module-major-version";
rev = "4a13e4bfd5a9";
sha256 = "0i1bpw3v73jhwnpa8vv276qhy39fk6qhgyci0wng9mwr2pxfha5y";
moduleDir = "";
@yihuang
yihuang / Cargo.toml
Created July 26, 2020 09:34
test open rpc
[package]
name = "open-rpc-test"
version = "0.1.0"
authors = ["yihuang <yi.codeplayer@gmail.com>"]
edition = "2018"
[dependencies]
schemars = "0.7"
serde = "1.0"
serde_json = "1.0"