witnet / web3-jsonrpc-gateway

A Web3 JSON-RPC provider that handles accounts on its own using Ethers.js but delegates chain queries to a 3rd party service, e.g. Infura
MIT License
3 stars 3 forks source link

web3-jsonrpc-gateway

A Web3 JSON-RPC provider gateway that handles accounts on its own using Ethers.js, or other SDKs, but delegates chain queries to a 3rd party "destination provider", e.g. Infura, Cloudflare, Conflux, BOBA-L2, etc.

Compilation

yarn build

Release

This repository is released automatically in DockerHub and npm using GitHub actions when a new release is detected in the repository. To release:

Running a single server instance, depending on destination provider type:

Infura as destination provider:

node dist/bin/ethers/infura

Required environment variables:

Optional environment variables:

Conflux Core compatible destination providers:

node ./dist/bin/conflux

Required environment variables:

Optional environment variables:

Reef-compatible destination providers:

node ./dist/bin/reef

Required environment variables:

Optional environment variables:

Generic destination providers:

node ./dist/bin/ethers

Generic destination providers need to comply with the JsonRpcProvider type from the Ethers.js library:

Required environment variables:

Optional environment variables:

Pre-configured JSON-RPC provider gateways:

There are several package scripts at your disposal for you to launch specific gateways to multiple WEB3-compatible blockchains, and different possible networks within them.

Important: In order to these batch scripts to work properly, please rename .env_batch_example to .env, and fulfill the following parameters:

Running gateways to Ethereum networks:

Running gateways to BOBA Layer-2 networks:

Running gateways to CELO networks:

Running gateways to Conflux networks:

Running gateways to HARMONY networks:

Running gateways to KCC networks:

Running gateways to METIS networks:

Running gateways to POLYGON networks:

Running gateways to REEF CHAIN networks:

How to create a server for any other provider

To integrate with a different provider, you can create your own script that creates the provider and then build a server around it. Please, have a look to provided examples in src/bin/**.