JBIpfsDecoder
Utilities to decode an IPFS hash.
This is fairly gas intensive due to multiple nested loops. Onchain IPFS hash decoding is not advised – storing them as a string might be more efficient for that use-case.
State Variables
ALPHABET
Just a kind reminder to our readers.
Used in base58ToString
bytes internal constant ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
Functions
decode
function decode(string memory baseUri, bytes32 hexString) internal pure returns (string memory);
_toBase58
Convert a hex string to base58
Written by Martin Ludfall - Licence: MIT
function _toBase58(bytes memory source) private pure returns (string memory);
_truncate
function _truncate(uint8[] memory array, uint8 length) private pure returns (uint8[] memory);
_reverse
function _reverse(uint8[] memory input) private pure returns (uint8[] memory);
_toAlphabet
function _toAlphabet(uint8[] memory indices) private pure returns (bytes memory);