Skip to content

Instantly share code, notes, and snippets.

View qianbin's full-sized avatar

Qian Bin qianbin

View GitHub Profile
@qianbin
qianbin / connex-playground.js
Last active January 21, 2021 02:45
Connex playground in browser
// copy and run following lines into your browser dev console,
// you'll get connex ready
const connex = await (() => {
const script = document.createElement('script')
script.src = 'https://unpkg.com/@vechain/connex@2'
document.body.appendChild(script)
return new Promise((resolve, reject) => {
script.onload = () => {
resolve(new Connex({
node: 'https://testnet.veblocks.net',
@qianbin
qianbin / web3-styled-contract-binding.ts
Created April 12, 2021 06:10
connex2: demonstrate how to create an contract object like web3
function contract(thor: Connex.Thor, address: string, abis: Array<any>) {
const obj: Record<string, Connex.Thor.Account.Method> = {}
abis.filter(i => i.type === 'function' && i.name)
.forEach(i => {
obj[i.name] = thor.account(address).method(i)
})
return obj
}
@qianbin
qianbin / mpt-node-compress.go
Last active August 6, 2022 17:51
full nodes compression ratio
func main() {
var node [16][]byte
for i := 0; i < len(node); i++ {
b := make([]byte, 32)
rand.Read(b)
node[i] = b
}
buf := bytes.NewBuffer(nil)
package main
import (
"fmt"
"log"
"math/rand"
"os"
"path"
"time"