UNPKG

eth-crypto

Version:

Cryptographic functions for ethereum and how to use them with web3 and solidity

12 lines 386 B
export function removeLeading0x(str) { if (str.startsWith('0x')) return str.substring(2);else return str; } export function addLeading0x(str) { if (!str.startsWith('0x')) return '0x' + str;else return str; } export function uint8ArrayToHex(arr) { return Buffer.from(arr).toString('hex'); } export function hexToUnit8Array(str) { return new Uint8Array(Buffer.from(str, 'hex')); }