DODOEX / web3-provider-proxy

🌍 Proxying and caching web3 requests with Cloudflare workers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Web3 Provider Proxy

A starting point for proxying and caching excessive web3 requests with Cloudflare workers

πŸ™‹ β‡° 🌍🌎🌏 β‡° β›“

Why would I need this?

At Audius, we've found it to be useful to be able to proxy and cache requets to web3 providers.

  1. Reliance on a single web3 provider has proven to be a dangerous single point of failure.

  2. Different users frequently read the same data from chain, which is both expensive and inefficient.

  3. Leaking your API keys for paid providers isn’t great when they’re hard-coded in your client / DApp

This repo is the cloudflare worker we use to give us flexible caching functionality and a extremely minimal & non-opinionated fashion.

This is an entry-point! Not all-in solution & we welcome all forking / tweaking / contributing as such tools might meet your use-cases.

How do I use this?

  1. You'll need a Cloudflare account set up with workers enabled to get going. See Cloudflare's docs to get started.

  2. Clone or fork this repo!

  3. cp wrangler-template.toml wrangler.toml

    and replace the relevant environment variables you'd like to use. The import variables you'll want to pay attention to are

account_id: from your Cloudflare workers account
zone_id: from your Cloudflare workers account
name: what you'd like your worker to be called

PROVIDERS: an array of web3 providers you'd like to use
  1. Deploy your worker
wrangler publish
  1. You'll then want to set up a DNS record pointing to your workers site.

Image of DNS

And of course the 100:: is a dummy address per the docs

  1. Update your client to send requests to your new provider!

About

🌍 Proxying and caching web3 requests with Cloudflare workers

License:Other


Languages

Language:JavaScript 100.0%