Skip to content
generated from refcell/femplate

Pack data tightly together and save space.

License

Notifications You must be signed in to change notification settings

exp-table/hyena

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hyena • tests license solidity

A data packing library.

What is Hyena?

Hyena is a library that is an alternative to abi.encode and abi.encodePacked that can result in smaller bytes.

It WON'T beat abi.encode or abi.encodePacked in terms of gas consumption but will in the size of the output. A reduction of up to 50% can be obtained.

It serves as educational material.

Warning

Due to how the internal "map" works, you can only pack 41 32-bytes values.

It should be noted that unpacking the payload produces an array whose elements order is in reverse w.r.t the elements that were added.

Installation

To install with Foundry:

forge install exp-table/hyena

Usage

bytes memory payload = Hyena.init();
payload = Hyena.crush(payload, uint(100));
payload = Hyena.crush(payload, uint(2**256 - 1));
uint256[] memory outputs = Hyena.digest(payload);

Notable Mentions

Disclaimer

These smart contracts are being provided as is. No guarantee, representation or warranty is being made, express or implied, as to the safety or correctness of the user interface or the smart contracts. They have not been audited and as such there can be no assurance they will work as intended, and users may experience delays, failures, errors, omissions, loss of transmitted information or loss of funds. The creators are not liable for any of the foregoing. Users should proceed with caution and use at their own risk.

See LICENSE for more details.

About

Pack data tightly together and save space.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published