Welcome to Nexus
- a load balancing blockchain RPC reverse proxy written in TypeScript.
Check out our documentation for detailed instructions.
# npm
npm install @whatsgood/nexus
# pnpm
pnpm install @whatsgood/nexus
# yarn
yarn add @whatsgood/nexus
// node.js standalone server example
import { Nexus, NodeProvider, CHAIN } from "@whatsgood/nexus";
import { createServer } from "node:http";
const llamaRpcNodeProvider = new NodeProvider({
name: "llama-rpc",
chain: CHAIN.ETHEREUM_MAINNET,
url: "https://eth.llamarpc.com",
});
const tenderlyNodeProvider = new NodeProvider({
name: "tenderly",
chain: CHAIN.ETHEREUM_MAINNET,
url: "https://gateway.tenderly.co/public/mainnet",
});
const nexus = Nexus.create({
nodeProviders: [llamaRpcNodeProvider, tenderlyNodeProvider],
port: 4000,
});
createServer(nexus).listen(nexus.port, () => {
console.log(`🚀 Server ready at http://localhost:${nexus.port}`);
});
In this example, since we have configured the server to connect to Ethereum Mainnet
, we supply the chain id = 1
as the endpoint.
curl \
-X POST http://localhost:4000/1 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'