You may have already seen that you can compress numbers using the PoliDataCompressor.js library, and you may already know that compressing data to store them in Blockchain can help you save a lot of money depending on the amount of records entered by your DAPP or SMART CONTRACT.
In today’s topic, we will apply compression to fields with email addresses.
Well, to facilitate our learning, open polidatacompressor.com in Google Chrome and right-click choose the last menu option that should be “Inspect” or if you prefer use the shortcut CTRL + SHIFT + I.
A window like the image below will appear.
If you are not in the “Console” option, navigate through the options until you find it.
Compressing email address
To compress fields that have alphanumeric, we must use the command Tcomp (P_1, P_2). This command has two parameters, the first one has the content that we will compress and the second has the list of allowed characters, see:
Tcomp (“firstname.lastname@example.org” .toLowerCase (), “abcdefghijklmnopqrstuvwxyz012345679@.-_”)
Note that we have changed the characters of the email to lowercase, since we do not have uppercase characters in the list that we defined in the second parameter.
The twenty-eight character compression representing the email got twenty-one characters to be stored in Blockchain, that is, the reduction of this email was 25%, see:
Uncompressing email address
To decompress we use the command Tdecomp (P_1, P_2). This command has two parameters where the first is the compressed content and the second the same list that we use to compress.
Caution: The list identified in the second parameter can not be changed after the data has been compressed or reorganized, keep it complete and static.
How to deploy the library in your web application
To deploy just download the .ZIP file on the site itself, unzip and reference the files in the <HEAD> of your HTML page.
You must to reference the JQuery library too.
About the license
Don’t worry about the license if your application stay in testing; but if this give to you opportunity to save money, you should contact us and negotiate a license for use.
Thanks for reading