Skip to content

Latest commit

 

History

History
52 lines (32 loc) · 2.21 KB

README.md

File metadata and controls

52 lines (32 loc) · 2.21 KB

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.