Skip to content

Instantly share code, notes, and snippets.

View dapplion's full-sized avatar

Lion - dapplion dapplion

View GitHub Profile
@dapplion
dapplion / slot_finder_gnosis.mjs
Last active January 4, 2024 14:48
Find fork slot and timestamp for a network with Gnosis preset and some time conditions
// Usage
// node slot_finder.mjs chiado
const genesisTimestamp = getGenesis();
const interval = 8192 * 5;
const now = Math.floor(Date.now() / 1000);
const futureDate = new Date();
futureDate.setMonth(futureDate.getMonth() + 2);
const futureTimestamp = Math.floor(futureDate.getTime() / 1000);
@dapplion
dapplion / signature_verify.mjs
Created May 30, 2023 17:55
Verify signature of example payload from beacon chain
import { ssz } from "@lodestar/types";
import { createBeaconConfig } from "@lodestar/config";
import { fromHexString, toHexString } from "@chainsafe/ssz";
import bls from "@chainsafe/bls";
// To run, first install dependencies:
// $ npm install @lodestar/types @lodestar/config @chainsafe/ssz @chainsafe/bls
//
// Then
// $ node signature_verify.mjs
import {randomBytes} from "node:crypto";
import {compress} from "snappyjs";
import {phase0, ssz} from "@lodestar/types";
import {BitArray} from "@chainsafe/ssz";
// To run:
// $ ../../node_modules/.bin/ts-node --esm test/unit/network/snappy.test.ts
/* eslint-disable no-console */