Skip to content
On this page

size โ€‹

Retrieves the size of the value (in bytes).

Install โ€‹

ts
import { size } from 'viem'

Usage โ€‹

ts
import { size } from 'viem'

size('0xa4') // 1
size('0xa4e12a45') // 4
size(new Uint8Array([1, 122, 51, 123])) // 4

Returns โ€‹

number

The size of the value (in bytes).

Parameters โ€‹

value โ€‹

  • Type: Hex | ByteArray

The value (hex or byte array) to retrieve the size of.

Released under the MIT License.