Public API¶
Typed¶
- class alysis.Node(*, root_balance_wei: int, evm_version: EVMVersion = EVMVersion.PRAGUE, 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_transactionsisTrue, 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: BlockHash, *, with_transactions: bool) BlockInfo[source]¶
Returns information about a block by hash.
Raises
BlockNotFoundif 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
BlockNotFoundif 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[TxHash] | list[BlockHash][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: TxHash) TxInfo[source]¶
Returns the information about a transaction requested by transaction hash.
Raises
TransactionNotFoundif 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: TxHash) TxReceipt[source]¶
Returns the receipt of a transaction by transaction hash.
Raises
TransactionNotFoundif 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) TxHash[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.
- class alysis.EVMVersion(value)[source]¶
Supported EVM versions. Some may not be available depending on the compiler version.
- BERLIN = 'berlin'¶
Berlin fork, Apr 15, 2021.
- BYZANTIUM = 'byzantium'¶
Byzantium fork, Oct 16, 2017.
- CANCUN = 'cancun'¶
Cancun fork, Mar 13, 2024.
- CONSTANTINOPLE = 'constantinople'¶
Constantinople fork, Feb 28, 2019.
- HOMESTEAD = 'homestead'¶
Homestead fork, Mar 14, 2016.
- ISTANBUL = 'istanbul'¶
Istanbul fork, Dec 8, 2019.
- LONDON = 'london'¶
London fork, Aug 5, 2021.
- PARIS = 'paris'¶
Paris fork, Sep 15, 2022.
- PRAGUE = 'prague'¶
Prague fork, May 7, 2025.
- SHANGHAI = 'shanghai'¶
Shanghai fork, Apr 12, 2023.
- SPURIOUS_DRAGON = 'spuriousDragon'¶
Spurious Dragon fork, Nov 22, 2016.
- TANGERINE_WHISTLE = 'tangerineWhistle'¶
Tangerine Whistle fork, Oct 18, 2016.