Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extracting contract address from log.address instead of call.address #19

Open
2 tasks
DenisCarriere opened this issue Feb 14, 2025 · 0 comments
Open
2 tasks

Comments

@DenisCarriere
Copy link

  • make sure to use log.address for contract address in Transfer events
  • make sure to use storage_change.address for contract address in Balance Change events

https://github.com/streamingfast/substreams-erc20-balance-changes/blob/99907f0bbb3bc0a4545bb1898b3883f6621381b9/src/maps.rs#L133C44-L133C56

ChatGPT context

In standard Ethereum logs, the log.address field always contains the address of the contract that emitted that log. So, if you are looking at an ERC‑20 Transfer event log, log.address will be the address of the token contract.

  • log.address = the contract address that emitted the event.
  • call.address (if exposed in certain tooling) may indicate the “to” or “from” in a lower-level call context, but is not the address that emitted the event.

Therefore, to find the token contract address from a Transfer event, you would look at log.address.


Example (pseudocode)

for (let log of receipt.logs) {
  if (log.topics[0] === TRANSFER_TOPIC_SIGNATURE) {
    let tokenContractAddress = log.address;
    // decode the rest of the event data, e.g., from/to/value
  }
}

Here, tokenContractAddress is the ERC‑20 contract’s address.

DenisCarriere added a commit to pinax-network/substreams-erc20-balance-changes that referenced this issue Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant