UNPKG

@lifi/rpc-wrapper

Version:
80 lines (54 loc) 2.03 kB
<div> <h1 align="center"> RPC wrapper </h1> <p align="center"> <strong>A wrapper around your rpc</strong> </p> <div align="center"> [![license](https://img.shields.io/badge/license-Apache%202-blue)](/LICENSE.md) [![npm latest package](https://img.shields.io/npm/v/@lifi/rpc-wrapper/latest.svg)](https://www.npmjs.com/package/@lifi/rpc-wrapper) [![npm downloads](https://img.shields.io/npm/dm/@lifi/rpc-wrapper.svg)](https://www.npmjs.com/package/@lifi/rpc-wrapper) [![Average time to resolve an issue](https://isitmaintained.com/badge/resolution/lifinance/rpc-wrapper.svg)](https://isitmaintained.com/project/lifinance/rpc-wrapper) [![Follow on Twitter](https://img.shields.io/twitter/follow/lifiprotocol.svg?label=follow+LI.FI)](https://twitter.com/lifiprotocol) </div> </div> The rpc wrapper is a wrapper around evm based rpc. It allows you as an developer not to handle retrying, logging and performance monitoring of your rpcs. # Getting started The package is available as an [NPM package]() You can install the package by running ```bash > yarn add @lifi/rpc-wrapper ``` or if you use npm ```bash > npm install @lifi/rpc-wrapper ``` Since the RPCProvider extends the ethersproject Fallbackprovider you can easily swap out your rpc handling with the RPCProvider. ```ts // specify your rpc providers for your specific chain const myRpcProviders = ['https://rpc1.com', 'https://rpc2.com'] // initialize the rpc provider const provider = new RPCProvider(myRpcProviders) const blockNumber = provider.getBlockNumber() console.log('This is a block number ', blockNumber) ``` ## Contributing Awesome! Please read more about contributing to the repo [here](/CONTRIBUTING.md) ## Development ### Running tests Test your code with Jest framework: ```bash yarn test ``` ### Build Build production (distribution) files in your **dist** folder: ```bash yarn build ``` If you want to test how your changes affect please use ```bash > yarn link ``` Then in your project, do ``` > yarn link @lifi/rpc-wrapper ```