Public API#
Typed#
- class alysis.Node(*, root_balance_wei: int, chain_id: int = 107118521969011, net_version: int = 1, auto_mine_transactions: bool = True)[source]#
An Ethereum node maintaining its own local chain.
If
auto_mine_transactions
isTrue
, a new block is mined after every successful transaction.- eth_call(params: EthCallParams, block: int | BlockLabel) bytes [source]#
Executes a new message call immediately without creating a transaction on the blockchain.
If the transaction is invalid, raises
ValidationError
. If the transaction is sent to the EVM but is reverted during execution, raisesTransactionReverted
. If there were other problems with the transaction, raisesTransactionFailed
.
- eth_estimate_gas(params: EstimateGasParams, block: int | BlockLabel) int [source]#
Generates and returns an estimate of how much gas is necessary to allow the transaction to complete. The transaction will not be added to the blockchain.
If the transaction is invalid, raises
ValidationError
. If the transaction is sent to the EVM but is reverted during execution, raisesTransactionReverted
. If there were other problems with the transaction, raisesTransactionFailed
.
- eth_get_balance(address: Address, block: int | BlockLabel) int [source]#
Returns the balance (in wei) of the account of given address.
- eth_get_block_by_hash(block_hash: Hash32, *, with_transactions: bool) BlockInfo [source]#
Returns information about a block by hash.
Raises
BlockNotFound
if the requested block does not exist.
- eth_get_block_by_number(block: int | BlockLabel, *, with_transactions: bool) BlockInfo [source]#
Returns information about a block by block number.
Raises
BlockNotFound
if the requested block does not exist.
- eth_get_code(address: Address, block: int | BlockLabel) bytes [source]#
Returns code of the contract at a given address.
- eth_get_filter_changes(filter_id: int) list[LogEntry] | list[Hash32] [source]#
Polling method for a filter, which returns an array of logs which occurred since last poll.
Note
This method will not return the events that happened before the filter creation, even if they satisfy the filter predicate. Call
eth_get_filter_logs()
to get those.
- eth_get_filter_logs(filter_id: int) list[LogEntry] [source]#
Returns an array of all logs matching filter with given id.
- eth_get_logs(params: FilterParams | FilterParamsEIP234) list[LogEntry] [source]#
Returns an array of all logs matching a given filter object.
- eth_get_storage_at(address: Address, slot: int, block: int | BlockLabel) bytes [source]#
Returns the value from a storage position at a given address.
- eth_get_transaction_by_hash(transaction_hash: Hash32) TransactionInfo [source]#
Returns the information about a transaction requested by transaction hash.
Raises
TransactionNotFound
if the transaction with this hash has not been included in a block yet.
- eth_get_transaction_count(address: Address, block: int | BlockLabel) int [source]#
Returns the number of transactions sent from an address.
- eth_get_transaction_receipt(transaction_hash: Hash32) TransactionReceipt [source]#
Returns the receipt of a transaction by transaction hash.
Raises
TransactionNotFound
if the transaction with this hash has not been included in a block yet.
- eth_new_block_filter() int [source]#
Creates a filter in the node, to notify when a new block arrives. Returns the identifier of the created filter.
- eth_new_filter(params: FilterParams) int [source]#
Creates a filter object, based on filter options, to notify when the state changes (logs). Returns the identifier of the created filter.
- eth_new_pending_transaction_filter() int [source]#
Creates a filter in the node, to notify when new pending transactions arrive. Returns the identifier of the created filter.
- eth_send_raw_transaction(raw_transaction: bytes) Hash32 [source]#
Attempts to add a signed RLP-encoded transaction to the current block. Returns the transaction hash on success.
If the transaction is invalid, raises
ValidationError
. If the transaction is sent to the EVM but is reverted during execution, raisesTransactionReverted
. If there were other problems with the transaction, raisesTransactionFailed
.
RPC#
- class alysis.RPCNode(node: Node)[source]#
A wrapper for
Node
exposing an RPC-like interface, taking and returning JSON-compatible data structures.
Exceptions#
Schema#
- alysis.schema.JSON#
Values serializable to JSON.
- class alysis.schema.BlockInfo(number: int, hash: None | Hash32, parent_hash: Hash32, nonce: None | BlockNonce, sha3_uncles: Hash32, logs_bloom: None | LogsBloom, transactions_root: Hash32, state_root: Hash32, receipts_root: Hash32, miner: None | Address, difficulty: int, total_difficulty: None | int, extra_data: bytes, size: int, gas_limit: int, gas_used: int, base_fee_per_gas: int, timestamp: int, transactions: list[TransactionInfo] | list[Hash32], uncles: list[Hash32])[source]#
Block info.
- enum alysis.schema.BlockLabel(value)[source]#
Block label.
Valid values are as follows:
- LATEST = <BlockLabel.LATEST: 'latest'>#
- PENDING = <BlockLabel.PENDING: 'pending'>#
- SAFE = <BlockLabel.SAFE: 'safe'>#
- FINALIZED = <BlockLabel.FINALIZED: 'finalized'>#
- EARLIEST = <BlockLabel.EARLIEST: 'earliest'>#
- class alysis.schema.EthCallParams(to: Address, from_: None | Address = None, gas: None | int = None, gas_price: int = 0, value: int = 0, data: None | bytes = None)[source]#
Transaction fields for
eth_call
.
- class alysis.schema.EstimateGasParams(from_: Address, to: None | Address = None, gas: None | int = None, gas_price: int = 0, nonce: None | int = None, value: int = 0, data: None | bytes = None)[source]#
Transaction fields for
eth_estimateGas
.
- class alysis.schema.FilterParams(from_block: None | int | BlockLabel = None, to_block: None | int | BlockLabel = None, address: None | Address | list[Address] = None, topics: None | list[None | LogTopic | list[LogTopic]] = None)[source]#
Filter parameters for
eth_getLogs
oreth_newFilter
.
- class alysis.schema.FilterParamsEIP234(block_hash: Hash32, address: None | Address | list[Address] = None, topics: None | list[None | LogTopic | list[LogTopic]] = None)[source]#
Alternative filter parameters for
eth_getLogs
(introduced in EIP-234).
- class alysis.schema.LogEntry(address: Address, block_hash: Hash32, block_number: int, data: bytes, log_index: int, removed: bool, topics: list[LogTopic], transaction_index: int, transaction_hash: Hash32)[source]#
Log entry.
- class alysis.schema.TransactionInfo(chain_id: int, block_hash: None | Hash32, block_number: int, from_: Address, gas: int, gas_price: int, max_fee_per_gas: int, max_priority_fee_per_gas: int, hash: Hash32, input: bytes, nonce: int, to: Address, transaction_index: None | int, type: int, value: int, v: int, r: int, s: int)[source]#
Transaction info.
- class alysis.schema.TransactionReceipt(transaction_hash: Hash32, transaction_index: int, block_hash: Hash32, block_number: int, from_: Address, to: None | Address, cumulative_gas_used: int, effective_gas_price: int, gas_used: int, contract_address: None | Address, logs: list[LogEntry], logs_bloom: LogsBloom, type: int, status: int)[source]#
Transaction receipt.