[Ethereum] How to find out if a token takes a fee on transfer


I'm trying to find out if there is a way programmatically (using web3) to check if a token takes a fee on transfer, such as the ones that require the swapExactETHForTokensSupportingFeeOnTransferTokens function on the Uniswap router.

Is it possible to discover this information without having to call the Uniswap swapExactETHForTokens function and subsequently checking for the infamous "UniswapV2: K" errors?

Best Answer

I've been trying to figure this out as well. The only thing I've seen, would be pretty hacky, but you could parse through some of the latest transactions with that token, and see how many internal transactions they generate.

enter image description here

For instance, this is what a transaction looks like when the token has some sort of burn or fee on transfer functionality. Every transaction using this token would have at least three internal transfers. But a token without any FoT or burn would mostly have transactions with two internal transfers. You'd have to parse a good number of them to be sure. But that is one (really ugly) way you could do it.

Additionally, somebody could maybe just make a token list with a curated set of data about fee on transfers.

Related Topic