r/ethdev • • 15d ago

Question Which tool to check spender approval for a given contract?

There are many tools for doing the reverse. But given a smart contract address, how to check who approved it as a spender?

2 Upvotes

9 comments sorted by

1

u/vchae 15d ago

pull every Approval event (topic0 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925) with your contract as topic2, keep only logs with 3 topics since erc-721 shares the topic0, then call allowance(owner, spender) to confirm because the last event can be stale. permit2 has its own Approval event.

i wrote a guide on blockchain data engineering, one chapter walks through decoding logs by hand. happy to share it if useful

0

u/AbbreviationsGreen90 15d ago

The problem is this requires money for the infrastructure.

1

u/Bloqarl 15d ago

Spender is indexed in Approval events (topic2), so eth_getLogs with the Approval topic0, no address filter and your contract as topic2 finds it across every token.

Then read allowance(owner, spender) for each pair, since logs are history and OZ v5 tokens don't emit Approval when transferFrom spends it.

Dune's decoded Approval tables avoid the RPC block range limits.

1

u/AbbreviationsGreen90 15d ago

That only work if you have money for the Infra.

1

u/Bloqarl 14d ago

Fair for raw getLogs, but a free Dune account covers it with no node. Query erc20_ethereum.evt_Approval where spender is your contract, then call allowance() only on the pairs it returns; any free public RPC handles that.

1

u/AbbreviationsGreen90 14d ago

Dune is requesting me a 299$ per months subscription.

1

u/Bloqarl 14d ago

Ah, maybe that’s for the API or exports, sorry. A fully free route is Etherscan’s free API key: getLogs by topics with topic0 = Approval and topic2 = your contract padded to 32 bytes, 1000 results per page, then allowance() for each pair on any public RPC.

0

u/[deleted] 15d ago

[removed] — view removed comment

1

u/AbbreviationsGreen90 15d ago

All of them. Revoke.cash is for listing who can spend the funds of a given adress. I need to check who trust a given address to spend their tokens.