◻
Mobile SDK Shortpolling
Symbiosis Mobile SDK for Symbiosis protocol V1: Shortpolling
Usually, Web3 providers provide HTTP JSON-RPC to work with Web3 and do not provide web sockets. On the other hand, the open-source web sockets are often unstable. Another method to get information about a transaction is Short Polling.
Short Polling is a service that sends HTTP requests to get up-to-date information at fixed delays. It doesn’t hold connection, unlike Long Polling and web sockets.
Common use cases are listed below:
- 1.Waiting for transactions to be processed,
- 2.Getting information about blocks,
- 3.Receiving information about events.
Waiting for transactions to be processed.
client.waitForTransactionReceipt(txHash
) periodically, according to the specified timeout and interval, calls getTransactionReceipt
, until a non-empty response is returned.Getting information about blocks.
client.newBlocksShortPolling()
gets all blocks starting fromBlock
(latest
by default), then waits for new blocks and gets information about them. It returns Flow<BlockInfo>
The method allows to retrieve information about multiple blocks in one batch request.
Receiving information about events emitted by contracts.
A smart contract emits events (its logs) during transaction execution in which this smart contract is called. Logs are part of the transaction receipts.
client.newLogsShortPolling()
allows to get data on events starting from fromBlock
and subscribes for following contract events.Last modified 11d ago