Skip to main content

AddressLib

Library for working with addresses encoded as uint256 values, which can include flags in the highest bits. type Address is uint256;

Functions

get

function get(
Address a
) internal pure returns (address)

Returns the address representation of a uint256

Parameters:

NameTypeDescription
aAddressThe uint256 value to convert to an address

Return values

TypeDescription
addressThe address representation of the provided uint256 value

getFlag

function getFlag(
Address a,
uint256 flag
) internal pure returns (bool)

Checks if a given flag is set for the provided address

Parameters:

NameTypeDescription
aAddressThe address to check for the flag
flaguint256The flag to check for in the provided address

Return values

TypeDescription
boolTrue if the provided flag is set in the address, false otherwise

getUint32

function getUint32(
Address a,
uint256 offset
) internal pure returns (uint32)

Returns a uint32 value stored at a specific bit offset in the provided address

Parameters:

NameTypeDescription
aAddressThe address containing the uint32 value
offsetuint256The bit offset at which the uint32 value is stored

Return values

TypeDescription
uint32The uint32 value stored in the address at the specified bit offset

getUint64

function getUint64(
Address a,
uint256 offset
) internal pure returns (uint64)

Returns a uint64 value stored at a specific bit offset in the provided address

Parameters:

NameTypeDescription
aAddressThe address containing the uint64 value
offsetuint256The bit offset at which the uint64 value is stored

Return values

TypeDescription
uint64The uint64 value stored in the address at the specified bit offset