Giter Club home page Giter Club logo

revoke.cash's Introduction

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 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.

Running locally

git clone [email protected]:rkalis/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_INFURA_API_KEY is used for reading data from Ethereum + Testnets.
  • NEXT_PUBLIC_ALCHEMY_API_KEY is used for reading data from Polygon, Optimism and Arbitrum + Testnets
    • Alchemy is also used for ENS and UNS name resolutions - if omitted those resolutions will not work.
  • COVALENT_API_KEY and COVALENT_IS_PREMIUM is used for certain chains such as Evmos and Harmony.
  • ETHERSCAN_API_KEYS and ETHERSCAN_RATE_LIMITS are used for many of the other chains such as BNB Chain or Avalanche.
  • NEXT_PUBLIC_NODE_URLS is used to override any RPC URLs on the frontend - e.g. if you want to use Alchemy instead of Infura.
  • 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.
  • NEXT_PUBLIC_HARPIE_API_KEY is used to call Harpie's API for getting contract address labels - if omitted it only uses public label data sources.
  • RESERVOIR_API_KEY is used for fetching NFT prices - if omitted, NFT prices will not be shown.
  • NODE_URLS is currently unused, but can be used for certain networks in the future.
  • LOCALAZY_API_KEY is used for generating "Help Us Translate This Page" links - if omitted, those links will not work.

Contributing

Adding a new network

Adding a new network is relatively straightforward as you only need to change three files: lib/utils/chains.ts, cypress/e2e/chains.cy.ts and 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.
  • Support in CovalentHQ for the network.
  • A block explorer with an exposed API that is compatible with Etherscan's API (such as Blockscout).

Also make sure that your network is listed in ethereum-lists/chains (and that it has subsequently been included in @revoke.cash/chains). 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

In lib/utils/chains.ts:

  • Add a network configuration for the network to the CHAINS mapping. A network configuration can include the following properties, and need to be filled out accordingly. name, infoUrl, nativeToken, explorerUrl and rpc only need to be added if the data in ethereum-lists/chains is different than what should be used by Revoke.cash
    • 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_COMPATIBLE 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 (Optional): The URL of the network's website.
    • nativeToken (Optional): The symbol of the network's native token.
    • explorerUrl (Optional): The URL of the network's block explorer.
    • etherscanCompatibleApiUrl (Only for SupportType.ETHERSCAN_COMPATIBLE): The URL of the network's block explorer API.
    • rpc.main (Optional): 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): The URL of the network's free RPC endpoint (will be used when adding the network to a wallet).
    • 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).
  • 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.
  • Add an amount to getDefaultDonationAmount() that corresponds to around $10-20 in the native token of the network.

In cypress/e2e/chains.cy.ts:

  • Find a wallet that has active approvals and add it to fixtures.

In locales/en/networks.json:

  • Add a one-paragraph description for the network in the "networks" object under the correct slug.
  • An admin will then need to run yarn translations:update to make sure this description gets forwarded to translators.

Credits

Website created by Rosco Kalis after discussing the idea with Paul Berg at Devcon 5 in Osaka. Uses viem and wagmi for all Ethereum-related operations and Etherscan, CovalentHQ, Infura & Alchemy for extended multichain support. Built with Next.js, Tailwind and TypeScript. Uses Upstash for queueing.

revoke.cash's People

Contributors

andreujuanc avatar bobeu avatar bossyuansu avatar chawyehsu avatar clonescody avatar danielheyman avatar davidcardenasus avatar dawsbot avatar itinance avatar jasondoyle avatar kris-ipor avatar maorstamati avatar merwane avatar monokh avatar natebeauregard avatar naugtur avatar npc7 avatar omahs avatar renshuncui avatar rkalis avatar ryanpwaldon avatar sabalpoudel avatar simbirskiy avatar steen3s avatar thevolcanomanishere avatar threehonor avatar timjrobinson avatar trtomasz avatar trungtt198x avatar ymittal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

revoke.cash's Issues

Improve performance on the NFTs section

On the NFTs section there's always requests timing out, which is causing them to load much slower than the tokens section. We should investigate and fix this.

Is revokecash.com legit?

Hey! Someone recently reported that there was a scam version of revoke.cash floating around out there at https://revokecash.com/
Looking at it, it actually doesn't seem like a malicious site at first glance. Is this legit, and if so is there a good place to acknowledge its existence?

Perhaps might be better to just replace revokecash.com with a 302 redirect to revoke.cash instead.

Add "current network" indicator

Revoke.cash can connect with any EVM network and uses Metamask's injected provider to detect the network (by chain ID). For clarity it makese sense to add a visual indicator to the website that shows what network we're currently connected to.

Use multicall for batch calls

Currently we get symbol, name and user balance for each token separately. This means that the app uses a lot of RPC calls. This is usually fine since we use the user's Metamask connection, but in case the user isn't using a web3-enabled browser, we fall back to my free-plan Infura key.

A short term solution can be upgrading to the $50 plan, but that only doubles the capacity, and the $225 plan is a bit expensive. So a better long-term solution is drastically reduce the number of RPC calls so that we don't hit the 100k requests limit as easily.

One way to do this is using Etherplex whch enables batch calls. The easiest change is to batch call symbol, name and user balance, but still having separate calls per token. That already cuts the number of calls to 1/3rd of what it is now.

But ideally we'd want to batch every call to every token. This batch call might become too big if there are a lot of tokens, so we'd need to split up all calls in batches of max X tokens. This needs quite some more work than the low hanging 2/3rd improvement.

Find alternative to Lokalise for i18n

We're not eligible for Lokalise's Open Source plan. Their free plan only allows 2 team members (i.e. me + 1 translator). We will need to have multiple translators working in parallel, so we need more than 2 seats. Additionally we need at least 2 separate projects (website + browser extension).

Options:

  • POEditor (https://poeditor.com/)
    • Free: 1000 total strings + unlimited seats + unlimited projects
    • Cheapest paid: 3000 total strings ($150/y)
  • Localazy (https://localazy.com/)
    • Free: 200 source strings + unlimited seats + unlimited projects
    • Cheapest paid: 500 strings ($190/y)
  • Alternative: Keep using Lokalise free tier with built-in translation services
    • Free: 500 source strings + 2 seats + unlimited projects
    • Cannot use own translators because of team limits

Other options (e.g. Phrase, Lokalise Paid, Crowdin) are all prohibitively expensive in their paid tiers and don't offer sufficient free functionality.

Show risk assessment for addresses

If the addresses are in the dapp-address-mapping or in the ethereum-lists registry, they are likely safer than unknown addresses. If they appear in the evm-labels phishing / hacking registry they are certainly unsafe. We could try to communicate this (e.g. using colour codes: green for "known", yellow for "unknown" and red for "known scammers").

'0x0d438f3b5175bebc262bf23753c1e53d03432bde'

Dapp address to name mappings are used to display huma-readable names on revoke.cash (e.g. Aave instead of 0x3dfd23A6c5E8BbcFc9581d2E864a68feb6a076d3). If you spot any 0x... addresses on revoke.cash that you know belong to well-known apps, request them to be added here.

Please provide the following information:

Address: e.g. 0x3dfd23A6c5E8BbcFc9581d2E864a68feb6a076d3
Dapp name: e.g. Aave

If you have any other information about the dapp (e.g. website, type of contract) feel free to provide it as well.

Show date of approval

Often times when people are checking Revoke.cash they want to see if they recently approved anything, so it would be nice to display the approval date (and maybe even allow sorting by date). However, we'd probably need a pretty significant UI overhaul to present that data in a good way, so this needs more discussion before implementing.

Price information

Show price information of tokens to indicate how much money is at stake.

Support more chains

I'm opening this as a way to track the chains that we still need to / want to support but can't right now (due to unsupported nodes / lack of better APIs). This issue will stay open, but I will use it to track new chain support. I will add comments for new chains so that you can signal support with emojis.

Please add a comment on this thread if the chain you want is not on the list yet, or add an emoji to the existing comments to signal that you want support for this chain as well.

Add more elaborate documentation

Right now we have the FAQ that provides some decent information, but it would be great to have some more elaborate documentation or even some tutorial videos.

'0x0d438f3b5175bebc262bf23753c1e53d03432bde' 'WNXM'

Dapp address to name mappings are used to display huma-readable names on revoke.cash (e.g. Aave instead of 0x3dfd23A6c5E8BbcFc9581d2E864a68feb6a076d3). If you spot any 0x... addresses on revoke.cash that you know belong to well-known apps, request them to be added here.

Please provide the following information:

Address: e.g. 0x3dfd23A6c5E8BbcFc9581d2E864a68feb6a076d3
Dapp name: e.g. Aave

If you have any other information about the dapp (e.g. website, type of contract) feel free to provide it as well.

Improve spam token filtering (especially for NFTs)

The old version of Revoke.cash retrieved NFT balances using balanceOf(). This has huge performance issues (2-3 times slower), so in the new version, we derive the asset balance from events.

As it turns out though, the balanceOf() function was a great filter for spam tokens, since a lot of spam NFTs would throw when calling balanceOf().

It's not an option to go back to calling balanceOf(), so it would be very useful to find a different way to detect spam NFTs, besides the other ones already implemented (name + bytecode size checks + alchemy spam list).

Does not display CryptoKitties approvals

This is a fun one. CryptoKitties does not conform to ERC721 at all (which makes sense since it mostly predates it). None of the event parameters are indexed, making it fundamentally impossible to use with the current setup (unlike other semi-ERC721 collections like CryptoStrikers). To support CryptoKitties we would need to add a completely custom code path for it, which does not seem to be worth the effort, but if we can figure out some smart way to go about it, it would be nice to support CK.

Add alternative network connections

Currently the network connection is done with Metamask (falling back to Infura). But many networks (e.g. Polygon and BSC) don't have the public infrastructure to support the historical getLogs requests that revoke.cash uses. For these cases we'd need to figure out an alternative way of getting data from chain. One option could be Covalent, but we need to look into this more.

Solution for accounts with a LOT of token transfers

For Ethereum there's a limit of 10k logs returned at a time. We have a tree-like retry mechanism for those cases, so that covers almost all accounts. However, for other chains where we use Etherscan's API, for which we can receive 10k logs (paginated in 1k-sized pages) logs at a time, which can be prone to timeouts / rate limit issues.

Check topic count to differentiate between ERC20 and ERC721 Transfers

We currently have the throwIfNotErcX() functions that ensure that we're not including any invalid tokens. But we can bring down the number of node requests (and reverts) by pre-filtering the Transfer events based on their topic count (ERC20 transfers has 3 topics, ERC721 has 4).

Moonriver Moonscan API Key Needs to be different from Moonbeam Moonscan API key

Revoke.cash for the Moonriver network doesn't appear to be working at this time. However I was able to fix it locally by swapping out the Moonbeam Moonscan API Key for a Moonriver Moonscan API Key. Naturally, that meant that Moonbeam didn't work on my local instance because the Moonbeam and Moonriver Moonscan API keys are different.

I suggest adding a moonriverMoonscan value to the example.env file and making any necessary changes to the hosted Revoke.cash's environment variables.

Refactor to use functional components + hooks

Currently revoke.cash uses class components almost exclusively (only exception is DonateButton). This should be refactored to use only functional components + hooks. In the process the current components should be pulled further apart as well.

Permalink for search results

After performing a search, the search results are displayed.

Please also update the URL to a permalink. Then if I share that permalink other people will see the same search results.

Move onload axios fetching into `getServerSideProps`

All visitors have an HTTP GET to "https://raw.githubusercontent.com/vasa-develop/nft-tokenlist/master/mainnet_curated_tokens.json" the moment they load. Instead of putting this burden on the browser, you can fetch this once serverclient-side and serve the homepage with this data already filled thanks to getStaticProps.

https://nextjs.org/docs/basic-features/data-fetching/get-static-props

If perhaps this list changes, you can even set a revalidate value

Translate toast messages

The entire website has translations. Except for toast messages. We'll need to add translated messages to those as well.

Feat: Bundle multiple revoke transactions

I think bundling multiple revoke transactions via multicall would be a nice feature to have. It's important that allowFailure is always set to False. If you're interested in a separate Vyper implementation of multicall, I wrote a version here.

Max rate limit reached

When using Polygon chain, I always only get the message "Max rate limit reached" and no approvals are shown.

Search by RECIPIENT

I would like to search the other way. For a specific address, find all the authorizations they received.

Along with #74, this can be helpful to show an address that is exhibiting unusual behavior. For example, when a phishing scam happens, you can see one address receiving lots of token approvals which they will then go and steal. This page could show those approvals and help as evidence in showing that a scam happened.

Also this is helpful for security research, I am studying a weak contract that received lots of approvals. I need to find some of those approvals to make a PoC exploit.

Etherscan API query timeouts

Every now and then Etherscan API request time out with error "Query timeout occured. Please select a smaller result dataset". This is separate from the expected max 1000 logs that their API returns. We should look into this.

Use Tailwind

Revoke.cash is currently built on top of react-bootstrap (w/ Bootstrap 4). I prefer using Tailwind instead.

Gnosis Safe App

Gnosis Safe has support for WalletConnect, so we'd have to figure out what is needed to function with Gnosis Safe through WalletConnect.

Add revoke.cash to IPFS

Given the ongoing debacle from last night, it'd probably be good to have a copy of revoke.cash on IPFS + an ENS name to easily find it.

I think it's an important utility and it'd be reassuring to have the ENS + IPFS records to know you're dealing with a trustworthy source during a security incident.

Security Risk ok Paste address textbox

Hello,
It's potentially risky to has enable the paste wallet address option because the scammer could use it to change to unlimited again 😨

It would be better if you remove that option and only let review and change the amount and the use of the revoke option to only the connected wallet.

Regards

Use web3-react

Once we're converted completely to functional components we should update to use web3-react rather than the homebrew solution.

Support revoking PERX

PERX (and perhaps others) do not implement ERC20 correctly (cannot call approve(0x.., 0), only >0). Furthermore they do not use the commonly used names increaseAllowance() and decreaseAllowance() for updating allowances, but instead these functions are called increase|decreaseApproval(). Hard to support such edge cases. Perhaps we could fall back to calling approve(1), which would be very close to revoked.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.