Skip to content

jit-strategies/json-rpc-proxy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON RPC Cache Proxy

This repo contains an Open-Resty caching proxy for JSON-RPC requests. It caches JSON-RPC requests based on URI and the JSON-RPC method and params fields.

Prerequisites

To build and run this project you need docker installed and running on your machine.

Build

To build the docker image, go to the root directory of this repository and run:

docker build -t json-rpc-proxy .

Run

To run the docker image, you can run the following command:

docker run --env "ADDRESS=rinkeby.infura.io" --env "CACHE_TIME=5s" -p 8080:8080 json-rpc-proxy

Where:

  • ADDRESS: is the address of the JSON RPC destination.
  • CACHE_TIME: is the cache TTL (time to live)

Use

In our example started at the Run step, to get the latest Rinkeby block number we can do:

curl http://localhost:8080/v3/<YOUR API KEY> \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params": [],"id":1}

About

JSON-RPC caching proxy built with OpenResty

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 51.4%
  • Dockerfile 48.6%