farm_rpc_proxy
v1.1.0
Published
HOT TO USE:
Downloads
8
Readme
HOT TO USE:
npm install farm_rpc_proxy
import {FarmRpcProxy} from 'farm_rpc_proxy';
import { getDefaultProvider } from 'ethers';
async function main(){
//config
const rpc_urls = [
"https://arb1.arbitrum.io/rpc",
"https://arb1.arbitrum.io/rpc",
"https://arb1.arbitrum.io/rpc"
];
const local_http_port = 3000;
const timeout_ms = 10_000;
const proxy = new FarmRpcProxy(rpc_urls, local_http_port, timeout_ms); //create
// const proxy = new FarmRpcProxy(rpc_urls); //then it will use random selected port and 30sec timeout by default.
// const local_http_port = proxy.port;
//start
proxy.run();
//access
const provider = getDefaultProvider(`http://localhost:${local_http_port}`);
const bn = await provider.getBlockNumber();
console.log(`bn: ${bn}`);
} main();