> For the complete documentation index, see [llms.txt](https://docs.mav.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mav.xyz/technical-reference/maverick-v2/v2-contracts/maverick-v2-supplemental-contracts/libraries/byteslib.md).

# BytesLib

### Functions <a href="#functions" id="functions"></a>

#### slice <a href="#slice" id="slice"></a>

```solidity
function slice(bytes memory _bytes, uint256 _start, uint256 _length) internal pure returns (bytes memory);
```

#### toAddress <a href="#toaddress" id="toaddress"></a>

```solidity
function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address addr);
```

#### toBool <a href="#tobool" id="tobool"></a>

```solidity
function toBool(bytes memory _bytes, uint256 _start) internal pure returns (bool);
```

#### toAddressAddressBoolUint128Uint128 <a href="#toaddressaddressbooluint128uint128" id="toaddressaddressbooluint128uint128"></a>

```solidity
function toAddressAddressBoolUint128Uint128(bytes memory _bytes)
    internal
    pure
    returns (address addr1, address addr2, bool bool_, uint128 amount1, uint128 amount2);
```

### Errors <a href="#errors" id="errors"></a>

#### BytesLibToBoolOutOfBounds <a href="#byteslibtobooloutofbounds" id="byteslibtobooloutofbounds"></a>

```solidity
error BytesLibToBoolOutOfBounds();
```

#### BytesLibToAddressOutOfBounds <a href="#byteslibtoaddressoutofbounds" id="byteslibtoaddressoutofbounds"></a>

```solidity
error BytesLibToAddressOutOfBounds();
```

#### BytesLibSliceOverflow <a href="#byteslibsliceoverflow" id="byteslibsliceoverflow"></a>

```solidity
error BytesLibSliceOverflow();
```

#### BytesLibSliceOutOfBounds <a href="#byteslibsliceoutofbounds" id="byteslibsliceoutofbounds"></a>

```solidity
error BytesLibSliceOutOfBounds();
```

#### BytesLibInvalidLength <a href="#byteslibinvalidlength" id="byteslibinvalidlength"></a>

```solidity
error BytesLibInvalidLength(uint256 inputLength, uint256 expectedLength);
```

<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.mav.xyz/technical-reference/maverick-v2/v2-contracts/maverick-v2-supplemental-contracts/libraries/byteslib.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
