> _Do you want to swap 10 DAI for ETH? Sure thing, we'll just need your approval to spend a BAJILLION DOLLARS!_ Do you ever feel worried about the different apps that have access to the tokens in your wallet? [revoke.cash](https://revoke.cash) allows you to inspect all the contracts you've approved to spend money on your behalf, and revoke their access for the ones you no longer need. If you don't want to completely revoke access, it's also possible to update the amount they are allowed to spend instead. If you want to learn more about (unlimited) token approvals, I wrote an article on my blog: [Unlimited ERC20 allowances considered harmful](https://kalis.me/unlimited-erc20-allowances/). ## Running locally ``` git clone git@github.com:RevokeCash/revoke.cash.git cd revoke.cash yarn yarn dev ``` ### Environment variables An `.example.env` file is provided that needs to be copied into a `.env` file and filled out. Some of these variables are integral to the functioning of Revoke.cash: - `NEXT_PUBLIC_ALCHEMY_API_KEY` is used for reading data from Ethereum, Polygon, Optimism and many other chains. - Alchemy is also used for ENS and UNS name resolutions - if omitted those resolutions will not work. - `COVALENT_API_KEY` and `COVALENT_RATE_LIMIT` is used for certain chains such as Ronin. - `ETHERSCAN_API_KEYS` and `ETHERSCAN_RATE_LIMITS` are used for many of the other chains such as BNB Chain or Avalanche. - `NODE_URLS` / `NEXT_PUBLIC_NODE_URLS` are used to override RPC URLs. Use `NODE_URLS` for server-side services and `NEXT_PUBLIC_NODE_URLS` for the frontend. - `NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID` is used for WalletConnect - if omitted, WalletConnect will not work. If you omit any of these variables, Revoke.cash will not work for the chains you omitted. Then there are a few less essential variables: - `IRON_SESSION_PASSWORD` is used for encrypting session cookies and can be filled with any random 32-character string - if omitted many chains will not work. - `NEXT_PUBLIC_MIXPANEL_API_KEY` is used for Analytics - if omitted, no Analytics are collected. - `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` are used for queueing third-party API calls - these are only necessary when hosting in a serverless environment such as Vercel. ### Using HTTP/2 locally The dev server only supports HTTP/1.1, where browsers allow 6 connections per host. The Premium multichain dashboard sends two API requests per network, so other requests (including JS chunks) can wait in the browser queue for close to a minute. In production this is not an issue because Vercel serves HTTP/2. To use HTTP/2 locally, run [Caddy](https://caddyserver.com) as a reverse proxy in front of the dev server and open https://localhost:3443 instead of http://localhost:3000: ``` brew install caddy caddy reverse-proxy --from localhost:3443 --to localhost:3000 ``` The first run asks for your password to add Caddy's local certificate authority to the system trust store. You can also start the dev server and Caddy with a single command: ``` yarn dev:caddy ``` ## Contributing ### Adding a new network Adding a new network is relatively straightforward as you only need to change a few files: `packages/core/lib/chains/ids.ts`, `packages/core/lib/chains/index.ts`, `apps/web/cypress/support/chain-fixtures.ts` and `apps/web/locales/en/networks.json`. #### Prerequisites To add a new network, **one** of the following needs to be available: - A (public or private) RPC endpoint that supports `eth_getLogs` requests for the entire history of the network. - Or: Support in [GoldRush](https://goldrush.dev/) for the network. - Or: A block explorer with an exposed API that is compatible with Etherscan's API (such as Blockscout). - Or: A [HyperSync](https://docs.envio.dev/docs/HyperSync/overview) instance with at least a Bronze tier. Besides the earlier requirements, we also require a publicly available RPC endpoint with rate limits that are not too restrictive. It is also helpful if your network is listed (with TVL and volume stats) on DeFiLlama, but this is not required. #### Adding the network All network data is maintained by hand in this repository. Run `yarn check-chain-data --chain ` from `packages/core` to print a draft configuration with the data listed in `ethereum-lists/chains`, then: - Add the chain ID to `ChainId` in `packages/core/lib/chains/ids.ts`, keyed by the PascalCase display name of the network (`BNBChain`, `PolygonAmoy`). - Add a network configuration for the network to the `CHAINS` mapping in `packages/core/lib/chains/index.ts`. Every property below is required unless marked optional. - `type`: The type of support, can be `SupportType.PROVIDER` for networks with a public RPC endpoint, `SupportType.COVALENT` for networks supported by CovalentHQ, or `SupportType.ETHERSCAN` (or `SupportType.BLOCKSCOUT`, `SupportType.ROUTESCAN`) for networks with a block explorer API. - `chainId`: The chain ID of the network. - `name`: The name of the network. - `logoUrl`: The URL of the network's logo. Add a logo file (preferably svg) to `public/assets/images/vendor/chains` and add the path here. - `infoUrl`: The URL of the network's website. - `nativeCurrency`: The name, symbol and decimals of the network's native token (use the shared `ETH` constant for networks that use Ether). - `nativeTokenCoingeckoId` (Optional): The Coingecko ID of the network's native token. - `explorerUrl`: The URL of the network's block explorer, without a trailing slash. - `etherscanCompatibleApiUrl` (Only for `SupportType.ETHERSCAN` or `SupportType.BLOCKSCOUT`): The URL of the network's block explorer API. - `rpc.main`: The URL of the network's RPC endpoint. - `rpc.logs` (Optional): The URL of the network's RPC endpoint for fetching logs (if different from `main`). - `rpc.free` (Optional): A public RPC URL without API keys for the add-network page and wallets, only needed when `rpc.main` uses an API key. - `deployedContracts` (Optional): If multicall3 is deployed to the network, set this to `{ ...MULTICALL }` (check on https://www.multicall3.com/). - `priceStrategy` (Optional): If a price source (Uniswap v2 or Uniswap v3 fork), add a corresponding `PriceStrategy` to enable token pricing. - `backendPriceStrategy` (Optional): If Reservoir has an API endpoint for the network, add a corresponding `ReservoirPriceStrategy` to enable NFT pricing. - `isTestnet` (Optional): Whether the network is a testnet. - `isCanary` (Optional): Whether the network is a canary network. - `correspondingMainnetChainId` (Optional): The chain ID of the corresponding mainnet network (only for testnets or canary networks). - Run `yarn check-chain-data --update` from `packages/core` to record the network's upstream data in `scripts/chain-data-upstream.json`. Running the script without `--update` later reports upstream changes for all networks and checks that every explorer and info URL still responds. - Add the network to `CHAIN_SELECT_MAINNETS` or `CHAIN_SELECT_TESTNETS` depending on whether it is a mainnet or testnet. You can subsequently run `yarn tsx scripts/get-chain-order.ts` to determine its rough position in the network selection dropdown. In `cypress/support/chain-fixtures.ts`: - Find a wallet that has active approvals and add it to `TEST_ADDRESSES`. In `locales/en/networks.json`: - Add a one-paragraph description for the network in the `"networks"` object under the correct slug. ## Credits Website created by Rosco Kalis after discussing the idea with Paul Berg at Devcon 5 in Osaka. Uses [viem](https://github.com/wagmi-dev/viem) and [wagmi](https://github.com/wagmi-dev/wagmi) for all Ethereum-related operations and [Etherscan](https://etherscan.io), [CovalentHQ](https://www.covalenthq.com/), [Infura](https://infura.io/) & [Alchemy](https://www.alchemy.com/) for extended multichain support. Built with Next.js, Tailwind and TypeScript. Uses Upstash for queueing.