A starting point for proxying and caching excessive web3 requests with Cloudflare workers
๐ โฐ ๐๐๐ โฐ โ
At Audius, we've found it to be useful to be able to proxy and cache requets to web3 providers.
-
Reliance on a single web3 provider has proven to be a dangerous single point of failure.
-
Different users frequently read the same data from chain, which is both expensive and inefficient.
-
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.
-
You'll need a Cloudflare account set up with workers enabled to get going. See Cloudflare's docs to get started.
-
Clone or fork this repo!
-
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
- Deploy your worker
wrangler publish
- You'll then want to set up a DNS record pointing to your workers site.
And of course the 100::
is a dummy address per the docs
- Update your client to send requests to your new provider!