# decodeUint32Key

> **decodeUint32Key**(`bytes`, `offset?`): `number`

Defined in: [packages/key-encoding/src/scalars.ts:51](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/key-encoding/src/scalars.ts#L51)

Decode the 4-byte `encodeUint32Key` encoding.

Every `decode*Key` function follows one rule for `offset`. Without it, `bytes` must be exactly one key and anything after the key is `TRAILING_BYTES`. With it, the key is read in place at `offset` and the bytes after it are left to the caller, which is how a hand-built composite key is read one field at a time.

## Parameters

### bytes

`Uint8Array`

### offset?

`number`

## Returns

`number`

## Throws

`INVALID_KEY_VALUE` when `bytes` is not a `Uint8Array`, or `INVALID_OFFSET` when `offset` is not an integer in `0 .. bytes.byteLength`.

## Throws

`TRUNCATED_KEY` when fewer than 4 bytes follow `offset`, or `TRAILING_BYTES` when `offset` is omitted and `bytes` is longer than 4 bytes.
