Mobile SDK Shortpolling
Symbiosis Mobile SDK Shortpolling

Why 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.
Symbiosis Mobile SDK supports Short Polling. Here is a general example.
Common use cases are listed below:
  1. 1.
    Waiting for transactions to be processed,
  2. 2.
    Getting information about blocks,
  3. 3.
    Receiving information about events.

Transactions

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.

Blocks

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.

Events

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.
Copy link
On this page
Why Shortpolling?
Transactions
Blocks
Events