Skip to main content

ERC-20 Token Transfers

Updated on
Dec 14, 2023

Overview

ERC-20 is a standard for creating tokens on EVM-compatible networks. If you want to learn more about the ERC-20 token standard and how to create your own token, check the guide here.

There are plenty of EVM-compatible chains out there, and each chain has many ERC-20 tokens deployed. Extracting a particular token's data from the chain may require doing a lot of filter operations to find that token's transaction from the long list of various kinds of transactions on the chain. On top of that, finding or listening for a particular event can be quite complex.

Fortunately, QuickAlerts makes this easy. Let's take a look at how you can use QuickAlerts to listen for a particular token's transfer. The examples below show us how we can track ERC-20 and TRC-20 token transfers.

ERC-20 Token Transfers

Whenever an ERC-20 transfer takes place Transfer (index_topic_1 address from, index_topic_2 address to, uint256 value) event is emitted by the smart contract. We will track this event.

To create our expression, we will need to target two values:

  1. The ERC-20 token smart contract - To track the transfer of a particular token we will need the smart contract address of that token (USDT in this case). This value gets set as the tx_logs_address, as we will be looking for any transactions from this address (the contract).
  2. The event the contract emits when the action we're interested in occurs - We will be tracking the Transfer event of the ERC-20 token smart contract. On EVM blockchains, the event is encoded and can be found in tx_logs_topic0. To get the encoded value, you will need to take the event definition (event name and parameters' types), run it through the Keccak-256 hash function, and prefix it with 0x.
Transfer(address,address,uint256)

ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef

0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef

You can replace the address in the tx_logs_address field with the address of any ERC-20 token smart contract you want to track.

Expression
Deploy
1
tx_logs_address=='0xdAC17F958D2ee523a2206206994597C13D831ec7'
2
&&
3
tx_logs_topic0=='0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'

TRC-20 Token Transfers

Whenever a TRC-20 transfer takes place, the Transfer (index_topic_1 address from, index_topic_2 address to, uint256 value) event is emitted by the smart contract. We will track this event.

Tron uses Base58 encoding for generating addresses, which differs from Ethereum. So, for it to work with QuickAlerts the address of the TRC-20 token smart contract we want to track needs to be converted to an EVM address using the TRONSCAN converter.

To create our expression, we will need to target two values:

  1. The TRC-20 token smart contract - To track the transfer of a particular token we will need the Tron smart contract address of that token (USDT in this case) which is converted to the EVM address. This value gets set as the tx_logs_address, as we will be looking for any transactions from this address (the contract).
  2. The event the contract emits when the action we're interested in occurs - We will be tracking the Transfer event of the TRC-20 token smart contract. On Tron blockchains, the event is encoded and can be found in tx_logs_topic0. To get the encoded value, you will need to take the event definition (event name and parameters' types), run it through the Keccak-256 hash function, and prefix it with 0x.
Transfer(address,address,uint256)

ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef

0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef

You can replace the address in the tx_logs_address field with the address of any TRC-20 token smart contract you want to track.

Expression
Deploy
1
tx_logs_address=='0xA614F803B6FD780986A42C78EC9C7F77E6DED13C'
2
&&
3
tx_logs_topic0=='0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
Share this doc