Pyetherchain
A python interface to the ethereum blockchain explorer at www.etherchain.org ❤⛓🐍
Install / Use
/learn @tintinweb/PyetherchainREADME
pyetherchain
A python interface to the ethereum blockchain explorer at www.etherchain.org ❤⛓🐍
- Access accounts, contracts, transaction, source-code, charts, correlations on www.etherchain.org
- abi-decode the constructor and transaction inputs to a human readable form
- dump smart-contract source-code with extra information
- provides a scriptable commandline interface
python -m pyetherchain -c "etherchain.account('address'); any other python code"(warning security) - provides an interactive mode with autocompletion to play with etherchain.org in your shell
python -m pyetherchain(default) - can easily be used as a library in your projects
🐍 Python 3.x
FUN
see advertising campaign via transactions to popular contracts
Dumped Contracts with abi decoded constructor/transactions

Interfaces
- EtherChainAccount - interface to account/contract addresses
- EtherChainTransaction - interface to transactions
- EtherChain - interface to general discovery/exploration/browsing api on etherchain
- EtherChainCharts - interface to statistics and charting features
Backend
- UserAgent - error correcting user agent for api interface
- EtherChainApi - main api interface
Experimental
- ContractAbi
- AbiMethod
Install
#> pip install pyetherchain
or
#> python setup.py install
Usage
Interactive mode:
#> python -m pyetherchain
==================================================================
pyetherchain - cli
==================================================================
Welcome to pyetherchain - the python interface to etherchain.org.
Here's a quick help to get you started :)
Available Classes
* EtherChain - interface to general discovery/exploration/browsing api on etherchain
* EtherChainAccount - interface to account/contract addresses
* EtherChainTransaction - interface to transactions
* EtherChainCharts - interface to statistics and charting features
* EtherChainApi - remote communication api
Available instances:
* etherchain - is an instance of EtherChain() - the main entry point
* api - is an instance of the back-end api connector
* logger - is the module logger instance
Examples:
etherchain
etherchain.account("ab7c74abc0c4d48d1bdad5dcb26153fc8780f83e")
etherchain.account("ab7c74abc0c4d48d1bdad5dcb26153fc8780f83e").transactions()
etherchain.transaction("d8df011e6112e2855717a46a16975a3b467bbb69f6db0a26ad6e0803f376dae9")
etherchain.transactions(start=0, length=10)
etherchain.transactions_pending(start=0, length=10)
etherchain.blocks(start=0, length=10)
etherchain.charts # access the charts api
etherchain.charts.price_usd()
exit() or ctr+c (multiple times) to quit.
>>> etherchain.<TAB for autocompletion>
Commandline scripting mode (dangerous because cmdline params will be eval'd):
python -m pyetherchain -c "print etherchain.account(0xaddress); "
Random Examples
from pyetherchain.pyetherchain import EtherChain
e = EtherChain()
# getting an accoutn object
ac = e.account("0x6090A6e47849629b7245Dfa1Ca21D94cd15878Ef")
# show the account object (json), retrieve the source if available, show transactions
print ac
print ac.source
print ac.swarm_hash
print ac.transactions()
print ac.history()
# access the charts api
print e.charts.market_cap()
# retrieve hardfork information
print e.hardforks()
# list pending transaactions (takes arguments)
print e.transactions_pending()
# describe the constructor invokation and other transaction in a human readable way
contract = e.account("0x6090A6e47849629b7245Dfa1Ca21D94cd15878Ef")
print "constructor: %s" % contract.abi.describe_constructor(contract.constructor_args)
for tx in contract.transactions(direction="in", length=10000)["data"]:
tx_obj = e.transaction(tx["parenthash"])[0]
print "transaction: [IN] <== %s : %s" % (tx_obj["hash"], contract.abi.describe_input(tx_obj["input"]))
# or just shorthand dump contract with extra info
contract.describe_contract()
# directly work with the backend api interface
e = EtherChainApi()
print e.get_transaction("c98061e6e1c9a293f57d59d53f4e171bb62afe3e5b6264e9a770406a81fb1f07")
print e.get_transactions_pending()
print e.get_transactions()
print e.get_blocks()
print e.get_accounts()
print e.get_hardforks()
# print e.get_correlations()
# print e.get_stats_price_btc()
print e.get_account_transactions("0x1104e154efa21ff3ca5da097f8906cd56b1e7d86")
try:
print e.get_account_abi("0x1104e154efa21ff3ca5da097f8906cd56b1e7d86")
print e.get_account_source(("0x1104e154efa21ff3ca5da097f8906cd56b1e7d86"))
except Exception, e:
pass
Output
{u'nonce': None, u'txsent': 3802934, u'code': u'606060405236156101175763ffffffff60e060020a6000350416630230a07c811461011957806313c89a8f1461012e57806315f733311461015357806322ec1244146101ab5780632525f5c1146101e2578063267b6922146102035780633f15457f1461025e57806347872b421461028a5780635ddae283146102a55780635e431709146102ba57806361d585da146102f557806379ce9fac1461032c578063935033371461034d578063983b94fb146103775780639c67f06f1461038c578063ae1a0b0c146103ae578063ce92dced146103d7578063de10f04b146103e4578063e27fe50f14610439578063ea9e107a1461048e578063ede8acdb146104b2578063faff50a8146104c7578063febefd61146104e9575bfe5b341561012157fe5b61012c600435610538565b005b341561013657fe5b610141600435610764565b60408051918252519081900360200190f35b341561015b57fe5b61012c600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284375094965061078995505050505050565b005b34156101b357fe5b610141600435600160a060020a0360243516604435606435610aac565b60408051918252519081900360200190f35b34156101ea57fe5b61012c600160a060020a0360043516602435610af3565b005b341561020b57fe5b610216600435610cb9565b6040518086600581111561022657fe5b60ff168152600160a060020a0390951660208601525060408085019390935260608401919091526080830152519081900360a0019150f35b341561026657fe5b61026e610d0a565b60408051600160a060020a039092168252519081900360200190f35b341561029257fe5b61012c600435602435604435610d19565b005b34156102ad57fe5b61012c600435611277565b005b34156102c257fe5b61026e600160a060020a03600435166024356114e7565b60408051600160a060020a039092168252519081900360200190f35b34156102fd57fe5b61030860043561150d565b6040518082600581111561031857fe5b60ff16815260200191505060405180910390f35b341561033457fe5b61012c600435600160a060020a036024351661158b565b005b341561035557fe5b6103636004356024356116cb565b604080519115158252519081900360200190f35b341561037f57fe5b61012c6004356116e1565b005b341561039457fe5b610141611944565b60408051918252519081900360200190f35b34156103b657fe5b6103be61194a565b6040805163ffffffff9092168252519081900360200190f35b61012c600435611951565b005b34156103ec57fe5b61012c600480803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843750949650611a4495505050505050565b005b341561044157fe5b61012c600480803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843750949650611aa595505050505050565b005b341561049657fe5b61012c600435600160a060020a0360243516604435610cb4565b005b34156104ba57fe5b61012c600435611ae5565b005b34156104cf57fe5b610141611c34565b60408051918252519081900360200190f35b61012c6004808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437509496505093359350611c3a92505050565b005b6000808260025b6105488261150d565b600581111561055357fe5b1415806105e0575060008181526002602090815260408083205481518301849052815160e060020a638da5cb5b0281529151600160a060020a0390911693638da5cb5b93600480850194919392918390030190829087803b15156105b357fe5b60325a03f115156105c057fe5b50505060405180519050600160a060020a031633600160a060020a031614155b156105eb5760006000fd5b600084815260026020526040902080546001820154919450600160a060020a031692506301e13380014210801561069b575060008054600154604080516020908101859052815160e060020a6302571be302815260048101939093529051600160a060020a03308116959416936302571be3936024808201949392918390030190829087803b151561067957fe5b60325a03f1151561068657fe5b50505060405180519050600160a060020a0316145b156106a65760006000fd5b60006002840181905560038401558254600160a060020a03191683556106cb84611c51565b81600160a060020a031663bbe427716103e86040518263ffffffff1660e060020a02815260040180828152602001915050600060405180830381600087803b151561071257fe5b60325a03f1151561071f57fe5b5050506002830154604080519182525185917f292b79b9246fa2c8e77d3fe195b251f9cb839d7d038e667c069ee7708c631e16919081900360200190a25b5b50505050565b6004547001000000000000000000000000000000006249d4008184040204015b919050565b60006000826040518082805190602001908083835b602083106107bd5780518252601f19909201916020918201910161079e565b5181516020939093036101000a600019018019909116921691909117905260405192018290039091209250600291508190505b6107f98361150d565b600581111561080457fe5b1461080f5760006000fd5b600661081a86611e19565b11156108265760006000fd5b846040518082805190602001908083835b602083106108565780518252601f199092019160209182019101610837565b51815160209384036101000a60001901801990921691161790526040805192909401829003909120600081815260029092529290209197509095506108a09250869150611c519050565b8254600160a060020a0316156109e8576108c58360020154662386f26fc10000611ecc565b60028085018290558454600160a060020a03169163b0c8097291905b6040805160e060020a63ffffffff8616028152929091046004830152600060248301819052905160448084019382900301818387803b151561091f57fe5b60325a03f1151561092c57fe5b505083546040805160e060020a6313af4035028152600160a060020a03338116600483015291519190921692506313af40359160248082019260009290919082900301818387803b151561097c57fe5b60325a03f1151561098957fe5b505083546040805160e060020a63bbe427710281526103e860048201529051600160a060020a03909216925063bbe4277191

