How to use the @ethersproject/constants.HashZero function in @ethersproject/constants

To help you get started, we’ve selected a few @ethersproject/constants examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ethers-io / ethers.js / packages / strings / lib / bytes32.js View on Github external
function formatBytes32String(text) {
    // Get the bytes
    var bytes = utf8_1.toUtf8Bytes(text);
    // Check we have room for null-termination
    if (bytes.length > 31) {
        throw new Error("bytes32 string must be less than 32 bytes");
    }
    // Zero-pad (implicitly null-terminates)
    return bytes_1.hexlify(bytes_1.concat([bytes, constants_1.HashZero]).slice(0, 32));
}
exports.formatBytes32String = formatBytes32String;

@ethersproject/constants

Common Ethereum constants used for ethers.

MIT
Latest version published 2 years ago

Package Health Score

68 / 100
Full package analysis