Skip to main content

PyEtherBalance

pyetherbalance is a python module for getting Ethereum and er20 token balances. There are other modules like web3py out there, however the goal of this module is to be super light weight and not depend on too many other modules.

Installation

Simply clone the project and run python setup.py install - or install via pip pip install pyetherbalance.

This module only depends on the 'requests' library in python to send post requests

Basic Usage:

import pyetherbalance 
# Sign up for https://infura.io/, and get the url to an ethereum node
infura_url = 'https://mainnet.infura.543254324532543254345'
ethereum_address = '0xeb9f035dd1211af75976427d68d2d6dc549c458e'
# Create an pyetherbalance object , pass the infura_url
ethbalance = pyetherbalance.PyEtherBalance(infura_url)
# get ether balance
balance_eth = ethbalance.get_eth_balance(ethereum_address)
print(balance_eth)
# get token balance 
balance_omg = ethbalance.get_token_balance('OMG', ethereum_address)
print(balance_omg)

Advanced Usage:

Adding tokens

Currently the module uses https://github.com/ethereum-lists/tokens for a list of tokens. If you want to add your own custom token, you can follow the steps below. This will also work for overwriting internal token contract addresses.

import pyetherbalance 
# Sign up for https://infura.io/, and get the url to an ethereum node
infura_url = 'https://mainnet.infura.543254324532543254345'
ethereum_address = '0xeb9f035dd1211af75976427d68d2d6dc549c458e'
# Create an pyetherbalance object , pass the infura_url
ethbalance = pyetherbalance.PyEtherBalance(infura_url)
# New token symbol
token = "OMG"
# Token details. The fields below are all required
details = {'symbol': 'OMG', 'address': '0xd26114cd6EE289AccF82350c8d8487fedB8A0C07', 'decimals': 18, 'name': 'OmiseGO'}
# Add token 
erc20tokens = ethbalance.add_token(token, details)
# print list of all internal tokens
print(erc20tokens['OMG'])

Getting all tokens:

import pyetherbalance 
# Sign up for https://infura.io/, and get the url to an ethereum node
infura_url = 'https://mainnet.infura.543254324532543254345'
# Create an pyetherbalance object , pass the infura_url
ethbalance = pyetherbalance.PyEtherBalance(infura_url)
# Get a dictionary with all tokens and details 
erc20tokens = ethbalance.get_erc20_tokens()
print(erc20tokens)

Testing:

Test You can test on either Ropsten, Kovan, Rinkeby or local testnets by providing the url of your corresponding ethereum node, while initializing pyetherbalance object.

Copyright

MTI License - See LICENSE for details.

Changelog

Version 0.0.1

New

  • First Working Version

Release files for pyetherbalance 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyetherbalance 0.0.1
File Size Uploaded
pyetherbalance-0.0.1.tar.gz 124.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyetherbalance 0.0.1
File Interpreter ABI Platform
pyetherbalance-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 254.7 kB

Release files / pyetherbalance-0.0.1.tar.gz

Download URL pyetherbalance-0.0.1.tar.gz
Size 124.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3ab72404e32790f69ed4207f388f8693b50a41756c3102a615cbfe3a53d287c0
BLAKE2b-256 checksum
How to use checksums
9ca56bab3ba914cc4af0835c5ddc2049b66bc119b3a486f0e0703932da0759bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.4

Release files / pyetherbalance-0.0.1-py3-none-any.whl

Download URL pyetherbalance-0.0.1-py3-none-any.whl
Size 129.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
05776a268d3fe0077a000c7f0e3df0411177743f5316ded40f74218292346316
BLAKE2b-256 checksum
How to use checksums
3a61a22d94e286f12297b3427bfd32d6f3eb1531cf3aa3407ebc8ceca62d6be8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.4

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page