The Apollo development team has always pushed for education and clarity in the crypto space. The good news is that the Ethereum blockchain handles a lot of the clarity part. However, the space can be confusing and while there are great tools like Etherscan out there… there are many drawers in the toolbox that go unopened. So for this blog we want to talk through a drawer in your crypto toolbox… “Events”.
While everything that happens on the Ethereum blockchain is traceable, it also allows developers to add “logs” to transactions. In a basic sense, Events are logs on the blockchain. They can make it much easier to search and is likely what your wallet is using to keep your token balances up to date.
So let’s start with what an Event looks like. And to do that you need to look at the source code for a project. Almost every reputable project will have their source code verified (Etherscan has confirmed that the source code provided matches the project’s smart contract). Every dApp/ERC-20 token’s contract page will have a “Contract” tab on Etherscan. For example, say you are viewing the Apollo Etherscan page.
If you click on the “Contract: …” under the “Profile Summary” you will be taken to the contract page for the Apollo token. Note that for ERC-20 tokens there is a difference between its token tracker page and its contract page. Note the differences between the image namely…
- The URL will say “address” if you are on the contract page instead of “token”
- Next to the icon at the top left you will wee “Contract” if you are on the contract page instead of the token page
- The contract page will not have information like “holders”, “Max Total Supply”, or “Profile Summary”
Now that we are on the Apollo contract page. We want to look at the source code for the smart contract. To do that you can click on the “Contract” tab and make sure “Code” is selected. NOTE: Browsing the source code can be more complex. For example many projects use proxies like EIP-1967, but that is a topic for another day.
So we are looking at the verified (note the green check mark above the contract”) source code for the Apollo token. Now I want to see which Events I can search for. Events are mostly up to the discretion of the developer outside the requirements for the protocol or pattern you may be using. For example ERC20 tokens have a transfer Event. Traditional Events include, but are limited to, when a transfer happens, when ownership of a contract changes, and when tokens are minted.
Browsing the Apollo contract we see there is an Event for when a new DAO address is set. That Event also includes the address of that new DAO. So now how do I search for any time that Event is triggered? This part gets a little more complex, but stick with me. Events are separated into “Topics” and “Data”. For now we will just be sticking with the topic(s), namely Topic (if you are new to this don’t think too much on that). Ethereum uses keccak hashes to represent these topics. So if I know the topic/event source code, I can get the hash for it. So what we will do is copy that Event and take it to a Keccak-256 hash function tool. You’ll need to remove any keywords (“event” and “indexed”) and argument names (“newDAO”).
Below you will see the hash printed out. Now we can go back to Etherscan to the “Events” tab of the contract page for Apollo. Next you’ll tap the search button on the top right and enter the hash you got from the Keccak tool with the “0x” prefix as the hash is in hexi-decimal form.
And Voila! We can see any time that Event was “emitted”.
Now if I want details on any of the transactions I can click on the txn hash. Here I am going to click on the hash of that third entry.
As you can see, Event tracking can be very useful for things like investigating new projects or setting up listeners/alarms for certain actions on the blockchain. And this example here is just scratching the surface…