Skip to content

Instantly share code, notes, and snippets.

@zhangweis
zhangweis / token.scrypt
Last active March 9, 2024 08:42
Add current merkle root to records and allow signature only on record. This can better support cold key storage.
import "util.scrypt";
contract Token {
public function transfer(bytes txPreimage, bytes fromRecord, bytes fromMerklePath, Sig senderSig,
bytes toRecord, bytes toMerklePath, bytes insertPoint, bytes insertPointMerklePath,
int amount, int utxoAmount) {
require(amount>0);
require(utxoAmount>=0);
// this ensures the preimage is for the current tx
require(Tx.checkPreimage(txPreimage));
import Web3 from 'https://deno.land/x/web3/mod.ts'
const providerURL = Deno.args[0]
const web3 = new Web3(new (Web3 as any).providers.HttpProvider(providerURL))
const balance = await (web3 as any).eth.getBalance("0x7a915e362353d72570dcf90aa5baa1c5b341c7aa")
console.log(`the balance is ${balance} wei`)
const transactionHash = "0x0d558d490c89fc94ddfebd284e39da5c1bcff15d18c4e9fd2eb37a202d20c703"
@zhangweis
zhangweis / tableify.ts
Created September 6, 2022 08:37
deno tableify
import tableify from "https://esm.sh/tableify";
import json2json from "https://gitee.com/zhangweis/deno-report-tools/raw/master/json2json.ts";
json2json(tableify)