ERC20 tokens

Monitor any ERC-20 compatible token

ERC-20 allows the implementation of a standard API to ensure the interoperability between tokens. It offers basic functionalities to transfer tokens, obtain account balances, get the total supply of tokens, and allow token approvals. You can read more about their API and methods here: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md

Let’s see how HAL can helps us interact with any token that follows the ERC-20 standard, with some real-world examples:

Track when you send or receive tokens

The method transferFrom:

function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)

is used for a withdraw workflow, allowing contracts to transfer tokens on your behalf, and it must fire the Transfer event Transfer(msg.sender, _to, _value); we can therefore create an Event Trigger that looks for events emitted and sends us an email every time a smart contract transfers any amount of tokens from our account:

  1. EventsTriggers -> Create new

  2. In Smart contract address, insert the address of the token you want to track. E.g. If you want to track the MakerDAO’s stablecoin, insert 0x6b175474e89094c44da98b954eedeac495271d0f

  3. From the "contract event to watch" dropdown menu, select Transfer

  4. If you want to track sent tokens, insert your address in from If you want to track the token you receive, insert your address in to. You can also specify a range in the value field, for example to filter transactions that move more than X coins.

Track the balance of any account

The standard also implements a method balanceOf for returning the account balance of another account:

function balanceOf(address _owner) public view returns (uint256 balance)

Say that we want to monitor whether the balance for a specific address drops below a certain threshold. We can call it directly with a Watch a Contract Trigger:

  1. Contracts Triggers > Create new

  2. If you want to track the MakerDAO’s stablecoin, insert 0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2

  3. From the Contract function to watch menu, select balanceOf

  4. In the field src [address], insert the address you want to track.

  5. In the field returns, enter the threshold value that you want the trigger to be fired if the balance drops below.

Track when the total supply of coin changes (minting and burning)

Minting and Burning are implemented using a Transfer with a specific from field, which emits a Transfer event with the address set to 0x (see an example here). You can create a Trigger that fires every time tokens are mint this way:

  1. Events Trigger > Create new

  2. If you want to track the MakerDAO’s stablecoin, insert 0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2

  3. From the Contract function to watch menu, select Transfer

  4. In the From field, insert 0x0000000000000000000000000000000000000000000000000000000000000000

Track when a contract is allowed to withdraw your tokens

The Approval event is fired on any successful call to approve(address _spender, uint256 _value). We can create a Trigger that is fired every time some funds are withdrawn from your account:

  1. EventsTriggers -> Create new

  2. In Smart contract address, insert the address of the token you want to track. E.g. If you want to track the MakerDAO’s stablecoin, insert 0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2

  3. From the "contract event to watch" dropdown menu, select Approval

  4. Under the owner field, insert your own address

  5. You can leave spender empty, or track a specific spender

  6. You can leave value empty, or track any transfer that moves a particular amount of tokens.

Last updated