@lifi/rpc-wrapper
Version:
LI.FI rpc-wrapper
80 lines (54 loc) • 2.03 kB
Markdown
<div>
<h1 align="center"> RPC wrapper </h1>
<p align="center">
<strong>A wrapper around your rpc</strong>
</p>
<div align="center">
[](/LICENSE.md)
[](https://www.npmjs.com/package/@lifi/rpc-wrapper)
[](https://www.npmjs.com/package/@lifi/rpc-wrapper)
[](https://isitmaintained.com/project/lifinance/rpc-wrapper)
[](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
```