Skip to content

Instantly share code, notes, and snippets.

@banteg
banteg / cheatsheet.md
Last active September 21, 2023 21:47 — forked from sekrystal/cheatsheet.md
EIP Cheatsheet
EIP Block # (Hard Fork Name) TransactionType (EIP2718) Unsigned Transaction Signed Transaction Value of v or yParity
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@banteg
banteg / model_flip_eth_a.py
Last active July 31, 2022 18:48
boilerplate makerdao auction keeper model using python
#!/usr/bin/env python
import os
import sys
import json
import requests
discount = 0.15
def get_price():
resp = requests.get('https://api.coingecko.com/api/v3/simple/price', params={'ids': 'ethereum', 'vs_currencies': 'usd'})
@banteg
banteg / deposit.py
Last active July 31, 2022 18:48
eth2 mass deposit for lighthouse
# 1. generate keys with `lighthouse account validator new random N`
# 2. run `python deposit.py`, it skips the ones already deposited and deposits the rest
import json
import sys
from pathlib import Path
from getpass import getpass
from eth_utils import encode_hex, decode_hex
from web3 import Web3
from web3.middleware import construct_sign_and_send_raw_middleware
miner count
e7f7634e925541f368b827ad5c72421905100f6205285a78c19d7b4a38711805 54578
93ac6ca68b2540453261abdb962e3fdb878a5523c08caf9c4079aef92d3177be 37029
0e92c6030a05010c1e7bd40b7d8261fe5e9da2821d1411e3e440cb773463679a 13541
a248289e385c7cbac252eae9b03577c5d3f3a9a7a1f67ed43c65e9318dd65c18 12039
96cfb7db1a5f6989e5624c7dd81b5a2b3ebe1ddfd849ecba7cfdce15d201b0c9 11631
f37d819fc4a6e80286557807e0d39a66ff448daf355363da807902621e374ef0 9083
40c204ee9d55aba202e76c457c7ac0afccf7bce8768d2bb0f4696605eb342123 7722
d30c907adc0000d8a54e8c4f0843d05c500da3c2faa0fe943e085ab278abe751 7496
834ec56e02fbddf69886c3b2801fc39dad301c0d05406843288fb8f79c45b5c6 4644

transaction 1

(interface fungible-v1

  " Standard for fungible coins and tokens as specified in KIP-0002. "

   ; ----------------------------------------------------------------------
   ; Schema

   (defschema account-details
@banteg
banteg / yt-seek.sh
Created April 29, 2019 14:35
download fragment of a youtube video without downloading the whole thing
#!/bin/bash
NAME=yt-seek
if [ "$#" -ne 3 ]; then
echo "Usage: $NAME <url> <start> <duration>"
exit 1
fi
URL=$1
START=$2
import json
from collections import Counter, defaultdict
from concurrent.futures import ThreadPoolExecutor
from dataclasses import dataclass, field
from decimal import Decimal
from itertools import count
from pathlib import Path
import click
import requests
@banteg
banteg / uniswap_total.py
Created March 6, 2019 08:23
tally ether locked across all uniswap exchanges
from concurrent.futures import ThreadPoolExecutor
from web3.auto import w3
from cryptocompare import get_price
abi = [{'name': 'NewExchange', 'inputs': [{'type': 'address', 'name': 'token', 'indexed': True}, {'type': 'address', 'name': 'exchange', 'indexed': True}], 'anonymous': False, 'type': 'event'}]
factory = w3.eth.contract('0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95', abi=abi)
new_exchange = factory.events.NewExchange().createFilter(fromBlock=6627917)
exchanges = [x.args.exchange for x in new_exchange.get_all_entries()]
@banteg
banteg / buffidai.py
Last active February 21, 2019 06:32
ethdenver vendor statistics
from dataclasses import dataclass
from operator import attrgetter
from web3 import Web3, HTTPProvider
from web3.utils.filters import construct_event_filter_params
from tabulate import tabulate
@dataclass
class Vendor:
address: str