Automatic Transaction Machine (ATxM) for Ethereum
Project description
Automatic Tx Machine 🏧
An async EVM transaction retry machine. Programmatically queue, broadcast, and retrying (speedup) transactions. Transactions are queued and broadcasted in a first-in-first-out (FIFO) order.
Installation
pip install atxm
Usage
from eth_account.local import LocalAccount
from web3 import Web3, HTTPProvider
from atxm import AutomaticTxMachine
from twisted.internet import reactor
account = LocalAccount.from_keyfile('path/to/keyfile', 'password')
w3 = Web3(HTTPProvider("http://localhost:8545"))
transaction = {
'chainId': 80001,
'to': '0x1234567890123456789012345678901234567890',
'nonce': 0,
'value': 0,
'gas': 21000,
'maxFeePerGas': '1',
'maxPriorityFeePerGas': '1',
}
machine = AutomaticTxMachine(w3=w3)
future_tx = machine.queue_transaction(
signer=account,
params=transaction,
)
reactor.start()
Features
Futures
The tracker returns a FutureTx
instance when a transaction is queued.
The FutureTx instance can be used to track the transaction's lifecycle and
to retrieve the transaction's receipt when it is finalized.
Retry Strategies
The tracker supports a generic configurable interface for retry strategies (AsynxTxStrategy
).
These strategies are used to determine when to retry a transaction and how to do so.
They can be configured to use any kind of custom context, like gas oracles.
Lifecycle Hooks
Hooks are fired in a dedicated thread for lifecycle events.
on_broadcast
: When a transaction is broadcasted.on_finalized
: When a transaction is finalized.on_pause
: When a transaction is halted by the strategy.on_fault
: When a transaction reverted or another error occurred.
Crash-Tolerance
Internal state is written to a file to help recover from crashes and restarts. Internally caches LocalAccount instances in-memory which in combination with disk i/o is used to recover from async task restarts.
Throttle
There are three rates, work (fast scan), idle (slow scan) and sleep (zero activity). This reduces the use of resources when there are no transactions to track. When a transaction is queued, the machine wakes up and goes to work. When all work is complete it eases into idle mode and eventually goes to sleep.
Event Loop Support
Currently, the machine is designed to work with the Twisted reactor. However, it can be adapted to work with any event loop.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file atxm-0.2.0.tar.gz
.
File metadata
- Download URL: atxm-0.2.0.tar.gz
- Upload date:
- Size: 56.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec662ee196d6f395c2054e39cd1d5a1fbcf2923b44b0bf39097d7f6dba441989 |
|
MD5 | 88094e7cc39de315b6dd5a67ec27fc08 |
|
BLAKE2b-256 | 771454cf060f14076aa01f800365cce03d3b5e6dde37c3f134d4c98447e5a128 |
File details
Details for the file atxm-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: atxm-0.2.0-py3-none-any.whl
- Upload date:
- Size: 42.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16502bb16b71bcfe8f89626cf6c574ae48365e1753582bdc2383a89d8a384de2 |
|
MD5 | 3e34b171591dc4761f26859f50a72127 |
|
BLAKE2b-256 | eb162486229bc737e0b17bbe09d5831b31a04462724dd8c57629498a8c3249bc |