RPCMaker
This is a simple helper to provide the formatted JSON-RPC for the subscription.
It is possible to write and pass them manually to the SubscriberClient.
- class sub3.RPCMaker[source]
- logs() list[str, Dict][source]
JSON-RPC for the logs in the new imported blocks according to the filters
- Possible kwargs:
address: either an address or an array of addresses. Only logs that are created from these addresses are returned (optional)
topics: only logs which match the specified topics (optional)
>>> RPCMaker.logs( address="0x8320fe7702b96808f7bbc0d4a888ed1468216cfd", topics=["0xd78a0cb8bb633d06981248b816e7bd33c2a35a6089241d099fa519e361cab902"] ) {'jsonrpc': '2.0', 'id': '1', 'method': 'eth_subscribe', 'params': ['logs', {'address': '0x8320fe7702b96808f7bbc0d4a888ed1468216cfd', 'topics': [ '0xd78a0cb8bb633d06981248b816e7bd33c2a35a6089241d099fa519e361cab902' ]}]}
- new_heads() list[str, Dict][source]
JSON-RPC for the new blocks as they are mined
- Parameters
kwargs – Nethermind has the possibility for
{"includeTransactions":"true"}, Geth doesn’t accept any args
- new_pending_transaction() list[str, Dict][source]
JSON-RPC for the pending transaction as they are added in the mempool
- Parameters
kwargs – This RPC Don’t usually take additional args
- syncing() list[str, Dict][source]
JSON-RPC for the syncing status of the connected node
- Parameters
kwargs – This RPC Don’t usually take additional args
- static unsubscribe(confirmation_id) list[str, Dict][source]
JSON-RPC for unsubscribing to an ongoing JSON-RPC call. The client should normally close the WebSocket properly but it is still available in case someone would have the need for it
- Parameters
confirmation_id – This is the identification as written in the field
resultof the subscription confirmation.
{"jsonrpc":"2.0","id":"1","result":"0x57c86f70cf91507bdb29953e121cb174"} >>> RPCMaker.unsubscribe("0x57c86f70cf91507bdb29953e121cb174") {'jsonrpc': '2.0', 'id': 1, 'method': 'eth_unsubscribe', 'params': ['0x57c86f70cf91507bdb29953e121cb174']}