0

I can find my approval list in etherscan.io. But I don't see any api to get list of approval.

https://etherscan.io/tokenapprovalchecker?search=0xf7931b9b1fff5fc63c45577c43dfc0d0def16c46
Sithu Soe
  • 29
  • 4

1 Answers1

1

Etherscan builds their own database of approvals aggregated from the Approval event logs emitted by transactions.

Example subscribing to event logs with web3js:

web3.eth.subscribe("logs", {
    topics: [
        // event signature standardized by ERC20 and ERC721
        web3.utils.keccak256("Approval(address,address,uint256)")
    ]
}, (err, event) => {
    console.log(event)
    // `address` - token contract emitting the event
    // `topics[0]` - approver
    // `topics[1] - spender
    // `topics[2]` - ERC721 token ID
    // `data` - ERC20 amount
})

Docs: https://web3js.readthedocs.io/en/v1.8.1/web3-eth-subscribe.html#subscribe-logs

Petr Hejda
  • 40,554
  • 8
  • 72
  • 100
  • is that means i cannot get my last approval? So will i get the log when i make transaction right now, and will not get last approval ? – Sithu Soe Nov 17 '22 at 11:02
  • 1
    There's no method in the RPC API that would return the ordered and aggregated approvals list. But you use a 3rd party API that built the database of approvals from all transactions - or build the database yourself. – Petr Hejda Nov 17 '22 at 18:46
  • @PetrHejda - do you know of any 3rd party APIs that currently do this? – cmptrwizard Jun 09 '23 at 10:27