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
# Poker Design Notes
## 合约框架
### CheckIn
- 创建牌桌,初始化参数
- 玩家加入,锁定资产
- 玩家提交公钥和DLOG证明,客户端合并玩家公钥可得全局公钥
@yihuang
yihuang / demo.sol
Last active August 6, 2021 06:40
some pseudocode to demonstrate interaction between evm contract and host system
contract ERC20 {
map[address][uint256] _balances;
// deposit through native module
// native module will first move user's native tokens to contract address,
// then mint on evm directly
function deposit(receipient, amount) {
require(msg.sender == native_module_address)
_balances[receipient] += amount;
}
// Sources flattened with hardhat v2.4.3 https://hardhat.org
// File @openzeppelin/contracts/token/ERC20/[email protected]
// 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 <[email protected]>"]
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 March 8, 2025 15:31
build rust project using bindgen with nix
[package]
name = "test-rust"
version = "0.1.0"
authors = ["yihuang <[email protected]>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]