Skip to content

Instantly share code, notes, and snippets.

@adambor
adambor / Resolve-hackathon-live-coding-session.md
Created September 19, 2025 16:05
Resolve hackathon live coding session
@adambor
adambor / BtcRelay.yul
Created June 23, 2025 20:45
Stub for a bitcoin light client implemented in Yul
object "BtcRelay" {
code {
let constructorOffset := add(dataoffset("runtime"), datasize("runtime"))
datacopy(0x00, constructorOffset, 160)
let commitHash := keccak256(0x00, 160)
let blockHeight := shr(224, mload(112))
let chainWork := mload(80)
//Save the initial stored header
mstore(0x00, blockHeight)
use core::sha256::{compute_sha256_u32_array, compute_sha256_byte_array};
fn one_shift_left_bytes_u128(n_bytes: usize) -> u128 {
match n_bytes {
0 => 0x1,
1 => 0x100,
2 => 0x10000,
3 => 0x1000000,
4 => 0x100000000,
5 => 0x10000000000,
const fs = require("fs");
//Zaciatocny cas, pozor, mesiac je medzi 0-11 (nie 1-12)
const date = new Date(2023, 10, 2, 0, 0, 0);
//Sem skopci Cookies header z browseru
const cookie = "multiLanguage=true; HWWAFSESID=45db710758d5a27673e0; HWWAFSESTIME=1707488456990; locale=en-us; ztsg_ruuid=847b80cd5d5d9982-d30a-42ab-8462-09ec7f8f2217; _ga=GA1.1.727327667.1715349167; _ga_DYQ8BLWLFS=GS1.1.1717002134.3.0.1717002134.0.0.0; utag_main=v_id:018f62c71970004d8b13fa50917c0006f003e06701328$_sn:3$_se:1$_ss:1$_st:1717003935574$ses_id:1717002135574%3Bexp-session$_pn:1%3Bexp-session; antoEco-analytics=1; lang=en; support_last_vist=enterprise; _abck=08FAB5EED2765C5885F25DC5A74B5934~0~YAAQjZoXAtdOFt+SAQAAopxm4gza+8rZJk3Qj+Oeev6chsP8w5rJhuddJO94f9wwgK0p8DYGjvwzaSGYM5cJXPAYHt3DVEv/ANK8GdT6Vbpklrlw9pat/qwXzBknoASwEsk9N8YQkYfr37TwLuc9LYnCnxgqupYSf+y1BgGEPllSqJIf06Nh0AjEzBQzyJ49W4uj0Bz9DLsm0qpNTW4IStqk9lDPJIfKfmCJ0/+cuWBQoszgDeF1XK9ysdagbySutIqR/8CEgUc0FTS9JXn5YR6AFenMshusKRgFHfVTZgpCLXpWhrZFVX72j5SMTfPO3XW45Rq4cMrSU38r0Vb+dmo1zCii
@adambor
adambor / SolanaFeeEstimator.ts
Last active July 11, 2024 08:44
Solana fee estimator taking into account global and localized fee market. Preferably trying to use Helius fee RPC API call, but falling back to client fee estimation (with block fetching) when not available.
import * as BN from "bn.js";
import {Connection, PublicKey} from "@solana/web3.js";
const MAX_FEE_AGE = 5000;
export class SolanaFeeEstimator {
private readonly connection: Connection;
private readonly maxFeeMicroLamports: BN;
private readonly numSamples: number;