How I saved $ 98000/year in GAS using Solidity

Marcus Poli
Jul 27, 2018 · 3 min read

This history occurs in the testing environment of the Rinkeby network and the amount saved was only a projection exercise.

All started in April, 2018 when I decide to create a exercise using Ethereum Blockchain.
I believe that next years a lot of developers will looking for soluctions using Blockchain because doesn’t require investment in infraestructure machines and security maintenance.
The IT word “FOG” will be used more often than the word “BLOCKCHAIN”
and both will walk technically together without the knowledge of must people.
DAPPS will have accomplished much more than SMART CONTRACTS;
unfortunately, Ethereum will be much more expensive than the current value.
I made a system that controls the issuance of blood donor certificates.
Here, in Brazil, we have government incentives to donate blood.
When someone decides to donate, he has priority seats on public transport, has preference in bank queues and other benefits that are given according to the state; of course these benefits are given to those who donate within a stipulated period and some benefits are just for in the same day.

Simplifying, my goal was to store who made the donation and when this donation was last made.

First, I start write this Solidity code:

Repair that have mapping a parameter defined as String, It’s just because we must to save in Blockchain CPF.
CPF is a kind of Brazilian document.
It is numeric and have a mask with dot and dash, similar to 000.000.000–00, but, last two digits has been calculate with modular 11.
After develop solidity code, I went to create a simple DAPP using HTML, AngularJs, Javascript and Metamask pluggin.
The result was bellow.



First page is just for public query and other page is exclusively for public health administrators.
If you want to see running this app, go to https://hidedocsbit.000webhostapp.com/

This app must to store data from 2 percent of total peoples and four records each year. It is fifteen million records.

Wow, implanting this project, would spend $ 2,257,200.

- Is it possible to economize a little?

So, I back to the drawing board to remove the calculable digits, the dot and dash from CPF.
Now, I would store it as number field.

That night, when I was in a shower, I had an idea.
- Hey brow, If I had a numeric sequence with three chars like 255, I store it using only one byte identified by 255.
Eureka! I change nine chars to four bytes.

Doing it, I saved four percent/year.
I was happy, it’s would approach ninety-eight thousand dollars year.

You may be thinking that the economy is not much, but if you turn that economy into ambulances, this would buy three fully equipped vehicles year.

After this exercise, I spent some time developing routines that be really effective for Blockchains and you can check out at www.polidatacompressor.com

Marcus Poli

Written by

I’m Brazilian. I’ve interest in technologies matters. I wrote one fiction book that talk about drones - KDP 2017. Currently I’ve developing PoliDataCompressor.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade