pyetherscan.ethereum module

Library for building ethereum objects using the ETherscan API.

class pyetherscan.ethereum.Address(address)[source]

Bases: object

Represents a base address.

This uses the Client object to retrieve information about, and construct, the Address.

Public Attributes:
  • address
  • balance
  • blocks_mined
Public Methods:

Example Usage:

In [1]: address = '0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae'

In [2]: ethereum_address = Address(address)

In [3]: ethereum_address.balance
Out[3]: 748997604382925139479303.0

In [4]: for txn in ethereum_address.transactions:
   ...:     print(txn.value)

Initializes an ethereum address object.

balance

The balance in ether for this address.

blocks_mined
token_balance(contract_address)[source]

Obtains an address’s ERC-20 compliant token balance given a token contract address.

Parameters:contract_address (str) – The address of the token contract.
Returns:The balance of the token as a float.
transactions

returns a ethereum.TransactionContainer object. This object can be treated as a sequence object containing transactions this address was involved in.

class pyetherscan.ethereum.Block(block_number)[source]

Bases: object

Represents an ethereum block.

This uses the Client object to retrieve information about, and construct, the Block.

Public Attributes:
  • time_stamp
  • block_miner
  • block_reward
  • uncles
  • datetime_mined
  • uncle_inclusion_reward

Example Usage:

In [1]: address = '0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae'

In [2]: ethereum_address = Address(address)

In [3]: ethereum_address.balance
Out[3]: 748997604382925139479303.0

In [4]: for txn in ethereum_address.transactions:
   ...:     print(txn.value)
block_miner
block_reward
datetime_mined
time_stamp
uncle_inclusion_reward
uncles
class pyetherscan.ethereum.BlockContainer(block_list)[source]

Bases: object

Represents a sequence of blocks.

class pyetherscan.ethereum.Token(contract_address)[source]

Bases: object

Represents an ERC-20 compliant token.

Parameters:contract_address (str) – The address of the Token contract
supply
token_balance(address)[source]

The user balance of this token for a given address.

Parameters:address (str) – An ethereum address.
Returns:The balance as a float.
class pyetherscan.ethereum.Transaction(data)[source]

Bases: object

Represents a generic ethereum transaction. The object is built to lazily parse transactions. Attributes are only evaluated when called for the first time.

Public Attributes:

  • nonce
  • contract_address
  • cumulative_gas_used
  • hash
  • block_hash
  • time_stamp
  • gas
  • gas_price
  • value
  • block_number
  • block
  • to
  • from_
  • confirmations
  • input
  • transaction_index
  • type
  • datetime_executed
  • gas_used

Initializes the Transaction object.

Parameters:data (dict) – The dictionary of data that makes up the transaction.
block
block_hash
block_number
confirmations
contract_address
cumulative_gas_used
datetime_executed
from_
gas
gas_price
gas_used
hash
input
nonce
time_stamp
to
transaction_index
type
value
class pyetherscan.ethereum.TransactionContainer(transaction_list)[source]

Bases: object

Represents a sequence of transactions (normal and internal).