An Open Source Tool for Smart Contracts' Transactions Analytics

Written by koteld | Published 2020/05/26
Tech Story Tags: blockchain | ethereum | smart-contracts | blockchain-development | ethereum-developers | smart-contract-development | blockchain-technology | blockchain-developer

TLDR Gaster is an Open Source Tool for Smart Contracts' Transactions Analytics. It gives you raw data about transactions conducted with a smart contract. Gaster gathers all the necessary data, aggregates it in one place, and gives you options for tuning your smart contract parameters. The tool is available for free and available to anyone who wants to know how much money they are going to spend on using smart contracts should take advantage of Gaster. The author is a full stack developer at Exyte, a real estate company.via the TL;DR App

Ethereum smart contracts promise to change the way we handle sensitive data and money. The drawback is that it is but a promise for now.

The technology is too new to be trusted with day-to-day business tasks.
Smart contracts themselves work like Swiss watches, but every transaction costs the smart contract owner money, the Ethereum blockchain fee. The fee depends on the features and parameters of a transaction.
As of now there is not a free tool that allows you to get data about transactions conducted with a smart contract in a straightforward way.
You have to collect all transaction data manually, and that is not even the worst part; you also have to decode it yourself.
We in Exyte decided to solve this problem.
(Disclaimer: The author is a full stack developer at Exyte)
And this is how Gaster appeared.
In this article we explain how Gaster works and how the blockchain community can benefit from this tool absolutely for free.

How does Gaster solve the problem of getting data about smart contract transactions?

Gaster gives you info about how a smart contract has been used. It gives you raw data about transactions. For example, what methods were called, what their parameters were, and how much that transaction cost the smart contract owner.
The smart contract owner analyses these data to learn: what smart contract methods are used more often what smart contract methods cost the most which users load the smart contract the most
Gaster gathers all the necessary data, aggregates it in one place, and gives you many options for tuning your smart contract parameters.

Why did no one make an open-source tool like that before?

Well, someone actually might have a similar tool. There may even be several of them, but they are mostly for private use. There are not many public (open) smart contracts, and there are not many public (free/open) tools for smart contract analytics that anyone can use.
The benefit of Gaster is that it is an Open-source tool. It is available to everyone. Anyone who has a smart contract or a dApp with a smart contract and wants to know how much money they are going to spend on using a smart contract should take advantage of Gaster.

Why didn't someone share the private tool that they'd been using?

It may be connected to the fact that there haven't been many dApps with smart contracts up until recently. DApp developers and smart contract owners just hadn't thought that they needed an analytics tool for their smart contracts.
The technology is still in its development stage. Usually, open-source tools appear when the technology is widespread. Smart contract technology starts trending about now with 75% growth in March. We felt that this was the time to start doing open-source projects for the community.

Why did you decide to work on this project? Are there any other problems with dealing with smart contracts from a business point of view?

There was another thing we wanted to work on: the possibility of going back to a previous state of the network and setting up that state of the network locally. This possibility is necessary to test and analyze complex use cases of unexpected smart contract behavior.
Having a tool like that would help Exyte in some of our recent projects. So we decided to write a script that would do that, transferring your local blockchain to a previous state of a public blockchain.  
While researching this topic, we found out that similar feature is scheduled for OpenEthereum (previously Parity Ethereum) in one of the upcoming milestones.
There weren't any other issues that needed to be addressed, so we focused on operational cost analytics.

How was the issue of transaction cost analytics solved before?

I cannot be certain here, because, again, there weren't any public tools that did that. Gaster is genuinely a crawler and decoder. It follows a certain logic to gather data about a smart contract through Etherscan API, taking into account the peculiarities of how a transaction was conducted.
After the data is gathered, Gaster decodes it into a human-readable format and saves the outcome into a CVS. The process is quite simple, and I think if anyone needed smart contract analytics, they would follow the same logic.

What was the business problem that initiated the work on Gaster?

It all started with the development of smart contract for the Proof of Ownership mechanism for a real estate company. The purpose of a smart contract in that case was to confirm that a user can buy a piece of land. Among other data, smart contracts there transferred the name of that piece of land.
As long as the Ethereum blockchain is sensitive to the amount of data, the length of that name directly influenced the transaction fee. We were able to discover that fact after taking a look at the data Gaster collected about that network.

How does Gaster work?

Gaster can collect raw transactions' data considering the specifics of its storage. With a single command, it collects, decodes, and saves all that data in CSV so you can use it for further analytics. Gaster collects the following data:
  • smart contract addressinput data (method and its parameters)
  • who called the smart contract
  • block where the transaction took place
  • transaction hash
  • amount of gas spent
  • gas price
Of course, there are several nuances here. Blockchain transactions can have a hierarchical call structure, as if you use Zeppelin OS (proxy contract) or just call one contract inside of another one, so each smart contract has both regular transactions and related internal transactions.
All of the internal transactions have their type according to what it does: create, delegatecall, staticcall, and so on. These transactions should be crawled and merged correctly in order to see the full picture of how the contract works.
It is not the topic of this talk, but more information about internal transaction (message call) types can be found herehere, and here.

How and where can Gaster be used?

Gaster can make an automatic Python report that uses raw CSV data and makes general analytics to show how it can work. So you, as contract owner, can get useful information about the most-used functions, the most expensive functions, and how users use your contract, as well as make invoices for them and much more, presented in the form of plots and tables.
The Gaster-generated plots below provide the contract owner with useful information, such as:
The cost dynamics of contract methods over time
Based on this data, you can forecast the future cost and identify thresholds for changes in cost for a particular method.
The dynamics of cost distribution for contract methods over time
You can also use this graph to determine how often the smart contract is used.
The nature of changes in the average cost of smart contract methods over time
This data allows you to track the use of methods and compare it with the gas price data.
The gas price value set for the transaction relative to time
This graph help you find a better way to adjust the gas price for the methods in the future.

Bottom line

We hope you will find Gaster useful for your blockchain-based projects. If you like what we did, we’d really appreciate it if you star Gaster rep on GitHub. As for now, we are continuing our work on developing Gaster.
If you have any questions or suggestions, we’d be glad to hear from you! Drop us a message or hit us on TwitterLinkedIn or Facebook.
(Disclaimer: The author is a full stack developer at Exyte)

Written by koteld | Full Stack Blockchain Developer @ Protofire
Published by HackerNoon on 2020/05/26