Skip to content

Instantly share code, notes, and snippets.

import click
from web3 import Web3, HTTPProvider
from datetime import datetime, timezone
abi = [{'constant': True,
'inputs': [],
'name': 'name',
'outputs': [{'name': '', 'type': 'string'}],
'payable': False,
"""
estimates remaining time to sync tezos node.
dependencies:
pip3 install click requests python-dateutil
"""
import requests
from requests.exceptions import ConnectionError
from dateutil.parser import parse
from datetime import datetime, timedelta, timezone
@banteg
banteg / maker_votes.py
Created December 19, 2018 03:38
recover makerdao governance votes
import json
from collections import Counter, defaultdict
from dataclasses import dataclass, field
from decimal import Decimal
from eth_abi import encode_single
from eth_utils import function_signature_to_4byte_selector, decode_hex, encode_hex
from itertools import count
from web3.auto import w3
import json
from collections import Counter, defaultdict
from dataclasses import dataclass, field
from decimal import Decimal
from itertools import chain
import requests
from eth_abi import encode_single
from eth_utils import function_signature_to_4byte_selector, decode_hex, encode_hex
from itertools import count
@banteg
banteg / get_tokens.py
Last active August 13, 2021 04:07
get all tokens a user has interacted with
from web3 import Web3, HTTPProvider
from eth_utils import encode_hex, event_signature_to_log_topic
from eth_abi import encode_single
w3 = Web3(HTTPProvider('http://127.0.0.1:8545', {'timeout': 120}))
transfer_topic = encode_hex(event_signature_to_log_topic('Transfer(address,address,uint256)'))
def get_tokens(address):
import requests
from tqdm import trange
from web3 import Web3, HTTPProvider
w3 = Web3(HTTPProvider('http://127.0.0.1:8545', {'timeout': 120}))
def get_contract(address):
resp = requests.get(
@banteg
banteg / lto.md
Last active January 23, 2019 21:30

How to access LTO node dashboard/API

To enable API in the docker-compose.yml, add these lines to the envoronment section:

      - LTO_API_KEY=your super secret password
      - LTO_ENABLE_REST_API=true

Access the node using SSH tunnel

import os
from operator import itemgetter
from json import JSONDecodeError
from time import sleep
import click
import requests
import pendulum
import requests
import click
LTO_NODE_URL = 'http://127.0.0.1:6869'
LTO_API_KEY = '<your api password>'
s = requests.session()
s.headers['X-API-Key'] = LTO_API_KEY
@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