Skip to content

Instantly share code, notes, and snippets.

View mhchia's full-sized avatar

Kevin Mai-Husan Chia mhchia

View GitHub Profile
@mhchia
mhchia / test.py
Last active August 4, 2017 03:34
I fail to use `RLPList` in viper in this case
from ethereum.tools import tester as t
from ethereum import utils
import rlp
code = """
def test(a1: bytes <= 1000) -> num:
tempa = RLPList(a1, [num])
return tempa[0]
"""
@mhchia
mhchia / test-proto-tracerstate.go
Last active August 10, 2018 17:24
To reproduce `proto: duplicate proto type registered: basictracer_go.wire.TracerState`
package main
import (
logging "github.com/ipfs/go-log"
appdash "sourcegraph.com/sourcegraph/appdash"
appdashtracer "sourcegraph.com/sourcegraph/appdash/opentracing"
)
func main() {
remoteCollector := appdash.NewRemoteCollector("localhost:8701")
@mhchia
mhchia / update_libp2p.sh
Created February 24, 2019 09:23
Copy bindings code from py-libp2p-daemon-bindings to trinity, and modify import paths
#!/bin/bash
# TODO: currently only support "bindings to trinity", probably need the reverse direction as well.
echo "Run this script with a new process spun up because of the usage of \`exit\`"
PATH_BINDINGS="$HOME/projects/ethereum/pyeth/py-libp2p-daemon-bindings"
PATH_TRINITY="$HOME/projects/ethereum/pyeth/trinity"
LIBP2P_BINDINGS_PACKAGE="p2pclient"
@mhchia
mhchia / test_stream_reader_writer.py
Created March 8, 2019 10:19
timeit benchmark for different implementation of the pipe-like stream reader writer
from io import BytesIO
class BytesIOReaderWriter:
_buf: BytesIO
def __init__(self):
self._buf = BytesIO()
def write(self, data):
import random
from multiaddr.protocols import (
Protocol,
PROTOCOLS,
P_IP6ZONE,
)
protocols = tuple(filter(lambda x: x.code != P_IP6ZONE, PROTOCOLS))
@mhchia
mhchia / asyncctxmgr_fails_when_exiting.py
Created February 3, 2020 07:48
`async_generator.asynccontextmanager` fails in Python 3.7-dev
import asyncio
from async_generator import asynccontextmanager
@asynccontextmanager
async def async_iterator():
yield 1
@mhchia
mhchia / crawl_ranked_erc20_tokens.py
Last active June 24, 2020 09:24
This script crawls the top-ranked ERC20 tokens' name and abbreviation from etherscan.io
"""
This script crawls the top-ranked ERC20 tokens' name and abbreviation from etherscan.io .
"""
from typing import Tuple, Union
import re
from bs4 import BeautifulSoup
import requests
@mhchia
mhchia / attestation.txt
Created March 29, 2021 05:33
ZKOPRU trusted setup attestation
I contributed to the ZKOPRU Trusted Setup Multi-Party Ceremony.
The following are my contribution signatures:
Circuit: zk_transaction_1_2
Contributor # 136
Hash: 7cf4214d aa960bfc b496601f ddbae666
f6b1457e 06d36f67 4858b8b2 8eb24924
c119483c 78471897 140a6d4c 496aaf9a
8814ea2f f0a7f905 63d5d957 df82d2bb
@mhchia
mhchia / README.txt
Created November 17, 2021 10:59
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
REMIX EXAMPLE PROJECT
Remix example project is present when Remix loads very first time or there are no files existing in the File Explorer.
It contains 3 directories:
1. 'contracts': Holds three contracts with different complexity level, denoted with number prefix in file name.
2. 'scripts': Holds two scripts to deploy a contract. It is explained below.
3. 'tests': Contains one test file for 'Ballot' contract with unit tests in Solidity.
SCRIPTS

I'm trying the step Instantiate the CosmWasm contract in the tutorial. The command in instantiate_egg.sh is copied-pasted from the tutorial but one argument --node tcp://testnet.palomaswap.com:26656 is added to tell palomad about the node. It keeps failing due to "missing field factory_contract".

Environments:

  • palomad version: v0.11.4.
  • Pretty sure ADDRESS, PALOMA_CHAIN_ID, and ETH_ADDRESS are well set.