Skip to content

whats-good/nexus-test

 
 

Repository files navigation

hero banner with nexus dog

npm version npm downloads Documentation Maintenance license: MIT

Discord GitHub Actions Status

Introduction

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.

Documentation

Check out our documentation for detailed instructions.

Installation

# npm
npm install @whatsgood/nexus

# pnpm
pnpm install @whatsgood/nexus

# yarn
yarn add @whatsgood/nexus

Quickstart

// 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}`);
});

Interaction

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}'

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 87.6%
  • Shell 6.9%
  • JavaScript 5.1%
  • Dockerfile 0.4%