Welcome to Nexus
- a simple TypeScript proxy server for any Ethereum JSON RPC compliant blockchain. Instead of connecting your dApps to a blockchain node, you can connect them to Nexus
and Nexus
serves the requests for you. Nexus
is open source and free to use.
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 alchemyNodeProvider = new NodeProvider({
name: "alchemy",
chain: CHAIN.ETHEREUM_MAINNET,
url: process.env.ALCHEMY_URL,
});
const infuraNodeProvider = new NodeProvider({
name: "infura",
chain: CHAIN.ETHEREUM_MAINNET,
url: process.env.INFURA_URL,
});
const nexus = Nexus.create({
nodeProviders: [alchemyNodeProvider, infuraNodeProvider],
port: 4005,
});
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:4005/1 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'