Skip to content

Instantly share code, notes, and snippets.

eth_address = "0x" + hex(keccak256(pubkey_raw)[-20:])
cosmos_address = bech32(prefix, ripemd160(sha256(pubkey_compressed)))
cosmos_evmos_address = bech32(prefix, keccak256(pubkey_raw)[-20:])
import { fromBase64, fromHex, toBase64, toHex } from "secretjs";
import { TxRaw } from "secretjs/dist/protobuf/cosmos/tx/v1beta1/tx";
import { sha256 } from "@noble/hashes/sha256";
async function main() {
const txhash =
"2b324cd8d36ace2ff1d26145df2109bbaec9d508aa465d36ff88fcd72aa985a8".toUpperCase();
const tcpStream = fromHex(
[
#!/usr/bin/env python3
# Usage: ./whisper3-json-to-srt.py output.json > output.srt
import sys
import json
if len(sys.argv) > 1 and sys.argv[1] != '-':
with open(sys.argv[1]) as file:
data = json.load(file)
@assafmo
assafmo / main.ts
Created March 19, 2024 09:31
Manually send an IBC timeout
// Run this code with `ts-node main.ts`
import { IbcClient, Link } from "@confio/relayer";
import { stringToPath } from "@cosmjs/crypto";
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { GasPrice } from "@cosmjs/stargate";
import Long from "long";
import { fromHex } from "secretjs";
export async function createIbcConnection(): Promise<Link> {
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x2 addr=0x7f12160ac000 pc=0x7f125f3d931f]
runtime stack:
runtime.throw({0x1c913b1?, 0x7f125f3d92d6?})
/usr/local/go/src/runtime/panic.go:1047 +0x5d fp=0x7f12168aacd0 sp=0x7f12168aaca0 pc=0x44189d
runtime.sigpanic()
/usr/local/go/src/runtime/signal_unix.go:819 +0x369 fp=0x7f12168aad20 sp=0x7f12168aacd0 pc=0x458389
goroutine 1 [syscall]:
runtime.cgocall(0x187fe50, 0xc004846138)
/usr/local/go/src/runtime/cgocall.go:158 +0x5c fp=0xc0048460a0 sp=0xc004846068 pc=0x40b79c
import {
BroadcastMode,
coinsFromString,
SecretNetworkClient,
Wallet,
} from "secretjs";
import { BaseAccount } from "secretjs/dist/grpc_gateway/cosmos/auth/v1beta1/auth.pb";
import { AminoWallet } from "secretjs/dist/wallet_amino";
function sleep(ms: number) {
@assafmo
assafmo / when_last_block.sh
Created October 11, 2022 08:57
Last block
watch $'curl -s localhost:26657/status |
jq .result.sync_info.latest_block_time |
perl -pe "s/\.\d+Z/Z/" |
jq -r \'"Last block: " + (now - (. | fromdate) | floor | tostring) + " seconds ago"\''
#!/bin/bash
# https://gist.github.com/assafmo/01d7ee0d131a99518d2a4189a9250460
BLOCK_WINDOW="${1}" # e.g. 100000 blocks in the past
UPGRADE_TIME="${2}" # e.g. 2023-03-02T19:07:13Z
LCD="${3}" # e.g. https://lcd.secret.express or https://api.pulsar.scrttestnet.com
LATEST="$(curl -s "$LCD/cosmos/base/tendermint/v1beta1/blocks/latest")"
@assafmo
assafmo / shockwave-alpha.sh
Last active April 11, 2022 17:45
Launching a new local testnet
SGX_MODE=SW SCRT_SGX_STORAGE="$(pwd)/.sgx_secrets" LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$(pwd)" RUST_BACKTRACE=1 ./secretd --home "$(pwd)/.secretd" tx gov submit-proposal software-upgrade v1.3 --upgrade-height 28100 --title hi --description bye --deposit 10000000uscrt -y --from a
SGX_MODE=SW SCRT_SGX_STORAGE="$(pwd)/.sgx_secrets" LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$(pwd)" RUST_BACKTRACE=1 ./secretd --home "$(pwd)/.secretd" tx gov vote 1 yes --from a -y
@assafmo
assafmo / index.html
Last active March 28, 2024 15:24
SEO
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- SEO Title -->
<meta name="application-name" content="$SHORT_TITLE" />
<meta name="title" content="$TITLE" />