Store
Reference
Miscellaneous

Bytes

Git Source (opens in a new tab)

Utility functions for bytes.

Functions

setLength

UTILS

Sets the length of a bytes blob in memory. This function does not resize the memory allocation; it only changes the length field, which affects operations that access the length property.

function setLength(bytes memory input, uint256 length) internal pure returns (bytes memory);

Parameters

NameTypeDescription
inputbytesThe bytes blob to modify.
lengthuint256The new length to set.

Returns

NameTypeDescription
<none>bytesReference to the input bytes blob with modified length.

setBytes4

SET

Sets a specific 4-byte sequence in a bytes blob at a given index.

function setBytes4(bytes memory input, uint256 index, bytes4 overwrite) internal pure returns (bytes memory);

Parameters

NameTypeDescription
inputbytesThe bytes blob in which a specific 4-byte sequence is to be altered.
indexuint256The position within the bytes blob to start altering the 4-byte sequence. Index starts from the left.
overwritebytes4The new 4-byte value to be set at the specified index.

Returns

NameTypeDescription
<none>bytesThe modified bytes blob with the new 4-byte value at the specified index.

getBytes1

GET Used by codegen libraries

Extracts a single byte from a bytes blob starting at a specific position.

function getBytes1(bytes memory data, uint256 start) internal pure returns (bytes1 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a byte is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes1The extracted bytes1 value from the specified position in the bytes blob.

getBytes1

Extracts a single byte from a bytes32 value starting at a specific position.

function getBytes1(bytes32 data, uint256 start) internal pure returns (bytes1 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a byte is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes1The extracted bytes1 value from the specified position in the bytes32 value.

getBytes2

Extracts a 2-byte sequence from a bytes blob starting at a specific position.

function getBytes2(bytes memory data, uint256 start) internal pure returns (bytes2 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 2-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes2The extracted bytes2 value from the specified position in the bytes blob.

getBytes2

Extracts a 2-byte sequence from a bytes32 value starting at a specific position.

function getBytes2(bytes32 data, uint256 start) internal pure returns (bytes2 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 2-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes2The extracted bytes2 value from the specified position in the bytes32 value.

getBytes3

Extracts a 3-byte sequence from a bytes blob starting at a specific position.

function getBytes3(bytes memory data, uint256 start) internal pure returns (bytes3 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 3-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes3The extracted bytes3 value from the specified position in the bytes blob.

getBytes3

Extracts a 3-byte sequence from a bytes32 value starting at a specific position.

function getBytes3(bytes32 data, uint256 start) internal pure returns (bytes3 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 3-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes3The extracted bytes3 value from the specified position in the bytes32 value.

getBytes4

Extracts a 4-byte sequence from a bytes blob starting at a specific position.

function getBytes4(bytes memory data, uint256 start) internal pure returns (bytes4 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 4-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes4The extracted bytes4 value from the specified position in the bytes blob.

getBytes4

Extracts a 4-byte sequence from a bytes32 value starting at a specific position.

function getBytes4(bytes32 data, uint256 start) internal pure returns (bytes4 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 4-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes4The extracted bytes4 value from the specified position in the bytes32 value.

getBytes5

Extracts a 5-byte sequence from a bytes blob starting at a specific position.

function getBytes5(bytes memory data, uint256 start) internal pure returns (bytes5 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 5-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes5The extracted bytes5 value from the specified position in the bytes blob.

getBytes5

Extracts a 5-byte sequence from a bytes32 value starting at a specific position.

function getBytes5(bytes32 data, uint256 start) internal pure returns (bytes5 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 5-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes5The extracted bytes5 value from the specified position in the bytes32 value.

getBytes6

Extracts a 6-byte sequence from a bytes blob starting at a specific position.

function getBytes6(bytes memory data, uint256 start) internal pure returns (bytes6 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 6-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes6The extracted bytes6 value from the specified position in the bytes blob.

getBytes6

Extracts a 6-byte sequence from a bytes32 value starting at a specific position.

function getBytes6(bytes32 data, uint256 start) internal pure returns (bytes6 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 6-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes6The extracted bytes6 value from the specified position in the bytes32 value.

getBytes7

Extracts a 7-byte sequence from a bytes blob starting at a specific position.

function getBytes7(bytes memory data, uint256 start) internal pure returns (bytes7 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 7-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes7The extracted bytes7 value from the specified position in the bytes blob.

getBytes7

Extracts a 7-byte sequence from a bytes32 value starting at a specific position.

function getBytes7(bytes32 data, uint256 start) internal pure returns (bytes7 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 7-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes7The extracted bytes7 value from the specified position in the bytes32 value.

getBytes8

Extracts a 8-byte sequence from a bytes blob starting at a specific position.

function getBytes8(bytes memory data, uint256 start) internal pure returns (bytes8 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 8-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes8The extracted bytes8 value from the specified position in the bytes blob.

getBytes8

Extracts a 8-byte sequence from a bytes32 value starting at a specific position.

function getBytes8(bytes32 data, uint256 start) internal pure returns (bytes8 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 8-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes8The extracted bytes8 value from the specified position in the bytes32 value.

getBytes9

Extracts a 9-byte sequence from a bytes blob starting at a specific position.

function getBytes9(bytes memory data, uint256 start) internal pure returns (bytes9 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 9-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes9The extracted bytes9 value from the specified position in the bytes blob.

getBytes9

Extracts a 9-byte sequence from a bytes32 value starting at a specific position.

function getBytes9(bytes32 data, uint256 start) internal pure returns (bytes9 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 9-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes9The extracted bytes9 value from the specified position in the bytes32 value.

getBytes10

Extracts a 10-byte sequence from a bytes blob starting at a specific position.

function getBytes10(bytes memory data, uint256 start) internal pure returns (bytes10 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 10-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes10The extracted bytes10 value from the specified position in the bytes blob.

getBytes10

Extracts a 10-byte sequence from a bytes32 value starting at a specific position.

function getBytes10(bytes32 data, uint256 start) internal pure returns (bytes10 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 10-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes10The extracted bytes10 value from the specified position in the bytes32 value.

getBytes11

Extracts a 11-byte sequence from a bytes blob starting at a specific position.

function getBytes11(bytes memory data, uint256 start) internal pure returns (bytes11 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 11-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes11The extracted bytes11 value from the specified position in the bytes blob.

getBytes11

Extracts a 11-byte sequence from a bytes32 value starting at a specific position.

function getBytes11(bytes32 data, uint256 start) internal pure returns (bytes11 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 11-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes11The extracted bytes11 value from the specified position in the bytes32 value.

getBytes12

Extracts a 12-byte sequence from a bytes blob starting at a specific position.

function getBytes12(bytes memory data, uint256 start) internal pure returns (bytes12 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 12-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes12The extracted bytes12 value from the specified position in the bytes blob.

getBytes12

Extracts a 12-byte sequence from a bytes32 value starting at a specific position.

function getBytes12(bytes32 data, uint256 start) internal pure returns (bytes12 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 12-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes12The extracted bytes12 value from the specified position in the bytes32 value.

getBytes13

Extracts a 13-byte sequence from a bytes blob starting at a specific position.

function getBytes13(bytes memory data, uint256 start) internal pure returns (bytes13 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 13-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes13The extracted bytes13 value from the specified position in the bytes blob.

getBytes13

Extracts a 13-byte sequence from a bytes32 value starting at a specific position.

function getBytes13(bytes32 data, uint256 start) internal pure returns (bytes13 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 13-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes13The extracted bytes13 value from the specified position in the bytes32 value.

getBytes14

Extracts a 14-byte sequence from a bytes blob starting at a specific position.

function getBytes14(bytes memory data, uint256 start) internal pure returns (bytes14 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 14-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes14The extracted bytes14 value from the specified position in the bytes blob.

getBytes14

Extracts a 14-byte sequence from a bytes32 value starting at a specific position.

function getBytes14(bytes32 data, uint256 start) internal pure returns (bytes14 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 14-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes14The extracted bytes14 value from the specified position in the bytes32 value.

getBytes15

Extracts a 15-byte sequence from a bytes blob starting at a specific position.

function getBytes15(bytes memory data, uint256 start) internal pure returns (bytes15 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 15-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes15The extracted bytes15 value from the specified position in the bytes blob.

getBytes15

Extracts a 15-byte sequence from a bytes32 value starting at a specific position.

function getBytes15(bytes32 data, uint256 start) internal pure returns (bytes15 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 15-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes15The extracted bytes15 value from the specified position in the bytes32 value.

getBytes16

Extracts a 16-byte sequence from a bytes blob starting at a specific position.

function getBytes16(bytes memory data, uint256 start) internal pure returns (bytes16 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 16-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes16The extracted bytes16 value from the specified position in the bytes blob.

getBytes16

Extracts a 16-byte sequence from a bytes32 value starting at a specific position.

function getBytes16(bytes32 data, uint256 start) internal pure returns (bytes16 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 16-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes16The extracted bytes16 value from the specified position in the bytes32 value.

getBytes17

Extracts a 17-byte sequence from a bytes blob starting at a specific position.

function getBytes17(bytes memory data, uint256 start) internal pure returns (bytes17 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 17-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes17The extracted bytes17 value from the specified position in the bytes blob.

getBytes17

Extracts a 17-byte sequence from a bytes32 value starting at a specific position.

function getBytes17(bytes32 data, uint256 start) internal pure returns (bytes17 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 17-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes17The extracted bytes17 value from the specified position in the bytes32 value.

getBytes18

Extracts a 18-byte sequence from a bytes blob starting at a specific position.

function getBytes18(bytes memory data, uint256 start) internal pure returns (bytes18 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 18-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes18The extracted bytes18 value from the specified position in the bytes blob.

getBytes18

Extracts a 18-byte sequence from a bytes32 value starting at a specific position.

function getBytes18(bytes32 data, uint256 start) internal pure returns (bytes18 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 18-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes18The extracted bytes18 value from the specified position in the bytes32 value.

getBytes19

Extracts a 19-byte sequence from a bytes blob starting at a specific position.

function getBytes19(bytes memory data, uint256 start) internal pure returns (bytes19 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 19-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes19The extracted bytes19 value from the specified position in the bytes blob.

getBytes19

Extracts a 19-byte sequence from a bytes32 value starting at a specific position.

function getBytes19(bytes32 data, uint256 start) internal pure returns (bytes19 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 19-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes19The extracted bytes19 value from the specified position in the bytes32 value.

getBytes20

Extracts a 20-byte sequence from a bytes blob starting at a specific position.

function getBytes20(bytes memory data, uint256 start) internal pure returns (bytes20 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 20-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes20The extracted bytes20 value from the specified position in the bytes blob.

getBytes20

Extracts a 20-byte sequence from a bytes32 value starting at a specific position.

function getBytes20(bytes32 data, uint256 start) internal pure returns (bytes20 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 20-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes20The extracted bytes20 value from the specified position in the bytes32 value.

getBytes21

Extracts a 21-byte sequence from a bytes blob starting at a specific position.

function getBytes21(bytes memory data, uint256 start) internal pure returns (bytes21 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 21-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes21The extracted bytes21 value from the specified position in the bytes blob.

getBytes21

Extracts a 21-byte sequence from a bytes32 value starting at a specific position.

function getBytes21(bytes32 data, uint256 start) internal pure returns (bytes21 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 21-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes21The extracted bytes21 value from the specified position in the bytes32 value.

getBytes22

Extracts a 22-byte sequence from a bytes blob starting at a specific position.

function getBytes22(bytes memory data, uint256 start) internal pure returns (bytes22 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 22-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes22The extracted bytes22 value from the specified position in the bytes blob.

getBytes22

Extracts a 22-byte sequence from a bytes32 value starting at a specific position.

function getBytes22(bytes32 data, uint256 start) internal pure returns (bytes22 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 22-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes22The extracted bytes22 value from the specified position in the bytes32 value.

getBytes23

Extracts a 23-byte sequence from a bytes blob starting at a specific position.

function getBytes23(bytes memory data, uint256 start) internal pure returns (bytes23 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 23-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes23The extracted bytes23 value from the specified position in the bytes blob.

getBytes23

Extracts a 23-byte sequence from a bytes32 value starting at a specific position.

function getBytes23(bytes32 data, uint256 start) internal pure returns (bytes23 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 23-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes23The extracted bytes23 value from the specified position in the bytes32 value.

getBytes24

Extracts a 24-byte sequence from a bytes blob starting at a specific position.

function getBytes24(bytes memory data, uint256 start) internal pure returns (bytes24 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 24-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes24The extracted bytes24 value from the specified position in the bytes blob.

getBytes24

Extracts a 24-byte sequence from a bytes32 value starting at a specific position.

function getBytes24(bytes32 data, uint256 start) internal pure returns (bytes24 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 24-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes24The extracted bytes24 value from the specified position in the bytes32 value.

getBytes25

Extracts a 25-byte sequence from a bytes blob starting at a specific position.

function getBytes25(bytes memory data, uint256 start) internal pure returns (bytes25 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 25-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes25The extracted bytes25 value from the specified position in the bytes blob.

getBytes25

Extracts a 25-byte sequence from a bytes32 value starting at a specific position.

function getBytes25(bytes32 data, uint256 start) internal pure returns (bytes25 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 25-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes25The extracted bytes25 value from the specified position in the bytes32 value.

getBytes26

Extracts a 26-byte sequence from a bytes blob starting at a specific position.

function getBytes26(bytes memory data, uint256 start) internal pure returns (bytes26 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 26-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes26The extracted bytes26 value from the specified position in the bytes blob.

getBytes26

Extracts a 26-byte sequence from a bytes32 value starting at a specific position.

function getBytes26(bytes32 data, uint256 start) internal pure returns (bytes26 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 26-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes26The extracted bytes26 value from the specified position in the bytes32 value.

getBytes27

Extracts a 27-byte sequence from a bytes blob starting at a specific position.

function getBytes27(bytes memory data, uint256 start) internal pure returns (bytes27 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 27-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes27The extracted bytes27 value from the specified position in the bytes blob.

getBytes27

Extracts a 27-byte sequence from a bytes32 value starting at a specific position.

function getBytes27(bytes32 data, uint256 start) internal pure returns (bytes27 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 27-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes27The extracted bytes27 value from the specified position in the bytes32 value.

getBytes28

Extracts a 28-byte sequence from a bytes blob starting at a specific position.

function getBytes28(bytes memory data, uint256 start) internal pure returns (bytes28 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 28-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes28The extracted bytes28 value from the specified position in the bytes blob.

getBytes28

Extracts a 28-byte sequence from a bytes32 value starting at a specific position.

function getBytes28(bytes32 data, uint256 start) internal pure returns (bytes28 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 28-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes28The extracted bytes28 value from the specified position in the bytes32 value.

getBytes29

Extracts a 29-byte sequence from a bytes blob starting at a specific position.

function getBytes29(bytes memory data, uint256 start) internal pure returns (bytes29 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 29-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes29The extracted bytes29 value from the specified position in the bytes blob.

getBytes29

Extracts a 29-byte sequence from a bytes32 value starting at a specific position.

function getBytes29(bytes32 data, uint256 start) internal pure returns (bytes29 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 29-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes29The extracted bytes29 value from the specified position in the bytes32 value.

getBytes30

Extracts a 30-byte sequence from a bytes blob starting at a specific position.

function getBytes30(bytes memory data, uint256 start) internal pure returns (bytes30 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 30-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes30The extracted bytes30 value from the specified position in the bytes blob.

getBytes30

Extracts a 30-byte sequence from a bytes32 value starting at a specific position.

function getBytes30(bytes32 data, uint256 start) internal pure returns (bytes30 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 30-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes30The extracted bytes30 value from the specified position in the bytes32 value.

getBytes31

Extracts a 31-byte sequence from a bytes blob starting at a specific position.

function getBytes31(bytes memory data, uint256 start) internal pure returns (bytes31 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 31-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes31The extracted bytes31 value from the specified position in the bytes blob.

getBytes31

Extracts a 31-byte sequence from a bytes32 value starting at a specific position.

function getBytes31(bytes32 data, uint256 start) internal pure returns (bytes31 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 31-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes31The extracted bytes31 value from the specified position in the bytes32 value.

getBytes32

Extracts a 32-byte sequence from a bytes blob starting at a specific position.

function getBytes32(bytes memory data, uint256 start) internal pure returns (bytes32 output);

Parameters

NameTypeDescription
databytesThe bytes blob from which a 32-byte sequence is to be extracted.
startuint256The starting position within the bytes blob for extraction.

Returns

NameTypeDescription
outputbytes32The extracted bytes32 value from the specified position in the bytes blob.

getBytes32

Extracts a 32-byte sequence from a bytes32 value starting at a specific position.

function getBytes32(bytes32 data, uint256 start) internal pure returns (bytes32 output);

Parameters

NameTypeDescription
databytes32The bytes32 value from which a 32-byte sequence is to be extracted.
startuint256The starting position within the bytes32 value for extraction.

Returns

NameTypeDescription
outputbytes32The extracted bytes32 value from the specified position in the bytes32 value.

FieldLayoutInstance

Git Source (opens in a new tab)

Provides instance functions for obtaining information from an encoded FieldLayout.

Functions

atIndex

Get the static byte length at the given index from the field layout.

function atIndex(FieldLayout fieldLayout, uint256 index) internal pure returns (uint256);

Parameters

NameTypeDescription
fieldLayoutFieldLayoutThe FieldLayout to extract the byte length from.
indexuint256The field index to get the static byte length from.

Returns

NameTypeDescription
<none>uint256The static byte length at the specified index.

staticDataLength

Get the total static byte length for the given field layout.

function staticDataLength(FieldLayout fieldLayout) internal pure returns (uint256);

Parameters

NameTypeDescription
fieldLayoutFieldLayoutThe FieldLayout to extract the total static byte length from.

Returns

NameTypeDescription
<none>uint256The total static byte length.

numStaticFields

Get the number of static fields for the field layout.

function numStaticFields(FieldLayout fieldLayout) internal pure returns (uint256);

Parameters

NameTypeDescription
fieldLayoutFieldLayoutThe FieldLayout to extract the number of static fields from.

Returns

NameTypeDescription
<none>uint256The number of static fields.

numDynamicFields

Get the number of dynamic length fields for the field layout.

function numDynamicFields(FieldLayout fieldLayout) internal pure returns (uint256);

Parameters

NameTypeDescription
fieldLayoutFieldLayoutThe FieldLayout to extract the number of dynamic fields from.

Returns

NameTypeDescription
<none>uint256The number of dynamic length fields.

numFields

Get the total number of fields for the field layout.

function numFields(FieldLayout fieldLayout) internal pure returns (uint256);

Parameters

NameTypeDescription
fieldLayoutFieldLayoutThe FieldLayout to extract the total number of fields from.

Returns

NameTypeDescription
<none>uint256The total number of fields.

isEmpty

Check if the field layout is empty.

function isEmpty(FieldLayout fieldLayout) internal pure returns (bool);

Parameters

NameTypeDescription
fieldLayoutFieldLayoutThe FieldLayout to check.

Returns

NameTypeDescription
<none>boolTrue if the field layout is empty, false otherwise.

validate

Validate the field layout with various checks on the length and size of the fields.

Reverts if total fields, static field length, or static byte length exceed allowed limits.

function validate(FieldLayout fieldLayout) internal pure;

Parameters

NameTypeDescription
fieldLayoutFieldLayoutThe FieldLayout to validate.

unwrap

Unwrap the field layout to obtain the raw bytes32 representation.

function unwrap(FieldLayout fieldLayout) internal pure returns (bytes32);

Parameters

NameTypeDescription
fieldLayoutFieldLayoutThe FieldLayout to unwrap.

Returns

NameTypeDescription
<none>bytes32The unwrapped bytes32 representation of the FieldLayout.

FieldLayoutLib

Git Source (opens in a new tab)

A library for handling field layout encoding into a single bytes32. It provides a function to encode static and dynamic fields and ensure various constraints regarding the length and size of the fields.

Functions

encode

Usage Sample

Encodes the given field layout into a single bytes32.

Ensures various constraints on the length and size of the fields. Reverts if total fields, static field length, or static byte length exceed allowed limits.

function encode(uint256[] memory _staticFieldLengths, uint256 numDynamicFields) internal pure returns (FieldLayout);

Parameters

NameTypeDescription
_staticFieldLengthsuint256[]An array of static field lengths.
numDynamicFieldsuint256The number of dynamic fields.

Returns

NameTypeDescription
<none>FieldLayoutA FieldLayout structure containing the encoded field layout.

FieldLayout

Git Source (opens in a new tab)

*Represents a field layout encoded into a single bytes32. From left to right, the bytes are laid out as follows:

  • 2 bytes for total length of all static fields
  • 1 byte for number of static size fields
  • 1 byte for number of dynamic size fields
  • 28 bytes for 28 static field lengths (MAX_DYNAMIC_FIELDS allows EncodedLengths to pack the dynamic lengths into 1 word)*
type FieldLayout is bytes32;

HookInstance

Git Source (opens in a new tab)

Library for interacting with Hook instances.

Functions

isEnabled

Check if the given hook types are enabled in the hook.

We check multiple hook types at once by using a bitmap.

function isEnabled(Hook self, uint8 hookTypes) internal pure returns (bool);

Parameters

NameTypeDescription
selfHookThe Hook instance to check.
hookTypesuint8A bitmap of hook types to check.

Returns

NameTypeDescription
<none>boolTrue if the hook types are enabled, false otherwise.

getAddress

Get the address from the hook.

The address is stored in the leftmost 20 bytes.

function getAddress(Hook self) internal pure returns (address);

Parameters

NameTypeDescription
selfHookThe Hook instance to get the address from.

Returns

NameTypeDescription
<none>addressThe address contained in the Hook instance.

getBitmap

Get the bitmap from the hook.

The bitmap is stored in the rightmost byte.

function getBitmap(Hook self) internal pure returns (uint8);

Parameters

NameTypeDescription
selfHookThe Hook instance to get the bitmap from.

Returns

NameTypeDescription
<none>uint8The bitmap contained in the Hook instance.

HookLib

Git Source (opens in a new tab)

Library for encoding hooks and filtering hooks from a list by address.

Functions

encode

Packs the bitmap of enabled hooks with the hook address into a Hook value (bytes21).

The hook address is stored in the leftmost 20 bytes, and the bitmap is stored in the rightmost byte.

function encode(address hookAddress, uint8 encodedHooks) internal pure returns (Hook);

Parameters

NameTypeDescription
hookAddressaddressThe address of the hook.
encodedHooksuint8The encoded hooks in a bitmap.

Returns

NameTypeDescription
<none>HookA Hook type with packed hook address and bitmap.

filterListByAddress

Filter a hook from the hook list by its address.

This function writes the updated hook list to the table in place.

function filterListByAddress(
  ResourceId hookTableId,
  ResourceId resourceWithHooks,
  address hookAddressToRemove
) internal;

Parameters

NameTypeDescription
hookTableIdResourceIdThe resource ID of the hook table.
resourceWithHooksResourceIdThe resource ID of the table with hooks to filter.
hookAddressToRemoveaddressThe address of the hook to remove.

Hook

Git Source (opens in a new tab)

type Hook is bytes21;

Memory

Git Source (opens in a new tab)

A library for performing low-level memory operations.

This library provides low-level memory operations with safety checks.

Functions

dataPointer

Gets the actual data pointer of dynamic arrays.

In dynamic arrays, the first word stores the length of the data, after which comes the actual data. Example: 0x40 0x01 0x02 ^len ^data

function dataPointer(bytes memory data) internal pure returns (uint256 memoryPointer);

Parameters

NameTypeDescription
databytesThe dynamic bytes data from which to get the pointer.

Returns

NameTypeDescription
memoryPointeruint256The pointer to the actual data (skipping the length).

copy

Copies memory from one location to another.

Safely copies memory in chunks of 32 bytes, then handles any residual bytes.

function copy(uint256 fromPointer, uint256 toPointer, uint256 length) internal pure;

Parameters

NameTypeDescription
fromPointeruint256The memory location to copy from.
toPointeruint256The memory location to copy to.
lengthuint256The number of bytes to copy.

ResourceId.sol constants

Git Source (opens in a new tab)

TYPE_BITS

Number of bits reserved for the type in the ResourceId.

uint256 constant TYPE_BITS = 2 * 8;

ResourceIdInstance

Git Source (opens in a new tab)

Provides functions to extract data from a ResourceId.

Functions

getType

Extracts the type identifier from a given ResourceId.

function getType(ResourceId resourceId) internal pure returns (bytes2);

Parameters

NameTypeDescription
resourceIdResourceIdThe ResourceId from which the type identifier should be extracted.

Returns

NameTypeDescription
<none>bytes2The extracted 2-byte type identifier.

getResourceName

Get the name from a resource ID.

function getResourceName(ResourceId resourceId) internal pure returns (bytes30);

Parameters

NameTypeDescription
resourceIdResourceIdThe resource ID.

Returns

NameTypeDescription
<none>bytes30A 30-byte name.

unwrap

Unwrap a resource ID into a bytes32.

function unwrap(ResourceId resourceId) internal pure returns (bytes32);

Parameters

NameTypeDescription
resourceIdResourceIdThe resource ID.

Returns

NameTypeDescription
<none>bytes32The underlying bytes32.

ResourceIdLib

Git Source (opens in a new tab)

Provides functions to encode data into the ResourceId

Functions

encode

Encodes given typeId and name into a ResourceId.

function encode(bytes2 typeId, bytes30 name) internal pure returns (ResourceId);

Parameters

NameTypeDescription
typeIdbytes2The type identifier to be encoded. Must be 2 bytes.
namebytes30The name to be encoded. Must be 30 bytes.

Returns

NameTypeDescription
<none>ResourceIdA ResourceId containing the encoded typeId and name.

ResourceId

Git Source (opens in a new tab)

A ResourceId is a bytes32 data structure that consists of a type and a name

type ResourceId is bytes32;

SchemaInstance

Git Source (opens in a new tab)

Instance utility functions for handling a Schema instance.

Functions

staticDataLength

Get the length of static data for the given schema.

function staticDataLength(Schema schema) internal pure returns (uint256);

Parameters

NameTypeDescription
schemaSchemaThe schema to inspect.

Returns

NameTypeDescription
<none>uint256The static data length.

atIndex

Get the SchemaType at a given index in the schema.

function atIndex(Schema schema, uint256 index) internal pure returns (SchemaType);

Parameters

NameTypeDescription
schemaSchemaThe schema to inspect.
indexuint256The index of the SchemaType to retrieve.

Returns

NameTypeDescription
<none>SchemaTypeThe SchemaType at the given index.

numStaticFields

Get the number of static (fixed length) fields in the schema.

function numStaticFields(Schema schema) internal pure returns (uint256);

Parameters

NameTypeDescription
schemaSchemaThe schema to inspect.

Returns

NameTypeDescription
<none>uint256The number of static fields.

numDynamicFields

Get the number of dynamic length fields in the schema.

function numDynamicFields(Schema schema) internal pure returns (uint256);

Parameters

NameTypeDescription
schemaSchemaThe schema to inspect.

Returns

NameTypeDescription
<none>uint256The number of dynamic length fields.

numFields

Get the total number of fields in the schema.

function numFields(Schema schema) internal pure returns (uint256);

Parameters

NameTypeDescription
schemaSchemaThe schema to inspect.

Returns

NameTypeDescription
<none>uint256The total number of fields.

isEmpty

Checks if the provided schema is empty.

function isEmpty(Schema schema) internal pure returns (bool);

Parameters

NameTypeDescription
schemaSchemaThe schema to check.

Returns

NameTypeDescription
<none>booltrue if the schema is empty, false otherwise.

validate

Validates the given schema.

function validate(Schema schema, bool allowEmpty) internal pure;

Parameters

NameTypeDescription
schemaSchemaThe schema to validate.
allowEmptyboolDetermines if an empty schema is valid or not.

unwrap

Unwraps the schema to its underlying bytes32 representation.

function unwrap(Schema schema) internal pure returns (bytes32);

Parameters

NameTypeDescription
schemaSchemaThe schema to unwrap.

Returns

NameTypeDescription
<none>bytes32The bytes32 representation of the schema.

SchemaLib

Git Source (opens in a new tab)

Static utility functions for handling Schemas.

Functions

encode

Encodes a given schema into a single bytes32.

function encode(SchemaType[] memory schemas) internal pure returns (Schema);

Parameters

NameTypeDescription
schemasSchemaType[]The list of SchemaTypes that constitute the schema.

Returns

NameTypeDescription
<none>SchemaThe encoded Schema.

Schema

Git Source (opens in a new tab)

Defines and handles the encoding/decoding of Schemas which describe the layout of data structures. 2 bytes length of all the static (in size) fields in the schema 1 byte for number of static size fields 1 byte for number of dynamic size fields 28 bytes for 28 schema types (MAX_DYNAMIC_FIELDS allows us to pack the lengths into 1 word)

type Schema is bytes32;

SliceInstance

Git Source (opens in a new tab)

Functions

pointer

Returns the pointer to the start of a slice

function pointer(Slice self) internal pure returns (uint256);

Parameters

NameTypeDescription
selfSliceThe slice whose pointer needs to be fetched

Returns

NameTypeDescription
<none>uint256The pointer to the start of the slice

length

Returns the slice length in bytes

function length(Slice self) internal pure returns (uint256);

Parameters

NameTypeDescription
selfSliceThe slice whose length needs to be fetched

Returns

NameTypeDescription
<none>uint256The length of the slice

toBytes

Converts a Slice to bytes

This function internally manages the conversion of a slice into a bytes format.

function toBytes(Slice self) internal pure returns (bytes memory data);

Parameters

NameTypeDescription
selfSliceThe Slice to be converted to bytes.

Returns

NameTypeDescription
databytesThe bytes representation of the provided Slice.

toBytes32

Converts a Slice to bytes32

This function converts a slice into a fixed-length bytes32. Uses inline assembly for the conversion.

function toBytes32(Slice self) internal pure returns (bytes32 result);

Parameters

NameTypeDescription
selfSliceThe Slice to be converted to bytes32.

Returns

NameTypeDescription
resultbytes32The bytes32 representation of the provided Slice.

SliceLib

Git Source (opens in a new tab)

State Variables

MASK_LEN

uint256 constant MASK_LEN = uint256(type(uint128).max);

Functions

fromBytes

Converts a bytes array to a slice (without copying data)

function fromBytes(bytes memory data) internal pure returns (Slice);

Parameters

NameTypeDescription
databytesThe bytes array to be converted

Returns

NameTypeDescription
<none>SliceA new Slice representing the bytes array

getSubslice

Subslice a bytes array using the given start index until the end of the array (without copying data)

function getSubslice(bytes memory data, uint256 start) internal pure returns (Slice);

Parameters

NameTypeDescription
databytesThe bytes array to subslice
startuint256The start index for the subslice

Returns

NameTypeDescription
<none>SliceA new Slice representing the subslice

getSubslice

Subslice a bytes array using the given indexes (without copying data)

The start index is inclusive, the end index is exclusive

function getSubslice(bytes memory data, uint256 start, uint256 end) internal pure returns (Slice);

Parameters

NameTypeDescription
databytesThe bytes array to subslice
startuint256The start index for the subslice
enduint256The end index for the subslice

Returns

NameTypeDescription
<none>SliceA new Slice representing the subslice

Slice

Git Source (opens in a new tab)

type Slice is uint256;

Storage

Git Source (opens in a new tab)

Provides functions for low-level storage manipulation, including storing and retrieving bytes.

Functions

store

Store a single word of data at a specific storage pointer.

function store(uint256 storagePointer, bytes32 data) internal;

Parameters

NameTypeDescription
storagePointeruint256The location to store the data.
databytes32The 32-byte word of data to store.

store

Store bytes of data at a specific storage pointer and offset.

function store(uint256 storagePointer, uint256 offset, bytes memory data) internal;

Parameters

NameTypeDescription
storagePointeruint256The base storage location.
offsetuint256Offset within the storage location.
databytesBytes to store.

store

Stores raw bytes to storage at a given pointer, offset, and length, keeping the rest of the word intact.

function store(uint256 storagePointer, uint256 offset, uint256 length, uint256 memoryPointer) internal;

Parameters

NameTypeDescription
storagePointeruint256The base storage location.
offsetuint256Offset within the storage location.
lengthuint256Length of the data in bytes.
memoryPointeruint256Pointer to the start of the data in memory.

zero

Set multiple storage locations to zero.

function zero(uint256 storagePointer, uint256 length) internal;

Parameters

NameTypeDescription
storagePointeruint256The starting storage location.
lengthuint256The number of storage locations to set to zero, in bytes

load

Load a single word of data from a specific storage pointer.

function load(uint256 storagePointer) internal view returns (bytes32 word);

Parameters

NameTypeDescription
storagePointeruint256