This release is a pre-release and may not be stable for production use.
ethtoken.py
This is a tiny library leveraging web3.py to make an interface for working with EIP20 tokens on Ethereum. (formerly ERC20)
It is currently in Alpha, with 0 automated tests
Usage
Install
virtualenv -p python3 venv
. venv/bin/activate
pip install --pre ethtoken
Initialize
from ethtoken import token
# Use the ENS name that points to your token contract here:
omg = token("omg.thetoken.eth")
Use standard EIP20 methods
Most EIP20 methods are optional. ethtoken makes no attempt to verify which methods are implemented by a token contract.
Here’s an example with all the read functions working:
>>> omg.name()
'OMGToken'
>>> omg.symbol()
'OMG'
>>> omg.decimals()
18
>>> omg.totalSupply()
140245398245132780789239631
# Use the ENS name of the owner address here:
>>> omg.balanceOf('ethereumfoundation.eth')
308744633639977714804
Custom methods
ethtoken has a single custom method not in the EIP20 spec: token_balance.
>>> omg.token_balance("ethereumfoundation.eth")
Decimal('308.744633639977714804')
It returns the balance of an address, with the decimal point shifted according to the decimals() value on the contract. In other words, it is the human-readable number of tokens that the given address owns.
Completely Untested: Transfers
In theory, you could use this to send a token. I haven’t even tried it once yet. Just don’t use it. If you’re going to ignore me, don’t blame me if you lose tokens or ether.
This should theoretically transfer 1 giga units from 0x0 to 0xdead. (That’s 1 nanotoken, at 18 decimals). Of course, this won’t work if you don’t control the 0x0 address. (hint: you don’t)
from web3 import Web3
>>> omg.transfer(
'0x000000000000000000000000000000000000dEaD',
10 ** 9,
transact={
'from': '0x0000000000000000000000000000000000000000',
'gasPrice': Web3.toWei('0.1', 'gwei'),
},
)
Ownership Disclosure
I own some OmiseGo tokens, because anyone who had some ether during their airdrop got some. I don’t have any opinions on the company or token.
Metadata
Release files for ethtoken 0.0.1a4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ethtoken-0.0.1a4.tar.gz | 3.7 kB | Without provenance | Details for ethtoken-0.0.1a4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ethtoken-0.0.1a4-py3-none-any.whl | Python 3 | none | any | Details for ethtoken-0.0.1a4-py3-none-any.whl |
Total release size: 7.8 kB
Release files / ethtoken-0.0.1a4.tar.gz
| Download URL | ethtoken-0.0.1a4.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
22776382a76b31cef0ecfa13781d68cab3fffacbb6990b5e5bd21da7cb036d2b
|
|
BLAKE2b-256 checksum How to use checksums |
ac4e3fe9a6dfc94217f4250d0d1f467420c0adbd2158ab2a135a9beeb9da761b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.6
|
Release files / ethtoken-0.0.1a4-py3-none-any.whl
| Download URL | ethtoken-0.0.1a4-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
31866fed979254565ad33224d89330cd9cec187ef09d65fdbbe73005ddf6d230
|
|
BLAKE2b-256 checksum How to use checksums |
ce0e44fc7c399ee3004304210cfc54870f4c7e4acbebedc26a6e4bbf42ca7e3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.6
|
Security for ethtoken 0.0.1a4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.