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
Name | Type | Description |
---|---|---|
input | bytes | The bytes blob to modify. |
length | uint256 | The new length to set. |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes | Reference 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
Name | Type | Description |
---|---|---|
input | bytes | The bytes blob in which a specific 4-byte sequence is to be altered. |
index | uint256 | The position within the bytes blob to start altering the 4-byte sequence. Index starts from the left. |
overwrite | bytes4 | The new 4-byte value to be set at the specified index. |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a byte is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes1 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a byte is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes1 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 2-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes2 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 2-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes2 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 3-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes3 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 3-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes3 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 4-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes4 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 4-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes4 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 5-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes5 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 5-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes5 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 6-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes6 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 6-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes6 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 7-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes7 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 7-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes7 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 8-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes8 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 8-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes8 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 9-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes9 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 9-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes9 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 10-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes10 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 10-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes10 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 11-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes11 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 11-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes11 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 12-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes12 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 12-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes12 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 13-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes13 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 13-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes13 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 14-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes14 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 14-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes14 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 15-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes15 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 15-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes15 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 16-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes16 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 16-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes16 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 17-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes17 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 17-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes17 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 18-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes18 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 18-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes18 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 19-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes19 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 19-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes19 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 20-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes20 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 20-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes20 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 21-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes21 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 21-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes21 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 22-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes22 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 22-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes22 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 23-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes23 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 23-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes23 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 24-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes24 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 24-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes24 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 25-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes25 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 25-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes25 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 26-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes26 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 26-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes26 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 27-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes27 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 27-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes27 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 28-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes28 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 28-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes28 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 29-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes29 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 29-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes29 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 30-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes30 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 30-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes30 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 31-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes31 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 31-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes31 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes blob from which a 32-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes blob for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes32 | The 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
Name | Type | Description |
---|---|---|
data | bytes32 | The bytes32 value from which a 32-byte sequence is to be extracted. |
start | uint256 | The starting position within the bytes32 value for extraction. |
Returns
Name | Type | Description |
---|---|---|
output | bytes32 | The 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
Name | Type | Description |
---|---|---|
fieldLayout | FieldLayout | The FieldLayout to extract the byte length from. |
index | uint256 | The field index to get the static byte length from. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The 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
Name | Type | Description |
---|---|---|
fieldLayout | FieldLayout | The FieldLayout to extract the total static byte length from. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The total static byte length. |
numStaticFields
Get the number of static fields for the field layout.
function numStaticFields(FieldLayout fieldLayout) internal pure returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
fieldLayout | FieldLayout | The FieldLayout to extract the number of static fields from. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The 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
Name | Type | Description |
---|---|---|
fieldLayout | FieldLayout | The FieldLayout to extract the number of dynamic fields from. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The 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
Name | Type | Description |
---|---|---|
fieldLayout | FieldLayout | The FieldLayout to extract the total number of fields from. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The total number of fields. |
isEmpty
Check if the field layout is empty.
function isEmpty(FieldLayout fieldLayout) internal pure returns (bool);
Parameters
Name | Type | Description |
---|---|---|
fieldLayout | FieldLayout | The FieldLayout to check. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | True 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
Name | Type | Description |
---|---|---|
fieldLayout | FieldLayout | The FieldLayout to validate. |
unwrap
Unwrap the field layout to obtain the raw bytes32 representation.
function unwrap(FieldLayout fieldLayout) internal pure returns (bytes32);
Parameters
Name | Type | Description |
---|---|---|
fieldLayout | FieldLayout | The FieldLayout to unwrap. |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes32 | The 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
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
Name | Type | Description |
---|---|---|
_staticFieldLengths | uint256[] | An array of static field lengths. |
numDynamicFields | uint256 | The number of dynamic fields. |
Returns
Name | Type | Description |
---|---|---|
<none> | FieldLayout | A 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
Name | Type | Description |
---|---|---|
self | Hook | The Hook instance to check. |
hookTypes | uint8 | A bitmap of hook types to check. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | True 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
Name | Type | Description |
---|---|---|
self | Hook | The Hook instance to get the address from. |
Returns
Name | Type | Description |
---|---|---|
<none> | address | The 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
Name | Type | Description |
---|---|---|
self | Hook | The Hook instance to get the bitmap from. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint8 | The 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
Name | Type | Description |
---|---|---|
hookAddress | address | The address of the hook. |
encodedHooks | uint8 | The encoded hooks in a bitmap. |
Returns
Name | Type | Description |
---|---|---|
<none> | Hook | A 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
Name | Type | Description |
---|---|---|
hookTableId | ResourceId | The resource ID of the hook table. |
resourceWithHooks | ResourceId | The resource ID of the table with hooks to filter. |
hookAddressToRemove | address | The 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
Name | Type | Description |
---|---|---|
data | bytes | The dynamic bytes data from which to get the pointer. |
Returns
Name | Type | Description |
---|---|---|
memoryPointer | uint256 | The 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
Name | Type | Description |
---|---|---|
fromPointer | uint256 | The memory location to copy from. |
toPointer | uint256 | The memory location to copy to. |
length | uint256 | The 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
Name | Type | Description |
---|---|---|
resourceId | ResourceId | The ResourceId from which the type identifier should be extracted. |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes2 | The extracted 2-byte type identifier. |
getResourceName
Get the name from a resource ID.
function getResourceName(ResourceId resourceId) internal pure returns (bytes30);
Parameters
Name | Type | Description |
---|---|---|
resourceId | ResourceId | The resource ID. |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes30 | A 30-byte name. |
unwrap
Unwrap a resource ID into a bytes32.
function unwrap(ResourceId resourceId) internal pure returns (bytes32);
Parameters
Name | Type | Description |
---|---|---|
resourceId | ResourceId | The resource ID. |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes32 | The 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
Name | Type | Description |
---|---|---|
typeId | bytes2 | The type identifier to be encoded. Must be 2 bytes. |
name | bytes30 | The name to be encoded. Must be 30 bytes. |
Returns
Name | Type | Description |
---|---|---|
<none> | ResourceId | A 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
Name | Type | Description |
---|---|---|
schema | Schema | The schema to inspect. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The 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
Name | Type | Description |
---|---|---|
schema | Schema | The schema to inspect. |
index | uint256 | The index of the SchemaType to retrieve. |
Returns
Name | Type | Description |
---|---|---|
<none> | SchemaType | The 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
Name | Type | Description |
---|---|---|
schema | Schema | The schema to inspect. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The number of static fields. |
numDynamicFields
Get the number of dynamic length fields in the schema.
function numDynamicFields(Schema schema) internal pure returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
schema | Schema | The schema to inspect. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The number of dynamic length fields. |
numFields
Get the total number of fields in the schema.
function numFields(Schema schema) internal pure returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
schema | Schema | The schema to inspect. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The total number of fields. |
isEmpty
Checks if the provided schema is empty.
function isEmpty(Schema schema) internal pure returns (bool);
Parameters
Name | Type | Description |
---|---|---|
schema | Schema | The schema to check. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | true if the schema is empty, false otherwise. |
validate
Validates the given schema.
function validate(Schema schema, bool allowEmpty) internal pure;
Parameters
Name | Type | Description |
---|---|---|
schema | Schema | The schema to validate. |
allowEmpty | bool | Determines 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
Name | Type | Description |
---|---|---|
schema | Schema | The schema to unwrap. |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes32 | The 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
Name | Type | Description |
---|---|---|
schemas | SchemaType[] | The list of SchemaTypes that constitute the schema. |
Returns
Name | Type | Description |
---|---|---|
<none> | Schema | The 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
Name | Type | Description |
---|---|---|
self | Slice | The slice whose pointer needs to be fetched |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The pointer to the start of the slice |
length
Returns the slice length in bytes
function length(Slice self) internal pure returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
self | Slice | The slice whose length needs to be fetched |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The 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
Name | Type | Description |
---|---|---|
self | Slice | The Slice to be converted to bytes. |
Returns
Name | Type | Description |
---|---|---|
data | bytes | The 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
Name | Type | Description |
---|---|---|
self | Slice | The Slice to be converted to bytes32. |
Returns
Name | Type | Description |
---|---|---|
result | bytes32 | The 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes array to be converted |
Returns
Name | Type | Description |
---|---|---|
<none> | Slice | A 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes array to subslice |
start | uint256 | The start index for the subslice |
Returns
Name | Type | Description |
---|---|---|
<none> | Slice | A 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
Name | Type | Description |
---|---|---|
data | bytes | The bytes array to subslice |
start | uint256 | The start index for the subslice |
end | uint256 | The end index for the subslice |
Returns
Name | Type | Description |
---|---|---|
<none> | Slice | A 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
Name | Type | Description |
---|---|---|
storagePointer | uint256 | The location to store the data. |
data | bytes32 | The 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
Name | Type | Description |
---|---|---|
storagePointer | uint256 | The base storage location. |
offset | uint256 | Offset within the storage location. |
data | bytes | Bytes 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
Name | Type | Description |
---|---|---|
storagePointer | uint256 | The base storage location. |
offset | uint256 | Offset within the storage location. |
length | uint256 | Length of the data in bytes. |
memoryPointer | uint256 | Pointer to the start of the data in memory. |
zero
Set multiple storage locations to zero.
function zero(uint256 storagePointer, uint256 length) internal;
Parameters
Name | Type | Description |
---|---|---|
storagePointer | uint256 | The starting storage location. |
length | uint256 | The 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
Name | Type | Description |
---|---|---|
storagePointer | uint256 | The location to load the data from. |
Returns
Name | Type | Description |
---|---|---|
word | bytes32 | The loaded 32-byte word of data. |
load
Load raw bytes from storage at a given pointer, offset, and length.
function load(uint256 storagePointer, uint256 offset, uint256 length) internal view returns (bytes memory result);
Parameters
Name | Type | Description |
---|---|---|
storagePointer | uint256 | The base storage location. |
offset | uint256 | Offset within the storage location. |
length | uint256 | Length of the data in bytes. |
Returns
Name | Type | Description |
---|---|---|
result | bytes | The loaded bytes of data. |
load
Append raw bytes from storage at a given pointer, offset, and length to a specific memory pointer.
function load(uint256 storagePointer, uint256 offset, uint256 length, uint256 memoryPointer) internal view;
Parameters
Name | Type | Description |
---|---|---|
storagePointer | uint256 | The base storage location. |
offset | uint256 | Offset within the storage location. |
length | uint256 | Length of the data in bytes. |
memoryPointer | uint256 | Pointer to the location in memory to append the data. |
loadField
Load up to 32 bytes from storage at a given pointer and offset.
Since fields are tightly packed, they can span more than one slot. Since they're max 32 bytes, they can span at most 2 slots.
function loadField(uint256 storagePointer, uint256 length, uint256 offset) internal view returns (bytes32 result);
Parameters
Name | Type | Description |
---|---|---|
storagePointer | uint256 | The base storage location. |
length | uint256 | Length of the data in bytes. |
offset | uint256 | Offset within the storage location. |
Returns
Name | Type | Description |
---|---|---|
result | bytes32 | The loaded bytes, left-aligned bytes. Bytes beyond the length are not zeroed. |
constants.sol
Git Source (opens in a new tab)
WORD_SIZE
This file provides constants for better handling of EVM and Schema related functionalities.
Represents the total byte length of an EVM word.
uint256 constant WORD_SIZE = 32;
WORD_LAST_INDEX
Represents the index of the last byte in an EVM word.
uint256 constant WORD_LAST_INDEX = 31;
BYTE_TO_BITS
Represents the conversion constant from byte to bits.
uint256 constant BYTE_TO_BITS = 8;
MAX_TOTAL_FIELDS
Represents the maximum number of fields a Schema can handle.
uint256 constant MAX_TOTAL_FIELDS = 28;
MAX_STATIC_FIELDS
Represents the maximum number of static fields in a FieldLayout.
uint256 constant MAX_STATIC_FIELDS = 28;
MAX_DYNAMIC_FIELDS
Represents the maximum number of dynamic fields that can be packed in EncodedLengths.
uint256 constant MAX_DYNAMIC_FIELDS = 5;
LayoutOffsets
Git Source (opens in a new tab)
This library provides constant offsets for FieldLayout and Schema metadata.
FieldLayout and Schema utilize the same offset values for metadata.
State Variables
TOTAL_LENGTH
Represents the total length offset within the EVM word.
uint256 internal constant TOTAL_LENGTH = (WORD_SIZE - 2) * BYTE_TO_BITS;
NUM_STATIC_FIELDS
Represents the number of static fields offset within the EVM word.
uint256 internal constant NUM_STATIC_FIELDS = (WORD_SIZE - 2 - 1) * BYTE_TO_BITS;
NUM_DYNAMIC_FIELDS
Represents the number of dynamic fields offset within the EVM word.
uint256 internal constant NUM_DYNAMIC_FIELDS = (WORD_SIZE - 2 - 1 - 1) * BYTE_TO_BITS;
rightMask
Git Source (opens in a new tab)
Utility functions to manage bytes in memory.
Computes a right-aligned byte mask based on the provided byte length.
Adapted from https://github.com/dk1a/solidity-stringutils/blob/main/src/utils/mem.sol#L149-L167 (opens in a new tab)
The mask is used to extract a specified number of rightmost bytes.
function rightMask(uint256 byteLength) pure returns (uint256 mask);
Parameters
Name | Type | Description |
---|---|---|
byteLength | uint256 | The number of rightmost bytes to be masked. |
Returns
Name | Type | Description |
---|---|---|
mask | uint256 | A right-aligned byte mask corresponding to the specified byte length. |
storeHookTypes.sol constants
Git Source (opens in a new tab)
BEFORE_SET_RECORD
Constants for enabling store hooks.
These bitmaps can be used to enable selected store hooks. They can be combined with a bitwise OR (|
).
Flag to enable the onBeforeSetRecord
hook.
uint8 constant BEFORE_SET_RECORD = 1 << 0;
AFTER_SET_RECORD
Flag to enable the afterSetRecord
hook.
uint8 constant AFTER_SET_RECORD = 1 << 1;
BEFORE_SPLICE_STATIC_DATA
Flag to enable the beforeSpliceStaticData
hook.
uint8 constant BEFORE_SPLICE_STATIC_DATA = 1 << 2;
AFTER_SPLICE_STATIC_DATA
Flag to enable the afterSpliceStaticData
hook.
uint8 constant AFTER_SPLICE_STATIC_DATA = 1 << 3;
BEFORE_SPLICE_DYNAMIC_DATA
Flag to enable the beforeSpliceDynamicData
hook.
uint8 constant BEFORE_SPLICE_DYNAMIC_DATA = 1 << 4;
AFTER_SPLICE_DYNAMIC_DATA
Flag to enable the afterSpliceDynamicData
hook.
uint8 constant AFTER_SPLICE_DYNAMIC_DATA = 1 << 5;
BEFORE_DELETE_RECORD
Flag to enable the beforeDeleteRecord
hook.
uint8 constant BEFORE_DELETE_RECORD = 1 << 6;
AFTER_DELETE_RECORD
Flag to enable the afterDeleteRecord
hook.
uint8 constant AFTER_DELETE_RECORD = 1 << 7;
ALL
Bitmap to enable all hooks.
uint8 constant ALL = BEFORE_SET_RECORD |
AFTER_SET_RECORD |
BEFORE_SPLICE_STATIC_DATA |
AFTER_SPLICE_STATIC_DATA |
BEFORE_SPLICE_DYNAMIC_DATA |
AFTER_SPLICE_DYNAMIC_DATA |
BEFORE_DELETE_RECORD |
AFTER_DELETE_RECORD;
BEFORE_ALL
Bitmap to enable all "before" hooks.
uint8 constant BEFORE_ALL = BEFORE_SET_RECORD |
BEFORE_SPLICE_STATIC_DATA |
BEFORE_SPLICE_DYNAMIC_DATA |
BEFORE_DELETE_RECORD;
AFTER_ALL
Bitmap to enable all "after" hooks.
uint8 constant AFTER_ALL = AFTER_SET_RECORD |
AFTER_SPLICE_STATIC_DATA |
AFTER_SPLICE_DYNAMIC_DATA |
AFTER_DELETE_RECORD;
storeResourceTypes.sol constants
Git Source (opens in a new tab)
RESOURCE_TABLE
Constants representing unique identifiers for different resource types.
These identifiers can be used to distinguish between various resource types.
Identifier for a resource table.
bytes2 constant RESOURCE_TABLE = "tb";
RESOURCE_OFFCHAIN_TABLE
Identifier for an offchain resource table.
bytes2 constant RESOURCE_OFFCHAIN_TABLE = "ot";
version.sol constants
Git Source (opens in a new tab)
STORE_VERSION
Contains a constant representing the version of the Store protocol.
Identifier for the current Store protocol version.
bytes32 constant STORE_VERSION = "2.0.2";