Skip to content

Latest commit

 

History

History
35 lines (19 loc) · 1.59 KB

README.md

File metadata and controls

35 lines (19 loc) · 1.59 KB

RPC error handling examples

This repo contains multiple examples to handle RPC errors when sending requests to blockchain nodes.

Handle errors with Promises

Use can wrap the RPC requests in a method and use Promise.all, Promise.race or Promise.any.

Retry same request

We can wrap the RPC request in a method that catches any error and use recursion to make the retries.

Retry same request with delay

A modification of the previous one, just adding a delay between each retry

Retry with a backup provider

The retries are done using a different provider that users a different RPC endpoint.

Retry with backup provider for smart contract methods

Another wrapper function used to invoke smart contract methods, catch any errors and retry using a different provider and RPC endpoint.