Skip to content

Commit

Permalink
docs: erpc (#76)
Browse files Browse the repository at this point in the history
* docs: erpc

* docs: erpc guide

* docs: fix comment
  • Loading branch information
kasrakhosravi authored Aug 8, 2024
1 parent ba21c7e commit 833ec93
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 1 deletion.
62 changes: 61 additions & 1 deletion documentation/docs/pages/docs/references/rpc-node-providers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,64 @@ You can use [chainlist](https://chainlist.org/) to find all the providers which

## Local nodes

rindexer should work with any local nodes you run including [Anvil](https://book.getfoundry.sh/anvil/) and [Hardhat](https://hardhat.org/)
rindexer should work with any local nodes you run including [Anvil](https://book.getfoundry.sh/anvil/) and [Hardhat](https://hardhat.org/)

# RPC Proxy and Caching

[eRPC](https://github.com/erpc/erpc) is a fault-tolerant EVM RPC proxy and re-org aware permanent caching solution. It is built with read-heavy use-cases in mind such as data indexing and high-load frontend usage.

## Quickstart

1. Create your [`erpc.yaml`](https://docs.erpc.cloud/config/example) configuration file:

```yaml filename="erpc.yaml"
logLevel: debug
projects:
- id: main
upstreams:
# You don't need to define architecture (e.g. evm) or chain id (e.g. 137)
# as they will be detected automatically by eRPC.
- endpoint: https://eth-mainnet.blastapi.io/xxxx
- endpoint: https://polygon-mainnet.blastapi.io/xxxx
- endpoint: evm+alchemy://xxxx-my-alchemy-api-key-xxxx
```
See [a complete config example](https://docs.erpc.cloud/config/example) for inspiration.
2. Use the Docker image:
```bash
docker run -v $(pwd)/erpc.yaml:/root/erpc.yaml -p 4000:4000 -p 4001:4001 ghcr.io/erpc/erpc:latest
```

or add the below configs to the rindexer's [docker-compose.yaml](https://github.com/joshstevens19/rindexer/blob/master/docker-compose.yml) as a service and run `docker-compose up -d`:

```yaml [rindexer.yaml]
services:
...

erpc: // [!code focus]
image: ghcr.io/erpc/erpc:latest // [!code focus]
platform: linux/amd64 // [!code focus]
volumes: // [!code focus]
- ${PROJECT_PATH}/erpc.yaml:/root/erpc.yaml // [!code focus]
ports: // [!code focus]
- 4000:4000 // [!code focus]
- 4001:4001 // [!code focus]
restart: always // [!code focus]
```
3. Set erpc url in [rindexer network config](https://rindexer.xyz/docs/start-building/yaml-config/networks#rpc):
```yaml [rindexer.yaml]
name: rETHIndexer
description: My first rindexer project
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks:
- name: ethereum
chain_id: 1
rpc: http://erpc:4000/main/evm/1 // [!code focus]
```
and you are set to go. the rpc requests now will be redirected toward erpc and it will handle caching, failover, auto-batching, rate-limiting, auto-discovery of node providers, etc. behind the scens.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ networks:
rpc: https://mainnet.gateway.tenderly.co // [!code focus]
```
You can use [erpc](https://rindexer.xyz/docs/references/rpc-node-providers#rpc-proxy-and-caching) for load-balancing between multiple rpc endpoints (with failover, re-org aware caching, auto-batching, rate-limiters, auto-discovery of node providers, etc.)
```yaml [rindexer.yaml]
name: rETHIndexer
description: My first rindexer project
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks:
- name: ethereum
chain_id: 1
rpc: http://erpc:4000/main/evm/1 // [!code focus]
```
We advise using environment variables for the rpc url to avoid checking in sensitive information.
```yaml [rindexer.yaml]
Expand Down

0 comments on commit 833ec93

Please sign in to comment.