ethextended¶
ethextended is a python library with external tools provided by different services (like etherscan.io, ethgasstation.info, and others).
Contents¶
Installation¶
Install using pip:
$ pip3 install ethextended
Or build from source:
$ python3 setup.py install
Accounts¶
-
class
ethextended.
account
¶
This class is the parent of all functions related to Ethereum addresses (accounts).
-
account.
address_autocomplete
(address)¶
- Uses
etherscan.io
API
Takes not completed address like 0x3f5CE5
, and returns a list of possible addresses with any transaction like ['0x3F5ce52A7ea4471a73b7aCA7bCcc9b03ea8449bE', '0x3f5...]
.
>>> ethextended.account.address_autocomplete("0x3f5CE5")
['0x3F5ce52A7ea4471a73b7aCA7bCcc9b03ea8449bE', '0x3f5cE530eF787ce64e277D84aa4546b520D62f9E', '0x3f5cE541912eb5cFE38b9e1F84c0E37504f89212', '0x3F5CE5cBbAdB3102f62051CF14c25630bF16c65D', '0x3f5CE5FBFe3E9af3971dD833D26bA9b5C936f0bE']
- Uses
etherscan.io
API
Displays address tags, gathered from etherscan.io
.
Note
The first tag would be the main tag of the address. Others would be as additional.
>>> ethextended.account.address_tags("0x3f5CE5FBFe3E9af3971dD833D26bA9b5C936f0bE")
['Binance', 'Exchange']
-
account.
address_label
(address)¶
- Uses
etherscan.io
API
Displays address label given by etherscan.io
.
>>> ethextended.account.address_label("0x3f5CE5FBFe3E9af3971dD833D26bA9b5C936f0bE")
'Binance 1'
-
account.
transactions
(address)¶
- Uses
etherscan.io
API
Returns list of latest transactions (max. 10 000). Transactions sorted by new.
Warning
This method can take several seconds.
# Returns array with transactions
>>> transactions = ethextended.account.transactions("0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb")
# First transaction
>>> transactions[-1]
{
'blockNumber': '414116',
'timeStamp': '1445375797',
'hash': '0x9ae04758afbea7867023ee11c631f63657c88fa07ce5b1a7666229a891bc3460',
'nonce': '28',
'blockHash': '0xcfc5396f0b0ad784ce5318b829f36fd5b4db7161e49e5abda08f4bc1290c8c02',
'transactionIndex': '0',
'from': '0x70e3e34c0100b1e05700fa699183c82af7a25ba0',
'to': '0xd1220a0cf47c7b9be7a2e6ba89f429762e7b9adb',
'value': '10000000000000000000',
'gas': '121000',
'gasPrice': '50000000000',
'isError': '0',
'txreceipt_status': '',
'input': '0x',
'contractAddress': '',
'cumulativeGasUsed':
'21000',
'gasUsed':
'21000',
'confirmations': '8205501'
}
Gas¶
-
class
ethextended.
gas
¶
This class is the parent of all functions related to Ethereum gas.
-
gas.
fast_wei
()¶
- Uses
ethgasstation.info
API
Returns fast gas price (in wei
)
>>> ethextended.gas.fast_wei()
24000000000
-
gas.
fast_waittime
()¶
- Uses
ethgasstation.info
API
Returns calculated fast
waiting time.
>>> ethextended.gas.fast_waittime()
24.0
-
gas.
avg_wei
()¶
- Uses
ethgasstation.info
API
Returns average gas price (in wei
)
>>> ethextended.gas.avg_wei()
22100000000
-
gas.
avg_waittime
()¶
- Uses
ethgasstation.info
API
Returns calculated average
waiting time.
>>> ethextended.gas.avg_waittime()
216.0
-
gas.
slow_wei
()¶
- Uses
ethgasstation.info
API
Returns slow gas price (in wei
)
>>> ethextended.gas.slow_wei()
22000000000
-
gas.
slow_waittime
()¶
- Uses
ethgasstation.info
API
Returns calculated slow
waiting time.
>>> ethextended.gas.slow_waittime()
474.0
Identicons¶
Warning
Identicons aren’t generated locally, library uses eth.vanity.show
public API.
-
class
ethextended.
indenticon
¶
This class is the parent of all functions related to Ethereum identicons.
-
identicon.
base64
(address)¶
- Uses
eth.vanity.show
API
Returns base64
encoded PNG
image (in bytes).
>>> ethextended.identicon.base64("0x3f5CE5FBFe3E9af3971dD833D26bA9b5C936f0bE")
b'iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABmJLR0QA/wD/AP+gvaeTAAABE0lEQVR4nO2asQ3CMBQFbZQZAIkasQSIgpoVUrEhtFQMQM0AKZgCNvArPtYB/11rYp1OX8KRUy/79as0WD0WreUybZ7N9d5E/WaflPlFHIAWoHEAWoDGAWgBmqrOAf9O+glwAFqAxgFoARoHoAVohugG19u5uX7YHb96//QT4AC0AI0D0AI0DkAL0MhzQPR/WD2viO6vnk8/AQ5AC9A4AC1A4wC0AI08B4zzU/sH4n4+irr/V36T2D/9BDgALUDjALQAjQPQAjThewH1Hd5YxDkiuL86JyjST4AD0AI0DkAL0DgALUBT78utvxPMjAPQAjQOQAvQOAAtQDNE37d7v6/39ks/AQ5AC9A4AC1A4wC0AM0bhiwxFBovXU0AAAAASUVORK5CYII='
-
identicon.
url
(address)¶
- Uses
eth.vanity.show
API
Returns url to identicon PNG
image.
>>> ethextended.identicon.url("0x3f5CE5FBFe3E9af3971dD833D26bA9b5C936f0bE")
'https://eth.vanity.show/0x3f5CE5FBFe3E9af3971dD833D26bA9b5C936f0bE'
Internal Utillities¶
-
class
ethextended.
utils
¶
Local native ethereum utillities, that don’t need internet connection.
-
utils.
clear_0x
(text)¶
Removes 0x
prefix from text.
>>> ethextended.utils.clear_0x("0x3f5CE5FBFe3E9af3971dD833D26bA9b5C936f0bE")
'3f5CE5FBFe3E9af3971dD833D26bA9b5C936f0bE'
-
utils.
is_hex
(text)¶
Checks if input text is hexdecimal
.
>>> ethextended.utils.is_hex("0x1234567890ABCDEF")
True
>>> ethextended.utils.is_hex("0x1234567890ABCDEFGHIJKLMNOP")
False
-
utils.
is_address
(text)¶
Checks if input text is address
.
>>> ethextended.utils.is_address("0x3f5CE5FBFe3E9af3971dD833D26bA9b5C936f0bE")
True
>>> ethextended.utils.is_address("0xE9af3971dD833D26bA")
False
-
utils.
to_checksum_address
(text)¶
Converts address to checksum
format.
>>> ethextended.utils.to_checksum_address("0x3f5ce5fbfe3e9af3971dd833d26ba9b5c936f0be")
'0x3f5CE5FBFe3E9af3971dD833D26bA9b5C936f0bE'