Skip to content

jimouris/rpc-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RPC Middleware Logo

Rotating Ethereum JSON-RPC Middleware GPLv3 License

A lightweight middleware that accepts Ethereum JSON-RPC requests and forwards each to a randomly chosen provider from a pool.

Note 1: This project is for research and not production-ready. Use at your own risk.

Note 2: This is meant to be run inside a trusted execution environment (TEE) so that the TEE handles all the interactions with the RPC providers instead of the dAPP or user wallet.

Setup

  1. Install dependencies:

    pip install -r requirements.txt
  2. Configure providers: Copy rpc-providers/example.csv to rpc-providers/rpcs.csv and update it with your RPC endpoints and API keys.

  3. Run the server:

    uvicorn src.main:app --reload

With the server running, you can:

  1. Send JSON-RPC requests:
  • POST to http://localhost:8000/rpc
  1. View metrics:
  • GET http://localhost:8000/metrics

For example:

curl -X POST http://localhost:8000/rpc \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'

returns

{"jsonrpc":"2.0","id":1,"result":"0x15eb54a"}

Example

Go to http://127.0.0.1:8000/metrics to see how many times each RPC has been used!

Docker Support

You can also build it and run with Docker:

docker build -t rpc-middleware .
docker run -p 8000:8000 rpc-middleware

About

A middleware that accepts Ethereum JSON-RPC requests and forwards each to a randomly chosen provider from a pool.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors