Chain Sniper
A high-performance EVM blockchain listener and transaction monitor.
Install
git clone https://github.com/rakibhossain72/chain-sniper.git
cd chain-sniper
uv sync
Or with pip:
pip install chain-sniper
Quick Start
from chain_sniper import ChainSniper
ERC20_ABI = [...] # Transfer event ABI
USDT = "0x55d398326f99059fF775485246999027B3197955"
sniper = ChainSniper("wss://bsc-ws-node.nariox.org:443")
@sniper.event(contract=USDT, abi=ERC20_ABI, name="Transfer")
async def handle_transfer(event):
print(f"Transfer: {event['args']['value'] / 10**18} USDT")
await sniper.start()
Use a WebSocket URL (wss:// or ws://) — that's the only supported transport.
RPC Pool (fault-tolerant)
from chain_sniper.rpc_pool import RPCPool
pool = await RPCPool.create(
rpcs=[
"https://bsc-dataseed1.binance.org",
"wss://bsc-ws-node.nariox.org:443",
],
expected_chain_id=56,
)
sniper = ChainSniper(pool)
Transaction Monitoring
sniper.block_detail("full_block")
@sniper.on_transaction
async def handle_tx(tx):
print(f"{tx['hash']} | {tx['from']} -> {tx['to']}")
Filtering
MongoDB-style rules with operators: $eq, $ne, $gt, $gte, $lt, $lte, $in, $nin, $regex, $exists.
from chain_sniper import Filter
f = Filter()
f.add_tx_rule({"value": {"_op": "$gte", "_value": 10**18}})
f.add_log_rule({"args.value": {"_op": "$gte", "_value": 1000 * 10**18}})
sniper.filter(f)
Dynamic Rules via Redis
Inject or remove filter rules at runtime without restarting:
from chain_sniper.listener import RedisRuleListener
redis_listener = RedisRuleListener(
dynamic_filter=f,
redis_url="redis://localhost",
channel="sniper_rules",
)
await redis_listener.start()
Push rules from anywhere:
import redis, json
r = redis.Redis(host="localhost", port=6379, decode_responses=True)
r.publish("sniper_rules", json.dumps({"action": "add_tx", "rule": {"to": "0x..."}}))
Key API
| Method | Description |
|---|---|
@sniper.event(contract, abi, name) |
Register an event handler |
@sniper.on_transaction |
Handle individual transactions |
@sniper.on_block |
Handle new blocks |
@sniper.on_reorg |
Handle chain reorgs |
sniper.filter(f) |
Attach a Filter |
sniper.block_detail("header" | "full_block") |
Set block detail level |
sniper.start() / .stop() |
Start or stop monitoring |
See examples/ for complete usage patterns.
License
MIT
Metadata
Release files for chain-sniper 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| chain_sniper-0.1.2.tar.gz | 194.6 kB | Without provenance | Details for chain_sniper-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| chain_sniper-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for chain_sniper-0.1.2-py3-none-any.whl |
Total release size: 238.0 kB
Release files / chain_sniper-0.1.2.tar.gz
| Download URL | chain_sniper-0.1.2.tar.gz |
|---|---|
| Size | 194.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bf6c61d34e042babd8a09438c27e198eb15603ae4ea6f1e4cf473d00de08253e
|
|
BLAKE2b-256 checksum How to use checksums |
175fbe06528e3ed5e040243a4952bbb50a960f472db88ef1b8d5688fffd08d3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.20
|
Release files / chain_sniper-0.1.2-py3-none-any.whl
| Download URL | chain_sniper-0.1.2-py3-none-any.whl |
|---|---|
| Size | 43.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
862c2696bd974099366269a89aeb0699d8f01327fd362a7c92d1e83381866d18
|
|
BLAKE2b-256 checksum How to use checksums |
5dd7a53a57ea5898d0477db0fed9f6a0f5f04c007c49483ddb980c5a25d0c503
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.20
|
Security for chain-sniper 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.