A data packing library.
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.
To install with Foundry:
forge install exp-table/hyena
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);
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.