### Install Solady Library Source: https://github.com/vectorized/solady/blob/main/docs/overview.md Instructions for installing the Solady library using either Foundry's forge command or npm for Hardhat/Truffle projects. ```sh forge install vectorized/solady ``` ```sh npm install solady ``` -------------------------------- ### Install Solady with Foundry Source: https://github.com/vectorized/solady/blob/main/README.md This command installs the Solady library into your project using Foundry, a popular Solidity development framework. It clones the repository into your project's `lib` directory. ```sh forge install vectorized/solady ``` -------------------------------- ### Install Solady with Hardhat Source: https://github.com/vectorized/solady/blob/main/README.md This command installs the Solady library as an npm package, making it available for use in Hardhat projects. Hardhat is a widely used Ethereum development environment. ```sh npm install solady ``` -------------------------------- ### Solidity Error: SaltDoesNotStartWith() Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Defines an error indicating that the provided salt for a deterministic clone operation does not start with the required zero address or 'by' prefix. ```solidity error SaltDoesNotStartWith() ``` -------------------------------- ### Read Immutable Arguments from Clone (Solidity) Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md These functions allow reading immutable arguments from a deployed clone instance. The `argsOnClone(address)` variant reads all arguments. `argsOnClone(address, uint256 start)` reads from a specified `start` index to the end. `argsOnClone(address, uint256 start, uint256 end)` reads a slice between `start` and `end` indices. The `instance` must have been deployed via clone with immutable args functions; otherwise, behavior is undefined. Out-of-gas reverts if the instance has no code. ```Solidity function argsOnClone(address instance) internal view returns (bytes memory args) ``` ```Solidity function argsOnClone(address instance, uint256 start) internal view returns (bytes memory args) ``` ```Solidity function argsOnClone(address instance, uint256 start, uint256 end) internal view returns (bytes memory args) ``` -------------------------------- ### Get Immutable Arguments from ERC1967 Beacon Proxy with Start Index Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Returns a slice of the immutable arguments on the specified proxy instance, starting from a given index. The 'start' index will be clamped to the valid range of the arguments' length. The instance MUST have been deployed via ERC1967 beacon proxy functions that support immutable arguments; otherwise, behavior is undefined. An out-of-gas error may occur if the instance has no code. ```solidity function argsOnERC1967BeaconProxy(address instance, uint256 start) internal view returns (bytes memory args) ``` -------------------------------- ### JavaScript Initial Theme Setup and Reload Source: https://github.com/vectorized/solady/blob/main/docs/index.html This snippet checks for the availability of the `fetch` API and, if present, calls `setupTheme()` to initialize the application's theme. It then immediately calls `reloadTheme()` to apply the theme settings, ensuring the UI is styled correctly upon page load. ```JavaScript if (window.fetch) setupTheme(); reloadTheme(); ``` -------------------------------- ### APIDOC: Set a batch of bits in Bitmap Source: https://github.com/vectorized/solady/blob/main/docs/utils/libbitmap.md Consecutively sets `amount` of bits starting from the bit at `start`. ```APIDOC function setBatch(Bitmap storage bitmap, uint256 start, uint256 amount) internal ``` -------------------------------- ### Example: Perform Keccak256 Hashing with Malloc Buffer in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/efficienthashlib.md This example demonstrates how to use `EfficientHashLib`'s `malloc`, `set`, and `hash` functions to perform `keccak256` hashing on multiple values. This approach helps avoid 'stack-too-deep' errors by utilizing an allocated buffer for inputs before hashing. ```Solidity bytes32[] memory buffer = EfficientHashLib.malloc(10); EfficientHashLib.set(buffer, 0, value0); .. EfficientHashLib.set(buffer, 9, value9); bytes32 finalHash = EfficientHashLib.hash(buffer); ``` -------------------------------- ### ERC1967Factory Custom Error: SaltDoesNotStartWithCaller Source: https://github.com/vectorized/solady/blob/main/docs/utils/erc1967factory.md Indicates that the provided salt does not start with the caller's address. ```Solidity error SaltDoesNotStartWithCaller() ``` -------------------------------- ### Get Clone Initialization Code (Solidity) Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Returns the full initialization code (bytecode) that would be used to deploy a clone of a given `implementation` contract, incorporating the specified immutable `args`. ```Solidity function initCode(address implementation, bytes memory args) internal pure returns (bytes memory c) ``` -------------------------------- ### Slice Bytes (From Start to End) in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/libbytes.md Returns a copy of the `subject` bytes, sliced from the `start` byte offset to the end of the bytes. This function is internal and pure, providing a convenient way to get a suffix of a byte sequence. ```Solidity function slice(bytes memory subject, uint256 start) internal pure returns (bytes memory result) ``` -------------------------------- ### Initialize new empty DynamicBuffer in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/dynamicbufferlib.md Shorthand function to create and return a new, empty `DynamicBuffer` instance. This function is internal and pure, providing a convenient starting point for buffer operations. ```solidity function p() internal pure returns (DynamicBuffer memory result) ``` -------------------------------- ### Get Slice of Immutable Arguments from ERC1967 Beacon Proxy Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Returns a slice of the immutable arguments on the specified proxy instance, from a given start index to an end index. Both 'start' and 'end' indices will be clamped to the valid range of the arguments' length. The instance MUST have been deployed via ERC1967 beacon proxy functions that support immutable arguments; otherwise, behavior is undefined. An out-of-gas error may occur if the instance has no code. ```solidity function argsOnERC1967BeaconProxy( address instance, uint256 start, uint256 end ) internal view returns (bytes memory args) ``` -------------------------------- ### Get Clone Initialization Code Hash (Solidity) Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Calculates and returns the Keccak-256 hash of the initialization code for a clone of an `implementation` contract, based on the provided immutable `args`. ```Solidity function initCodeHash(address implementation, bytes memory args) internal pure returns (bytes32 hash) ``` -------------------------------- ### Encoding Initialization Parameters for UpgradeableBeacon Deployment Source: https://github.com/vectorized/solady/blob/main/docs/utils/upgradeablebeacon.md Illustrates how to combine the optimized creation bytecode with initial owner and implementation addresses using `abi.encodePacked` for deploying the UpgradeableBeacon. ```Solidity abi.encodePacked(creationCode, abi.encode(initialOwner, initialImplementation)) ``` -------------------------------- ### Check if String Starts With Substring in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/libstring.md Returns whether `subject` starts with `needle`. ```Solidity function startsWith(string memory subject, string memory needle) internal pure returns (bool) ``` -------------------------------- ### Solidity Initializer: initialize(address) Source: https://github.com/vectorized/solady/blob/main/docs/accounts/erc4337.md Initializes the account with a new owner. This function can only be called once to set up the account's ownership. ```Solidity function initialize(address newOwner) public payable virtual ``` -------------------------------- ### API: Deploy Deterministic Contract with Value, Init Code, and Salt Source: https://github.com/vectorized/solady/blob/main/docs/utils/create3.md Deploys a contract deterministically with a specified `value` (in wei) ETH, using provided initialization code and a salt. The deployed contract is funded with this value, and its address is solely dependent on the salt. ```APIDOC function deployDeterministic(uint256 value, bytes memory initCode, bytes32 salt) internal returns (address deployed) Parameters: value: uint256 - The amount of ETH (in wei) to fund the deployed contract. initCode: bytes memory - The initialization code for the contract. salt: bytes32 - A unique salt to ensure deterministic deployment. Returns: deployed: address - The deterministic address of the deployed contract. ``` -------------------------------- ### APIDOC: Unset a batch of bits in Bitmap Source: https://github.com/vectorized/solady/blob/main/docs/utils/libbitmap.md Consecutively unsets `amount` of bits starting from the bit at `start`. ```APIDOC function unsetBatch(Bitmap storage bitmap, uint256 start, uint256 amount) internal ``` -------------------------------- ### Configure Docsify for Solady Documentation Source: https://github.com/vectorized/solady/blob/main/docs/index.html This JavaScript snippet configures the Docsify documentation site, setting up the repository link, cover page, homepage, sidebar loading, auto-scrolling, search functionality, and themeable options. ```JavaScript window.$docsify = { name: logo, repo: 'https://github.com/vectorized/Solady', coverpage: false, homepage: 'overview.md', loadSidebar: 'sidebar.md', auto2top: true, maxLevel: 3, subMaxLevel: 3, search: { depth: 3, noData: 'No results!', placeholder: 'Search...' }, themeable: { readyTransition : false, responsiveTables: true } } ``` -------------------------------- ### API: Deploy Deterministic Contract with Init Code and Salt Source: https://github.com/vectorized/solady/blob/main/docs/utils/create3.md Deploys a contract deterministically using provided initialization code and a salt. The deployed contract's address is solely dependent on the salt, ensuring predictability. ```APIDOC function deployDeterministic(bytes memory initCode, bytes32 salt) internal returns (address deployed) Parameters: initCode: bytes memory - The initialization code for the contract. salt: bytes32 - A unique salt to ensure deterministic deployment. Returns: deployed: address - The deterministic address of the deployed contract. ``` -------------------------------- ### Get Length of DynamicArray in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/dynamicarraylib.md This function provides a shorthand to get the length of a `DynamicArray` instance, equivalent to accessing `a.data.length`. ```Solidity function length(DynamicArray memory a) internal pure returns (uint256) ``` -------------------------------- ### Get Minimal Proxy Initialization Code (Standard) Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Returns the raw initialization bytecode that would be used to deploy a minimal proxy clone of the given `implementation` address. This code is used internally for contract creation. ```solidity function initCode(address implementation) internal pure returns (bytes memory c) ``` -------------------------------- ### Solidity Function: Initialize RLP List (`p` overloaded) Source: https://github.com/vectorized/solady/blob/main/docs/utils/librlp.md Initializes and returns a new RLP list. This function is overloaded to support creating an empty list or a list containing a single element of various types: `uint256`, `address`, `bool`, `bytes`, or another `List`. ```solidity function p() internal pure returns (List memory result) ``` ```solidity function p(uint256 x) internal pure returns (List memory result) ``` ```solidity function p(address x) internal pure returns (List memory result) ``` ```solidity function p(bool x) internal pure returns (List memory result) ``` ```solidity function p(bytes memory x) internal pure returns (List memory result) ``` ```solidity function p(List memory x) internal pure returns (List memory result) ``` -------------------------------- ### Public Function: setTimedRole Source: https://github.com/vectorized/solady/blob/main/docs/auth/timedroles.md Sets the active time range of `timedRole` of `holder` to [`start`, `expires`]. The `timedRole` is active when `start <= block.timestamp && block.timestamp <= expires`. ```solidity function setTimedRole( address holder, uint256 timedRole, uint40 start, uint40 expires ) public payable virtual ``` -------------------------------- ### APIDOC: Count set bits in Bitmap range Source: https://github.com/vectorized/solady/blob/main/docs/utils/libbitmap.md Returns number of set bits within a range by scanning `amount` of bits starting from the bit at `start`. ```APIDOC function popCount(Bitmap storage bitmap, uint256 start, uint256 amount) internal view returns (uint256 count) ``` -------------------------------- ### ERC1967Factory Internal Deploy Function: _deploy Source: https://github.com/vectorized/solady/blob/main/docs/utils/erc1967factory.md Internal function to deploy the proxy, with optionality to deploy deterministically using a `salt`. Parameters: - `implementation` (address): The address of the implementation contract. - `admin` (address): The admin address for the new proxy. - `salt` (bytes32): A unique salt for deterministic address generation. - `useSalt` (bool): A flag indicating whether to use the salt for deterministic deployment. - `data` (bytes calldata): ABI-encoded data to call the proxy with after deployment. Returns: - `proxy` (address): The address of the newly deployed proxy. ```Solidity function _deploy( address implementation, address admin, bytes32 salt, bool useSalt, bytes ``` -------------------------------- ### Deploy Deterministic ERC1967 Beacon Proxy with ETH and Args Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Deploys a deterministic minimal ERC1967 beacon proxy with specified arguments and a salt. This function also deposits a given amount of ETH during the deployment process. ```solidity function deployDeterministicERC1967BeaconProxy( uint256 value, address beacon, bytes memory args, bytes32 salt ) internal returns (address instance) ``` -------------------------------- ### Get Unit Exponential Sample (WAD) Source: https://github.com/vectorized/solady/blob/main/docs/utils/libprng.md Returns a sample from the unit exponential distribution, denominated in `WAD` (1e18). ```APIDOC function exponentialWad(PRNG memory prng) internal pure returns (uint256 result) prng: The PRNG struct to draw from. result: A uint256 sample from the unit exponential distribution, scaled by WAD. ``` -------------------------------- ### Check if Bytes Starts With Subsequence Source: https://github.com/vectorized/solady/blob/main/docs/utils/libbytes.md Verifies if a `subject` byte array begins with a specific `needle` byte sequence. This function returns `true` if the `subject` starts with the `needle`, and `false` otherwise, useful for prefix matching. ```Solidity function startsWith(bytes memory subject, bytes memory needle) internal pure returns (bool result) ``` -------------------------------- ### Deploy Minimal Proxy Clone with Immutable Args and ETH Value Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Deploys a minimal proxy clone of the `implementation` address, passing `args` as immutable arguments and depositing `value` Ether during deployment. Returns the address of the new instance. ```solidity function clone(uint256 value, address implementation, bytes memory args) internal returns (address instance) ``` -------------------------------- ### UUPSUpgradeable API Reference Source: https://github.com/vectorized/solady/blob/main/docs/utils/uupsupgradeable.md Comprehensive API documentation for the `UUPSUpgradeable` mixin, detailing its custom errors, events, storage variables, and core upgrade operations. ```APIDOC UUPSUpgradeable: Description: UUPS proxy mixin. Notes: - This implementation is intended to be used with ERC1967 proxies. See: `LibClone.deployERC1967` and related functions. - This implementation is NOT compatible with legacy OpenZeppelin proxies which do not store the implementation at `_ERC1967_IMPLEMENTATION_SLOT`. Inherits: - utils/CallContextChecker.sol Custom Errors: UpgradeFailed(): Description: The upgrade failed. Signature: error UpgradeFailed() Events: Upgraded(address indexed implementation): Description: Emitted when the proxy's implementation is upgraded. Parameters: implementation: The address of the new implementation. Signature: event Upgraded(address indexed implementation) Storage: _ERC1967_IMPLEMENTATION_SLOT: Description: The ERC-1967 storage slot for the implementation in the proxy. `uint256(keccak256("eip1967.proxy.implementation")) - 1`. Type: bytes32 internal constant Value: 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc Signature: bytes32 internal constant _ERC1967_IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc UUPS Operations: upgradeToAndCall(address newImplementation, bytes calldata data): Description: Upgrades the proxy's implementation to `newImplementation`. Emits a `Upgraded` event. Note: Passing in empty `data` skips the delegatecall to `newImplementation`. Parameters: newImplementation: The address of the new implementation contract. data: Calldata to be delegatecalled on the new implementation. Visibility: public payable virtual onlyProxy Signature: function upgradeToAndCall(address newImplementation, bytes calldata data) public payable virtual onlyProxy ``` -------------------------------- ### Slice Array in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/dynamicarraylib.md These functions return a copy of a `uint256` array, either by slicing from a `start` index to an `end` index (exclusive) or from a `start` index to the end of the array. They are pure functions, meaning they do not modify the state. ```Solidity function slice(uint256[] memory a, uint256 start, uint256 end) internal pure returns (uint256[] memory result) ``` ```Solidity function slice(uint256[] memory a, uint256 start) internal pure returns (uint256[] memory result) ``` -------------------------------- ### Get Initialization Code for Minimal ERC1967 Beacon Proxy in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Returns the initialization code of the minimal ERC1967 beacon proxy. ```Solidity function initCodeERC1967BeaconProxy(address beacon) internal pure returns (bytes memory c) ``` -------------------------------- ### Slice Bytes (Start and End) in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/libbytes.md Returns a copy of the `subject` bytes, sliced from the `start` byte offset up to the `end` byte offset (exclusive). This function is internal and pure, useful for extracting sub-sequences from memory bytes. ```Solidity function slice(bytes memory subject, uint256 start, uint256 end) internal pure returns (bytes memory result) ``` -------------------------------- ### Deploy Deterministic Minimal Proxy Clone with Immutable Args Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Deploys a deterministic minimal proxy clone of the `implementation` address with `salt` and `args` as immutable arguments. The deployed address is predictable based on these inputs. ```solidity function cloneDeterministic( address implementation, bytes memory args, bytes32 salt ) internal returns (address instance) ``` -------------------------------- ### Get ERC1967 Proxy Initialization Code with Immutable Args Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Returns the raw initialization bytecode for a minimal ERC1967 proxy, given its `implementation` address and `args` (immutable arguments). ```solidity function initCodeERC1967(address implementation, bytes memory args) internal pure returns (bytes memory c) ``` -------------------------------- ### Get ERC1967 Proxy Initialization Code Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Returns the raw initialization bytecode for a minimal ERC1967 proxy, given its `implementation` address. ```solidity function initCodeERC1967(address implementation) internal pure returns (bytes memory c) ``` -------------------------------- ### ERC1967Factory Deploy Function: deployDeterministicAndCall Source: https://github.com/vectorized/solady/blob/main/docs/utils/erc1967factory.md Deploys a new proxy contract for a given `implementation` with a specified `admin` and a `salt` for deterministic address generation, and then calls the proxy with ABI-encoded `data`. Any value passed into this function will be forwarded to the proxy. Parameters: - `implementation` (address): The address of the implementation contract. - `admin` (address): The admin address for the new proxy. - `salt` (bytes32): A unique salt for deterministic address generation. - `data` (bytes calldata): ABI-encoded data to call the proxy with after deployment. Returns: - `proxy` (address): The deterministic address of the newly deployed proxy. ```Solidity function deployDeterministicAndCall( address implementation, address admin, bytes32 salt, bytes calldata data ) public payable returns (address proxy) ``` -------------------------------- ### Slice Calldata (Start and End) in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/libbytes.md Returns a copy of the `subject` calldata, sliced from the `start` byte offset up to the `end` byte offset (exclusive). This function is faster than Solidity's native slicing and is internal and pure, optimizing calldata processing. ```Solidity function sliceCalldata(bytes calldata subject, uint256 start, uint256 end) internal pure returns (bytes calldata result) ``` -------------------------------- ### Slice Calldata (From Start to End) in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/libbytes.md Returns a copy of the `subject` calldata, sliced from the `start` byte offset to the end of the bytes. This function is faster than Solidity's native slicing and is internal and pure, offering an optimized way to handle calldata suffixes. ```Solidity function sliceCalldata(bytes calldata subject, uint256 start) internal pure returns (bytes calldata result) ``` -------------------------------- ### Deploy ERC1967I Proxy with Immutable Args and ETH Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Deploys a minimal ERC1967I proxy with a specified `implementation`, `args` (immutable arguments), and an initial `value` of ETH. This combines the benefits of immutable arguments with the ability to fund the proxy upon creation. The function returns the address of the newly deployed proxy instance. ```solidity function deployERC1967I( uint256 value, address implementation, bytes memory args ) internal returns (address instance) ``` -------------------------------- ### ERC1967Factory Deploy Function: deployDeterministic Source: https://github.com/vectorized/solady/blob/main/docs/utils/erc1967factory.md Deploys a new proxy contract for a given `implementation` with a specified `admin` and a `salt` for deterministic address generation. Any value passed into this function will be forwarded to the proxy. Parameters: - `implementation` (address): The address of the implementation contract. - `admin` (address): The admin address for the new proxy. - `salt` (bytes32): A unique salt for deterministic address generation. Returns: - `proxy` (address): The deterministic address of the newly deployed proxy. ```Solidity function deployDeterministic( address implementation, address admin, bytes32 salt ) public payable returns (address proxy) ``` -------------------------------- ### Custom Error: InvalidTimedRoleRange Source: https://github.com/vectorized/solady/blob/main/docs/auth/timedroles.md The `expires` cannot be less than the `start`. ```solidity error InvalidTimedRoleRange() ``` -------------------------------- ### ERC1967Factory Deploy Function: deployAndCall Source: https://github.com/vectorized/solady/blob/main/docs/utils/erc1967factory.md Deploys a new proxy contract for a given `implementation` with a specified `admin`, and then calls the proxy with ABI-encoded `data`. Any value passed into this function will be forwarded to the proxy. Parameters: - `implementation` (address): The address of the implementation contract. - `admin` (address): The admin address for the new proxy. - `data` (bytes calldata): ABI-encoded data to call the proxy with after deployment. Returns: - `proxy` (address): The address of the newly deployed proxy. ```Solidity function deployAndCall( address implementation, address admin, bytes calldata data ) public payable returns (address proxy) ``` -------------------------------- ### Get ERC1967I Proxy Initialization Code Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Returns the full initialization bytecode for an ERC1967I proxy, constructed from the specified `implementation` address and `args` (immutable arguments). This code can be used for deploying the proxy. ```Solidity function initCodeERC1967I(address implementation, bytes memory args) internal pure returns (bytes memory c) ``` -------------------------------- ### deployDeterministicERC1967IBeaconProxy(address,bytes,bytes32) Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Deploys a deterministic ERC1967I beacon proxy with `args` and `salt`. ```Solidity function deployDeterministicERC1967IBeaconProxy( address beacon, bytes memory args, bytes32 salt ) internal returns (address instance) ``` -------------------------------- ### Get Item Type in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/jsonparserlib.md Returns the item's type as a `uint8`. ```Solidity function getType(Item memory item) internal pure returns (uint8 result) ``` -------------------------------- ### Deploy Deterministic Minimal Proxy Clone (Standard) Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Deploys a deterministic minimal proxy clone of the `implementation` address using a provided `salt`. Deterministic deployment ensures the contract address is predictable based on the `implementation` and `salt`. ```solidity function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) ``` -------------------------------- ### Get Length of Uint256ToBytes32Map in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/enumerablemaplib.md Returns the number of key-value pairs in the map. ```Solidity function length(Uint256ToBytes32Map storage map) internal view returns (uint256) ``` -------------------------------- ### Get Length of Bytes32ToAddressMap in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/enumerablemaplib.md Returns the number of key-value pairs in the map. ```Solidity function length(Bytes32ToAddressMap storage map) internal view returns (uint256) ``` -------------------------------- ### Deploy Minimal Proxy Clone (Standard) Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Deploys a minimal proxy clone of the specified `implementation` address. This function creates a new contract instance that delegates calls to the `implementation`. ```solidity function clone(address implementation) internal returns (address instance) ``` -------------------------------- ### Get ERC1967 Beacon Proxy Initialization Code Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Returns the full initialization code required for deploying a minimal ERC1967 beacon proxy with the specified beacon and arguments. ```solidity function initCodeERC1967BeaconProxy(address beacon, bytes memory args) internal pure returns (bytes memory c) ``` -------------------------------- ### Get Minimal Proxy Initialization Code (PUSH0 Variant) Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Returns the raw initialization bytecode for a minimal proxy clone of the given `implementation` address, specifically for the PUSH0 opcode variant. ```solidity function initCode_PUSH0(address implementation) internal pure returns (bytes memory c) ``` -------------------------------- ### Get Length of Bytes32ToUint256Map in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/enumerablemaplib.md Returns the number of key-value pairs in the map. ```Solidity function length(Bytes32ToUint256Map storage map) internal view returns (uint256) ``` -------------------------------- ### Deploy Deterministic Minimal Proxy Clone with ETH Value (Standard) Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Deploys a deterministic minimal proxy clone of the `implementation` address with a specified `salt`, depositing a `value` of Ether during deployment. The address of the deployed instance is predictable. ```solidity function cloneDeterministic( uint256 value, address implementation, bytes32 salt ) internal returns (address instance) ``` -------------------------------- ### UpgradeableBeacon Core Operations Reference Source: https://github.com/vectorized/solady/blob/main/docs/utils/upgradeablebeacon.md Comprehensive documentation for the public and internal functions that manage the UpgradeableBeacon's implementation and ownership, including initialization, direct setting of addresses, and owner-restricted upgrade/transfer functionalities. ```APIDOC function _initializeUpgradeableBeacon(address initialOwner, address initialImplementation) internal virtual Parameters: initialOwner: The address of the initial owner. initialImplementation: The address of the initial implementation. Description: Required to be called in the constructor or initializer. This function does not guard against double-initialization. function _setImplementation(address newImplementation) internal virtual Parameters: newImplementation: The address of the new implementation. Description: Sets the implementation directly without authorization guard. function _setOwner(address newOwner) internal virtual Parameters: newOwner: The address of the new owner. Description: Sets the owner directly without authorization guard. function implementation() public view returns (address result) Returns: result: The address of the current implementation stored in the beacon. Description: Returns the implementation stored in the beacon. See: https://eips.ethereum.org/EIPS/eip-1967#beacon-contract-address function owner() public view returns (address result) Returns: result: The address of the current owner of the beacon. Description: Returns the owner of the beacon. function upgradeTo(address newImplementation) public virtual onlyOwner Parameters: newImplementation: The address of the new implementation to upgrade to. Description: Allows the owner to upgrade the implementation. function transferOwnership(address newOwner) public virtual onlyOwner Parameters: newOwner: The address of the new owner. Description: Allows the owner to transfer the ownership to newOwner. function renounceOwnership() public virtual onlyOwner Description: Allows the owner to renounce their ownership. ``` -------------------------------- ### Get Roles of User (Public) Source: https://github.com/vectorized/solady/blob/main/docs/auth/ownableroles.md Returns the `roles` bitmap of a specified `user`. ```Solidity function rolesOf(address user) public view virtual returns (uint256 roles) ``` -------------------------------- ### Deploy Deterministic Minimal ERC1967 Beacon Proxy in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Deploys a deterministic minimal ERC1967 beacon proxy using a specified salt. One variant allows depositing ETH during deployment. ```Solidity function deployDeterministicERC1967BeaconProxy(address beacon, bytes32 salt) internal returns (address instance) ``` ```Solidity function deployDeterministicERC1967BeaconProxy( uint256 value, address beacon, bytes32 salt ) internal returns (address instance) ``` -------------------------------- ### Get Number of Items in Heap Source: https://github.com/vectorized/solady/blob/main/docs/utils/minheaplib.md Returns the current number of items stored in the heap. ```Solidity function length(Heap storage heap) internal view returns (uint256) ``` ```Solidity function length(MemHeap memory heap) internal pure returns (uint256) ``` -------------------------------- ### Get Minimal Proxy Initialization Code Hash (Standard) Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Calculates and returns the keccak256 hash of the initialization bytecode for a minimal proxy clone of the specified `implementation` address. This hash can be used for pre-computation or verification. ```solidity function initCodeHash(address implementation) internal pure returns (bytes32 hash) ``` -------------------------------- ### Push and Pop Minimum from Min-Heap Source: https://github.com/vectorized/solady/blob/main/docs/utils/minheaplib.md Inserts a `value` into the min-heap and then removes and returns the new minimum value. This is more efficient than separate push and pop operations. ```Solidity function pushPop(Heap storage heap, uint256 value) internal returns (uint256 popped) ``` ```Solidity function pushPop(MemHeap memory heap, uint256 value) internal pure returns (uint256 popped) ``` -------------------------------- ### Get Most Recent Monday Timestamp in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/datetimelib.md Returns the unix timestamp of the most recent Monday. ```Solidity function mondayTimestamp(uint256 timestamp) internal pure returns (uint256 result) ``` -------------------------------- ### Deploy ERC1967I Proxy with ETH Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Deploys a new ERC1967I proxy contract with the specified `implementation` address, depositing a given `value` of ETH during deployment. This allows the proxy to be initialized with a balance. The returned address is the instance of the newly deployed proxy. ```solidity function deployERC1967I(uint256 value, address implementation) internal returns (address instance) ``` -------------------------------- ### Get Initialization Code for ERC1967 Bootstrap in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Returns the initialization code of the ERC1967 bootstrap. ```Solidity function initCodeERC1967Bootstrap(address authorizedUpgrader) internal pure returns (bytes memory c) ``` -------------------------------- ### Upgrade Proxy Implementation and Execute Call Source: https://github.com/vectorized/solady/blob/main/docs/utils/uupsupgradeable.md Upgrades the proxy's implementation to `newImplementation` and optionally performs a delegatecall to it with `data`. Emits an `Upgraded` event. Passing empty `data` skips the delegatecall. ```solidity function upgradeToAndCall(address newImplementation, bytes calldata data) public payable virtual onlyProxy ``` -------------------------------- ### APIDOC: Get bit value from Bitmap Source: https://github.com/vectorized/solady/blob/main/docs/utils/libbitmap.md Returns the boolean value of the bit at `index` in `bitmap`. ```APIDOC function get(Bitmap storage bitmap, uint256 index) internal view returns (bool isSet) ``` -------------------------------- ### ERC1967Factory Deploy Function: deploy Source: https://github.com/vectorized/solady/blob/main/docs/utils/erc1967factory.md Deploys a new proxy contract for a given `implementation` with a specified `admin`. Any value passed into this function will be forwarded to the proxy. Parameters: - `implementation` (address): The address of the implementation contract. - `admin` (address): The admin address for the new proxy. Returns: - `proxy` (address): The address of the newly deployed proxy. ```Solidity function deploy(address implementation, address admin) public payable returns (address proxy) ``` -------------------------------- ### Get Value from Uint256ToBytes32Map by Key in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/enumerablemaplib.md Returns the value for the key. Reverts if the key is not found. ```Solidity function get(Uint256ToBytes32Map storage map, uint256 key) internal view returns (bytes32 value) ``` -------------------------------- ### Deploy Minimal Proxy Clone with Immutable Arguments Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Deploys a minimal proxy clone of the `implementation` address, passing `args` as immutable arguments during deployment. This allows for constructor-like initialization for clones. ```solidity function clone(address implementation, bytes memory args) internal returns (address instance) ``` -------------------------------- ### Safely Get Value from Uint256ToBytes32Map by Key in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/enumerablemaplib.md Tries to return the value associated with the key. ```Solidity function tryGet(Uint256ToBytes32Map storage map, uint256 key) internal view returns (bool exists, bytes32 value) ``` -------------------------------- ### Get Minimal Proxy Initialization Code Hash (PUSH0 Variant) Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Calculates and returns the keccak256 hash of the initialization bytecode for a minimal proxy clone of the specified `implementation` address, using the PUSH0 opcode variant. ```solidity function initCodeHash_PUSH0(address implementation) internal pure returns (bytes32 hash) ``` -------------------------------- ### Deploy Deterministic ERC1967I Proxy with ETH Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Deploys a new ERC1967I proxy contract at a predictable address using a `salt` value and the specified `implementation`, depositing a given `value` of ETH during deployment. This combines deterministic deployment with initial ETH funding. The returned address is the instance of the newly deployed proxy. ```solidity function deployDeterministicERC1967I( uint256 value, address implementation, bytes32 salt ) internal returns (address instance) ``` -------------------------------- ### Get Value from Bytes32ToAddressMap by Key in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/enumerablemaplib.md Returns the value for the key. Reverts if the key is not found. ```Solidity function get(Bytes32ToAddressMap storage map, bytes32 key) internal view returns (address value) ``` -------------------------------- ### Safely Get Value from Bytes32ToAddressMap by Key in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/enumerablemaplib.md Tries to return the value associated with the key. ```Solidity function tryGet(Bytes32ToAddressMap storage map, bytes32 key) internal view returns (bool exists, address value) ``` -------------------------------- ### initCodeERC1967IBeaconProxy(address,bytes) Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Returns the initialization code of the ERC1967I beacon proxy with `args`. ```Solidity function initCodeERC1967IBeaconProxy(address beacon, bytes memory args) internal pure returns (bytes memory c) ``` -------------------------------- ### Get Value from Bytes32ToUint256Map by Key in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/enumerablemaplib.md Returns the value for the key. Reverts if the key is not found. ```Solidity function get(Bytes32ToUint256Map storage map, bytes32 key) internal view returns (uint256 value) ``` -------------------------------- ### Deploy Deterministic ERC1967 Proxy with Value, Immutable Args, and Salt Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Deploys a deterministic minimal ERC1967 proxy using a specified `implementation` address, `args` (immutable arguments), and a `salt` value. This function also deposits a `value` of ETH during deployment. ```solidity function deployDeterministicERC1967( uint256 value, address implementation, bytes memory args, bytes32 salt ) internal returns (address instance) ``` -------------------------------- ### Safely Get Value from Bytes32ToUint256Map by Key in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/enumerablemaplib.md Tries to return the value associated with the key. ```Solidity function tryGet(Bytes32ToUint256Map storage map, bytes32 key) internal view returns (bool exists, uint256 value) ``` -------------------------------- ### Get Days in Month in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/datetimelib.md Returns the number of days in the specified month of a given year. ```Solidity function daysInMonth(uint256 year, uint256 month) internal pure returns (uint256 result) ``` -------------------------------- ### ERC4337Factory Deploy Function: createAccount Source: https://github.com/vectorized/solady/blob/main/docs/accounts/erc4337factory.md Deploys an ERC4337 account with `ownSalt` and returns its deterministic address. The `owner` is encoded in the upper 160 bits of `ownSalt`. If the account is already deployed, it will simply return its address. Any `msg.value` will simply be forwarded to the account, regardless. ```APIDOC Method: createAccount Parameters: ownSalt: bytes32 Visibility: public payable virtual Returns: address ``` ```solidity function createAccount(bytes32 ownSalt) public payable virtual returns (address) ``` -------------------------------- ### Get ERC1967 Proxy Initialization Code Hash with Immutable Args Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Computes and returns the keccak256 hash of the initialization code for a minimal ERC1967 proxy, based on its `implementation` address and `args` (immutable arguments). ```solidity function initCodeHashERC1967(address implementation, bytes memory args) internal pure returns (bytes32 hash) ``` -------------------------------- ### Get ERC6551 Account Implementation Source: https://github.com/vectorized/solady/blob/main/docs/accounts/liberc6551.md Retrieves the address of the implementation contract used by the ERC6551 account `a`. ```APIDOC function implementation(address a) internal view returns (address result) ``` -------------------------------- ### API: Predict Deterministic Address by Salt Source: https://github.com/vectorized/solady/blob/main/docs/utils/create3.md Calculates and returns the deterministic address for a given salt. This function allows predicting the deployment address without actually deploying the contract, based on the current contract as the deployer. ```APIDOC function predictDeterministicAddress(bytes32 salt) internal view returns (address deployed) Parameters: salt: bytes32 - The salt used for deterministic address calculation. Returns: deployed: address - The predicted deterministic address. ``` -------------------------------- ### Get ERC1967 Beacon Proxy Initialization Code Hash Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Calculates and returns the keccak256 hash of the initialization code for a minimal ERC1967 beacon proxy, based on the provided beacon address and arguments. ```solidity function initCodeHashERC1967BeaconProxy(address beacon, bytes memory args) internal pure returns (bytes32 hash) ``` -------------------------------- ### UpgradeableBeacon Constructor Function Reference Source: https://github.com/vectorized/solady/blob/main/docs/utils/upgradeablebeacon.md Documentation for the internal `_constructUpgradeableBeacon` function, which is called during contract construction and can be overridden for custom initialization logic. ```APIDOC function _constructUpgradeableBeacon(address initialOwner, address initialImplementation) internal virtual Parameters: initialOwner: The address of the initial owner. initialImplementation: The address of the initial implementation. Description: Called in the constructor. Override as required. ``` -------------------------------- ### Slice DynamicArray in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/dynamicarraylib.md These functions provide ways to create a new `DynamicArray` by slicing an existing one. The `slice(DynamicArray, uint256, uint256)` function returns a copy of the array from a specified `start` index up to (but not including) the `end` index. The `slice(DynamicArray, uint256)` function returns a copy from the `start` index to the end of the array. Both functions operate on `DynamicArray` memory and return a new `DynamicArray` instance. ```Solidity function slice(DynamicArray memory a, uint256 start, uint256 end) internal pure returns (DynamicArray memory result) ``` ```Solidity function slice(DynamicArray memory a, uint256 start) internal pure returns (DynamicArray memory result) ``` -------------------------------- ### Get Empty Calldata Bytes32 Array for Proof Source: https://github.com/vectorized/solady/blob/main/docs/utils/merkleprooflib.md Returns an empty `bytes32[]` array with `calldata` location. This helper function is useful for initializing proof arrays when no proof is needed or for testing scenarios. ```Solidity function emptyProof() internal pure returns (bytes32[] calldata proof) ``` -------------------------------- ### Request UUPS Proxy Delegation Initialization (Solidity) Source: https://github.com/vectorized/solady/blob/main/docs/accounts/libeip7702.md Requests the proxy's implementation to be initialized to its latest version. This function is intended to be used under the authority of an EIP7702Proxy delegation, commonly placed at the end of an `execute` function to ensure the latest implementation is active after a delegation. ```Solidity function requestProxyDelegationInitialization() internal ``` -------------------------------- ### Get All Byte Indices of Substring in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/libstring.md Returns all the indices of `needle` in `subject`. The indices are byte offsets. ```Solidity function indicesOf(string memory subject, string memory needle) internal pure returns (uint256[] memory) ``` -------------------------------- ### Deploy ERC1967I Beacon Proxy with ETH Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Deploys an ERC1967I beacon proxy using the specified beacon address, and also deposits a given amount of ETH during the deployment process. ```solidity function deployERC1967IBeaconProxy(uint256 value, address beacon) internal returns (address instance) ``` -------------------------------- ### Get UTF Character Count of String Source: https://github.com/vectorized/solady/blob/main/docs/utils/libstring.md Returns the number of UTF characters (runes) in the given string. ```Solidity function runeCount(string memory s) internal pure returns (uint256 result) ``` -------------------------------- ### Deploy Minimal Proxy Clone with ETH Value (Standard) Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Deploys a minimal proxy clone of the specified `implementation` address, depositing a specified `value` of Ether during the deployment process. Returns the address of the newly deployed instance. ```solidity function clone(uint256 value, address implementation) internal returns (address instance) ``` -------------------------------- ### Get ERC6551 Account Token ID Source: https://github.com/vectorized/solady/blob/main/docs/accounts/liberc6551.md Returns the token ID of the NFT that the ERC6551 account `a` is associated with. ```APIDOC function tokenId(address a) internal view returns (uint256 result) ``` -------------------------------- ### Solidity Function: delegationAndImplementationOf Source: https://github.com/vectorized/solady/blob/main/docs/accounts/libeip7702.md Returns the delegation and the implementation of the account. If the account delegation is not a valid EIP7702Proxy, returns `address(0)`. ```APIDOC delegationAndImplementationOf(account: address) account: The address of the account to query. returns: (address delegation, address implementation) (The delegation and implementation addresses. If the account delegation is not a valid EIP7702Proxy, returns address(0) for both.) ``` -------------------------------- ### Get ERC6551 Account Salt Source: https://github.com/vectorized/solady/blob/main/docs/accounts/liberc6551.md Returns the unique salt value used in the creation of the ERC6551 account `a`. ```APIDOC function salt(address a) internal view returns (bytes32 result) ``` -------------------------------- ### Deploy Minimal ERC1967 Proxy (Solidity) Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md These functions deploy a minimal ERC1967 proxy, intended for UUPS upgrades, with a specified `implementation` address. One variant allows for `value` (ETH) to be deposited during deployment. This proxy differs from `ERC1967Factory`'s transparent proxy as it does not include admin logic. ```Solidity function deployERC1967(address implementation) internal returns (address instance) ``` ```Solidity function deployERC1967(uint256 value, address implementation) internal returns (address instance) ``` -------------------------------- ### Get ERC1967I Proxy Initialization Code Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Returns the full initialization bytecode for an ERC1967I proxy given its `implementation` address. This code is used during the proxy's deployment to set up its initial state and delegate logic. It is a pure function, meaning it does not read or modify state. ```solidity function initCodeERC1967I(address implementation) internal pure returns (bytes memory c) ``` -------------------------------- ### Get Standard Normal Sample (WAD) Source: https://github.com/vectorized/solady/blob/main/docs/utils/libprng.md Returns a sample from the standard normal distribution, denominated in `WAD` (1e18). ```APIDOC function standardNormalWad(PRNG memory prng) internal pure returns (int256 result) prng: The PRNG struct to draw from. result: An int256 sample from the standard normal distribution, scaled by WAD. ``` -------------------------------- ### Create Deterministic ERC1967 Proxy with Value, Immutable Args, and Salt Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Creates a deterministic minimal ERC1967 proxy using a specified `implementation` address, `args` (immutable arguments), and a `salt` value. This function also deposits a `value` of ETH during deployment. It is intended for ERC4337 factories and will not revert if the proxy already exists. ```solidity function createDeterministicERC1967( uint256 value, address implementation, bytes memory args, bytes32 salt ) internal returns (bool alreadyDeployed, address instance) ``` -------------------------------- ### Generate EIP7702Proxy Initialization Code (Solidity) Source: https://github.com/vectorized/solady/blob/main/docs/accounts/libeip7702.md Returns the initialization code (bytecode) required for deploying an EIP7702Proxy. This internal and pure function computes the necessary bytes without modifying the contract's state, providing the raw data needed for proxy creation. ```Solidity function proxyInitCode(address initialImplementation, address initialAdmin) internal pure returns (bytes memory) ``` -------------------------------- ### Get Initialization Code Hash for ERC1967 Bootstrap in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Returns the initialization code hash of the ERC1967 bootstrap. ```Solidity function initCodeHashERC1967Bootstrap(address authorizedUpgrader) internal pure returns (bytes32) ``` -------------------------------- ### Deploy or Get ERC1967 Bootstrap Implementation Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Deploys the ERC1967 bootstrap contract if it has not already been deployed. This bootstrap is a minimal UUPS implementation that allows an ERC1967 proxy pointing to it to be upgraded. An optional `authorizedUpgrader` address can be specified during deployment, returning the address of the deployed bootstrap. ```Solidity function erc1967Bootstrap() internal returns (address) ``` ```Solidity function erc1967Bootstrap(address authorizedUpgrader) internal returns (address bootstrap) ``` -------------------------------- ### Get ERC6551 Account Token Contract Source: https://github.com/vectorized/solady/blob/main/docs/accounts/liberc6551.md Returns the address of the NFT token contract that the ERC6551 account `a` is associated with. ```APIDOC function tokenContract(address a) internal view returns (address result) ``` -------------------------------- ### deployERC1967IBeaconProxy(address,bytes) Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Deploys a ERC1967I beacon proxy with `args`. ```Solidity function deployERC1967IBeaconProxy(address beacon, bytes memory args) internal returns (address instance) ``` -------------------------------- ### Get ERC6551 Account Initialization Code Source: https://github.com/vectorized/solady/blob/main/docs/accounts/liberc6551.md Retrieves the full initialization bytecode for an ERC6551 account based on its parameters. ```APIDOC function initCode( address implementation_, bytes32 salt_, uint256 chainId_, address tokenContract_, uint256 tokenId_ ) internal pure returns (bytes memory result) ``` -------------------------------- ### Deploy Minimal Proxy Clone with ETH Value (PUSH0 Variant) Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Deploys a minimal proxy clone of the specified `implementation` address using the PUSH0 opcode variant, depositing a specified `value` of Ether during deployment. Returns the address of the new instance. ```solidity function clone_PUSH0(uint256 value, address implementation) internal returns (address instance) ``` -------------------------------- ### Get Minimum Value from Heap Source: https://github.com/vectorized/solady/blob/main/docs/utils/minheaplib.md Returns the minimum value from a min-heap without modifying it. This function reverts if the heap is empty. ```Solidity function root(Heap storage heap) internal view returns (uint256 result) ``` ```Solidity function root(MemHeap memory heap) internal pure returns (uint256 result) ``` -------------------------------- ### Deploy Deterministic Minimal Proxy Clone (PUSH0 Variant) Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Deploys a deterministic minimal proxy clone of the `implementation` address with a `salt`, utilizing the PUSH0 opcode variant. The deployed address is predictable. ```solidity function cloneDeterministic_PUSH0(address implementation, bytes32 salt) internal returns (address instance) ``` -------------------------------- ### Get Parent of Item in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/jsonparserlib.md Returns the item's parent. If the item does not have a parent, the result's type will be undefined. ```Solidity function parent(Item memory item) internal pure returns (Item memory result) ``` -------------------------------- ### Push Value onto Min-Heap Source: https://github.com/vectorized/solady/blob/main/docs/utils/minheaplib.md Inserts a new `value` into the min-heap, maintaining the heap property. ```Solidity function push(Heap storage heap, uint256 value) internal ``` ```Solidity function push(MemHeap memory heap, uint256 value) internal pure ``` -------------------------------- ### Get DynamicBuffer Length Source: https://github.com/vectorized/solady/blob/main/docs/utils/dynamicbufferlib.md Provides a shorthand method to retrieve the current length of the `data` bytes array within a `DynamicBuffer`. ```Solidity function length(DynamicBuffer memory buffer) internal pure returns (uint256) ``` -------------------------------- ### Get Weekday from Timestamp in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/datetimelib.md Returns the day of the week (1-indexed, Monday: 1 to Sunday: 7) from a Unix timestamp. ```Solidity function weekday(uint256 timestamp) internal pure returns (uint256 result) ``` -------------------------------- ### Deploy Deterministic ERC1967 Beacon Proxy with Immutable Args in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Deploys a deterministic minimal ERC1967 beacon proxy with specified immutable arguments and a salt. ```Solidity function deployDeterministicERC1967BeaconProxy( address beacon, bytes memory args, bytes32 salt ) internal returns (address instance) ``` -------------------------------- ### Get ERC6551 Account Chain ID Source: https://github.com/vectorized/solady/blob/main/docs/accounts/liberc6551.md Returns the chain ID associated with the ERC6551 account `a`, indicating the blockchain it was created on. ```APIDOC function chainId(address a) internal view returns (uint256 result) ``` -------------------------------- ### Clone Deterministically with Value and Arguments (Solidity) Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Deploys a deterministic clone of an `implementation` contract, allowing for a specified `value` to be sent during deployment and immutable arguments (`args`) to be encoded. A `salt` is used to ensure deterministic address generation. ```Solidity function cloneDeterministic( uint256 value, address implementation, bytes memory args, bytes32 salt ) internal returns (address instance) ``` -------------------------------- ### Get ERC6551 Account Initialization Code Hash Source: https://github.com/vectorized/solady/blob/main/docs/accounts/liberc6551.md Calculates and returns the keccak256 hash of the initialization code for an ERC6551 account. ```APIDOC function initCodeHash( address implementation_, bytes32 salt_, uint256 chainId_, address tokenContract_, uint256 tokenId_ ) internal pure returns (bytes32 result) ``` -------------------------------- ### Get ERC20 Token Total Supply in Solidity Source: https://github.com/vectorized/solady/blob/main/docs/utils/safetransferlib.md Returns the total supply of the `token`. Reverts if the token does not exist or does not implement `totalSupply()`. ```solidity function totalSupply(address token) internal view returns (uint256 result) ``` -------------------------------- ### Deploy Deterministic ERC1967 Proxy with Immutable Args and Salt Source: https://github.com/vectorized/solady/blob/main/docs/utils/libclone.md Deploys a deterministic minimal ERC1967 proxy using a specified `implementation` address, `args` (immutable arguments), and a `salt` value. ```solidity function deployDeterministicERC1967( address implementation, bytes memory args, bytes32 salt ) internal returns (address instance) ```