Event signature · Token standards

Approval event signature and topic0

The topic0 of the Approval event is 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925, the keccak-256 hash of Approval(address,address,uint256); 2 of its 3 arguments are indexed. Spending allowance granted.

Anatomy of a Approval log

Topics

  • topic00x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925keccak256("Approval(address,address,uint256)")
  • topic1owner (address)indexed: filterable
  • topic2spender (address)indexed: filterable

Data

  • datavalue (uint256)ABI-encoded, decoded with the ABI
Parameters

Arguments and where they sit in the log

Indexed arguments travel as topics and can be filtered cheaply; the others are ABI-encoded together in the data.

NameTypeIn the log
owneraddresstopic1
spenderaddresstopic2
valueuint256data

Solidity declaration

event Approval(address indexed owner, address indexed spender, uint256 value);

Canonical signature

Approval(address,address,uint256)

topic0

0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925

Ready-made alerts

Get an alert on Approval

Each rule opens with the contract and the conditions filled in. Sign in, pick your chat and click Create.

Who emits it

Contracts we list that emit Approval

Any other contract with the same signature emits a log with the same topic0.

And 19 more contracts in the app's directory.

Code

Read Approval logs in code

The same filter in viem, ethers and plain JSON-RPC, and the Solidity that emits it. The address is USD Coin (USDC), a contract we list that emits it.

viem
import { createPublicClient, http, parseAbiItem } from "viem"
import { mainnet } from "viem/chains"

const client = createPublicClient({ chain: mainnet, transport: http() })

const logs = await client.getLogs({
  address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
  event: parseAbiItem("event Approval(address indexed owner, address indexed spender, uint256 value)"),
  fromBlock: "latest",
})

for (const log of logs) console.log(log.args) // { owner, spender, value }
ethers v6
import { Interface, JsonRpcProvider } from "ethers"

const provider = new JsonRpcProvider(process.env.RPC_URL)
const iface = new Interface(["event Approval(address indexed owner, address indexed spender, uint256 value)"])

const logs = await provider.getLogs({
  address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
  topics: [iface.getEvent("Approval")!.topicHash],
})

for (const log of logs) console.log(iface.parseLog(log)?.args)
JSON-RPC (eth_getLogs)
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_getLogs",
  "params": [
    {
      "address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
      "topics": [
        "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925"
      ],
      "fromBlock": "latest"
    }
  ]
}
Solidity
event Approval(address indexed owner, address indexed spender, uint256 value);

// inside a function:
emit Approval(owner, spender, value);
Example

An example Approval log, encoded and decoded

Placeholder values, not a real transaction: how each argument is stored in the topics and the data, and what decoding gives back.

Encoded (as the node returns it)
  • topic0keccak256("Approval(address,address,uint256)")0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925
  • topic1owner0x0000000000000000000000001111111111111111111111111111111111111111
  • topic2spender0x0000000000000000000000002222222222222222222222222222222222222222
  • data0x0000000000000000000000000000000000000000000000000000000000000bb8
Decoded with the ABI
  • owneraddress · indexed0x1111111111111111111111111111111111111111
  • spenderaddress · indexed0x2222222222222222222222222222222222222222
  • valueuint2563000
FAQ

Frequently asked questions

What is the topic0 of the Approval event?

0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925: the keccak-256 hash of Approval(address,address,uint256).

Which Approval arguments are indexed?

owner, spender are indexed and sit in the log's topics; value is in the data.

Do ERC-20 and ERC-721 Approval events have the same topic0?

Yes. The signature is the same, so the hash is too. ERC-721 also indexes the third argument (the token id), so its logs carry four topics and an empty data field, where ERC-20 logs carry three topics and the amount in the data.

How do I get an alert when a contract emits Approval?

Open one of the ready-made rules on this page, or add any contract and pick Approval from the event list. Conditions can be set on indexed and non-indexed arguments, and each alert names the contract and links to the transaction.

Keep exploring

More event signatures and tools

Know the moment a contract emits it

The Beta plan is free: one wallet and one contract, no credit card.