Skip to content

zeroPad

zeroPad(value, length): Uint8Array

Defined in: utils/bytes.ts:332

Pads the beginning of a BytesLike with zeros so it’s the specified length as a Uint8Array

Parameters

value

BytesLike

the value to pad

length

number

the desired length of the value

Returns

Uint8Array

the value padded with zeros to the specified length

Examples

zeroPad('0x039284');
// Uint8Array { [Iterator] 0: 0, 1: 0, 2: 0, 3: 3, 4: 146, 5: 132 }
// Equivalent to 0x000000039284
zeroPad([39, 25, 103, 45], 5);
// Uint8Array { [Iterator] 0: 0, 1: 39, 2: 25, 3: 103, 4: 45 }