EVMAuth Core
Overview
EVMAuth is an authorization state management system for APIs, MCP servers, and AI agents.
Purpose
EVMAuth was created to provide a simple, standardized way to manage persistent authorization without the overhead of developing and maintaining auth servers, databases, subscription management services, and payment systems.
Use Cases
- Token-Gated Access Control: Grant access to digital services, APIs, and AI agents based on token ownership.
- Subscription Management: Issue time-limited access tokens for subscription-based services.
- Metered Usage: Issue tokens that can be redeemed for usage credits, allowing for pay-as-you-go models.
- Licensing: Manage software licenses and entitlements through tokens.
- Access Revocation: Instantly revoke access by burning tokens or freezing accounts.
- Decentralized Identity: Leverage EVM networks for secure and verifiable identity management.
Features
Each EVMAuth token type can be configured for direct purchase, with any of the following:
- Native currencies like ETH
- Stablecoins like USDC and USDT
- Any other ERC-20 tokens
Each accepted payment method can be priced independently. If no prices are set (i.e. all prices are zero), direct purchases are disabled for that token type.
EVMAuth tokens can also be issued to users programmatically and redeemed by the issuer at any time. This works well for metered usage models, where tokens are used as credits.
Each EVMAuth token type can be configured with a time-to-live (TTL). If the TTL is set (i.e. greater than zero), tokens of that type will automatically expire. This is ideal for subscription models.
All EVMAuth tokens are transferable by default, but each token type can be made non-transferable. This is useful for non-transferable licenses, identity tokens, or other situations where transfers are undesirable.
Compatibility
EVMAuth comes in two flavors: ERC-1155 and ERC-6909. Each version is fully compliant with its token standard and, as such, is fully compatible with existing wallets, apps, marketplaces, and other tools that support those standards.
EVMAuth contracts are upgradable by default, using OpenZeppelin's UUPSUpgradeable and ERC-7201 namespaced storage layout, and can be deployed to any EVM-compatible network, including Ethereum, Base, Tron, Polygon, Monad, and Radius.
Deployment
EVMAuth can be deployed on any EVM-compatible network (e.g. Ethereum, Base, Radius) using the scripts provided in the scripts/ directory.
When deploying the contract, you will need to specify the following parameters:
- Initial transfer delay for the default admin role
- Initial default admin address, for role management
- Initial treasury address, for receiving revenue from direct purchases
- Role grants, to set up access control during initialization (optional, can be done later)
- Base token metadata URI (for ERC-1155) or contract URI (for ERC-6909) (optional, can be updated later)
Access Control
If you did not grant roles during initialization, only the default admin can assign roles after deployment, by calling:
grantRole(TOKEN_MANAGER_ROLE, address)for accounts that can configure tokens and token metadatagrantRole(ACCESS_MANAGER_ROLE, address)for accounts that can pause/unpause the contract and freeze accountsgrantRole(TREASURER_ROLE, address)for accounts that can modify the treasury address where funds are collectedgrantRole(MINTER_ROLE, address)for accounts that can issue tokens to addressesgrantRole(BURNER_ROLE, address)for accounts that can deduct tokens from addresses
Token Configuration
An account with the TOKEN_MANAGER_ROLE should then create one or more new tokens by calling createToken with the desired configuration:
uint256 price: The cost to purchase one unit of the token; 0 means the token cannot be purchased directly; set to0to disable native currency purchasesPaymentToken[] erc20Prices: Array ofPaymentTokenstructs, each containing ERC-20tokenaddress andprice; pass an empty array to disable ERC-20 token purchasesuint256 ttl: Time-to-live in seconds; 0 means the token never expires; set to 0 for non-expiring tokensbool transferable: Whether the token can be transferred between accounts
An account with the TOKEN_MANAGER_ROLE can modify an existing token by calling updateToken(id, EVMAuthTokenConfig).
Token Standards
ERC-1155 vs ERC-6909
| Feature | ERC-1155 | ERC-6909 |
|---|---|---|
| Callbacks | Required for each transfer to contract accounts; must return specific values | Removed entirely; no callbacks required |
| Batch Operations | Included in specification (batch transfers) | Excluded from specification to allow custom implementations |
| Permission System | Single operator scheme: operators get unlimited allowance on all token IDs | Hybrid scheme: allowances for specific token IDs + operators for all tokens |
| Transfer Methods | Both transferFrom and safeTransferFrom required; no opt-out for callbacks | Simplified transfers without mandatory recipient validation |
| Transfer Semantics | Safe transfers with data parameter and receiver hooks | Simple transfers without hooks |
| Interface Complexity | Includes multiple features (callbacks, batching, etc.) | Minimized to bare essentials for multi-token management |
| Recipient Requirements | Contract recipients must implement callback functions with return values | No special requirements for contract recipients |
| Approval Granularity | Operators only (all-or-nothing for entire contract) | Granular allowances per token ID + full operators |
| Metadata Handling | URI-based metadata (typically off-chain JSON) | On-chain name/symbol/decimals per token ID |
When to Choose Which
Choose ERC-1155 when you:
- Need NFT marketplace compatibility
- Batch operations are important
- Want receiver hook notifications
- Prefer URI-based metadata
Choose ERC-6909 when you:
- Need ERC-20-like semantics per token
- Want granular approval control
- Need on-chain token metadata
- Prefer a simpler token transfer model
- Want to extend the contract with custom features
Both versions of EVMAuth are fairly large. EVMAuth1155 is right near the limit, while EVMAuth6909 has a bit more headroom for expansion.
╭------------------------------+------------------+-------------------+--------------------+---------------------╮
| Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) |
+================================================================================================================+
| EVMAuth1155 | 24,516 | 24,575 | 60 | 24,577 |
|------------------------------+------------------+-------------------+--------------------+---------------------|
| EVMAuth6909 | 22,247 | 22,306 | 2,329 | 26,846 |
╰------------------------------+------------------+-------------------+--------------------+---------------------╯
EVMAuth Contract Architecture
Overview
The EVMAuth contract system is designed with a modular, composable architecture that separates concerns into focused base contracts. This approach provides flexibility while maintaining a clean inheritance structure.
The architecture consists of:
- Base Contracts: Modular components that handle specific functionality (e.g. access control, purchasing, token expiry)
- Base EVMAuth Contract: Combines all base contracts into a unified authorization state management system
- Token Standard Implementations:
EVMAuth1155andEVMAuth6909extendEVMAuthwith their respective token standards
Base Contracts Hierarchy
classDiagram
class TokenAccessControl {
<<abstract>>
+DEFAULT_ADMIN_ROLE
+UPGRADE_MANAGER_ROLE
+ACCESS_MANAGER_ROLE
+TOKEN_MANAGER_ROLE
+MINTER_ROLE
+BURNER_ROLE
+TREASURER_ROLE
+freezeAccount(account)
+unfreezeAccount(account)
+pause()
+unpause()
<<inherited from Pausable>>
+paused()
<<inherited from AccessControl>>
+hasRole(role, account)
+grantRole(role, account)
+revokeRole(role, account)
+renounceRole(role, account)
}
class AccountFreezable {
<<abstract>>
-frozenAccounts mapping
+isFrozen(address)
+frozenAccounts()
#_freezeAccount(address)
#_unfreezeAccount(address)
}
class TokenEnumerable {
<<abstract>>
-nextTokenId
-tokenExists mapping
+nextTokenID()
+exists(id)
#_claimNextTokenID()
}
class TokenTransferable {
<<abstract>>
-transferable mapping
+isTransferable(id)
#_setTransferable(id, bool)
}
class TokenEphemeral {
<<abstract>>
-ttl mapping
-balanceRecords mapping
+balanceOf(account, id)
+balanceRecordsOf(account, id)
+tokenTTL(id)
+pruneBalanceRecords(account, id)
#_setTTL(id, ttl)
#_expiresAt(id)
#_maxBalanceRecords()
#_updateBalanceRecords(from, to, id, amount)
#_addToBalanceRecords(account, id, amount, expiresAt)
#_deductFromBalanceRecords(account, id, amount)
#_transferBalanceRecords(from, to, id, amount)
}
class TokenPurchasable {
<<abstract>>
-treasury address
-prices mapping
-erc20Prices mapping
+treasury()
+tokenPrice(id)
+tokenERC20Prices(id)
+isAcceptedERC20PaymentToken(id, token)
+purchase(id, amount)
+purchaseFor(receiver, id, amount)
+purchaseWithERC20(token, id, amount)
+purchaseWithERC20For(receiver, token, id, amount)
#_setPrice(id, price)
#_setERC20Price(id, token, price)
#_setERC20Prices(id, prices[])
#_mintPurchasedTokens(to, id, amount)
}
class EVMAuth {
<<abstract>>
+EVMAuthTokenConfig struct
+createToken(config)
+updateToken(id, config)
+tokenConfig(id)
+setTreasury(address payable newTreasury)
#_authorizeUpgrade(newImplementation)
}
AccessControlDefaultAdminRulesUpgradeable <|-- TokenAccessControl
PausableUpgradeable <|-- TokenAccessControl
AccountFreezable <|-- TokenAccessControl
TokenAccessControl <|-- EVMAuth
TokenEnumerable <|-- EVMAuth
TokenTransferable <|-- EVMAuth
TokenEphemeral <|-- EVMAuth
TokenPurchasable <|-- EVMAuth
UUPSUpgradeable <|-- EVMAuth
EVMAuth1155 Implementation
classDiagram
class EVMAuth {
<<abstract>>
+DEFAULT_ADMIN_ROLE
+UPGRADE_MANAGER_ROLE
+ACCESS_MANAGER_ROLE
+TOKEN_MANAGER_ROLE
+MINTER_ROLE
+BURNER_ROLE
+TREASURER_ROLE
+hasRole(role, account)
+isFrozen(address)
+frozenAccounts()
+balanceOf(account, id)
+balanceRecordsOf(account, id)
+nextTokenID()
+exists(id)
+tokenConfig(id)
+treasury()
+tokenPrice(id)
+tokenERC20Prices(id)
+isAcceptedERC20PaymentToken(id, token)
+tokenTTL(id)
+isTransferable(id)
+grantRole(role, account)
+revokeRole(role, account)
+renounceRole(role, account)
+pause()
+unpause()
+freezeAccount(account)
+unfreezeAccount(account)
+createToken(config)
+updateToken(id, config)
+setTreasury(address payable newTreasury)
+purchase(id, amount)
+purchaseFor(receiver, id, amount)
+purchaseWithERC20(token, id, amount)
+purchaseWithERC20For(receiver, token, id, amount)
+pruneBalanceRecords(account, id)
}
class ERC1155Upgradeable {
+balanceOf(account, id)
+balanceOfBatch(accounts[], ids[])
+setApprovalForAll(operator, approved)
+isApprovedForAll(account, operator)
+safeTransferFrom(from, to, id, amount, data)
+safeBatchTransferFrom(from, to, ids[], amounts[], data)
}
class ERC1155URIStorageUpgradeable {
+uri(id)
#_setURI(id, uri)
#_setBaseURI(baseURI)
}
class EVMAuth1155 {
+initialize(delay, admin, treasury, uri)
+mint(to, id, amount, data)
+mintBatch(to, ids[], amounts[], data)
+burn(from, id, amount)
+burnBatch(from, ids[], amounts[])
+setBaseURI(uri)
+setTokenURI(id, uri)
+purchaseFor(recipient, id, amount)
+purchaseWithERC20For(token, recipient, id, amount)
+balanceRecordsOf(account, id)
+pruneBalanceRecords(account, id)
+exists(id)
+supportsInterface(interfaceId)
#_update(from, to, ids[], amounts[])
#_mintPurchasedTokens(to, id, amount)
}
ERC1155Upgradeable <|-- ERC1155SupplyUpgradeable
ERC1155Upgradeable <|-- ERC1155URIStorageUpgradeable
ERC1155SupplyUpgradeable <|-- EVMAuth1155
ERC1155URIStorageUpgradeable <|-- EVMAuth1155
EVMAuth <|-- EVMAuth1155
EVMAuth6909 Implementation
classDiagram
class EVMAuth {
<<abstract>>
+DEFAULT_ADMIN_ROLE
+UPGRADE_MANAGER_ROLE
+ACCESS_MANAGER_ROLE
+TOKEN_MANAGER_ROLE
+MINTER_ROLE
+BURNER_ROLE
+TREASURER_ROLE
+hasRole(role, account)
+isFrozen(address)
+frozenAccounts()
+balanceOf(account, id)
+balanceRecordsOf(account, id)
+nextTokenID()
+exists(id)
+tokenConfig(id)
+treasury()
+tokenPrice(id)
+tokenERC20Prices(id)
+isAcceptedERC20PaymentToken(id, token)
+tokenTTL(id)
+isTransferable(id)
+grantRole(role, account)
+revokeRole(role, account)
+renounceRole(role, account)
+pause()
+unpause()
+freezeAccount(account)
+unfreezeAccount(account)
+createToken(config)
+updateToken(id, config)
+setTreasury(address payable newTreasury)
+purchase(id, amount)
+purchaseFor(receiver, id, amount)
+purchaseWithERC20(token, id, amount)
+purchaseWithERC20For(receiver, token, id, amount)
+pruneBalanceRecords(account, id)
}
class ERC6909Upgradeable {
+balanceOf(account, id)
+allowance(owner, spender, id)
+isOperator(owner, spender)
+transfer(to, id, amount)
+transferFrom(from, to, id, amount)
+approve(spender, id, amount)
+setOperator(operator, approved)
}
class ERC6909MetadataUpgradeable {
+name(id)
+symbol(id)
+decimals(id)
#_setTokenMetadata(id, name, symbol, decimals)
}
class ERC6909ContentURIUpgradeable {
+contractURI()
+tokenURI(id)
#_setContractURI(uri)
#_setTokenURI(id, uri)
}
class EVMAuth6909 {
+initialize(delay, admin, treasury, uri)
+mint(to, id, amount)
+burn(from, id, amount)
+setContractURI(uri)
+setTokenURI(id, uri)
+setTokenMetadata(id, name, symbol, decimals)
+purchaseFor(recipient, id, amount)
+purchaseWithERC20For(token, recipient, id, amount)
+balanceRecordsOf(account, id)
+pruneBalanceRecords(account, id)
+exists(id)
+supportsInterface(interfaceId)
#_update(from, to, id, amount)
#_mintPurchasedTokens(to, id, amount)
}
ERC6909Upgradeable <|-- ERC6909MetadataUpgradeable
ERC6909Upgradeable <|-- ERC6909ContentURIUpgradeable
ERC6909MetadataUpgradeable <|-- EVMAuth6909
ERC6909ContentURIUpgradeable <|-- EVMAuth6909
EVMAuth <|-- EVMAuth6909
Base Contract Descriptions
TokenAccessControl
Provides role-based access control with six distinct roles, pausable functionality, and account freezing capabilities. Extends OpenZeppelin's AccessControlDefaultAdminRulesUpgradeable for secure admin transfer with time delays.
AccountFreezable
Enables freezing and unfreezing of individual accounts, preventing them from transferring or receiving tokens. Maintains a list of frozen accounts for transparency.
TokenEnumerable
Manages token ID generation and tracks which token IDs have been created. Provides a sequential ID system starting from 1.
TokenTransferable
Controls whether individual token types can be transferred between accounts. Each token ID can be configured as transferable or non-transferable.
TokenEphemeral
Implements time-to-live (TTL) functionality for tokens. Tokens with a TTL expire after the specified duration, with automatic pruning of expired balance records. Uses an efficient time-bucket system for gas optimization.
TokenPurchasable
Handles direct token purchases with both native currency and ERC-20 tokens. Supports per-token pricing in multiple currencies, with revenue sent to a configurable treasury address. Includes reentrancy protection for secure purchases.
EVMAuth
The main abstract contract that combines all base functionality and provides a unified interface for token configuration. Defines the EVMAuthTokenConfig structure that encapsulates price, ERC-20 prices, TTL, and transferability settings for each token type.
Key Architectural Decisions
-
Upgradability: All contracts use the Universal Upgradeable Proxy Standard (UUPS) pattern for future improvements
-
Security:
- Role-based access control with time-delayed admin transfers
- Pausable operations for emergency situations
- Account freezing capabilities
- Reentrancy protection on purchase functions
-
Gas Optimization:
- TTL implementation uses bounded arrays and time buckets for balance records
- Automatic pruning of expired records, with manual pruning methods available
- Efficient storage patterns for token properties, as defined in ERC-7201
-
Flexibility:
SDKs & Libraries
EVMAuth provides the following SDKs and libraries for easy integration with applications and frameworks:
- TypeScript SDK
- Python SDK (coming soon)
To request additional SDKs or libraries, create a new issue with the question label.
You can also use Foundry's cast command line tool to interact with deployed EVMAuth contracts, and reference this Cast Command Cheat Sheet which illustrates how to call each EVMAuth function.
Contributing
To contribute to this open source project, please follow the guidelines in the Contributing Guide.
License
The EVMAuth contract is released under the MIT License. See the LICENSE file for details.
Contents
Contents
- interfaces
- CommonBase
- TestBase
- ScriptBase
- Script
- StdAssertions
- StdChains
- StdCheatsSafe
- StdCheats
- StdConstants
- stdError
- StdInvariant
- stdJson
- stdMath
- FindData
- StdStorage
- stdStorageSafe
- stdStorage
- StdStyle
- stdToml
- StdUtils
- Test
- VmSafe
- Vm
- console
- safeconsole
Contents
- IERC1155
- IERC165
- IERC20
- IERC4626
- IERC6909
- IERC6909Metadata
- IERC6909ContentURI
- IERC6909TokenSupply
- IERC721
- IERC721TokenReceiver
- IERC721Metadata
- IERC721Enumerable
- IERC7540Operator
- IERC7540Deposit
- IERC7540Redeem
- IERC7540
- IERC7575
- IERC7575Share
- IMulticall3
IERC1155
Inherits: IERC165
See https://eips.ethereum.org/EIPS/eip-1155 Note: The ERC-165 identifier for this interface is 0xd9b67a26.
Functions
safeTransferFrom
Transfers _value amount of an _id from the _from address to the _to address specified (with safety call).
*Caller must be approved to manage the tokens being transferred out of the _from account (see "Approval" section of the standard).
- MUST revert if
_tois the zero address. - MUST revert if balance of holder for token
_idis lower than the_valuesent. - MUST revert on any other error.
- MUST emit the
TransferSingleevent to reflect the balance change (see "Safe Transfer Rules" section of the standard). - After the above conditions are met, this function MUST check if
_tois a smart contract (e.g. code size > 0). If so, it MUST callonERC1155Receivedon_toand act appropriately (see "Safe Transfer Rules" section of the standard).*
function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _value, bytes calldata _data) external;
Parameters
| Name | Type | Description |
|---|---|---|
_from | address | Source address |
_to | address | Target address |
_id | uint256 | ID of the token type |
_value | uint256 | Transfer amount |
_data | bytes | Additional data with no specified format, MUST be sent unaltered in call to onERC1155Received on _to |
safeBatchTransferFrom
Transfers _values amount(s) of _ids from the _from address to the _to address specified (with safety call).
*Caller must be approved to manage the tokens being transferred out of the _from account (see "Approval" section of the standard).
- MUST revert if
_tois the zero address. - MUST revert if length of
_idsis not the same as length of_values. - MUST revert if any of the balance(s) of the holder(s) for token(s) in
_idsis lower than the respective amount(s) in_valuessent to the recipient. - MUST revert on any other error.
- MUST emit
TransferSingleorTransferBatchevent(s) such that all the balance changes are reflected (see "Safe Transfer Rules" section of the standard). - Balance changes and events MUST follow the ordering of the arrays (_ids[0]/_values[0] before _ids[1]/_values[1], etc).
- After the above conditions for the transfer(s) in the batch are met, this function MUST check if
_tois a smart contract (e.g. code size > 0). If so, it MUST call the relevantERC1155TokenReceiverhook(s) on_toand act appropriately (see "Safe Transfer Rules" section of the standard).*
function safeBatchTransferFrom(
address _from,
address _to,
uint256[] calldata _ids,
uint256[] calldata _values,
bytes calldata _data
) external;
Parameters
| Name | Type | Description |
|---|---|---|
_from | address | Source address |
_to | address | Target address |
_ids | uint256[] | IDs of each token type (order and length must match _values array) |
_values | uint256[] | Transfer amounts per token type (order and length must match _ids array) |
_data | bytes | Additional data with no specified format, MUST be sent unaltered in call to the ERC1155TokenReceiver hook(s) on _to |
balanceOf
Get the balance of an account's tokens.
function balanceOf(address _owner, uint256 _id) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_owner | address | The address of the token holder |
_id | uint256 | ID of the token |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The _owner's balance of the token type requested |
balanceOfBatch
Get the balance of multiple account/token pairs
function balanceOfBatch(address[] calldata _owners, uint256[] calldata _ids) external view returns (uint256[] memory);
Parameters
| Name | Type | Description |
|---|---|---|
_owners | address[] | The addresses of the token holders |
_ids | uint256[] | ID of the tokens |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256[] | The _owner's balance of the token types requested (i.e. balance for each (owner, id) pair) |
setApprovalForAll
Enable or disable approval for a third party ("operator") to manage all of the caller's tokens.
MUST emit the ApprovalForAll event on success.
function setApprovalForAll(address _operator, bool _approved) external;
Parameters
| Name | Type | Description |
|---|---|---|
_operator | address | Address to add to the set of authorized operators |
_approved | bool | True if the operator is approved, false to revoke approval |
isApprovedForAll
Queries the approval status of an operator for a given owner.
function isApprovedForAll(address _owner, address _operator) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
_owner | address | The owner of the tokens |
_operator | address | Address of authorized operator |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the operator is approved, false if not |
Events
TransferSingle
- Either
TransferSingleorTransferBatchMUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see "Safe Transfer Rules" section of the standard). - The
_operatorargument MUST be the address of an account/contract that is approved to make the transfer (SHOULD be msg.sender). - The
_fromargument MUST be the address of the holder whose balance is decreased. - The
_toargument MUST be the address of the recipient whose balance is increased. - The
_idargument MUST be the token type being transferred. - The
_valueargument MUST be the number of tokens the holder balance is decreased by and match what the recipient balance is increased by. - When minting/creating tokens, the
_fromargument MUST be set to0x0(i.e. zero address). - When burning/destroying tokens, the
_toargument MUST be set to0x0(i.e. zero address).*
event TransferSingle(
address indexed _operator, address indexed _from, address indexed _to, uint256 _id, uint256 _value
);
TransferBatch
- Either
TransferSingleorTransferBatchMUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see "Safe Transfer Rules" section of the standard). - The
_operatorargument MUST be the address of an account/contract that is approved to make the transfer (SHOULD be msg.sender). - The
_fromargument MUST be the address of the holder whose balance is decreased. - The
_toargument MUST be the address of the recipient whose balance is increased. - The
_idsargument MUST be the list of tokens being transferred. - The
_valuesargument MUST be the list of number of tokens (matching the list and order of tokens specified in _ids) the holder balance is decreased by and match what the recipient balance is increased by. - When minting/creating tokens, the
_fromargument MUST be set to0x0(i.e. zero address). - When burning/destroying tokens, the
_toargument MUST be set to0x0(i.e. zero address).*
event TransferBatch(
address indexed _operator, address indexed _from, address indexed _to, uint256[] _ids, uint256[] _values
);
ApprovalForAll
MUST emit when approval for a second party/operator address to manage all tokens for an owner address is enabled or disabled (absence of an event assumes disabled).
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
URI
MUST emit when the URI is updated for a token ID. URIs are defined in RFC 3986. The URI MUST point to a JSON file that conforms to the "ERC-1155 Metadata URI JSON Schema".
event URI(string _value, uint256 indexed _id);
IERC165
Functions
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceID) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceID | bytes4 | The interface identifier, as specified in ERC-165 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
IERC20
Interface of the ERC20 standard as defined in the EIP.
This includes the optional name, symbol, and decimals metadata.
Functions
totalSupply
Returns the amount of tokens in existence.
function totalSupply() external view returns (uint256);
balanceOf
Returns the amount of tokens owned by account.
function balanceOf(address account) external view returns (uint256);
transfer
Moves amount tokens from the caller's account to to.
function transfer(address to, uint256 amount) external returns (bool);
allowance
Returns the remaining number of tokens that spender is allowed
to spend on behalf of owner
function allowance(address owner, address spender) external view returns (uint256);
approve
Sets amount as the allowance of spender over the caller's tokens.
Be aware of front-running risks: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
function approve(address spender, uint256 amount) external returns (bool);
transferFrom
Moves amount tokens from from to to using the allowance mechanism.
amount is then deducted from the caller's allowance.
function transferFrom(address from, address to, uint256 amount) external returns (bool);
name
Returns the name of the token.
function name() external view returns (string memory);
symbol
Returns the symbol of the token.
function symbol() external view returns (string memory);
decimals
Returns the decimals places of the token.
function decimals() external view returns (uint8);
Events
Transfer
Emitted when value tokens are moved from one account (from) to another (to).
event Transfer(address indexed from, address indexed to, uint256 value);
Approval
Emitted when the allowance of a spender for an owner is set, where value
is the new allowance.
event Approval(address indexed owner, address indexed spender, uint256 value);
IERC4626
Inherits: IERC20
Interface of the ERC4626 "Tokenized Vault Standard", as defined in https://eips.ethereum.org/EIPS/eip-4626
Functions
asset
Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.
- MUST be an ERC-20 token contract.
- MUST NOT revert.*
function asset() external view returns (address assetTokenAddress);
totalAssets
Returns the total amount of the underlying asset that is “managed” by Vault.
- SHOULD include any compounding that occurs from yield.
- MUST be inclusive of any fees that are charged against assets in the Vault.
- MUST NOT revert.*
function totalAssets() external view returns (uint256 totalManagedAssets);
convertToShares
Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal scenario where all the conditions are met.
- MUST NOT be inclusive of any fees that are charged against assets in the Vault.
- MUST NOT show any variations depending on the caller.
- MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
- MUST NOT revert. NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and from.*
function convertToShares(uint256 assets) external view returns (uint256 shares);
convertToAssets
Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal scenario where all the conditions are met.
- MUST NOT be inclusive of any fees that are charged against assets in the Vault.
- MUST NOT show any variations depending on the caller.
- MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
- MUST NOT revert. NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and from.*
function convertToAssets(uint256 shares) external view returns (uint256 assets);
maxDeposit
Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver, through a deposit call.
- MUST return a limited value if receiver is subject to some deposit limit.
- MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.
- MUST NOT revert.*
function maxDeposit(address receiver) external view returns (uint256 maxAssets);
previewDeposit
Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given current on-chain conditions.
- MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called in the same transaction.
- MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the deposit would be accepted, regardless if the user has enough tokens approved, etc.
- MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
- MUST NOT revert. NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by depositing.*
function previewDeposit(uint256 assets) external view returns (uint256 shares);
deposit
Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.
- MUST emit the Deposit event.
- MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the deposit execution, and are accounted for during deposit.
- MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not approving enough underlying tokens to the Vault contract, etc). NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.*
function deposit(uint256 assets, address receiver) external returns (uint256 shares);
maxMint
Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.
- MUST return a limited value if receiver is subject to some mint limit.
- MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.
- MUST NOT revert.*
function maxMint(address receiver) external view returns (uint256 maxShares);
previewMint
Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given current on-chain conditions.
- MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the same transaction.
- MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint would be accepted, regardless if the user has enough tokens approved, etc.
- MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
- MUST NOT revert. NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by minting.*
function previewMint(uint256 shares) external view returns (uint256 assets);
mint
Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.
- MUST emit the Deposit event.
- MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint execution, and are accounted for during mint.
- MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not approving enough underlying tokens to the Vault contract, etc). NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.*
function mint(uint256 shares, address receiver) external returns (uint256 assets);
maxWithdraw
Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the Vault, through a withdrawal call.
- MUST return a limited value if owner is subject to some withdrawal limit or timelock.
- MUST NOT revert.*
function maxWithdraw(address owner) external view returns (uint256 maxAssets);
previewWithdraw
Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block, given current on-chain conditions.
- MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if called in the same transaction.
- MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though the withdrawal would be accepted, regardless if the user has enough shares, etc.
- MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
- MUST NOT revert. NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by depositing.*
function previewWithdraw(uint256 assets) external view returns (uint256 shares);
withdraw
Burns shares from owner and sends exactly assets of underlying tokens to receiver.
- MUST emit the Withdraw event.
- MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the withdraw execution, and are accounted for during withdrawal.
- MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner not having enough shares, etc). Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed. Those methods should be performed separately.*
function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);
maxRedeem
Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, through a redeem call.
- MUST return a limited value if owner is subject to some withdrawal limit or timelock.
- MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.
- MUST NOT revert.*
function maxRedeem(address owner) external view returns (uint256 maxShares);
previewRedeem
Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block, given current on-chain conditions.
- MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the same transaction.
- MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the redemption would be accepted, regardless if the user has enough shares, etc.
- MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
- MUST NOT revert. NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by redeeming.*
function previewRedeem(uint256 shares) external view returns (uint256 assets);
redeem
Burns exactly shares from owner and sends assets of underlying tokens to receiver.
- MUST emit the Withdraw event.
- MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the redeem execution, and are accounted for during redeem.
- MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner not having enough shares, etc). NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed. Those methods should be performed separately.*
function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);
Events
Deposit
event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);
Withdraw
event Withdraw(address indexed sender, address indexed receiver, address indexed owner, uint256 assets, uint256 shares);
IERC6909
Inherits: IERC165
Required interface of an ERC-6909 compliant contract, as defined in https://eips.ethereum.org/EIPS/eip-6909
Functions
balanceOf
Returns the amount of tokens of type id owned by owner.
function balanceOf(address owner, uint256 id) external view returns (uint256);
allowance
Returns the amount of tokens of type id that spender is allowed to spend on behalf of owner.
NOTE: Does not include operator allowances.
function allowance(address owner, address spender, uint256 id) external view returns (uint256);
isOperator
Returns true if spender is set as an operator for owner.
function isOperator(address owner, address spender) external view returns (bool);
approve
Sets an approval to spender for amount tokens of type id from the caller's tokens.
Must return true.
function approve(address spender, uint256 id, uint256 amount) external returns (bool);
setOperator
Grants or revokes unlimited transfer permission of any token id to spender for the caller's tokens.
Must return true.
function setOperator(address spender, bool approved) external returns (bool);
transfer
Transfers amount of token type id from the caller's account to receiver.
Must return true.
function transfer(address receiver, uint256 id, uint256 amount) external returns (bool);
transferFrom
Transfers amount of token type id from sender to receiver.
Must return true.
function transferFrom(address sender, address receiver, uint256 id, uint256 amount) external returns (bool);
Events
Approval
Emitted when the allowance of a spender for an owner is set for a token of type id.
event Approval(address indexed owner, address indexed spender, uint256 indexed id, uint256 amount);
OperatorSet
Emitted when owner grants or revokes operator status for a spender.
event OperatorSet(address indexed owner, address indexed spender, bool approved);
Transfer
Emitted when amount tokens of type id are moved from sender to receiver initiated by caller.
event Transfer(address caller, address indexed sender, address indexed receiver, uint256 indexed id, uint256 amount);
IERC6909Metadata
Inherits: IERC6909
Optional extension of {IERC6909} that adds metadata functions.
Functions
name
Returns the name of the token of type id.
function name(uint256 id) external view returns (string memory);
symbol
Returns the ticker symbol of the token of type id.
function symbol(uint256 id) external view returns (string memory);
decimals
Returns the number of decimals for the token of type id.
function decimals(uint256 id) external view returns (uint8);
IERC6909ContentURI
Inherits: IERC6909
Optional extension of {IERC6909} that adds content URI functions.
Functions
contractURI
Returns URI for the contract.
function contractURI() external view returns (string memory);
tokenURI
Returns the URI for the token of type id.
function tokenURI(uint256 id) external view returns (string memory);
IERC6909TokenSupply
Inherits: IERC6909
Optional extension of {IERC6909} that adds a token supply function.
Functions
totalSupply
Returns the total supply of the token of type id.
function totalSupply(uint256 id) external view returns (uint256);
IERC721
Inherits: IERC165
See https://eips.ethereum.org/EIPS/eip-721 Note: the ERC-165 identifier for this interface is 0x80ac58cd.
Functions
balanceOf
Count all NFTs assigned to an owner
NFTs assigned to the zero address are considered invalid, and this function throws for queries about the zero address.
function balanceOf(address _owner) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_owner | address | An address for whom to query the balance |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The number of NFTs owned by _owner, possibly zero |
ownerOf
Find the owner of an NFT
NFTs assigned to zero address are considered invalid, and queries about them do throw.
function ownerOf(uint256 _tokenId) external view returns (address);
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | The identifier for an NFT |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The address of the owner of the NFT |
safeTransferFrom
Transfers the ownership of an NFT from one address to another address
Throws unless msg.sender is the current owner, an authorized
operator, or the approved address for this NFT. Throws if _from is
not the current owner. Throws if _to is the zero address. Throws if
_tokenId is not a valid NFT. When transfer is complete, this function
checks if _to is a smart contract (code size > 0). If so, it calls
onERC721Received on _to and throws if the return value is not
bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")).
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes calldata data) external payable;
Parameters
| Name | Type | Description |
|---|---|---|
_from | address | The current owner of the NFT |
_to | address | The new owner |
_tokenId | uint256 | The NFT to transfer |
data | bytes | Additional data with no specified format, sent in call to _to |
safeTransferFrom
Transfers the ownership of an NFT from one address to another address
This works identically to the other function with an extra data parameter, except this function just sets data to "".
function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable;
Parameters
| Name | Type | Description |
|---|---|---|
_from | address | The current owner of the NFT |
_to | address | The new owner |
_tokenId | uint256 | The NFT to transfer |
transferFrom
Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE
TO CONFIRM THAT _to IS CAPABLE OF RECEIVING NFTS OR ELSE
THEY MAY BE PERMANENTLY LOST
Throws unless msg.sender is the current owner, an authorized
operator, or the approved address for this NFT. Throws if _from is
not the current owner. Throws if _to is the zero address. Throws if
_tokenId is not a valid NFT.
function transferFrom(address _from, address _to, uint256 _tokenId) external payable;
Parameters
| Name | Type | Description |
|---|---|---|
_from | address | The current owner of the NFT |
_to | address | The new owner |
_tokenId | uint256 | The NFT to transfer |
approve
Change or reaffirm the approved address for an NFT
The zero address indicates there is no approved address.
Throws unless msg.sender is the current NFT owner, or an authorized
operator of the current owner.
function approve(address _approved, uint256 _tokenId) external payable;
Parameters
| Name | Type | Description |
|---|---|---|
_approved | address | The new approved NFT controller |
_tokenId | uint256 | The NFT to approve |
setApprovalForAll
Enable or disable approval for a third party ("operator") to manage
all of msg.sender's assets
Emits the ApprovalForAll event. The contract MUST allow multiple operators per owner.
function setApprovalForAll(address _operator, bool _approved) external;
Parameters
| Name | Type | Description |
|---|---|---|
_operator | address | Address to add to the set of authorized operators |
_approved | bool | True if the operator is approved, false to revoke approval |
getApproved
Get the approved address for a single NFT
Throws if _tokenId is not a valid NFT.
function getApproved(uint256 _tokenId) external view returns (address);
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | The NFT to find the approved address for |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The approved address for this NFT, or the zero address if there is none |
isApprovedForAll
Query if an address is an authorized operator for another address
function isApprovedForAll(address _owner, address _operator) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
_owner | address | The address that owns the NFTs |
_operator | address | The address that acts on behalf of the owner |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if _operator is an approved operator for _owner, false otherwise |
Events
Transfer
This emits when ownership of any NFT changes by any mechanism.
This event emits when NFTs are created (from == 0) and destroyed
(to == 0). Exception: during contract creation, any number of NFTs
may be created and assigned without emitting Transfer. At the time of
any transfer, the approved address for that NFT (if any) is reset to none.
event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);
Approval
This emits when the approved address for an NFT is changed or reaffirmed. The zero address indicates there is no approved address. When a Transfer event emits, this also indicates that the approved address for that NFT (if any) is reset to none.
event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId);
ApprovalForAll
This emits when an operator is enabled or disabled for an owner. The operator can manage all NFTs of the owner.
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
IERC721TokenReceiver
Note: the ERC-165 identifier for this interface is 0x150b7a02.
Functions
onERC721Received
Handle the receipt of an NFT
The ERC721 smart contract calls this function on the recipient
after a transfer. This function MAY throw to revert and reject the
transfer. Return of other than the magic value MUST result in the
transaction being reverted.
Note: the contract address is always the message sender.
function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes calldata _data)
external
returns (bytes4);
Parameters
| Name | Type | Description |
|---|---|---|
_operator | address | The address which called safeTransferFrom function |
_from | address | The address which previously owned the token |
_tokenId | uint256 | The NFT identifier which is being transferred |
_data | bytes | Additional data with no specified format |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes4 | bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")) unless throwing |
IERC721Metadata
Inherits: IERC721
See https://eips.ethereum.org/EIPS/eip-721 Note: the ERC-165 identifier for this interface is 0x5b5e139f.
Functions
name
A descriptive name for a collection of NFTs in this contract
function name() external view returns (string memory _name);
symbol
An abbreviated name for NFTs in this contract
function symbol() external view returns (string memory _symbol);
tokenURI
A distinct Uniform Resource Identifier (URI) for a given asset.
Throws if _tokenId is not a valid NFT. URIs are defined in RFC
3986. The URI may point to a JSON file that conforms to the "ERC721
Metadata JSON Schema".
function tokenURI(uint256 _tokenId) external view returns (string memory);
IERC721Enumerable
Inherits: IERC721
See https://eips.ethereum.org/EIPS/eip-721 Note: the ERC-165 identifier for this interface is 0x780e9d63.
Functions
totalSupply
Count NFTs tracked by this contract
function totalSupply() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | A count of valid NFTs tracked by this contract, where each one of them has an assigned and queryable owner not equal to the zero address |
tokenByIndex
Enumerate valid NFTs
Throws if _index >= totalSupply().
function tokenByIndex(uint256 _index) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_index | uint256 | A counter less than totalSupply() |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The token identifier for the _indexth NFT, (sort order not specified) |
tokenOfOwnerByIndex
Enumerate NFTs assigned to an owner
Throws if _index >= balanceOf(_owner) or if
_owner is the zero address, representing invalid NFTs.
function tokenOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_owner | address | An address where we are interested in NFTs owned by them |
_index | uint256 | A counter less than balanceOf(_owner) |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The token identifier for the _indexth NFT assigned to _owner, (sort order not specified) |
IERC7540Operator
Interface of the base operator logic of ERC7540, as defined in https://eips.ethereum.org/EIPS/eip-7540
Functions
setOperator
Sets or removes an operator for the caller.
function setOperator(address operator, bool approved) external returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
operator | address | The address of the operator. |
approved | bool | The approval status. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | Whether the call was executed successfully or not |
isOperator
Returns true if the operator is approved as an operator for an controller.
function isOperator(address controller, address operator) external view returns (bool status);
Parameters
| Name | Type | Description |
|---|---|---|
controller | address | The address of the controller. |
operator | address | The address of the operator. |
Returns
| Name | Type | Description |
|---|---|---|
status | bool | The approval status |
Events
OperatorSet
The event emitted when an operator is set.
event OperatorSet(address indexed controller, address indexed operator, bool approved);
Parameters
| Name | Type | Description |
|---|---|---|
controller | address | The address of the controller. |
operator | address | The address of the operator. |
approved | bool | The approval status. |
IERC7540Deposit
Inherits: IERC7540Operator
Interface of the asynchronous deposit Vault interface of ERC7540, as defined in https://eips.ethereum.org/EIPS/eip-7540
Functions
requestDeposit
*Transfers assets from sender into the Vault and submits a Request for asynchronous deposit.
- MUST support ERC-20 approve / transferFrom on asset as a deposit Request flow.
- MUST revert if all of assets cannot be requested for deposit.
- owner MUST be msg.sender unless some unspecified explicit approval is given by the caller, approval of ERC-20 tokens from owner to sender is NOT enough.*
function requestDeposit(uint256 assets, address controller, address owner) external returns (uint256 requestId);
Parameters
| Name | Type | Description |
|---|---|---|
assets | uint256 | the amount of deposit assets to transfer from owner |
controller | address | the controller of the request who will be able to operate the request |
owner | address | the source of the deposit assets NOTE: most implementations will require pre-approval of the Vault with the Vault's underlying asset token. |
pendingDepositRequest
*Returns the amount of requested assets in Pending state.
- MUST NOT include any assets in Claimable state for deposit or mint.
- MUST NOT show any variations depending on the caller.
- MUST NOT revert unless due to integer overflow caused by an unreasonably large input.*
function pendingDepositRequest(uint256 requestId, address controller) external view returns (uint256 pendingAssets);
claimableDepositRequest
*Returns the amount of requested assets in Claimable state for the controller to deposit or mint.
- MUST NOT include any assets in Pending state.
- MUST NOT show any variations depending on the caller.
- MUST NOT revert unless due to integer overflow caused by an unreasonably large input.*
function claimableDepositRequest(uint256 requestId, address controller)
external
view
returns (uint256 claimableAssets);
deposit
*Mints shares Vault shares to receiver by claiming the Request of the controller.
- MUST emit the Deposit event.
- controller MUST equal msg.sender unless the controller has approved the msg.sender as an operator.*
function deposit(uint256 assets, address receiver, address controller) external returns (uint256 shares);
mint
*Mints exactly shares Vault shares to receiver by claiming the Request of the controller.
- MUST emit the Deposit event.
- controller MUST equal msg.sender unless the controller has approved the msg.sender as an operator.*
function mint(uint256 shares, address receiver, address controller) external returns (uint256 assets);
Events
DepositRequest
event DepositRequest(
address indexed controller, address indexed owner, uint256 indexed requestId, address sender, uint256 assets
);
IERC7540Redeem
Inherits: IERC7540Operator
Interface of the asynchronous deposit Vault interface of ERC7540, as defined in https://eips.ethereum.org/EIPS/eip-7540
Functions
requestRedeem
*Assumes control of shares from sender into the Vault and submits a Request for asynchronous redeem.
- MUST support a redeem Request flow where the control of shares is taken from sender directly where msg.sender has ERC-20 approval over the shares of owner.
- MUST revert if all of shares cannot be requested for redeem.*
function requestRedeem(uint256 shares, address controller, address owner) external returns (uint256 requestId);
Parameters
| Name | Type | Description |
|---|---|---|
shares | uint256 | the amount of shares to be redeemed to transfer from owner |
controller | address | the controller of the request who will be able to operate the request |
owner | address | the source of the shares to be redeemed NOTE: most implementations will require pre-approval of the Vault with the Vault's share token. |
pendingRedeemRequest
*Returns the amount of requested shares in Pending state.
- MUST NOT include any shares in Claimable state for redeem or withdraw.
- MUST NOT show any variations depending on the caller.
- MUST NOT revert unless due to integer overflow caused by an unreasonably large input.*
function pendingRedeemRequest(uint256 requestId, address controller) external view returns (uint256 pendingShares);
claimableRedeemRequest
*Returns the amount of requested shares in Claimable state for the controller to redeem or withdraw.
- MUST NOT include any shares in Pending state for redeem or withdraw.
- MUST NOT show any variations depending on the caller.
- MUST NOT revert unless due to integer overflow caused by an unreasonably large input.*
function claimableRedeemRequest(uint256 requestId, address controller)
external
view
returns (uint256 claimableShares);
Events
RedeemRequest
event RedeemRequest(
address indexed controller, address indexed owner, uint256 indexed requestId, address sender, uint256 assets
);
IERC7540
Inherits: IERC7540Deposit, IERC7540Redeem, IERC7575
Interface of the fully asynchronous Vault interface of ERC7540, as defined in https://eips.ethereum.org/EIPS/eip-7540
IERC7575
Inherits: IERC165
Interface of the ERC7575 "Multi-Asset ERC-4626 Vaults", as defined in https://eips.ethereum.org/EIPS/eip-7575
Functions
asset
*Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.
- MUST be an ERC-20 token contract.
- MUST NOT revert.*
function asset() external view returns (address assetTokenAddress);
share
*Returns the address of the share token
- MUST be an ERC-20 token contract.
- MUST NOT revert.*
function share() external view returns (address shareTokenAddress);
convertToShares
*Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal scenario where all the conditions are met.
- MUST NOT be inclusive of any fees that are charged against assets in the Vault.
- MUST NOT show any variations depending on the caller.
- MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
- MUST NOT revert. NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and from.*
function convertToShares(uint256 assets) external view returns (uint256 shares);
convertToAssets
*Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal scenario where all the conditions are met.
- MUST NOT be inclusive of any fees that are charged against assets in the Vault.
- MUST NOT show any variations depending on the caller.
- MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
- MUST NOT revert. NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and from.*
function convertToAssets(uint256 shares) external view returns (uint256 assets);
totalAssets
*Returns the total amount of the underlying asset that is “managed” by Vault.
- SHOULD include any compounding that occurs from yield.
- MUST be inclusive of any fees that are charged against assets in the Vault.
- MUST NOT revert.*
function totalAssets() external view returns (uint256 totalManagedAssets);
maxDeposit
*Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver, through a deposit call.
- MUST return a limited value if receiver is subject to some deposit limit.
- MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.
- MUST NOT revert.*
function maxDeposit(address receiver) external view returns (uint256 maxAssets);
previewDeposit
*Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given current on-chain conditions.
- MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called in the same transaction.
- MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the deposit would be accepted, regardless if the user has enough tokens approved, etc.
- MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
- MUST NOT revert. NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by depositing.*
function previewDeposit(uint256 assets) external view returns (uint256 shares);
deposit
*Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.
- MUST emit the Deposit event.
- MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the deposit execution, and are accounted for during deposit.
- MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not approving enough underlying tokens to the Vault contract, etc). NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.*
function deposit(uint256 assets, address receiver) external returns (uint256 shares);
maxMint
*Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.
- MUST return a limited value if receiver is subject to some mint limit.
- MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.
- MUST NOT revert.*
function maxMint(address receiver) external view returns (uint256 maxShares);
previewMint
*Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given current on-chain conditions.
- MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the same transaction.
- MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint would be accepted, regardless if the user has enough tokens approved, etc.
- MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
- MUST NOT revert. NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by minting.*
function previewMint(uint256 shares) external view returns (uint256 assets);
mint
*Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.
- MUST emit the Deposit event.
- MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint execution, and are accounted for during mint.
- MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not approving enough underlying tokens to the Vault contract, etc). NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.*
function mint(uint256 shares, address receiver) external returns (uint256 assets);
maxWithdraw
*Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the Vault, through a withdraw call.
- MUST return a limited value if owner is subject to some withdrawal limit or timelock.
- MUST NOT revert.*
function maxWithdraw(address owner) external view returns (uint256 maxAssets);
previewWithdraw
*Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block, given current on-chain conditions.
- MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if called in the same transaction.
- MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though the withdrawal would be accepted, regardless if the user has enough shares, etc.
- MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
- MUST NOT revert. NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by depositing.*
function previewWithdraw(uint256 assets) external view returns (uint256 shares);
withdraw
*Burns shares from owner and sends exactly assets of underlying tokens to receiver.
- MUST emit the Withdraw event.
- MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the withdraw execution, and are accounted for during withdraw.
- MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner not having enough shares, etc). Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed. Those methods should be performed separately.*
function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);
maxRedeem
*Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, through a redeem call.
- MUST return a limited value if owner is subject to some withdrawal limit or timelock.
- MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.
- MUST NOT revert.*
function maxRedeem(address owner) external view returns (uint256 maxShares);
previewRedeem
*Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block, given current on-chain conditions.
- MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the same transaction.
- MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the redemption would be accepted, regardless if the user has enough shares, etc.
- MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
- MUST NOT revert. NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by redeeming.*
function previewRedeem(uint256 shares) external view returns (uint256 assets);
redeem
*Burns exactly shares from owner and sends assets of underlying tokens to receiver.
- MUST emit the Withdraw event.
- MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the redeem execution, and are accounted for during redeem.
- MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner not having enough shares, etc). NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed. Those methods should be performed separately.*
function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);
Events
Deposit
event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);
Withdraw
event Withdraw(address indexed sender, address indexed receiver, address indexed owner, uint256 assets, uint256 shares);
IERC7575Share
Inherits: IERC165
Interface of the ERC20 share token, as defined in https://eips.ethereum.org/EIPS/eip-7575
Functions
vault
Returns the address of the Vault for the given asset.
function vault(address asset) external view returns (address);
Parameters
| Name | Type | Description |
|---|---|---|
asset | address | the ERC-20 token to deposit with into the Vault |
Events
VaultUpdate
event VaultUpdate(address indexed asset, address vault);
IMulticall3
Functions
aggregate
function aggregate(Call[] calldata calls) external payable returns (uint256 blockNumber, bytes[] memory returnData);
aggregate3
function aggregate3(Call3[] calldata calls) external payable returns (Result[] memory returnData);
aggregate3Value
function aggregate3Value(Call3Value[] calldata calls) external payable returns (Result[] memory returnData);
blockAndAggregate
function blockAndAggregate(Call[] calldata calls)
external
payable
returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData);
getBasefee
function getBasefee() external view returns (uint256 basefee);
getBlockHash
function getBlockHash(uint256 blockNumber) external view returns (bytes32 blockHash);
getBlockNumber
function getBlockNumber() external view returns (uint256 blockNumber);
getChainId
function getChainId() external view returns (uint256 chainid);
getCurrentBlockCoinbase
function getCurrentBlockCoinbase() external view returns (address coinbase);
getCurrentBlockDifficulty
function getCurrentBlockDifficulty() external view returns (uint256 difficulty);
getCurrentBlockGasLimit
function getCurrentBlockGasLimit() external view returns (uint256 gaslimit);
getCurrentBlockTimestamp
function getCurrentBlockTimestamp() external view returns (uint256 timestamp);
getEthBalance
function getEthBalance(address addr) external view returns (uint256 balance);
getLastBlockHash
function getLastBlockHash() external view returns (bytes32 blockHash);
tryAggregate
function tryAggregate(bool requireSuccess, Call[] calldata calls)
external
payable
returns (Result[] memory returnData);
tryBlockAndAggregate
function tryBlockAndAggregate(bool requireSuccess, Call[] calldata calls)
external
payable
returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData);
Structs
Call
struct Call {
address target;
bytes callData;
}
Call3
struct Call3 {
address target;
bool allowFailure;
bytes callData;
}
Call3Value
struct Call3Value {
address target;
bool allowFailure;
uint256 value;
bytes callData;
}
Result
struct Result {
bool success;
bytes returnData;
}
CommonBase
State Variables
VM_ADDRESS
Cheat code address.
Calculated as address(uint160(uint256(keccak256("hevm cheat code")))).
address internal constant VM_ADDRESS = 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D;
CONSOLE
console.sol and console2.sol work by executing a staticcall to this address.
Calculated as address(uint160(uint88(bytes11("console.log")))).
address internal constant CONSOLE = 0x000000000000000000636F6e736F6c652e6c6f67;
CREATE2_FACTORY
Used when deploying with create2. Taken from https://github.com/Arachnid/deterministic-deployment-proxy.
address internal constant CREATE2_FACTORY = 0x4e59b44847b379578588920cA78FbF26c0B4956C;
DEFAULT_SENDER
The default address for tx.origin and msg.sender.
Calculated as address(uint160(uint256(keccak256("foundry default caller")))).
address internal constant DEFAULT_SENDER = 0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38;
DEFAULT_TEST_CONTRACT
The address of the first contract CREATEd by a running test contract.
When running tests, each test contract is CREATEd by DEFAULT_SENDER with nonce 1.
Calculated as VM.computeCreateAddress(VM.computeCreateAddress(DEFAULT_SENDER, 1), 1).
address internal constant DEFAULT_TEST_CONTRACT = 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f;
MULTICALL3_ADDRESS
Deterministic deployment address of the Multicall3 contract. Taken from https://www.multicall3.com.
address internal constant MULTICALL3_ADDRESS = 0xcA11bde05977b3631167028862bE2a173976CA11;
SECP256K1_ORDER
The order of the secp256k1 curve.
uint256 internal constant SECP256K1_ORDER =
115792089237316195423570985008687907852837564279074904382605163141518161494337;
UINT256_MAX
uint256 internal constant UINT256_MAX = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
vm
Vm internal constant vm = Vm(VM_ADDRESS);
stdstore
StdStorage internal stdstore;
TestBase
Inherits: CommonBase
ScriptBase
Inherits: CommonBase
State Variables
vmSafe
VmSafe internal constant vmSafe = VmSafe(VM_ADDRESS);
Script
Inherits: ScriptBase, StdChains, StdCheatsSafe, StdUtils
State Variables
IS_SCRIPT
bool public IS_SCRIPT = true;
StdAssertions
State Variables
vm
Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));
_failed
bool private _failed;
Functions
failed
function failed() public view returns (bool);
fail
function fail() internal virtual;
assertTrue
function assertTrue(bool data) internal pure virtual;
assertTrue
function assertTrue(bool data, string memory err) internal pure virtual;
assertFalse
function assertFalse(bool data) internal pure virtual;
assertFalse
function assertFalse(bool data, string memory err) internal pure virtual;
assertEq
function assertEq(bool left, bool right) internal pure virtual;
assertEq
function assertEq(bool left, bool right, string memory err) internal pure virtual;
assertEq
function assertEq(uint256 left, uint256 right) internal pure virtual;
assertEq
function assertEq(uint256 left, uint256 right, string memory err) internal pure virtual;
assertEqDecimal
function assertEqDecimal(uint256 left, uint256 right, uint256 decimals) internal pure virtual;
assertEqDecimal
function assertEqDecimal(uint256 left, uint256 right, uint256 decimals, string memory err) internal pure virtual;
assertEq
function assertEq(int256 left, int256 right) internal pure virtual;
assertEq
function assertEq(int256 left, int256 right, string memory err) internal pure virtual;
assertEqDecimal
function assertEqDecimal(int256 left, int256 right, uint256 decimals) internal pure virtual;
assertEqDecimal
function assertEqDecimal(int256 left, int256 right, uint256 decimals, string memory err) internal pure virtual;
assertEq
function assertEq(address left, address right) internal pure virtual;
assertEq
function assertEq(address left, address right, string memory err) internal pure virtual;
assertEq
function assertEq(bytes32 left, bytes32 right) internal pure virtual;
assertEq
function assertEq(bytes32 left, bytes32 right, string memory err) internal pure virtual;
assertEq32
function assertEq32(bytes32 left, bytes32 right) internal pure virtual;
assertEq32
function assertEq32(bytes32 left, bytes32 right, string memory err) internal pure virtual;
assertEq
function assertEq(string memory left, string memory right) internal pure virtual;
assertEq
function assertEq(string memory left, string memory right, string memory err) internal pure virtual;
assertEq
function assertEq(bytes memory left, bytes memory right) internal pure virtual;
assertEq
function assertEq(bytes memory left, bytes memory right, string memory err) internal pure virtual;
assertEq
function assertEq(bool[] memory left, bool[] memory right) internal pure virtual;
assertEq
function assertEq(bool[] memory left, bool[] memory right, string memory err) internal pure virtual;
assertEq
function assertEq(uint256[] memory left, uint256[] memory right) internal pure virtual;
assertEq
function assertEq(uint256[] memory left, uint256[] memory right, string memory err) internal pure virtual;
assertEq
function assertEq(int256[] memory left, int256[] memory right) internal pure virtual;
assertEq
function assertEq(int256[] memory left, int256[] memory right, string memory err) internal pure virtual;
assertEq
function assertEq(address[] memory left, address[] memory right) internal pure virtual;
assertEq
function assertEq(address[] memory left, address[] memory right, string memory err) internal pure virtual;
assertEq
function assertEq(bytes32[] memory left, bytes32[] memory right) internal pure virtual;
assertEq
function assertEq(bytes32[] memory left, bytes32[] memory right, string memory err) internal pure virtual;
assertEq
function assertEq(string[] memory left, string[] memory right) internal pure virtual;
assertEq
function assertEq(string[] memory left, string[] memory right, string memory err) internal pure virtual;
assertEq
function assertEq(bytes[] memory left, bytes[] memory right) internal pure virtual;
assertEq
function assertEq(bytes[] memory left, bytes[] memory right, string memory err) internal pure virtual;
assertEqUint
function assertEqUint(uint256 left, uint256 right) internal pure virtual;
assertNotEq
function assertNotEq(bool left, bool right) internal pure virtual;
assertNotEq
function assertNotEq(bool left, bool right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(uint256 left, uint256 right) internal pure virtual;
assertNotEq
function assertNotEq(uint256 left, uint256 right, string memory err) internal pure virtual;
assertNotEqDecimal
function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals) internal pure virtual;
assertNotEqDecimal
function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(int256 left, int256 right) internal pure virtual;
assertNotEq
function assertNotEq(int256 left, int256 right, string memory err) internal pure virtual;
assertNotEqDecimal
function assertNotEqDecimal(int256 left, int256 right, uint256 decimals) internal pure virtual;
assertNotEqDecimal
function assertNotEqDecimal(int256 left, int256 right, uint256 decimals, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(address left, address right) internal pure virtual;
assertNotEq
function assertNotEq(address left, address right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(bytes32 left, bytes32 right) internal pure virtual;
assertNotEq
function assertNotEq(bytes32 left, bytes32 right, string memory err) internal pure virtual;
assertNotEq32
function assertNotEq32(bytes32 left, bytes32 right) internal pure virtual;
assertNotEq32
function assertNotEq32(bytes32 left, bytes32 right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(string memory left, string memory right) internal pure virtual;
assertNotEq
function assertNotEq(string memory left, string memory right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(bytes memory left, bytes memory right) internal pure virtual;
assertNotEq
function assertNotEq(bytes memory left, bytes memory right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(bool[] memory left, bool[] memory right) internal pure virtual;
assertNotEq
function assertNotEq(bool[] memory left, bool[] memory right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(uint256[] memory left, uint256[] memory right) internal pure virtual;
assertNotEq
function assertNotEq(uint256[] memory left, uint256[] memory right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(int256[] memory left, int256[] memory right) internal pure virtual;
assertNotEq
function assertNotEq(int256[] memory left, int256[] memory right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(address[] memory left, address[] memory right) internal pure virtual;
assertNotEq
function assertNotEq(address[] memory left, address[] memory right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(bytes32[] memory left, bytes32[] memory right) internal pure virtual;
assertNotEq
function assertNotEq(bytes32[] memory left, bytes32[] memory right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(string[] memory left, string[] memory right) internal pure virtual;
assertNotEq
function assertNotEq(string[] memory left, string[] memory right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(bytes[] memory left, bytes[] memory right) internal pure virtual;
assertNotEq
function assertNotEq(bytes[] memory left, bytes[] memory right, string memory err) internal pure virtual;
assertLt
function assertLt(uint256 left, uint256 right) internal pure virtual;
assertLt
function assertLt(uint256 left, uint256 right, string memory err) internal pure virtual;
assertLtDecimal
function assertLtDecimal(uint256 left, uint256 right, uint256 decimals) internal pure virtual;
assertLtDecimal
function assertLtDecimal(uint256 left, uint256 right, uint256 decimals, string memory err) internal pure virtual;
assertLt
function assertLt(int256 left, int256 right) internal pure virtual;
assertLt
function assertLt(int256 left, int256 right, string memory err) internal pure virtual;
assertLtDecimal
function assertLtDecimal(int256 left, int256 right, uint256 decimals) internal pure virtual;
assertLtDecimal
function assertLtDecimal(int256 left, int256 right, uint256 decimals, string memory err) internal pure virtual;
assertGt
function assertGt(uint256 left, uint256 right) internal pure virtual;
assertGt
function assertGt(uint256 left, uint256 right, string memory err) internal pure virtual;
assertGtDecimal
function assertGtDecimal(uint256 left, uint256 right, uint256 decimals) internal pure virtual;
assertGtDecimal
function assertGtDecimal(uint256 left, uint256 right, uint256 decimals, string memory err) internal pure virtual;
assertGt
function assertGt(int256 left, int256 right) internal pure virtual;
assertGt
function assertGt(int256 left, int256 right, string memory err) internal pure virtual;
assertGtDecimal
function assertGtDecimal(int256 left, int256 right, uint256 decimals) internal pure virtual;
assertGtDecimal
function assertGtDecimal(int256 left, int256 right, uint256 decimals, string memory err) internal pure virtual;
assertLe
function assertLe(uint256 left, uint256 right) internal pure virtual;
assertLe
function assertLe(uint256 left, uint256 right, string memory err) internal pure virtual;
assertLeDecimal
function assertLeDecimal(uint256 left, uint256 right, uint256 decimals) internal pure virtual;
assertLeDecimal
function assertLeDecimal(uint256 left, uint256 right, uint256 decimals, string memory err) internal pure virtual;
assertLe
function assertLe(int256 left, int256 right) internal pure virtual;
assertLe
function assertLe(int256 left, int256 right, string memory err) internal pure virtual;
assertLeDecimal
function assertLeDecimal(int256 left, int256 right, uint256 decimals) internal pure virtual;
assertLeDecimal
function assertLeDecimal(int256 left, int256 right, uint256 decimals, string memory err) internal pure virtual;
assertGe
function assertGe(uint256 left, uint256 right) internal pure virtual;
assertGe
function assertGe(uint256 left, uint256 right, string memory err) internal pure virtual;
assertGeDecimal
function assertGeDecimal(uint256 left, uint256 right, uint256 decimals) internal pure virtual;
assertGeDecimal
function assertGeDecimal(uint256 left, uint256 right, uint256 decimals, string memory err) internal pure virtual;
assertGe
function assertGe(int256 left, int256 right) internal pure virtual;
assertGe
function assertGe(int256 left, int256 right, string memory err) internal pure virtual;
assertGeDecimal
function assertGeDecimal(int256 left, int256 right, uint256 decimals) internal pure virtual;
assertGeDecimal
function assertGeDecimal(int256 left, int256 right, uint256 decimals, string memory err) internal pure virtual;
assertApproxEqAbs
function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta) internal pure virtual;
assertApproxEqAbs
function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta, string memory err) internal pure virtual;
assertApproxEqAbsDecimal
function assertApproxEqAbsDecimal(uint256 left, uint256 right, uint256 maxDelta, uint256 decimals)
internal
pure
virtual;
assertApproxEqAbsDecimal
function assertApproxEqAbsDecimal(uint256 left, uint256 right, uint256 maxDelta, uint256 decimals, string memory err)
internal
pure
virtual;
assertApproxEqAbs
function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta) internal pure virtual;
assertApproxEqAbs
function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta, string memory err) internal pure virtual;
assertApproxEqAbsDecimal
function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals)
internal
pure
virtual;
assertApproxEqAbsDecimal
function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals, string memory err)
internal
pure
virtual;
assertApproxEqRel
function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta) internal pure virtual;
assertApproxEqRel
function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta, string memory err)
internal
pure
virtual;
assertApproxEqRelDecimal
function assertApproxEqRelDecimal(uint256 left, uint256 right, uint256 maxPercentDelta, uint256 decimals)
internal
pure
virtual;
assertApproxEqRelDecimal
function assertApproxEqRelDecimal(
uint256 left,
uint256 right,
uint256 maxPercentDelta,
uint256 decimals,
string memory err
) internal pure virtual;
assertApproxEqRel
function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta) internal pure virtual;
assertApproxEqRel
function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta, string memory err)
internal
pure
virtual;
assertApproxEqRelDecimal
function assertApproxEqRelDecimal(int256 left, int256 right, uint256 maxPercentDelta, uint256 decimals)
internal
pure
virtual;
assertApproxEqRelDecimal
function assertApproxEqRelDecimal(
int256 left,
int256 right,
uint256 maxPercentDelta,
uint256 decimals,
string memory err
) internal pure virtual;
checkEq0
function checkEq0(bytes memory left, bytes memory right) internal pure returns (bool);
assertEq0
function assertEq0(bytes memory left, bytes memory right) internal pure virtual;
assertEq0
function assertEq0(bytes memory left, bytes memory right, string memory err) internal pure virtual;
assertNotEq0
function assertNotEq0(bytes memory left, bytes memory right) internal pure virtual;
assertNotEq0
function assertNotEq0(bytes memory left, bytes memory right, string memory err) internal pure virtual;
assertEqCall
function assertEqCall(address target, bytes memory callDataA, bytes memory callDataB) internal virtual;
assertEqCall
function assertEqCall(address targetA, bytes memory callDataA, address targetB, bytes memory callDataB)
internal
virtual;
assertEqCall
function assertEqCall(address target, bytes memory callDataA, bytes memory callDataB, bool strictRevertData)
internal
virtual;
assertEqCall
function assertEqCall(
address targetA,
bytes memory callDataA,
address targetB,
bytes memory callDataB,
bool strictRevertData
) internal virtual;
Events
log
event log(string);
logs
event logs(bytes);
log_address
event log_address(address);
log_bytes32
event log_bytes32(bytes32);
log_int
event log_int(int256);
log_uint
event log_uint(uint256);
log_bytes
event log_bytes(bytes);
log_string
event log_string(string);
log_named_address
event log_named_address(string key, address val);
log_named_bytes32
event log_named_bytes32(string key, bytes32 val);
log_named_decimal_int
event log_named_decimal_int(string key, int256 val, uint256 decimals);
log_named_decimal_uint
event log_named_decimal_uint(string key, uint256 val, uint256 decimals);
log_named_int
event log_named_int(string key, int256 val);
log_named_uint
event log_named_uint(string key, uint256 val);
log_named_bytes
event log_named_bytes(string key, bytes val);
log_named_string
event log_named_string(string key, string val);
log_array
event log_array(uint256[] val);
log_array
event log_array(int256[] val);
log_array
event log_array(address[] val);
log_named_array
event log_named_array(string key, uint256[] val);
log_named_array
event log_named_array(string key, int256[] val);
log_named_array
event log_named_array(string key, address[] val);
StdChains
StdChains provides information about EVM compatible chains that can be used in scripts/tests.
For each chain, the chain's name, chain ID, and a default RPC URL are provided. Chains are
identified by their alias, which is the same as the alias in the [rpc_endpoints] section of
the foundry.toml file. For best UX, ensure the alias in the foundry.toml file match the
alias used in this contract, which can be found as the first argument to the
setChainWithDefaultRpcUrl call in the initializeStdChains function.
There are two main ways to use this contract:
- Set a chain with
setChain(string memory chainAlias, ChainData memory chain)orsetChain(string memory chainAlias, Chain memory chain) - Get a chain with
getChain(string memory chainAlias)orgetChain(uint256 chainId). The first time either of those are used, chains are initialized with the default set of RPC URLs. This is done ininitializeStdChains, which usessetChainWithDefaultRpcUrl. Defaults are recorded indefaultRpcUrls. ThesetChainfunction is straightforward, and it simply saves off the given chain data. ThegetChainmethods usegetChainWithUpdatedRpcUrlto return a chain. For example, let's say we want to retrieve the RPC URL formainnet:
- If you have specified data with
setChain, it will return that. - If you have configured a mainnet RPC URL in
foundry.toml, it will return the URL, provided it is valid (e.g. a URL is specified, or an environment variable is given and exists). - If neither of the above conditions is met, the default data is returned.
Summarizing the above, the prioritization hierarchy is
setChain->foundry.toml-> environment variable -> defaults.
State Variables
vm
VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));
stdChainsInitialized
bool private stdChainsInitialized;
chains
mapping(string => Chain) private chains;
defaultRpcUrls
mapping(string => string) private defaultRpcUrls;
idToAlias
mapping(uint256 => string) private idToAlias;
fallbackToDefaultRpcUrls
bool private fallbackToDefaultRpcUrls = true;
Functions
getChain
function getChain(string memory chainAlias) internal virtual returns (Chain memory chain);
getChain
function getChain(uint256 chainId) internal virtual returns (Chain memory chain);
setChain
function setChain(string memory chainAlias, ChainData memory chain) internal virtual;
setChain
function setChain(string memory chainAlias, Chain memory chain) internal virtual;
_toUpper
function _toUpper(string memory str) private pure returns (string memory);
getChainWithUpdatedRpcUrl
function getChainWithUpdatedRpcUrl(string memory chainAlias, Chain memory chain) private view returns (Chain memory);
setFallbackToDefaultRpcUrls
function setFallbackToDefaultRpcUrls(bool useDefault) internal;
initializeStdChains
function initializeStdChains() private;
setChainWithDefaultRpcUrl
function setChainWithDefaultRpcUrl(string memory chainAlias, ChainData memory chain) private;
Structs
ChainData
struct ChainData {
string name;
uint256 chainId;
string rpcUrl;
}
Chain
struct Chain {
string name;
uint256 chainId;
string chainAlias;
string rpcUrl;
}
StdCheatsSafe
State Variables
vm
Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));
UINT256_MAX
uint256 private constant UINT256_MAX = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
gasMeteringOff
bool private gasMeteringOff;
Functions
assumeNotBlacklisted
function assumeNotBlacklisted(address token, address addr) internal view virtual;
assumeNoBlacklisted
function assumeNoBlacklisted(address token, address addr) internal view virtual;
assumeAddressIsNot
function assumeAddressIsNot(address addr, AddressType addressType) internal virtual;
assumeAddressIsNot
function assumeAddressIsNot(address addr, AddressType addressType1, AddressType addressType2) internal virtual;
assumeAddressIsNot
function assumeAddressIsNot(address addr, AddressType addressType1, AddressType addressType2, AddressType addressType3)
internal
virtual;
assumeAddressIsNot
function assumeAddressIsNot(
address addr,
AddressType addressType1,
AddressType addressType2,
AddressType addressType3,
AddressType addressType4
) internal virtual;
_isPayable
function _isPayable(address addr) private returns (bool);
assumePayable
function assumePayable(address addr) internal virtual;
assumeNotPayable
function assumeNotPayable(address addr) internal virtual;
assumeNotZeroAddress
function assumeNotZeroAddress(address addr) internal pure virtual;
assumeNotPrecompile
function assumeNotPrecompile(address addr) internal pure virtual;
assumeNotPrecompile
function assumeNotPrecompile(address addr, uint256 chainId) internal pure virtual;
assumeNotForgeAddress
function assumeNotForgeAddress(address addr) internal pure virtual;
assumeUnusedAddress
function assumeUnusedAddress(address addr) internal view virtual;
readEIP1559ScriptArtifact
function readEIP1559ScriptArtifact(string memory path) internal view virtual returns (EIP1559ScriptArtifact memory);
rawToConvertedEIPTx1559s
function rawToConvertedEIPTx1559s(RawTx1559[] memory rawTxs) internal pure virtual returns (Tx1559[] memory);
rawToConvertedEIPTx1559
function rawToConvertedEIPTx1559(RawTx1559 memory rawTx) internal pure virtual returns (Tx1559 memory);
rawToConvertedEIP1559Detail
function rawToConvertedEIP1559Detail(RawTx1559Detail memory rawDetail)
internal
pure
virtual
returns (Tx1559Detail memory);
readTx1559s
function readTx1559s(string memory path) internal view virtual returns (Tx1559[] memory);
readTx1559
function readTx1559(string memory path, uint256 index) internal view virtual returns (Tx1559 memory);
readReceipts
function readReceipts(string memory path) internal view virtual returns (Receipt[] memory);
readReceipt
function readReceipt(string memory path, uint256 index) internal view virtual returns (Receipt memory);
rawToConvertedReceipts
function rawToConvertedReceipts(RawReceipt[] memory rawReceipts) internal pure virtual returns (Receipt[] memory);
rawToConvertedReceipt
function rawToConvertedReceipt(RawReceipt memory rawReceipt) internal pure virtual returns (Receipt memory);
rawToConvertedReceiptLogs
function rawToConvertedReceiptLogs(RawReceiptLog[] memory rawLogs)
internal
pure
virtual
returns (ReceiptLog[] memory);
deployCode
function deployCode(string memory what, bytes memory args) internal virtual returns (address addr);
deployCode
function deployCode(string memory what) internal virtual returns (address addr);
deployCode
deploy contract with value on construction
function deployCode(string memory what, bytes memory args, uint256 val) internal virtual returns (address addr);
deployCode
function deployCode(string memory what, uint256 val) internal virtual returns (address addr);
makeAddrAndKey
function makeAddrAndKey(string memory name) internal virtual returns (address addr, uint256 privateKey);
makeAddr
function makeAddr(string memory name) internal virtual returns (address addr);
destroyAccount
function destroyAccount(address who, address beneficiary) internal virtual;
makeAccount
function makeAccount(string memory name) internal virtual returns (Account memory account);
deriveRememberKey
function deriveRememberKey(string memory mnemonic, uint32 index)
internal
virtual
returns (address who, uint256 privateKey);
_bytesToUint
function _bytesToUint(bytes memory b) private pure returns (uint256);
isFork
function isFork() internal view virtual returns (bool status);
skipWhenForking
modifier skipWhenForking();
skipWhenNotForking
modifier skipWhenNotForking();
noGasMetering
modifier noGasMetering();
_viewChainId
function _viewChainId() private view returns (uint256 chainId);
_pureChainId
function _pureChainId() private pure returns (uint256 chainId);
Structs
RawTx1559
struct RawTx1559 {
string[] arguments;
address contractAddress;
string contractName;
string functionSig;
bytes32 hash;
RawTx1559Detail txDetail;
string opcode;
}
RawTx1559Detail
struct RawTx1559Detail {
AccessList[] accessList;
bytes data;
address from;
bytes gas;
bytes nonce;
address to;
bytes txType;
bytes value;
}
Tx1559
struct Tx1559 {
string[] arguments;
address contractAddress;
string contractName;
string functionSig;
bytes32 hash;
Tx1559Detail txDetail;
string opcode;
}
Tx1559Detail
struct Tx1559Detail {
AccessList[] accessList;
bytes data;
address from;
uint256 gas;
uint256 nonce;
address to;
uint256 txType;
uint256 value;
}
TxLegacy
struct TxLegacy {
string[] arguments;
address contractAddress;
string contractName;
string functionSig;
string hash;
string opcode;
TxDetailLegacy transaction;
}
TxDetailLegacy
struct TxDetailLegacy {
AccessList[] accessList;
uint256 chainId;
bytes data;
address from;
uint256 gas;
uint256 gasPrice;
bytes32 hash;
uint256 nonce;
bytes1 opcode;
bytes32 r;
bytes32 s;
uint256 txType;
address to;
uint8 v;
uint256 value;
}
AccessList
struct AccessList {
address accessAddress;
bytes32[] storageKeys;
}
RawReceipt
struct RawReceipt {
bytes32 blockHash;
bytes blockNumber;
address contractAddress;
bytes cumulativeGasUsed;
bytes effectiveGasPrice;
address from;
bytes gasUsed;
RawReceiptLog[] logs;
bytes logsBloom;
bytes status;
address to;
bytes32 transactionHash;
bytes transactionIndex;
}
Receipt
struct Receipt {
bytes32 blockHash;
uint256 blockNumber;
address contractAddress;
uint256 cumulativeGasUsed;
uint256 effectiveGasPrice;
address from;
uint256 gasUsed;
ReceiptLog[] logs;
bytes logsBloom;
uint256 status;
address to;
bytes32 transactionHash;
uint256 transactionIndex;
}
EIP1559ScriptArtifact
struct EIP1559ScriptArtifact {
string[] libraries;
string path;
string[] pending;
Receipt[] receipts;
uint256 timestamp;
Tx1559[] transactions;
TxReturn[] txReturns;
}
RawEIP1559ScriptArtifact
struct RawEIP1559ScriptArtifact {
string[] libraries;
string path;
string[] pending;
RawReceipt[] receipts;
TxReturn[] txReturns;
uint256 timestamp;
RawTx1559[] transactions;
}
RawReceiptLog
struct RawReceiptLog {
address logAddress;
bytes32 blockHash;
bytes blockNumber;
bytes data;
bytes logIndex;
bool removed;
bytes32[] topics;
bytes32 transactionHash;
bytes transactionIndex;
bytes transactionLogIndex;
}
ReceiptLog
struct ReceiptLog {
address logAddress;
bytes32 blockHash;
uint256 blockNumber;
bytes data;
uint256 logIndex;
bytes32[] topics;
uint256 transactionIndex;
uint256 transactionLogIndex;
bool removed;
}
TxReturn
struct TxReturn {
string internalType;
string value;
}
Account
struct Account {
address addr;
uint256 key;
}
Enums
AddressType
enum AddressType {
Payable,
NonPayable,
ZeroAddress,
Precompile,
ForgeAddress
}
StdCheats
Inherits: StdCheatsSafe
State Variables
stdstore
StdStorage private stdstore;
vm
Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));
CONSOLE2_ADDRESS
address private constant CONSOLE2_ADDRESS = 0x000000000000000000636F6e736F6c652e6c6f67;
Functions
skip
function skip(uint256 time) internal virtual;
rewind
function rewind(uint256 time) internal virtual;
hoax
function hoax(address msgSender) internal virtual;
hoax
function hoax(address msgSender, uint256 give) internal virtual;
hoax
function hoax(address msgSender, address origin) internal virtual;
hoax
function hoax(address msgSender, address origin, uint256 give) internal virtual;
startHoax
function startHoax(address msgSender) internal virtual;
startHoax
function startHoax(address msgSender, uint256 give) internal virtual;
startHoax
function startHoax(address msgSender, address origin) internal virtual;
startHoax
function startHoax(address msgSender, address origin, uint256 give) internal virtual;
changePrank
function changePrank(address msgSender) internal virtual;
changePrank
function changePrank(address msgSender, address txOrigin) internal virtual;
deal
function deal(address to, uint256 give) internal virtual;
deal
function deal(address token, address to, uint256 give) internal virtual;
dealERC1155
function dealERC1155(address token, address to, uint256 id, uint256 give) internal virtual;
deal
function deal(address token, address to, uint256 give, bool adjust) internal virtual;
dealERC1155
function dealERC1155(address token, address to, uint256 id, uint256 give, bool adjust) internal virtual;
dealERC721
function dealERC721(address token, address to, uint256 id) internal virtual;
deployCodeTo
function deployCodeTo(string memory what, address where) internal virtual;
deployCodeTo
function deployCodeTo(string memory what, bytes memory args, address where) internal virtual;
deployCodeTo
function deployCodeTo(string memory what, bytes memory args, uint256 value, address where) internal virtual;
console2_log_StdCheats
function console2_log_StdCheats(string memory p0) private view;
StdConstants
State Variables
VM
Cheat code address.
Calculated as address(uint160(uint256(keccak256("hevm cheat code")))).
Vm internal constant VM = Vm(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
CONSOLE
console.sol and console2.sol work by executing a staticcall to this address.
Calculated as address(uint160(uint88(bytes11("console.log")))).
address internal constant CONSOLE = 0x000000000000000000636F6e736F6c652e6c6f67;
CREATE2_FACTORY
Used when deploying with create2. Taken from https://github.com/Arachnid/deterministic-deployment-proxy.
address internal constant CREATE2_FACTORY = 0x4e59b44847b379578588920cA78FbF26c0B4956C;
DEFAULT_SENDER
The default address for tx.origin and msg.sender.
Calculated as address(uint160(uint256(keccak256("foundry default caller")))).
address internal constant DEFAULT_SENDER = 0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38;
DEFAULT_TEST_CONTRACT
The address of the first contract CREATEd by a running test contract.
When running tests, each test contract is CREATEd by DEFAULT_SENDER with nonce 1.
Calculated as VM.computeCreateAddress(VM.computeCreateAddress(DEFAULT_SENDER, 1), 1).
address internal constant DEFAULT_TEST_CONTRACT = 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f;
MULTICALL3_ADDRESS
Deterministic deployment address of the Multicall3 contract. Taken from https://www.multicall3.com.
IMulticall3 internal constant MULTICALL3_ADDRESS = IMulticall3(0xcA11bde05977b3631167028862bE2a173976CA11);
SECP256K1_ORDER
The order of the secp256k1 curve.
uint256 internal constant SECP256K1_ORDER =
115792089237316195423570985008687907852837564279074904382605163141518161494337;
stdError
State Variables
assertionError
bytes public constant assertionError = abi.encodeWithSignature("Panic(uint256)", 0x01);
arithmeticError
bytes public constant arithmeticError = abi.encodeWithSignature("Panic(uint256)", 0x11);
divisionError
bytes public constant divisionError = abi.encodeWithSignature("Panic(uint256)", 0x12);
enumConversionError
bytes public constant enumConversionError = abi.encodeWithSignature("Panic(uint256)", 0x21);
encodeStorageError
bytes public constant encodeStorageError = abi.encodeWithSignature("Panic(uint256)", 0x22);
popError
bytes public constant popError = abi.encodeWithSignature("Panic(uint256)", 0x31);
indexOOBError
bytes public constant indexOOBError = abi.encodeWithSignature("Panic(uint256)", 0x32);
memOverflowError
bytes public constant memOverflowError = abi.encodeWithSignature("Panic(uint256)", 0x41);
zeroVarError
bytes public constant zeroVarError = abi.encodeWithSignature("Panic(uint256)", 0x51);
StdInvariant
State Variables
_excludedContracts
address[] private _excludedContracts;
_excludedSenders
address[] private _excludedSenders;
_targetedContracts
address[] private _targetedContracts;
_targetedSenders
address[] private _targetedSenders;
_excludedArtifacts
string[] private _excludedArtifacts;
_targetedArtifacts
string[] private _targetedArtifacts;
_targetedArtifactSelectors
FuzzArtifactSelector[] private _targetedArtifactSelectors;
_excludedSelectors
FuzzSelector[] private _excludedSelectors;
_targetedSelectors
FuzzSelector[] private _targetedSelectors;
_targetedInterfaces
FuzzInterface[] private _targetedInterfaces;
Functions
excludeContract
function excludeContract(address newExcludedContract_) internal;
excludeSelector
function excludeSelector(FuzzSelector memory newExcludedSelector_) internal;
excludeSender
function excludeSender(address newExcludedSender_) internal;
excludeArtifact
function excludeArtifact(string memory newExcludedArtifact_) internal;
targetArtifact
function targetArtifact(string memory newTargetedArtifact_) internal;
targetArtifactSelector
function targetArtifactSelector(FuzzArtifactSelector memory newTargetedArtifactSelector_) internal;
targetContract
function targetContract(address newTargetedContract_) internal;
targetSelector
function targetSelector(FuzzSelector memory newTargetedSelector_) internal;
targetSender
function targetSender(address newTargetedSender_) internal;
targetInterface
function targetInterface(FuzzInterface memory newTargetedInterface_) internal;
excludeArtifacts
function excludeArtifacts() public view returns (string[] memory excludedArtifacts_);
excludeContracts
function excludeContracts() public view returns (address[] memory excludedContracts_);
excludeSelectors
function excludeSelectors() public view returns (FuzzSelector[] memory excludedSelectors_);
excludeSenders
function excludeSenders() public view returns (address[] memory excludedSenders_);
targetArtifacts
function targetArtifacts() public view returns (string[] memory targetedArtifacts_);
targetArtifactSelectors
function targetArtifactSelectors() public view returns (FuzzArtifactSelector[] memory targetedArtifactSelectors_);
targetContracts
function targetContracts() public view returns (address[] memory targetedContracts_);
targetSelectors
function targetSelectors() public view returns (FuzzSelector[] memory targetedSelectors_);
targetSenders
function targetSenders() public view returns (address[] memory targetedSenders_);
targetInterfaces
function targetInterfaces() public view returns (FuzzInterface[] memory targetedInterfaces_);
Structs
FuzzSelector
struct FuzzSelector {
address addr;
bytes4[] selectors;
}
FuzzArtifactSelector
struct FuzzArtifactSelector {
string artifact;
bytes4[] selectors;
}
FuzzInterface
struct FuzzInterface {
address addr;
string[] artifacts;
}
stdJson
State Variables
vm
VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));
Functions
keyExists
function keyExists(string memory json, string memory key) internal view returns (bool);
parseRaw
function parseRaw(string memory json, string memory key) internal pure returns (bytes memory);
readUint
function readUint(string memory json, string memory key) internal pure returns (uint256);
readUintArray
function readUintArray(string memory json, string memory key) internal pure returns (uint256[] memory);
readInt
function readInt(string memory json, string memory key) internal pure returns (int256);
readIntArray
function readIntArray(string memory json, string memory key) internal pure returns (int256[] memory);
readBytes32
function readBytes32(string memory json, string memory key) internal pure returns (bytes32);
readBytes32Array
function readBytes32Array(string memory json, string memory key) internal pure returns (bytes32[] memory);
readString
function readString(string memory json, string memory key) internal pure returns (string memory);
readStringArray
function readStringArray(string memory json, string memory key) internal pure returns (string[] memory);
readAddress
function readAddress(string memory json, string memory key) internal pure returns (address);
readAddressArray
function readAddressArray(string memory json, string memory key) internal pure returns (address[] memory);
readBool
function readBool(string memory json, string memory key) internal pure returns (bool);
readBoolArray
function readBoolArray(string memory json, string memory key) internal pure returns (bool[] memory);
readBytes
function readBytes(string memory json, string memory key) internal pure returns (bytes memory);
readBytesArray
function readBytesArray(string memory json, string memory key) internal pure returns (bytes[] memory);
readUintOr
function readUintOr(string memory json, string memory key, uint256 defaultValue) internal view returns (uint256);
readUintArrayOr
function readUintArrayOr(string memory json, string memory key, uint256[] memory defaultValue)
internal
view
returns (uint256[] memory);
readIntOr
function readIntOr(string memory json, string memory key, int256 defaultValue) internal view returns (int256);
readIntArrayOr
function readIntArrayOr(string memory json, string memory key, int256[] memory defaultValue)
internal
view
returns (int256[] memory);
readBytes32Or
function readBytes32Or(string memory json, string memory key, bytes32 defaultValue) internal view returns (bytes32);
readBytes32ArrayOr
function readBytes32ArrayOr(string memory json, string memory key, bytes32[] memory defaultValue)
internal
view
returns (bytes32[] memory);
readStringOr
function readStringOr(string memory json, string memory key, string memory defaultValue)
internal
view
returns (string memory);
readStringArrayOr
function readStringArrayOr(string memory json, string memory key, string[] memory defaultValue)
internal
view
returns (string[] memory);
readAddressOr
function readAddressOr(string memory json, string memory key, address defaultValue) internal view returns (address);
readAddressArrayOr
function readAddressArrayOr(string memory json, string memory key, address[] memory defaultValue)
internal
view
returns (address[] memory);
readBoolOr
function readBoolOr(string memory json, string memory key, bool defaultValue) internal view returns (bool);
readBoolArrayOr
function readBoolArrayOr(string memory json, string memory key, bool[] memory defaultValue)
internal
view
returns (bool[] memory);
readBytesOr
function readBytesOr(string memory json, string memory key, bytes memory defaultValue)
internal
view
returns (bytes memory);
readBytesArrayOr
function readBytesArrayOr(string memory json, string memory key, bytes[] memory defaultValue)
internal
view
returns (bytes[] memory);
serialize
function serialize(string memory jsonKey, string memory rootObject) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bool value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bool[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, uint256 value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, uint256[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, int256 value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, int256[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, address value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, address[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bytes32 value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bytes32[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bytes memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bytes[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, string memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, string[] memory value) internal returns (string memory);
write
function write(string memory jsonKey, string memory path) internal;
write
function write(string memory jsonKey, string memory path, string memory valueKey) internal;
stdMath
State Variables
INT256_MIN
int256 private constant INT256_MIN = -57896044618658097711785492504343953926634992332820282019728792003956564819968;
Functions
abs
function abs(int256 a) internal pure returns (uint256);
delta
function delta(uint256 a, uint256 b) internal pure returns (uint256);
delta
function delta(int256 a, int256 b) internal pure returns (uint256);
percentDelta
function percentDelta(uint256 a, uint256 b) internal pure returns (uint256);
percentDelta
function percentDelta(int256 a, int256 b) internal pure returns (uint256);
FindData
struct FindData {
uint256 slot;
uint256 offsetLeft;
uint256 offsetRight;
bool found;
}
StdStorage
struct StdStorage {
mapping(address => mapping(bytes4 => mapping(bytes32 => FindData))) finds;
bytes32[] _keys;
bytes4 _sig;
uint256 _depth;
address _target;
bytes32 _set;
bool _enable_packed_slots;
bytes _calldata;
}
stdStorageSafe
State Variables
vm
Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));
UINT256_MAX
uint256 constant UINT256_MAX = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
Functions
sigs
function sigs(string memory sigStr) internal pure returns (bytes4);
getCallParams
function getCallParams(StdStorage storage self) internal view returns (bytes memory);
callTarget
function callTarget(StdStorage storage self) internal view returns (bool, bytes32);
checkSlotMutatesCall
function checkSlotMutatesCall(StdStorage storage self, bytes32 slot) internal returns (bool);
findOffset
function findOffset(StdStorage storage self, bytes32 slot, bool left) internal returns (bool, uint256);
findOffsets
function findOffsets(StdStorage storage self, bytes32 slot) internal returns (bool, uint256, uint256);
find
function find(StdStorage storage self) internal returns (FindData storage);
find
find an arbitrary storage slot given a function sig, input data, address of the contract and a value to check against
function find(StdStorage storage self, bool _clear) internal returns (FindData storage);
target
function target(StdStorage storage self, address _target) internal returns (StdStorage storage);
sig
function sig(StdStorage storage self, bytes4 _sig) internal returns (StdStorage storage);
sig
function sig(StdStorage storage self, string memory _sig) internal returns (StdStorage storage);
with_calldata
function with_calldata(StdStorage storage self, bytes memory _calldata) internal returns (StdStorage storage);
with_key
function with_key(StdStorage storage self, address who) internal returns (StdStorage storage);
with_key
function with_key(StdStorage storage self, uint256 amt) internal returns (StdStorage storage);
with_key
function with_key(StdStorage storage self, bytes32 key) internal returns (StdStorage storage);
enable_packed_slots
function enable_packed_slots(StdStorage storage self) internal returns (StdStorage storage);
depth
function depth(StdStorage storage self, uint256 _depth) internal returns (StdStorage storage);
read
function read(StdStorage storage self) private returns (bytes memory);
read_bytes32
function read_bytes32(StdStorage storage self) internal returns (bytes32);
read_bool
function read_bool(StdStorage storage self) internal returns (bool);
read_address
function read_address(StdStorage storage self) internal returns (address);
read_uint
function read_uint(StdStorage storage self) internal returns (uint256);
read_int
function read_int(StdStorage storage self) internal returns (int256);
parent
function parent(StdStorage storage self) internal returns (uint256, bytes32);
root
function root(StdStorage storage self) internal returns (uint256);
bytesToBytes32
function bytesToBytes32(bytes memory b, uint256 offset) private pure returns (bytes32);
flatten
function flatten(bytes32[] memory b) private pure returns (bytes memory);
clear
function clear(StdStorage storage self) internal;
getMaskByOffsets
function getMaskByOffsets(uint256 offsetLeft, uint256 offsetRight) internal pure returns (uint256 mask);
getUpdatedSlotValue
function getUpdatedSlotValue(bytes32 curValue, uint256 varValue, uint256 offsetLeft, uint256 offsetRight)
internal
pure
returns (bytes32 newValue);
Events
SlotFound
event SlotFound(address who, bytes4 fsig, bytes32 keysHash, uint256 slot);
WARNING_UninitedSlot
event WARNING_UninitedSlot(address who, uint256 slot);
stdStorage
State Variables
vm
Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));
Functions
sigs
function sigs(string memory sigStr) internal pure returns (bytes4);
find
function find(StdStorage storage self) internal returns (uint256);
find
function find(StdStorage storage self, bool _clear) internal returns (uint256);
target
function target(StdStorage storage self, address _target) internal returns (StdStorage storage);
sig
function sig(StdStorage storage self, bytes4 _sig) internal returns (StdStorage storage);
sig
function sig(StdStorage storage self, string memory _sig) internal returns (StdStorage storage);
with_key
function with_key(StdStorage storage self, address who) internal returns (StdStorage storage);
with_key
function with_key(StdStorage storage self, uint256 amt) internal returns (StdStorage storage);
with_key
function with_key(StdStorage storage self, bytes32 key) internal returns (StdStorage storage);
with_calldata
function with_calldata(StdStorage storage self, bytes memory _calldata) internal returns (StdStorage storage);
enable_packed_slots
function enable_packed_slots(StdStorage storage self) internal returns (StdStorage storage);
depth
function depth(StdStorage storage self, uint256 _depth) internal returns (StdStorage storage);
clear
function clear(StdStorage storage self) internal;
checked_write
function checked_write(StdStorage storage self, address who) internal;
checked_write
function checked_write(StdStorage storage self, uint256 amt) internal;
checked_write_int
function checked_write_int(StdStorage storage self, int256 val) internal;
checked_write
function checked_write(StdStorage storage self, bool write) internal;
checked_write
function checked_write(StdStorage storage self, bytes32 set) internal;
read_bytes32
function read_bytes32(StdStorage storage self) internal returns (bytes32);
read_bool
function read_bool(StdStorage storage self) internal returns (bool);
read_address
function read_address(StdStorage storage self) internal returns (address);
read_uint
function read_uint(StdStorage storage self) internal returns (uint256);
read_int
function read_int(StdStorage storage self) internal returns (int256);
parent
function parent(StdStorage storage self) internal returns (uint256, bytes32);
root
function root(StdStorage storage self) internal returns (uint256);
StdStyle
State Variables
vm
VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));
RED
string constant RED = "\u001b[91m";
GREEN
string constant GREEN = "\u001b[92m";
YELLOW
string constant YELLOW = "\u001b[93m";
BLUE
string constant BLUE = "\u001b[94m";
MAGENTA
string constant MAGENTA = "\u001b[95m";
CYAN
string constant CYAN = "\u001b[96m";
BOLD
string constant BOLD = "\u001b[1m";
DIM
string constant DIM = "\u001b[2m";
ITALIC
string constant ITALIC = "\u001b[3m";
UNDERLINE
string constant UNDERLINE = "\u001b[4m";
INVERSE
string constant INVERSE = "\u001b[7m";
RESET
string constant RESET = "\u001b[0m";
Functions
styleConcat
function styleConcat(string memory style, string memory self) private pure returns (string memory);
red
function red(string memory self) internal pure returns (string memory);
red
function red(uint256 self) internal pure returns (string memory);
red
function red(int256 self) internal pure returns (string memory);
red
function red(address self) internal pure returns (string memory);
red
function red(bool self) internal pure returns (string memory);
redBytes
function redBytes(bytes memory self) internal pure returns (string memory);
redBytes32
function redBytes32(bytes32 self) internal pure returns (string memory);
green
function green(string memory self) internal pure returns (string memory);
green
function green(uint256 self) internal pure returns (string memory);
green
function green(int256 self) internal pure returns (string memory);
green
function green(address self) internal pure returns (string memory);
green
function green(bool self) internal pure returns (string memory);
greenBytes
function greenBytes(bytes memory self) internal pure returns (string memory);
greenBytes32
function greenBytes32(bytes32 self) internal pure returns (string memory);
yellow
function yellow(string memory self) internal pure returns (string memory);
yellow
function yellow(uint256 self) internal pure returns (string memory);
yellow
function yellow(int256 self) internal pure returns (string memory);
yellow
function yellow(address self) internal pure returns (string memory);
yellow
function yellow(bool self) internal pure returns (string memory);
yellowBytes
function yellowBytes(bytes memory self) internal pure returns (string memory);
yellowBytes32
function yellowBytes32(bytes32 self) internal pure returns (string memory);
blue
function blue(string memory self) internal pure returns (string memory);
blue
function blue(uint256 self) internal pure returns (string memory);
blue
function blue(int256 self) internal pure returns (string memory);
blue
function blue(address self) internal pure returns (string memory);
blue
function blue(bool self) internal pure returns (string memory);
blueBytes
function blueBytes(bytes memory self) internal pure returns (string memory);
blueBytes32
function blueBytes32(bytes32 self) internal pure returns (string memory);
magenta
function magenta(string memory self) internal pure returns (string memory);
magenta
function magenta(uint256 self) internal pure returns (string memory);
magenta
function magenta(int256 self) internal pure returns (string memory);
magenta
function magenta(address self) internal pure returns (string memory);
magenta
function magenta(bool self) internal pure returns (string memory);
magentaBytes
function magentaBytes(bytes memory self) internal pure returns (string memory);
magentaBytes32
function magentaBytes32(bytes32 self) internal pure returns (string memory);
cyan
function cyan(string memory self) internal pure returns (string memory);
cyan
function cyan(uint256 self) internal pure returns (string memory);
cyan
function cyan(int256 self) internal pure returns (string memory);
cyan
function cyan(address self) internal pure returns (string memory);
cyan
function cyan(bool self) internal pure returns (string memory);
cyanBytes
function cyanBytes(bytes memory self) internal pure returns (string memory);
cyanBytes32
function cyanBytes32(bytes32 self) internal pure returns (string memory);
bold
function bold(string memory self) internal pure returns (string memory);
bold
function bold(uint256 self) internal pure returns (string memory);
bold
function bold(int256 self) internal pure returns (string memory);
bold
function bold(address self) internal pure returns (string memory);
bold
function bold(bool self) internal pure returns (string memory);
boldBytes
function boldBytes(bytes memory self) internal pure returns (string memory);
boldBytes32
function boldBytes32(bytes32 self) internal pure returns (string memory);
dim
function dim(string memory self) internal pure returns (string memory);
dim
function dim(uint256 self) internal pure returns (string memory);
dim
function dim(int256 self) internal pure returns (string memory);
dim
function dim(address self) internal pure returns (string memory);
dim
function dim(bool self) internal pure returns (string memory);
dimBytes
function dimBytes(bytes memory self) internal pure returns (string memory);
dimBytes32
function dimBytes32(bytes32 self) internal pure returns (string memory);
italic
function italic(string memory self) internal pure returns (string memory);
italic
function italic(uint256 self) internal pure returns (string memory);
italic
function italic(int256 self) internal pure returns (string memory);
italic
function italic(address self) internal pure returns (string memory);
italic
function italic(bool self) internal pure returns (string memory);
italicBytes
function italicBytes(bytes memory self) internal pure returns (string memory);
italicBytes32
function italicBytes32(bytes32 self) internal pure returns (string memory);
underline
function underline(string memory self) internal pure returns (string memory);
underline
function underline(uint256 self) internal pure returns (string memory);
underline
function underline(int256 self) internal pure returns (string memory);
underline
function underline(address self) internal pure returns (string memory);
underline
function underline(bool self) internal pure returns (string memory);
underlineBytes
function underlineBytes(bytes memory self) internal pure returns (string memory);
underlineBytes32
function underlineBytes32(bytes32 self) internal pure returns (string memory);
inverse
function inverse(string memory self) internal pure returns (string memory);
inverse
function inverse(uint256 self) internal pure returns (string memory);
inverse
function inverse(int256 self) internal pure returns (string memory);
inverse
function inverse(address self) internal pure returns (string memory);
inverse
function inverse(bool self) internal pure returns (string memory);
inverseBytes
function inverseBytes(bytes memory self) internal pure returns (string memory);
inverseBytes32
function inverseBytes32(bytes32 self) internal pure returns (string memory);
stdToml
State Variables
vm
VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));
Functions
keyExists
function keyExists(string memory toml, string memory key) internal view returns (bool);
parseRaw
function parseRaw(string memory toml, string memory key) internal pure returns (bytes memory);
readUint
function readUint(string memory toml, string memory key) internal pure returns (uint256);
readUintArray
function readUintArray(string memory toml, string memory key) internal pure returns (uint256[] memory);
readInt
function readInt(string memory toml, string memory key) internal pure returns (int256);
readIntArray
function readIntArray(string memory toml, string memory key) internal pure returns (int256[] memory);
readBytes32
function readBytes32(string memory toml, string memory key) internal pure returns (bytes32);
readBytes32Array
function readBytes32Array(string memory toml, string memory key) internal pure returns (bytes32[] memory);
readString
function readString(string memory toml, string memory key) internal pure returns (string memory);
readStringArray
function readStringArray(string memory toml, string memory key) internal pure returns (string[] memory);
readAddress
function readAddress(string memory toml, string memory key) internal pure returns (address);
readAddressArray
function readAddressArray(string memory toml, string memory key) internal pure returns (address[] memory);
readBool
function readBool(string memory toml, string memory key) internal pure returns (bool);
readBoolArray
function readBoolArray(string memory toml, string memory key) internal pure returns (bool[] memory);
readBytes
function readBytes(string memory toml, string memory key) internal pure returns (bytes memory);
readBytesArray
function readBytesArray(string memory toml, string memory key) internal pure returns (bytes[] memory);
readUintOr
function readUintOr(string memory toml, string memory key, uint256 defaultValue) internal view returns (uint256);
readUintArrayOr
function readUintArrayOr(string memory toml, string memory key, uint256[] memory defaultValue)
internal
view
returns (uint256[] memory);
readIntOr
function readIntOr(string memory toml, string memory key, int256 defaultValue) internal view returns (int256);
readIntArrayOr
function readIntArrayOr(string memory toml, string memory key, int256[] memory defaultValue)
internal
view
returns (int256[] memory);
readBytes32Or
function readBytes32Or(string memory toml, string memory key, bytes32 defaultValue) internal view returns (bytes32);
readBytes32ArrayOr
function readBytes32ArrayOr(string memory toml, string memory key, bytes32[] memory defaultValue)
internal
view
returns (bytes32[] memory);
readStringOr
function readStringOr(string memory toml, string memory key, string memory defaultValue)
internal
view
returns (string memory);
readStringArrayOr
function readStringArrayOr(string memory toml, string memory key, string[] memory defaultValue)
internal
view
returns (string[] memory);
readAddressOr
function readAddressOr(string memory toml, string memory key, address defaultValue) internal view returns (address);
readAddressArrayOr
function readAddressArrayOr(string memory toml, string memory key, address[] memory defaultValue)
internal
view
returns (address[] memory);
readBoolOr
function readBoolOr(string memory toml, string memory key, bool defaultValue) internal view returns (bool);
readBoolArrayOr
function readBoolArrayOr(string memory toml, string memory key, bool[] memory defaultValue)
internal
view
returns (bool[] memory);
readBytesOr
function readBytesOr(string memory toml, string memory key, bytes memory defaultValue)
internal
view
returns (bytes memory);
readBytesArrayOr
function readBytesArrayOr(string memory toml, string memory key, bytes[] memory defaultValue)
internal
view
returns (bytes[] memory);
serialize
function serialize(string memory jsonKey, string memory rootObject) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bool value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bool[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, uint256 value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, uint256[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, int256 value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, int256[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, address value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, address[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bytes32 value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bytes32[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bytes memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bytes[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, string memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, string[] memory value) internal returns (string memory);
write
function write(string memory jsonKey, string memory path) internal;
write
function write(string memory jsonKey, string memory path, string memory valueKey) internal;
StdUtils
State Variables
multicall
IMulticall3 private constant multicall = IMulticall3(0xcA11bde05977b3631167028862bE2a173976CA11);
vm
VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));
CONSOLE2_ADDRESS
address private constant CONSOLE2_ADDRESS = 0x000000000000000000636F6e736F6c652e6c6f67;
INT256_MIN_ABS
uint256 private constant INT256_MIN_ABS = 57896044618658097711785492504343953926634992332820282019728792003956564819968;
SECP256K1_ORDER
uint256 private constant SECP256K1_ORDER =
115792089237316195423570985008687907852837564279074904382605163141518161494337;
UINT256_MAX
uint256 private constant UINT256_MAX = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
CREATE2_FACTORY
address private constant CREATE2_FACTORY = 0x4e59b44847b379578588920cA78FbF26c0B4956C;
Functions
_bound
function _bound(uint256 x, uint256 min, uint256 max) internal pure virtual returns (uint256 result);
bound
function bound(uint256 x, uint256 min, uint256 max) internal pure virtual returns (uint256 result);
_bound
function _bound(int256 x, int256 min, int256 max) internal pure virtual returns (int256 result);
bound
function bound(int256 x, int256 min, int256 max) internal pure virtual returns (int256 result);
boundPrivateKey
function boundPrivateKey(uint256 privateKey) internal pure virtual returns (uint256 result);
bytesToUint
function bytesToUint(bytes memory b) internal pure virtual returns (uint256);
computeCreateAddress
adapted from Solmate implementation (https://github.com/Rari-Capital/solmate/blob/main/src/utils/LibRLP.sol)
Compute the address a contract will be deployed at for a given deployer address and nonce
function computeCreateAddress(address deployer, uint256 nonce) internal pure virtual returns (address);
computeCreate2Address
function computeCreate2Address(bytes32 salt, bytes32 initcodeHash, address deployer)
internal
pure
virtual
returns (address);
computeCreate2Address
returns the address of a contract created with CREATE2 using the default CREATE2 deployer
function computeCreate2Address(bytes32 salt, bytes32 initCodeHash) internal pure returns (address);
hashInitCode
returns the hash of the init code (creation code + no args) used in CREATE2 with no constructor arguments
function hashInitCode(bytes memory creationCode) internal pure returns (bytes32);
Parameters
| Name | Type | Description |
|---|---|---|
creationCode | bytes | the creation code of a contract C, as returned by type(C).creationCode |
hashInitCode
returns the hash of the init code (creation code + ABI-encoded args) used in CREATE2
function hashInitCode(bytes memory creationCode, bytes memory args) internal pure returns (bytes32);
Parameters
| Name | Type | Description |
|---|---|---|
creationCode | bytes | the creation code of a contract C, as returned by type(C).creationCode |
args | bytes | the ABI-encoded arguments to the constructor of C |
getTokenBalances
function getTokenBalances(address token, address[] memory addresses)
internal
virtual
returns (uint256[] memory balances);
addressFromLast20Bytes
function addressFromLast20Bytes(bytes32 bytesValue) private pure returns (address);
_castLogPayloadViewToPure
function _castLogPayloadViewToPure(function(bytes memory) internal view fnIn)
internal
pure
returns (function(bytes memory) internal pure fnOut);
_sendLogPayload
function _sendLogPayload(bytes memory payload) internal pure;
_sendLogPayloadView
function _sendLogPayloadView(bytes memory payload) private view;
console2_log_StdUtils
function console2_log_StdUtils(string memory p0) private pure;
console2_log_StdUtils
function console2_log_StdUtils(string memory p0, uint256 p1) private pure;
console2_log_StdUtils
function console2_log_StdUtils(string memory p0, string memory p1) private pure;
Test
Inherits: TestBase, StdAssertions, StdChains, StdCheats, StdInvariant, StdUtils
State Variables
IS_TEST
bool public IS_TEST = true;
VmSafe
The VmSafe interface does not allow manipulation of the EVM state or other actions that may
result in Script simulations differing from on-chain execution. It is recommended to only use
these cheats in scripts.
Functions
createWallet
Derives a private key from the name, labels the account with that name, and returns the wallet.
function createWallet(string calldata walletLabel) external returns (Wallet memory wallet);
createWallet
Generates a wallet from the private key and returns the wallet.
function createWallet(uint256 privateKey) external returns (Wallet memory wallet);
createWallet
Generates a wallet from the private key, labels the account with that name, and returns the wallet.
function createWallet(uint256 privateKey, string calldata walletLabel) external returns (Wallet memory wallet);
deriveKey
Derive a private key from a provided mnenomic string (or mnenomic file path)
at the derivation path m/44'/60'/0'/0/{index}.
function deriveKey(string calldata mnemonic, uint32 index) external pure returns (uint256 privateKey);
deriveKey
Derive a private key from a provided mnenomic string (or mnenomic file path)
at {derivationPath}{index}.
function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index)
external
pure
returns (uint256 privateKey);
deriveKey
Derive a private key from a provided mnenomic string (or mnenomic file path) in the specified language
at the derivation path m/44'/60'/0'/0/{index}.
function deriveKey(string calldata mnemonic, uint32 index, string calldata language)
external
pure
returns (uint256 privateKey);
deriveKey
Derive a private key from a provided mnenomic string (or mnenomic file path) in the specified language
at {derivationPath}{index}.
function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index, string calldata language)
external
pure
returns (uint256 privateKey);
publicKeyP256
Derives secp256r1 public key from the provided privateKey.
function publicKeyP256(uint256 privateKey) external pure returns (uint256 publicKeyX, uint256 publicKeyY);
rememberKey
Adds a private key to the local forge wallet and returns the address.
function rememberKey(uint256 privateKey) external returns (address keyAddr);
rememberKeys
Derive a set number of wallets from a mnemonic at the derivation path m/44'/60'/0'/0/{0..count}.
The respective private keys are saved to the local forge wallet for later use and their addresses are returned.
function rememberKeys(string calldata mnemonic, string calldata derivationPath, uint32 count)
external
returns (address[] memory keyAddrs);
rememberKeys
Derive a set number of wallets from a mnemonic in the specified language at the derivation path m/44'/60'/0'/0/{0..count}.
The respective private keys are saved to the local forge wallet for later use and their addresses are returned.
function rememberKeys(string calldata mnemonic, string calldata derivationPath, string calldata language, uint32 count)
external
returns (address[] memory keyAddrs);
signCompact
Signs data with a Wallet.
Returns a compact signature (r, vs) as per EIP-2098, where vs encodes both the
signature's s value, and the recovery id v in a single bytes32.
This format reduces the signature size from 65 to 64 bytes.
function signCompact(Wallet calldata wallet, bytes32 digest) external returns (bytes32 r, bytes32 vs);
signCompact
Signs digest with privateKey using the secp256k1 curve.
Returns a compact signature (r, vs) as per EIP-2098, where vs encodes both the
signature's s value, and the recovery id v in a single bytes32.
This format reduces the signature size from 65 to 64 bytes.
function signCompact(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
signCompact
Signs digest with signer provided to script using the secp256k1 curve.
Returns a compact signature (r, vs) as per EIP-2098, where vs encodes both the
signature's s value, and the recovery id v in a single bytes32.
This format reduces the signature size from 65 to 64 bytes.
If --sender is provided, the signer with provided address is used, otherwise,
if exactly one signer is provided to the script, that signer is used.
Raises error if signer passed through --sender does not match any unlocked signers or
if --sender is not provided and not exactly one signer is passed to the script.
function signCompact(bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
signCompact
Signs digest with signer provided to script using the secp256k1 curve.
Returns a compact signature (r, vs) as per EIP-2098, where vs encodes both the
signature's s value, and the recovery id v in a single bytes32.
This format reduces the signature size from 65 to 64 bytes.
Raises error if none of the signers passed into the script have provided address.
function signCompact(address signer, bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
signP256
Signs digest with privateKey using the secp256r1 curve.
function signP256(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 s);
sign
Signs data with a Wallet.
function sign(Wallet calldata wallet, bytes32 digest) external returns (uint8 v, bytes32 r, bytes32 s);
sign
Signs digest with privateKey using the secp256k1 curve.
function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
sign
Signs digest with signer provided to script using the secp256k1 curve.
If --sender is provided, the signer with provided address is used, otherwise,
if exactly one signer is provided to the script, that signer is used.
Raises error if signer passed through --sender does not match any unlocked signers or
if --sender is not provided and not exactly one signer is passed to the script.
function sign(bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
sign
Signs digest with signer provided to script using the secp256k1 curve.
Raises error if none of the signers passed into the script have provided address.
function sign(address signer, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
envAddress
Gets the environment variable name and parses it as address.
Reverts if the variable was not found or could not be parsed.
function envAddress(string calldata name) external view returns (address value);
envAddress
Gets the environment variable name and parses it as an array of address, delimited by delim.
Reverts if the variable was not found or could not be parsed.
function envAddress(string calldata name, string calldata delim) external view returns (address[] memory value);
envBool
Gets the environment variable name and parses it as bool.
Reverts if the variable was not found or could not be parsed.
function envBool(string calldata name) external view returns (bool value);
envBool
Gets the environment variable name and parses it as an array of bool, delimited by delim.
Reverts if the variable was not found or could not be parsed.
function envBool(string calldata name, string calldata delim) external view returns (bool[] memory value);
envBytes32
Gets the environment variable name and parses it as bytes32.
Reverts if the variable was not found or could not be parsed.
function envBytes32(string calldata name) external view returns (bytes32 value);
envBytes32
Gets the environment variable name and parses it as an array of bytes32, delimited by delim.
Reverts if the variable was not found or could not be parsed.
function envBytes32(string calldata name, string calldata delim) external view returns (bytes32[] memory value);
envBytes
Gets the environment variable name and parses it as bytes.
Reverts if the variable was not found or could not be parsed.
function envBytes(string calldata name) external view returns (bytes memory value);
envBytes
Gets the environment variable name and parses it as an array of bytes, delimited by delim.
Reverts if the variable was not found or could not be parsed.
function envBytes(string calldata name, string calldata delim) external view returns (bytes[] memory value);
envExists
Gets the environment variable name and returns true if it exists, else returns false.
function envExists(string calldata name) external view returns (bool result);
envInt
Gets the environment variable name and parses it as int256.
Reverts if the variable was not found or could not be parsed.
function envInt(string calldata name) external view returns (int256 value);
envInt
Gets the environment variable name and parses it as an array of int256, delimited by delim.
Reverts if the variable was not found or could not be parsed.
function envInt(string calldata name, string calldata delim) external view returns (int256[] memory value);
envOr
Gets the environment variable name and parses it as bool.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, bool defaultValue) external view returns (bool value);
envOr
Gets the environment variable name and parses it as uint256.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, uint256 defaultValue) external view returns (uint256 value);
envOr
Gets the environment variable name and parses it as an array of address, delimited by delim.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, string calldata delim, address[] calldata defaultValue)
external
view
returns (address[] memory value);
envOr
Gets the environment variable name and parses it as an array of bytes32, delimited by delim.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, string calldata delim, bytes32[] calldata defaultValue)
external
view
returns (bytes32[] memory value);
envOr
Gets the environment variable name and parses it as an array of string, delimited by delim.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, string calldata delim, string[] calldata defaultValue)
external
view
returns (string[] memory value);
envOr
Gets the environment variable name and parses it as an array of bytes, delimited by delim.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, string calldata delim, bytes[] calldata defaultValue)
external
view
returns (bytes[] memory value);
envOr
Gets the environment variable name and parses it as int256.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, int256 defaultValue) external view returns (int256 value);
envOr
Gets the environment variable name and parses it as address.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, address defaultValue) external view returns (address value);
envOr
Gets the environment variable name and parses it as bytes32.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, bytes32 defaultValue) external view returns (bytes32 value);
envOr
Gets the environment variable name and parses it as string.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, string calldata defaultValue) external view returns (string memory value);
envOr
Gets the environment variable name and parses it as bytes.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, bytes calldata defaultValue) external view returns (bytes memory value);
envOr
Gets the environment variable name and parses it as an array of bool, delimited by delim.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, string calldata delim, bool[] calldata defaultValue)
external
view
returns (bool[] memory value);
envOr
Gets the environment variable name and parses it as an array of uint256, delimited by delim.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, string calldata delim, uint256[] calldata defaultValue)
external
view
returns (uint256[] memory value);
envOr
Gets the environment variable name and parses it as an array of int256, delimited by delim.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, string calldata delim, int256[] calldata defaultValue)
external
view
returns (int256[] memory value);
envString
Gets the environment variable name and parses it as string.
Reverts if the variable was not found or could not be parsed.
function envString(string calldata name) external view returns (string memory value);
envString
Gets the environment variable name and parses it as an array of string, delimited by delim.
Reverts if the variable was not found or could not be parsed.
function envString(string calldata name, string calldata delim) external view returns (string[] memory value);
envUint
Gets the environment variable name and parses it as uint256.
Reverts if the variable was not found or could not be parsed.
function envUint(string calldata name) external view returns (uint256 value);
envUint
Gets the environment variable name and parses it as an array of uint256, delimited by delim.
Reverts if the variable was not found or could not be parsed.
function envUint(string calldata name, string calldata delim) external view returns (uint256[] memory value);
isContext
Returns true if forge command was executed in given context.
function isContext(ForgeContext context) external view returns (bool result);
setEnv
Sets environment variables.
function setEnv(string calldata name, string calldata value) external;
accesses
Gets all accessed reads and write slot from a vm.record session, for a given address.
function accesses(address target) external returns (bytes32[] memory readSlots, bytes32[] memory writeSlots);
addr
Gets the address for a given private key.
function addr(uint256 privateKey) external pure returns (address keyAddr);
eth_getLogs
Gets all the logs according to specified filter.
function eth_getLogs(uint256 fromBlock, uint256 toBlock, address target, bytes32[] calldata topics)
external
returns (EthGetLogs[] memory logs);
getBlobBaseFee
Gets the current block.blobbasefee.
You should use this instead of block.blobbasefee if you use vm.blobBaseFee, as block.blobbasefee is assumed to be constant across a transaction,
and as a result will get optimized out by the compiler.
See https://github.com/foundry-rs/foundry/issues/6180
function getBlobBaseFee() external view returns (uint256 blobBaseFee);
getBlockNumber
Gets the current block.number.
You should use this instead of block.number if you use vm.roll, as block.number is assumed to be constant across a transaction,
and as a result will get optimized out by the compiler.
See https://github.com/foundry-rs/foundry/issues/6180
function getBlockNumber() external view returns (uint256 height);
getBlockTimestamp
Gets the current block.timestamp.
You should use this instead of block.timestamp if you use vm.warp, as block.timestamp is assumed to be constant across a transaction,
and as a result will get optimized out by the compiler.
See https://github.com/foundry-rs/foundry/issues/6180
function getBlockTimestamp() external view returns (uint256 timestamp);
getMappingKeyAndParentOf
Gets the map key and parent of a mapping at a given slot, for a given address.
function getMappingKeyAndParentOf(address target, bytes32 elementSlot)
external
returns (bool found, bytes32 key, bytes32 parent);
getMappingLength
Gets the number of elements in the mapping at the given slot, for a given address.
function getMappingLength(address target, bytes32 mappingSlot) external returns (uint256 length);
getMappingSlotAt
Gets the elements at index idx of the mapping at the given slot, for a given address. The index must be less than the length of the mapping (i.e. the number of keys in the mapping).
function getMappingSlotAt(address target, bytes32 mappingSlot, uint256 idx) external returns (bytes32 value);
getNonce
Gets the nonce of an account.
function getNonce(address account) external view returns (uint64 nonce);
getNonce
Get the nonce of a Wallet.
function getNonce(Wallet calldata wallet) external returns (uint64 nonce);
getRecordedLogs
Gets all the recorded logs.
function getRecordedLogs() external returns (Log[] memory logs);
getStateDiff
Returns state diffs from current vm.startStateDiffRecording session.
function getStateDiff() external view returns (string memory diff);
getStateDiffJson
Returns state diffs from current vm.startStateDiffRecording session, in json format.
function getStateDiffJson() external view returns (string memory diff);
lastCallGas
Gets the gas used in the last call from the callee perspective.
function lastCallGas() external view returns (Gas memory gas);
load
Loads a storage slot from an address.
function load(address target, bytes32 slot) external view returns (bytes32 data);
pauseGasMetering
Pauses gas metering (i.e. gas usage is not counted). Noop if already paused.
function pauseGasMetering() external;
record
Records all storage reads and writes.
function record() external;
recordLogs
Record all the transaction logs.
function recordLogs() external;
resetGasMetering
Reset gas metering (i.e. gas usage is set to gas limit).
function resetGasMetering() external;
resumeGasMetering
Resumes gas metering (i.e. gas usage is counted again). Noop if already on.
function resumeGasMetering() external;
rpc
Performs an Ethereum JSON-RPC request to the current fork URL.
function rpc(string calldata method, string calldata params) external returns (bytes memory data);
rpc
Performs an Ethereum JSON-RPC request to the given endpoint.
function rpc(string calldata urlOrAlias, string calldata method, string calldata params)
external
returns (bytes memory data);
startDebugTraceRecording
Records the debug trace during the run.
function startDebugTraceRecording() external;
startMappingRecording
Starts recording all map SSTOREs for later retrieval.
function startMappingRecording() external;
startStateDiffRecording
Record all account accesses as part of CREATE, CALL or SELFDESTRUCT opcodes in order, along with the context of the calls
function startStateDiffRecording() external;
stopAndReturnDebugTraceRecording
Stop debug trace recording and returns the recorded debug trace.
function stopAndReturnDebugTraceRecording() external returns (DebugStep[] memory step);
stopAndReturnStateDiff
Returns an ordered array of all account accesses from a vm.startStateDiffRecording session.
function stopAndReturnStateDiff() external returns (AccountAccess[] memory accountAccesses);
stopMappingRecording
Stops recording all map SSTOREs for later retrieval and clears the recorded data.
function stopMappingRecording() external;
closeFile
Closes file for reading, resetting the offset and allowing to read it from beginning with readLine.
path is relative to the project root.
function closeFile(string calldata path) external;
copyFile
Copies the contents of one file to another. This function will overwrite the contents of to.
On success, the total number of bytes copied is returned and it is equal to the length of the to file as reported by metadata.
Both from and to are relative to the project root.
function copyFile(string calldata from, string calldata to) external returns (uint64 copied);
createDir
Creates a new, empty directory at the provided path. This cheatcode will revert in the following situations, but is not limited to just these cases:
- User lacks permissions to modify
path. - A parent of the given path doesn't exist and
recursiveis false. pathalready exists andrecursiveis false.pathis relative to the project root.
function createDir(string calldata path, bool recursive) external;
deployCode
Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the
artifact in the form of
function deployCode(string calldata artifactPath) external returns (address deployedAddress);
deployCode
Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the
artifact in the form of
function deployCode(string calldata artifactPath, bytes calldata constructorArgs)
external
returns (address deployedAddress);
deployCode
Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the
artifact in the form of msg.value.
function deployCode(string calldata artifactPath, uint256 value) external returns (address deployedAddress);
deployCode
Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the
artifact in the form of msg.value.
function deployCode(string calldata artifactPath, bytes calldata constructorArgs, uint256 value)
external
returns (address deployedAddress);
deployCode
Deploys a contract from an artifact file, using the CREATE2 salt. Takes in the relative path to the json file or the path to the
artifact in the form of
function deployCode(string calldata artifactPath, bytes32 salt) external returns (address deployedAddress);
deployCode
Deploys a contract from an artifact file, using the CREATE2 salt. Takes in the relative path to the json file or the path to the
artifact in the form of
function deployCode(string calldata artifactPath, bytes calldata constructorArgs, bytes32 salt)
external
returns (address deployedAddress);
deployCode
Deploys a contract from an artifact file, using the CREATE2 salt. Takes in the relative path to the json file or the path to the
artifact in the form of msg.value.
function deployCode(string calldata artifactPath, uint256 value, bytes32 salt)
external
returns (address deployedAddress);
deployCode
Deploys a contract from an artifact file, using the CREATE2 salt. Takes in the relative path to the json file or the path to the
artifact in the form of msg.value.
function deployCode(string calldata artifactPath, bytes calldata constructorArgs, uint256 value, bytes32 salt)
external
returns (address deployedAddress);
exists
Returns true if the given path points to an existing entity, else returns false.
function exists(string calldata path) external view returns (bool result);
ffi
Performs a foreign function call via the terminal.
function ffi(string[] calldata commandInput) external returns (bytes memory result);
fsMetadata
Given a path, query the file system to get information about a file, directory, etc.
function fsMetadata(string calldata path) external view returns (FsMetadata memory metadata);
getArtifactPathByCode
Gets the artifact path from code (aka. creation code).
function getArtifactPathByCode(bytes calldata code) external view returns (string memory path);
getArtifactPathByDeployedCode
Gets the artifact path from deployed code (aka. runtime code).
function getArtifactPathByDeployedCode(bytes calldata deployedCode) external view returns (string memory path);
getBroadcast
Returns the most recent broadcast for the given contract on chainId matching txType.
For example:
The most recent deployment can be fetched by passing txType as CREATE or CREATE2.
The most recent call can be fetched by passing txType as CALL.
function getBroadcast(string calldata contractName, uint64 chainId, BroadcastTxType txType)
external
view
returns (BroadcastTxSummary memory);
getBroadcasts
Returns all broadcasts for the given contract on chainId with the specified txType.
Sorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber.
function getBroadcasts(string calldata contractName, uint64 chainId, BroadcastTxType txType)
external
view
returns (BroadcastTxSummary[] memory);
getBroadcasts
Returns all broadcasts for the given contract on chainId.
Sorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber.
function getBroadcasts(string calldata contractName, uint64 chainId)
external
view
returns (BroadcastTxSummary[] memory);
getCode
Gets the creation bytecode from an artifact file. Takes in the relative path to the json file or the path to the
artifact in the form of
function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode);
getDeployedCode
Gets the deployed bytecode from an artifact file. Takes in the relative path to the json file or the path to the
artifact in the form of
function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode);
getDeployment
Returns the most recent deployment for the current chainId.
function getDeployment(string calldata contractName) external view returns (address deployedAddress);
getDeployment
Returns the most recent deployment for the given contract on chainId
function getDeployment(string calldata contractName, uint64 chainId) external view returns (address deployedAddress);
getDeployments
Returns all deployments for the given contract on chainId
Sorted in descending order of deployment time i.e descending order of BroadcastTxSummary.blockNumber.
The most recent deployment is the first element, and the oldest is the last.
function getDeployments(string calldata contractName, uint64 chainId)
external
view
returns (address[] memory deployedAddresses);
isDir
Returns true if the path exists on disk and is pointing at a directory, else returns false.
function isDir(string calldata path) external view returns (bool result);
isFile
Returns true if the path exists on disk and is pointing at a regular file, else returns false.
function isFile(string calldata path) external view returns (bool result);
projectRoot
Get the path of the current project root.
function projectRoot() external view returns (string memory path);
prompt
Prompts the user for a string value in the terminal.
function prompt(string calldata promptText) external returns (string memory input);
promptAddress
Prompts the user for an address in the terminal.
function promptAddress(string calldata promptText) external returns (address);
promptSecret
Prompts the user for a hidden string value in the terminal.
function promptSecret(string calldata promptText) external returns (string memory input);
promptSecretUint
Prompts the user for hidden uint256 in the terminal (usually pk).
function promptSecretUint(string calldata promptText) external returns (uint256);
promptUint
Prompts the user for uint256 in the terminal.
function promptUint(string calldata promptText) external returns (uint256);
readDir
Reads the directory at the given path recursively, up to maxDepth.
maxDepth defaults to 1, meaning only the direct children of the given directory will be returned.
Follows symbolic links if followLinks is true.
function readDir(string calldata path) external view returns (DirEntry[] memory entries);
readDir
See readDir(string).
function readDir(string calldata path, uint64 maxDepth) external view returns (DirEntry[] memory entries);
readDir
See readDir(string).
function readDir(string calldata path, uint64 maxDepth, bool followLinks)
external
view
returns (DirEntry[] memory entries);
readFile
Reads the entire content of file to string. path is relative to the project root.
function readFile(string calldata path) external view returns (string memory data);
readFileBinary
Reads the entire content of file as binary. path is relative to the project root.
function readFileBinary(string calldata path) external view returns (bytes memory data);
readLine
Reads next line of file to string.
function readLine(string calldata path) external view returns (string memory line);
readLink
Reads a symbolic link, returning the path that the link points to. This cheatcode will revert in the following situations, but is not limited to just these cases:
pathis not a symbolic link.pathdoes not exist.
function readLink(string calldata linkPath) external view returns (string memory targetPath);
removeDir
Removes a directory at the provided path. This cheatcode will revert in the following situations, but is not limited to just these cases:
pathdoesn't exist.pathisn't a directory.- User lacks permissions to modify
path. - The directory is not empty and
recursiveis false.pathis relative to the project root.
function removeDir(string calldata path, bool recursive) external;
removeFile
Removes a file from the filesystem. This cheatcode will revert in the following situations, but is not limited to just these cases:
pathpoints to a directory.- The file doesn't exist.
- The user lacks permissions to remove the file.
pathis relative to the project root.
function removeFile(string calldata path) external;
tryFfi
Performs a foreign function call via terminal and returns the exit code, stdout, and stderr.
function tryFfi(string[] calldata commandInput) external returns (FfiResult memory result);
unixTime
Returns the time since unix epoch in milliseconds.
function unixTime() external view returns (uint256 milliseconds);
writeFile
Writes data to file, creating a file if it does not exist, and entirely replacing its contents if it does.
path is relative to the project root.
function writeFile(string calldata path, string calldata data) external;
writeFileBinary
Writes binary data to a file, creating a file if it does not exist, and entirely replacing its contents if it does.
path is relative to the project root.
function writeFileBinary(string calldata path, bytes calldata data) external;
writeLine
Writes line to file, creating a file if it does not exist.
path is relative to the project root.
function writeLine(string calldata path, string calldata data) external;
keyExistsJson
Checks if key exists in a JSON object.
function keyExistsJson(string calldata json, string calldata key) external view returns (bool);
parseJsonAddress
Parses a string of JSON data at key and coerces it to address.
function parseJsonAddress(string calldata json, string calldata key) external pure returns (address);
parseJsonAddressArray
Parses a string of JSON data at key and coerces it to address[].
function parseJsonAddressArray(string calldata json, string calldata key) external pure returns (address[] memory);
parseJsonBool
Parses a string of JSON data at key and coerces it to bool.
function parseJsonBool(string calldata json, string calldata key) external pure returns (bool);
parseJsonBoolArray
Parses a string of JSON data at key and coerces it to bool[].
function parseJsonBoolArray(string calldata json, string calldata key) external pure returns (bool[] memory);
parseJsonBytes
Parses a string of JSON data at key and coerces it to bytes.
function parseJsonBytes(string calldata json, string calldata key) external pure returns (bytes memory);
parseJsonBytes32
Parses a string of JSON data at key and coerces it to bytes32.
function parseJsonBytes32(string calldata json, string calldata key) external pure returns (bytes32);
parseJsonBytes32Array
Parses a string of JSON data at key and coerces it to bytes32[].
function parseJsonBytes32Array(string calldata json, string calldata key) external pure returns (bytes32[] memory);
parseJsonBytesArray
Parses a string of JSON data at key and coerces it to bytes[].
function parseJsonBytesArray(string calldata json, string calldata key) external pure returns (bytes[] memory);
parseJsonInt
Parses a string of JSON data at key and coerces it to int256.
function parseJsonInt(string calldata json, string calldata key) external pure returns (int256);
parseJsonIntArray
Parses a string of JSON data at key and coerces it to int256[].
function parseJsonIntArray(string calldata json, string calldata key) external pure returns (int256[] memory);
parseJsonKeys
Returns an array of all the keys in a JSON object.
function parseJsonKeys(string calldata json, string calldata key) external pure returns (string[] memory keys);
parseJsonString
Parses a string of JSON data at key and coerces it to string.
function parseJsonString(string calldata json, string calldata key) external pure returns (string memory);
parseJsonStringArray
Parses a string of JSON data at key and coerces it to string[].
function parseJsonStringArray(string calldata json, string calldata key) external pure returns (string[] memory);
parseJsonTypeArray
Parses a string of JSON data at key and coerces it to type array corresponding to typeDescription.
function parseJsonTypeArray(string calldata json, string calldata key, string calldata typeDescription)
external
pure
returns (bytes memory);
parseJsonType
Parses a string of JSON data and coerces it to type corresponding to typeDescription.
function parseJsonType(string calldata json, string calldata typeDescription) external pure returns (bytes memory);
parseJsonType
Parses a string of JSON data at key and coerces it to type corresponding to typeDescription.
function parseJsonType(string calldata json, string calldata key, string calldata typeDescription)
external
pure
returns (bytes memory);
parseJsonUint
Parses a string of JSON data at key and coerces it to uint256.
function parseJsonUint(string calldata json, string calldata key) external pure returns (uint256);
parseJsonUintArray
Parses a string of JSON data at key and coerces it to uint256[].
function parseJsonUintArray(string calldata json, string calldata key) external pure returns (uint256[] memory);
parseJson
ABI-encodes a JSON object.
function parseJson(string calldata json) external pure returns (bytes memory abiEncodedData);
parseJson
ABI-encodes a JSON object at key.
function parseJson(string calldata json, string calldata key) external pure returns (bytes memory abiEncodedData);
serializeAddress
See serializeJson.
function serializeAddress(string calldata objectKey, string calldata valueKey, address value)
external
returns (string memory json);
serializeAddress
See serializeJson.
function serializeAddress(string calldata objectKey, string calldata valueKey, address[] calldata values)
external
returns (string memory json);
serializeBool
See serializeJson.
function serializeBool(string calldata objectKey, string calldata valueKey, bool value)
external
returns (string memory json);
serializeBool
See serializeJson.
function serializeBool(string calldata objectKey, string calldata valueKey, bool[] calldata values)
external
returns (string memory json);
serializeBytes32
See serializeJson.
function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32 value)
external
returns (string memory json);
serializeBytes32
See serializeJson.
function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32[] calldata values)
external
returns (string memory json);
serializeBytes
See serializeJson.
function serializeBytes(string calldata objectKey, string calldata valueKey, bytes calldata value)
external
returns (string memory json);
serializeBytes
See serializeJson.
function serializeBytes(string calldata objectKey, string calldata valueKey, bytes[] calldata values)
external
returns (string memory json);
serializeInt
See serializeJson.
function serializeInt(string calldata objectKey, string calldata valueKey, int256 value)
external
returns (string memory json);
serializeInt
See serializeJson.
function serializeInt(string calldata objectKey, string calldata valueKey, int256[] calldata values)
external
returns (string memory json);
serializeJson
Serializes a key and value to a JSON object stored in-memory that can be later written to a file. Returns the stringified version of the specific JSON file up to that moment.
function serializeJson(string calldata objectKey, string calldata value) external returns (string memory json);
serializeJsonType
See serializeJson.
function serializeJsonType(string calldata typeDescription, bytes calldata value)
external
pure
returns (string memory json);
serializeJsonType
See serializeJson.
function serializeJsonType(
string calldata objectKey,
string calldata valueKey,
string calldata typeDescription,
bytes calldata value
) external returns (string memory json);
serializeString
See serializeJson.
function serializeString(string calldata objectKey, string calldata valueKey, string calldata value)
external
returns (string memory json);
serializeString
See serializeJson.
function serializeString(string calldata objectKey, string calldata valueKey, string[] calldata values)
external
returns (string memory json);
serializeUintToHex
See serializeJson.
function serializeUintToHex(string calldata objectKey, string calldata valueKey, uint256 value)
external
returns (string memory json);
serializeUint
See serializeJson.
function serializeUint(string calldata objectKey, string calldata valueKey, uint256 value)
external
returns (string memory json);
serializeUint
See serializeJson.
function serializeUint(string calldata objectKey, string calldata valueKey, uint256[] calldata values)
external
returns (string memory json);
writeJson
Write a serialized JSON object to a file. If the file exists, it will be overwritten.
function writeJson(string calldata json, string calldata path) external;
writeJson
Write a serialized JSON object to an existing JSON file, replacing a value with key = <value_key.> This is useful to replace a specific value of a JSON file, without having to parse the entire thing.
function writeJson(string calldata json, string calldata path, string calldata valueKey) external;
keyExists
Checks if key exists in a JSON object
keyExists is being deprecated in favor of keyExistsJson. It will be removed in future versions.
function keyExists(string calldata json, string calldata key) external view returns (bool);
attachBlob
Attach an EIP-4844 blob to the next call
function attachBlob(bytes calldata blob) external;
attachDelegation
Designate the next call as an EIP-7702 transaction
function attachDelegation(SignedDelegation calldata signedDelegation) external;
broadcastRawTransaction
Takes a signed transaction and broadcasts it to the network.
function broadcastRawTransaction(bytes calldata data) external;
broadcast
Has the next call (at this call depth only) create transactions that can later be signed and sent onchain. Broadcasting address is determined by checking the following in order:
- If
--senderargument was provided, that address is used. - If exactly one signer (e.g. private key, hw wallet, keystore) is set when
forge broadcastis invoked, that signer is used. - Otherwise, default foundry sender (1804c8AB1F12E6bbf3894d4083f33e07309d1f38) is used.
function broadcast() external;
broadcast
Has the next call (at this call depth only) create a transaction with the address provided as the sender that can later be signed and sent onchain.
function broadcast(address signer) external;
broadcast
Has the next call (at this call depth only) create a transaction with the private key provided as the sender that can later be signed and sent onchain.
function broadcast(uint256 privateKey) external;
getWallets
Returns addresses of available unlocked wallets in the script environment.
function getWallets() external returns (address[] memory wallets);
signAndAttachDelegation
Sign an EIP-7702 authorization and designate the next call as an EIP-7702 transaction
function signAndAttachDelegation(address implementation, uint256 privateKey)
external
returns (SignedDelegation memory signedDelegation);
signAndAttachDelegation
Sign an EIP-7702 authorization and designate the next call as an EIP-7702 transaction for specific nonce
function signAndAttachDelegation(address implementation, uint256 privateKey, uint64 nonce)
external
returns (SignedDelegation memory signedDelegation);
signDelegation
Sign an EIP-7702 authorization for delegation
function signDelegation(address implementation, uint256 privateKey)
external
returns (SignedDelegation memory signedDelegation);
signDelegation
Sign an EIP-7702 authorization for delegation for specific nonce
function signDelegation(address implementation, uint256 privateKey, uint64 nonce)
external
returns (SignedDelegation memory signedDelegation);
startBroadcast
Has all subsequent calls (at this call depth only) create transactions that can later be signed and sent onchain. Broadcasting address is determined by checking the following in order:
- If
--senderargument was provided, that address is used. - If exactly one signer (e.g. private key, hw wallet, keystore) is set when
forge broadcastis invoked, that signer is used. - Otherwise, default foundry sender (1804c8AB1F12E6bbf3894d4083f33e07309d1f38) is used.
function startBroadcast() external;
startBroadcast
Has all subsequent calls (at this call depth only) create transactions with the address provided that can later be signed and sent onchain.
function startBroadcast(address signer) external;
startBroadcast
Has all subsequent calls (at this call depth only) create transactions with the private key provided that can later be signed and sent onchain.
function startBroadcast(uint256 privateKey) external;
stopBroadcast
Stops collecting onchain transactions.
function stopBroadcast() external;
contains
Returns true if search is found in subject, false otherwise.
function contains(string calldata subject, string calldata search) external returns (bool result);
indexOf
Returns the index of the first occurrence of a key in an input string.
Returns NOT_FOUND (i.e. type(uint256).max) if the key is not found.
Returns 0 in case of an empty key.
function indexOf(string calldata input, string calldata key) external pure returns (uint256);
parseAddress
Parses the given string into an address.
function parseAddress(string calldata stringifiedValue) external pure returns (address parsedValue);
parseBool
Parses the given string into a bool.
function parseBool(string calldata stringifiedValue) external pure returns (bool parsedValue);
parseBytes
Parses the given string into bytes.
function parseBytes(string calldata stringifiedValue) external pure returns (bytes memory parsedValue);
parseBytes32
Parses the given string into a bytes32.
function parseBytes32(string calldata stringifiedValue) external pure returns (bytes32 parsedValue);
parseInt
Parses the given string into a int256.
function parseInt(string calldata stringifiedValue) external pure returns (int256 parsedValue);
parseUint
Parses the given string into a uint256.
function parseUint(string calldata stringifiedValue) external pure returns (uint256 parsedValue);
replace
Replaces occurrences of from in the given string with to.
function replace(string calldata input, string calldata from, string calldata to)
external
pure
returns (string memory output);
split
Splits the given string into an array of strings divided by the delimiter.
function split(string calldata input, string calldata delimiter) external pure returns (string[] memory outputs);
toLowercase
Converts the given string value to Lowercase.
function toLowercase(string calldata input) external pure returns (string memory output);
toString
Converts the given value to a string.
function toString(address value) external pure returns (string memory stringifiedValue);
toString
Converts the given value to a string.
function toString(bytes calldata value) external pure returns (string memory stringifiedValue);
toString
Converts the given value to a string.
function toString(bytes32 value) external pure returns (string memory stringifiedValue);
toString
Converts the given value to a string.
function toString(bool value) external pure returns (string memory stringifiedValue);
toString
Converts the given value to a string.
function toString(uint256 value) external pure returns (string memory stringifiedValue);
toString
Converts the given value to a string.
function toString(int256 value) external pure returns (string memory stringifiedValue);
toUppercase
Converts the given string value to Uppercase.
function toUppercase(string calldata input) external pure returns (string memory output);
trim
Trims leading and trailing whitespace from the given string value.
function trim(string calldata input) external pure returns (string memory output);
assertApproxEqAbsDecimal
Compares two uint256 values. Expects difference to be less than or equal to maxDelta.
Formats values with decimals in failure message.
function assertApproxEqAbsDecimal(uint256 left, uint256 right, uint256 maxDelta, uint256 decimals) external pure;
assertApproxEqAbsDecimal
Compares two uint256 values. Expects difference to be less than or equal to maxDelta.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertApproxEqAbsDecimal(
uint256 left,
uint256 right,
uint256 maxDelta,
uint256 decimals,
string calldata error
) external pure;
assertApproxEqAbsDecimal
Compares two int256 values. Expects difference to be less than or equal to maxDelta.
Formats values with decimals in failure message.
function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals) external pure;
assertApproxEqAbsDecimal
Compares two int256 values. Expects difference to be less than or equal to maxDelta.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals, string calldata error)
external
pure;
assertApproxEqAbs
Compares two uint256 values. Expects difference to be less than or equal to maxDelta.
function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta) external pure;
assertApproxEqAbs
Compares two uint256 values. Expects difference to be less than or equal to maxDelta.
Includes error message into revert string on failure.
function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta, string calldata error) external pure;
assertApproxEqAbs
Compares two int256 values. Expects difference to be less than or equal to maxDelta.
function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta) external pure;
assertApproxEqAbs
Compares two int256 values. Expects difference to be less than or equal to maxDelta.
Includes error message into revert string on failure.
function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta, string calldata error) external pure;
assertApproxEqRelDecimal
Compares two uint256 values. Expects relative difference in percents to be less than or equal to maxPercentDelta.
maxPercentDelta is an 18 decimal fixed point number, where 1e18 == 100%
Formats values with decimals in failure message.
function assertApproxEqRelDecimal(uint256 left, uint256 right, uint256 maxPercentDelta, uint256 decimals)
external
pure;
assertApproxEqRelDecimal
Compares two uint256 values. Expects relative difference in percents to be less than or equal to maxPercentDelta.
maxPercentDelta is an 18 decimal fixed point number, where 1e18 == 100%
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertApproxEqRelDecimal(
uint256 left,
uint256 right,
uint256 maxPercentDelta,
uint256 decimals,
string calldata error
) external pure;
assertApproxEqRelDecimal
Compares two int256 values. Expects relative difference in percents to be less than or equal to maxPercentDelta.
maxPercentDelta is an 18 decimal fixed point number, where 1e18 == 100%
Formats values with decimals in failure message.
function assertApproxEqRelDecimal(int256 left, int256 right, uint256 maxPercentDelta, uint256 decimals) external pure;
assertApproxEqRelDecimal
Compares two int256 values. Expects relative difference in percents to be less than or equal to maxPercentDelta.
maxPercentDelta is an 18 decimal fixed point number, where 1e18 == 100%
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertApproxEqRelDecimal(
int256 left,
int256 right,
uint256 maxPercentDelta,
uint256 decimals,
string calldata error
) external pure;
assertApproxEqRel
Compares two uint256 values. Expects relative difference in percents to be less than or equal to maxPercentDelta.
maxPercentDelta is an 18 decimal fixed point number, where 1e18 == 100%
function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta) external pure;
assertApproxEqRel
Compares two uint256 values. Expects relative difference in percents to be less than or equal to maxPercentDelta.
maxPercentDelta is an 18 decimal fixed point number, where 1e18 == 100%
Includes error message into revert string on failure.
function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta, string calldata error) external pure;
assertApproxEqRel
Compares two int256 values. Expects relative difference in percents to be less than or equal to maxPercentDelta.
maxPercentDelta is an 18 decimal fixed point number, where 1e18 == 100%
function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta) external pure;
assertApproxEqRel
Compares two int256 values. Expects relative difference in percents to be less than or equal to maxPercentDelta.
maxPercentDelta is an 18 decimal fixed point number, where 1e18 == 100%
Includes error message into revert string on failure.
function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta, string calldata error) external pure;
assertEqDecimal
Asserts that two uint256 values are equal, formatting them with decimals in failure message.
function assertEqDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
assertEqDecimal
Asserts that two uint256 values are equal, formatting them with decimals in failure message.
Includes error message into revert string on failure.
function assertEqDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
assertEqDecimal
Asserts that two int256 values are equal, formatting them with decimals in failure message.
function assertEqDecimal(int256 left, int256 right, uint256 decimals) external pure;
assertEqDecimal
Asserts that two int256 values are equal, formatting them with decimals in failure message.
Includes error message into revert string on failure.
function assertEqDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
assertEq
Asserts that two bool values are equal.
function assertEq(bool left, bool right) external pure;
assertEq
Asserts that two bool values are equal and includes error message into revert string on failure.
function assertEq(bool left, bool right, string calldata error) external pure;
assertEq
Asserts that two string values are equal.
function assertEq(string calldata left, string calldata right) external pure;
assertEq
Asserts that two string values are equal and includes error message into revert string on failure.
function assertEq(string calldata left, string calldata right, string calldata error) external pure;
assertEq
Asserts that two bytes values are equal.
function assertEq(bytes calldata left, bytes calldata right) external pure;
assertEq
Asserts that two bytes values are equal and includes error message into revert string on failure.
function assertEq(bytes calldata left, bytes calldata right, string calldata error) external pure;
assertEq
Asserts that two arrays of bool values are equal.
function assertEq(bool[] calldata left, bool[] calldata right) external pure;
assertEq
Asserts that two arrays of bool values are equal and includes error message into revert string on failure.
function assertEq(bool[] calldata left, bool[] calldata right, string calldata error) external pure;
assertEq
Asserts that two arrays of `uint256 values are equal.
function assertEq(uint256[] calldata left, uint256[] calldata right) external pure;
assertEq
Asserts that two arrays of uint256 values are equal and includes error message into revert string on failure.
function assertEq(uint256[] calldata left, uint256[] calldata right, string calldata error) external pure;
assertEq
Asserts that two arrays of int256 values are equal.
function assertEq(int256[] calldata left, int256[] calldata right) external pure;
assertEq
Asserts that two arrays of int256 values are equal and includes error message into revert string on failure.
function assertEq(int256[] calldata left, int256[] calldata right, string calldata error) external pure;
assertEq
Asserts that two uint256 values are equal.
function assertEq(uint256 left, uint256 right) external pure;
assertEq
Asserts that two arrays of address values are equal.
function assertEq(address[] calldata left, address[] calldata right) external pure;
assertEq
Asserts that two arrays of address values are equal and includes error message into revert string on failure.
function assertEq(address[] calldata left, address[] calldata right, string calldata error) external pure;
assertEq
Asserts that two arrays of bytes32 values are equal.
function assertEq(bytes32[] calldata left, bytes32[] calldata right) external pure;
assertEq
Asserts that two arrays of bytes32 values are equal and includes error message into revert string on failure.
function assertEq(bytes32[] calldata left, bytes32[] calldata right, string calldata error) external pure;
assertEq
Asserts that two arrays of string values are equal.
function assertEq(string[] calldata left, string[] calldata right) external pure;
assertEq
Asserts that two arrays of string values are equal and includes error message into revert string on failure.
function assertEq(string[] calldata left, string[] calldata right, string calldata error) external pure;
assertEq
Asserts that two arrays of bytes values are equal.
function assertEq(bytes[] calldata left, bytes[] calldata right) external pure;
assertEq
Asserts that two arrays of bytes values are equal and includes error message into revert string on failure.
function assertEq(bytes[] calldata left, bytes[] calldata right, string calldata error) external pure;
assertEq
Asserts that two uint256 values are equal and includes error message into revert string on failure.
function assertEq(uint256 left, uint256 right, string calldata error) external pure;
assertEq
Asserts that two int256 values are equal.
function assertEq(int256 left, int256 right) external pure;
assertEq
Asserts that two int256 values are equal and includes error message into revert string on failure.
function assertEq(int256 left, int256 right, string calldata error) external pure;
assertEq
Asserts that two address values are equal.
function assertEq(address left, address right) external pure;
assertEq
Asserts that two address values are equal and includes error message into revert string on failure.
function assertEq(address left, address right, string calldata error) external pure;
assertEq
Asserts that two bytes32 values are equal.
function assertEq(bytes32 left, bytes32 right) external pure;
assertEq
Asserts that two bytes32 values are equal and includes error message into revert string on failure.
function assertEq(bytes32 left, bytes32 right, string calldata error) external pure;
assertFalse
Asserts that the given condition is false.
function assertFalse(bool condition) external pure;
assertFalse
Asserts that the given condition is false and includes error message into revert string on failure.
function assertFalse(bool condition, string calldata error) external pure;
assertGeDecimal
Compares two uint256 values. Expects first value to be greater than or equal to second.
Formats values with decimals in failure message.
function assertGeDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
assertGeDecimal
Compares two uint256 values. Expects first value to be greater than or equal to second.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertGeDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
assertGeDecimal
Compares two int256 values. Expects first value to be greater than or equal to second.
Formats values with decimals in failure message.
function assertGeDecimal(int256 left, int256 right, uint256 decimals) external pure;
assertGeDecimal
Compares two int256 values. Expects first value to be greater than or equal to second.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertGeDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
assertGe
Compares two uint256 values. Expects first value to be greater than or equal to second.
function assertGe(uint256 left, uint256 right) external pure;
assertGe
Compares two uint256 values. Expects first value to be greater than or equal to second.
Includes error message into revert string on failure.
function assertGe(uint256 left, uint256 right, string calldata error) external pure;
assertGe
Compares two int256 values. Expects first value to be greater than or equal to second.
function assertGe(int256 left, int256 right) external pure;
assertGe
Compares two int256 values. Expects first value to be greater than or equal to second.
Includes error message into revert string on failure.
function assertGe(int256 left, int256 right, string calldata error) external pure;
assertGtDecimal
Compares two uint256 values. Expects first value to be greater than second.
Formats values with decimals in failure message.
function assertGtDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
assertGtDecimal
Compares two uint256 values. Expects first value to be greater than second.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertGtDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
assertGtDecimal
Compares two int256 values. Expects first value to be greater than second.
Formats values with decimals in failure message.
function assertGtDecimal(int256 left, int256 right, uint256 decimals) external pure;
assertGtDecimal
Compares two int256 values. Expects first value to be greater than second.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertGtDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
assertGt
Compares two uint256 values. Expects first value to be greater than second.
function assertGt(uint256 left, uint256 right) external pure;
assertGt
Compares two uint256 values. Expects first value to be greater than second.
Includes error message into revert string on failure.
function assertGt(uint256 left, uint256 right, string calldata error) external pure;
assertGt
Compares two int256 values. Expects first value to be greater than second.
function assertGt(int256 left, int256 right) external pure;
assertGt
Compares two int256 values. Expects first value to be greater than second.
Includes error message into revert string on failure.
function assertGt(int256 left, int256 right, string calldata error) external pure;
assertLeDecimal
Compares two uint256 values. Expects first value to be less than or equal to second.
Formats values with decimals in failure message.
function assertLeDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
assertLeDecimal
Compares two uint256 values. Expects first value to be less than or equal to second.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertLeDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
assertLeDecimal
Compares two int256 values. Expects first value to be less than or equal to second.
Formats values with decimals in failure message.
function assertLeDecimal(int256 left, int256 right, uint256 decimals) external pure;
assertLeDecimal
Compares two int256 values. Expects first value to be less than or equal to second.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertLeDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
assertLe
Compares two uint256 values. Expects first value to be less than or equal to second.
function assertLe(uint256 left, uint256 right) external pure;
assertLe
Compares two uint256 values. Expects first value to be less than or equal to second.
Includes error message into revert string on failure.
function assertLe(uint256 left, uint256 right, string calldata error) external pure;
assertLe
Compares two int256 values. Expects first value to be less than or equal to second.
function assertLe(int256 left, int256 right) external pure;
assertLe
Compares two int256 values. Expects first value to be less than or equal to second.
Includes error message into revert string on failure.
function assertLe(int256 left, int256 right, string calldata error) external pure;
assertLtDecimal
Compares two uint256 values. Expects first value to be less than second.
Formats values with decimals in failure message.
function assertLtDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
assertLtDecimal
Compares two uint256 values. Expects first value to be less than second.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertLtDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
assertLtDecimal
Compares two int256 values. Expects first value to be less than second.
Formats values with decimals in failure message.
function assertLtDecimal(int256 left, int256 right, uint256 decimals) external pure;
assertLtDecimal
Compares two int256 values. Expects first value to be less than second.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertLtDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
assertLt
Compares two uint256 values. Expects first value to be less than second.
function assertLt(uint256 left, uint256 right) external pure;
assertLt
Compares two uint256 values. Expects first value to be less than second.
Includes error message into revert string on failure.
function assertLt(uint256 left, uint256 right, string calldata error) external pure;
assertLt
Compares two int256 values. Expects first value to be less than second.
function assertLt(int256 left, int256 right) external pure;
assertLt
Compares two int256 values. Expects first value to be less than second.
Includes error message into revert string on failure.
function assertLt(int256 left, int256 right, string calldata error) external pure;
assertNotEqDecimal
Asserts that two uint256 values are not equal, formatting them with decimals in failure message.
function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
assertNotEqDecimal
Asserts that two uint256 values are not equal, formatting them with decimals in failure message.
Includes error message into revert string on failure.
function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
assertNotEqDecimal
Asserts that two int256 values are not equal, formatting them with decimals in failure message.
function assertNotEqDecimal(int256 left, int256 right, uint256 decimals) external pure;
assertNotEqDecimal
Asserts that two int256 values are not equal, formatting them with decimals in failure message.
Includes error message into revert string on failure.
function assertNotEqDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
assertNotEq
Asserts that two bool values are not equal.
function assertNotEq(bool left, bool right) external pure;
assertNotEq
Asserts that two bool values are not equal and includes error message into revert string on failure.
function assertNotEq(bool left, bool right, string calldata error) external pure;
assertNotEq
Asserts that two string values are not equal.
function assertNotEq(string calldata left, string calldata right) external pure;
assertNotEq
Asserts that two string values are not equal and includes error message into revert string on failure.
function assertNotEq(string calldata left, string calldata right, string calldata error) external pure;
assertNotEq
Asserts that two bytes values are not equal.
function assertNotEq(bytes calldata left, bytes calldata right) external pure;
assertNotEq
Asserts that two bytes values are not equal and includes error message into revert string on failure.
function assertNotEq(bytes calldata left, bytes calldata right, string calldata error) external pure;
assertNotEq
Asserts that two arrays of bool values are not equal.
function assertNotEq(bool[] calldata left, bool[] calldata right) external pure;
assertNotEq
Asserts that two arrays of bool values are not equal and includes error message into revert string on failure.
function assertNotEq(bool[] calldata left, bool[] calldata right, string calldata error) external pure;
assertNotEq
Asserts that two arrays of uint256 values are not equal.
function assertNotEq(uint256[] calldata left, uint256[] calldata right) external pure;
assertNotEq
Asserts that two arrays of uint256 values are not equal and includes error message into revert string on failure.
function assertNotEq(uint256[] calldata left, uint256[] calldata right, string calldata error) external pure;
assertNotEq
Asserts that two arrays of int256 values are not equal.
function assertNotEq(int256[] calldata left, int256[] calldata right) external pure;
assertNotEq
Asserts that two arrays of int256 values are not equal and includes error message into revert string on failure.
function assertNotEq(int256[] calldata left, int256[] calldata right, string calldata error) external pure;
assertNotEq
Asserts that two uint256 values are not equal.
function assertNotEq(uint256 left, uint256 right) external pure;
assertNotEq
Asserts that two arrays of address values are not equal.
function assertNotEq(address[] calldata left, address[] calldata right) external pure;
assertNotEq
Asserts that two arrays of address values are not equal and includes error message into revert string on failure.
function assertNotEq(address[] calldata left, address[] calldata right, string calldata error) external pure;
assertNotEq
Asserts that two arrays of bytes32 values are not equal.
function assertNotEq(bytes32[] calldata left, bytes32[] calldata right) external pure;
assertNotEq
Asserts that two arrays of bytes32 values are not equal and includes error message into revert string on failure.
function assertNotEq(bytes32[] calldata left, bytes32[] calldata right, string calldata error) external pure;
assertNotEq
Asserts that two arrays of string values are not equal.
function assertNotEq(string[] calldata left, string[] calldata right) external pure;
assertNotEq
Asserts that two arrays of string values are not equal and includes error message into revert string on failure.
function assertNotEq(string[] calldata left, string[] calldata right, string calldata error) external pure;
assertNotEq
Asserts that two arrays of bytes values are not equal.
function assertNotEq(bytes[] calldata left, bytes[] calldata right) external pure;
assertNotEq
Asserts that two arrays of bytes values are not equal and includes error message into revert string on failure.
function assertNotEq(bytes[] calldata left, bytes[] calldata right, string calldata error) external pure;
assertNotEq
Asserts that two uint256 values are not equal and includes error message into revert string on failure.
function assertNotEq(uint256 left, uint256 right, string calldata error) external pure;
assertNotEq
Asserts that two int256 values are not equal.
function assertNotEq(int256 left, int256 right) external pure;
assertNotEq
Asserts that two int256 values are not equal and includes error message into revert string on failure.
function assertNotEq(int256 left, int256 right, string calldata error) external pure;
assertNotEq
Asserts that two address values are not equal.
function assertNotEq(address left, address right) external pure;
assertNotEq
Asserts that two address values are not equal and includes error message into revert string on failure.
function assertNotEq(address left, address right, string calldata error) external pure;
assertNotEq
Asserts that two bytes32 values are not equal.
function assertNotEq(bytes32 left, bytes32 right) external pure;
assertNotEq
Asserts that two bytes32 values are not equal and includes error message into revert string on failure.
function assertNotEq(bytes32 left, bytes32 right, string calldata error) external pure;
assertTrue
Asserts that the given condition is true.
function assertTrue(bool condition) external pure;
assertTrue
Asserts that the given condition is true and includes error message into revert string on failure.
function assertTrue(bool condition, string calldata error) external pure;
assume
If the condition is false, discard this run's fuzz inputs and generate new ones.
function assume(bool condition) external pure;
assumeNoRevert
Discard this run's fuzz inputs and generate new ones if next call reverted.
function assumeNoRevert() external pure;
assumeNoRevert
Discard this run's fuzz inputs and generate new ones if next call reverts with the potential revert parameters.
function assumeNoRevert(PotentialRevert calldata potentialRevert) external pure;
assumeNoRevert
Discard this run's fuzz inputs and generate new ones if next call reverts with the any of the potential revert parameters.
function assumeNoRevert(PotentialRevert[] calldata potentialReverts) external pure;
breakpoint
Writes a breakpoint to jump to in the debugger.
function breakpoint(string calldata char) external pure;
breakpoint
Writes a conditional breakpoint to jump to in the debugger.
function breakpoint(string calldata char, bool value) external pure;
foundryVersionAtLeast
Returns true if the current Foundry version is greater than or equal to the given version.
The given version string must be in the format major.minor.patch.
This is equivalent to foundryVersionCmp(version) >= 0.
function foundryVersionAtLeast(string calldata version) external view returns (bool);
foundryVersionCmp
Compares the current Foundry version with the given version string.
The given version string must be in the format major.minor.patch.
Returns:
-1 if current Foundry version is less than the given version
0 if current Foundry version equals the given version
1 if current Foundry version is greater than the given version
This result can then be used with a comparison operator against 0.
For example, to check if the current Foundry version is greater than or equal to 1.0.0:
if (foundryVersionCmp("1.0.0") >= 0) { ... }
function foundryVersionCmp(string calldata version) external view returns (int256);
getChain
Returns a Chain struct for specific alias
function getChain(string calldata chainAlias) external view returns (Chain memory chain);
getChain
Returns a Chain struct for specific chainId
function getChain(uint256 chainId) external view returns (Chain memory chain);
getFoundryVersion
Returns the Foundry version.
Format: <cargo_version>-
function getFoundryVersion() external view returns (string memory version);
rpcUrl
Returns the RPC url for the given alias.
function rpcUrl(string calldata rpcAlias) external view returns (string memory json);
rpcUrlStructs
Returns all rpc urls and their aliases as structs.
function rpcUrlStructs() external view returns (Rpc[] memory urls);
rpcUrls
Returns all rpc urls and their aliases [alias, url][].
function rpcUrls() external view returns (string[2][] memory urls);
sleep
Suspends execution of the main thread for duration milliseconds.
function sleep(uint256 duration) external;
keyExistsToml
Checks if key exists in a TOML table.
function keyExistsToml(string calldata toml, string calldata key) external view returns (bool);
parseTomlAddress
Parses a string of TOML data at key and coerces it to address.
function parseTomlAddress(string calldata toml, string calldata key) external pure returns (address);
parseTomlAddressArray
Parses a string of TOML data at key and coerces it to address[].
function parseTomlAddressArray(string calldata toml, string calldata key) external pure returns (address[] memory);
parseTomlBool
Parses a string of TOML data at key and coerces it to bool.
function parseTomlBool(string calldata toml, string calldata key) external pure returns (bool);
parseTomlBoolArray
Parses a string of TOML data at key and coerces it to bool[].
function parseTomlBoolArray(string calldata toml, string calldata key) external pure returns (bool[] memory);
parseTomlBytes
Parses a string of TOML data at key and coerces it to bytes.
function parseTomlBytes(string calldata toml, string calldata key) external pure returns (bytes memory);
parseTomlBytes32
Parses a string of TOML data at key and coerces it to bytes32.
function parseTomlBytes32(string calldata toml, string calldata key) external pure returns (bytes32);
parseTomlBytes32Array
Parses a string of TOML data at key and coerces it to bytes32[].
function parseTomlBytes32Array(string calldata toml, string calldata key) external pure returns (bytes32[] memory);
parseTomlBytesArray
Parses a string of TOML data at key and coerces it to bytes[].
function parseTomlBytesArray(string calldata toml, string calldata key) external pure returns (bytes[] memory);
parseTomlInt
Parses a string of TOML data at key and coerces it to int256.
function parseTomlInt(string calldata toml, string calldata key) external pure returns (int256);
parseTomlIntArray
Parses a string of TOML data at key and coerces it to int256[].
function parseTomlIntArray(string calldata toml, string calldata key) external pure returns (int256[] memory);
parseTomlKeys
Returns an array of all the keys in a TOML table.
function parseTomlKeys(string calldata toml, string calldata key) external pure returns (string[] memory keys);
parseTomlString
Parses a string of TOML data at key and coerces it to string.
function parseTomlString(string calldata toml, string calldata key) external pure returns (string memory);
parseTomlStringArray
Parses a string of TOML data at key and coerces it to string[].
function parseTomlStringArray(string calldata toml, string calldata key) external pure returns (string[] memory);
parseTomlTypeArray
Parses a string of TOML data at key and coerces it to type array corresponding to typeDescription.
function parseTomlTypeArray(string calldata toml, string calldata key, string calldata typeDescription)
external
pure
returns (bytes memory);
parseTomlType
Parses a string of TOML data and coerces it to type corresponding to typeDescription.
function parseTomlType(string calldata toml, string calldata typeDescription) external pure returns (bytes memory);
parseTomlType
Parses a string of TOML data at key and coerces it to type corresponding to typeDescription.
function parseTomlType(string calldata toml, string calldata key, string calldata typeDescription)
external
pure
returns (bytes memory);
parseTomlUint
Parses a string of TOML data at key and coerces it to uint256.
function parseTomlUint(string calldata toml, string calldata key) external pure returns (uint256);
parseTomlUintArray
Parses a string of TOML data at key and coerces it to uint256[].
function parseTomlUintArray(string calldata toml, string calldata key) external pure returns (uint256[] memory);
parseToml
ABI-encodes a TOML table.
function parseToml(string calldata toml) external pure returns (bytes memory abiEncodedData);
parseToml
ABI-encodes a TOML table at key.
function parseToml(string calldata toml, string calldata key) external pure returns (bytes memory abiEncodedData);
writeToml
Takes serialized JSON, converts to TOML and write a serialized TOML to a file.
function writeToml(string calldata json, string calldata path) external;
writeToml
Takes serialized JSON, converts to TOML and write a serialized TOML table to an existing TOML file, replacing a value with key = <value_key.> This is useful to replace a specific value of a TOML file, without having to parse the entire thing.
function writeToml(string calldata json, string calldata path, string calldata valueKey) external;
computeCreate2Address
Compute the address of a contract created with CREATE2 using the given CREATE2 deployer.
function computeCreate2Address(bytes32 salt, bytes32 initCodeHash, address deployer) external pure returns (address);
computeCreate2Address
Compute the address of a contract created with CREATE2 using the default CREATE2 deployer.
function computeCreate2Address(bytes32 salt, bytes32 initCodeHash) external pure returns (address);
computeCreateAddress
Compute the address a contract will be deployed at for a given deployer address and nonce.
function computeCreateAddress(address deployer, uint256 nonce) external pure returns (address);
copyStorage
Utility cheatcode to copy storage of from contract to another to contract.
function copyStorage(address from, address to) external;
ensNamehash
Returns ENS namehash for provided string.
function ensNamehash(string calldata name) external pure returns (bytes32);
getLabel
Gets the label for the specified address.
function getLabel(address account) external view returns (string memory currentLabel);
label
Labels an address in call traces.
function label(address account, string calldata newLabel) external;
pauseTracing
Pauses collection of call traces. Useful in cases when you want to skip tracing of complex calls which are not useful for debugging.
function pauseTracing() external view;
randomAddress
Returns a random address.
function randomAddress() external returns (address);
randomBool
Returns a random bool.
function randomBool() external view returns (bool);
randomBytes
Returns a random byte array value of the given length.
function randomBytes(uint256 len) external view returns (bytes memory);
randomBytes4
Returns a random fixed-size byte array of length 4.
function randomBytes4() external view returns (bytes4);
randomBytes8
Returns a random fixed-size byte array of length 8.
function randomBytes8() external view returns (bytes8);
randomInt
Returns a random int256 value.
function randomInt() external view returns (int256);
randomInt
Returns a random int256 value of given bits.
function randomInt(uint256 bits) external view returns (int256);
randomUint
Returns a random uint256 value.
function randomUint() external returns (uint256);
randomUint
Returns random uint256 value between the provided range (=min..=max).
function randomUint(uint256 min, uint256 max) external returns (uint256);
randomUint
Returns a random uint256 value of given bits.
function randomUint(uint256 bits) external view returns (uint256);
resumeTracing
Unpauses collection of call traces.
function resumeTracing() external view;
setArbitraryStorage
Utility cheatcode to set arbitrary storage for given target address.
function setArbitraryStorage(address target) external;
setArbitraryStorage
Utility cheatcode to set arbitrary storage for given target address and overwrite any storage slots that have been previously set.
function setArbitraryStorage(address target, bool overwrite) external;
shuffle
Randomly shuffles an array.
function shuffle(uint256[] calldata array) external returns (uint256[] memory);
sort
Sorts an array in ascending order.
function sort(uint256[] calldata array) external returns (uint256[] memory);
toBase64URL
Encodes a bytes value to a base64url string.
function toBase64URL(bytes calldata data) external pure returns (string memory);
toBase64URL
Encodes a string value to a base64url string.
function toBase64URL(string calldata data) external pure returns (string memory);
toBase64
Encodes a bytes value to a base64 string.
function toBase64(bytes calldata data) external pure returns (string memory);
toBase64
Encodes a string value to a base64 string.
function toBase64(string calldata data) external pure returns (string memory);
Structs
Log
An Ethereum log. Returned by getRecordedLogs.
struct Log {
bytes32[] topics;
bytes data;
address emitter;
}
Rpc
An RPC URL and its alias. Returned by rpcUrlStructs.
struct Rpc {
string key;
string url;
}
EthGetLogs
An RPC log object. Returned by eth_getLogs.
struct EthGetLogs {
address emitter;
bytes32[] topics;
bytes data;
bytes32 blockHash;
uint64 blockNumber;
bytes32 transactionHash;
uint64 transactionIndex;
uint256 logIndex;
bool removed;
}
DirEntry
A single entry in a directory listing. Returned by readDir.
struct DirEntry {
string errorMessage;
string path;
uint64 depth;
bool isDir;
bool isSymlink;
}
FsMetadata
Metadata information about a file.
This structure is returned from the fsMetadata function and represents known
metadata about a file such as its permissions, size, modification
times, etc.
struct FsMetadata {
bool isDir;
bool isSymlink;
uint256 length;
bool readOnly;
uint256 modified;
uint256 accessed;
uint256 created;
}
Wallet
A wallet with a public and private key.
struct Wallet {
address addr;
uint256 publicKeyX;
uint256 publicKeyY;
uint256 privateKey;
}
FfiResult
The result of a tryFfi call.
struct FfiResult {
int32 exitCode;
bytes stdout;
bytes stderr;
}
ChainInfo
Information on the chain and fork.
struct ChainInfo {
uint256 forkId;
uint256 chainId;
}
Chain
Information about a blockchain.
struct Chain {
string name;
uint256 chainId;
string chainAlias;
string rpcUrl;
}
AccountAccess
The result of a stopAndReturnStateDiff call.
struct AccountAccess {
ChainInfo chainInfo;
AccountAccessKind kind;
address account;
address accessor;
bool initialized;
uint256 oldBalance;
uint256 newBalance;
bytes deployedCode;
uint256 value;
bytes data;
bool reverted;
StorageAccess[] storageAccesses;
uint64 depth;
}
StorageAccess
The storage accessed during an AccountAccess.
struct StorageAccess {
address account;
bytes32 slot;
bool isWrite;
bytes32 previousValue;
bytes32 newValue;
bool reverted;
}
Gas
Gas used. Returned by lastCallGas.
struct Gas {
uint64 gasLimit;
uint64 gasTotalUsed;
uint64 gasMemoryUsed;
int64 gasRefunded;
uint64 gasRemaining;
}
DebugStep
The result of the stopDebugTraceRecording call
struct DebugStep {
uint256[] stack;
bytes memoryInput;
uint8 opcode;
uint64 depth;
bool isOutOfGas;
address contractAddr;
}
BroadcastTxSummary
Represents a transaction's broadcast details.
struct BroadcastTxSummary {
bytes32 txHash;
BroadcastTxType txType;
address contractAddress;
uint64 blockNumber;
bool success;
}
SignedDelegation
Holds a signed EIP-7702 authorization for an authority account to delegate to an implementation.
struct SignedDelegation {
uint8 v;
bytes32 r;
bytes32 s;
uint64 nonce;
address implementation;
}
PotentialRevert
Represents a "potential" revert reason from a single subsequent call when using vm.assumeNoReverts.
Reverts that match will result in a FOUNDRY::ASSUME rejection, whereas unmatched reverts will be surfaced
as normal.
struct PotentialRevert {
address reverter;
bool partialMatch;
bytes revertData;
}
AccessListItem
An EIP-2930 access list item.
struct AccessListItem {
address target;
bytes32[] storageKeys;
}
Enums
CallerMode
A modification applied to either msg.sender or tx.origin. Returned by readCallers.
enum CallerMode {
None,
Broadcast,
RecurrentBroadcast,
Prank,
RecurrentPrank
}
AccountAccessKind
The kind of account access that occurred.
enum AccountAccessKind {
Call,
DelegateCall,
CallCode,
StaticCall,
Create,
SelfDestruct,
Resume,
Balance,
Extcodesize,
Extcodehash,
Extcodecopy
}
ForgeContext
Forge execution contexts.
enum ForgeContext {
TestGroup,
Test,
Coverage,
Snapshot,
ScriptGroup,
ScriptDryRun,
ScriptBroadcast,
ScriptResume,
Unknown
}
BroadcastTxType
The transaction type (txType) of the broadcast.
enum BroadcastTxType {
Call,
Create,
Create2
}
Vm
Inherits: VmSafe
The Vm interface does allow manipulation of the EVM state. These are all intended to be used
in tests, but it is not recommended to use these cheats in scripts.
Functions
accessList
Utility cheatcode to set an EIP-2930 access list for all subsequent transactions.
function accessList(AccessListItem[] calldata access) external;
activeFork
Returns the identifier of the currently active fork. Reverts if no fork is currently active.
function activeFork() external view returns (uint256 forkId);
allowCheatcodes
In forking mode, explicitly grant the given address cheatcode access.
function allowCheatcodes(address account) external;
blobBaseFee
Sets block.blobbasefee
function blobBaseFee(uint256 newBlobBaseFee) external;
blobhashes
Sets the blobhashes in the transaction. Not available on EVM versions before Cancun. If used on unsupported EVM versions it will revert.
function blobhashes(bytes32[] calldata hashes) external;
chainId
Sets block.chainid.
function chainId(uint256 newChainId) external;
clearMockedCalls
Clears all mocked calls.
function clearMockedCalls() external;
cloneAccount
Clones a source account code, state, balance and nonce to a target account and updates in-memory EVM state.
function cloneAccount(address source, address target) external;
coinbase
Sets block.coinbase.
function coinbase(address newCoinbase) external;
cool
Marks the slots of an account and the account address as cold.
function cool(address target) external;
coolSlot
Utility cheatcode to mark specific storage slot as cold, simulating no prior read.
function coolSlot(address target, bytes32 slot) external;
createFork
Creates a new fork with the given endpoint and the latest block and returns the identifier of the fork.
function createFork(string calldata urlOrAlias) external returns (uint256 forkId);
createFork
Creates a new fork with the given endpoint and block and returns the identifier of the fork.
function createFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);
createFork
Creates a new fork with the given endpoint and at the block the given transaction was mined in, replays all transaction mined in the block before the transaction, and returns the identifier of the fork.
function createFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);
createSelectFork
Creates and also selects a new fork with the given endpoint and the latest block and returns the identifier of the fork.
function createSelectFork(string calldata urlOrAlias) external returns (uint256 forkId);
createSelectFork
Creates and also selects a new fork with the given endpoint and block and returns the identifier of the fork.
function createSelectFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);
createSelectFork
Creates and also selects new fork with the given endpoint and at the block the given transaction was mined in, replays all transaction mined in the block before the transaction, returns the identifier of the fork.
function createSelectFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);
deal
Sets an address' balance.
function deal(address account, uint256 newBalance) external;
deleteStateSnapshot
Removes the snapshot with the given ID created by snapshot.
Takes the snapshot ID to delete.
Returns true if the snapshot was successfully deleted.
Returns false if the snapshot does not exist.
function deleteStateSnapshot(uint256 snapshotId) external returns (bool success);
deleteStateSnapshots
Removes all snapshots previously created by snapshot.
function deleteStateSnapshots() external;
difficulty
Sets block.difficulty.
Not available on EVM versions from Paris onwards. Use prevrandao instead.
Reverts if used on unsupported EVM versions.
function difficulty(uint256 newDifficulty) external;
dumpState
Dump a genesis JSON file's allocs to disk.
function dumpState(string calldata pathToStateJson) external;
etch
Sets an address' code.
function etch(address target, bytes calldata newRuntimeBytecode) external;
fee
Sets block.basefee.
function fee(uint256 newBasefee) external;
getBlobhashes
Gets the blockhashes from the current transaction. Not available on EVM versions before Cancun. If used on unsupported EVM versions it will revert.
function getBlobhashes() external view returns (bytes32[] memory hashes);
isPersistent
Returns true if the account is marked as persistent.
function isPersistent(address account) external view returns (bool persistent);
loadAllocs
Load a genesis JSON file's allocs into the in-memory EVM state.
function loadAllocs(string calldata pathToAllocsJson) external;
makePersistent
Marks that the account(s) should use persistent storage across fork swaps in a multifork setup Meaning, changes made to the state of this account will be kept when switching forks.
function makePersistent(address account) external;
makePersistent
See makePersistent(address).
function makePersistent(address account0, address account1) external;
makePersistent
See makePersistent(address).
function makePersistent(address account0, address account1, address account2) external;
makePersistent
See makePersistent(address).
function makePersistent(address[] calldata accounts) external;
mockCallRevert
Reverts a call to an address with specified revert data.
function mockCallRevert(address callee, bytes calldata data, bytes calldata revertData) external;
mockCallRevert
Reverts a call to an address with a specific msg.value, with specified revert data.
function mockCallRevert(address callee, uint256 msgValue, bytes calldata data, bytes calldata revertData) external;
mockCallRevert
Reverts a call to an address with specified revert data.
Overload to pass the function selector directly token.approve.selector instead of abi.encodeWithSelector(token.approve.selector).
function mockCallRevert(address callee, bytes4 data, bytes calldata revertData) external;
mockCallRevert
Reverts a call to an address with a specific msg.value, with specified revert data.
Overload to pass the function selector directly token.approve.selector instead of abi.encodeWithSelector(token.approve.selector).
function mockCallRevert(address callee, uint256 msgValue, bytes4 data, bytes calldata revertData) external;
mockCall
Mocks a call to an address, returning specified data. Calldata can either be strict or a partial match, e.g. if you only pass a Solidity selector to the expected calldata, then the entire Solidity function will be mocked.
function mockCall(address callee, bytes calldata data, bytes calldata returnData) external;
mockCall
Mocks a call to an address with a specific msg.value, returning specified data.
Calldata match takes precedence over msg.value in case of ambiguity.
function mockCall(address callee, uint256 msgValue, bytes calldata data, bytes calldata returnData) external;
mockCall
Mocks a call to an address, returning specified data.
Calldata can either be strict or a partial match, e.g. if you only
pass a Solidity selector to the expected calldata, then the entire Solidity
function will be mocked.
Overload to pass the function selector directly token.approve.selector instead of abi.encodeWithSelector(token.approve.selector).
function mockCall(address callee, bytes4 data, bytes calldata returnData) external;
mockCall
Mocks a call to an address with a specific msg.value, returning specified data.
Calldata match takes precedence over msg.value in case of ambiguity.
Overload to pass the function selector directly token.approve.selector instead of abi.encodeWithSelector(token.approve.selector).
function mockCall(address callee, uint256 msgValue, bytes4 data, bytes calldata returnData) external;
mockCalls
Mocks multiple calls to an address, returning specified data for each call.
function mockCalls(address callee, bytes calldata data, bytes[] calldata returnData) external;
mockCalls
Mocks multiple calls to an address with a specific msg.value, returning specified data for each call.
function mockCalls(address callee, uint256 msgValue, bytes calldata data, bytes[] calldata returnData) external;
mockFunction
Whenever a call is made to callee with calldata data, this cheatcode instead calls
target with the same calldata. This functionality is similar to a delegate call made to
target contract from callee.
Can be used to substitute a call to a function with another implementation that captures
the primary logic of the original function but is easier to reason about.
If calldata is not a strict match then partial match by selector is attempted.
function mockFunction(address callee, address target, bytes calldata data) external;
noAccessList
Utility cheatcode to remove any EIP-2930 access list set by accessList cheatcode.
function noAccessList() external;
prank
Sets the next call's msg.sender to be the input address.
function prank(address msgSender) external;
prank
Sets the next call's msg.sender to be the input address, and the tx.origin to be the second input.
function prank(address msgSender, address txOrigin) external;
prank
Sets the next delegate call's msg.sender to be the input address.
function prank(address msgSender, bool delegateCall) external;
prank
Sets the next delegate call's msg.sender to be the input address, and the tx.origin to be the second input.
function prank(address msgSender, address txOrigin, bool delegateCall) external;
prevrandao
Sets block.prevrandao.
Not available on EVM versions before Paris. Use difficulty instead.
If used on unsupported EVM versions it will revert.
function prevrandao(bytes32 newPrevrandao) external;
prevrandao
Sets block.prevrandao.
Not available on EVM versions before Paris. Use difficulty instead.
If used on unsupported EVM versions it will revert.
function prevrandao(uint256 newPrevrandao) external;
readCallers
Reads the current msg.sender and tx.origin from state and reports if there is any active caller modification.
function readCallers() external returns (CallerMode callerMode, address msgSender, address txOrigin);
resetNonce
Resets the nonce of an account to 0 for EOAs and 1 for contract accounts.
function resetNonce(address account) external;
revertToState
Revert the state of the EVM to a previous snapshot
Takes the snapshot ID to revert to.
Returns true if the snapshot was successfully reverted.
Returns false if the snapshot does not exist.
Note: This does not automatically delete the snapshot. To delete the snapshot use deleteStateSnapshot.
function revertToState(uint256 snapshotId) external returns (bool success);
revertToStateAndDelete
Revert the state of the EVM to a previous snapshot and automatically deletes the snapshots
Takes the snapshot ID to revert to.
Returns true if the snapshot was successfully reverted and deleted.
Returns false if the snapshot does not exist.
function revertToStateAndDelete(uint256 snapshotId) external returns (bool success);
revokePersistent
Revokes persistent status from the address, previously added via makePersistent.
function revokePersistent(address account) external;
revokePersistent
See revokePersistent(address).
function revokePersistent(address[] calldata accounts) external;
roll
Sets block.height.
function roll(uint256 newHeight) external;
rollFork
Updates the currently active fork to given block number
This is similar to roll but for the currently active fork.
function rollFork(uint256 blockNumber) external;
rollFork
Updates the currently active fork to given transaction. This will rollFork with the number
of the block the transaction was mined in and replays all transaction mined before it in the block.
function rollFork(bytes32 txHash) external;
rollFork
Updates the given fork to given block number.
function rollFork(uint256 forkId, uint256 blockNumber) external;
rollFork
Updates the given fork to block number of the given transaction and replays all transaction mined before it in the block.
function rollFork(uint256 forkId, bytes32 txHash) external;
selectFork
Takes a fork identifier created by createFork and sets the corresponding forked state as active.
function selectFork(uint256 forkId) external;
setBlockhash
Set blockhash for the current block.
It only sets the blockhash for blocks where block.number - 256 <= number < block.number.
function setBlockhash(uint256 blockNumber, bytes32 blockHash) external;
setNonce
Sets the nonce of an account. Must be higher than the current nonce of the account.
function setNonce(address account, uint64 newNonce) external;
setNonceUnsafe
Sets the nonce of an account to an arbitrary value.
function setNonceUnsafe(address account, uint64 newNonce) external;
snapshotGasLastCall
Snapshot capture the gas usage of the last call by name from the callee perspective.
function snapshotGasLastCall(string calldata name) external returns (uint256 gasUsed);
snapshotGasLastCall
Snapshot capture the gas usage of the last call by name in a group from the callee perspective.
function snapshotGasLastCall(string calldata group, string calldata name) external returns (uint256 gasUsed);
snapshotState
Snapshot the current state of the evm.
Returns the ID of the snapshot that was created.
To revert a snapshot use revertToState.
function snapshotState() external returns (uint256 snapshotId);
snapshotValue
Snapshot capture an arbitrary numerical value by name. The group name is derived from the contract name.
function snapshotValue(string calldata name, uint256 value) external;
snapshotValue
Snapshot capture an arbitrary numerical value by name in a group.
function snapshotValue(string calldata group, string calldata name, uint256 value) external;
startPrank
Sets all subsequent calls' msg.sender to be the input address until stopPrank is called.
function startPrank(address msgSender) external;
startPrank
Sets all subsequent calls' msg.sender to be the input address until stopPrank is called, and the tx.origin to be the second input.
function startPrank(address msgSender, address txOrigin) external;
startPrank
Sets all subsequent delegate calls' msg.sender to be the input address until stopPrank is called.
function startPrank(address msgSender, bool delegateCall) external;
startPrank
Sets all subsequent delegate calls' msg.sender to be the input address until stopPrank is called, and the tx.origin to be the second input.
function startPrank(address msgSender, address txOrigin, bool delegateCall) external;
startSnapshotGas
Start a snapshot capture of the current gas usage by name. The group name is derived from the contract name.
function startSnapshotGas(string calldata name) external;
startSnapshotGas
Start a snapshot capture of the current gas usage by name in a group.
function startSnapshotGas(string calldata group, string calldata name) external;
stopPrank
Resets subsequent calls' msg.sender to be address(this).
function stopPrank() external;
stopSnapshotGas
Stop the snapshot capture of the current gas by latest snapshot name, capturing the gas used since the start.
function stopSnapshotGas() external returns (uint256 gasUsed);
stopSnapshotGas
Stop the snapshot capture of the current gas usage by name, capturing the gas used since the start. The group name is derived from the contract name.
function stopSnapshotGas(string calldata name) external returns (uint256 gasUsed);
stopSnapshotGas
Stop the snapshot capture of the current gas usage by name in a group, capturing the gas used since the start.
function stopSnapshotGas(string calldata group, string calldata name) external returns (uint256 gasUsed);
store
Stores a value to an address' storage slot.
function store(address target, bytes32 slot, bytes32 value) external;
transact
Fetches the given transaction from the active fork and executes it on the current state.
function transact(bytes32 txHash) external;
transact
Fetches the given transaction from the given fork and executes it on the current state.
function transact(uint256 forkId, bytes32 txHash) external;
txGasPrice
Sets tx.gasprice.
function txGasPrice(uint256 newGasPrice) external;
warmSlot
Utility cheatcode to mark specific storage slot as warm, simulating a prior read.
function warmSlot(address target, bytes32 slot) external;
warp
Sets block.timestamp.
function warp(uint256 newTimestamp) external;
deleteSnapshot
deleteSnapshot is being deprecated in favor of deleteStateSnapshot. It will be removed in future versions.
function deleteSnapshot(uint256 snapshotId) external returns (bool success);
deleteSnapshots
deleteSnapshots is being deprecated in favor of deleteStateSnapshots. It will be removed in future versions.
function deleteSnapshots() external;
revertToAndDelete
revertToAndDelete is being deprecated in favor of revertToStateAndDelete. It will be removed in future versions.
function revertToAndDelete(uint256 snapshotId) external returns (bool success);
revertTo
revertTo is being deprecated in favor of revertToState. It will be removed in future versions.
function revertTo(uint256 snapshotId) external returns (bool success);
snapshot
snapshot is being deprecated in favor of snapshotState. It will be removed in future versions.
function snapshot() external returns (uint256 snapshotId);
expectCallMinGas
Expect a call to an address with the specified msg.value and calldata, and a minimum amount of gas.
function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data) external;
expectCallMinGas
Expect given number of calls to an address with the specified msg.value and calldata, and a minimum amount of gas.
function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data, uint64 count)
external;
expectCall
Expects a call to an address with the specified calldata. Calldata can either be a strict or a partial match.
function expectCall(address callee, bytes calldata data) external;
expectCall
Expects given number of calls to an address with the specified calldata.
function expectCall(address callee, bytes calldata data, uint64 count) external;
expectCall
Expects a call to an address with the specified msg.value and calldata.
function expectCall(address callee, uint256 msgValue, bytes calldata data) external;
expectCall
Expects given number of calls to an address with the specified msg.value and calldata.
function expectCall(address callee, uint256 msgValue, bytes calldata data, uint64 count) external;
expectCall
Expect a call to an address with the specified msg.value, gas, and calldata.
function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data) external;
expectCall
Expects given number of calls to an address with the specified msg.value, gas, and calldata.
function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data, uint64 count) external;
expectCreate
Expects the deployment of the specified bytecode by the specified address using the CREATE opcode
function expectCreate(bytes calldata bytecode, address deployer) external;
expectCreate2
Expects the deployment of the specified bytecode by the specified address using the CREATE2 opcode
function expectCreate2(bytes calldata bytecode, address deployer) external;
expectEmitAnonymous
Prepare an expected anonymous log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData.). Call this function, then emit an anonymous event, then call a function. Internally after the call, we check if logs were emitted in the expected order with the expected topics and data (as specified by the booleans).
function expectEmitAnonymous(bool checkTopic0, bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData)
external;
expectEmitAnonymous
Same as the previous method, but also checks supplied address against emitting contract.
function expectEmitAnonymous(
bool checkTopic0,
bool checkTopic1,
bool checkTopic2,
bool checkTopic3,
bool checkData,
address emitter
) external;
expectEmitAnonymous
Prepare an expected anonymous log with all topic and data checks enabled. Call this function, then emit an anonymous event, then call a function. Internally after the call, we check if logs were emitted in the expected order with the expected topics and data.
function expectEmitAnonymous() external;
expectEmitAnonymous
Same as the previous method, but also checks supplied address against emitting contract.
function expectEmitAnonymous(address emitter) external;
expectEmit
Prepare an expected log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData.). Call this function, then emit an event, then call a function. Internally after the call, we check if logs were emitted in the expected order with the expected topics and data (as specified by the booleans).
function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external;
expectEmit
Same as the previous method, but also checks supplied address against emitting contract.
function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter) external;
expectEmit
Prepare an expected log with all topic and data checks enabled. Call this function, then emit an event, then call a function. Internally after the call, we check if logs were emitted in the expected order with the expected topics and data.
function expectEmit() external;
expectEmit
Same as the previous method, but also checks supplied address against emitting contract.
function expectEmit(address emitter) external;
expectEmit
Expect a given number of logs with the provided topics.
function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, uint64 count) external;
expectEmit
Expect a given number of logs from a specific emitter with the provided topics.
function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter, uint64 count)
external;
expectEmit
Expect a given number of logs with all topic and data checks enabled.
function expectEmit(uint64 count) external;
expectEmit
Expect a given number of logs from a specific emitter with all topic and data checks enabled.
function expectEmit(address emitter, uint64 count) external;
expectPartialRevert
Expects an error on next call that starts with the revert data.
function expectPartialRevert(bytes4 revertData) external;
expectPartialRevert
Expects an error on next call to reverter address, that starts with the revert data.
function expectPartialRevert(bytes4 revertData, address reverter) external;
expectRevert
Expects an error on next call with any revert data.
function expectRevert() external;
expectRevert
Expects an error on next call that exactly matches the revert data.
function expectRevert(bytes4 revertData) external;
expectRevert
Expects a count number of reverts from the upcoming calls from the reverter address that match the revert data.
function expectRevert(bytes4 revertData, address reverter, uint64 count) external;
expectRevert
Expects a count number of reverts from the upcoming calls from the reverter address that exactly match the revert data.
function expectRevert(bytes calldata revertData, address reverter, uint64 count) external;
expectRevert
Expects an error on next call that exactly matches the revert data.
function expectRevert(bytes calldata revertData) external;
expectRevert
Expects an error with any revert data on next call to reverter address.
function expectRevert(address reverter) external;
expectRevert
Expects an error from reverter address on next call, with any revert data.
function expectRevert(bytes4 revertData, address reverter) external;
expectRevert
Expects an error from reverter address on next call, that exactly matches the revert data.
function expectRevert(bytes calldata revertData, address reverter) external;
expectRevert
Expects a count number of reverts from the upcoming calls with any revert data or reverter.
function expectRevert(uint64 count) external;
expectRevert
Expects a count number of reverts from the upcoming calls that match the revert data.
function expectRevert(bytes4 revertData, uint64 count) external;
expectRevert
Expects a count number of reverts from the upcoming calls that exactly match the revert data.
function expectRevert(bytes calldata revertData, uint64 count) external;
expectRevert
Expects a count number of reverts from the upcoming calls from the reverter address.
function expectRevert(address reverter, uint64 count) external;
expectSafeMemory
Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the current subcontext. If any other memory is written to, the test will fail. Can be called multiple times to add more ranges to the set.
function expectSafeMemory(uint64 min, uint64 max) external;
expectSafeMemoryCall
Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the next created subcontext. If any other memory is written to, the test will fail. Can be called multiple times to add more ranges to the set.
function expectSafeMemoryCall(uint64 min, uint64 max) external;
skip
Marks a test as skipped. Must be called at the top level of a test.
function skip(bool skipTest) external;
skip
Marks a test as skipped with a reason. Must be called at the top level of a test.
function skip(bool skipTest, string calldata reason) external;
stopExpectSafeMemory
Stops all safe memory expectation in the current subcontext.
function stopExpectSafeMemory() external;
interceptInitcode
Causes the next contract creation (via new) to fail and return its initcode in the returndata buffer. This allows type-safe access to the initcode payload that would be used for contract creation. Example usage: vm.interceptInitcode(); bytes memory initcode; try new MyContract(param1, param2) { assert(false); } catch (bytes memory interceptedInitcode) { initcode = interceptedInitcode; }
function interceptInitcode() external;
console
State Variables
CONSOLE_ADDRESS
address constant CONSOLE_ADDRESS = 0x000000000000000000636F6e736F6c652e6c6f67;
Functions
_sendLogPayloadImplementation
function _sendLogPayloadImplementation(bytes memory payload) internal view;
_castToPure
function _castToPure(function(bytes memory) internal view fnIn)
internal
pure
returns (function(bytes memory) pure fnOut);
_sendLogPayload
function _sendLogPayload(bytes memory payload) internal pure;
log
function log() internal pure;
logInt
function logInt(int256 p0) internal pure;
logUint
function logUint(uint256 p0) internal pure;
logString
function logString(string memory p0) internal pure;
logBool
function logBool(bool p0) internal pure;
logAddress
function logAddress(address p0) internal pure;
logBytes
function logBytes(bytes memory p0) internal pure;
logBytes1
function logBytes1(bytes1 p0) internal pure;
logBytes2
function logBytes2(bytes2 p0) internal pure;
logBytes3
function logBytes3(bytes3 p0) internal pure;
logBytes4
function logBytes4(bytes4 p0) internal pure;
logBytes5
function logBytes5(bytes5 p0) internal pure;
logBytes6
function logBytes6(bytes6 p0) internal pure;
logBytes7
function logBytes7(bytes7 p0) internal pure;
logBytes8
function logBytes8(bytes8 p0) internal pure;
logBytes9
function logBytes9(bytes9 p0) internal pure;
logBytes10
function logBytes10(bytes10 p0) internal pure;
logBytes11
function logBytes11(bytes11 p0) internal pure;
logBytes12
function logBytes12(bytes12 p0) internal pure;
logBytes13
function logBytes13(bytes13 p0) internal pure;
logBytes14
function logBytes14(bytes14 p0) internal pure;
logBytes15
function logBytes15(bytes15 p0) internal pure;
logBytes16
function logBytes16(bytes16 p0) internal pure;
logBytes17
function logBytes17(bytes17 p0) internal pure;
logBytes18
function logBytes18(bytes18 p0) internal pure;
logBytes19
function logBytes19(bytes19 p0) internal pure;
logBytes20
function logBytes20(bytes20 p0) internal pure;
logBytes21
function logBytes21(bytes21 p0) internal pure;
logBytes22
function logBytes22(bytes22 p0) internal pure;
logBytes23
function logBytes23(bytes23 p0) internal pure;
logBytes24
function logBytes24(bytes24 p0) internal pure;
logBytes25
function logBytes25(bytes25 p0) internal pure;
logBytes26
function logBytes26(bytes26 p0) internal pure;
logBytes27
function logBytes27(bytes27 p0) internal pure;
logBytes28
function logBytes28(bytes28 p0) internal pure;
logBytes29
function logBytes29(bytes29 p0) internal pure;
logBytes30
function logBytes30(bytes30 p0) internal pure;
logBytes31
function logBytes31(bytes31 p0) internal pure;
logBytes32
function logBytes32(bytes32 p0) internal pure;
log
function log(uint256 p0) internal pure;
log
function log(int256 p0) internal pure;
log
function log(string memory p0) internal pure;
log
function log(bool p0) internal pure;
log
function log(address p0) internal pure;
log
function log(uint256 p0, uint256 p1) internal pure;
log
function log(uint256 p0, string memory p1) internal pure;
log
function log(uint256 p0, bool p1) internal pure;
log
function log(uint256 p0, address p1) internal pure;
log
function log(string memory p0, uint256 p1) internal pure;
log
function log(string memory p0, int256 p1) internal pure;
log
function log(string memory p0, string memory p1) internal pure;
log
function log(string memory p0, bool p1) internal pure;
log
function log(string memory p0, address p1) internal pure;
log
function log(bool p0, uint256 p1) internal pure;
log
function log(bool p0, string memory p1) internal pure;
log
function log(bool p0, bool p1) internal pure;
log
function log(bool p0, address p1) internal pure;
log
function log(address p0, uint256 p1) internal pure;
log
function log(address p0, string memory p1) internal pure;
log
function log(address p0, bool p1) internal pure;
log
function log(address p0, address p1) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2) internal pure;
log
function log(uint256 p0, uint256 p1, string memory p2) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2) internal pure;
log
function log(uint256 p0, uint256 p1, address p2) internal pure;
log
function log(uint256 p0, string memory p1, uint256 p2) internal pure;
log
function log(uint256 p0, string memory p1, string memory p2) internal pure;
log
function log(uint256 p0, string memory p1, bool p2) internal pure;
log
function log(uint256 p0, string memory p1, address p2) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2) internal pure;
log
function log(uint256 p0, bool p1, string memory p2) internal pure;
log
function log(uint256 p0, bool p1, bool p2) internal pure;
log
function log(uint256 p0, bool p1, address p2) internal pure;
log
function log(uint256 p0, address p1, uint256 p2) internal pure;
log
function log(uint256 p0, address p1, string memory p2) internal pure;
log
function log(uint256 p0, address p1, bool p2) internal pure;
log
function log(uint256 p0, address p1, address p2) internal pure;
log
function log(string memory p0, uint256 p1, uint256 p2) internal pure;
log
function log(string memory p0, uint256 p1, string memory p2) internal pure;
log
function log(string memory p0, uint256 p1, bool p2) internal pure;
log
function log(string memory p0, uint256 p1, address p2) internal pure;
log
function log(string memory p0, string memory p1, uint256 p2) internal pure;
log
function log(string memory p0, string memory p1, string memory p2) internal pure;
log
function log(string memory p0, string memory p1, bool p2) internal pure;
log
function log(string memory p0, string memory p1, address p2) internal pure;
log
function log(string memory p0, bool p1, uint256 p2) internal pure;
log
function log(string memory p0, bool p1, string memory p2) internal pure;
log
function log(string memory p0, bool p1, bool p2) internal pure;
log
function log(string memory p0, bool p1, address p2) internal pure;
log
function log(string memory p0, address p1, uint256 p2) internal pure;
log
function log(string memory p0, address p1, string memory p2) internal pure;
log
function log(string memory p0, address p1, bool p2) internal pure;
log
function log(string memory p0, address p1, address p2) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2) internal pure;
log
function log(bool p0, uint256 p1, string memory p2) internal pure;
log
function log(bool p0, uint256 p1, bool p2) internal pure;
log
function log(bool p0, uint256 p1, address p2) internal pure;
log
function log(bool p0, string memory p1, uint256 p2) internal pure;
log
function log(bool p0, string memory p1, string memory p2) internal pure;
log
function log(bool p0, string memory p1, bool p2) internal pure;
log
function log(bool p0, string memory p1, address p2) internal pure;
log
function log(bool p0, bool p1, uint256 p2) internal pure;
log
function log(bool p0, bool p1, string memory p2) internal pure;
log
function log(bool p0, bool p1, bool p2) internal pure;
log
function log(bool p0, bool p1, address p2) internal pure;
log
function log(bool p0, address p1, uint256 p2) internal pure;
log
function log(bool p0, address p1, string memory p2) internal pure;
log
function log(bool p0, address p1, bool p2) internal pure;
log
function log(bool p0, address p1, address p2) internal pure;
log
function log(address p0, uint256 p1, uint256 p2) internal pure;
log
function log(address p0, uint256 p1, string memory p2) internal pure;
log
function log(address p0, uint256 p1, bool p2) internal pure;
log
function log(address p0, uint256 p1, address p2) internal pure;
log
function log(address p0, string memory p1, uint256 p2) internal pure;
log
function log(address p0, string memory p1, string memory p2) internal pure;
log
function log(address p0, string memory p1, bool p2) internal pure;
log
function log(address p0, string memory p1, address p2) internal pure;
log
function log(address p0, bool p1, uint256 p2) internal pure;
log
function log(address p0, bool p1, string memory p2) internal pure;
log
function log(address p0, bool p1, bool p2) internal pure;
log
function log(address p0, bool p1, address p2) internal pure;
log
function log(address p0, address p1, uint256 p2) internal pure;
log
function log(address p0, address p1, string memory p2) internal pure;
log
function log(address p0, address p1, bool p2) internal pure;
log
function log(address p0, address p1, address p2) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2, uint256 p3) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2, string memory p3) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2, bool p3) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2, address p3) internal pure;
log
function log(uint256 p0, uint256 p1, string memory p2, uint256 p3) internal pure;
log
function log(uint256 p0, uint256 p1, string memory p2, string memory p3) internal pure;
log
function log(uint256 p0, uint256 p1, string memory p2, bool p3) internal pure;
log
function log(uint256 p0, uint256 p1, string memory p2, address p3) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2, uint256 p3) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2, string memory p3) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2, bool p3) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2, address p3) internal pure;
log
function log(uint256 p0, uint256 p1, address p2, uint256 p3) internal pure;
log
function log(uint256 p0, uint256 p1, address p2, string memory p3) internal pure;
log
function log(uint256 p0, uint256 p1, address p2, bool p3) internal pure;
log
function log(uint256 p0, uint256 p1, address p2, address p3) internal pure;
log
function log(uint256 p0, string memory p1, uint256 p2, uint256 p3) internal pure;
log
function log(uint256 p0, string memory p1, uint256 p2, string memory p3) internal pure;
log
function log(uint256 p0, string memory p1, uint256 p2, bool p3) internal pure;
log
function log(uint256 p0, string memory p1, uint256 p2, address p3) internal pure;
log
function log(uint256 p0, string memory p1, string memory p2, uint256 p3) internal pure;
log
function log(uint256 p0, string memory p1, string memory p2, string memory p3) internal pure;
log
function log(uint256 p0, string memory p1, string memory p2, bool p3) internal pure;
log
function log(uint256 p0, string memory p1, string memory p2, address p3) internal pure;
log
function log(uint256 p0, string memory p1, bool p2, uint256 p3) internal pure;
log
function log(uint256 p0, string memory p1, bool p2, string memory p3) internal pure;
log
function log(uint256 p0, string memory p1, bool p2, bool p3) internal pure;
log
function log(uint256 p0, string memory p1, bool p2, address p3) internal pure;
log
function log(uint256 p0, string memory p1, address p2, uint256 p3) internal pure;
log
function log(uint256 p0, string memory p1, address p2, string memory p3) internal pure;
log
function log(uint256 p0, string memory p1, address p2, bool p3) internal pure;
log
function log(uint256 p0, string memory p1, address p2, address p3) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2, uint256 p3) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2, string memory p3) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2, bool p3) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2, address p3) internal pure;
log
function log(uint256 p0, bool p1, string memory p2, uint256 p3) internal pure;
log
function log(uint256 p0, bool p1, string memory p2, string memory p3) internal pure;
log
function log(uint256 p0, bool p1, string memory p2, bool p3) internal pure;
log
function log(uint256 p0, bool p1, string memory p2, address p3) internal pure;
log
function log(uint256 p0, bool p1, bool p2, uint256 p3) internal pure;
log
function log(uint256 p0, bool p1, bool p2, string memory p3) internal pure;
log
function log(uint256 p0, bool p1, bool p2, bool p3) internal pure;
log
function log(uint256 p0, bool p1, bool p2, address p3) internal pure;
log
function log(uint256 p0, bool p1, address p2, uint256 p3) internal pure;
log
function log(uint256 p0, bool p1, address p2, string memory p3) internal pure;
log
function log(uint256 p0, bool p1, address p2, bool p3) internal pure;
log
function log(uint256 p0, bool p1, address p2, address p3) internal pure;
log
function log(uint256 p0, address p1, uint256 p2, uint256 p3) internal pure;
log
function log(uint256 p0, address p1, uint256 p2, string memory p3) internal pure;
log
function log(uint256 p0, address p1, uint256 p2, bool p3) internal pure;
log
function log(uint256 p0, address p1, uint256 p2, address p3) internal pure;
log
function log(uint256 p0, address p1, string memory p2, uint256 p3) internal pure;
log
function log(uint256 p0, address p1, string memory p2, string memory p3) internal pure;
log
function log(uint256 p0, address p1, string memory p2, bool p3) internal pure;
log
function log(uint256 p0, address p1, string memory p2, address p3) internal pure;
log
function log(uint256 p0, address p1, bool p2, uint256 p3) internal pure;
log
function log(uint256 p0, address p1, bool p2, string memory p3) internal pure;
log
function log(uint256 p0, address p1, bool p2, bool p3) internal pure;
log
function log(uint256 p0, address p1, bool p2, address p3) internal pure;
log
function log(uint256 p0, address p1, address p2, uint256 p3) internal pure;
log
function log(uint256 p0, address p1, address p2, string memory p3) internal pure;
log
function log(uint256 p0, address p1, address p2, bool p3) internal pure;
log
function log(uint256 p0, address p1, address p2, address p3) internal pure;
log
function log(string memory p0, uint256 p1, uint256 p2, uint256 p3) internal pure;
log
function log(string memory p0, uint256 p1, uint256 p2, string memory p3) internal pure;
log
function log(string memory p0, uint256 p1, uint256 p2, bool p3) internal pure;
log
function log(string memory p0, uint256 p1, uint256 p2, address p3) internal pure;
log
function log(string memory p0, uint256 p1, string memory p2, uint256 p3) internal pure;
log
function log(string memory p0, uint256 p1, string memory p2, string memory p3) internal pure;
log
function log(string memory p0, uint256 p1, string memory p2, bool p3) internal pure;
log
function log(string memory p0, uint256 p1, string memory p2, address p3) internal pure;
log
function log(string memory p0, uint256 p1, bool p2, uint256 p3) internal pure;
log
function log(string memory p0, uint256 p1, bool p2, string memory p3) internal pure;
log
function log(string memory p0, uint256 p1, bool p2, bool p3) internal pure;
log
function log(string memory p0, uint256 p1, bool p2, address p3) internal pure;
log
function log(string memory p0, uint256 p1, address p2, uint256 p3) internal pure;
log
function log(string memory p0, uint256 p1, address p2, string memory p3) internal pure;
log
function log(string memory p0, uint256 p1, address p2, bool p3) internal pure;
log
function log(string memory p0, uint256 p1, address p2, address p3) internal pure;
log
function log(string memory p0, string memory p1, uint256 p2, uint256 p3) internal pure;
log
function log(string memory p0, string memory p1, uint256 p2, string memory p3) internal pure;
log
function log(string memory p0, string memory p1, uint256 p2, bool p3) internal pure;
log
function log(string memory p0, string memory p1, uint256 p2, address p3) internal pure;
log
function log(string memory p0, string memory p1, string memory p2, uint256 p3) internal pure;
log
function log(string memory p0, string memory p1, string memory p2, string memory p3) internal pure;
log
function log(string memory p0, string memory p1, string memory p2, bool p3) internal pure;
log
function log(string memory p0, string memory p1, string memory p2, address p3) internal pure;
log
function log(string memory p0, string memory p1, bool p2, uint256 p3) internal pure;
log
function log(string memory p0, string memory p1, bool p2, string memory p3) internal pure;
log
function log(string memory p0, string memory p1, bool p2, bool p3) internal pure;
log
function log(string memory p0, string memory p1, bool p2, address p3) internal pure;
log
function log(string memory p0, string memory p1, address p2, uint256 p3) internal pure;
log
function log(string memory p0, string memory p1, address p2, string memory p3) internal pure;
log
function log(string memory p0, string memory p1, address p2, bool p3) internal pure;
log
function log(string memory p0, string memory p1, address p2, address p3) internal pure;
log
function log(string memory p0, bool p1, uint256 p2, uint256 p3) internal pure;
log
function log(string memory p0, bool p1, uint256 p2, string memory p3) internal pure;
log
function log(string memory p0, bool p1, uint256 p2, bool p3) internal pure;
log
function log(string memory p0, bool p1, uint256 p2, address p3) internal pure;
log
function log(string memory p0, bool p1, string memory p2, uint256 p3) internal pure;
log
function log(string memory p0, bool p1, string memory p2, string memory p3) internal pure;
log
function log(string memory p0, bool p1, string memory p2, bool p3) internal pure;
log
function log(string memory p0, bool p1, string memory p2, address p3) internal pure;
log
function log(string memory p0, bool p1, bool p2, uint256 p3) internal pure;
log
function log(string memory p0, bool p1, bool p2, string memory p3) internal pure;
log
function log(string memory p0, bool p1, bool p2, bool p3) internal pure;
log
function log(string memory p0, bool p1, bool p2, address p3) internal pure;
log
function log(string memory p0, bool p1, address p2, uint256 p3) internal pure;
log
function log(string memory p0, bool p1, address p2, string memory p3) internal pure;
log
function log(string memory p0, bool p1, address p2, bool p3) internal pure;
log
function log(string memory p0, bool p1, address p2, address p3) internal pure;
log
function log(string memory p0, address p1, uint256 p2, uint256 p3) internal pure;
log
function log(string memory p0, address p1, uint256 p2, string memory p3) internal pure;
log
function log(string memory p0, address p1, uint256 p2, bool p3) internal pure;
log
function log(string memory p0, address p1, uint256 p2, address p3) internal pure;
log
function log(string memory p0, address p1, string memory p2, uint256 p3) internal pure;
log
function log(string memory p0, address p1, string memory p2, string memory p3) internal pure;
log
function log(string memory p0, address p1, string memory p2, bool p3) internal pure;
log
function log(string memory p0, address p1, string memory p2, address p3) internal pure;
log
function log(string memory p0, address p1, bool p2, uint256 p3) internal pure;
log
function log(string memory p0, address p1, bool p2, string memory p3) internal pure;
log
function log(string memory p0, address p1, bool p2, bool p3) internal pure;
log
function log(string memory p0, address p1, bool p2, address p3) internal pure;
log
function log(string memory p0, address p1, address p2, uint256 p3) internal pure;
log
function log(string memory p0, address p1, address p2, string memory p3) internal pure;
log
function log(string memory p0, address p1, address p2, bool p3) internal pure;
log
function log(string memory p0, address p1, address p2, address p3) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2, uint256 p3) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2, string memory p3) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2, bool p3) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2, address p3) internal pure;
log
function log(bool p0, uint256 p1, string memory p2, uint256 p3) internal pure;
log
function log(bool p0, uint256 p1, string memory p2, string memory p3) internal pure;
log
function log(bool p0, uint256 p1, string memory p2, bool p3) internal pure;
log
function log(bool p0, uint256 p1, string memory p2, address p3) internal pure;
log
function log(bool p0, uint256 p1, bool p2, uint256 p3) internal pure;
log
function log(bool p0, uint256 p1, bool p2, string memory p3) internal pure;
log
function log(bool p0, uint256 p1, bool p2, bool p3) internal pure;
log
function log(bool p0, uint256 p1, bool p2, address p3) internal pure;
log
function log(bool p0, uint256 p1, address p2, uint256 p3) internal pure;
log
function log(bool p0, uint256 p1, address p2, string memory p3) internal pure;
log
function log(bool p0, uint256 p1, address p2, bool p3) internal pure;
log
function log(bool p0, uint256 p1, address p2, address p3) internal pure;
log
function log(bool p0, string memory p1, uint256 p2, uint256 p3) internal pure;
log
function log(bool p0, string memory p1, uint256 p2, string memory p3) internal pure;
log
function log(bool p0, string memory p1, uint256 p2, bool p3) internal pure;
log
function log(bool p0, string memory p1, uint256 p2, address p3) internal pure;
log
function log(bool p0, string memory p1, string memory p2, uint256 p3) internal pure;
log
function log(bool p0, string memory p1, string memory p2, string memory p3) internal pure;
log
function log(bool p0, string memory p1, string memory p2, bool p3) internal pure;
log
function log(bool p0, string memory p1, string memory p2, address p3) internal pure;
log
function log(bool p0, string memory p1, bool p2, uint256 p3) internal pure;
log
function log(bool p0, string memory p1, bool p2, string memory p3) internal pure;
log
function log(bool p0, string memory p1, bool p2, bool p3) internal pure;
log
function log(bool p0, string memory p1, bool p2, address p3) internal pure;
log
function log(bool p0, string memory p1, address p2, uint256 p3) internal pure;
log
function log(bool p0, string memory p1, address p2, string memory p3) internal pure;
log
function log(bool p0, string memory p1, address p2, bool p3) internal pure;
log
function log(bool p0, string memory p1, address p2, address p3) internal pure;
log
function log(bool p0, bool p1, uint256 p2, uint256 p3) internal pure;
log
function log(bool p0, bool p1, uint256 p2, string memory p3) internal pure;
log
function log(bool p0, bool p1, uint256 p2, bool p3) internal pure;
log
function log(bool p0, bool p1, uint256 p2, address p3) internal pure;
log
function log(bool p0, bool p1, string memory p2, uint256 p3) internal pure;
log
function log(bool p0, bool p1, string memory p2, string memory p3) internal pure;
log
function log(bool p0, bool p1, string memory p2, bool p3) internal pure;
log
function log(bool p0, bool p1, string memory p2, address p3) internal pure;
log
function log(bool p0, bool p1, bool p2, uint256 p3) internal pure;
log
function log(bool p0, bool p1, bool p2, string memory p3) internal pure;
log
function log(bool p0, bool p1, bool p2, bool p3) internal pure;
log
function log(bool p0, bool p1, bool p2, address p3) internal pure;
log
function log(bool p0, bool p1, address p2, uint256 p3) internal pure;
log
function log(bool p0, bool p1, address p2, string memory p3) internal pure;
log
function log(bool p0, bool p1, address p2, bool p3) internal pure;
log
function log(bool p0, bool p1, address p2, address p3) internal pure;
log
function log(bool p0, address p1, uint256 p2, uint256 p3) internal pure;
log
function log(bool p0, address p1, uint256 p2, string memory p3) internal pure;
log
function log(bool p0, address p1, uint256 p2, bool p3) internal pure;
log
function log(bool p0, address p1, uint256 p2, address p3) internal pure;
log
function log(bool p0, address p1, string memory p2, uint256 p3) internal pure;
log
function log(bool p0, address p1, string memory p2, string memory p3) internal pure;
log
function log(bool p0, address p1, string memory p2, bool p3) internal pure;
log
function log(bool p0, address p1, string memory p2, address p3) internal pure;
log
function log(bool p0, address p1, bool p2, uint256 p3) internal pure;
log
function log(bool p0, address p1, bool p2, string memory p3) internal pure;
log
function log(bool p0, address p1, bool p2, bool p3) internal pure;
log
function log(bool p0, address p1, bool p2, address p3) internal pure;
log
function log(bool p0, address p1, address p2, uint256 p3) internal pure;
log
function log(bool p0, address p1, address p2, string memory p3) internal pure;
log
function log(bool p0, address p1, address p2, bool p3) internal pure;
log
function log(bool p0, address p1, address p2, address p3) internal pure;
log
function log(address p0, uint256 p1, uint256 p2, uint256 p3) internal pure;
log
function log(address p0, uint256 p1, uint256 p2, string memory p3) internal pure;
log
function log(address p0, uint256 p1, uint256 p2, bool p3) internal pure;
log
function log(address p0, uint256 p1, uint256 p2, address p3) internal pure;
log
function log(address p0, uint256 p1, string memory p2, uint256 p3) internal pure;
log
function log(address p0, uint256 p1, string memory p2, string memory p3) internal pure;
log
function log(address p0, uint256 p1, string memory p2, bool p3) internal pure;
log
function log(address p0, uint256 p1, string memory p2, address p3) internal pure;
log
function log(address p0, uint256 p1, bool p2, uint256 p3) internal pure;
log
function log(address p0, uint256 p1, bool p2, string memory p3) internal pure;
log
function log(address p0, uint256 p1, bool p2, bool p3) internal pure;
log
function log(address p0, uint256 p1, bool p2, address p3) internal pure;
log
function log(address p0, uint256 p1, address p2, uint256 p3) internal pure;
log
function log(address p0, uint256 p1, address p2, string memory p3) internal pure;
log
function log(address p0, uint256 p1, address p2, bool p3) internal pure;
log
function log(address p0, uint256 p1, address p2, address p3) internal pure;
log
function log(address p0, string memory p1, uint256 p2, uint256 p3) internal pure;
log
function log(address p0, string memory p1, uint256 p2, string memory p3) internal pure;
log
function log(address p0, string memory p1, uint256 p2, bool p3) internal pure;
log
function log(address p0, string memory p1, uint256 p2, address p3) internal pure;
log
function log(address p0, string memory p1, string memory p2, uint256 p3) internal pure;
log
function log(address p0, string memory p1, string memory p2, string memory p3) internal pure;
log
function log(address p0, string memory p1, string memory p2, bool p3) internal pure;
log
function log(address p0, string memory p1, string memory p2, address p3) internal pure;
log
function log(address p0, string memory p1, bool p2, uint256 p3) internal pure;
log
function log(address p0, string memory p1, bool p2, string memory p3) internal pure;
log
function log(address p0, string memory p1, bool p2, bool p3) internal pure;
log
function log(address p0, string memory p1, bool p2, address p3) internal pure;
log
function log(address p0, string memory p1, address p2, uint256 p3) internal pure;
log
function log(address p0, string memory p1, address p2, string memory p3) internal pure;
log
function log(address p0, string memory p1, address p2, bool p3) internal pure;
log
function log(address p0, string memory p1, address p2, address p3) internal pure;
log
function log(address p0, bool p1, uint256 p2, uint256 p3) internal pure;
log
function log(address p0, bool p1, uint256 p2, string memory p3) internal pure;
log
function log(address p0, bool p1, uint256 p2, bool p3) internal pure;
log
function log(address p0, bool p1, uint256 p2, address p3) internal pure;
log
function log(address p0, bool p1, string memory p2, uint256 p3) internal pure;
log
function log(address p0, bool p1, string memory p2, string memory p3) internal pure;
log
function log(address p0, bool p1, string memory p2, bool p3) internal pure;
log
function log(address p0, bool p1, string memory p2, address p3) internal pure;
log
function log(address p0, bool p1, bool p2, uint256 p3) internal pure;
log
function log(address p0, bool p1, bool p2, string memory p3) internal pure;
log
function log(address p0, bool p1, bool p2, bool p3) internal pure;
log
function log(address p0, bool p1, bool p2, address p3) internal pure;
log
function log(address p0, bool p1, address p2, uint256 p3) internal pure;
log
function log(address p0, bool p1, address p2, string memory p3) internal pure;
log
function log(address p0, bool p1, address p2, bool p3) internal pure;
log
function log(address p0, bool p1, address p2, address p3) internal pure;
log
function log(address p0, address p1, uint256 p2, uint256 p3) internal pure;
log
function log(address p0, address p1, uint256 p2, string memory p3) internal pure;
log
function log(address p0, address p1, uint256 p2, bool p3) internal pure;
log
function log(address p0, address p1, uint256 p2, address p3) internal pure;
log
function log(address p0, address p1, string memory p2, uint256 p3) internal pure;
log
function log(address p0, address p1, string memory p2, string memory p3) internal pure;
log
function log(address p0, address p1, string memory p2, bool p3) internal pure;
log
function log(address p0, address p1, string memory p2, address p3) internal pure;
log
function log(address p0, address p1, bool p2, uint256 p3) internal pure;
log
function log(address p0, address p1, bool p2, string memory p3) internal pure;
log
function log(address p0, address p1, bool p2, bool p3) internal pure;
log
function log(address p0, address p1, bool p2, address p3) internal pure;
log
function log(address p0, address p1, address p2, uint256 p3) internal pure;
log
function log(address p0, address p1, address p2, string memory p3) internal pure;
log
function log(address p0, address p1, address p2, bool p3) internal pure;
log
function log(address p0, address p1, address p2, address p3) internal pure;
safeconsole
Author: philogy https://github.com/philogy
Code generated automatically by script.
State Variables
CONSOLE_ADDR
uint256 constant CONSOLE_ADDR = 0x000000000000000000000000000000000000000000636F6e736F6c652e6c6f67;
Functions
_sendLogPayload
function _sendLogPayload(uint256 offset, uint256 size) private pure;
_sendLogPayloadView
function _sendLogPayloadView(uint256 offset, uint256 size) private view;
_memcopy
function _memcopy(uint256 fromOffset, uint256 toOffset, uint256 length) private pure;
_memcopyView
function _memcopyView(uint256 fromOffset, uint256 toOffset, uint256 length) private view;
logMemory
function logMemory(uint256 offset, uint256 length) internal pure;
log
function log(address p0) internal pure;
log
function log(bool p0) internal pure;
log
function log(uint256 p0) internal pure;
log
function log(bytes32 p0) internal pure;
log
function log(address p0, address p1) internal pure;
log
function log(address p0, bool p1) internal pure;
log
function log(address p0, uint256 p1) internal pure;
log
function log(address p0, bytes32 p1) internal pure;
log
function log(bool p0, address p1) internal pure;
log
function log(bool p0, bool p1) internal pure;
log
function log(bool p0, uint256 p1) internal pure;
log
function log(bool p0, bytes32 p1) internal pure;
log
function log(uint256 p0, address p1) internal pure;
log
function log(uint256 p0, bool p1) internal pure;
log
function log(uint256 p0, uint256 p1) internal pure;
log
function log(uint256 p0, bytes32 p1) internal pure;
log
function log(bytes32 p0, address p1) internal pure;
log
function log(bytes32 p0, bool p1) internal pure;
log
function log(bytes32 p0, uint256 p1) internal pure;
log
function log(bytes32 p0, bytes32 p1) internal pure;
log
function log(address p0, address p1, address p2) internal pure;
log
function log(address p0, address p1, bool p2) internal pure;
log
function log(address p0, address p1, uint256 p2) internal pure;
log
function log(address p0, address p1, bytes32 p2) internal pure;
log
function log(address p0, bool p1, address p2) internal pure;
log
function log(address p0, bool p1, bool p2) internal pure;
log
function log(address p0, bool p1, uint256 p2) internal pure;
log
function log(address p0, bool p1, bytes32 p2) internal pure;
log
function log(address p0, uint256 p1, address p2) internal pure;
log
function log(address p0, uint256 p1, bool p2) internal pure;
log
function log(address p0, uint256 p1, uint256 p2) internal pure;
log
function log(address p0, uint256 p1, bytes32 p2) internal pure;
log
function log(address p0, bytes32 p1, address p2) internal pure;
log
function log(address p0, bytes32 p1, bool p2) internal pure;
log
function log(address p0, bytes32 p1, uint256 p2) internal pure;
log
function log(address p0, bytes32 p1, bytes32 p2) internal pure;
log
function log(bool p0, address p1, address p2) internal pure;
log
function log(bool p0, address p1, bool p2) internal pure;
log
function log(bool p0, address p1, uint256 p2) internal pure;
log
function log(bool p0, address p1, bytes32 p2) internal pure;
log
function log(bool p0, bool p1, address p2) internal pure;
log
function log(bool p0, bool p1, bool p2) internal pure;
log
function log(bool p0, bool p1, uint256 p2) internal pure;
log
function log(bool p0, bool p1, bytes32 p2) internal pure;
log
function log(bool p0, uint256 p1, address p2) internal pure;
log
function log(bool p0, uint256 p1, bool p2) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2) internal pure;
log
function log(bool p0, uint256 p1, bytes32 p2) internal pure;
log
function log(bool p0, bytes32 p1, address p2) internal pure;
log
function log(bool p0, bytes32 p1, bool p2) internal pure;
log
function log(bool p0, bytes32 p1, uint256 p2) internal pure;
log
function log(bool p0, bytes32 p1, bytes32 p2) internal pure;
log
function log(uint256 p0, address p1, address p2) internal pure;
log
function log(uint256 p0, address p1, bool p2) internal pure;
log
function log(uint256 p0, address p1, uint256 p2) internal pure;
log
function log(uint256 p0, address p1, bytes32 p2) internal pure;
log
function log(uint256 p0, bool p1, address p2) internal pure;
log
function log(uint256 p0, bool p1, bool p2) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2) internal pure;
log
function log(uint256 p0, bool p1, bytes32 p2) internal pure;
log
function log(uint256 p0, uint256 p1, address p2) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2) internal pure;
log
function log(uint256 p0, uint256 p1, bytes32 p2) internal pure;
log
function log(uint256 p0, bytes32 p1, address p2) internal pure;
log
function log(uint256 p0, bytes32 p1, bool p2) internal pure;
log
function log(uint256 p0, bytes32 p1, uint256 p2) internal pure;
log
function log(uint256 p0, bytes32 p1, bytes32 p2) internal pure;
log
function log(bytes32 p0, address p1, address p2) internal pure;
log
function log(bytes32 p0, address p1, bool p2) internal pure;
log
function log(bytes32 p0, address p1, uint256 p2) internal pure;
log
function log(bytes32 p0, address p1, bytes32 p2) internal pure;
log
function log(bytes32 p0, bool p1, address p2) internal pure;
log
function log(bytes32 p0, bool p1, bool p2) internal pure;
log
function log(bytes32 p0, bool p1, uint256 p2) internal pure;
log
function log(bytes32 p0, bool p1, bytes32 p2) internal pure;
log
function log(bytes32 p0, uint256 p1, address p2) internal pure;
log
function log(bytes32 p0, uint256 p1, bool p2) internal pure;
log
function log(bytes32 p0, uint256 p1, uint256 p2) internal pure;
log
function log(bytes32 p0, uint256 p1, bytes32 p2) internal pure;
log
function log(bytes32 p0, bytes32 p1, address p2) internal pure;
log
function log(bytes32 p0, bytes32 p1, bool p2) internal pure;
log
function log(bytes32 p0, bytes32 p1, uint256 p2) internal pure;
log
function log(bytes32 p0, bytes32 p1, bytes32 p2) internal pure;
log
function log(address p0, address p1, address p2, address p3) internal pure;
log
function log(address p0, address p1, address p2, bool p3) internal pure;
log
function log(address p0, address p1, address p2, uint256 p3) internal pure;
log
function log(address p0, address p1, address p2, bytes32 p3) internal pure;
log
function log(address p0, address p1, bool p2, address p3) internal pure;
log
function log(address p0, address p1, bool p2, bool p3) internal pure;
log
function log(address p0, address p1, bool p2, uint256 p3) internal pure;
log
function log(address p0, address p1, bool p2, bytes32 p3) internal pure;
log
function log(address p0, address p1, uint256 p2, address p3) internal pure;
log
function log(address p0, address p1, uint256 p2, bool p3) internal pure;
log
function log(address p0, address p1, uint256 p2, uint256 p3) internal pure;
log
function log(address p0, address p1, uint256 p2, bytes32 p3) internal pure;
log
function log(address p0, address p1, bytes32 p2, address p3) internal pure;
log
function log(address p0, address p1, bytes32 p2, bool p3) internal pure;
log
function log(address p0, address p1, bytes32 p2, uint256 p3) internal pure;
log
function log(address p0, address p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(address p0, bool p1, address p2, address p3) internal pure;
log
function log(address p0, bool p1, address p2, bool p3) internal pure;
log
function log(address p0, bool p1, address p2, uint256 p3) internal pure;
log
function log(address p0, bool p1, address p2, bytes32 p3) internal pure;
log
function log(address p0, bool p1, bool p2, address p3) internal pure;
log
function log(address p0, bool p1, bool p2, bool p3) internal pure;
log
function log(address p0, bool p1, bool p2, uint256 p3) internal pure;
log
function log(address p0, bool p1, bool p2, bytes32 p3) internal pure;
log
function log(address p0, bool p1, uint256 p2, address p3) internal pure;
log
function log(address p0, bool p1, uint256 p2, bool p3) internal pure;
log
function log(address p0, bool p1, uint256 p2, uint256 p3) internal pure;
log
function log(address p0, bool p1, uint256 p2, bytes32 p3) internal pure;
log
function log(address p0, bool p1, bytes32 p2, address p3) internal pure;
log
function log(address p0, bool p1, bytes32 p2, bool p3) internal pure;
log
function log(address p0, bool p1, bytes32 p2, uint256 p3) internal pure;
log
function log(address p0, bool p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(address p0, uint256 p1, address p2, address p3) internal pure;
log
function log(address p0, uint256 p1, address p2, bool p3) internal pure;
log
function log(address p0, uint256 p1, address p2, uint256 p3) internal pure;
log
function log(address p0, uint256 p1, address p2, bytes32 p3) internal pure;
log
function log(address p0, uint256 p1, bool p2, address p3) internal pure;
log
function log(address p0, uint256 p1, bool p2, bool p3) internal pure;
log
function log(address p0, uint256 p1, bool p2, uint256 p3) internal pure;
log
function log(address p0, uint256 p1, bool p2, bytes32 p3) internal pure;
log
function log(address p0, uint256 p1, uint256 p2, address p3) internal pure;
log
function log(address p0, uint256 p1, uint256 p2, bool p3) internal pure;
log
function log(address p0, uint256 p1, uint256 p2, uint256 p3) internal pure;
log
function log(address p0, uint256 p1, uint256 p2, bytes32 p3) internal pure;
log
function log(address p0, uint256 p1, bytes32 p2, address p3) internal pure;
log
function log(address p0, uint256 p1, bytes32 p2, bool p3) internal pure;
log
function log(address p0, uint256 p1, bytes32 p2, uint256 p3) internal pure;
log
function log(address p0, uint256 p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(address p0, bytes32 p1, address p2, address p3) internal pure;
log
function log(address p0, bytes32 p1, address p2, bool p3) internal pure;
log
function log(address p0, bytes32 p1, address p2, uint256 p3) internal pure;
log
function log(address p0, bytes32 p1, address p2, bytes32 p3) internal pure;
log
function log(address p0, bytes32 p1, bool p2, address p3) internal pure;
log
function log(address p0, bytes32 p1, bool p2, bool p3) internal pure;
log
function log(address p0, bytes32 p1, bool p2, uint256 p3) internal pure;
log
function log(address p0, bytes32 p1, bool p2, bytes32 p3) internal pure;
log
function log(address p0, bytes32 p1, uint256 p2, address p3) internal pure;
log
function log(address p0, bytes32 p1, uint256 p2, bool p3) internal pure;
log
function log(address p0, bytes32 p1, uint256 p2, uint256 p3) internal pure;
log
function log(address p0, bytes32 p1, uint256 p2, bytes32 p3) internal pure;
log
function log(address p0, bytes32 p1, bytes32 p2, address p3) internal pure;
log
function log(address p0, bytes32 p1, bytes32 p2, bool p3) internal pure;
log
function log(address p0, bytes32 p1, bytes32 p2, uint256 p3) internal pure;
log
function log(address p0, bytes32 p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(bool p0, address p1, address p2, address p3) internal pure;
log
function log(bool p0, address p1, address p2, bool p3) internal pure;
log
function log(bool p0, address p1, address p2, uint256 p3) internal pure;
log
function log(bool p0, address p1, address p2, bytes32 p3) internal pure;
log
function log(bool p0, address p1, bool p2, address p3) internal pure;
log
function log(bool p0, address p1, bool p2, bool p3) internal pure;
log
function log(bool p0, address p1, bool p2, uint256 p3) internal pure;
log
function log(bool p0, address p1, bool p2, bytes32 p3) internal pure;
log
function log(bool p0, address p1, uint256 p2, address p3) internal pure;
log
function log(bool p0, address p1, uint256 p2, bool p3) internal pure;
log
function log(bool p0, address p1, uint256 p2, uint256 p3) internal pure;
log
function log(bool p0, address p1, uint256 p2, bytes32 p3) internal pure;
log
function log(bool p0, address p1, bytes32 p2, address p3) internal pure;
log
function log(bool p0, address p1, bytes32 p2, bool p3) internal pure;
log
function log(bool p0, address p1, bytes32 p2, uint256 p3) internal pure;
log
function log(bool p0, address p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(bool p0, bool p1, address p2, address p3) internal pure;
log
function log(bool p0, bool p1, address p2, bool p3) internal pure;
log
function log(bool p0, bool p1, address p2, uint256 p3) internal pure;
log
function log(bool p0, bool p1, address p2, bytes32 p3) internal pure;
log
function log(bool p0, bool p1, bool p2, address p3) internal pure;
log
function log(bool p0, bool p1, bool p2, bool p3) internal pure;
log
function log(bool p0, bool p1, bool p2, uint256 p3) internal pure;
log
function log(bool p0, bool p1, bool p2, bytes32 p3) internal pure;
log
function log(bool p0, bool p1, uint256 p2, address p3) internal pure;
log
function log(bool p0, bool p1, uint256 p2, bool p3) internal pure;
log
function log(bool p0, bool p1, uint256 p2, uint256 p3) internal pure;
log
function log(bool p0, bool p1, uint256 p2, bytes32 p3) internal pure;
log
function log(bool p0, bool p1, bytes32 p2, address p3) internal pure;
log
function log(bool p0, bool p1, bytes32 p2, bool p3) internal pure;
log
function log(bool p0, bool p1, bytes32 p2, uint256 p3) internal pure;
log
function log(bool p0, bool p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(bool p0, uint256 p1, address p2, address p3) internal pure;
log
function log(bool p0, uint256 p1, address p2, bool p3) internal pure;
log
function log(bool p0, uint256 p1, address p2, uint256 p3) internal pure;
log
function log(bool p0, uint256 p1, address p2, bytes32 p3) internal pure;
log
function log(bool p0, uint256 p1, bool p2, address p3) internal pure;
log
function log(bool p0, uint256 p1, bool p2, bool p3) internal pure;
log
function log(bool p0, uint256 p1, bool p2, uint256 p3) internal pure;
log
function log(bool p0, uint256 p1, bool p2, bytes32 p3) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2, address p3) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2, bool p3) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2, uint256 p3) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2, bytes32 p3) internal pure;
log
function log(bool p0, uint256 p1, bytes32 p2, address p3) internal pure;
log
function log(bool p0, uint256 p1, bytes32 p2, bool p3) internal pure;
log
function log(bool p0, uint256 p1, bytes32 p2, uint256 p3) internal pure;
log
function log(bool p0, uint256 p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(bool p0, bytes32 p1, address p2, address p3) internal pure;
log
function log(bool p0, bytes32 p1, address p2, bool p3) internal pure;
log
function log(bool p0, bytes32 p1, address p2, uint256 p3) internal pure;
log
function log(bool p0, bytes32 p1, address p2, bytes32 p3) internal pure;
log
function log(bool p0, bytes32 p1, bool p2, address p3) internal pure;
log
function log(bool p0, bytes32 p1, bool p2, bool p3) internal pure;
log
function log(bool p0, bytes32 p1, bool p2, uint256 p3) internal pure;
log
function log(bool p0, bytes32 p1, bool p2, bytes32 p3) internal pure;
log
function log(bool p0, bytes32 p1, uint256 p2, address p3) internal pure;
log
function log(bool p0, bytes32 p1, uint256 p2, bool p3) internal pure;
log
function log(bool p0, bytes32 p1, uint256 p2, uint256 p3) internal pure;
log
function log(bool p0, bytes32 p1, uint256 p2, bytes32 p3) internal pure;
log
function log(bool p0, bytes32 p1, bytes32 p2, address p3) internal pure;
log
function log(bool p0, bytes32 p1, bytes32 p2, bool p3) internal pure;
log
function log(bool p0, bytes32 p1, bytes32 p2, uint256 p3) internal pure;
log
function log(bool p0, bytes32 p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(uint256 p0, address p1, address p2, address p3) internal pure;
log
function log(uint256 p0, address p1, address p2, bool p3) internal pure;
log
function log(uint256 p0, address p1, address p2, uint256 p3) internal pure;
log
function log(uint256 p0, address p1, address p2, bytes32 p3) internal pure;
log
function log(uint256 p0, address p1, bool p2, address p3) internal pure;
log
function log(uint256 p0, address p1, bool p2, bool p3) internal pure;
log
function log(uint256 p0, address p1, bool p2, uint256 p3) internal pure;
log
function log(uint256 p0, address p1, bool p2, bytes32 p3) internal pure;
log
function log(uint256 p0, address p1, uint256 p2, address p3) internal pure;
log
function log(uint256 p0, address p1, uint256 p2, bool p3) internal pure;
log
function log(uint256 p0, address p1, uint256 p2, uint256 p3) internal pure;
log
function log(uint256 p0, address p1, uint256 p2, bytes32 p3) internal pure;
log
function log(uint256 p0, address p1, bytes32 p2, address p3) internal pure;
log
function log(uint256 p0, address p1, bytes32 p2, bool p3) internal pure;
log
function log(uint256 p0, address p1, bytes32 p2, uint256 p3) internal pure;
log
function log(uint256 p0, address p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(uint256 p0, bool p1, address p2, address p3) internal pure;
log
function log(uint256 p0, bool p1, address p2, bool p3) internal pure;
log
function log(uint256 p0, bool p1, address p2, uint256 p3) internal pure;
log
function log(uint256 p0, bool p1, address p2, bytes32 p3) internal pure;
log
function log(uint256 p0, bool p1, bool p2, address p3) internal pure;
log
function log(uint256 p0, bool p1, bool p2, bool p3) internal pure;
log
function log(uint256 p0, bool p1, bool p2, uint256 p3) internal pure;
log
function log(uint256 p0, bool p1, bool p2, bytes32 p3) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2, address p3) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2, bool p3) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2, uint256 p3) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2, bytes32 p3) internal pure;
log
function log(uint256 p0, bool p1, bytes32 p2, address p3) internal pure;
log
function log(uint256 p0, bool p1, bytes32 p2, bool p3) internal pure;
log
function log(uint256 p0, bool p1, bytes32 p2, uint256 p3) internal pure;
log
function log(uint256 p0, bool p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(uint256 p0, uint256 p1, address p2, address p3) internal pure;
log
function log(uint256 p0, uint256 p1, address p2, bool p3) internal pure;
log
function log(uint256 p0, uint256 p1, address p2, uint256 p3) internal pure;
log
function log(uint256 p0, uint256 p1, address p2, bytes32 p3) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2, address p3) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2, bool p3) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2, uint256 p3) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2, bytes32 p3) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2, address p3) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2, bool p3) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2, uint256 p3) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2, bytes32 p3) internal pure;
log
function log(uint256 p0, uint256 p1, bytes32 p2, address p3) internal pure;
log
function log(uint256 p0, uint256 p1, bytes32 p2, bool p3) internal pure;
log
function log(uint256 p0, uint256 p1, bytes32 p2, uint256 p3) internal pure;
log
function log(uint256 p0, uint256 p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(uint256 p0, bytes32 p1, address p2, address p3) internal pure;
log
function log(uint256 p0, bytes32 p1, address p2, bool p3) internal pure;
log
function log(uint256 p0, bytes32 p1, address p2, uint256 p3) internal pure;
log
function log(uint256 p0, bytes32 p1, address p2, bytes32 p3) internal pure;
log
function log(uint256 p0, bytes32 p1, bool p2, address p3) internal pure;
log
function log(uint256 p0, bytes32 p1, bool p2, bool p3) internal pure;
log
function log(uint256 p0, bytes32 p1, bool p2, uint256 p3) internal pure;
log
function log(uint256 p0, bytes32 p1, bool p2, bytes32 p3) internal pure;
log
function log(uint256 p0, bytes32 p1, uint256 p2, address p3) internal pure;
log
function log(uint256 p0, bytes32 p1, uint256 p2, bool p3) internal pure;
log
function log(uint256 p0, bytes32 p1, uint256 p2, uint256 p3) internal pure;
log
function log(uint256 p0, bytes32 p1, uint256 p2, bytes32 p3) internal pure;
log
function log(uint256 p0, bytes32 p1, bytes32 p2, address p3) internal pure;
log
function log(uint256 p0, bytes32 p1, bytes32 p2, bool p3) internal pure;
log
function log(uint256 p0, bytes32 p1, bytes32 p2, uint256 p3) internal pure;
log
function log(uint256 p0, bytes32 p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, address p1, address p2, address p3) internal pure;
log
function log(bytes32 p0, address p1, address p2, bool p3) internal pure;
log
function log(bytes32 p0, address p1, address p2, uint256 p3) internal pure;
log
function log(bytes32 p0, address p1, address p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, address p1, bool p2, address p3) internal pure;
log
function log(bytes32 p0, address p1, bool p2, bool p3) internal pure;
log
function log(bytes32 p0, address p1, bool p2, uint256 p3) internal pure;
log
function log(bytes32 p0, address p1, bool p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, address p1, uint256 p2, address p3) internal pure;
log
function log(bytes32 p0, address p1, uint256 p2, bool p3) internal pure;
log
function log(bytes32 p0, address p1, uint256 p2, uint256 p3) internal pure;
log
function log(bytes32 p0, address p1, uint256 p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, address p1, bytes32 p2, address p3) internal pure;
log
function log(bytes32 p0, address p1, bytes32 p2, bool p3) internal pure;
log
function log(bytes32 p0, address p1, bytes32 p2, uint256 p3) internal pure;
log
function log(bytes32 p0, address p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, bool p1, address p2, address p3) internal pure;
log
function log(bytes32 p0, bool p1, address p2, bool p3) internal pure;
log
function log(bytes32 p0, bool p1, address p2, uint256 p3) internal pure;
log
function log(bytes32 p0, bool p1, address p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, bool p1, bool p2, address p3) internal pure;
log
function log(bytes32 p0, bool p1, bool p2, bool p3) internal pure;
log
function log(bytes32 p0, bool p1, bool p2, uint256 p3) internal pure;
log
function log(bytes32 p0, bool p1, bool p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, bool p1, uint256 p2, address p3) internal pure;
log
function log(bytes32 p0, bool p1, uint256 p2, bool p3) internal pure;
log
function log(bytes32 p0, bool p1, uint256 p2, uint256 p3) internal pure;
log
function log(bytes32 p0, bool p1, uint256 p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, bool p1, bytes32 p2, address p3) internal pure;
log
function log(bytes32 p0, bool p1, bytes32 p2, bool p3) internal pure;
log
function log(bytes32 p0, bool p1, bytes32 p2, uint256 p3) internal pure;
log
function log(bytes32 p0, bool p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, uint256 p1, address p2, address p3) internal pure;
log
function log(bytes32 p0, uint256 p1, address p2, bool p3) internal pure;
log
function log(bytes32 p0, uint256 p1, address p2, uint256 p3) internal pure;
log
function log(bytes32 p0, uint256 p1, address p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, uint256 p1, bool p2, address p3) internal pure;
log
function log(bytes32 p0, uint256 p1, bool p2, bool p3) internal pure;
log
function log(bytes32 p0, uint256 p1, bool p2, uint256 p3) internal pure;
log
function log(bytes32 p0, uint256 p1, bool p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, uint256 p1, uint256 p2, address p3) internal pure;
log
function log(bytes32 p0, uint256 p1, uint256 p2, bool p3) internal pure;
log
function log(bytes32 p0, uint256 p1, uint256 p2, uint256 p3) internal pure;
log
function log(bytes32 p0, uint256 p1, uint256 p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, uint256 p1, bytes32 p2, address p3) internal pure;
log
function log(bytes32 p0, uint256 p1, bytes32 p2, bool p3) internal pure;
log
function log(bytes32 p0, uint256 p1, bytes32 p2, uint256 p3) internal pure;
log
function log(bytes32 p0, uint256 p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, address p2, address p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, address p2, bool p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, address p2, uint256 p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, address p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, bool p2, address p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, bool p2, bool p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, bool p2, uint256 p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, bool p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, uint256 p2, address p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, uint256 p2, bool p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, uint256 p2, uint256 p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, uint256 p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, bytes32 p2, address p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, bytes32 p2, bool p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, bytes32 p2, uint256 p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, bytes32 p2, bytes32 p3) internal pure;
Contents
- compilation
- CommonBaseTest
- VmInternal
- StdAssertionsTest
- TestMockCall
- StdChainsMock
- StdChainsTest
- StdCheatsTest
- StdCheatsMock
- StdCheatsForkTest
- USDCLike
- USDTLike
- MockUSDT
- MockUSDC
- Bar
- BarERC1155
- BarERC721
- RevertingContract
- MockContractWithConstructorArgs
- MockContractPayable
- StdConstantsTest
- Dummy
- StdErrorsTest
- ErrorsTest
- StdJsonTest
- StdMathMock
- StdMathTest
- StdStorageTest
- StorageTestTarget
- StorageTest
- StdStyleTest
- StdTomlTest
- StdUtilsMock
- StdUtilsTest
- StdUtilsForkTest
- VmTest
Contents
CompilationScript
Inherits: Script
CompilationScriptBase
Inherits: ScriptBase
CompilationTest
Inherits: Test
CompilationTestBase
Inherits: TestBase
CommonBaseTest
Inherits: Test
Functions
testVmAddressValue
function testVmAddressValue() public pure;
testConsoleValue
function testConsoleValue() public pure;
testCreate2FactoryValue
function testCreate2FactoryValue() public pure;
testDefaultSenderValue
function testDefaultSenderValue() public pure;
testDefaultTestContractValue
function testDefaultTestContractValue() public pure;
testMulticall3AddressValue
function testMulticall3AddressValue() public pure;
testSecp256k1OrderValue
function testSecp256k1OrderValue() public pure;
testUint256MaxValue
function testUint256MaxValue() public pure;
testVmValue
function testVmValue() public pure;
VmInternal
Inherits: Vm
Functions
_expectCheatcodeRevert
function _expectCheatcodeRevert(bytes memory message) external;
StdAssertionsTest
Inherits: StdAssertions
State Variables
errorMessage
string constant errorMessage = "User provided message";
maxDecimals
uint256 constant maxDecimals = 77;
SHOULD_REVERT
bool constant SHOULD_REVERT = true;
SHOULD_RETURN
bool constant SHOULD_RETURN = false;
STRICT_REVERT_DATA
bool constant STRICT_REVERT_DATA = true;
NON_STRICT_REVERT_DATA
bool constant NON_STRICT_REVERT_DATA = false;
vm
VmInternal constant vm = VmInternal(address(uint160(uint256(keccak256("hevm cheat code")))));
Functions
testFuzz_AssertEqCall_Return_Pass
function testFuzz_AssertEqCall_Return_Pass(
bytes memory callDataA,
bytes memory callDataB,
bytes memory returnData,
bool strictRevertData
) external;
testFuzz_RevertWhenCalled_AssertEqCall_Return_Fail
function testFuzz_RevertWhenCalled_AssertEqCall_Return_Fail(
bytes memory callDataA,
bytes memory callDataB,
bytes memory returnDataA,
bytes memory returnDataB,
bool strictRevertData
) external;
testFuzz_AssertEqCall_Revert_Pass
function testFuzz_AssertEqCall_Revert_Pass(
bytes memory callDataA,
bytes memory callDataB,
bytes memory revertDataA,
bytes memory revertDataB
) external;
testFuzz_RevertWhenCalled_AssertEqCall_Revert_Fail
function testFuzz_RevertWhenCalled_AssertEqCall_Revert_Fail(
bytes memory callDataA,
bytes memory callDataB,
bytes memory revertDataA,
bytes memory revertDataB
) external;
testFuzz_RevertWhenCalled_AssertEqCall_Fail
function testFuzz_RevertWhenCalled_AssertEqCall_Fail(
bytes memory callDataA,
bytes memory callDataB,
bytes memory returnDataA,
bytes memory returnDataB,
bool strictRevertData
) external;
assertEqCallExternal
function assertEqCallExternal(
address targetA,
bytes memory callDataA,
address targetB,
bytes memory callDataB,
bool strictRevertData
) public;
TestMockCall
State Variables
returnData
bytes returnData;
shouldRevert
bool shouldRevert;
Functions
constructor
constructor(bytes memory returnData_, bool shouldRevert_);
fallback
fallback() external payable;
StdChainsMock
Inherits: Test
Functions
exposed_getChain
function exposed_getChain(string memory chainAlias) public returns (Chain memory);
exposed_getChain
function exposed_getChain(uint256 chainId) public returns (Chain memory);
exposed_setChain
function exposed_setChain(string memory chainAlias, ChainData memory chainData) public;
exposed_setFallbackToDefaultRpcUrls
function exposed_setFallbackToDefaultRpcUrls(bool useDefault) public;
StdChainsTest
Inherits: Test
Functions
test_ChainRpcInitialization
function test_ChainRpcInitialization() public;
_testRpc
function _testRpc(string memory rpcAlias) internal;
test_RevertIf_ChainNotFound
function test_RevertIf_ChainNotFound() public;
test_RevertIf_SetChain_ChainIdExist_FirstTest
function test_RevertIf_SetChain_ChainIdExist_FirstTest() public;
test_RevertIf_ChainBubbleUp
function test_RevertIf_ChainBubbleUp() public;
test_RevertIf_SetChain_ChainIdExists_SecondTest
function test_RevertIf_SetChain_ChainIdExists_SecondTest() public;
test_SetChain
function test_SetChain() public;
test_RevertIf_SetEmptyAlias
function test_RevertIf_SetEmptyAlias() public;
test_RevertIf_SetNoChainId0
function test_RevertIf_SetNoChainId0() public;
test_RevertIf_GetNoChainId0
function test_RevertIf_GetNoChainId0() public;
test_RevertIf_GetNoEmptyAlias
function test_RevertIf_GetNoEmptyAlias() public;
test_RevertIf_ChainIdNotFound
function test_RevertIf_ChainIdNotFound() public;
test_RevertIf_ChainAliasNotFound
function test_RevertIf_ChainAliasNotFound() public;
test_SetChain_ExistingOne
function test_SetChain_ExistingOne() public;
test_RevertIf_DontUseDefaultRpcUrl
function test_RevertIf_DontUseDefaultRpcUrl() public;
StdCheatsTest
Inherits: Test
State Variables
test
Bar test;
Functions
setUp
function setUp() public;
test_Skip
function test_Skip() public;
test_Rewind
function test_Rewind() public;
test_Hoax
function test_Hoax() public;
test_HoaxOrigin
function test_HoaxOrigin() public;
test_HoaxDifferentAddresses
function test_HoaxDifferentAddresses() public;
test_StartHoax
function test_StartHoax() public;
test_StartHoaxOrigin
function test_StartHoaxOrigin() public;
test_ChangePrankMsgSender
function test_ChangePrankMsgSender() public;
test_ChangePrankMsgSenderAndTxOrigin
function test_ChangePrankMsgSenderAndTxOrigin() public;
test_MakeAccountEquivalence
function test_MakeAccountEquivalence() public;
test_MakeAddrEquivalence
function test_MakeAddrEquivalence() public;
test_MakeAddrSigning
function test_MakeAddrSigning() public;
test_Deal
function test_Deal() public;
test_DealToken
function test_DealToken() public;
test_DealTokenAdjustTotalSupply
function test_DealTokenAdjustTotalSupply() public;
test_DealERC1155Token
function test_DealERC1155Token() public;
test_DealERC1155TokenAdjustTotalSupply
function test_DealERC1155TokenAdjustTotalSupply() public;
test_DealERC721Token
function test_DealERC721Token() public;
test_DeployCode
function test_DeployCode() public;
test_DestroyAccount
function test_DestroyAccount() public;
test_DeployCodeNoArgs
function test_DeployCodeNoArgs() public;
test_DeployCodeVal
function test_DeployCodeVal() public;
test_DeployCodeValNoArgs
function test_DeployCodeValNoArgs() public;
deployCodeHelper
function deployCodeHelper(string memory what) external;
test_RevertIf_DeployCodeFail
function test_RevertIf_DeployCodeFail() public;
getCode
function getCode(address who) internal view returns (bytes memory o_code);
test_DeriveRememberKey
function test_DeriveRememberKey() public;
test_BytesToUint
function test_BytesToUint() public pure;
test_ParseJsonTxDetail
function test_ParseJsonTxDetail() public view;
test_ReadEIP1559Transaction
function test_ReadEIP1559Transaction() public view;
test_ReadEIP1559Transactions
function test_ReadEIP1559Transactions() public view;
test_ReadReceipt
function test_ReadReceipt() public view;
test_ReadReceipts
function test_ReadReceipts() public view;
test_GasMeteringModifier
function test_GasMeteringModifier() public;
addInLoop
function addInLoop() internal pure returns (uint256);
addInLoopNoGas
function addInLoopNoGas() internal noGasMetering returns (uint256);
addInLoopNoGasNoGas
function addInLoopNoGasNoGas() internal noGasMetering returns (uint256);
bytesToUint_test
function bytesToUint_test(bytes memory b) private pure returns (uint256);
testFuzz_AssumeAddressIsNot
function testFuzz_AssumeAddressIsNot(address addr) external;
test_AssumePayable
function test_AssumePayable() external;
test_AssumeNotPayable
function test_AssumeNotPayable() external;
testFuzz_AssumeNotPrecompile
function testFuzz_AssumeNotPrecompile(address addr) external;
testFuzz_AssumeNotForgeAddress
function testFuzz_AssumeNotForgeAddress(address addr) external pure;
test_RevertIf_CannotDeployCodeTo
function test_RevertIf_CannotDeployCodeTo() external;
_revertDeployCodeTo
function _revertDeployCodeTo() external;
test_DeployCodeTo
function test_DeployCodeTo() external;
StdCheatsMock
Inherits: StdCheats
Functions
exposed_assumePayable
function exposed_assumePayable(address addr) external;
exposed_assumeNotPayable
function exposed_assumeNotPayable(address addr) external;
exposed_assumeNotBlacklisted
function exposed_assumeNotBlacklisted(address token, address addr) external view;
StdCheatsForkTest
Inherits: Test
State Variables
USDC_BLACKLISTED_USER
address internal constant USDC_BLACKLISTED_USER = 0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD;
USDT_BLACKLISTED_USER
address internal constant USDT_BLACKLISTED_USER = 0x8f8a8F4B54a2aAC7799d7bc81368aC27b852822A;
USDT
MockUSDT public USDT;
USDC
MockUSDC public USDC;
Functions
setUp
function setUp() public;
test_RevertIf_CannotAssumeNoBlacklisted_EOA
function test_RevertIf_CannotAssumeNoBlacklisted_EOA() external;
testFuzz_AssumeNotBlacklisted_TokenWithoutBlacklist
function testFuzz_AssumeNotBlacklisted_TokenWithoutBlacklist(address addr) external view;
test_RevertIf_AssumeNoBlacklisted_USDC
function test_RevertIf_AssumeNoBlacklisted_USDC() external;
testFuzz_AssumeNotBlacklisted_USDC
function testFuzz_AssumeNotBlacklisted_USDC(address addr) external view;
test_RevertIf_AssumeNoBlacklisted_USDT
function test_RevertIf_AssumeNoBlacklisted_USDT() external;
testFuzz_AssumeNotBlacklisted_USDT
function testFuzz_AssumeNotBlacklisted_USDT(address addr) external view;
USDCLike
https://etherscan.io/token/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48#readProxyContract
Functions
isBlacklisted
function isBlacklisted(address) external view returns (bool);
USDTLike
https://etherscan.io/token/0xdac17f958d2ee523a2206206994597c13d831ec7#readContract
Functions
isBlackListed
function isBlackListed(address) external view returns (bool);
MockUSDT
Inherits: USDTLike
State Variables
blacklist
mapping(address => bool) private blacklist;
Functions
isBlackListed
function isBlackListed(address addr) external view returns (bool);
setBlacklisted
function setBlacklisted(address addr, bool value) external;
MockUSDC
Inherits: USDCLike
State Variables
blacklist
mapping(address => bool) private blacklist;
Functions
isBlacklisted
function isBlacklisted(address addr) external view returns (bool);
setBlacklisted
function setBlacklisted(address addr, bool value) external;
Bar
State Variables
balanceOf
DEAL STDCHEAT
mapping(address => uint256) public balanceOf;
totalSupply
uint256 public totalSupply;
Functions
constructor
constructor() payable;
bar
HOAX and CHANGEPRANK STDCHEATS
function bar(address expectedSender) public payable;
origin
function origin(address expectedSender) public payable;
origin
function origin(address expectedSender, address expectedOrigin) public payable;
BarERC1155
State Variables
_balances
DEALERC1155 STDCHEAT
mapping(uint256 => mapping(address => uint256)) private _balances;
_totalSupply
mapping(uint256 => uint256) private _totalSupply;
Functions
constructor
constructor() payable;
balanceOf
function balanceOf(address account, uint256 id) public view virtual returns (uint256);
totalSupply
function totalSupply(uint256 id) public view virtual returns (uint256);
BarERC721
State Variables
_owners
mapping(uint256 => address) private _owners;
_balances
mapping(address => uint256) private _balances;
Functions
constructor
constructor() payable;
balanceOf
function balanceOf(address owner) public view virtual returns (uint256);
ownerOf
function ownerOf(uint256 tokenId) public view virtual returns (address);
RevertingContract
Functions
constructor
constructor();
MockContractWithConstructorArgs
State Variables
x
uint256 public immutable x;
y
bool public y;
z
bytes20 public z;
Functions
constructor
constructor(uint256 _x, bool _y, bytes20 _z) payable;
MockContractPayable
Functions
receive
receive() external payable;
StdConstantsTest
Inherits: Test
Functions
testVm
function testVm() public view;
testVmDerivation
function testVmDerivation() public pure;
testConsoleDerivation
function testConsoleDerivation() public pure;
testDefaultSender
function testDefaultSender() public view;
testDefaultSenderDerivation
function testDefaultSenderDerivation() public pure;
testDefaultTestContract
function testDefaultTestContract() public;
testDefaultTestContractDerivation
function testDefaultTestContractDerivation() public view;
Dummy
StdErrorsTest
Inherits: Test
State Variables
test
ErrorsTest test;
Functions
setUp
function setUp() public;
test_RevertIf_AssertionError
function test_RevertIf_AssertionError() public;
test_RevertIf_ArithmeticError
function test_RevertIf_ArithmeticError() public;
test_RevertIf_DivisionError
function test_RevertIf_DivisionError() public;
test_RevertIf_ModError
function test_RevertIf_ModError() public;
test_RevertIf_EnumConversionError
function test_RevertIf_EnumConversionError() public;
test_RevertIf_EncodeStgError
function test_RevertIf_EncodeStgError() public;
test_RevertIf_PopError
function test_RevertIf_PopError() public;
test_RevertIf_IndexOOBError
function test_RevertIf_IndexOOBError() public;
test_RevertIf_MemOverflowError
function test_RevertIf_MemOverflowError() public;
test_RevertIf_InternError
function test_RevertIf_InternError() public;
ErrorsTest
State Variables
someArr
uint256[] public someArr;
someBytes
bytes someBytes;
Functions
assertionError
function assertionError() public pure;
arithmeticError
function arithmeticError(uint256 a) public pure;
divError
function divError(uint256 a) public pure;
modError
function modError(uint256 a) public pure;
enumConversion
function enumConversion(uint256 a) public pure;
encodeStgError
function encodeStgError() public;
pop
function pop() public;
indexOOBError
function indexOOBError(uint256 a) public pure;
mem
function mem() public pure;
intern
function intern() public returns (uint256);
Enums
T
enum T {
T1
}
StdJsonTest
Inherits: Test
State Variables
root
string root;
path
string path;
Functions
setUp
function setUp() public;
test_readJson
function test_readJson() public view;
test_writeJson
function test_writeJson() public;
Structs
SimpleJson
struct SimpleJson {
uint256 a;
string b;
}
NestedJson
struct NestedJson {
uint256 a;
string b;
SimpleJson c;
}
StdMathMock
Inherits: Test
Functions
exposed_percentDelta
function exposed_percentDelta(uint256 a, uint256 b) public pure returns (uint256);
exposed_percentDelta
function exposed_percentDelta(int256 a, int256 b) public pure returns (uint256);
StdMathTest
Inherits: Test
Functions
test_GetAbs
function test_GetAbs() external pure;
testFuzz_GetAbs
function testFuzz_GetAbs(int256 a) external pure;
test_GetDelta_Uint
function test_GetDelta_Uint() external pure;
testFuzz_GetDelta_Uint
function testFuzz_GetDelta_Uint(uint256 a, uint256 b) external pure;
test_GetDelta_Int
function test_GetDelta_Int() external pure;
testFuzz_GetDelta_Int
function testFuzz_GetDelta_Int(int256 a, int256 b) external pure;
test_GetPercentDelta_Uint
function test_GetPercentDelta_Uint() external;
testFuzz_GetPercentDelta_Uint
function testFuzz_GetPercentDelta_Uint(uint192 a, uint192 b) external pure;
test_GetPercentDelta_Int
function test_GetPercentDelta_Int() external;
testFuzz_GetPercentDelta_Int
function testFuzz_GetPercentDelta_Int(int192 a, int192 b) external pure;
getAbs
function getAbs(int256 a) private pure returns (uint256);
StdStorageTest
Inherits: Test
State Variables
test
StorageTest internal test;
Functions
setUp
function setUp() public;
test_StorageHidden
function test_StorageHidden() public;
test_StorageObvious
function test_StorageObvious() public;
test_StorageExtraSload
function test_StorageExtraSload() public;
test_StorageCheckedWriteHidden
function test_StorageCheckedWriteHidden() public;
test_StorageCheckedWriteObvious
function test_StorageCheckedWriteObvious() public;
test_StorageCheckedWriteSignedIntegerHidden
function test_StorageCheckedWriteSignedIntegerHidden() public;
test_StorageCheckedWriteSignedIntegerObvious
function test_StorageCheckedWriteSignedIntegerObvious() public;
test_StorageMapStructA
function test_StorageMapStructA() public;
test_StorageMapStructB
function test_StorageMapStructB() public;
test_StorageDeepMap
function test_StorageDeepMap() public;
test_StorageCheckedWriteDeepMap
function test_StorageCheckedWriteDeepMap() public;
test_StorageDeepMapStructA
function test_StorageDeepMapStructA() public;
test_StorageDeepMapStructB
function test_StorageDeepMapStructB() public;
test_StorageCheckedWriteDeepMapStructA
function test_StorageCheckedWriteDeepMapStructA() public;
test_StorageCheckedWriteDeepMapStructB
function test_StorageCheckedWriteDeepMapStructB() public;
test_StorageCheckedWriteMapStructA
function test_StorageCheckedWriteMapStructA() public;
test_StorageCheckedWriteMapStructB
function test_StorageCheckedWriteMapStructB() public;
test_StorageStructA
function test_StorageStructA() public;
test_StorageStructB
function test_StorageStructB() public;
test_StorageCheckedWriteStructA
function test_StorageCheckedWriteStructA() public;
test_StorageCheckedWriteStructB
function test_StorageCheckedWriteStructB() public;
test_StorageMapAddrFound
function test_StorageMapAddrFound() public;
test_StorageMapAddrRoot
function test_StorageMapAddrRoot() public;
test_StorageMapUintFound
function test_StorageMapUintFound() public;
test_StorageCheckedWriteMapUint
function test_StorageCheckedWriteMapUint() public;
test_StorageCheckedWriteMapAddr
function test_StorageCheckedWriteMapAddr() public;
test_StorageCheckedWriteMapBool
function test_StorageCheckedWriteMapBool() public;
testFuzz_StorageCheckedWriteMapPacked
function testFuzz_StorageCheckedWriteMapPacked(address addr, uint128 value) public;
test_StorageCheckedWriteMapPackedFullSuccess
function test_StorageCheckedWriteMapPackedFullSuccess() public;
test_RevertStorageConst
function test_RevertStorageConst() public;
testFuzz_StorageNativePack
function testFuzz_StorageNativePack(uint248 val1, uint248 val2, bool boolVal1, bool boolVal2) public;
test_StorageReadBytes32
function test_StorageReadBytes32() public;
test_StorageReadBool_False
function test_StorageReadBool_False() public;
test_StorageReadBool_True
function test_StorageReadBool_True() public;
test_RevertIf_ReadingNonBoolValue
function test_RevertIf_ReadingNonBoolValue() public;
readNonBoolValue
function readNonBoolValue() public;
test_StorageReadAddress
function test_StorageReadAddress() public;
test_StorageReadUint
function test_StorageReadUint() public;
test_StorageReadInt
function test_StorageReadInt() public;
testFuzz_Packed
function testFuzz_Packed(uint256 val, uint8 elemToGet) public;
testFuzz_Packed2
function testFuzz_Packed2(uint256 nvars, uint256 seed) public;
testEdgeCaseArray
function testEdgeCaseArray() public;
StorageTestTarget
State Variables
stdstore
StdStorage internal stdstore;
test
StorageTest internal test;
Functions
constructor
constructor(StorageTest test_);
expectRevertStorageConst
function expectRevertStorageConst() public;
StorageTest
State Variables
exists
uint256 public exists = 1;
map_addr
mapping(address => uint256) public map_addr;
map_uint
mapping(uint256 => uint256) public map_uint;
map_packed
mapping(address => uint256) public map_packed;
map_struct
mapping(address => UnpackedStruct) public map_struct;
deep_map
mapping(address => mapping(address => uint256)) public deep_map;
deep_map_struct
mapping(address => mapping(address => UnpackedStruct)) public deep_map_struct;
basic
UnpackedStruct public basic;
tA
uint248 public tA;
tB
bool public tB;
tC
bool public tC = false;
tD
uint248 public tD = 1;
map_bool
mapping(address => bool) public map_bool;
tE
bytes32 public tE = hex"1337";
tF
address public tF = address(1337);
tG
int256 public tG = type(int256).min;
tH
bool public tH = true;
tI
bytes32 private tI = ~bytes32(hex"1337");
randomPacking
uint256 randomPacking;
edgeCaseArray
uint256[] public edgeCaseArray = [3, 3, 3];
Functions
constructor
constructor();
read_struct_upper
function read_struct_upper(address who) public view returns (uint256);
read_struct_lower
function read_struct_lower(address who) public view returns (uint256);
hidden
function hidden() public view returns (bytes32 t);
const
function const() public pure returns (bytes32 t);
extra_sload
function extra_sload() public view returns (bytes32 t);
setRandomPacking
function setRandomPacking(uint256 val) public;
_getMask
function _getMask(uint256 size) internal pure returns (uint256 mask);
setRandomPacking
function setRandomPacking(uint256 val, uint256 size, uint256 offset) public;
getRandomPacked
function getRandomPacked(uint256 size, uint256 offset) public view returns (uint256);
getRandomPacked
function getRandomPacked(uint8 shifts, uint8[] memory shiftSizes, uint8 elem) public view returns (uint256);
Structs
UnpackedStruct
struct UnpackedStruct {
uint256 a;
uint256 b;
}
StdStyleTest
Inherits: Test
Functions
test_StyleColor
function test_StyleColor() public pure;
test_StyleFontWeight
function test_StyleFontWeight() public pure;
test_StyleCombined
function test_StyleCombined() public pure;
test_StyleCustom
function test_StyleCustom() public pure;
h1
function h1(string memory a) private pure returns (string memory);
h2
function h2(string memory a) private pure returns (string memory);
StdTomlTest
Inherits: Test
State Variables
root
string root;
path
string path;
Functions
setUp
function setUp() public;
test_readToml
function test_readToml() public view;
test_writeToml
function test_writeToml() public;
Structs
SimpleToml
struct SimpleToml {
uint256 a;
string b;
}
NestedToml
struct NestedToml {
uint256 a;
string b;
SimpleToml c;
}
StdUtilsMock
Inherits: StdUtils
Functions
exposed_getTokenBalances
function exposed_getTokenBalances(address token, address[] memory addresses)
external
returns (uint256[] memory balances);
exposed_bound
function exposed_bound(int256 num, int256 min, int256 max) external pure returns (int256);
exposed_bound
function exposed_bound(uint256 num, uint256 min, uint256 max) external pure returns (uint256);
exposed_bytesToUint
function exposed_bytesToUint(bytes memory b) external pure returns (uint256);
StdUtilsTest
Inherits: Test
Functions
test_Bound
function test_Bound() public pure;
test_Bound_WithinRange
function test_Bound_WithinRange() public pure;
test_Bound_EdgeCoverage
function test_Bound_EdgeCoverage() public pure;
testFuzz_Bound_DistributionIsEven
function testFuzz_Bound_DistributionIsEven(uint256 min, uint256 size) public pure;
testFuzz_Bound
function testFuzz_Bound(uint256 num, uint256 min, uint256 max) public pure;
test_BoundUint256Max
function test_BoundUint256Max() public pure;
test_RevertIf_BoundMaxLessThanMin
function test_RevertIf_BoundMaxLessThanMin() public;
testFuzz_RevertIf_BoundMaxLessThanMin
function testFuzz_RevertIf_BoundMaxLessThanMin(uint256 num, uint256 min, uint256 max) public;
test_BoundInt
function test_BoundInt() public pure;
test_BoundInt_WithinRange
function test_BoundInt_WithinRange() public pure;
test_BoundInt_EdgeCoverage
function test_BoundInt_EdgeCoverage() public pure;
testFuzz_BoundInt_DistributionIsEven
function testFuzz_BoundInt_DistributionIsEven(int256 min, uint256 size) public pure;
testFuzz_BoundInt
function testFuzz_BoundInt(int256 num, int256 min, int256 max) public pure;
test_BoundIntInt256Max
function test_BoundIntInt256Max() public pure;
test_BoundIntInt256Min
function test_BoundIntInt256Min() public pure;
test_RevertIf_BoundIntMaxLessThanMin
function test_RevertIf_BoundIntMaxLessThanMin() public;
testFuzz_RevertIf_BoundIntMaxLessThanMin
function testFuzz_RevertIf_BoundIntMaxLessThanMin(int256 num, int256 min, int256 max) public;
test_BoundPrivateKey
function test_BoundPrivateKey() public pure;
test_BytesToUint
function test_BytesToUint() external pure;
test_RevertIf_BytesLengthExceeds32
function test_RevertIf_BytesLengthExceeds32() external;
test_ComputeCreateAddress
function test_ComputeCreateAddress() external pure;
test_ComputeCreate2Address
function test_ComputeCreate2Address() external pure;
test_ComputeCreate2AddressWithDefaultDeployer
function test_ComputeCreate2AddressWithDefaultDeployer() external pure;
StdUtilsForkTest
Inherits: Test
State Variables
SHIB
address internal SHIB = 0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE;
SHIB_HOLDER_0
address internal SHIB_HOLDER_0 = 0x855F5981e831D83e6A4b4EBFCAdAa68D92333170;
SHIB_HOLDER_1
address internal SHIB_HOLDER_1 = 0x8F509A90c2e47779cA408Fe00d7A72e359229AdA;
SHIB_HOLDER_2
address internal SHIB_HOLDER_2 = 0x0e3bbc0D04fF62211F71f3e4C45d82ad76224385;
USDC
address internal USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
USDC_HOLDER_0
address internal USDC_HOLDER_0 = 0xDa9CE944a37d218c3302F6B82a094844C6ECEb17;
USDC_HOLDER_1
address internal USDC_HOLDER_1 = 0x3e67F4721E6d1c41a015f645eFa37BEd854fcf52;
Functions
setUp
function setUp() public;
test_RevertIf_CannotGetTokenBalances_NonTokenContract
function test_RevertIf_CannotGetTokenBalances_NonTokenContract() external;
test_RevertIf_CannotGetTokenBalances_EOA
function test_RevertIf_CannotGetTokenBalances_EOA() external;
test_GetTokenBalances_Empty
function test_GetTokenBalances_Empty() external;
test_GetTokenBalances_USDC
function test_GetTokenBalances_USDC() external;
test_GetTokenBalances_SHIB
function test_GetTokenBalances_SHIB() external;
VmTest
Inherits: Test
Functions
test_VmInterfaceId
function test_VmInterfaceId() public pure;
test_VmSafeInterfaceId
function test_VmSafeInterfaceId() public pure;
Contents
Contents
Contents
- AccessControlDefaultAdminRulesHarness
- AccessControlHarness
- AccessManagedHarness
- AccessManagerHarness
- DoubleEndedQueueHarness
- ERC20FlashMintHarness
- ERC20PermitHarness
- ERC20WrapperHarness
- ERC3156FlashBorrowerHarness
- ERC721Harness
- ERC721ReceiverHarness
- EnumerableMapHarness
- EnumerableSetHarness
- InitializableHarness
- NoncesHarness
- Ownable2StepHarness
- OwnableHarness
- PausableHarness
- TimelockControllerHarness
AccessControlDefaultAdminRulesHarness
Inherits: AccessControlDefaultAdminRules
State Variables
_delayIncreaseWait
uint48 private _delayIncreaseWait;
Functions
constructor
constructor(uint48 initialDelay, address initialDefaultAdmin, uint48 delayIncreaseWait)
AccessControlDefaultAdminRules(initialDelay, initialDefaultAdmin);
pendingDefaultAdmin_
function pendingDefaultAdmin_() external view returns (address);
pendingDefaultAdminSchedule_
function pendingDefaultAdminSchedule_() external view returns (uint48);
pendingDelay_
function pendingDelay_() external view returns (uint48);
pendingDelaySchedule_
function pendingDelaySchedule_() external view returns (uint48);
delayChangeWait_
function delayChangeWait_(uint48 newDelay) external view returns (uint48);
defaultAdminDelayIncreaseWait
function defaultAdminDelayIncreaseWait() public view override returns (uint48);
AccessControlHarness
Inherits: AccessControl
AccessManagedHarness
Inherits: AccessManaged
State Variables
SOME_FUNCTION_CALLDATA
bytes internal SOME_FUNCTION_CALLDATA = abi.encodeCall(this.someFunction, ());
Functions
constructor
constructor(address initialAuthority) AccessManaged(initialAuthority);
someFunction
function someFunction() public restricted;
authority_canCall_immediate
function authority_canCall_immediate(address caller) public view returns (bool result);
authority_canCall_delay
function authority_canCall_delay(address caller) public view returns (uint32 result);
authority_getSchedule
function authority_getSchedule(address caller) public view returns (uint48);
AccessManagerHarness
Inherits: AccessManager
State Variables
_minSetback
uint32 private _minSetback;
Functions
constructor
constructor(address initialAdmin) AccessManager(initialAdmin);
minSetback
function minSetback() public view override returns (uint32);
canCall_immediate
function canCall_immediate(address caller, address target, bytes4 selector) external view returns (bool result);
canCall_delay
function canCall_delay(address caller, address target, bytes4 selector) external view returns (uint32 result);
canCallExtended
function canCallExtended(address caller, address target, bytes calldata data) external view returns (bool, uint32);
canCallExtended_immediate
function canCallExtended_immediate(address caller, address target, bytes calldata data)
external
view
returns (bool result);
canCallExtended_delay
function canCallExtended_delay(address caller, address target, bytes calldata data)
external
view
returns (uint32 result);
getAdminRestrictions_restricted
function getAdminRestrictions_restricted(bytes calldata data) external view returns (bool result);
getAdminRestrictions_roleAdminId
function getAdminRestrictions_roleAdminId(bytes calldata data) external view returns (uint64 result);
getAdminRestrictions_executionDelay
function getAdminRestrictions_executionDelay(bytes calldata data) external view returns (uint32 result);
hasRole_isMember
function hasRole_isMember(uint64 roleId, address account) external view returns (bool result);
hasRole_executionDelay
function hasRole_executionDelay(uint64 roleId, address account) external view returns (uint32 result);
getAccess_since
function getAccess_since(uint64 roleId, address account) external view returns (uint48 result);
getAccess_currentDelay
function getAccess_currentDelay(uint64 roleId, address account) external view returns (uint32 result);
getAccess_pendingDelay
function getAccess_pendingDelay(uint64 roleId, address account) external view returns (uint32 result);
getAccess_effect
function getAccess_effect(uint64 roleId, address account) external view returns (uint48 result);
getTargetAdminDelay_after
function getTargetAdminDelay_after(address target) public view virtual returns (uint32 result);
getTargetAdminDelay_effect
function getTargetAdminDelay_effect(address target) public view virtual returns (uint48 result);
getRoleGrantDelay_after
function getRoleGrantDelay_after(uint64 roleId) public view virtual returns (uint32 result);
getRoleGrantDelay_effect
function getRoleGrantDelay_effect(uint64 roleId) public view virtual returns (uint48 result);
hashExecutionId
function hashExecutionId(address target, bytes4 selector) external pure returns (bytes32);
executionId
function executionId() external view returns (bytes32);
getSelector
function getSelector(bytes calldata data) external pure returns (bytes4);
getFirstArgumentAsAddress
function getFirstArgumentAsAddress(bytes calldata data) external pure returns (address);
getFirstArgumentAsUint64
function getFirstArgumentAsUint64(bytes calldata data) external pure returns (uint64);
_checkAuthorized
function _checkAuthorized() internal override;
DoubleEndedQueueHarness
State Variables
_deque
DoubleEndedQueue.Bytes32Deque private _deque;
Functions
pushFront
function pushFront(bytes32 value) external;
pushBack
function pushBack(bytes32 value) external;
popFront
function popFront() external returns (bytes32 value);
popBack
function popBack() external returns (bytes32 value);
clear
function clear() external;
begin
function begin() external view returns (uint128);
end
function end() external view returns (uint128);
length
function length() external view returns (uint256);
empty
function empty() external view returns (bool);
front
function front() external view returns (bytes32 value);
back
function back() external view returns (bytes32 value);
at_
function at_(uint256 index) external view returns (bytes32 value);
ERC20FlashMintHarness
Inherits: ERC20, ERC20Permit, ERC20FlashMint
State Variables
someFee
uint256 someFee;
someFeeReceiver
address someFeeReceiver;
Functions
constructor
constructor(string memory name, string memory symbol) ERC20(name, symbol) ERC20Permit(name);
mint
function mint(address account, uint256 amount) external;
burn
function burn(address account, uint256 amount) external;
flashFeeReceiver
function flashFeeReceiver() public view returns (address);
_flashFee
function _flashFee(address, uint256) internal view override returns (uint256);
_flashFeeReceiver
function _flashFeeReceiver() internal view override returns (address);
ERC20PermitHarness
Inherits: ERC20Permit
Functions
constructor
constructor(string memory name, string memory symbol) ERC20(name, symbol) ERC20Permit(name);
mint
function mint(address account, uint256 amount) external;
burn
function burn(address account, uint256 amount) external;
ERC20WrapperHarness
Inherits: ERC20Permit, ERC20Wrapper
Functions
constructor
constructor(IERC20 _underlying, string memory _name, string memory _symbol)
ERC20(_name, _symbol)
ERC20Permit(_name)
ERC20Wrapper(_underlying);
underlyingTotalSupply
function underlyingTotalSupply() public view returns (uint256);
underlyingBalanceOf
function underlyingBalanceOf(address account) public view returns (uint256);
underlyingAllowanceToThis
function underlyingAllowanceToThis(address account) public view returns (uint256);
recover
function recover(address account) public returns (uint256);
decimals
function decimals() public view override(ERC20Wrapper, ERC20) returns (uint8);
ERC3156FlashBorrowerHarness
Inherits: IERC3156FlashBorrower
State Variables
somethingToReturn
bytes32 somethingToReturn;
Functions
onFlashLoan
function onFlashLoan(address, address, uint256, uint256, bytes calldata) external view override returns (bytes32);
ERC721Harness
Inherits: ERC721
Functions
constructor
constructor(string memory name, string memory symbol) ERC721(name, symbol);
mint
function mint(address account, uint256 tokenId) external;
safeMint
function safeMint(address to, uint256 tokenId) external;
safeMint
function safeMint(address to, uint256 tokenId, bytes memory data) external;
burn
function burn(uint256 tokenId) external;
unsafeOwnerOf
function unsafeOwnerOf(uint256 tokenId) external view returns (address);
unsafeGetApproved
function unsafeGetApproved(uint256 tokenId) external view returns (address);
ERC721ReceiverHarness
Inherits: IERC721Receiver
Functions
onERC721Received
function onERC721Received(address, address, uint256, bytes calldata) external pure returns (bytes4);
EnumerableMapHarness
State Variables
_map
EnumerableMap.Bytes32ToBytes32Map private _map;
Functions
set
function set(bytes32 key, bytes32 value) public returns (bool);
remove
function remove(bytes32 key) public returns (bool);
contains
function contains(bytes32 key) public view returns (bool);
length
function length() public view returns (uint256);
key_at
function key_at(uint256 index) public view returns (bytes32);
value_at
function value_at(uint256 index) public view returns (bytes32);
tryGet_contains
function tryGet_contains(bytes32 key) public view returns (bool);
tryGet_value
function tryGet_value(bytes32 key) public view returns (bytes32);
get
function get(bytes32 key) public view returns (bytes32);
_positionOf
function _positionOf(bytes32 key) public view returns (uint256);
EnumerableSetHarness
State Variables
_set
EnumerableSet.Bytes32Set private _set;
Functions
add
function add(bytes32 value) public returns (bool);
remove
function remove(bytes32 value) public returns (bool);
contains
function contains(bytes32 value) public view returns (bool);
length
function length() public view returns (uint256);
at_
function at_(uint256 index) public view returns (bytes32);
_positionOf
function _positionOf(bytes32 value) public view returns (uint256);
InitializableHarness
Inherits: Initializable
Functions
initialize
function initialize() public initializer;
reinitialize
function reinitialize(uint64 n) public reinitializer(n);
disable
function disable() public;
nested_init_init
function nested_init_init() public initializer;
nested_init_reinit
function nested_init_reinit(uint64 m) public initializer;
nested_reinit_init
function nested_reinit_init(uint64 n) public reinitializer(n);
nested_reinit_reinit
function nested_reinit_reinit(uint64 n, uint64 m) public reinitializer(n);
version
function version() public view returns (uint64);
initializing
function initializing() public view returns (bool);
NoncesHarness
Inherits: Nonces
Functions
useNonce
function useNonce(address account) external returns (uint256);
useCheckedNonce
function useCheckedNonce(address account, uint256 nonce) external;
Ownable2StepHarness
Inherits: Ownable2Step
Functions
constructor
constructor(address initialOwner) Ownable(initialOwner);
restricted
function restricted() external onlyOwner;
OwnableHarness
Inherits: Ownable
Functions
constructor
constructor(address initialOwner) Ownable(initialOwner);
restricted
function restricted() external onlyOwner;
PausableHarness
Inherits: Pausable
Functions
pause
function pause() external;
unpause
function unpause() external;
onlyWhenPaused
function onlyWhenPaused() external whenPaused;
onlyWhenNotPaused
function onlyWhenNotPaused() external whenNotPaused;
TimelockControllerHarness
Inherits: TimelockController
Functions
constructor
constructor(uint256 minDelay, address[] memory proposers, address[] memory executors, address admin)
TimelockController(minDelay, proposers, executors, admin);
Contents
Contents
Contents
AccessControlDefaultAdminRulesUpgradeable
Inherits: Initializable, IAccessControlDefaultAdminRules, IERC5313, AccessControlUpgradeable
*Extension of {AccessControl} that allows specifying special rules to manage
the DEFAULT_ADMIN_ROLE holder, which is a sensitive role with special permissions
over other roles that may potentially have privileged rights in the system.
If a specific role doesn't have an admin role assigned, the holder of the
DEFAULT_ADMIN_ROLE will have the ability to grant it and revoke it.
This contract implements the following risk mitigations on top of {AccessControl}:
Only one account holds the DEFAULT_ADMIN_ROLE since deployment until it's potentially renounced.
Enforces a 2-step process to transfer the DEFAULT_ADMIN_ROLE to another account.
Enforces a configurable delay between the two steps, with the ability to cancel before the transfer is accepted.
The delay can be changed by scheduling, see {changeDefaultAdminDelay}.
Role transfers must wait at least one block after scheduling before it can be accepted.
It is not possible to use another role to manage the DEFAULT_ADMIN_ROLE.
Example usage:
contract MyToken is AccessControlDefaultAdminRules {
constructor() AccessControlDefaultAdminRules(
3 days,
msg.sender // Explicit initial `DEFAULT_ADMIN_ROLE` holder
) {}
}
```*
## State Variables
### AccessControlDefaultAdminRulesStorageLocation
```solidity
bytes32 private constant AccessControlDefaultAdminRulesStorageLocation =
0xeef3dac4538c82c8ace4063ab0acd2d15cdb5883aa1dff7c2673abb3d8698400;
Functions
_getAccessControlDefaultAdminRulesStorage
function _getAccessControlDefaultAdminRulesStorage()
private
pure
returns (AccessControlDefaultAdminRulesStorage storage $);
__AccessControlDefaultAdminRules_init
Sets the initial values for defaultAdminDelay and {defaultAdmin} address.
function __AccessControlDefaultAdminRules_init(uint48 initialDelay, address initialDefaultAdmin)
internal
onlyInitializing;
__AccessControlDefaultAdminRules_init_unchained
function __AccessControlDefaultAdminRules_init_unchained(uint48 initialDelay, address initialDefaultAdmin)
internal
onlyInitializing;
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
owner
Gets the address of the owner.
function owner() public view virtual returns (address);
grantRole
Override AccessControl role management
See AccessControl-grantRole. Reverts for DEFAULT_ADMIN_ROLE.
function grantRole(bytes32 role, address account) public virtual override(AccessControlUpgradeable, IAccessControl);
revokeRole
See AccessControl-revokeRole. Reverts for DEFAULT_ADMIN_ROLE.
function revokeRole(bytes32 role, address account) public virtual override(AccessControlUpgradeable, IAccessControl);
renounceRole
See AccessControl-renounceRole.
For the DEFAULT_ADMIN_ROLE, it only allows renouncing in two steps by first calling
{beginDefaultAdminTransfer} to the address(0), so it's required that the {pendingDefaultAdmin} schedule
has also passed when calling this function.
After its execution, it will not be possible to call onlyRole(DEFAULT_ADMIN_ROLE) functions.
NOTE: Renouncing DEFAULT_ADMIN_ROLE will leave the contract without a {defaultAdmin},
thereby disabling any functionality that is only available for it, and the possibility of reassigning a
non-administrated role.
function renounceRole(bytes32 role, address account)
public
virtual
override(AccessControlUpgradeable, IAccessControl);
_grantRole
See AccessControl-_grantRole.
For DEFAULT_ADMIN_ROLE, it only allows granting if there isn't already a {defaultAdmin} or if the
role has been previously renounced.
NOTE: Exposing this function through another mechanism may make the DEFAULT_ADMIN_ROLE
assignable again. Make sure to guarantee this is the expected behavior in your implementation.
function _grantRole(bytes32 role, address account) internal virtual override returns (bool);
_revokeRole
Attempts to revoke role from account and returns a boolean indicating if role was revoked.
Internal function without access restriction.
May emit a {RoleRevoked} event.
function _revokeRole(bytes32 role, address account) internal virtual override returns (bool);
_setRoleAdmin
See AccessControl-_setRoleAdmin. Reverts for DEFAULT_ADMIN_ROLE.
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual override;
defaultAdmin
AccessControlDefaultAdminRules accessors
Returns the address of the current DEFAULT_ADMIN_ROLE holder.
function defaultAdmin() public view virtual returns (address);
pendingDefaultAdmin
Returns a tuple of a newAdmin and an accept schedule.
After the schedule passes, the newAdmin will be able to accept the {defaultAdmin} role
by calling {acceptDefaultAdminTransfer}, completing the role transfer.
A zero value only in acceptSchedule indicates no pending admin transfer.
NOTE: A zero address newAdmin means that {defaultAdmin} is being renounced.
function pendingDefaultAdmin() public view virtual returns (address newAdmin, uint48 schedule);
defaultAdminDelay
Returns the delay required to schedule the acceptance of a {defaultAdmin} transfer started. This delay will be added to the current timestamp when calling {beginDefaultAdminTransfer} to set the acceptance schedule. NOTE: If a delay change has been scheduled, it will take effect as soon as the schedule passes, making this function returns the new delay. See {changeDefaultAdminDelay}.
function defaultAdminDelay() public view virtual returns (uint48);
pendingDefaultAdminDelay
Returns a tuple of newDelay and an effect schedule.
After the schedule passes, the newDelay will get into effect immediately for every
new {defaultAdmin} transfer started with {beginDefaultAdminTransfer}.
A zero value only in effectSchedule indicates no pending delay change.
NOTE: A zero value only for newDelay means that the next {defaultAdminDelay}
will be zero after the effect schedule.
function pendingDefaultAdminDelay() public view virtual returns (uint48 newDelay, uint48 schedule);
defaultAdminDelayIncreaseWait
Maximum time in seconds for an increase to {defaultAdminDelay} (that is scheduled using {changeDefaultAdminDelay}) to take effect. Default to 5 days. When the {defaultAdminDelay} is scheduled to be increased, it goes into effect after the new delay has passed with the purpose of giving enough time for reverting any accidental change (i.e. using milliseconds instead of seconds) that may lock the contract. However, to avoid excessive schedules, the wait is capped by this function and it can be overrode for a custom {defaultAdminDelay} increase scheduling. IMPORTANT: Make sure to add a reasonable amount of time while overriding this value, otherwise, there's a risk of setting a high new delay that goes into effect almost immediately without the possibility of human intervention in the case of an input error (eg. set milliseconds instead of seconds).
function defaultAdminDelayIncreaseWait() public view virtual returns (uint48);
beginDefaultAdminTransfer
AccessControlDefaultAdminRules public and internal setters for defaultAdmin/pendingDefaultAdmin
*Starts a {defaultAdmin} transfer by setting a {pendingDefaultAdmin} scheduled for acceptance after the current timestamp plus a {defaultAdminDelay}. Requirements:
- Only can be called by the current {defaultAdmin}. Emits a DefaultAdminRoleChangeStarted event.*
function beginDefaultAdminTransfer(address newAdmin) public virtual onlyRole(DEFAULT_ADMIN_ROLE);
_beginDefaultAdminTransfer
See beginDefaultAdminTransfer. Internal function without access restriction.
function _beginDefaultAdminTransfer(address newAdmin) internal virtual;
cancelDefaultAdminTransfer
*Cancels a {defaultAdmin} transfer previously started with {beginDefaultAdminTransfer}. A {pendingDefaultAdmin} not yet accepted can also be cancelled with this function. Requirements:
- Only can be called by the current {defaultAdmin}. May emit a DefaultAdminTransferCanceled event.*
function cancelDefaultAdminTransfer() public virtual onlyRole(DEFAULT_ADMIN_ROLE);
_cancelDefaultAdminTransfer
See cancelDefaultAdminTransfer. Internal function without access restriction.
function _cancelDefaultAdminTransfer() internal virtual;
acceptDefaultAdminTransfer
*Completes a {defaultAdmin} transfer previously started with {beginDefaultAdminTransfer}. After calling the function:
DEFAULT_ADMIN_ROLEshould be granted to the caller.DEFAULT_ADMIN_ROLEshould be revoked from the previous holder.- {pendingDefaultAdmin} should be reset to zero values. Requirements:
- Only can be called by the {pendingDefaultAdmin}'s
newAdmin. - The {pendingDefaultAdmin}'s
acceptScheduleshould've passed.*
function acceptDefaultAdminTransfer() public virtual;
_acceptDefaultAdminTransfer
See acceptDefaultAdminTransfer. Internal function without access restriction.
function _acceptDefaultAdminTransfer() internal virtual;
changeDefaultAdminDelay
AccessControlDefaultAdminRules public and internal setters for defaultAdminDelay/pendingDefaultAdminDelay
*Initiates a {defaultAdminDelay} update by setting a {pendingDefaultAdminDelay} scheduled for getting into effect after the current timestamp plus a {defaultAdminDelay}. This function guarantees that any call to {beginDefaultAdminTransfer} done between the timestamp this method is called and the {pendingDefaultAdminDelay} effect schedule will use the current {defaultAdminDelay} set before calling. The {pendingDefaultAdminDelay}'s effect schedule is defined in a way that waiting until the schedule and then calling {beginDefaultAdminTransfer} with the new delay will take at least the same as another {defaultAdmin} complete transfer (including acceptance). The schedule is designed for two scenarios:
- When the delay is changed for a larger one the schedule is
block.timestamp + newDelaycapped by {defaultAdminDelayIncreaseWait}. - When the delay is changed for a shorter one, the schedule is
block.timestamp + (current delay - new delay). A {pendingDefaultAdminDelay} that never got into effect will be canceled in favor of a new scheduled change. Requirements: - Only can be called by the current {defaultAdmin}. Emits a DefaultAdminDelayChangeScheduled event and may emit a DefaultAdminDelayChangeCanceled event.*
function changeDefaultAdminDelay(uint48 newDelay) public virtual onlyRole(DEFAULT_ADMIN_ROLE);
_changeDefaultAdminDelay
See changeDefaultAdminDelay. Internal function without access restriction.
function _changeDefaultAdminDelay(uint48 newDelay) internal virtual;
rollbackDefaultAdminDelay
*Cancels a scheduled {defaultAdminDelay} change. Requirements:
- Only can be called by the current {defaultAdmin}. May emit a DefaultAdminDelayChangeCanceled event.*
function rollbackDefaultAdminDelay() public virtual onlyRole(DEFAULT_ADMIN_ROLE);
_rollbackDefaultAdminDelay
See rollbackDefaultAdminDelay. Internal function without access restriction.
function _rollbackDefaultAdminDelay() internal virtual;
_delayChangeWait
Returns the amount of seconds to wait after the newDelay will
become the new defaultAdminDelay.
The value returned guarantees that if the delay is reduced, it will go into effect
after a wait that honors the previously set delay.
See {defaultAdminDelayIncreaseWait}.
function _delayChangeWait(uint48 newDelay) internal view virtual returns (uint48);
_setPendingDefaultAdmin
Private setters
Setter of the tuple for pending admin and its schedule. May emit a DefaultAdminTransferCanceled event.
function _setPendingDefaultAdmin(address newAdmin, uint48 newSchedule) private;
_setPendingDelay
Setter of the tuple for pending delay and its schedule. May emit a DefaultAdminDelayChangeCanceled event.
function _setPendingDelay(uint48 newDelay, uint48 newSchedule) private;
_isScheduleSet
Private helpers
Defines if an schedule is considered set. For consistency purposes.
function _isScheduleSet(uint48 schedule) private pure returns (bool);
_hasSchedulePassed
Defines if an schedule is considered passed. For consistency purposes.
function _hasSchedulePassed(uint48 schedule) private view returns (bool);
Structs
AccessControlDefaultAdminRulesStorage
Note: storage-location: erc7201:openzeppelin.storage.AccessControlDefaultAdminRules
struct AccessControlDefaultAdminRulesStorage {
address _pendingDefaultAdmin;
uint48 _pendingDefaultAdminSchedule;
uint48 _currentDelay;
address _currentDefaultAdmin;
uint48 _pendingDelay;
uint48 _pendingDelaySchedule;
}
AccessControlEnumerableUpgradeable
Inherits: Initializable, IAccessControlEnumerable, AccessControlUpgradeable
Extension of {AccessControl} that allows enumerating the members of each role.
State Variables
AccessControlEnumerableStorageLocation
bytes32 private constant AccessControlEnumerableStorageLocation =
0xc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000;
Functions
_getAccessControlEnumerableStorage
function _getAccessControlEnumerableStorage() private pure returns (AccessControlEnumerableStorage storage $);
__AccessControlEnumerable_init
function __AccessControlEnumerable_init() internal onlyInitializing;
__AccessControlEnumerable_init_unchained
function __AccessControlEnumerable_init_unchained() internal onlyInitializing;
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
getRoleMember
Returns one of the accounts that have role. index must be a
value between 0 and getRoleMemberCount, non-inclusive.
Role bearers are not sorted in any particular way, and their ordering may
change at any point.
WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
you perform all queries on the same block. See the following
https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
for more information.
function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address);
getRoleMemberCount
Returns the number of accounts that have role. Can be used
together with getRoleMember to enumerate all bearers of a role.
function getRoleMemberCount(bytes32 role) public view virtual returns (uint256);
getRoleMembers
Return all accounts that have role
WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
this function has an unbounded cost, and using it as part of a state-changing function may render the function
uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
function getRoleMembers(bytes32 role) public view virtual returns (address[] memory);
_grantRole
Overload AccessControl-_grantRole to track enumerable memberships
function _grantRole(bytes32 role, address account) internal virtual override returns (bool);
_revokeRole
Overload AccessControl-_revokeRole to track enumerable memberships
function _revokeRole(bytes32 role, address account) internal virtual override returns (bool);
Structs
AccessControlEnumerableStorage
Note: storage-location: erc7201:openzeppelin.storage.AccessControlEnumerable
struct AccessControlEnumerableStorage {
mapping(bytes32 role => EnumerableSet.AddressSet) _roleMembers;
}
Contents
AccessManagedUpgradeable
Inherits: Initializable, ContextUpgradeable, IAccessManaged
This contract module makes available a restricted modifier. Functions decorated with this modifier will be
permissioned according to an "authority": a contract like {AccessManager} that follows the {IAuthority} interface,
implementing a policy that allows certain callers to access certain functions.
IMPORTANT: The restricted modifier should never be used on internal functions, judiciously used in public
functions, and ideally only used in external functions. See {restricted}.
State Variables
AccessManagedStorageLocation
bytes32 private constant AccessManagedStorageLocation =
0xf3177357ab46d8af007ab3fdb9af81da189e1068fefdc0073dca88a2cab40a00;
Functions
_getAccessManagedStorage
function _getAccessManagedStorage() private pure returns (AccessManagedStorage storage $);
__AccessManaged_init
Initializes the contract connected to an initial authority.
function __AccessManaged_init(address initialAuthority) internal onlyInitializing;
__AccessManaged_init_unchained
function __AccessManaged_init_unchained(address initialAuthority) internal onlyInitializing;
restricted
*Restricts access to a function as defined by the connected Authority for this contract and the caller and selector of the function that entered the contract. [IMPORTANT]
In general, this modifier should only be used on external functions. It is okay to use it on public
functions that are used as external entry points and are not called internally. Unless you know what you're
doing, it should never be used on internal functions. Failure to follow these rules can have critical security
implications! This is because the permissions are determined by the function that entered the contract, i.e. the
function at the bottom of the call stack, and not the function where the modifier is visible in the source code.
[WARNING]
Avoid adding this modifier to the https://docs.soliditylang.org/en/v0.8.20/contracts.html#receive-ether-function[receive()]
function or the https://docs.soliditylang.org/en/v0.8.20/contracts.html#fallback-function[fallback()]. These
functions are the only execution paths where a function selector cannot be unambiguously determined from the calldata
since the selector defaults to 0x00000000 in the receive() function and similarly in the fallback() function
if no calldata is provided. (See _checkCanCall).
The receive() function will always panic whereas the fallback() may panic depending on the calldata length.
====*
modifier restricted();
authority
Returns the current authority.
function authority() public view virtual returns (address);
setAuthority
Transfers control to a new authority. The caller must be the current authority.
function setAuthority(address newAuthority) public virtual;
isConsumingScheduledOp
Returns true only in the context of a delayed restricted call, at the moment that the scheduled operation is being consumed. Prevents denial of service for delayed restricted calls in the case that the contract performs attacker controlled calls.
function isConsumingScheduledOp() public view returns (bytes4);
_setAuthority
Transfers control to a new authority. Internal function with no access restriction. Allows bypassing the permissions set by the current authority.
function _setAuthority(address newAuthority) internal virtual;
_checkCanCall
Reverts if the caller is not allowed to call the function identified by a selector. Panics if the calldata is less than 4 bytes long.
function _checkCanCall(address caller, bytes calldata data) internal virtual;
Structs
AccessManagedStorage
Note: storage-location: erc7201:openzeppelin.storage.AccessManaged
struct AccessManagedStorage {
address _authority;
bool _consumingSchedule;
}
AccessManagerUpgradeable
Inherits: Initializable, ContextUpgradeable, MulticallUpgradeable, IAccessManager
AccessManager is a central contract to store the permissions of a system.
A smart contract under the control of an AccessManager instance is known as a target, and will inherit from the
{AccessManaged} contract, be connected to this contract as its manager and implement the {AccessManaged-restricted}
modifier on a set of functions selected to be permissioned. Note that any function without this setup won't be
effectively restricted.
The restriction rules for such functions are defined in terms of "roles" identified by an uint64 and scoped
by target (address) and function selectors (bytes4). These roles are stored in this contract and can be
configured by admins (ADMIN_ROLE members) after a delay (see {getTargetAdminDelay}).
For each target contract, admins can configure the following without any delay:
The target's {AccessManaged-authority} via {updateAuthority}.
Close or open a target via {setTargetClosed} keeping the permissions intact.
The roles that are allowed (or disallowed) to call a given function (identified by its selector) through {setTargetFunctionRole}.
By default every address is member of the PUBLIC_ROLE and every target function is restricted to the ADMIN_ROLE until configured otherwise.
Additionally, each role has the following configuration options restricted to this manager's admins:
A role's admin role via {setRoleAdmin} who can grant or revoke roles.
A role's guardian role via {setRoleGuardian} who's allowed to cancel operations.
A delay in which a role takes effect after being granted through {setGrantDelay}.
A delay of any target's admin action via {setTargetAdminDelay}.
A role label for discoverability purposes with {labelRole}.
Any account can be added and removed into any number of these roles by using the {grantRole} and {revokeRole} functions
restricted to each role's admin (see {getRoleAdmin}).
Since all the permissions of the managed system can be modified by the admins of this instance, it is expected that
they will be highly secured (e.g., a multisig or a well-configured DAO).
NOTE: This contract implements a form of the {IAuthority} interface, but {canCall} has additional return data so it
doesn't inherit IAuthority. It is however compatible with the IAuthority interface since the first 32 bytes of
the return data are a boolean as expected by that interface.
NOTE: Systems that implement other access control mechanisms (for example using {Ownable}) can be paired with an
{AccessManager} by transferring permissions (ownership in the case of {Ownable}) directly to the {AccessManager}.
Users will be able to interact with these contracts through the {execute} function, following the access rules
registered in the {AccessManager}. Keep in mind that in that context, the msg.sender seen by restricted functions
will be {AccessManager} itself.
WARNING: When granting permissions over an {Ownable} or {AccessControl} contract to an {AccessManager}, be very
mindful of the danger associated with functions such as {Ownable-renounceOwnership} or
{AccessControl-renounceRole}.
State Variables
ADMIN_ROLE
The identifier of the admin role. Required to perform most configuration operations including other roles' management and target restrictions.
uint64 public constant ADMIN_ROLE = type(uint64).min;
PUBLIC_ROLE
The identifier of the public role. Automatically granted to all addresses with no delay.
uint64 public constant PUBLIC_ROLE = type(uint64).max;
AccessManagerStorageLocation
bytes32 private constant AccessManagerStorageLocation =
0x40c6c8c28789853c7efd823ab20824bbd71718a8a5915e855f6f288c9a26ad00;
Functions
_getAccessManagerStorage
function _getAccessManagerStorage() private pure returns (AccessManagerStorage storage $);
onlyAuthorized
Check that the caller is authorized to perform the operation. See {AccessManager} description for a detailed breakdown of the authorization logic.
modifier onlyAuthorized();
initialize
function initialize(address initialAdmin) public virtual initializer;
__AccessManager_init
function __AccessManager_init(address initialAdmin) internal onlyInitializing;
__AccessManager_init_unchained
function __AccessManager_init_unchained(address initialAdmin) internal onlyInitializing;
canCall
Check if an address (caller) is authorised to call a given function on a given contract directly (with
no restriction). Additionally, it returns the delay needed to perform the call indirectly through the {schedule}
& {execute} workflow.
This function is usually called by the targeted contract to control immediate execution of restricted functions.
Therefore we only return true if the call can be performed without any delay. If the call is subject to a
previously set delay (not zero), then the function should return false and the caller should schedule the operation
for future execution.
If allowed is true, the delay can be disregarded and the operation can be immediately executed, otherwise
the operation can be executed if and only if delay is greater than 0.
NOTE: The IAuthority interface does not include the uint32 delay. This is an extension of that interface that
is backward compatible. Some contracts may thus ignore the second return argument. In that case they will fail
to identify the indirect workflow, and will consider calls that require a delay to be forbidden.
NOTE: This function does not report the permissions of the admin functions in the manager itself. These are defined by the
{AccessManager} documentation.
function canCall(address caller, address target, bytes4 selector)
public
view
virtual
returns (bool immediate, uint32 delay);
expiration
Expiration delay for scheduled proposals. Defaults to 1 week. IMPORTANT: Avoid overriding the expiration with 0. Otherwise every contract proposal will be expired immediately, disabling any scheduling usage.
function expiration() public view virtual returns (uint32);
minSetback
Minimum setback for all delay updates, with the exception of execution delays. It can be increased without setback (and reset via {revokeRole} in the case event of an accidental increase). Defaults to 5 days.
function minSetback() public view virtual returns (uint32);
isTargetClosed
Get whether the contract is closed disabling any access. Otherwise role permissions are applied. NOTE: When the manager itself is closed, admin functions are still accessible to avoid locking the contract.
function isTargetClosed(address target) public view virtual returns (bool);
getTargetFunctionRole
Get the role required to call a function.
function getTargetFunctionRole(address target, bytes4 selector) public view virtual returns (uint64);
getTargetAdminDelay
Get the admin delay for a target contract. Changes to contract configuration are subject to this delay.
function getTargetAdminDelay(address target) public view virtual returns (uint32);
getRoleAdmin
Get the id of the role that acts as an admin for the given role. The admin permission is required to grant the role, revoke the role and update the execution delay to execute an operation that is restricted to this role.
function getRoleAdmin(uint64 roleId) public view virtual returns (uint64);
getRoleGuardian
Get the role that acts as a guardian for a given role. The guardian permission allows canceling operations that have been scheduled under the role.
function getRoleGuardian(uint64 roleId) public view virtual returns (uint64);
getRoleGrantDelay
Get the role current grant delay. Its value may change at any point without an event emitted following a call to {setGrantDelay}. Changes to this value, including effect timepoint are notified in advance by the {RoleGrantDelayChanged} event.
function getRoleGrantDelay(uint64 roleId) public view virtual returns (uint32);
getAccess
Get the access details for a given account for a given role. These details include the timepoint at which membership becomes active, and the delay applied to all operation by this user that requires this permission level. Returns: [0] Timestamp at which the account membership becomes valid. 0 means role is not granted. [1] Current execution delay for the account. [2] Pending execution delay for the account. [3] Timestamp at which the pending execution delay will become active. 0 means no delay update is scheduled.
function getAccess(uint64 roleId, address account)
public
view
virtual
returns (uint48 since, uint32 currentDelay, uint32 pendingDelay, uint48 effect);
hasRole
Check if a given account currently has the permission level corresponding to a given role. Note that this permission might be associated with an execution delay. {getAccess} can provide more details.
function hasRole(uint64 roleId, address account) public view virtual returns (bool isMember, uint32 executionDelay);
labelRole
*Give a label to a role, for improved role discoverability by UIs. Requirements:
- the caller must be a global admin Emits a {RoleLabel} event.*
function labelRole(uint64 roleId, string calldata label) public virtual onlyAuthorized;
grantRole
*Add account to roleId, or change its execution delay.
This gives the account the authorization to call any function that is restricted to this role. An optional
execution delay (in seconds) can be set. If that delay is non 0, the user is required to schedule any operation
that is restricted to members of this role. The user will only be able to execute the operation after the delay has
passed, before it has expired. During this period, admin and guardians can cancel the operation (see {cancel}).
If the account has already been granted this role, the execution delay will be updated. This update is not
immediate and follows the delay rules. For example, if a user currently has a delay of 3 hours, and this is
called to reduce that delay to 1 hour, the new delay will take some time to take effect, enforcing that any
operation executed in the 3 hours that follows this update was indeed scheduled before this update.
Requirements:
- the caller must be an admin for the role (see {getRoleAdmin})
- granted role must not be the
PUBLIC_ROLEEmits a {RoleGranted} event.*
function grantRole(uint64 roleId, address account, uint32 executionDelay) public virtual onlyAuthorized;
revokeRole
*Remove an account from a role, with immediate effect. If the account does not have the role, this call has no effect. Requirements:
- the caller must be an admin for the role (see {getRoleAdmin})
- revoked role must not be the
PUBLIC_ROLEEmits a {RoleRevoked} event if the account had the role.*
function revokeRole(uint64 roleId, address account) public virtual onlyAuthorized;
renounceRole
*Renounce role permissions for the calling account with immediate effect. If the sender is not in the role this call has no effect. Requirements:
- the caller must be
callerConfirmation. Emits a {RoleRevoked} event if the account had the role.*
function renounceRole(uint64 roleId, address callerConfirmation) public virtual;
setRoleAdmin
*Change admin role for a given role. Requirements:
- the caller must be a global admin Emits a {RoleAdminChanged} event*
function setRoleAdmin(uint64 roleId, uint64 admin) public virtual onlyAuthorized;
setRoleGuardian
*Change guardian role for a given role. Requirements:
- the caller must be a global admin Emits a {RoleGuardianChanged} event*
function setRoleGuardian(uint64 roleId, uint64 guardian) public virtual onlyAuthorized;
setGrantDelay
*Update the delay for granting a roleId.
Requirements:
- the caller must be a global admin Emits a {RoleGrantDelayChanged} event.*
function setGrantDelay(uint64 roleId, uint32 newDelay) public virtual onlyAuthorized;
_grantRole
Internal version of grantRole without access control. Returns true if the role was newly granted. Emits a {RoleGranted} event.
function _grantRole(uint64 roleId, address account, uint32 grantDelay, uint32 executionDelay)
internal
virtual
returns (bool);
_revokeRole
Internal version of revokeRole without access control. This logic is also used by {renounceRole}. Returns true if the role was previously granted. Emits a {RoleRevoked} event if the account had the role.
function _revokeRole(uint64 roleId, address account) internal virtual returns (bool);
_setRoleAdmin
Internal version of setRoleAdmin without access control.
Emits a {RoleAdminChanged} event.
NOTE: Setting the admin role as the PUBLIC_ROLE is allowed, but it will effectively allow
anyone to set grant or revoke such role.
function _setRoleAdmin(uint64 roleId, uint64 admin) internal virtual;
_setRoleGuardian
Internal version of setRoleGuardian without access control.
Emits a {RoleGuardianChanged} event.
NOTE: Setting the guardian role as the PUBLIC_ROLE is allowed, but it will effectively allow
anyone to cancel any scheduled operation for such role.
function _setRoleGuardian(uint64 roleId, uint64 guardian) internal virtual;
_setGrantDelay
Internal version of setGrantDelay without access control. Emits a {RoleGrantDelayChanged} event.
function _setGrantDelay(uint64 roleId, uint32 newDelay) internal virtual;
setTargetFunctionRole
*Set the role required to call functions identified by the selectors in the target contract.
Requirements:
- the caller must be a global admin Emits a {TargetFunctionRoleUpdated} event per selector.*
function setTargetFunctionRole(address target, bytes4[] calldata selectors, uint64 roleId)
public
virtual
onlyAuthorized;
_setTargetFunctionRole
Internal version of setTargetFunctionRole without access control. Emits a {TargetFunctionRoleUpdated} event.
function _setTargetFunctionRole(address target, bytes4 selector, uint64 roleId) internal virtual;
setTargetAdminDelay
*Set the delay for changing the configuration of a given target contract. Requirements:
- the caller must be a global admin Emits a {TargetAdminDelayUpdated} event.*
function setTargetAdminDelay(address target, uint32 newDelay) public virtual onlyAuthorized;
_setTargetAdminDelay
Internal version of setTargetAdminDelay without access control. Emits a {TargetAdminDelayUpdated} event.
function _setTargetAdminDelay(address target, uint32 newDelay) internal virtual;
setTargetClosed
*Set the closed flag for a contract. Closing the manager itself won't disable access to admin methods to avoid locking the contract. Requirements:
- the caller must be a global admin Emits a {TargetClosed} event.*
function setTargetClosed(address target, bool closed) public virtual onlyAuthorized;
_setTargetClosed
Set the closed flag for a contract. This is an internal setter with no access restrictions. Emits a {TargetClosed} event.
function _setTargetClosed(address target, bool closed) internal virtual;
getSchedule
Return the timepoint at which a scheduled operation will be ready for execution. This returns 0 if the operation is not yet scheduled, has expired, was executed, or was canceled.
function getSchedule(bytes32 id) public view virtual returns (uint48);
getNonce
Return the nonce for the latest scheduled operation with a given id. Returns 0 if the operation has never been scheduled.
function getNonce(bytes32 id) public view virtual returns (uint32);
schedule
Schedule a delayed operation for future execution, and return the operation identifier. It is possible to
choose the timestamp at which the operation becomes executable as long as it satisfies the execution delays
required for the caller. The special value zero will automatically set the earliest possible time.
Returns the operationId that was scheduled. Since this value is a hash of the parameters, it can reoccur when
the same parameters are used; if this is relevant, the returned nonce can be used to uniquely identify this
scheduled operation from other occurrences of the same operationId in invocations of {execute} and {cancel}.
Emits a {OperationScheduled} event.
NOTE: It is not possible to concurrently schedule more than one operation with the same target and data. If
this is necessary, a random byte can be appended to data to act as a salt that will be ignored by the target
contract if it is using standard Solidity ABI encoding.
function schedule(address target, bytes calldata data, uint48 when)
public
virtual
returns (bytes32 operationId, uint32 nonce);
_checkNotScheduled
Reverts if the operation is currently scheduled and has not expired. NOTE: This function was introduced due to stack too deep errors in schedule.
function _checkNotScheduled(bytes32 operationId) private view;
execute
Execute a function that is delay restricted, provided it was properly scheduled beforehand, or the execution delay is 0. Returns the nonce that identifies the previously scheduled operation that is executed, or 0 if the operation wasn't previously scheduled (if the caller doesn't have an execution delay). Emits an {OperationExecuted} event only if the call was scheduled and delayed.
function execute(address target, bytes calldata data) public payable virtual returns (uint32);
cancel
*Cancel a scheduled (delayed) operation. Returns the nonce that identifies the previously scheduled operation that is cancelled. Requirements:
- the caller must be the proposer, a guardian of the targeted function, or a global admin Emits a {OperationCanceled} event.*
function cancel(address caller, address target, bytes calldata data) public virtual returns (uint32);
consumeScheduledOp
Consume a scheduled operation targeting the caller. If such an operation exists, mark it as consumed (emit an {OperationExecuted} event and clean the state). Otherwise, throw an error. This is useful for contract that want to enforce that calls targeting them were scheduled on the manager, with all the verifications that it implies. Emit a {OperationExecuted} event.
function consumeScheduledOp(address caller, bytes calldata data) public virtual;
_consumeScheduledOp
Internal variant of consumeScheduledOp that operates on bytes32 operationId. Returns the nonce of the scheduled operation that is consumed.
function _consumeScheduledOp(bytes32 operationId) internal virtual returns (uint32);
hashOperation
Hashing function for delayed operations.
function hashOperation(address caller, address target, bytes calldata data) public view virtual returns (bytes32);
updateAuthority
*Changes the authority of a target managed by this manager instance. Requirements:
- the caller must be a global admin*
function updateAuthority(address target, address newAuthority) public virtual onlyAuthorized;
_checkAuthorized
Check if the current call is authorized according to admin and roles logic. WARNING: Carefully review the considerations of AccessManaged-restricted since they apply to this modifier.
function _checkAuthorized() private;
_getAdminRestrictions
*Get the admin restrictions of a given function call based on the function and arguments involved. Returns:
- bool restricted: does this data match a restricted operation
- uint64: which role is this operation restricted to
- uint32: minimum delay to enforce for that operation (max between operation's delay and admin's execution delay)*
function _getAdminRestrictions(bytes calldata data)
private
view
returns (bool adminRestricted, uint64 roleAdminId, uint32 executionDelay);
_canCallExtended
*An extended version of canCall for internal usage that checks {_canCallSelf} when the target is this contract. Returns:
- bool immediate: whether the operation can be executed immediately (with no delay)
- uint32 delay: the execution delay*
function _canCallExtended(address caller, address target, bytes calldata data)
private
view
returns (bool immediate, uint32 delay);
_canCallSelf
A version of canCall that checks for restrictions in this contract.
function _canCallSelf(address caller, bytes calldata data) private view returns (bool immediate, uint32 delay);
_isExecuting
Returns true if a call with target and selector is being executed via {executed}.
function _isExecuting(address target, bytes4 selector) private view returns (bool);
_isExpired
Returns true if a schedule timepoint is past its expiration deadline.
function _isExpired(uint48 timepoint) private view returns (bool);
_checkSelector
Extracts the selector from calldata. Panics if data is not at least 4 bytes
function _checkSelector(bytes calldata data) private pure returns (bytes4);
_hashExecutionId
Hashing function for execute protection
function _hashExecutionId(address target, bytes4 selector) private pure returns (bytes32);
Structs
TargetConfig
struct TargetConfig {
mapping(bytes4 selector => uint64 roleId) allowedRoles;
Time.Delay adminDelay;
bool closed;
}
Access
struct Access {
uint48 since;
Time.Delay delay;
}
Role
struct Role {
mapping(address user => Access access) members;
uint64 admin;
uint64 guardian;
Time.Delay grantDelay;
}
Schedule
struct Schedule {
uint48 timepoint;
uint32 nonce;
}
AccessManagerStorage
Note: storage-location: erc7201:openzeppelin.storage.AccessManager
struct AccessManagerStorage {
mapping(address target => TargetConfig mode) _targets;
mapping(uint64 roleId => Role) _roles;
mapping(bytes32 operationId => Schedule) _schedules;
bytes32 _executionId;
}
AccessControlUpgradeable
Inherits: Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable
*Contract module that allows children to implement role-based access
control mechanisms. This is a lightweight version that doesn't allow enumerating role
members except through off-chain means by accessing the contract event logs. Some
applications may benefit from on-chain enumerability, for those cases see
{AccessControlEnumerable}.
Roles are referred to by their bytes32 identifier. These should be exposed
in the external API and be unique. The best way to achieve this is by
using public constant hash digests:
bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
Roles can be used to represent a set of permissions. To restrict access to a function call, use {hasRole}:
function foo() public {
require(hasRole(MY_ROLE, msg.sender));
...
}
Roles can be granted and revoked dynamically via the {grantRole} and
{revokeRole} functions. Each role has an associated admin role, and only
accounts that have a role's admin role can call {grantRole} and {revokeRole}.
By default, the admin role for all roles is DEFAULT_ADMIN_ROLE, which means
that only accounts with this role will be able to grant or revoke other
roles. More complex role relationships can be created by using
{_setRoleAdmin}.
WARNING: The DEFAULT_ADMIN_ROLE is also its own admin: it has permission to
grant and revoke this role. Extra precautions should be taken to secure
accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
to enforce additional security measures for this role.*
State Variables
DEFAULT_ADMIN_ROLE
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
AccessControlStorageLocation
bytes32 private constant AccessControlStorageLocation =
0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;
Functions
_getAccessControlStorage
function _getAccessControlStorage() private pure returns (AccessControlStorage storage $);
onlyRole
Modifier that checks that an account has a specific role. Reverts with an {AccessControlUnauthorizedAccount} error including the required role.
modifier onlyRole(bytes32 role);
__AccessControl_init
function __AccessControl_init() internal onlyInitializing;
__AccessControl_init_unchained
function __AccessControl_init_unchained() internal onlyInitializing;
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
hasRole
Returns true if account has been granted role.
function hasRole(bytes32 role, address account) public view virtual returns (bool);
_checkRole
Reverts with an {AccessControlUnauthorizedAccount} error if _msgSender()
is missing role. Overriding this function changes the behavior of the {onlyRole} modifier.
function _checkRole(bytes32 role) internal view virtual;
_checkRole
Reverts with an {AccessControlUnauthorizedAccount} error if account
is missing role.
function _checkRole(bytes32 role, address account) internal view virtual;
getRoleAdmin
Returns the admin role that controls role. See grantRole and
{revokeRole}.
To change a role's admin, use {_setRoleAdmin}.
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32);
grantRole
*Grants role to account.
If account had not been already granted role, emits a {RoleGranted}
event.
Requirements:
- the caller must have
role's admin role. May emit a {RoleGranted} event.*
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role));
revokeRole
*Revokes role from account.
If account had been granted role, emits a {RoleRevoked} event.
Requirements:
- the caller must have
role's admin role. May emit a {RoleRevoked} event.*
function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role));
renounceRole
*Revokes role from the calling account.
Roles are often managed via grantRole and {revokeRole}: this function's
purpose is to provide a mechanism for accounts to lose their privileges
if they are compromised (such as when a trusted device is misplaced).
If the calling account had been revoked role, emits a {RoleRevoked}
event.
Requirements:
- the caller must be
callerConfirmation. May emit a {RoleRevoked} event.*
function renounceRole(bytes32 role, address callerConfirmation) public virtual;
_setRoleAdmin
Sets adminRole as role's admin role.
Emits a {RoleAdminChanged} event.
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual;
_grantRole
Attempts to grant role to account and returns a boolean indicating if role was granted.
Internal function without access restriction.
May emit a {RoleGranted} event.
function _grantRole(bytes32 role, address account) internal virtual returns (bool);
_revokeRole
Attempts to revoke role from account and returns a boolean indicating if role was revoked.
Internal function without access restriction.
May emit a {RoleRevoked} event.
function _revokeRole(bytes32 role, address account) internal virtual returns (bool);
Structs
RoleData
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
AccessControlStorage
Note: storage-location: erc7201:openzeppelin.storage.AccessControl
struct AccessControlStorage {
mapping(bytes32 role => RoleData) _roles;
}
Ownable2StepUpgradeable
Inherits: Initializable, OwnableUpgradeable
Contract module which provides access control mechanism, where
there is an account (an owner) that can be granted exclusive access to
specific functions.
This extension of the {Ownable} contract includes a two-step mechanism to transfer
ownership, where the new owner must call {acceptOwnership} in order to replace the
old one. This can help prevent common mistakes, such as transfers of ownership to
incorrect accounts, or to contracts that are unable to interact with the
permission system.
The initial owner is specified at deployment time in the constructor for Ownable. This
can later be changed with {transferOwnership} and {acceptOwnership}.
This module is used through inheritance. It will make available all functions
from parent (Ownable).
State Variables
Ownable2StepStorageLocation
bytes32 private constant Ownable2StepStorageLocation =
0x237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c00;
Functions
_getOwnable2StepStorage
function _getOwnable2StepStorage() private pure returns (Ownable2StepStorage storage $);
__Ownable2Step_init
function __Ownable2Step_init() internal onlyInitializing;
__Ownable2Step_init_unchained
function __Ownable2Step_init_unchained() internal onlyInitializing;
pendingOwner
Returns the address of the pending owner.
function pendingOwner() public view virtual returns (address);
transferOwnership
Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
Can only be called by the current owner.
Setting newOwner to the zero address is allowed; this can be used to cancel an initiated ownership transfer.
function transferOwnership(address newOwner) public virtual override onlyOwner;
_transferOwnership
Transfers ownership of the contract to a new account (newOwner) and deletes any pending owner.
Internal function without access restriction.
function _transferOwnership(address newOwner) internal virtual override;
acceptOwnership
The new owner accepts the ownership transfer.
function acceptOwnership() public virtual;
Events
OwnershipTransferStarted
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
Structs
Ownable2StepStorage
Note: storage-location: erc7201:openzeppelin.storage.Ownable2Step
struct Ownable2StepStorage {
address _pendingOwner;
}
OwnableUpgradeable
Inherits: Initializable, ContextUpgradeable
Contract module which provides a basic access control mechanism, where
there is an account (an owner) that can be granted exclusive access to
specific functions.
The initial owner is set to the address provided by the deployer. This can
later be changed with transferOwnership.
This module is used through inheritance. It will make available the modifier
onlyOwner, which can be applied to your functions to restrict their use to
the owner.
State Variables
OwnableStorageLocation
bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;
Functions
_getOwnableStorage
function _getOwnableStorage() private pure returns (OwnableStorage storage $);
__Ownable_init
Initializes the contract setting the address provided by the deployer as the initial owner.
function __Ownable_init(address initialOwner) internal onlyInitializing;
__Ownable_init_unchained
function __Ownable_init_unchained(address initialOwner) internal onlyInitializing;
onlyOwner
Throws if called by any account other than the owner.
modifier onlyOwner();
owner
Returns the address of the current owner.
function owner() public view virtual returns (address);
_checkOwner
Throws if the sender is not the owner.
function _checkOwner() internal view virtual;
renounceOwnership
Leaves the contract without owner. It will not be possible to call
onlyOwner functions. Can only be called by the current owner.
NOTE: Renouncing ownership will leave the contract without an owner,
thereby disabling any functionality that is only available to the owner.
function renounceOwnership() public virtual onlyOwner;
transferOwnership
Transfers ownership of the contract to a new account (newOwner).
Can only be called by the current owner.
function transferOwnership(address newOwner) public virtual onlyOwner;
_transferOwnership
Transfers ownership of the contract to a new account (newOwner).
Internal function without access restriction.
function _transferOwnership(address newOwner) internal virtual;
Events
OwnershipTransferred
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
Errors
OwnableUnauthorizedAccount
The caller account is not authorized to perform an operation.
error OwnableUnauthorizedAccount(address account);
OwnableInvalidOwner
The owner is not a valid owner account. (eg. address(0))
error OwnableInvalidOwner(address owner);
Structs
OwnableStorage
Note: storage-location: erc7201:openzeppelin.storage.Ownable
struct OwnableStorage {
address _owner;
}
Contents
Contents
AccountERC7579HookedUpgradeable
Inherits: Initializable, AccountERC7579Upgradeable
Extension of {AccountERC7579} with support for a single hook module (type 4).
If installed, this extension will call the hook module's {IERC7579Hook-preCheck} before executing any operation
with {_execute} (including {execute} and {executeFromExecutor} by default) and {IERC7579Hook-postCheck} thereafter.
NOTE: Hook modules break the check-effect-interaction pattern. In particular, the {IERC7579Hook-preCheck} hook can
lead to potentially dangerous reentrancy. Using the withHook() modifier is safe if no effect is performed
before the preHook or after the postHook. That is the case on all functions here, but it may not be the case if
functions that have this modifier are overridden. Developers should be extremely careful when implementing hook
modules or further overriding functions that involve hooks.
State Variables
AccountERC7579HookedStorageLocation
bytes32 private constant AccountERC7579HookedStorageLocation =
0x2b49b75317ffc1021ca7da4ca3423bf8403e18b223e63e6bc7abe8f39a5ed700;
Functions
_getAccountERC7579HookedStorage
function _getAccountERC7579HookedStorage() private pure returns (AccountERC7579HookedStorage storage $);
withHook
Calls IERC7579Hook-preCheck before executing the modified function and {IERC7579Hook-postCheck} thereafter.
modifier withHook();
__AccountERC7579Hooked_init
function __AccountERC7579Hooked_init() internal onlyInitializing;
__AccountERC7579Hooked_init_unchained
function __AccountERC7579Hooked_init_unchained() internal onlyInitializing;
accountId
function accountId() public view virtual override returns (string memory);
hook
Returns the hook module address if installed, or address(0) otherwise.
function hook() public view virtual returns (address);
supportsModule
Supports hook modules. See AccountERC7579-supportsModule
function supportsModule(uint256 moduleTypeId) public view virtual override returns (bool);
isModuleInstalled
function isModuleInstalled(uint256 moduleTypeId, address module, bytes calldata data)
public
view
virtual
override
returns (bool);
_installModule
Installs a module with support for hook modules. See AccountERC7579-_installModule
function _installModule(uint256 moduleTypeId, address module, bytes memory initData)
internal
virtual
override
withHook;
_uninstallModule
Uninstalls a module with support for hook modules. See AccountERC7579-_uninstallModule
function _uninstallModule(uint256 moduleTypeId, address module, bytes memory deInitData)
internal
virtual
override
withHook;
_execute
Hooked version of AccountERC7579-_execute.
function _execute(Mode mode, bytes calldata executionCalldata)
internal
virtual
override
withHook
returns (bytes[] memory);
_fallback
Hooked version of AccountERC7579-_fallback.
function _fallback() internal virtual override withHook returns (bytes memory);
Errors
ERC7579HookModuleAlreadyPresent
A hook module is already present. This contract only supports one hook module.
error ERC7579HookModuleAlreadyPresent(address hook);
Structs
AccountERC7579HookedStorage
Note: storage-location: erc7201:openzeppelin.storage.AccountERC7579Hooked
struct AccountERC7579HookedStorage {
address _hook;
}
AccountERC7579Upgradeable
Inherits: Initializable, Account, IERC1271, IERC7579Execution, IERC7579AccountConfig, IERC7579ModuleConfig
*Extension of {Account} that implements support for ERC-7579 modules. To comply with the ERC-1271 support requirement, this contract defers signature validation to installed validator modules by calling {IERC7579Validator-isValidSignatureWithSender}. This contract does not implement validation logic for user operations since this functionality is often delegated to self-contained validation modules. Developers must install a validator module upon initialization (or any other mechanism to enable execution from the account):
contract MyAccountERC7579 is AccountERC7579, Initializable {
function initializeAccount(address validator, bytes calldata validatorData) public initializer {
_installModule(MODULE_TYPE_VALIDATOR, validator, validatorData);
}
}
[NOTE]
Hook support is not included. See {AccountERC7579Hooked} for a version that hooks to execution.
Validator selection, when verifying either ERC-1271 signature or ERC-4337 UserOperation is implemented in
internal virtual functions {_extractUserOpValidator} and {_extractSignatureValidator}. Both are implemented
following common practices. However, this part is not standardized in ERC-7579 (or in any follow-up ERC). Some
accounts may want to override these internal functions.
When combined with {ERC7739}, resolution ordering of {isValidSignature} may have an impact ({ERC7739} does not
call super). Manual resolution might be necessary.
Static calls (using callType 0xfe) are currently NOT supported.
WARNING: Removing all validator modules will render the account inoperable, as no user operations can be validated thereafter.*
State Variables
AccountERC7579StorageLocation
bytes32 private constant AccountERC7579StorageLocation =
0x0a47d913d72b2639f4ca1c145cc07ddf7170b73b257c8e0d4fced7cc8e3e3900;
Functions
_getAccountERC7579Storage
function _getAccountERC7579Storage() private pure returns (AccountERC7579Storage storage $);
onlyModule
Modifier that checks if the caller is an installed module of the given type.
modifier onlyModule(uint256 moduleTypeId, bytes calldata additionalContext);
__AccountERC7579_init
function __AccountERC7579_init() internal onlyInitializing;
__AccountERC7579_init_unchained
function __AccountERC7579_init_unchained() internal onlyInitializing;
fallback
See _fallback.
fallback(bytes calldata) external payable virtual returns (bytes memory);
accountId
Returns the account id of the smart account
function accountId() public view virtual returns (string memory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | string | accountImplementationId the account id of the smart account MUST return a non-empty string The accountId SHOULD be structured like so: "vendorname.accountname.semver" The id SHOULD be unique across all smart accounts |
supportsExecutionMode
Supported call types:
Single (0x00): A single transaction execution.
Batch (0x01): A batch of transactions execution.
Delegate (0xff): A delegate call execution.
Supported exec types:
Default (0x00): Default execution type (revert on failure).
Try (0x01): Try execution type (emits ERC7579TryExecuteFail on failure).
function supportsExecutionMode(bytes32 encodedMode) public view virtual returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
encodedMode | bytes32 | the encoded mode MUST return true if the account supports the mode and false otherwise |
supportsModule
Supported module types: Validator: A module used during the validation phase to determine if a transaction is valid and should be executed on the account. Executor: A module that can execute transactions on behalf of the smart account via a callback. Fallback Handler: A module that can extend the fallback functionality of a smart account.
function supportsModule(uint256 moduleTypeId) public view virtual returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
moduleTypeId | uint256 | the module type ID according to the ERC-7579 spec MUST return true if the account supports the module type and false otherwise |
installModule
Installs a Module of a certain type on the smart account
function installModule(uint256 moduleTypeId, address module, bytes calldata initData)
public
virtual
onlyEntryPointOrSelf;
Parameters
| Name | Type | Description |
|---|---|---|
moduleTypeId | uint256 | the module type ID according to the ERC-7579 spec |
module | address | the module address |
initData | bytes | arbitrary data that may be passed to the module during onInstall initialization. MUST implement authorization control MUST call onInstall on the module with the initData parameter if provided MUST emit ModuleInstalled event MUST revert if the module is already installed or the initialization on the module failed |
uninstallModule
Uninstalls a Module of a certain type on the smart account
function uninstallModule(uint256 moduleTypeId, address module, bytes calldata deInitData)
public
virtual
onlyEntryPointOrSelf;
Parameters
| Name | Type | Description |
|---|---|---|
moduleTypeId | uint256 | the module type ID according the ERC-7579 spec |
module | address | the module address |
deInitData | bytes | arbitrary data that may be passed to the module during onUninstall deinitialization. MUST implement authorization control MUST call onUninstall on the module with the deInitData parameter if provided MUST emit ModuleUninstalled event MUST revert if the module is not installed or the deInitialization on the module failed |
isModuleInstalled
Returns whether a module is installed on the smart account
function isModuleInstalled(uint256 moduleTypeId, address module, bytes calldata additionalContext)
public
view
virtual
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
moduleTypeId | uint256 | the module type ID according the ERC-7579 spec |
module | address | the module address |
additionalContext | bytes | arbitrary data that may be passed to determine if the module is installed MUST return true if the module is installed and false otherwise |
execute
Executes a transaction on behalf of the account.
function execute(bytes32 mode, bytes calldata executionCalldata) public payable virtual onlyEntryPointOrSelf;
Parameters
| Name | Type | Description |
|---|---|---|
mode | bytes32 | The encoded execution mode of the transaction. See ModeLib.sol for details |
executionCalldata | bytes | The encoded execution call data MUST ensure adequate authorization control: e.g. onlyEntryPointOrSelf if used with ERC-4337 If a mode is requested that is not supported by the Account, it MUST revert |
executeFromExecutor
Executes a transaction on behalf of the account. This function is intended to be called by Executor Modules
function executeFromExecutor(bytes32 mode, bytes calldata executionCalldata)
public
payable
virtual
onlyModule(MODULE_TYPE_EXECUTOR, Calldata.emptyBytes())
returns (bytes[] memory returnData);
Parameters
| Name | Type | Description |
|---|---|---|
mode | bytes32 | The encoded execution mode of the transaction. See ModeLib.sol for details |
executionCalldata | bytes | The encoded execution call data |
Returns
| Name | Type | Description |
|---|---|---|
returnData | bytes[] | An array with the returned data of each executed subcall MUST ensure adequate authorization control: i.e. onlyExecutorModule If a mode is requested that is not supported by the Account, it MUST revert |
isValidSignature
Implement ERC-1271 through IERC7579Validator modules. If module based validation fails, fallback to "native" validation by the abstract signer. NOTE: when combined with {ERC7739}, resolution ordering may have an impact ({ERC7739} does not call super). Manual resolution might be necessary.
function isValidSignature(bytes32 hash, bytes calldata signature) public view virtual returns (bytes4);
_validateUserOp
Validates a user operation with {_signableUserOpHash} and returns the validation data if the module specified by the first 20 bytes of the nonce key is installed. Falls back to {Account-_validateUserOp} otherwise. See {_extractUserOpValidator} for the module extraction logic.
function _validateUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash)
internal
virtual
override
returns (uint256);
_execute
ERC-7579 execution logic. See supportsExecutionMode for supported modes. Reverts if the call type is not supported.
function _execute(Mode mode, bytes calldata executionCalldata) internal virtual returns (bytes[] memory returnData);
_installModule
Installs a module of the given type with the given initialization data.
For the fallback module type, the initData is expected to be the (packed) concatenation of a 4-byte
selector and the rest of the data to be sent to the handler when calling IERC7579Module-onInstall.
Requirements:
Module type must be supported. See {supportsModule}. Reverts with {ERC7579Utils-ERC7579UnsupportedModuleType}.
Module must be of the given type. Reverts with {ERC7579Utils-ERC7579MismatchedModuleTypeId}.
Module must not be already installed. Reverts with {ERC7579Utils-ERC7579AlreadyInstalledModule}.
Emits a {IERC7579ModuleConfig-ModuleInstalled} event.
function _installModule(uint256 moduleTypeId, address module, bytes memory initData) internal virtual;
_uninstallModule
Uninstalls a module of the given type with the given de-initialization data.
For the fallback module type, the deInitData is expected to be the (packed) concatenation of a 4-byte
selector and the rest of the data to be sent to the handler when calling IERC7579Module-onUninstall.
Requirements:
Module must be already installed. Reverts with {ERC7579Utils-ERC7579UninstalledModule} otherwise.
function _uninstallModule(uint256 moduleTypeId, address module, bytes memory deInitData) internal virtual;
_fallback
Fallback function that delegates the call to the installed handler for the given selector.
Reverts with ERC7579MissingFallbackHandler if the handler is not installed.
Calls the handler with the original msg.sender appended at the end of the calldata following
the ERC-2771 format.
function _fallback() internal virtual returns (bytes memory);
_fallbackHandler
Returns the fallback handler for the given selector. Returns address(0) if not installed.
function _fallbackHandler(bytes4 selector) internal view virtual returns (address);
_checkModule
Checks if the module is installed. Reverts if the module is not installed.
function _checkModule(uint256 moduleTypeId, address module, bytes calldata additionalContext) internal view virtual;
_extractUserOpValidator
*Extracts the nonce validator from the user operation. To construct a nonce key, set nonce as follows:
<module address (20 bytes)> | <key (4 bytes)> | <nonce (8 bytes)>
NOTE: The default behavior of this function replicates the behavior of https://github.com/rhinestonewtf/safe7579/blob/bb29e8b1a66658790c4169e72608e27d220f79be/src/Safe7579.sol#L266[Safe adapter], https://github.com/etherspot/etherspot-prime-contracts/blob/cfcdb48c4172cea0d66038324c0bae3288aa8caa/src/modular-etherspot-wallet/wallet/ModularEtherspotWallet.sol#L227[Etherspot's Prime Account], and https://github.com/erc7579/erc7579-implementation/blob/16138d1afd4e9711f6c1425133538837bd7787b5/src/MSAAdvanced.sol#L247[ERC7579 reference implementation]. This is not standardized in ERC-7579 (or in any follow-up ERC). Some accounts may want to override these internal functions. For example, https://github.com/bcnmy/nexus/blob/54f4e19baaff96081a8843672977caf712ef19f4/contracts/lib/NonceLib.sol#L17[Biconomy's Nexus] uses a similar yet incompatible approach (the validator address is also part of the nonce, but not at the same location)*
function _extractUserOpValidator(PackedUserOperation calldata userOp) internal pure virtual returns (address);
_extractSignatureValidator
*Extracts the signature validator from the signature. To construct a signature, set the first 20 bytes as the module address and the remaining bytes as the signature data:
<module address (20 bytes)> | <signature data>
NOTE: The default behavior of this function replicates the behavior of https://github.com/rhinestonewtf/safe7579/blob/bb29e8b1a66658790c4169e72608e27d220f79be/src/Safe7579.sol#L350[Safe adapter], https://github.com/bcnmy/nexus/blob/54f4e19baaff96081a8843672977caf712ef19f4/contracts/Nexus.sol#L239[Biconomy's Nexus], https://github.com/etherspot/etherspot-prime-contracts/blob/cfcdb48c4172cea0d66038324c0bae3288aa8caa/src/modular-etherspot-wallet/wallet/ModularEtherspotWallet.sol#L252[Etherspot's Prime Account], and https://github.com/erc7579/erc7579-implementation/blob/16138d1afd4e9711f6c1425133538837bd7787b5/src/MSAAdvanced.sol#L296[ERC7579 reference implementation]. This is not standardized in ERC-7579 (or in any follow-up ERC). Some accounts may want to override these internal functions.*
function _extractSignatureValidator(bytes calldata signature)
internal
pure
virtual
returns (address module, bytes calldata innerSignature);
_decodeFallbackData
Extract the function selector from initData/deInitData for MODULE_TYPE_FALLBACK
NOTE: If we had calldata here, we could use calldata slice which are cheaper to manipulate and don't require
actual copy. However, this would require _installModule to get a calldata bytes object instead of a memory
bytes object. This would prevent calling _installModule from a contract constructor and would force the use
of external initializers. That may change in the future, as most accounts will probably be deployed as
clones/proxy/ERC-7702 delegates and therefore rely on initializers anyway.
function _decodeFallbackData(bytes memory data)
internal
pure
virtual
returns (bytes4 selector, bytes memory remaining);
_rawSignatureValidation
By default, only use the modules for validation of userOp and signature. Disable raw signatures.
function _rawSignatureValidation(bytes32, bytes calldata) internal view virtual override returns (bool);
Errors
ERC7579MissingFallbackHandler
The account's {fallback} was called with a selector that doesn't have an installed handler.
error ERC7579MissingFallbackHandler(bytes4 selector);
Structs
AccountERC7579Storage
Note: storage-location: erc7201:openzeppelin.storage.AccountERC7579
struct AccountERC7579Storage {
EnumerableSet.AddressSet _validators;
EnumerableSet.AddressSet _executors;
mapping(bytes4 selector => address) _fallbacks;
}
Contents
VestingWalletCliffUpgradeable
Inherits: Initializable, VestingWalletUpgradeable
Extension of {VestingWallet} that adds a cliff to the vesting schedule. Available since v5.1.
State Variables
VestingWalletCliffStorageLocation
bytes32 private constant VestingWalletCliffStorageLocation =
0x0a0ceb66c7c9aef32c0bfc43d3108868a39e95e96162520745e462557492f100;
Functions
_getVestingWalletCliffStorage
function _getVestingWalletCliffStorage() private pure returns (VestingWalletCliffStorage storage $);
__VestingWalletCliff_init
Set the duration of the cliff, in seconds. The cliff starts vesting schedule (see {VestingWallet}'s
constructor) and ends cliffSeconds later.
function __VestingWalletCliff_init(uint64 cliffSeconds) internal onlyInitializing;
__VestingWalletCliff_init_unchained
function __VestingWalletCliff_init_unchained(uint64 cliffSeconds) internal onlyInitializing;
cliff
Getter for the cliff timestamp.
function cliff() public view virtual returns (uint256);
_vestingSchedule
Virtual implementation of the vesting formula. This returns the amount vested, as a function of time, for
an asset given its total historical allocation. Returns 0 if the cliff timestamp is not met.
IMPORTANT: The cliff not only makes the schedule return 0, but it also ignores every possible side
effect from calling the inherited implementation (i.e. super._vestingSchedule). Carefully consider
this caveat if the overridden implementation of this function has any (e.g. writing to memory or reverting).
function _vestingSchedule(uint256 totalAllocation, uint64 timestamp) internal view virtual override returns (uint256);
Errors
InvalidCliffDuration
The specified cliff duration is larger than the vesting duration.
error InvalidCliffDuration(uint64 cliffSeconds, uint64 durationSeconds);
Structs
VestingWalletCliffStorage
Note: storage-location: erc7201:openzeppelin.storage.VestingWalletCliff
struct VestingWalletCliffStorage {
uint64 _cliff;
}
VestingWalletUpgradeable
Inherits: Initializable, ContextUpgradeable, OwnableUpgradeable
A vesting wallet is an ownable contract that can receive native currency and ERC-20 tokens, and release these assets to the wallet owner, also referred to as "beneficiary", according to a vesting schedule. Any assets transferred to this contract will follow the vesting schedule as if they were locked from the beginning. Consequently, if the vesting has already started, any amount of tokens sent to this contract will (at least partly) be immediately releasable. By setting the duration to 0, one can configure this contract to behave like an asset timelock that holds tokens for a beneficiary until a specified time. NOTE: Since the wallet is {Ownable}, and ownership can be transferred, it is possible to sell unvested tokens. Preventing this in a smart contract is difficult, considering that: 1) a beneficiary address could be a counterfactually deployed contract, 2) there is likely to be a migration path for EOAs to become contracts in the near future. NOTE: When using this contract with any token whose balance is adjusted automatically (i.e. a rebase token), make sure to account the supply/balance adjustment in the vesting schedule to ensure the vested amount is as intended. NOTE: Chains with support for native ERC20s may allow the vesting wallet to withdraw the underlying asset as both an ERC20 and as native currency. For example, if chain C supports token A and the wallet gets deposited 100 A, then at 50% of the vesting period, the beneficiary can withdraw 50 A as ERC20 and 25 A as native currency (totaling 75 A). Consider disabling one of the withdrawal methods.
State Variables
VestingWalletStorageLocation
bytes32 private constant VestingWalletStorageLocation =
0xa1eac494560f7591e4da38ed031587f09556afdfc4399dd2e205b935fdfa3900;
Functions
_getVestingWalletStorage
function _getVestingWalletStorage() private pure returns (VestingWalletStorage storage $);
initialize
function initialize(address beneficiary, uint64 startTimestamp, uint64 durationSeconds) public virtual initializer;
__VestingWallet_init
Sets the beneficiary (owner), the start timestamp and the vesting duration (in seconds) of the vesting wallet.
function __VestingWallet_init(address beneficiary, uint64 startTimestamp, uint64 durationSeconds)
internal
onlyInitializing;
__VestingWallet_init_unchained
function __VestingWallet_init_unchained(address, uint64 startTimestamp, uint64 durationSeconds)
internal
onlyInitializing;
receive
The contract should be able to receive Eth.
receive() external payable virtual;
start
Getter for the start timestamp.
function start() public view virtual returns (uint256);
duration
Getter for the vesting duration.
function duration() public view virtual returns (uint256);
end
Getter for the end timestamp.
function end() public view virtual returns (uint256);
released
Amount of eth already released
function released() public view virtual returns (uint256);
released
Amount of token already released
function released(address token) public view virtual returns (uint256);
releasable
Getter for the amount of releasable eth.
function releasable() public view virtual returns (uint256);
releasable
Getter for the amount of releasable token tokens. token should be the address of an
{IERC20} contract.
function releasable(address token) public view virtual returns (uint256);
release
Release the native token (ether) that have already vested. Emits a EtherReleased event.
function release() public virtual;
release
Release the tokens that have already vested. Emits a ERC20Released event.
function release(address token) public virtual;
vestedAmount
Calculates the amount of ether that has already vested. Default implementation is a linear vesting curve.
function vestedAmount(uint64 timestamp) public view virtual returns (uint256);
vestedAmount
Calculates the amount of tokens that has already vested. Default implementation is a linear vesting curve.
function vestedAmount(address token, uint64 timestamp) public view virtual returns (uint256);
_vestingSchedule
Virtual implementation of the vesting formula. This returns the amount vested, as a function of time, for an asset given its total historical allocation.
function _vestingSchedule(uint256 totalAllocation, uint64 timestamp) internal view virtual returns (uint256);
Events
EtherReleased
event EtherReleased(uint256 amount);
ERC20Released
event ERC20Released(address indexed token, uint256 amount);
Structs
VestingWalletStorage
Note: storage-location: erc7201:openzeppelin.storage.VestingWallet
struct VestingWalletStorage {
uint256 _released;
mapping(address token => uint256) _erc20Released;
uint64 _start;
uint64 _duration;
}
Contents
Contents
- GovernorCountingFractionalUpgradeable
- GovernorCountingOverridableUpgradeable
- GovernorCountingSimpleUpgradeable
- GovernorNoncesKeyedUpgradeable
- GovernorPreventLateQuorumUpgradeable
- GovernorProposalGuardianUpgradeable
- GovernorSequentialProposalIdUpgradeable
- GovernorSettingsUpgradeable
- GovernorStorageUpgradeable
- GovernorSuperQuorumUpgradeable
- GovernorTimelockAccessUpgradeable
- GovernorTimelockCompoundUpgradeable
- GovernorTimelockControlUpgradeable
- GovernorVotesQuorumFractionUpgradeable
- GovernorVotesSuperQuorumFractionUpgradeable
- GovernorVotesUpgradeable
GovernorCountingFractionalUpgradeable
Inherits: Initializable, GovernorUpgradeable
Extension of {Governor} for fractional voting.
Similar to {GovernorCountingSimple}, this contract is a votes counting module for {Governor} that supports 3 options:
Against, For, Abstain. Additionally, it includes a fourth option: Fractional, which allows voters to split their voting
power amongst the other 3 options.
Votes cast with the Fractional support must be accompanied by a params argument that is three packed uint128 values
representing the weight the delegate assigns to Against, For, and Abstain respectively. For those votes cast for the other
3 options, the params argument must be empty.
This is mostly useful when the delegate is a contract that implements its own rules for voting. These delegate-contracts
can cast fractional votes according to the preferences of multiple entities delegating their voting power.
Some example use cases include:
Voting from tokens that are held by a DeFi pool
Voting from an L2 with tokens held by a bridge
Voting privately from a shielded pool using zero knowledge proofs.
Based on ScopeLift's https://github.com/ScopeLift/flexible-voting/blob/e5de2efd1368387b840931f19f3c184c85842761/src/GovernorCountingFractional.sol[GovernorCountingFractional]
Available since v5.1.
State Variables
VOTE_TYPE_FRACTIONAL
uint8 internal constant VOTE_TYPE_FRACTIONAL = 255;
GovernorCountingFractionalStorageLocation
bytes32 private constant GovernorCountingFractionalStorageLocation =
0xd073797d8f9d07d835a3fc13195afeafd2f137da609f97a44f7a3aa434170800;
Functions
_getGovernorCountingFractionalStorage
function _getGovernorCountingFractionalStorage() private pure returns (GovernorCountingFractionalStorage storage $);
__GovernorCountingFractional_init
function __GovernorCountingFractional_init() internal onlyInitializing;
__GovernorCountingFractional_init_unchained
function __GovernorCountingFractional_init_unchained() internal onlyInitializing;
COUNTING_MODE
module:voting
*A description of the possible support values for {castVote} and the way these votes are counted, meant to
be consumed by UIs to show correct vote options and interpret the results. The string is a URL-encoded sequence of
key-value pairs that each describe one aspect, for example support=bravo&quorum=for,abstain.
There are 2 standard keys: support and quorum.
support=bravorefers to the vote options 0 = Against, 1 = For, 2 = Abstain, as inGovernorBravo.quorum=bravomeans that only For votes are counted towards quorum.quorum=for,abstainmeans that both For and Abstain votes are counted towards quorum. If a counting module makes use of encodedparams, it should include this under aparamskey with a unique name that describes the behavior. For example:params=fractionalmight refer to a scheme where votes are divided fractionally between for/against/abstain.params=erc721might refer to a scheme where specific NFTs are delegated to vote. NOTE: The string can be decoded by the standard https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams[URLSearchParams] JavaScript class.*
function COUNTING_MODE() public pure virtual override returns (string memory);
hasVoted
module:voting
Returns whether account has cast a vote on proposalId.
function hasVoted(uint256 proposalId, address account) public view virtual override returns (bool);
usedVotes
Get the number of votes already cast by account for a proposal with proposalId. Useful for
integrations that allow delegates to cast rolling, partial votes.
function usedVotes(uint256 proposalId, address account) public view virtual returns (uint256);
proposalVotes
Get current distribution of votes for a given proposal.
function proposalVotes(uint256 proposalId)
public
view
virtual
returns (uint256 againstVotes, uint256 forVotes, uint256 abstainVotes);
_quorumReached
Amount of votes already cast passes the threshold limit.
function _quorumReached(uint256 proposalId) internal view virtual override returns (bool);
_voteSucceeded
See Governor-_voteSucceeded. In this module, forVotes must be > againstVotes.
function _voteSucceeded(uint256 proposalId) internal view virtual override returns (bool);
_countVote
*See Governor-_countVote. Function that records the delegate's votes.
Executing this function consumes (part of) the delegate's weight on the proposal. This weight can be
distributed amongst the 3 options (Against, For, Abstain) by specifying a fractional support.
This counting module supports two vote casting modes: nominal and fractional.
- Nominal: A nominal vote is cast by setting
supportto one of the 3 bravo options (Against, For, Abstain). - Fractional: A fractional vote is cast by setting
supporttotype(uint8).max(255). Casting a nominal vote requiresparamsto be empty and consumes the delegate's full remaining weight on the proposal for the specifiedsupportoption. This is similar to the {GovernorCountingSimple} module and follows theVoteTypeenum from Governor Bravo. As a consequence, no vote weight remains unspent so no further voting is possible (for thisproposalIdand thisaccount). Casting a fractional vote consumes a fraction of the delegate's remaining weight on the proposal according to the weights the delegate assigns to each support option (Against, For, Abstain respectively). The sum total of the three decoded vote weights must be less than or equal to the delegate's remaining weight on the proposal (i.e. their checkpointed total weight minus votes already cast on the proposal). This format can be produced using:abi.encodePacked(uint128(againstVotes), uint128(forVotes), uint128(abstainVotes))NOTE: Consider that fractional voting restricts the number of casted votes (in each category) to 128 bits. Depending on how many decimals the underlying token has, a single voter may require to split their vote into multiple vote operations. For precision higher than ~30 decimals, large token holders may require a potentially large number of calls to cast all their votes. The voter has the possibility to cast all the remaining votes in a single operation using the traditional "bravo" vote.*
function _countVote(uint256 proposalId, address account, uint8 support, uint256 totalWeight, bytes memory params)
internal
virtual
override
returns (uint256);
Errors
GovernorExceedRemainingWeight
A fractional vote params uses more votes than are available for that user.
error GovernorExceedRemainingWeight(address voter, uint256 usedVotes, uint256 remainingWeight);
Structs
ProposalVote
struct ProposalVote {
uint256 againstVotes;
uint256 forVotes;
uint256 abstainVotes;
mapping(address voter => uint256) usedVotes;
}
GovernorCountingFractionalStorage
Note: storage-location: erc7201:openzeppelin.storage.GovernorCountingFractional
struct GovernorCountingFractionalStorage {
mapping(uint256 proposalId => ProposalVote) _proposalVotes;
}
GovernorCountingOverridableUpgradeable
Inherits: Initializable, GovernorVotesUpgradeable
Extension of {Governor} which enables delegators to override the vote of their delegates. This module requires a token that inherits {VotesExtended}.
State Variables
OVERRIDE_BALLOT_TYPEHASH
bytes32 public constant OVERRIDE_BALLOT_TYPEHASH =
keccak256("OverrideBallot(uint256 proposalId,uint8 support,address voter,uint256 nonce,string reason)");
GovernorCountingOverridableStorageLocation
bytes32 private constant GovernorCountingOverridableStorageLocation =
0xbffde6e7ca736efb3d8171f99b09abc076e81f804bf1703dc71fb0b1f7715100;
Functions
_getGovernorCountingOverridableStorage
function _getGovernorCountingOverridableStorage() private pure returns (GovernorCountingOverridableStorage storage $);
__GovernorCountingOverridable_init
function __GovernorCountingOverridable_init() internal onlyInitializing;
__GovernorCountingOverridable_init_unchained
function __GovernorCountingOverridable_init_unchained() internal onlyInitializing;
COUNTING_MODE
module:voting
*A description of the possible support values for {castVote} and the way these votes are counted, meant to
be consumed by UIs to show correct vote options and interpret the results. The string is a URL-encoded sequence of
key-value pairs that each describe one aspect, for example support=bravo&quorum=for,abstain.
There are 2 standard keys: support and quorum.
support=bravorefers to the vote options 0 = Against, 1 = For, 2 = Abstain, as inGovernorBravo.quorum=bravomeans that only For votes are counted towards quorum.quorum=for,abstainmeans that both For and Abstain votes are counted towards quorum. If a counting module makes use of encodedparams, it should include this under aparamskey with a unique name that describes the behavior. For example:params=fractionalmight refer to a scheme where votes are divided fractionally between for/against/abstain.params=erc721might refer to a scheme where specific NFTs are delegated to vote. NOTE: The string can be decoded by the standard https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams[URLSearchParams] JavaScript class.*
function COUNTING_MODE() public pure virtual override returns (string memory);
hasVoted
See IGovernor-hasVoted. NOTE: Calling {castVote} (or similar) casts a vote using the voting power that is delegated to the voter. Conversely, calling {castOverrideVote} (or similar) uses the voting power of the account itself, from its asset balances. Casting an "override vote" does not count as voting and won't be reflected by this getter. Consider using {hasVotedOverride} to check if an account has casted an "override vote" for a given proposal id.
function hasVoted(uint256 proposalId, address account) public view virtual override returns (bool);
hasVotedOverride
Check if an account has overridden their delegate for a proposal.
function hasVotedOverride(uint256 proposalId, address account) public view virtual returns (bool);
proposalVotes
Accessor to the internal vote counts.
function proposalVotes(uint256 proposalId)
public
view
virtual
returns (uint256 againstVotes, uint256 forVotes, uint256 abstainVotes);
_quorumReached
Amount of votes already cast passes the threshold limit.
function _quorumReached(uint256 proposalId) internal view virtual override returns (bool);
_voteSucceeded
See Governor-_voteSucceeded. In this module, the forVotes must be strictly over the againstVotes.
function _voteSucceeded(uint256 proposalId) internal view virtual override returns (bool);
_countVote
See Governor-_countVote. In this module, the support follows the VoteType enum (from Governor Bravo).
NOTE: called by {Governor-_castVote} which emits the {IGovernor-VoteCast} (or {IGovernor-VoteCastWithParams})
event.
function _countVote(uint256 proposalId, address account, uint8 support, uint256 totalWeight, bytes memory)
internal
virtual
override
returns (uint256);
_countOverride
Variant of Governor-_countVote that deals with vote overrides. NOTE: See {hasVoted} for more details about the difference between {castVote} and {castOverrideVote}.
function _countOverride(uint256 proposalId, address account, uint8 support) internal virtual returns (uint256);
_castOverride
Variant of Governor-_castVote that deals with vote overrides. Returns the overridden weight.
function _castOverride(uint256 proposalId, address account, uint8 support, string calldata reason)
internal
virtual
returns (uint256);
castOverrideVote
Public function for casting an override vote. Returns the overridden weight.
function castOverrideVote(uint256 proposalId, uint8 support, string calldata reason) public virtual returns (uint256);
castOverrideVoteBySig
Public function for casting an override vote using a voter's signature. Returns the overridden weight.
function castOverrideVoteBySig(
uint256 proposalId,
uint8 support,
address voter,
string calldata reason,
bytes calldata signature
) public virtual returns (uint256);
Events
VoteReduced
The votes casted by delegate were reduced by weight after an override vote was casted by the original token holder
event VoteReduced(address indexed delegate, uint256 proposalId, uint8 support, uint256 weight);
OverrideVoteCast
A delegated vote on proposalId was overridden by weight
event OverrideVoteCast(address indexed voter, uint256 proposalId, uint8 support, uint256 weight, string reason);
Errors
GovernorAlreadyOverriddenVote
error GovernorAlreadyOverriddenVote(address account);
Structs
VoteReceipt
struct VoteReceipt {
uint8 casted;
bool hasOverridden;
uint208 overriddenWeight;
}
ProposalVote
struct ProposalVote {
uint256[3] votes;
mapping(address voter => VoteReceipt) voteReceipt;
}
GovernorCountingOverridableStorage
Note: storage-location: erc7201:openzeppelin.storage.GovernorCountingOverridable
struct GovernorCountingOverridableStorage {
mapping(uint256 proposalId => ProposalVote) _proposalVotes;
}
Enums
VoteType
Supported vote types. Matches Governor Bravo ordering.
enum VoteType {
Against,
For,
Abstain
}
GovernorCountingSimpleUpgradeable
Inherits: Initializable, GovernorUpgradeable
Extension of {Governor} for simple, 3 options, vote counting.
State Variables
GovernorCountingSimpleStorageLocation
bytes32 private constant GovernorCountingSimpleStorageLocation =
0xa1cefa0f43667ef127a258e673c94202a79b656e62899531c4376d87a7f39800;
Functions
_getGovernorCountingSimpleStorage
function _getGovernorCountingSimpleStorage() private pure returns (GovernorCountingSimpleStorage storage $);
__GovernorCountingSimple_init
function __GovernorCountingSimple_init() internal onlyInitializing;
__GovernorCountingSimple_init_unchained
function __GovernorCountingSimple_init_unchained() internal onlyInitializing;
COUNTING_MODE
module:voting
*A description of the possible support values for {castVote} and the way these votes are counted, meant to
be consumed by UIs to show correct vote options and interpret the results. The string is a URL-encoded sequence of
key-value pairs that each describe one aspect, for example support=bravo&quorum=for,abstain.
There are 2 standard keys: support and quorum.
support=bravorefers to the vote options 0 = Against, 1 = For, 2 = Abstain, as inGovernorBravo.quorum=bravomeans that only For votes are counted towards quorum.quorum=for,abstainmeans that both For and Abstain votes are counted towards quorum. If a counting module makes use of encodedparams, it should include this under aparamskey with a unique name that describes the behavior. For example:params=fractionalmight refer to a scheme where votes are divided fractionally between for/against/abstain.params=erc721might refer to a scheme where specific NFTs are delegated to vote. NOTE: The string can be decoded by the standard https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams[URLSearchParams] JavaScript class.*
function COUNTING_MODE() public pure virtual override returns (string memory);
hasVoted
module:voting
Returns whether account has cast a vote on proposalId.
function hasVoted(uint256 proposalId, address account) public view virtual override returns (bool);
proposalVotes
Accessor to the internal vote counts.
function proposalVotes(uint256 proposalId)
public
view
virtual
returns (uint256 againstVotes, uint256 forVotes, uint256 abstainVotes);
_quorumReached
Amount of votes already cast passes the threshold limit.
function _quorumReached(uint256 proposalId) internal view virtual override returns (bool);
_voteSucceeded
See Governor-_voteSucceeded. In this module, the forVotes must be strictly over the againstVotes.
function _voteSucceeded(uint256 proposalId) internal view virtual override returns (bool);
_countVote
See Governor-_countVote. In this module, the support follows the VoteType enum (from Governor Bravo).
function _countVote(uint256 proposalId, address account, uint8 support, uint256 totalWeight, bytes memory)
internal
virtual
override
returns (uint256);
Structs
ProposalVote
struct ProposalVote {
uint256 againstVotes;
uint256 forVotes;
uint256 abstainVotes;
mapping(address voter => bool) hasVoted;
}
GovernorCountingSimpleStorage
Note: storage-location: erc7201:openzeppelin.storage.GovernorCountingSimple
struct GovernorCountingSimpleStorage {
mapping(uint256 proposalId => ProposalVote) _proposalVotes;
}
Enums
VoteType
Supported vote types. Matches Governor Bravo ordering.
enum VoteType {
Against,
For,
Abstain
}
GovernorNoncesKeyedUpgradeable
Inherits: Initializable, GovernorUpgradeable, NoncesKeyedUpgradeable
An extension of {Governor} that extends existing nonce management to use {NoncesKeyed}, where the key is the low-order 192 bits of the proposalId.
This is useful for voting by signature while maintaining separate sequences of nonces for each proposal.
NOTE: Traditional (un-keyed) nonces are still supported and can continue to be used as if this extension was not present.
Functions
__GovernorNoncesKeyed_init
function __GovernorNoncesKeyed_init() internal onlyInitializing;
__GovernorNoncesKeyed_init_unchained
function __GovernorNoncesKeyed_init_unchained() internal onlyInitializing;
_useCheckedNonce
function _useCheckedNonce(address owner, uint256 nonce)
internal
virtual
override(NoncesUpgradeable, NoncesKeyedUpgradeable);
_validateVoteSig
Check the signature against keyed nonce and falls back to the traditional nonce.
NOTE: This function won't call super._validateVoteSig if the keyed nonce is valid.
Side effects may be skipped depending on the linearization of the function.
function _validateVoteSig(uint256 proposalId, uint8 support, address voter, bytes memory signature)
internal
virtual
override
returns (bool);
_validateExtendedVoteSig
Check the signature against keyed nonce and falls back to the traditional nonce.
NOTE: This function won't call super._validateExtendedVoteSig if the keyed nonce is valid.
Side effects may be skipped depending on the linearization of the function.
function _validateExtendedVoteSig(
uint256 proposalId,
uint8 support,
address voter,
string memory reason,
bytes memory params,
bytes memory signature
) internal virtual override returns (bool);
GovernorPreventLateQuorumUpgradeable
Inherits: Initializable, GovernorUpgradeable
A module that ensures there is a minimum voting period after quorum is reached. This prevents a large voter from swaying a vote and triggering quorum at the last minute, by ensuring there is always time for other voters to react and try to oppose the decision. If a vote causes quorum to be reached, the proposal's voting period may be extended so that it does not end before at least a specified time has passed (the "vote extension" parameter). This parameter can be set through a governance proposal.
State Variables
GovernorPreventLateQuorumStorageLocation
bytes32 private constant GovernorPreventLateQuorumStorageLocation =
0x042f525fd47e44d02e065dd7bb464f47b4f926fbd05b5e087891ebd756adf100;
Functions
_getGovernorPreventLateQuorumStorage
function _getGovernorPreventLateQuorumStorage() private pure returns (GovernorPreventLateQuorumStorage storage $);
__GovernorPreventLateQuorum_init
Initializes the vote extension parameter: the time in either number of blocks or seconds (depending on the governor clock mode) that is required to pass since the moment a proposal reaches quorum until its voting period ends. If necessary the voting period will be extended beyond the one set during proposal creation.
function __GovernorPreventLateQuorum_init(uint48 initialVoteExtension) internal onlyInitializing;
__GovernorPreventLateQuorum_init_unchained
function __GovernorPreventLateQuorum_init_unchained(uint48 initialVoteExtension) internal onlyInitializing;
proposalDeadline
Returns the proposal deadline, which may have been extended beyond that set at proposal creation, if the proposal reached quorum late in the voting period. See Governor-proposalDeadline.
function proposalDeadline(uint256 proposalId) public view virtual override returns (uint256);
_tallyUpdated
Vote tally updated and detects if it caused quorum to be reached, potentially extending the voting period. May emit a ProposalExtended event.
function _tallyUpdated(uint256 proposalId) internal virtual override;
lateQuorumVoteExtension
Returns the current value of the vote extension parameter: the number of blocks that are required to pass from the time a proposal reaches quorum until its voting period ends.
function lateQuorumVoteExtension() public view virtual returns (uint48);
setLateQuorumVoteExtension
Changes the lateQuorumVoteExtension. This operation can only be performed by the governance executor, generally through a governance proposal. Emits a {LateQuorumVoteExtensionSet} event.
function setLateQuorumVoteExtension(uint48 newVoteExtension) public virtual onlyGovernance;
_setLateQuorumVoteExtension
Changes the lateQuorumVoteExtension. This is an internal function that can be exposed in a public function like {setLateQuorumVoteExtension} if another access control mechanism is needed. Emits a {LateQuorumVoteExtensionSet} event.
function _setLateQuorumVoteExtension(uint48 newVoteExtension) internal virtual;
Events
ProposalExtended
Emitted when a proposal deadline is pushed back due to reaching quorum late in its voting period.
event ProposalExtended(uint256 indexed proposalId, uint64 extendedDeadline);
LateQuorumVoteExtensionSet
Emitted when the lateQuorumVoteExtension parameter is changed.
event LateQuorumVoteExtensionSet(uint64 oldVoteExtension, uint64 newVoteExtension);
Structs
GovernorPreventLateQuorumStorage
Note: storage-location: erc7201:openzeppelin.storage.GovernorPreventLateQuorum
struct GovernorPreventLateQuorumStorage {
uint48 _voteExtension;
mapping(uint256 proposalId => uint48) _extendedDeadlines;
}
GovernorProposalGuardianUpgradeable
Inherits: Initializable, GovernorUpgradeable
Extension of {Governor} which adds a proposal guardian that can cancel proposals at any stage in the proposal's lifecycle. NOTE: if the proposal guardian is not configured, then proposers take this role for their proposals.
State Variables
GovernorProposalGuardianStorageLocation
bytes32 private constant GovernorProposalGuardianStorageLocation =
0x2953e0c334ced07e397f02d0e9b450dbfd92be015e93a9c249855132826e0300;
Functions
_getGovernorProposalGuardianStorage
function _getGovernorProposalGuardianStorage() private pure returns (GovernorProposalGuardianStorage storage $);
__GovernorProposalGuardian_init
function __GovernorProposalGuardian_init() internal onlyInitializing;
__GovernorProposalGuardian_init_unchained
function __GovernorProposalGuardian_init_unchained() internal onlyInitializing;
proposalGuardian
Getter that returns the address of the proposal guardian.
function proposalGuardian() public view virtual returns (address);
setProposalGuardian
Update the proposal guardian's address. This operation can only be performed through a governance proposal. Emits a ProposalGuardianSet event.
function setProposalGuardian(address newProposalGuardian) public virtual onlyGovernance;
_setProposalGuardian
Internal setter for the proposal guardian. Emits a ProposalGuardianSet event.
function _setProposalGuardian(address newProposalGuardian) internal virtual;
_validateCancel
Override Governor-_validateCancel to implement the extended cancellation logic. The {proposalGuardian} can cancel any proposal at any point. If no proposal guardian is set, the {IGovernor-proposalProposer} can cancel their proposals at any point. In any case, permissions defined in {Governor-_validateCancel} (or another override) remains valid.
function _validateCancel(uint256 proposalId, address caller) internal view virtual override returns (bool);
Events
ProposalGuardianSet
event ProposalGuardianSet(address oldProposalGuardian, address newProposalGuardian);
Structs
GovernorProposalGuardianStorage
Note: storage-location: erc7201:openzeppelin.storage.GovernorProposalGuardian
struct GovernorProposalGuardianStorage {
address _proposalGuardian;
}
GovernorSequentialProposalIdUpgradeable
Inherits: Initializable, GovernorUpgradeable
Extension of {Governor} that changes the numbering of proposal ids from the default hash-based approach to sequential ids.
State Variables
GovernorSequentialProposalIdStorageLocation
bytes32 private constant GovernorSequentialProposalIdStorageLocation =
0x4b8c47b641115bbb755a0530712d89d8042b41728d36570a6119c90ae1b76800;
Functions
_getGovernorSequentialProposalIdStorage
function _getGovernorSequentialProposalIdStorage()
private
pure
returns (GovernorSequentialProposalIdStorage storage $);
__GovernorSequentialProposalId_init
function __GovernorSequentialProposalId_init() internal onlyInitializing;
__GovernorSequentialProposalId_init_unchained
function __GovernorSequentialProposalId_init_unchained() internal onlyInitializing;
getProposalId
module:core
Function used to get the proposal id from the proposal details.
function getProposalId(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) public view virtual override returns (uint256);
latestProposalId
Returns the latest proposal id. A return value of 0 means no proposals have been created yet.
function latestProposalId() public view virtual returns (uint256);
_propose
See IGovernor-_propose. Hook into the proposing mechanism to increment proposal count.
function _propose(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
string memory description,
address proposer
) internal virtual override returns (uint256);
_initializeLatestProposalId
Internal function to set the latestProposalId. This function is helpful when transitioning
from another governance system. The next proposal id will be newLatestProposalId + 1.
May only call this function if the current value of {latestProposalId} is 0.
function _initializeLatestProposalId(uint256 newLatestProposalId) internal virtual;
Errors
GovernorAlreadyInitializedLatestProposalId
The latestProposalId may only be initialized if it hasn't been set yet (through initialization or the creation of a proposal).
error GovernorAlreadyInitializedLatestProposalId();
Structs
GovernorSequentialProposalIdStorage
Note: storage-location: erc7201:openzeppelin.storage.GovernorSequentialProposalId
struct GovernorSequentialProposalIdStorage {
uint256 _latestProposalId;
mapping(uint256 proposalHash => uint256 proposalId) _proposalIds;
}
GovernorSettingsUpgradeable
Inherits: Initializable, GovernorUpgradeable
Extension of {Governor} for settings updatable through governance.
State Variables
GovernorSettingsStorageLocation
bytes32 private constant GovernorSettingsStorageLocation =
0x00d7616c8fe29c6c2fbe1d0c5bc8f2faa4c35b43746e70b24b4d532752affd00;
Functions
_getGovernorSettingsStorage
function _getGovernorSettingsStorage() private pure returns (GovernorSettingsStorage storage $);
__GovernorSettings_init
Initialize the governance parameters.
function __GovernorSettings_init(
uint48 initialVotingDelay,
uint32 initialVotingPeriod,
uint256 initialProposalThreshold
) internal onlyInitializing;
__GovernorSettings_init_unchained
function __GovernorSettings_init_unchained(
uint48 initialVotingDelay,
uint32 initialVotingPeriod,
uint256 initialProposalThreshold
) internal onlyInitializing;
votingDelay
module:user-config
Delay, between the proposal is created and the vote starts. The unit this duration is expressed in depends on the clock (see ERC-6372) this contract uses. This can be increased to leave time for users to buy voting power, or delegate it, before the voting of a proposal starts. NOTE: While this interface returns a uint256, timepoints are stored as uint48 following the ERC-6372 clock type. Consequently this value must fit in a uint48 (when added to the current clock). See {IERC6372-clock}.
function votingDelay() public view virtual override returns (uint256);
votingPeriod
module:user-config
Delay between the vote start and vote end. The unit this duration is expressed in depends on the clock (see ERC-6372) this contract uses. NOTE: The {votingDelay} can delay the start of the vote. This must be considered when setting the voting duration compared to the voting delay. NOTE: This value is stored when the proposal is submitted so that possible changes to the value do not affect proposals that have already been submitted. The type used to save it is a uint32. Consequently, while this interface returns a uint256, the value it returns should fit in a uint32.
function votingPeriod() public view virtual override returns (uint256);
proposalThreshold
function proposalThreshold() public view virtual override returns (uint256);
setVotingDelay
Update the voting delay. This operation can only be performed through a governance proposal. Emits a VotingDelaySet event.
function setVotingDelay(uint48 newVotingDelay) public virtual onlyGovernance;
setVotingPeriod
Update the voting period. This operation can only be performed through a governance proposal. Emits a VotingPeriodSet event.
function setVotingPeriod(uint32 newVotingPeriod) public virtual onlyGovernance;
setProposalThreshold
Update the proposal threshold. This operation can only be performed through a governance proposal. Emits a ProposalThresholdSet event.
function setProposalThreshold(uint256 newProposalThreshold) public virtual onlyGovernance;
_setVotingDelay
Internal setter for the voting delay. Emits a VotingDelaySet event.
function _setVotingDelay(uint48 newVotingDelay) internal virtual;
_setVotingPeriod
Internal setter for the voting period. Emits a VotingPeriodSet event.
function _setVotingPeriod(uint32 newVotingPeriod) internal virtual;
_setProposalThreshold
Internal setter for the proposal threshold. Emits a ProposalThresholdSet event.
function _setProposalThreshold(uint256 newProposalThreshold) internal virtual;
Events
VotingDelaySet
event VotingDelaySet(uint256 oldVotingDelay, uint256 newVotingDelay);
VotingPeriodSet
event VotingPeriodSet(uint256 oldVotingPeriod, uint256 newVotingPeriod);
ProposalThresholdSet
event ProposalThresholdSet(uint256 oldProposalThreshold, uint256 newProposalThreshold);
Structs
GovernorSettingsStorage
Note: storage-location: erc7201:openzeppelin.storage.GovernorSettings
struct GovernorSettingsStorage {
uint256 _proposalThreshold;
uint48 _votingDelay;
uint32 _votingPeriod;
}
GovernorStorageUpgradeable
Inherits: Initializable, GovernorUpgradeable
*Extension of {Governor} that implements storage of proposal details. This modules also provides primitives for the enumerability of proposals. Use cases for this module include:
- UIs that explore the proposal state without relying on event indexing.
- Using only the proposalId as an argument in the {Governor-queue} and {Governor-execute} functions for L2 chains where storage is cheap compared to calldata.*
State Variables
GovernorStorageStorageLocation
bytes32 private constant GovernorStorageStorageLocation =
0x7fd223d3380145bd26132714391e777c488a0df7ac2dd4b66419d8549fb3a600;
Functions
_getGovernorStorageStorage
function _getGovernorStorageStorage() private pure returns (GovernorStorageStorage storage $);
__GovernorStorage_init
function __GovernorStorage_init() internal onlyInitializing;
__GovernorStorage_init_unchained
function __GovernorStorage_init_unchained() internal onlyInitializing;
_propose
Hook into the proposing mechanism
function _propose(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
string memory description,
address proposer
) internal virtual override returns (uint256);
queue
Version of IGovernor-queue with only proposalId as an argument.
function queue(uint256 proposalId) public virtual;
execute
Version of IGovernor-execute with only proposalId as an argument.
function execute(uint256 proposalId) public payable virtual;
cancel
ProposalId version of IGovernor-cancel.
function cancel(uint256 proposalId) public virtual;
proposalCount
Returns the number of stored proposals.
function proposalCount() public view virtual returns (uint256);
proposalDetails
Returns the details of a proposalId. Reverts if proposalId is not a known proposal.
function proposalDetails(uint256 proposalId)
public
view
virtual
returns (address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash);
proposalDetailsAt
Returns the details (including the proposalId) of a proposal given its sequential index.
function proposalDetailsAt(uint256 index)
public
view
virtual
returns (
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
);
Structs
ProposalDetails
struct ProposalDetails {
address[] targets;
uint256[] values;
bytes[] calldatas;
bytes32 descriptionHash;
}
GovernorStorageStorage
Note: storage-location: erc7201:openzeppelin.storage.GovernorStorage
struct GovernorStorageStorage {
uint256[] _proposalIds;
mapping(uint256 proposalId => ProposalDetails) _proposalDetails;
}
GovernorSuperQuorumUpgradeable
Inherits: Initializable, GovernorUpgradeable
Extension of {Governor} with a super quorum. Proposals that meet the super quorum (and have a majority of for
votes) advance to the Succeeded state before the proposal deadline. Counting modules that want to use this
extension must implement {proposalVotes}.
Functions
__GovernorSuperQuorum_init
function __GovernorSuperQuorum_init() internal onlyInitializing;
__GovernorSuperQuorum_init_unchained
function __GovernorSuperQuorum_init_unchained() internal onlyInitializing;
superQuorum
Minimum number of cast votes required for a proposal to reach super quorum. Only FOR votes are counted
towards the super quorum. Once the super quorum is reached, an active proposal can proceed to the next state
without waiting for the proposal deadline.
NOTE: The timepoint parameter corresponds to the snapshot used for counting the vote. This enables scaling of the
quorum depending on values such as the totalSupply of a token at this timepoint (see {ERC20Votes}).
NOTE: Make sure the value specified for the super quorum is greater than {quorum}, otherwise, it may be
possible to pass a proposal with less votes than the default quorum.
function superQuorum(uint256 timepoint) public view virtual returns (uint256);
proposalVotes
Accessor to the internal vote counts. This must be implemented by the counting module. Counting modules that don't implement this function are incompatible with this module
function proposalVotes(uint256 proposalId)
public
view
virtual
returns (uint256 againstVotes, uint256 forVotes, uint256 abstainVotes);
state
Overridden version of the Governor-state function that checks if the proposal has reached the super quorum. NOTE: If the proposal reaches super quorum but {_voteSucceeded} returns false, eg, assuming the super quorum has been set low enough that both FOR and AGAINST votes have exceeded it and AGAINST votes exceed FOR votes, the proposal continues to be active until {_voteSucceeded} returns true or the proposal deadline is reached. This means that with a low super quorum it is also possible that a vote can succeed prematurely before enough AGAINST voters have a chance to vote. Hence, it is recommended to set a high enough super quorum to avoid these types of scenarios.
function state(uint256 proposalId) public view virtual override returns (ProposalState);
GovernorTimelockAccessUpgradeable
Inherits: Initializable, GovernorUpgradeable
This module connects a {Governor} instance to an {AccessManager} instance, allowing the governor to make calls
that are delay-restricted by the manager using the normal {queue} workflow. An optional base delay is applied to
operations that are not delayed externally by the manager. Execution of a proposal will be delayed as much as
necessary to meet the required delays of all of its operations.
This extension allows the governor to hold and use its own assets and permissions, unlike {GovernorTimelockControl}
and {GovernorTimelockCompound}, where the timelock is a separate contract that must be the one to hold assets and
permissions. Operations that are delay-restricted by the manager, however, will be executed through the
{AccessManager-execute} function.
==== Security Considerations
Some operations may be cancelable in the AccessManager by the admin or a set of guardians, depending on the
restricted function being invoked. Since proposals are atomic, the cancellation by a guardian of a single operation
in a proposal will cause all of the proposal to become unable to execute. Consider proposing cancellable operations
separately.
By default, function calls will be routed through the associated AccessManager whenever it claims the target
function to be restricted by it. However, admins may configure the manager to make that claim for functions that a
governor would want to call directly (e.g., token transfers) in an attempt to deny it access to those functions. To
mitigate this attack vector, the governor is able to ignore the restrictions claimed by the AccessManager using
{setAccessManagerIgnored}. While permanent denial of service is mitigated, temporary DoS may still be technically
possible. All of the governor's own functions (e.g., {setBaseDelaySeconds}) ignore the AccessManager by default.
NOTE: AccessManager does not support scheduling more than one operation with the same target and calldata at
the same time. See {AccessManager-schedule} for a workaround.
State Variables
GovernorTimelockAccessStorageLocation
bytes32 private constant GovernorTimelockAccessStorageLocation =
0xb26e23d38df572f5669f6310d407229c15b4fb320cb19bf5e8c38856d28d0800;
Functions
_getGovernorTimelockAccessStorage
function _getGovernorTimelockAccessStorage() private pure returns (GovernorTimelockAccessStorage storage $);
__GovernorTimelockAccess_init
Initialize the governor with an {AccessManager} and initial base delay.
function __GovernorTimelockAccess_init(address manager, uint32 initialBaseDelay) internal onlyInitializing;
__GovernorTimelockAccess_init_unchained
function __GovernorTimelockAccess_init_unchained(address manager, uint32 initialBaseDelay) internal onlyInitializing;
accessManager
Returns the {AccessManager} instance associated to this governor.
function accessManager() public view virtual returns (IAccessManager);
baseDelaySeconds
Base delay that will be applied to all function calls. Some may be further delayed by their associated
AccessManager authority; in this case the final delay will be the maximum of the base delay and the one
demanded by the authority.
NOTE: Execution delays are processed by the AccessManager contracts, and according to that contract are
expressed in seconds. Therefore, the base delay is also in seconds, regardless of the governor's clock mode.
function baseDelaySeconds() public view virtual returns (uint32);
setBaseDelaySeconds
Change the value of baseDelaySeconds. This operation can only be invoked through a governance proposal.
function setBaseDelaySeconds(uint32 newBaseDelay) public virtual onlyGovernance;
_setBaseDelaySeconds
Change the value of baseDelaySeconds. Internal function without access control.
function _setBaseDelaySeconds(uint32 newBaseDelay) internal virtual;
isAccessManagerIgnored
Check if restrictions from the associated {AccessManager} are ignored for a target function. Returns true
when the target function will be invoked directly regardless of AccessManager settings for the function.
See {setAccessManagerIgnored} and Security Considerations above.
function isAccessManagerIgnored(address target, bytes4 selector) public view virtual returns (bool);
setAccessManagerIgnored
Configure whether restrictions from the associated {AccessManager} are ignored for a target function. See Security Considerations above.
function setAccessManagerIgnored(address target, bytes4[] calldata selectors, bool ignored)
public
virtual
onlyGovernance;
_setAccessManagerIgnored
Internal version of setAccessManagerIgnored without access restriction.
function _setAccessManagerIgnored(address target, bytes4 selector, bool ignored) internal virtual;
proposalExecutionPlan
Public accessor to check the execution plan, including the number of seconds that the proposal will be
delayed since queuing, an array indicating which of the proposal actions will be executed indirectly through
the associated {AccessManager}, and another indicating which will be scheduled in {queue}. Note that
those that must be scheduled are cancellable by AccessManager guardians.
function proposalExecutionPlan(uint256 proposalId)
public
view
returns (uint32 delay, bool[] memory indirect, bool[] memory withDelay);
proposalNeedsQueuing
module:core
Whether a proposal needs to be queued before execution.
function proposalNeedsQueuing(uint256 proposalId) public view virtual override returns (bool);
propose
Create a new proposal. Vote start after a delay specified by {IGovernor-votingDelay} and lasts for a
duration specified by {IGovernor-votingPeriod}.
Emits a {ProposalCreated} event.
NOTE: The state of the Governor and targets may change between the proposal creation and its execution.
This may be the result of third party actions on the targeted contracts, or other governor proposals.
For example, the balance of this contract could be updated or its access control permissions may be modified,
possibly compromising the proposal's ability to execute successfully (e.g. the governor doesn't have enough
value to cover a proposal with multiple transfers).
function propose(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, string memory description)
public
virtual
override
returns (uint256);
_queueOperations
Mechanism to queue a proposal, potentially scheduling some of its operations in the AccessManager. NOTE: The execution delay is chosen based on the delay information retrieved in propose. This value may be off if the delay was updated since proposal creation. In this case, the proposal needs to be recreated.
function _queueOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory,
bytes[] memory calldatas,
bytes32
) internal virtual override returns (uint48);
_executeOperations
Mechanism to execute a proposal, potentially going through AccessManager-execute for delayed operations.
function _executeOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32
) internal virtual override;
_cancel
Internal cancel mechanism with minimal restrictions. A proposal can be cancelled in any state other than Canceled, Expired, or Executed. Once cancelled a proposal can't be re-submitted. Emits a {IGovernor-ProposalCanceled} event.
function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
internal
virtual
override
returns (uint256);
_getManagerData
Returns whether the operation at an index is delayed by the manager, and its scheduling nonce once queued.
function _getManagerData(ExecutionPlan storage plan, uint256 index)
private
view
returns (bool controlled, bool withDelay, uint32 nonce);
_setManagerData
Marks an operation at an index as permissioned by the manager, potentially delayed, and when delayed sets its scheduling nonce.
function _setManagerData(ExecutionPlan storage plan, uint256 index, bool withDelay, uint32 nonce) private;
_getManagerDataIndices
Returns bucket and subindex for reading manager data from the packed array mapping.
function _getManagerDataIndices(uint256 index) private pure returns (uint256 bucket, uint256 subindex);
Events
BaseDelaySet
event BaseDelaySet(uint32 oldBaseDelaySeconds, uint32 newBaseDelaySeconds);
AccessManagerIgnoredSet
event AccessManagerIgnoredSet(address target, bytes4 selector, bool ignored);
Errors
GovernorUnmetDelay
error GovernorUnmetDelay(uint256 proposalId, uint256 neededTimestamp);
GovernorMismatchedNonce
error GovernorMismatchedNonce(uint256 proposalId, uint256 expectedNonce, uint256 actualNonce);
GovernorLockedIgnore
error GovernorLockedIgnore();
Structs
ExecutionPlan
struct ExecutionPlan {
uint16 length;
uint32 delay;
mapping(uint256 operationBucket => uint32[8]) managerData;
}
GovernorTimelockAccessStorage
Note: storage-location: erc7201:openzeppelin.storage.GovernorTimelockAccess
struct GovernorTimelockAccessStorage {
mapping(address target => mapping(bytes4 selector => bool)) _ignoreToggle;
mapping(uint256 proposalId => ExecutionPlan) _executionPlan;
uint32 _baseDelay;
IAccessManager _manager;
}
GovernorTimelockCompoundUpgradeable
Inherits: Initializable, GovernorUpgradeable
Extension of {Governor} that binds the execution process to a Compound Timelock. This adds a delay, enforced by the external timelock to all successful proposals (in addition to the voting duration). The {Governor} needs to be the admin of the timelock for any operation to be performed. A public, unrestricted, {GovernorTimelockCompound-__acceptAdmin} is available to accept ownership of the timelock. Using this model means the proposal will be operated by the {TimelockController} and not by the {Governor}. Thus, the assets and permissions must be attached to the {TimelockController}. Any asset sent to the {Governor} will be inaccessible from a proposal, unless executed via {Governor-relay}.
State Variables
GovernorTimelockCompoundStorageLocation
bytes32 private constant GovernorTimelockCompoundStorageLocation =
0x7d1501d734d0ca30b8d26751a7fae89646767b24afe11265192d56e5fe515b00;
Functions
_getGovernorTimelockCompoundStorage
function _getGovernorTimelockCompoundStorage() private pure returns (GovernorTimelockCompoundStorage storage $);
__GovernorTimelockCompound_init
Set the timelock.
function __GovernorTimelockCompound_init(ICompoundTimelock timelockAddress) internal onlyInitializing;
__GovernorTimelockCompound_init_unchained
function __GovernorTimelockCompound_init_unchained(ICompoundTimelock timelockAddress) internal onlyInitializing;
state
Overridden version of the Governor-state function with added support for the Expired state.
function state(uint256 proposalId) public view virtual override returns (ProposalState);
timelock
Public accessor to check the address of the timelock
function timelock() public view virtual returns (address);
proposalNeedsQueuing
module:core
Whether a proposal needs to be queued before execution.
function proposalNeedsQueuing(uint256) public view virtual override returns (bool);
_queueOperations
Function to queue a proposal to the timelock.
function _queueOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32
) internal virtual override returns (uint48);
_executeOperations
Overridden version of the Governor-_executeOperations function that run the already queued proposal through the timelock.
function _executeOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32
) internal virtual override;
_cancel
Overridden version of the Governor-_cancel function to cancel the timelocked proposal if it has already been queued.
function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
internal
virtual
override
returns (uint256);
_executor
Address through which the governor executes action. In this case, the timelock.
function _executor() internal view virtual override returns (address);
__acceptAdmin
Accept admin right over the timelock.
function __acceptAdmin() public;
updateTimelock
Public endpoint to update the underlying timelock instance. Restricted to the timelock itself, so updates must be proposed, scheduled, and executed through governance proposals. For security reasons, the timelock must be handed over to another admin before setting up a new one. The two operations (hand over the timelock) and do the update can be batched in a single proposal. Note that if the timelock admin has been handed over in a previous operation, we refuse updates made through the timelock if admin of the timelock has already been accepted and the operation is executed outside the scope of governance. CAUTION: It is not recommended to change the timelock while there are other queued governance proposals.
function updateTimelock(ICompoundTimelock newTimelock) external virtual onlyGovernance;
_updateTimelock
function _updateTimelock(ICompoundTimelock newTimelock) private;
Events
TimelockChange
Emitted when the timelock controller used for proposal execution is modified.
event TimelockChange(address oldTimelock, address newTimelock);
Structs
GovernorTimelockCompoundStorage
Note: storage-location: erc7201:openzeppelin.storage.GovernorTimelockCompound
struct GovernorTimelockCompoundStorage {
ICompoundTimelock _timelock;
}
GovernorTimelockControlUpgradeable
Inherits: Initializable, GovernorUpgradeable
Extension of {Governor} that binds the execution process to an instance of {TimelockController}. This adds a delay, enforced by the {TimelockController} to all successful proposal (in addition to the voting duration). The {Governor} needs the proposer (and ideally the executor and canceller) roles for the {Governor} to work properly. Using this model means the proposal will be operated by the {TimelockController} and not by the {Governor}. Thus, the assets and permissions must be attached to the {TimelockController}. Any asset sent to the {Governor} will be inaccessible from a proposal, unless executed via {Governor-relay}. WARNING: Setting up the TimelockController to have additional proposers or cancelers besides the governor is very risky, as it grants them the ability to: 1) execute operations as the timelock, and thus possibly performing operations or accessing funds that are expected to only be accessible through a vote, and 2) block governance proposals that have been approved by the voters, effectively executing a Denial of Service attack.
State Variables
GovernorTimelockControlStorageLocation
bytes32 private constant GovernorTimelockControlStorageLocation =
0x0d5829787b8befdbc6044ef7457d8a95c2a04bc99235349f1a212c063e59d400;
Functions
_getGovernorTimelockControlStorage
function _getGovernorTimelockControlStorage() private pure returns (GovernorTimelockControlStorage storage $);
__GovernorTimelockControl_init
Set the timelock.
function __GovernorTimelockControl_init(TimelockControllerUpgradeable timelockAddress) internal onlyInitializing;
__GovernorTimelockControl_init_unchained
function __GovernorTimelockControl_init_unchained(TimelockControllerUpgradeable timelockAddress)
internal
onlyInitializing;
state
Overridden version of the Governor-state function that considers the status reported by the timelock.
function state(uint256 proposalId) public view virtual override returns (ProposalState);
timelock
Public accessor to check the address of the timelock
function timelock() public view virtual returns (address);
proposalNeedsQueuing
module:core
Whether a proposal needs to be queued before execution.
function proposalNeedsQueuing(uint256) public view virtual override returns (bool);
_queueOperations
Function to queue a proposal to the timelock.
function _queueOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal virtual override returns (uint48);
_executeOperations
Overridden version of the Governor-_executeOperations function that runs the already queued proposal through the timelock.
function _executeOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal virtual override;
_cancel
Overridden version of the Governor-_cancel function to cancel the timelocked proposal if it has already been queued.
function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
internal
virtual
override
returns (uint256);
_executor
Address through which the governor executes action. In this case, the timelock.
function _executor() internal view virtual override returns (address);
updateTimelock
Public endpoint to update the underlying timelock instance. Restricted to the timelock itself, so updates must be proposed, scheduled, and executed through governance proposals. CAUTION: It is not recommended to change the timelock while there are other queued governance proposals.
function updateTimelock(TimelockControllerUpgradeable newTimelock) external virtual onlyGovernance;
_updateTimelock
function _updateTimelock(TimelockControllerUpgradeable newTimelock) private;
_timelockSalt
Computes the {TimelockController} operation salt. It is computed with the governor address itself to avoid collisions across governor instances using the same timelock.
function _timelockSalt(bytes32 descriptionHash) private view returns (bytes32);
Events
TimelockChange
Emitted when the timelock controller used for proposal execution is modified.
event TimelockChange(address oldTimelock, address newTimelock);
Structs
GovernorTimelockControlStorage
Note: storage-location: erc7201:openzeppelin.storage.GovernorTimelockControl
struct GovernorTimelockControlStorage {
TimelockControllerUpgradeable _timelock;
mapping(uint256 proposalId => bytes32) _timelockIds;
}
GovernorVotesQuorumFractionUpgradeable
Inherits: Initializable, GovernorVotesUpgradeable
Extension of {Governor} for voting weight extraction from an {ERC20Votes} token and a quorum expressed as a fraction of the total supply.
State Variables
GovernorVotesQuorumFractionStorageLocation
bytes32 private constant GovernorVotesQuorumFractionStorageLocation =
0xe770710421fd2cad75ad828c61aa98f2d77d423a440b67872d0f65554148e000;
Functions
_getGovernorVotesQuorumFractionStorage
function _getGovernorVotesQuorumFractionStorage() private pure returns (GovernorVotesQuorumFractionStorage storage $);
__GovernorVotesQuorumFraction_init
Initialize quorum as a fraction of the token's total supply.
The fraction is specified as numerator / denominator. By default the denominator is 100, so quorum is
specified as a percent: a numerator of 10 corresponds to quorum being 10% of total supply. The denominator can be
customized by overriding quorumDenominator.
function __GovernorVotesQuorumFraction_init(uint256 quorumNumeratorValue) internal onlyInitializing;
__GovernorVotesQuorumFraction_init_unchained
function __GovernorVotesQuorumFraction_init_unchained(uint256 quorumNumeratorValue) internal onlyInitializing;
quorumNumerator
Returns the current quorum numerator. See quorumDenominator.
function quorumNumerator() public view virtual returns (uint256);
quorumNumerator
Returns the quorum numerator at a specific timepoint. See quorumDenominator.
function quorumNumerator(uint256 timepoint) public view virtual returns (uint256);
quorumDenominator
Returns the quorum denominator. Defaults to 100, but may be overridden.
function quorumDenominator() public view virtual returns (uint256);
quorum
Returns the quorum for a timepoint, in terms of number of votes: supply * numerator / denominator.
function quorum(uint256 timepoint) public view virtual override returns (uint256);
updateQuorumNumerator
*Changes the quorum numerator. Emits a QuorumNumeratorUpdated event. Requirements:
- Must be called through a governance proposal.
- New numerator must be smaller or equal to the denominator.*
function updateQuorumNumerator(uint256 newQuorumNumerator) external virtual onlyGovernance;
_updateQuorumNumerator
*Changes the quorum numerator. Emits a QuorumNumeratorUpdated event. Requirements:
- New numerator must be smaller or equal to the denominator.*
function _updateQuorumNumerator(uint256 newQuorumNumerator) internal virtual;
_optimisticUpperLookupRecent
Returns the numerator at a specific timepoint.
function _optimisticUpperLookupRecent(Checkpoints.Trace208 storage ckpts, uint256 timepoint)
internal
view
returns (uint256);
Events
QuorumNumeratorUpdated
event QuorumNumeratorUpdated(uint256 oldQuorumNumerator, uint256 newQuorumNumerator);
Errors
GovernorInvalidQuorumFraction
The quorum set is not a valid fraction.
error GovernorInvalidQuorumFraction(uint256 quorumNumerator, uint256 quorumDenominator);
Structs
GovernorVotesQuorumFractionStorage
Note: storage-location: erc7201:openzeppelin.storage.GovernorVotesQuorumFraction
struct GovernorVotesQuorumFractionStorage {
Checkpoints.Trace208 _quorumNumeratorHistory;
}
GovernorVotesSuperQuorumFractionUpgradeable
Inherits: Initializable, GovernorVotesQuorumFractionUpgradeable, GovernorSuperQuorumUpgradeable
Extension of {GovernorVotesQuorumFraction} with a super quorum expressed as a
fraction of the total supply. Proposals that meet the super quorum (and have a majority of for votes) advance to
the Succeeded state before the proposal deadline.
State Variables
GovernorVotesSuperQuorumFractionStorageLocation
bytes32 private constant GovernorVotesSuperQuorumFractionStorageLocation =
0x31eabc8444b313223279a7cb4d22bce9201d463789f695e0a51f91d19ec31000;
Functions
_getGovernorVotesSuperQuorumFractionStorage
function _getGovernorVotesSuperQuorumFractionStorage()
private
pure
returns (GovernorVotesSuperQuorumFractionStorage storage $);
__GovernorVotesSuperQuorumFraction_init
Initialize super quorum as a fraction of the token's total supply. The super quorum is specified as a fraction of the token's total supply and has to be greater than the quorum.
function __GovernorVotesSuperQuorumFraction_init(uint256 superQuorumNumeratorValue) internal onlyInitializing;
__GovernorVotesSuperQuorumFraction_init_unchained
function __GovernorVotesSuperQuorumFraction_init_unchained(uint256 superQuorumNumeratorValue)
internal
onlyInitializing;
superQuorumNumerator
Returns the current super quorum numerator.
function superQuorumNumerator() public view virtual returns (uint256);
superQuorumNumerator
Returns the super quorum numerator at a specific timepoint.
function superQuorumNumerator(uint256 timepoint) public view virtual returns (uint256);
superQuorum
Returns the super quorum for a timepoint, in terms of number of votes: supply * numerator / denominator.
See GovernorSuperQuorum-superQuorum for more details.
function superQuorum(uint256 timepoint) public view virtual override returns (uint256);
updateSuperQuorumNumerator
*Changes the super quorum numerator. Emits a SuperQuorumNumeratorUpdated event. Requirements:
- Must be called through a governance proposal.
- New super quorum numerator must be smaller or equal to the denominator.
- New super quorum numerator must be greater than or equal to the quorum numerator.*
function updateSuperQuorumNumerator(uint256 newSuperQuorumNumerator) public virtual onlyGovernance;
_updateSuperQuorumNumerator
*Changes the super quorum numerator. Emits a SuperQuorumNumeratorUpdated event. Requirements:
- New super quorum numerator must be smaller or equal to the denominator.
- New super quorum numerator must be greater than or equal to the quorum numerator.*
function _updateSuperQuorumNumerator(uint256 newSuperQuorumNumerator) internal virtual;
_updateQuorumNumerator
Overrides GovernorVotesQuorumFraction-_updateQuorumNumerator to ensure the super quorum numerator is greater than or equal to the quorum numerator.
function _updateQuorumNumerator(uint256 newQuorumNumerator) internal virtual override;
state
Overridden version of the {Governor-state} function that checks if the proposal has reached the super quorum. NOTE: If the proposal reaches super quorum but {_voteSucceeded} returns false, eg, assuming the super quorum has been set low enough that both FOR and AGAINST votes have exceeded it and AGAINST votes exceed FOR votes, the proposal continues to be active until {_voteSucceeded} returns true or the proposal deadline is reached. This means that with a low super quorum it is also possible that a vote can succeed prematurely before enough AGAINST voters have a chance to vote. Hence, it is recommended to set a high enough super quorum to avoid these types of scenarios.
function state(uint256 proposalId)
public
view
virtual
override(GovernorUpgradeable, GovernorSuperQuorumUpgradeable)
returns (ProposalState);
Events
SuperQuorumNumeratorUpdated
event SuperQuorumNumeratorUpdated(uint256 oldSuperQuorumNumerator, uint256 newSuperQuorumNumerator);
Errors
GovernorInvalidSuperQuorumFraction
The super quorum set is not valid as it exceeds the quorum denominator.
error GovernorInvalidSuperQuorumFraction(uint256 superQuorumNumerator, uint256 denominator);
GovernorInvalidSuperQuorumTooSmall
The super quorum set is not valid as it is smaller or equal to the quorum.
error GovernorInvalidSuperQuorumTooSmall(uint256 superQuorumNumerator, uint256 quorumNumerator);
GovernorInvalidQuorumTooLarge
The quorum set is not valid as it exceeds the super quorum.
error GovernorInvalidQuorumTooLarge(uint256 quorumNumerator, uint256 superQuorumNumerator);
Structs
GovernorVotesSuperQuorumFractionStorage
Note: storage-location: erc7201:openzeppelin.storage.GovernorVotesSuperQuorumFraction
struct GovernorVotesSuperQuorumFractionStorage {
Checkpoints.Trace208 _superQuorumNumeratorHistory;
}
GovernorVotesUpgradeable
Inherits: Initializable, GovernorUpgradeable
Extension of {Governor} for voting weight extraction from an {ERC20Votes} token, or since v4.5 an {ERC721Votes} token.
State Variables
GovernorVotesStorageLocation
bytes32 private constant GovernorVotesStorageLocation =
0x3ba4977254e415696610a40ebf2258dbfa0ec6a2ff64e84bfe715ff16977cc00;
Functions
_getGovernorVotesStorage
function _getGovernorVotesStorage() private pure returns (GovernorVotesStorage storage $);
__GovernorVotes_init
function __GovernorVotes_init(IVotes tokenAddress) internal onlyInitializing;
__GovernorVotes_init_unchained
function __GovernorVotes_init_unchained(IVotes tokenAddress) internal onlyInitializing;
token
The token that voting power is sourced from.
function token() public view virtual returns (IERC5805);
clock
Clock (as specified in ERC-6372) is set to match the token's clock. Fallback to block numbers if the token does not implement ERC-6372.
function clock() public view virtual override returns (uint48);
CLOCK_MODE
Machine-readable description of the clock as specified in ERC-6372.
function CLOCK_MODE() public view virtual override returns (string memory);
_getVotes
Read the voting weight from the token's built in snapshot mechanism (see Governor-_getVotes).
function _getVotes(address account, uint256 timepoint, bytes memory) internal view virtual override returns (uint256);
Structs
GovernorVotesStorage
Note: storage-location: erc7201:openzeppelin.storage.GovernorVotes
struct GovernorVotesStorage {
IERC5805 _token;
}
Contents
VotesExtendedUpgradeable
Inherits: Initializable, VotesUpgradeable
*Extension of {Votes} that adds checkpoints for delegations and balances. WARNING: While this contract extends {Votes}, valid uses of {Votes} may not be compatible with {VotesExtended} without additional considerations. This implementation of {_transferVotingUnits} must run AFTER the voting weight movement is registered, such that it is reflected on {_getVotingUnits}. Said differently, {VotesExtended} MUST be integrated in a way that calls {_transferVotingUnits} AFTER the asset transfer is registered and balances are updated:
contract VotingToken is Token, VotesExtended {
function transfer(address from, address to, uint256 tokenId) public override {
super.transfer(from, to, tokenId); // <- Perform the transfer first ...
_transferVotingUnits(from, to, 1); // <- ... then call _transferVotingUnits.
}
function _getVotingUnits(address account) internal view override returns (uint256) {
return balanceOf(account);
}
}
{ERC20Votes} and {ERC721Votes} follow this pattern and are thus safe to use with {VotesExtended}.*
State Variables
VotesExtendedStorageLocation
bytes32 private constant VotesExtendedStorageLocation =
0x4a7bc7aabb540021543c1f28dd259f8776612c96fd248bdcc6fdf56c7778d900;
Functions
_getVotesExtendedStorage
function _getVotesExtendedStorage() private pure returns (VotesExtendedStorage storage $);
__VotesExtended_init
function __VotesExtended_init() internal onlyInitializing;
__VotesExtended_init_unchained
function __VotesExtended_init_unchained() internal onlyInitializing;
getPastDelegate
*Returns the delegate of an account at a specific moment in the past. If the clock() is
configured to use block numbers, this will return the value at the end of the corresponding block.
Requirements:
timepointmust be in the past. If operating using block numbers, the block must be already mined.*
function getPastDelegate(address account, uint256 timepoint) public view virtual returns (address);
getPastBalanceOf
*Returns the balanceOf of an account at a specific moment in the past. If the clock() is
configured to use block numbers, this will return the value at the end of the corresponding block.
Requirements:
timepointmust be in the past. If operating using block numbers, the block must be already mined.*
function getPastBalanceOf(address account, uint256 timepoint) public view virtual returns (uint256);
_delegate
Delegate all of account's voting units to delegatee.
Emits events {IVotes-DelegateChanged} and {IVotes-DelegateVotesChanged}.
function _delegate(address account, address delegatee) internal virtual override;
_transferVotingUnits
Transfers, mints, or burns voting units. To register a mint, from should be zero. To register a burn, to
should be zero. Total supply of voting units will be adjusted with mints and burns.
function _transferVotingUnits(address from, address to, uint256 amount) internal virtual override;
Structs
VotesExtendedStorage
Note: storage-location: erc7201:openzeppelin.storage.VotesExtended
struct VotesExtendedStorage {
mapping(address delegator => Checkpoints.Trace160) _userDelegationCheckpoints;
mapping(address account => Checkpoints.Trace208) _userVotingUnitsCheckpoints;
}
VotesUpgradeable
Inherits: Initializable, ContextUpgradeable, EIP712Upgradeable, NoncesUpgradeable, IERC5805
This is a base abstract contract that tracks voting units, which are a measure of voting power that can be transferred, and provides a system of vote delegation, where an account can delegate its voting units to a sort of "representative" that will pool delegated voting units from different accounts and can then use it to vote in decisions. In fact, voting units must be delegated in order to count as actual votes, and an account has to delegate those votes to itself if it wishes to participate in decisions and does not have a trusted representative. This contract is often combined with a token contract such that voting units correspond to token units. For an example, see {ERC721Votes}. The full history of delegate votes is tracked on-chain so that governance protocols can consider votes as distributed at a particular block number to protect against flash loans and double voting. The opt-in delegate system makes the cost of this history tracking optional. When using this module the derived contract must implement {_getVotingUnits} (for example, make it return {ERC721-balanceOf}), and can use {_transferVotingUnits} to track a change in the distribution of those units (in the previous example, it would be included in {ERC721-_update}).
State Variables
DELEGATION_TYPEHASH
bytes32 private constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
VotesStorageLocation
bytes32 private constant VotesStorageLocation = 0xe8b26c30fad74198956032a3533d903385d56dd795af560196f9c78d4af40d00;
Functions
_getVotesStorage
function _getVotesStorage() private pure returns (VotesStorage storage $);
__Votes_init
function __Votes_init() internal onlyInitializing;
__Votes_init_unchained
function __Votes_init_unchained() internal onlyInitializing;
clock
Clock used for flagging checkpoints. Can be overridden to implement timestamp based checkpoints (and voting), in which case CLOCK_MODE should be overridden as well to match.
function clock() public view virtual returns (uint48);
CLOCK_MODE
Machine-readable description of the clock as specified in ERC-6372.
function CLOCK_MODE() public view virtual returns (string memory);
_validateTimepoint
Validate that a timepoint is in the past, and return it as a uint48.
function _validateTimepoint(uint256 timepoint) internal view returns (uint48);
getVotes
Returns the current amount of votes that account has.
function getVotes(address account) public view virtual returns (uint256);
getPastVotes
*Returns the amount of votes that account had at a specific moment in the past. If the clock() is
configured to use block numbers, this will return the value at the end of the corresponding block.
Requirements:
timepointmust be in the past. If operating using block numbers, the block must be already mined.*
function getPastVotes(address account, uint256 timepoint) public view virtual returns (uint256);
getPastTotalSupply
*Returns the total supply of votes available at a specific moment in the past. If the clock() is
configured to use block numbers, this will return the value at the end of the corresponding block.
NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.
Votes that have not been delegated are still part of total supply, even though they would not participate in a
vote.
Requirements:
timepointmust be in the past. If operating using block numbers, the block must be already mined.*
function getPastTotalSupply(uint256 timepoint) public view virtual returns (uint256);
_getTotalSupply
Returns the current total supply of votes.
function _getTotalSupply() internal view virtual returns (uint256);
delegates
Returns the delegate that account has chosen.
function delegates(address account) public view virtual returns (address);
delegate
Delegates votes from the sender to delegatee.
function delegate(address delegatee) public virtual;
delegateBySig
Delegates votes from signer to delegatee.
function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s)
public
virtual;
_delegate
Delegate all of account's voting units to delegatee.
Emits events IVotes-DelegateChanged and {IVotes-DelegateVotesChanged}.
function _delegate(address account, address delegatee) internal virtual;
_transferVotingUnits
Transfers, mints, or burns voting units. To register a mint, from should be zero. To register a burn, to
should be zero. Total supply of voting units will be adjusted with mints and burns.
function _transferVotingUnits(address from, address to, uint256 amount) internal virtual;
_moveDelegateVotes
Moves delegated votes from one delegate to another.
function _moveDelegateVotes(address from, address to, uint256 amount) internal virtual;
_numCheckpoints
Get number of checkpoints for account.
function _numCheckpoints(address account) internal view virtual returns (uint32);
_checkpoints
Get the pos-th checkpoint for account.
function _checkpoints(address account, uint32 pos) internal view virtual returns (Checkpoints.Checkpoint208 memory);
_push
function _push(Checkpoints.Trace208 storage store, function(uint208, uint208) view returns (uint208) op, uint208 delta)
private
returns (uint208 oldValue, uint208 newValue);
_add
function _add(uint208 a, uint208 b) private pure returns (uint208);
_subtract
function _subtract(uint208 a, uint208 b) private pure returns (uint208);
_getVotingUnits
Must return the voting units held by an account.
function _getVotingUnits(address) internal view virtual returns (uint256);
Errors
ERC6372InconsistentClock
The clock was incorrectly modified.
error ERC6372InconsistentClock();
ERC5805FutureLookup
Lookup to future votes is not available.
error ERC5805FutureLookup(uint256 timepoint, uint48 clock);
Structs
VotesStorage
Note: storage-location: erc7201:openzeppelin.storage.Votes
struct VotesStorage {
mapping(address account => address) _delegatee;
mapping(address delegatee => Checkpoints.Trace208) _delegateCheckpoints;
Checkpoints.Trace208 _totalCheckpoints;
}
GovernorUpgradeable
Inherits: Initializable, ContextUpgradeable, ERC165Upgradeable, EIP712Upgradeable, NoncesUpgradeable, IGovernor, IERC721Receiver, IERC1155Receiver
*Core of the governance system, designed to be extended through various modules. This contract is abstract and requires several functions to be implemented in various modules:
- A counting module must implement _quorumReached, {_voteSucceeded} and {_countVote}
- A voting module must implement {_getVotes}
- Additionally, {votingPeriod}, {votingDelay}, and {quorum} must also be implemented*
State Variables
BALLOT_TYPEHASH
bytes32 public constant BALLOT_TYPEHASH =
keccak256("Ballot(uint256 proposalId,uint8 support,address voter,uint256 nonce)");
EXTENDED_BALLOT_TYPEHASH
bytes32 public constant EXTENDED_BALLOT_TYPEHASH =
keccak256("ExtendedBallot(uint256 proposalId,uint8 support,address voter,uint256 nonce,string reason,bytes params)");
ALL_PROPOSAL_STATES_BITMAP
bytes32 private constant ALL_PROPOSAL_STATES_BITMAP = bytes32((2 ** (uint8(type(ProposalState).max) + 1)) - 1);
GovernorStorageLocation
bytes32 private constant GovernorStorageLocation = 0x7c712897014dbe49c045ef1299aa2d5f9e67e48eea4403efa21f1e0f3ac0cb00;
Functions
_getGovernorStorage
function _getGovernorStorage() private pure returns (GovernorStorage storage $);
onlyGovernance
Restricts a function so it can only be executed through governance proposals. For example, governance parameter setters in {GovernorSettings} are protected using this modifier. The governance executing address may be different from the Governor's own address, for example it could be a timelock. This can be customized by modules by overriding {_executor}. The executor is only able to invoke these functions during the execution of the governor's {execute} function, and not under any other circumstances. Thus, for example, additional timelock proposers are not able to change governance parameters without going through the governance protocol (since v4.6).
modifier onlyGovernance();
__Governor_init
Sets the value for name and {version}
function __Governor_init(string memory name_) internal onlyInitializing;
__Governor_init_unchained
function __Governor_init_unchained(string memory name_) internal onlyInitializing;
receive
Function to receive ETH that will be handled by the governor (disabled if executor is a third party contract)
receive() external payable virtual;
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(IERC165, ERC165Upgradeable)
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
name
module:core
Name of the governor instance (used in building the EIP-712 domain separator).
function name() public view virtual returns (string memory);
version
module:core
Version of the governor instance (used in building the EIP-712 domain separator). Default: "1"
function version() public view virtual returns (string memory);
hashProposal
See IGovernor-hashProposal.
The proposal id is produced by hashing the ABI encoded targets array, the values array, the calldatas array
and the descriptionHash (bytes32 which itself is the keccak256 hash of the description string). This proposal id
can be produced from the proposal data which is part of the {ProposalCreated} event. It can even be computed in
advance, before the proposal is submitted.
Note that the chainId and the governor address are not part of the proposal id computation. Consequently, the
same proposal (with same operation and same description) will have the same id if submitted on multiple governors
across multiple networks. This also means that in order to execute the same operation twice (on the same
governor) the proposer will have to change the description in order to avoid proposal id conflicts.
function hashProposal(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) public pure virtual returns (uint256);
getProposalId
module:core
Function used to get the proposal id from the proposal details.
function getProposalId(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) public view virtual returns (uint256);
state
module:core
Current state of a proposal, following Compound's convention
function state(uint256 proposalId) public view virtual returns (ProposalState);
proposalThreshold
module:core
The number of votes required in order for a voter to become a proposer.
function proposalThreshold() public view virtual returns (uint256);
proposalSnapshot
module:core
Timepoint used to retrieve user's votes and quorum. If using block number (as per Compound's Comp), the snapshot is performed at the end of this block. Hence, voting for this proposal starts at the beginning of the following block.
function proposalSnapshot(uint256 proposalId) public view virtual returns (uint256);
proposalDeadline
module:core
Timepoint at which votes close. If using block number, votes close at the end of this block, so it is possible to cast a vote during this block.
function proposalDeadline(uint256 proposalId) public view virtual returns (uint256);
proposalProposer
module:core
The account that created a proposal.
function proposalProposer(uint256 proposalId) public view virtual returns (address);
proposalEta
module:core
The time when a queued proposal becomes executable ("ETA"). Unlike {proposalSnapshot} and {proposalDeadline}, this doesn't use the governor clock, and instead relies on the executor's clock which may be different. In most cases this will be a timestamp.
function proposalEta(uint256 proposalId) public view virtual returns (uint256);
proposalNeedsQueuing
module:core
Whether a proposal needs to be queued before execution.
function proposalNeedsQueuing(uint256) public view virtual returns (bool);
_checkGovernance
Reverts if the msg.sender is not the executor. In case the executor is not this contract
itself, the function reverts if msg.data is not whitelisted as a result of an execute
operation. See {onlyGovernance}.
function _checkGovernance() internal virtual;
_quorumReached
Amount of votes already cast passes the threshold limit.
function _quorumReached(uint256 proposalId) internal view virtual returns (bool);
_voteSucceeded
Is the proposal successful or not.
function _voteSucceeded(uint256 proposalId) internal view virtual returns (bool);
_getVotes
Get the voting weight of account at a specific timepoint, for a vote as described by params.
function _getVotes(address account, uint256 timepoint, bytes memory params) internal view virtual returns (uint256);
_countVote
Register a vote for proposalId by account with a given support, voting weight and voting params.
Note: Support is generic and can represent various things depending on the voting system used.
function _countVote(uint256 proposalId, address account, uint8 support, uint256 totalWeight, bytes memory params)
internal
virtual
returns (uint256);
_tallyUpdated
Hook that should be called every time the tally for a proposal is updated. Note: This function must run successfully. Reverts will result in the bricking of governance
function _tallyUpdated(uint256 proposalId) internal virtual;
_defaultParams
Default additional encoded parameters used by castVote methods that don't include them Note: Should be overridden by specific implementations to use an appropriate value, the meaning of the additional params, in the context of that implementation
function _defaultParams() internal view virtual returns (bytes memory);
propose
See IGovernor-propose. This function has opt-in frontrunning protection, described in {_isValidDescriptionForProposer}.
function propose(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, string memory description)
public
virtual
returns (uint256);
_propose
Internal propose mechanism. Can be overridden to add more logic on proposal creation. Emits a IGovernor-ProposalCreated event.
function _propose(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
string memory description,
address proposer
) internal virtual returns (uint256 proposalId);
queue
Queue a proposal. Some governors require this step to be performed before execution can happen. If queuing is not necessary, this function may revert. Queuing a proposal requires the quorum to be reached, the vote to be successful, and the deadline to be reached. Emits a {ProposalQueued} event.
function queue(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
public
virtual
returns (uint256);
_queueOperations
Internal queuing mechanism. Can be overridden (without a super call) to modify the way queuing is
performed (for example adding a vault/timelock).
This is empty by default, and must be overridden to implement queuing.
This function returns a timestamp that describes the expected ETA for execution. If the returned value is 0
(which is the default value), the core will consider queueing did not succeed, and the public queue function
will revert.
NOTE: Calling this function directly will NOT check the current state of the proposal, or emit the
ProposalQueued event. Queuing a proposal should be done using {queue}.
function _queueOperations(uint256, address[] memory, uint256[] memory, bytes[] memory, bytes32)
internal
virtual
returns (uint48);
execute
Execute a successful proposal. This requires the quorum to be reached, the vote to be successful, and the deadline to be reached. Depending on the governor it might also be required that the proposal was queued and that some delay passed. Emits a {ProposalExecuted} event. NOTE: Some modules can modify the requirements for execution, for example by adding an additional timelock.
function execute(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
public
payable
virtual
returns (uint256);
_executeOperations
Internal execution mechanism. Can be overridden (without a super call) to modify the way execution is
performed (for example adding a vault/timelock).
NOTE: Calling this function directly will NOT check the current state of the proposal, set the executed flag to
true or emit the ProposalExecuted event. Executing a proposal should be done using execute.
function _executeOperations(
uint256,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32
) internal virtual;
cancel
Cancel a proposal. A proposal is cancellable by the proposer, but only while it is Pending state, i.e. before the vote starts. Emits a {ProposalCanceled} event.
function cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
public
virtual
returns (uint256);
_cancel
Internal cancel mechanism with minimal restrictions. A proposal can be cancelled in any state other than Canceled, Expired, or Executed. Once cancelled a proposal can't be re-submitted. Emits a IGovernor-ProposalCanceled event.
function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
internal
virtual
returns (uint256);
getVotes
module:reputation
Voting power of an account at a specific timepoint.
Note: this can be implemented in a number of ways, for example by reading the delegated balance from one (or
multiple), {ERC20Votes} tokens.
function getVotes(address account, uint256 timepoint) public view virtual returns (uint256);
getVotesWithParams
module:reputation
Voting power of an account at a specific timepoint given additional encoded parameters.
function getVotesWithParams(address account, uint256 timepoint, bytes memory params)
public
view
virtual
returns (uint256);
castVote
Cast a vote Emits a {VoteCast} event.
function castVote(uint256 proposalId, uint8 support) public virtual returns (uint256);
castVoteWithReason
Cast a vote with a reason Emits a {VoteCast} event.
function castVoteWithReason(uint256 proposalId, uint8 support, string calldata reason)
public
virtual
returns (uint256);
castVoteWithReasonAndParams
Cast a vote with a reason and additional encoded parameters Emits a {VoteCast} or {VoteCastWithParams} event depending on the length of params.
function castVoteWithReasonAndParams(uint256 proposalId, uint8 support, string calldata reason, bytes memory params)
public
virtual
returns (uint256);
castVoteBySig
Cast a vote using the voter's signature, including ERC-1271 signature support. Emits a {VoteCast} event.
function castVoteBySig(uint256 proposalId, uint8 support, address voter, bytes memory signature)
public
virtual
returns (uint256);
castVoteWithReasonAndParamsBySig
Cast a vote with a reason and additional encoded parameters using the voter's signature, including ERC-1271 signature support. Emits a {VoteCast} or {VoteCastWithParams} event depending on the length of params.
function castVoteWithReasonAndParamsBySig(
uint256 proposalId,
uint8 support,
address voter,
string calldata reason,
bytes memory params,
bytes memory signature
) public virtual returns (uint256);
_validateVoteSig
Validate the signature used in castVoteBySig function.
function _validateVoteSig(uint256 proposalId, uint8 support, address voter, bytes memory signature)
internal
virtual
returns (bool);
_validateExtendedVoteSig
Validate the signature used in castVoteWithReasonAndParamsBySig function.
function _validateExtendedVoteSig(
uint256 proposalId,
uint8 support,
address voter,
string memory reason,
bytes memory params,
bytes memory signature
) internal virtual returns (bool);
_castVote
Internal vote casting mechanism: Check that the vote is pending, that it has not been cast yet, retrieve voting weight using IGovernor-getVotes and call the {_countVote} internal function. Uses the _defaultParams(). Emits a {IGovernor-VoteCast} event.
function _castVote(uint256 proposalId, address account, uint8 support, string memory reason)
internal
virtual
returns (uint256);
_castVote
Internal vote casting mechanism: Check that the vote is pending, that it has not been cast yet, retrieve voting weight using IGovernor-getVotes and call the {_countVote} internal function. Emits a {IGovernor-VoteCast} event.
function _castVote(uint256 proposalId, address account, uint8 support, string memory reason, bytes memory params)
internal
virtual
returns (uint256);
relay
Relays a transaction or function call to an arbitrary target. In cases where the governance executor
is some contract other than the governor itself, like when using a timelock, this function can be invoked
in a governance proposal to recover tokens or Ether that was sent to the governor contract by mistake.
Note that if the executor is simply the governor itself, use of relay is redundant.
function relay(address target, uint256 value, bytes calldata data) external payable virtual onlyGovernance;
_executor
Address through which the governor executes action. Will be overloaded by module that execute actions through another contract such as a timelock.
function _executor() internal view virtual returns (address);
onERC721Received
See IERC721Receiver-onERC721Received. Receiving tokens is disabled if the governance executor is other than the governor itself (eg. when using with a timelock).
function onERC721Received(address, address, uint256, bytes memory) public virtual returns (bytes4);
onERC1155Received
See IERC1155Receiver-onERC1155Received. Receiving tokens is disabled if the governance executor is other than the governor itself (eg. when using with a timelock).
function onERC1155Received(address, address, uint256, uint256, bytes memory) public virtual returns (bytes4);
onERC1155BatchReceived
See IERC1155Receiver-onERC1155BatchReceived. Receiving tokens is disabled if the governance executor is other than the governor itself (eg. when using with a timelock).
function onERC1155BatchReceived(address, address, uint256[] memory, uint256[] memory, bytes memory)
public
virtual
returns (bytes4);
_encodeStateBitmap
Encodes a ProposalState into a bytes32 representation where each bit enabled corresponds to
the underlying position in the ProposalState enum. For example:
0x000...10000
^^^^^^------ ...
^----- Succeeded
^---- Defeated
^--- Canceled
^-- Active
^- Pending
function _encodeStateBitmap(ProposalState proposalState) internal pure returns (bytes32);
_validateStateBitmap
Check that the current state of a proposal matches the requirements described by the allowedStates bitmap.
This bitmap should be built using _encodeStateBitmap.
If requirements are not met, reverts with a {GovernorUnexpectedProposalState} error.
function _validateStateBitmap(uint256 proposalId, bytes32 allowedStates) internal view returns (ProposalState);
_isValidDescriptionForProposer
function _isValidDescriptionForProposer(address proposer, string memory description)
internal
view
virtual
returns (bool);
_validateCancel
Check if the caller can cancel the proposal with the given proposalId.
The default implementation allows the proposal proposer to cancel the proposal during the pending state.
function _validateCancel(uint256 proposalId, address caller) internal view virtual returns (bool);
clock
Clock used for flagging checkpoints. Can be overridden to implement timestamp based checkpoints (and voting).
function clock() public view virtual returns (uint48);
CLOCK_MODE
Description of the clock
function CLOCK_MODE() public view virtual returns (string memory);
votingDelay
module:user-config
Delay, between the proposal is created and the vote starts. The unit this duration is expressed in depends on the clock (see ERC-6372) this contract uses. This can be increased to leave time for users to buy voting power, or delegate it, before the voting of a proposal starts. NOTE: While this interface returns a uint256, timepoints are stored as uint48 following the ERC-6372 clock type. Consequently this value must fit in a uint48 (when added to the current clock). See {IERC6372-clock}.
function votingDelay() public view virtual returns (uint256);
votingPeriod
module:user-config
Delay between the vote start and vote end. The unit this duration is expressed in depends on the clock (see ERC-6372) this contract uses. NOTE: The {votingDelay} can delay the start of the vote. This must be considered when setting the voting duration compared to the voting delay. NOTE: This value is stored when the proposal is submitted so that possible changes to the value do not affect proposals that have already been submitted. The type used to save it is a uint32. Consequently, while this interface returns a uint256, the value it returns should fit in a uint32.
function votingPeriod() public view virtual returns (uint256);
quorum
module:user-config
Minimum number of cast voted required for a proposal to be successful.
NOTE: The timepoint parameter corresponds to the snapshot used for counting vote. This allows to scale the
quorum depending on values such as the totalSupply of a token at this timepoint (see {ERC20Votes}).
function quorum(uint256 timepoint) public view virtual returns (uint256);
_unsafeReadBytesOffset
Reads a bytes32 from a bytes array without bounds checking. NOTE: making this function internal would mean it could be used with memory unsafe offset, and marking the assembly block as such would prevent some optimizations.
function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value);
Structs
ProposalCore
struct ProposalCore {
address proposer;
uint48 voteStart;
uint32 voteDuration;
bool executed;
bool canceled;
uint48 etaSeconds;
}
GovernorStorage
Note: storage-location: erc7201:openzeppelin.storage.Governor
struct GovernorStorage {
string _name;
mapping(uint256 proposalId => ProposalCore) _proposals;
DoubleEndedQueue.Bytes32Deque _governanceCall;
}
TimelockControllerUpgradeable
Inherits: Initializable, AccessControlUpgradeable, ERC721HolderUpgradeable, ERC1155HolderUpgradeable
Contract module which acts as a timelocked controller. When set as the
owner of an Ownable smart contract, it enforces a timelock on all
onlyOwner maintenance operations. This gives time for users of the
controlled contract to exit before a potentially dangerous maintenance
operation is applied.
By default, this contract is self administered, meaning administration tasks
have to go through the timelock process. The proposer (resp executor) role
is in charge of proposing (resp executing) operations. A common use case is
to position this {TimelockController} as the owner of a smart contract, with
a multisig or a DAO as the sole proposer.
State Variables
PROPOSER_ROLE
bytes32 public constant PROPOSER_ROLE = keccak256("PROPOSER_ROLE");
EXECUTOR_ROLE
bytes32 public constant EXECUTOR_ROLE = keccak256("EXECUTOR_ROLE");
CANCELLER_ROLE
bytes32 public constant CANCELLER_ROLE = keccak256("CANCELLER_ROLE");
_DONE_TIMESTAMP
uint256 internal constant _DONE_TIMESTAMP = uint256(1);
TimelockControllerStorageLocation
bytes32 private constant TimelockControllerStorageLocation =
0x9a37c2aa9d186a0969ff8a8267bf4e07e864c2f2768f5040949e28a624fb3600;
Functions
_getTimelockControllerStorage
function _getTimelockControllerStorage() private pure returns (TimelockControllerStorage storage $);
initialize
function initialize(uint256 minDelay, address[] memory proposers, address[] memory executors, address admin)
public
virtual
initializer;
__TimelockController_init
*Initializes the contract with the following parameters:
minDelay: initial minimum delay in seconds for operationsproposers: accounts to be granted proposer and canceller rolesexecutors: accounts to be granted executor roleadmin: optional account to be granted admin role; disable with zero address IMPORTANT: The optional admin can aid with initial configuration of roles after deployment without being subject to delay, but this role should be subsequently renounced in favor of administration through timelocked proposals. Previous versions of this contract would assign this admin to the deployer automatically and should be renounced as well.*
function __TimelockController_init(
uint256 minDelay,
address[] memory proposers,
address[] memory executors,
address admin
) internal onlyInitializing;
__TimelockController_init_unchained
function __TimelockController_init_unchained(
uint256 minDelay,
address[] memory proposers,
address[] memory executors,
address admin
) internal onlyInitializing;
onlyRoleOrOpenRole
Modifier to make a function callable only by a certain role. In
addition to checking the sender's role, address(0) 's role is also
considered. Granting a role to address(0) is equivalent to enabling
this role for everyone.
modifier onlyRoleOrOpenRole(bytes32 role);
receive
Contract might receive/hold ETH as part of the maintenance process.
receive() external payable virtual;
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(AccessControlUpgradeable, ERC1155HolderUpgradeable)
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
isOperation
Returns whether an id corresponds to a registered operation. This includes both Waiting, Ready, and Done operations.
function isOperation(bytes32 id) public view returns (bool);
isOperationPending
Returns whether an operation is pending or not. Note that a "pending" operation may also be "ready".
function isOperationPending(bytes32 id) public view returns (bool);
isOperationReady
Returns whether an operation is ready for execution. Note that a "ready" operation is also "pending".
function isOperationReady(bytes32 id) public view returns (bool);
isOperationDone
Returns whether an operation is done or not.
function isOperationDone(bytes32 id) public view returns (bool);
getTimestamp
Returns the timestamp at which an operation becomes ready (0 for unset operations, 1 for done operations).
function getTimestamp(bytes32 id) public view virtual returns (uint256);
getOperationState
Returns operation state.
function getOperationState(bytes32 id) public view virtual returns (OperationState);
getMinDelay
Returns the minimum delay in seconds for an operation to become valid.
This value can be changed by executing an operation that calls updateDelay.
function getMinDelay() public view virtual returns (uint256);
hashOperation
Returns the identifier of an operation containing a single transaction.
function hashOperation(address target, uint256 value, bytes calldata data, bytes32 predecessor, bytes32 salt)
public
pure
virtual
returns (bytes32);
hashOperationBatch
Returns the identifier of an operation containing a batch of transactions.
function hashOperationBatch(
address[] calldata targets,
uint256[] calldata values,
bytes[] calldata payloads,
bytes32 predecessor,
bytes32 salt
) public pure virtual returns (bytes32);
schedule
*Schedule an operation containing a single transaction. Emits CallSalt if salt is nonzero, and {CallScheduled}. Requirements:
- the caller must have the 'proposer' role.*
function schedule(address target, uint256 value, bytes calldata data, bytes32 predecessor, bytes32 salt, uint256 delay)
public
virtual
onlyRole(PROPOSER_ROLE);
scheduleBatch
*Schedule an operation containing a batch of transactions. Emits CallSalt if salt is nonzero, and one {CallScheduled} event per transaction in the batch. Requirements:
- the caller must have the 'proposer' role.*
function scheduleBatch(
address[] calldata targets,
uint256[] calldata values,
bytes[] calldata payloads,
bytes32 predecessor,
bytes32 salt,
uint256 delay
) public virtual onlyRole(PROPOSER_ROLE);
_schedule
Schedule an operation that is to become valid after a given delay.
function _schedule(bytes32 id, uint256 delay) private;
cancel
*Cancel an operation. Requirements:
- the caller must have the 'canceller' role.*
function cancel(bytes32 id) public virtual onlyRole(CANCELLER_ROLE);
execute
*Execute an (ready) operation containing a single transaction. Emits a CallExecuted event. Requirements:
- the caller must have the 'executor' role.*
function execute(address target, uint256 value, bytes calldata payload, bytes32 predecessor, bytes32 salt)
public
payable
virtual
onlyRoleOrOpenRole(EXECUTOR_ROLE);
executeBatch
*Execute an (ready) operation containing a batch of transactions. Emits one CallExecuted event per transaction in the batch. Requirements:
- the caller must have the 'executor' role.*
function executeBatch(
address[] calldata targets,
uint256[] calldata values,
bytes[] calldata payloads,
bytes32 predecessor,
bytes32 salt
) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE);
_execute
Execute an operation's call.
function _execute(address target, uint256 value, bytes calldata data) internal virtual;
_beforeCall
Checks before execution of an operation's calls.
function _beforeCall(bytes32 id, bytes32 predecessor) private view;
_afterCall
Checks after execution of an operation's calls.
function _afterCall(bytes32 id) private;
updateDelay
*Changes the minimum timelock duration for future operations. Emits a MinDelayChange event. Requirements:
- the caller must be the timelock itself. This can only be achieved by scheduling and later executing an operation where the timelock is the target and the data is the ABI-encoded call to this function.*
function updateDelay(uint256 newDelay) external virtual;
_encodeStateBitmap
Encodes a OperationState into a bytes32 representation where each bit enabled corresponds to
the underlying position in the OperationState enum. For example:
0x000...1000
^^^^^^----- ...
^---- Done
^--- Ready
^-- Waiting
^- Unset
function _encodeStateBitmap(OperationState operationState) internal pure returns (bytes32);
Events
CallScheduled
Emitted when a call is scheduled as part of operation id.
event CallScheduled(
bytes32 indexed id,
uint256 indexed index,
address target,
uint256 value,
bytes data,
bytes32 predecessor,
uint256 delay
);
CallExecuted
Emitted when a call is performed as part of operation id.
event CallExecuted(bytes32 indexed id, uint256 indexed index, address target, uint256 value, bytes data);
CallSalt
Emitted when new proposal is scheduled with non-zero salt.
event CallSalt(bytes32 indexed id, bytes32 salt);
Cancelled
Emitted when operation id is cancelled.
event Cancelled(bytes32 indexed id);
MinDelayChange
Emitted when the minimum delay for future operations is modified.
event MinDelayChange(uint256 oldDuration, uint256 newDuration);
Errors
TimelockInvalidOperationLength
Mismatch between the parameters length for an operation call.
error TimelockInvalidOperationLength(uint256 targets, uint256 payloads, uint256 values);
TimelockInsufficientDelay
The schedule operation doesn't meet the minimum delay.
error TimelockInsufficientDelay(uint256 delay, uint256 minDelay);
TimelockUnexpectedOperationState
The current state of an operation is not as required.
The expectedStates is a bitmap with the bits enabled for each OperationState enum position
counting from right to left.
See _encodeStateBitmap.
error TimelockUnexpectedOperationState(bytes32 operationId, bytes32 expectedStates);
TimelockUnexecutedPredecessor
The predecessor to an operation not yet done.
error TimelockUnexecutedPredecessor(bytes32 predecessorId);
TimelockUnauthorizedCaller
The caller account is not authorized.
error TimelockUnauthorizedCaller(address caller);
Structs
TimelockControllerStorage
Note: storage-location: erc7201:openzeppelin.storage.TimelockController
struct TimelockControllerStorage {
mapping(bytes32 id => uint256) _timestamps;
uint256 _minDelay;
}
Enums
OperationState
enum OperationState {
Unset,
Waiting,
Ready,
Done
}
Contents
ERC2771ContextUpgradeable
Inherits: Initializable, ContextUpgradeable
Context variant with ERC-2771 support.
WARNING: Avoid using this pattern in contracts that rely in a specific calldata length as they'll
be affected by any forwarder whose msg.data is suffixed with the from address according to the ERC-2771
specification adding the address size in bytes (20) to the calldata size. An example of an unexpected
behavior could be an unintended fallback (or another function) invocation while trying to invoke the receive
function only accessible if msg.data.length == 0.
WARNING: The usage of delegatecall in this contract is dangerous and may result in context corruption.
Any forwarded request to this contract triggering a delegatecall to itself will result in an invalid _msgSender
recovery.
State Variables
_trustedForwarder
Note: oz-upgrades-unsafe-allow: state-variable-immutable
address private immutable _trustedForwarder;
Functions
constructor
Initializes the contract with a trusted forwarder, which will be able to invoke functions on this contract on behalf of other accounts. NOTE: The trusted forwarder can be replaced by overriding trustedForwarder.
Note: oz-upgrades-unsafe-allow: constructor
constructor(address trustedForwarder_);
trustedForwarder
Returns the address of the trusted forwarder.
function trustedForwarder() public view virtual returns (address);
isTrustedForwarder
Indicates whether any particular address is the trusted forwarder.
function isTrustedForwarder(address forwarder) public view virtual returns (bool);
_msgSender
Override for msg.sender. Defaults to the original msg.sender whenever
a call is not performed by the trusted forwarder or the calldata length is less than
20 bytes (an address length).
function _msgSender() internal view virtual override returns (address);
_msgData
Override for msg.data. Defaults to the original msg.data whenever
a call is not performed by the trusted forwarder or the calldata length is less than
20 bytes (an address length).
function _msgData() internal view virtual override returns (bytes calldata);
_contextSuffixLength
ERC-2771 specifies the context as being a single address (20 bytes).
function _contextSuffixLength() internal view virtual override returns (uint256);
ERC2771ForwarderUpgradeable
Inherits: Initializable, EIP712Upgradeable, NoncesUpgradeable
A forwarder compatible with ERC-2771 contracts. See {ERC2771Context}.
This forwarder operates on forward requests that include:
from: An address to operate on behalf of. It is required to be equal to the request signer.
to: The address that should be called.
value: The amount of native token to attach with the requested call.
gas: The amount of gas limit that will be forwarded with the requested call.
nonce: A unique transaction ordering identifier to avoid replayability and request invalidation.
deadline: A timestamp after which the request is not executable anymore.
data: Encoded msg.data to send with the requested call.
Relayers are able to submit batches if they are processing a high volume of requests. With high
throughput, relayers may run into limitations of the chain such as limits on the number of
transactions in the mempool. In these cases the recommendation is to distribute the load among
multiple accounts.
NOTE: Batching requests includes an optional refund for unused msg.value that is achieved by
performing a call with empty calldata. While this is within the bounds of ERC-2771 compliance,
if the refund receiver happens to consider the forwarder a trusted forwarder, it MUST properly
handle msg.data.length == 0. ERC2771Context in OpenZeppelin Contracts versions prior to 4.9.3
do not handle this properly.
==== Security Considerations
If a relayer submits a forward request, it should be willing to pay up to 100% of the gas amount
specified in the request. This contract does not implement any kind of retribution for this gas,
and it is assumed that there is an out of band incentive for relayers to pay for execution on
behalf of signers. Often, the relayer is operated by a project that will consider it a user
acquisition cost.
By offering to pay for gas, relayers are at risk of having that gas used by an attacker toward
some other purpose that is not aligned with the expected out of band incentives. If you operate a
relayer, consider whitelisting target contracts and function selectors. When relaying ERC-721 or
ERC-1155 transfers specifically, consider rejecting the use of the data field, since it can be
used to execute arbitrary code.
State Variables
_FORWARD_REQUEST_TYPEHASH
bytes32 internal constant _FORWARD_REQUEST_TYPEHASH = keccak256(
"ForwardRequest(address from,address to,uint256 value,uint256 gas,uint256 nonce,uint48 deadline,bytes data)"
);
Functions
initialize
function initialize(string memory name) public virtual initializer;
__ERC2771Forwarder_init
See EIP712-constructor.
function __ERC2771Forwarder_init(string memory name) internal onlyInitializing;
__ERC2771Forwarder_init_unchained
function __ERC2771Forwarder_init_unchained(string memory) internal onlyInitializing;
verify
Returns true if a request is valid for a provided signature at the current block timestamp.
A transaction is considered valid when the target trusts this forwarder, the request hasn't expired
(deadline is not met), and the signer matches the from parameter of the signed request.
NOTE: A request may return false here but it won't cause executeBatch to revert if a refund
receiver is provided.
function verify(ForwardRequestData calldata request) public view virtual returns (bool);
execute
*Executes a request on behalf of signature's signer using the ERC-2771 protocol. The gas
provided to the requested call may not be exactly the amount requested, but the call will not run
out of gas. Will revert if the request is invalid or the call reverts, in this case the nonce is not consumed.
Requirements:
- The request value should be equal to the provided
msg.value. - The request should be valid according to verify.*
function execute(ForwardRequestData calldata request) public payable virtual;
executeBatch
*Batch version of execute with optional refunding and atomic execution.
In case a batch contains at least one invalid request (see {verify}), the
request will be skipped and the refundReceiver parameter will receive back the
unused requested value at the end of the execution. This is done to prevent reverting
the entire batch when a request is invalid or has already been submitted.
If the refundReceiver is the address(0), this function will revert when at least
one of the requests was not valid instead of skipping it. This could be useful if
a batch is required to get executed atomically (at least at the top-level). For example,
refunding (and thus atomicity) can be opt-out if the relayer is using a service that avoids
including reverted transactions.
Requirements:
- The sum of the requests' values should be equal to the provided
msg.value. - All of the requests should be valid (see {verify}) when
refundReceiveris the zero address. NOTE: Setting a zerorefundReceiverguarantees an all-or-nothing requests execution only for the first-level forwarded calls. In case a forwarded request calls to a contract with another subcall, the second-level call may revert without the top-level call reverting.*
function executeBatch(ForwardRequestData[] calldata requests, address payable refundReceiver) public payable virtual;
_validate
Validates if the provided request can be executed at current block timestamp with
the given request.signature on behalf of request.signer.
function _validate(ForwardRequestData calldata request)
internal
view
virtual
returns (bool isTrustedForwarder, bool active, bool signerMatch, address signer);
_recoverForwardRequestSigner
Returns a tuple with the recovered the signer of an EIP712 forward request message hash and a boolean indicating if the signature is valid. NOTE: The signature is considered valid if ECDSA-tryRecover indicates no recover error for it.
function _recoverForwardRequestSigner(ForwardRequestData calldata request)
internal
view
virtual
returns (bool isValid, address signer);
_execute
*Validates and executes a signed request returning the request call success value.
Internal function without msg.value validation.
Requirements:
- The caller must have provided enough gas to forward with the call.
- The request must be valid (see verify) if the
requireValidRequestis true. Emits an {ExecutedForwardRequest} event. IMPORTANT: Using this function doesn't check that all themsg.valuewas sent, potentially leaving value stuck in the contract.*
function _execute(ForwardRequestData calldata request, bool requireValidRequest)
internal
virtual
returns (bool success);
_isTrustedByTarget
Returns whether the target trusts this forwarder. This function performs a static call to the target contract calling the ERC2771Context-isTrustedForwarder function. NOTE: Consider the execution of this forwarder is permissionless. Without this check, anyone may transfer assets that are owned by, or are approved to this forwarder.
function _isTrustedByTarget(address target) internal view virtual returns (bool);
_checkForwardedGas
*Checks if the requested gas was correctly forwarded to the callee. As a consequence of https://eips.ethereum.org/EIPS/eip-150[EIP-150]:
- At most
gasleft() - floor(gasleft() / 64)is forwarded to the callee. - At least
floor(gasleft() / 64)is kept in the caller. It reverts consuming all the available gas if the forwarded gas is not the requested gas. IMPORTANT: ThegasLeftparameter should be measured exactly at the end of the forwarded call. Any gas consumed in between will make room for bypassing this check.*
function _checkForwardedGas(uint256 gasLeft, ForwardRequestData calldata request) private pure;
Events
ExecutedForwardRequest
Emitted when a ForwardRequest is executed.
NOTE: An unsuccessful forward request could be due to an invalid signature, an expired deadline,
or simply a revert in the requested call. The contract guarantees that the relayer is not able to force
the requested call to run out of gas.
event ExecutedForwardRequest(address indexed signer, uint256 nonce, bool success);
Errors
ERC2771ForwarderInvalidSigner
The request from doesn't match with the recovered signer.
error ERC2771ForwarderInvalidSigner(address signer, address from);
ERC2771ForwarderMismatchedValue
The requestedValue doesn't match with the available msgValue.
error ERC2771ForwarderMismatchedValue(uint256 requestedValue, uint256 msgValue);
ERC2771ForwarderExpiredRequest
The request deadline has expired.
error ERC2771ForwarderExpiredRequest(uint48 deadline);
ERC2771UntrustfulTarget
The request target doesn't trust the forwarder.
error ERC2771UntrustfulTarget(address target, address forwarder);
Structs
ForwardRequestData
struct ForwardRequestData {
address from;
address to;
uint256 value;
uint256 gas;
uint48 deadline;
bytes data;
bytes signature;
}
Contents
- ERC165
- account
- compound
- docs
- governance
- proxy
- token
- utils
- AccessManagedTargetUpgradeable
- AccessManagerMockUpgradeable
- Uint256ArraysMockUpgradeable
- AddressArraysMockUpgradeable
- Bytes32ArraysMockUpgradeable
- BytesArraysMockUpgradeable
- StringArraysMockUpgradeable
- NotAuthorityMockUpgradeable
- AuthorityNoDelayMockUpgradeable
- AuthorityDelayMockUpgradeable
- AuthorityNoResponseUpgradeable
- AuthorityObserveIsConsumingUpgradeable
- Base64DirtyUpgradeable
- BatchCallerUpgradeable
- CallReceiverMockUpgradeable
- CallReceiverMockTrustingForwarderUpgradeable
- ConstructorMockUpgradeable
- ContextMockUpgradeable
- ContextMockCallerUpgradeable
- ImplUpgradeable
- DummyImplementationUpgradeable
- DummyImplementationV2Upgradeable
- EIP712VerifierUpgradeable
- ERC1271WalletMockUpgradeable
- ERC1271MaliciousMockUpgradeable
- ERC2771ContextMockUpgradeable
- ERC3156FlashBorrowerMockUpgradeable
- EtherReceiverMockUpgradeable
- InitializableMock
- ConstructorInitializableMock
- ChildConstructorInitializableMock
- ReinitializerMock
- DisableNew
- DisableOld
- DisableBad1
- DisableBad2
- DisableOk
- MerkleProofCustomHashMockUpgradeable
- MerkleTreeMockUpgradeable
- MulticallHelperUpgradeable
- SampleHuman
- SampleMother
- SampleGramps
- SampleFather
- SampleChild
- PausableMockUpgradeable
- ReentrancyAttackUpgradeable
- ReentrancyMockUpgradeable
- ReentrancyTransientMockUpgradeable
- Implementation1
- Implementation2
- Implementation3
- Implementation4
- MigratableMockV1
- MigratableMockV2
- MigratableMockV3
- Dummy1234Upgradeable
- StorageSlotMockUpgradeable
- TimelockReentrantUpgradeable
- TransientSlotMockUpgradeable
- UpgradeableBeaconMockUpgradeable
- UpgradeableBeaconReentrantMockUpgradeable
- VotesExtendedMockUpgradeable
- VotesExtendedTimestampMockUpgradeable
- VotesMockUpgradeable
- VotesTimestampMockUpgradeable
- AccessControlUpgradeableWithInit
- AccessControlDefaultAdminRulesUpgradeableWithInit
- AccessControlEnumerableUpgradeableWithInit
- AccessManagedUpgradeableWithInit
- AccessManagerUpgradeableWithInit
- OwnableUpgradeableWithInit
- Ownable2StepUpgradeableWithInit
- AccountERC7579UpgradeableWithInit
- AccountERC7579HookedUpgradeableWithInit
- VestingWalletUpgradeableWithInit
- VestingWalletCliffUpgradeableWithInit
- TimelockControllerUpgradeableWithInit
- ERC2771ContextUpgradeableWithInit
- ERC2771ForwarderUpgradeableWithInit
- AccessManagedTargetUpgradeableWithInit
- AccessManagerMockUpgradeableWithInit
- AccountMockUpgradeableWithInit
- AccountECDSAMockUpgradeableWithInit
- AccountP256MockUpgradeableWithInit
- AccountRSAMockUpgradeableWithInit
- AccountERC7702MockUpgradeableWithInit
- AccountERC7702WithModulesMockUpgradeableWithInit
- AccountERC7579MockUpgradeableWithInit
- AccountERC7579HookedMockUpgradeableWithInit
- AccountERC7913MockUpgradeableWithInit
- AccountMultiSignerMockUpgradeableWithInit
- AccountMultiSignerWeightedMockUpgradeableWithInit
- ERC7579ModuleMockUpgradeableWithInit
- ERC7579HookMockUpgradeableWithInit
- ERC7579FallbackHandlerMockUpgradeableWithInit
- ERC7579ValidatorMockUpgradeableWithInit
- ERC7579UtilsGlobalMockUpgradeableWithInit
- Uint256ArraysMockUpgradeableWithInit
- AddressArraysMockUpgradeableWithInit
- Bytes32ArraysMockUpgradeableWithInit
- BytesArraysMockUpgradeableWithInit
- StringArraysMockUpgradeableWithInit
- NotAuthorityMockUpgradeableWithInit
- AuthorityNoDelayMockUpgradeableWithInit
- AuthorityDelayMockUpgradeableWithInit
- AuthorityNoResponseUpgradeableWithInit
- AuthorityObserveIsConsumingUpgradeableWithInit
- Base64DirtyUpgradeableWithInit
- BatchCallerUpgradeableWithInit
- CallReceiverMockUpgradeableWithInit
- CallReceiverMockTrustingForwarderUpgradeableWithInit
- CompTimelockUpgradeableWithInit
- ConstructorMockUpgradeableWithInit
- ContextMockUpgradeableWithInit
- ContextMockCallerUpgradeableWithInit
- AccessControlERC20MintBaseUpgradeableWithInit
- AccessControlERC20MintMissingUpgradeableWithInit
- AccessControlERC20MintUpgradeableWithInit
- AccessControlModifiedUpgradeableWithInit
- AccessManagedERC20MintUpgradeableWithInit
- MyContractUpgradeableWithInit
- MyAccountERC7702UpgradeableWithInit
- MyFactoryAccountUpgradeableWithInit
- ERC20WithAutoMinerRewardUpgradeableWithInit
- ERC4626FeesUpgradeableWithInit
- MyGovernorUpgradeableWithInit
- MyTokenUpgradeableWithInit
- MyTokenTimestampBasedUpgradeableWithInit
- MyTokenWrappedUpgradeableWithInit
- MyNFTUpgradeableWithInit
- GameItemsUpgradeableWithInit
- MyERC115HolderContractUpgradeableWithInit
- GLDTokenUpgradeableWithInit
- ERC6909GameItemsUpgradeableWithInit
- GameItemUpgradeableWithInit
- Base64NFTUpgradeableWithInit
- BoxUpgradeableWithInit
- DummyImplementationUpgradeableWithInit
- DummyImplementationV2UpgradeableWithInit
- EIP712VerifierUpgradeableWithInit
- ERC1271WalletMockUpgradeableWithInit
- ERC1271MaliciousMockUpgradeableWithInit
- SupportsInterfaceWithLookupMockUpgradeableWithInit
- ERC165InterfacesSupportedUpgradeableWithInit
- ERC165MaliciousDataUpgradeableWithInit
- ERC165MissingDataUpgradeableWithInit
- ERC165NotSupportedUpgradeableWithInit
- ERC165ReturnBombMockUpgradeableWithInit
- ERC2771ContextMockUpgradeableWithInit
- ERC3156FlashBorrowerMockUpgradeableWithInit
- EtherReceiverMockUpgradeableWithInit
- GovernorCountingOverridableMockUpgradeableWithInit
- GovernorFractionalMockUpgradeableWithInit
- GovernorMockUpgradeableWithInit
- GovernorNoncesKeyedMockUpgradeableWithInit
- GovernorPreventLateQuorumMockUpgradeableWithInit
- GovernorProposalGuardianMockUpgradeableWithInit
- GovernorSequentialProposalIdMockUpgradeableWithInit
- GovernorStorageMockUpgradeableWithInit
- GovernorSuperQuorumMockUpgradeableWithInit
- GovernorTimelockAccessMockUpgradeableWithInit
- GovernorTimelockCompoundMockUpgradeableWithInit
- GovernorTimelockControlMockUpgradeableWithInit
- GovernorVoteMocksUpgradeableWithInit
- GovernorVotesSuperQuorumFractionMockUpgradeableWithInit
- GovernorWithParamsMockUpgradeableWithInit
- MerkleProofCustomHashMockUpgradeableWithInit
- MerkleTreeMockUpgradeableWithInit
- MulticallHelperUpgradeableWithInit
- PausableMockUpgradeableWithInit
- BadBeaconNoImplUpgradeableWithInit
- BadBeaconNotContractUpgradeableWithInit
- ClashingImplementationUpgradeableWithInit
- NonUpgradeableMockUpgradeableWithInit
- UUPSUpgradeableMockUpgradeableWithInit
- UUPSUpgradeableUnsafeMockUpgradeableWithInit
- UUPSUnsupportedProxiableUUIDUpgradeableWithInit
- ReentrancyAttackUpgradeableWithInit
- ReentrancyMockUpgradeableWithInit
- ReentrancyTransientMockUpgradeableWithInit
- Dummy1234UpgradeableWithInit
- StorageSlotMockUpgradeableWithInit
- TimelockReentrantUpgradeableWithInit
- ERC1155ReceiverMockUpgradeableWithInit
- ERC1363ForceApproveMockUpgradeableWithInit
- ERC1363NoReturnMockUpgradeableWithInit
- ERC1363ReceiverMockUpgradeableWithInit
- ERC1363ReturnFalseOnERC20MockUpgradeableWithInit
- ERC1363ReturnFalseMockUpgradeableWithInit
- ERC1363SpenderMockUpgradeableWithInit
- ERC20ApprovalMockUpgradeableWithInit
- ERC20BridgeableMockUpgradeableWithInit
- ERC20DecimalsMockUpgradeableWithInit
- ERC20ExcessDecimalsMockUpgradeableWithInit
- ERC20FlashMintMockUpgradeableWithInit
- ERC20ForceApproveMockUpgradeableWithInit
- ERC20GetterHelperUpgradeableWithInit
- ERC20MockUpgradeableWithInit
- ERC20MulticallMockUpgradeableWithInit
- ERC20NoReturnMockUpgradeableWithInit
- ERC20ReentrantUpgradeableWithInit
- ERC20ReturnFalseMockUpgradeableWithInit
- ERC20VotesExtendedMockUpgradeableWithInit
- ERC20VotesExtendedTimestampMockUpgradeableWithInit
- ERC20VotesLegacyMockUpgradeableWithInit
- ERC20VotesTimestampMockUpgradeableWithInit
- ERC721VotesTimestampMockUpgradeableWithInit
- ERC4626LimitsMockUpgradeableWithInit
- ERC4626MockUpgradeableWithInit
- ERC4626OffsetMockUpgradeableWithInit
- ERC4626FeesMockUpgradeableWithInit
- ERC721ConsecutiveEnumerableMockUpgradeableWithInit
- ERC721ConsecutiveMockUpgradeableWithInit
- ERC721ConsecutiveNoConstructorMintMockUpgradeableWithInit
- ERC721ReceiverMockUpgradeableWithInit
- ERC721URIStorageMockUpgradeableWithInit
- TransientSlotMockUpgradeableWithInit
- UpgradeableBeaconMockUpgradeableWithInit
- UpgradeableBeaconReentrantMockUpgradeableWithInit
- ERC7739ECDSAMockUpgradeableWithInit
- ERC7739P256MockUpgradeableWithInit
- ERC7739RSAMockUpgradeableWithInit
- VotesExtendedMockUpgradeableWithInit
- VotesExtendedTimestampMockUpgradeableWithInit
- VotesMockUpgradeableWithInit
- VotesTimestampMockUpgradeableWithInit
- ERC2981UpgradeableWithInit
- ERC1155UpgradeableWithInit
- ERC1155BurnableUpgradeableWithInit
- ERC1155PausableUpgradeableWithInit
- ERC1155SupplyUpgradeableWithInit
- ERC1155URIStorageUpgradeableWithInit
- ERC1155HolderUpgradeableWithInit
- ERC20UpgradeableWithInit
- ERC20TemporaryApprovalUpgradeableWithInit
- ERC1363UpgradeableWithInit
- ERC20BurnableUpgradeableWithInit
- ERC20CappedUpgradeableWithInit
- ERC20FlashMintUpgradeableWithInit
- ERC20PausableUpgradeableWithInit
- ERC20PermitUpgradeableWithInit
- ERC20VotesUpgradeableWithInit
- ERC20WrapperUpgradeableWithInit
- ERC4626UpgradeableWithInit
- ERC6909UpgradeableWithInit
- ERC6909ContentURIUpgradeableWithInit
- ERC6909MetadataUpgradeableWithInit
- ERC6909TokenSupplyUpgradeableWithInit
- ERC721UpgradeableWithInit
- ERC721BurnableUpgradeableWithInit
- ERC721ConsecutiveUpgradeableWithInit
- ERC721EnumerableUpgradeableWithInit
- ERC721PausableUpgradeableWithInit
- ERC721RoyaltyUpgradeableWithInit
- ERC721URIStorageUpgradeableWithInit
- ERC721VotesUpgradeableWithInit
- ERC721WrapperUpgradeableWithInit
- ERC721HolderUpgradeableWithInit
- ContextUpgradeableWithInit
- EIP712UpgradeableWithInit
- MultiSignerERC7913UpgradeableWithInit
- MultiSignerERC7913WeightedUpgradeableWithInit
- SignerECDSAUpgradeableWithInit
- SignerERC7913UpgradeableWithInit
- SignerP256UpgradeableWithInit
- SignerRSAUpgradeableWithInit
- ERC165UpgradeableWithInit
- MulticallUpgradeableWithInit
- NoncesUpgradeableWithInit
- NoncesKeyedUpgradeableWithInit
- PausableUpgradeableWithInit
- ReentrancyGuardUpgradeableWithInit
- ReentrancyGuardTransientUpgradeableWithInit
Contents
- SupportsInterfaceWithLookupMockUpgradeable
- ERC165InterfacesSupportedUpgradeable
- ERC165MaliciousDataUpgradeable
- ERC165MissingDataUpgradeable
- ERC165NotSupportedUpgradeable
- ERC165ReturnBombMockUpgradeable
SupportsInterfaceWithLookupMockUpgradeable
Inherits: Initializable, IERC165
https://eips.ethereum.org/EIPS/eip-214#specification From the specification:
Any attempts to make state-changing operations inside an execution instance with STATIC set to true will instead throw an exception. These operations include [...], LOG0, LOG1, LOG2, [...] therefore, because this contract is staticcall'd we need to not emit events (which is how solidity-coverage works) solidity-coverage ignores the /mocks folder, so we duplicate its implementation here to avoid instrumenting it
State Variables
INTERFACE_ID_ERC165
bytes4 public constant INTERFACE_ID_ERC165 = 0x01ffc9a7;
_supportedInterfaces
A mapping of interface id to whether or not it's supported.
mapping(bytes4 interfaceId => bool) private _supportedInterfaces;
Functions
__SupportsInterfaceWithLookupMock_init
A contract implementing SupportsInterfaceWithLookup implement ERC-165 itself.
function __SupportsInterfaceWithLookupMock_init() internal onlyInitializing;
__SupportsInterfaceWithLookupMock_init_unchained
function __SupportsInterfaceWithLookupMock_init_unchained() internal onlyInitializing;
supportsInterface
Implement supportsInterface(bytes4) using a lookup table.
function supportsInterface(bytes4 interfaceId) public view override returns (bool);
_registerInterface
Private method for registering an interface.
function _registerInterface(bytes4 interfaceId) internal;
ERC165InterfacesSupportedUpgradeable
Inherits: Initializable, SupportsInterfaceWithLookupMockUpgradeable
Functions
__ERC165InterfacesSupported_init
function __ERC165InterfacesSupported_init(bytes4[] memory interfaceIds) internal onlyInitializing;
__ERC165InterfacesSupported_init_unchained
function __ERC165InterfacesSupported_init_unchained(bytes4[] memory interfaceIds) internal onlyInitializing;
ERC165MaliciousDataUpgradeable
Inherits: Initializable
Functions
__ERC165MaliciousData_init
function __ERC165MaliciousData_init() internal onlyInitializing;
__ERC165MaliciousData_init_unchained
function __ERC165MaliciousData_init_unchained() internal onlyInitializing;
supportsInterface
function supportsInterface(bytes4) public pure returns (bool);
ERC165MissingDataUpgradeable
Inherits: Initializable
Functions
__ERC165MissingData_init
function __ERC165MissingData_init() internal onlyInitializing;
__ERC165MissingData_init_unchained
function __ERC165MissingData_init_unchained() internal onlyInitializing;
supportsInterface
function supportsInterface(bytes4 interfaceId) public view;
ERC165NotSupportedUpgradeable
Inherits: Initializable
Functions
__ERC165NotSupported_init
function __ERC165NotSupported_init() internal onlyInitializing;
__ERC165NotSupported_init_unchained
function __ERC165NotSupported_init_unchained() internal onlyInitializing;
ERC165ReturnBombMockUpgradeable
Inherits: Initializable, IERC165
Functions
__ERC165ReturnBombMock_init
function __ERC165ReturnBombMock_init() internal onlyInitializing;
__ERC165ReturnBombMock_init_unchained
function __ERC165ReturnBombMock_init_unchained() internal onlyInitializing;
supportsInterface
function supportsInterface(bytes4 interfaceId) public pure override returns (bool);
Contents
- modules
- utils
- AccountMockUpgradeable
- AccountECDSAMockUpgradeable
- AccountP256MockUpgradeable
- AccountRSAMockUpgradeable
- AccountERC7702MockUpgradeable
- AccountERC7702WithModulesMockUpgradeable
- AccountERC7579MockUpgradeable
- AccountERC7579HookedMockUpgradeable
- AccountERC7913MockUpgradeable
- AccountMultiSignerMockUpgradeable
- AccountMultiSignerWeightedMockUpgradeable
Contents
- ERC7579ModuleMockUpgradeable
- ERC7579HookMockUpgradeable
- ERC7579FallbackHandlerMockUpgradeable
- ERC7579ValidatorMockUpgradeable
ERC7579ModuleMockUpgradeable
Inherits: Initializable, IERC7579Module
State Variables
_moduleTypeId
uint256 private _moduleTypeId;
Functions
__ERC7579ModuleMock_init
function __ERC7579ModuleMock_init(uint256 moduleTypeId) internal onlyInitializing;
__ERC7579ModuleMock_init_unchained
function __ERC7579ModuleMock_init_unchained(uint256 moduleTypeId) internal onlyInitializing;
onInstall
function onInstall(bytes calldata data) public virtual;
onUninstall
function onUninstall(bytes calldata data) public virtual;
isModuleType
function isModuleType(uint256 moduleTypeId) external view returns (bool);
Events
ModuleInstalledReceived
event ModuleInstalledReceived(address account, bytes data);
ModuleUninstalledReceived
event ModuleUninstalledReceived(address account, bytes data);
ERC7579HookMockUpgradeable
Inherits: Initializable, ERC7579ModuleMockUpgradeable, IERC7579Hook
Functions
__ERC7579HookMock_init
function __ERC7579HookMock_init() internal onlyInitializing;
__ERC7579HookMock_init_unchained
function __ERC7579HookMock_init_unchained() internal onlyInitializing;
preCheck
function preCheck(address msgSender, uint256 value, bytes calldata msgData) external returns (bytes memory hookData);
postCheck
function postCheck(bytes calldata hookData) external;
Events
PreCheck
event PreCheck(address sender, uint256 value, bytes data);
PostCheck
event PostCheck(bytes hookData);
ERC7579FallbackHandlerMockUpgradeable
Inherits: Initializable, ERC7579ModuleMockUpgradeable
Functions
__ERC7579FallbackHandlerMock_init
function __ERC7579FallbackHandlerMock_init() internal onlyInitializing;
__ERC7579FallbackHandlerMock_init_unchained
function __ERC7579FallbackHandlerMock_init_unchained() internal onlyInitializing;
_msgAccount
function _msgAccount() internal view returns (address);
_msgSender
function _msgSender() internal pure returns (address);
_msgData
function _msgData() internal pure returns (bytes calldata);
callPayable
function callPayable() public payable;
callView
function callView() public view returns (address, address);
callRevert
function callRevert() public pure;
Events
ERC7579FallbackHandlerMockCalled
event ERC7579FallbackHandlerMockCalled(address account, address sender, uint256 value, bytes data);
Errors
ERC7579FallbackHandlerMockRevert
error ERC7579FallbackHandlerMockRevert();
ERC7579ValidatorMockUpgradeable
Inherits: Initializable, ERC7579ModuleMockUpgradeable, IERC7579Validator
State Variables
_associatedSigners
mapping(address sender => address signer) private _associatedSigners;
Functions
__ERC7579ValidatorMock_init
function __ERC7579ValidatorMock_init() internal onlyInitializing;
__ERC7579ValidatorMock_init_unchained
function __ERC7579ValidatorMock_init_unchained() internal onlyInitializing;
onInstall
function onInstall(bytes calldata data) public virtual override(IERC7579Module, ERC7579ModuleMockUpgradeable);
onUninstall
function onUninstall(bytes calldata data) public virtual override(IERC7579Module, ERC7579ModuleMockUpgradeable);
validateUserOp
function validateUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash)
public
view
virtual
returns (uint256);
isValidSignatureWithSender
function isValidSignatureWithSender(address, bytes32 hash, bytes calldata signature)
public
view
virtual
returns (bytes4);
Contents
ERC7579UtilsGlobalMockUpgradeable
Inherits: Initializable
Functions
__ERC7579UtilsGlobalMock_init
function __ERC7579UtilsGlobalMock_init() internal onlyInitializing;
__ERC7579UtilsGlobalMock_init_unchained
function __ERC7579UtilsGlobalMock_init_unchained() internal onlyInitializing;
eqCallTypeGlobal
function eqCallTypeGlobal(CallType callType1, CallType callType2) internal pure returns (bool);
eqExecTypeGlobal
function eqExecTypeGlobal(ExecType execType1, ExecType execType2) internal pure returns (bool);
eqModeSelectorGlobal
function eqModeSelectorGlobal(ModeSelector modeSelector1, ModeSelector modeSelector2) internal pure returns (bool);
eqModePayloadGlobal
function eqModePayloadGlobal(ModePayload modePayload1, ModePayload modePayload2) internal pure returns (bool);
AccountMockUpgradeable
Inherits: Initializable, Account, ERC7739Upgradeable, ERC7821, ERC721HolderUpgradeable, ERC1155HolderUpgradeable
Functions
__AccountMock_init
function __AccountMock_init() internal onlyInitializing;
__AccountMock_init_unchained
function __AccountMock_init_unchained() internal onlyInitializing;
_rawSignatureValidation
Validates a user operation with a boolean signature.
function _rawSignatureValidation(bytes32 hash, bytes calldata signature) internal pure override returns (bool);
_erc7821AuthorizedExecutor
*Access control mechanism for the {execute} function. By default, only the contract itself is allowed to execute. Override this function to implement custom access control, for example to allow the ERC-4337 entrypoint to execute.
function _erc7821AuthorizedExecutor(
address caller,
bytes32 mode,
bytes calldata executionData
) internal view virtual override returns (bool) {
return caller == address(entryPoint()) || super._erc7821AuthorizedExecutor(caller, mode, executionData);
}
```*
```solidity
function _erc7821AuthorizedExecutor(address caller, bytes32 mode, bytes calldata executionData)
internal
view
virtual
override
returns (bool);
AccountECDSAMockUpgradeable
Inherits: Initializable, Account, SignerECDSAUpgradeable, ERC7739Upgradeable, ERC7821, ERC721HolderUpgradeable, ERC1155HolderUpgradeable
Functions
__AccountECDSAMock_init
function __AccountECDSAMock_init() internal onlyInitializing;
__AccountECDSAMock_init_unchained
function __AccountECDSAMock_init_unchained() internal onlyInitializing;
_erc7821AuthorizedExecutor
*Access control mechanism for the {execute} function. By default, only the contract itself is allowed to execute. Override this function to implement custom access control, for example to allow the ERC-4337 entrypoint to execute.
function _erc7821AuthorizedExecutor(
address caller,
bytes32 mode,
bytes calldata executionData
) internal view virtual override returns (bool) {
return caller == address(entryPoint()) || super._erc7821AuthorizedExecutor(caller, mode, executionData);
}
```*
```solidity
function _erc7821AuthorizedExecutor(address caller, bytes32 mode, bytes calldata executionData)
internal
view
virtual
override
returns (bool);
AccountP256MockUpgradeable
Inherits: Initializable, Account, SignerP256Upgradeable, ERC7739Upgradeable, ERC7821, ERC721HolderUpgradeable, ERC1155HolderUpgradeable
Functions
__AccountP256Mock_init
function __AccountP256Mock_init() internal onlyInitializing;
__AccountP256Mock_init_unchained
function __AccountP256Mock_init_unchained() internal onlyInitializing;
_erc7821AuthorizedExecutor
*Access control mechanism for the {execute} function. By default, only the contract itself is allowed to execute. Override this function to implement custom access control, for example to allow the ERC-4337 entrypoint to execute.
function _erc7821AuthorizedExecutor(
address caller,
bytes32 mode,
bytes calldata executionData
) internal view virtual override returns (bool) {
return caller == address(entryPoint()) || super._erc7821AuthorizedExecutor(caller, mode, executionData);
}
```*
```solidity
function _erc7821AuthorizedExecutor(address caller, bytes32 mode, bytes calldata executionData)
internal
view
virtual
override
returns (bool);
AccountRSAMockUpgradeable
Inherits: Initializable, Account, SignerRSAUpgradeable, ERC7739Upgradeable, ERC7821, ERC721HolderUpgradeable, ERC1155HolderUpgradeable
Functions
__AccountRSAMock_init
function __AccountRSAMock_init() internal onlyInitializing;
__AccountRSAMock_init_unchained
function __AccountRSAMock_init_unchained() internal onlyInitializing;
_erc7821AuthorizedExecutor
*Access control mechanism for the {execute} function. By default, only the contract itself is allowed to execute. Override this function to implement custom access control, for example to allow the ERC-4337 entrypoint to execute.
function _erc7821AuthorizedExecutor(
address caller,
bytes32 mode,
bytes calldata executionData
) internal view virtual override returns (bool) {
return caller == address(entryPoint()) || super._erc7821AuthorizedExecutor(caller, mode, executionData);
}
```*
```solidity
function _erc7821AuthorizedExecutor(address caller, bytes32 mode, bytes calldata executionData)
internal
view
virtual
override
returns (bool);
AccountERC7702MockUpgradeable
Inherits: Initializable, Account, SignerERC7702, ERC7739Upgradeable, ERC7821, ERC721HolderUpgradeable, ERC1155HolderUpgradeable
Functions
__AccountERC7702Mock_init
function __AccountERC7702Mock_init() internal onlyInitializing;
__AccountERC7702Mock_init_unchained
function __AccountERC7702Mock_init_unchained() internal onlyInitializing;
_erc7821AuthorizedExecutor
*Access control mechanism for the {execute} function. By default, only the contract itself is allowed to execute. Override this function to implement custom access control, for example to allow the ERC-4337 entrypoint to execute.
function _erc7821AuthorizedExecutor(
address caller,
bytes32 mode,
bytes calldata executionData
) internal view virtual override returns (bool) {
return caller == address(entryPoint()) || super._erc7821AuthorizedExecutor(caller, mode, executionData);
}
```*
```solidity
function _erc7821AuthorizedExecutor(address caller, bytes32 mode, bytes calldata executionData)
internal
view
virtual
override
returns (bool);
AccountERC7702WithModulesMockUpgradeable
Inherits: Initializable, Account, AccountERC7579Upgradeable, SignerERC7702, ERC7739Upgradeable, ERC721HolderUpgradeable, ERC1155HolderUpgradeable
Functions
__AccountERC7702WithModulesMock_init
function __AccountERC7702WithModulesMock_init() internal onlyInitializing;
__AccountERC7702WithModulesMock_init_unchained
function __AccountERC7702WithModulesMock_init_unchained() internal onlyInitializing;
_validateUserOp
function _validateUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash)
internal
virtual
override(Account, AccountERC7579Upgradeable)
returns (uint256);
isValidSignature
Resolve implementation of ERC-1271 by both ERC7739 and AccountERC7579 to support both schemes.
function isValidSignature(bytes32 hash, bytes calldata signature)
public
view
virtual
override(ERC7739Upgradeable, AccountERC7579Upgradeable)
returns (bytes4);
_rawSignatureValidation
Enable signature using the ERC-7702 signer.
function _rawSignatureValidation(bytes32 hash, bytes calldata signature)
internal
view
virtual
override(AbstractSigner, AccountERC7579Upgradeable, SignerERC7702)
returns (bool);
AccountERC7579MockUpgradeable
Inherits: Initializable, AccountERC7579Upgradeable
Functions
__AccountERC7579Mock_init
function __AccountERC7579Mock_init(address validator, bytes memory initData) internal onlyInitializing;
__AccountERC7579Mock_init_unchained
function __AccountERC7579Mock_init_unchained(address validator, bytes memory initData) internal onlyInitializing;
AccountERC7579HookedMockUpgradeable
Inherits: Initializable, AccountERC7579HookedUpgradeable
Functions
__AccountERC7579HookedMock_init
function __AccountERC7579HookedMock_init(address validator, bytes memory initData) internal onlyInitializing;
__AccountERC7579HookedMock_init_unchained
function __AccountERC7579HookedMock_init_unchained(address validator, bytes memory initData)
internal
onlyInitializing;
AccountERC7913MockUpgradeable
Inherits: Initializable, Account, SignerERC7913Upgradeable, ERC7739Upgradeable, ERC7821, ERC721HolderUpgradeable, ERC1155HolderUpgradeable
Functions
__AccountERC7913Mock_init
function __AccountERC7913Mock_init() internal onlyInitializing;
__AccountERC7913Mock_init_unchained
function __AccountERC7913Mock_init_unchained() internal onlyInitializing;
_erc7821AuthorizedExecutor
*Access control mechanism for the {execute} function. By default, only the contract itself is allowed to execute. Override this function to implement custom access control, for example to allow the ERC-4337 entrypoint to execute.
function _erc7821AuthorizedExecutor(
address caller,
bytes32 mode,
bytes calldata executionData
) internal view virtual override returns (bool) {
return caller == address(entryPoint()) || super._erc7821AuthorizedExecutor(caller, mode, executionData);
}
```*
```solidity
function _erc7821AuthorizedExecutor(address caller, bytes32 mode, bytes calldata executionData)
internal
view
virtual
override
returns (bool);
AccountMultiSignerMockUpgradeable
Inherits: Initializable, Account, MultiSignerERC7913Upgradeable, ERC7739Upgradeable, ERC7821, ERC721HolderUpgradeable, ERC1155HolderUpgradeable
Functions
__AccountMultiSignerMock_init
function __AccountMultiSignerMock_init() internal onlyInitializing;
__AccountMultiSignerMock_init_unchained
function __AccountMultiSignerMock_init_unchained() internal onlyInitializing;
_erc7821AuthorizedExecutor
*Access control mechanism for the {execute} function. By default, only the contract itself is allowed to execute. Override this function to implement custom access control, for example to allow the ERC-4337 entrypoint to execute.
function _erc7821AuthorizedExecutor(
address caller,
bytes32 mode,
bytes calldata executionData
) internal view virtual override returns (bool) {
return caller == address(entryPoint()) || super._erc7821AuthorizedExecutor(caller, mode, executionData);
}
```*
```solidity
function _erc7821AuthorizedExecutor(address caller, bytes32 mode, bytes calldata executionData)
internal
view
virtual
override
returns (bool);
AccountMultiSignerWeightedMockUpgradeable
Inherits: Initializable, Account, MultiSignerERC7913WeightedUpgradeable, ERC7739Upgradeable, ERC7821, ERC721HolderUpgradeable, ERC1155HolderUpgradeable
Functions
__AccountMultiSignerWeightedMock_init
function __AccountMultiSignerWeightedMock_init() internal onlyInitializing;
__AccountMultiSignerWeightedMock_init_unchained
function __AccountMultiSignerWeightedMock_init_unchained() internal onlyInitializing;
_erc7821AuthorizedExecutor
*Access control mechanism for the {execute} function. By default, only the contract itself is allowed to execute. Override this function to implement custom access control, for example to allow the ERC-4337 entrypoint to execute.
function _erc7821AuthorizedExecutor(
address caller,
bytes32 mode,
bytes calldata executionData
) internal view virtual override returns (bool) {
return caller == address(entryPoint()) || super._erc7821AuthorizedExecutor(caller, mode, executionData);
}
```*
```solidity
function _erc7821AuthorizedExecutor(address caller, bytes32 mode, bytes calldata executionData)
internal
view
virtual
override
returns (bool);
Contents
CompTimelockUpgradeable
Inherits: Initializable
Copyright 2020 Compound Labs, Inc. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
State Variables
GRACE_PERIOD
uint256 public constant GRACE_PERIOD = 14 days;
MINIMUM_DELAY
uint256 public constant MINIMUM_DELAY = 2 days;
MAXIMUM_DELAY
uint256 public constant MAXIMUM_DELAY = 30 days;
admin
address public admin;
pendingAdmin
address public pendingAdmin;
delay
uint256 public delay;
queuedTransactions
mapping(bytes32 => bool) public queuedTransactions;
Functions
__CompTimelock_init
function __CompTimelock_init(address admin_, uint256 delay_) internal onlyInitializing;
__CompTimelock_init_unchained
function __CompTimelock_init_unchained(address admin_, uint256 delay_) internal onlyInitializing;
receive
receive() external payable;
setDelay
function setDelay(uint256 delay_) public;
acceptAdmin
function acceptAdmin() public;
setPendingAdmin
function setPendingAdmin(address pendingAdmin_) public;
queueTransaction
function queueTransaction(address target, uint256 value, string memory signature, bytes memory data, uint256 eta)
public
returns (bytes32);
cancelTransaction
function cancelTransaction(address target, uint256 value, string memory signature, bytes memory data, uint256 eta)
public;
executeTransaction
function executeTransaction(address target, uint256 value, string memory signature, bytes memory data, uint256 eta)
public
payable
returns (bytes memory);
getBlockTimestamp
function getBlockTimestamp() internal view returns (uint256);
Events
NewAdmin
event NewAdmin(address indexed newAdmin);
NewPendingAdmin
event NewPendingAdmin(address indexed newPendingAdmin);
NewDelay
event NewDelay(uint256 indexed newDelay);
CancelTransaction
event CancelTransaction(
bytes32 indexed txHash, address indexed target, uint256 value, string signature, bytes data, uint256 eta
);
ExecuteTransaction
event ExecuteTransaction(
bytes32 indexed txHash, address indexed target, uint256 value, string signature, bytes data, uint256 eta
);
QueueTransaction
event QueueTransaction(
bytes32 indexed txHash, address indexed target, uint256 value, string signature, bytes data, uint256 eta
);
Contents
- access-control
- account
- governance
- token
- utilities
- ERC20WithAutoMinerRewardUpgradeable
- ERC4626FeesUpgradeable
- MyNFTUpgradeable
Contents
- AccessControlERC20MintBaseUpgradeable
- AccessControlERC20MintMissingUpgradeable
- AccessControlERC20MintUpgradeable
- AccessControlModifiedUpgradeable
- AccessManagedERC20MintUpgradeable
- MyContractUpgradeable
AccessControlERC20MintBaseUpgradeable
Inherits: Initializable, ERC20Upgradeable, AccessControlUpgradeable
State Variables
MINTER_ROLE
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
Functions
__AccessControlERC20MintBase_init
function __AccessControlERC20MintBase_init(address minter) internal onlyInitializing;
__AccessControlERC20MintBase_init_unchained
function __AccessControlERC20MintBase_init_unchained(address minter) internal onlyInitializing;
mint
function mint(address to, uint256 amount) public;
Errors
CallerNotMinter
error CallerNotMinter(address caller);
AccessControlERC20MintMissingUpgradeable
Inherits: Initializable, ERC20Upgradeable, AccessControlUpgradeable
State Variables
MINTER_ROLE
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
BURNER_ROLE
bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");
Functions
__AccessControlERC20MintMissing_init
function __AccessControlERC20MintMissing_init() internal onlyInitializing;
__AccessControlERC20MintMissing_init_unchained
function __AccessControlERC20MintMissing_init_unchained() internal onlyInitializing;
mint
function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE);
burn
function burn(address from, uint256 amount) public onlyRole(BURNER_ROLE);
AccessControlERC20MintUpgradeable
Inherits: Initializable, ERC20Upgradeable, AccessControlUpgradeable
State Variables
MINTER_ROLE
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
BURNER_ROLE
bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");
Functions
__AccessControlERC20Mint_init
function __AccessControlERC20Mint_init(address minter, address burner) internal onlyInitializing;
__AccessControlERC20Mint_init_unchained
function __AccessControlERC20Mint_init_unchained(address minter, address burner) internal onlyInitializing;
mint
function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE);
burn
function burn(address from, uint256 amount) public onlyRole(BURNER_ROLE);
AccessControlModifiedUpgradeable
Inherits: Initializable, AccessControlUpgradeable
Functions
__AccessControlModified_init
function __AccessControlModified_init() internal onlyInitializing;
__AccessControlModified_init_unchained
function __AccessControlModified_init_unchained() internal onlyInitializing;
revokeRole
function revokeRole(bytes32, address) public pure override;
Errors
AccessControlNonRevocable
error AccessControlNonRevocable();
AccessManagedERC20MintUpgradeable
Inherits: Initializable, ERC20Upgradeable, AccessManagedUpgradeable
Functions
__AccessManagedERC20Mint_init
function __AccessManagedERC20Mint_init(address manager) internal onlyInitializing;
__AccessManagedERC20Mint_init_unchained
function __AccessManagedERC20Mint_init_unchained(address) internal onlyInitializing;
mint
function mint(address to, uint256 amount) public restricted;
MyContractUpgradeable
Inherits: Initializable, OwnableUpgradeable
Functions
__MyContract_init
function __MyContract_init(address initialOwner) internal onlyInitializing;
__MyContract_init_unchained
function __MyContract_init_unchained(address) internal onlyInitializing;
normalThing
function normalThing() public;
specialThing
function specialThing() public onlyOwner;
Contents
MyAccountERC7702Upgradeable
Inherits: Initializable, Account, SignerERC7702, ERC7821, ERC721HolderUpgradeable, ERC1155HolderUpgradeable
Functions
__MyAccountERC7702_init
function __MyAccountERC7702_init() internal onlyInitializing;
__MyAccountERC7702_init_unchained
function __MyAccountERC7702_init_unchained() internal onlyInitializing;
_erc7821AuthorizedExecutor
Allows the entry point as an authorized executor.
function _erc7821AuthorizedExecutor(address caller, bytes32 mode, bytes calldata executionData)
internal
view
virtual
override
returns (bool);
MyFactoryAccountUpgradeable
Inherits: Initializable
A factory contract to create accounts on demand.
State Variables
_impl
address private _impl;
Functions
__MyFactoryAccount_init
function __MyFactoryAccount_init(address impl_) internal onlyInitializing;
__MyFactoryAccount_init_unchained
function __MyFactoryAccount_init_unchained(address impl_) internal onlyInitializing;
predictAddress
Predict the address of the account
function predictAddress(bytes calldata callData) public view returns (address);
cloneAndInitialize
Create clone accounts on demand
function cloneAndInitialize(bytes calldata callData) public returns (address);
Contents
MyGovernorUpgradeable
Inherits: Initializable, GovernorUpgradeable, GovernorCountingSimpleUpgradeable, GovernorVotesUpgradeable, GovernorVotesQuorumFractionUpgradeable, GovernorTimelockControlUpgradeable
Functions
__MyGovernor_init
function __MyGovernor_init(IVotes _token, TimelockControllerUpgradeable _timelock) internal onlyInitializing;
__MyGovernor_init_unchained
function __MyGovernor_init_unchained(IVotes, TimelockControllerUpgradeable) internal onlyInitializing;
votingDelay
function votingDelay() public pure override returns (uint256);
votingPeriod
function votingPeriod() public pure override returns (uint256);
proposalThreshold
function proposalThreshold() public pure override returns (uint256);
state
function state(uint256 proposalId)
public
view
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable)
returns (ProposalState);
proposalNeedsQueuing
function proposalNeedsQueuing(uint256 proposalId)
public
view
virtual
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable)
returns (bool);
_queueOperations
function _queueOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) returns (uint48);
_executeOperations
function _executeOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(GovernorUpgradeable, GovernorTimelockControlUpgradeable);
_cancel
function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
internal
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable)
returns (uint256);
_executor
function _executor()
internal
view
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable)
returns (address);
MyTokenTimestampBasedUpgradeable
Inherits: Initializable, ERC20Upgradeable, ERC20PermitUpgradeable, ERC20VotesUpgradeable
Functions
__MyTokenTimestampBased_init
function __MyTokenTimestampBased_init() internal onlyInitializing;
__MyTokenTimestampBased_init_unchained
function __MyTokenTimestampBased_init_unchained() internal onlyInitializing;
clock
function clock() public view override returns (uint48);
CLOCK_MODE
function CLOCK_MODE() public pure override returns (string memory);
_update
function _update(address from, address to, uint256 amount) internal override(ERC20Upgradeable, ERC20VotesUpgradeable);
nonces
function nonces(address owner)
public
view
virtual
override(ERC20PermitUpgradeable, NoncesUpgradeable)
returns (uint256);
MyTokenUpgradeable
Inherits: Initializable, ERC20Upgradeable, ERC20PermitUpgradeable, ERC20VotesUpgradeable
Functions
__MyToken_init
function __MyToken_init() internal onlyInitializing;
__MyToken_init_unchained
function __MyToken_init_unchained() internal onlyInitializing;
_update
function _update(address from, address to, uint256 amount) internal override(ERC20Upgradeable, ERC20VotesUpgradeable);
nonces
function nonces(address owner)
public
view
virtual
override(ERC20PermitUpgradeable, NoncesUpgradeable)
returns (uint256);
MyTokenWrappedUpgradeable
Inherits: Initializable, ERC20Upgradeable, ERC20PermitUpgradeable, ERC20VotesUpgradeable, ERC20WrapperUpgradeable
Functions
__MyTokenWrapped_init
function __MyTokenWrapped_init(IERC20 wrappedToken) internal onlyInitializing;
__MyTokenWrapped_init_unchained
function __MyTokenWrapped_init_unchained(IERC20) internal onlyInitializing;
decimals
function decimals() public view override(ERC20Upgradeable, ERC20WrapperUpgradeable) returns (uint8);
_update
function _update(address from, address to, uint256 amount) internal override(ERC20Upgradeable, ERC20VotesUpgradeable);
nonces
function nonces(address owner)
public
view
virtual
override(ERC20PermitUpgradeable, NoncesUpgradeable)
returns (uint256);
Contents
Contents
GameItemsUpgradeable
Inherits: Initializable, ERC1155Upgradeable
State Variables
GOLD
uint256 public constant GOLD = 0;
SILVER
uint256 public constant SILVER = 1;
THORS_HAMMER
uint256 public constant THORS_HAMMER = 2;
SWORD
uint256 public constant SWORD = 3;
SHIELD
uint256 public constant SHIELD = 4;
Functions
__GameItems_init
function __GameItems_init() internal onlyInitializing;
__GameItems_init_unchained
function __GameItems_init_unchained() internal onlyInitializing;
MyERC115HolderContractUpgradeable
Inherits: Initializable, ERC1155HolderUpgradeable
Functions
__MyERC115HolderContract_init
function __MyERC115HolderContract_init() internal onlyInitializing;
__MyERC115HolderContract_init_unchained
function __MyERC115HolderContract_init_unchained() internal onlyInitializing;
Contents
GLDTokenUpgradeable
Inherits: Initializable, ERC20Upgradeable
Functions
__GLDToken_init
function __GLDToken_init(uint256 initialSupply) internal onlyInitializing;
__GLDToken_init_unchained
function __GLDToken_init_unchained(uint256 initialSupply) internal onlyInitializing;
Contents
ERC6909GameItemsUpgradeable
Inherits: Initializable, ERC6909MetadataUpgradeable
State Variables
GOLD
uint256 public constant GOLD = 0;
SILVER
uint256 public constant SILVER = 1;
THORS_HAMMER
uint256 public constant THORS_HAMMER = 2;
SWORD
uint256 public constant SWORD = 3;
SHIELD
uint256 public constant SHIELD = 4;
Functions
__ERC6909GameItems_init
function __ERC6909GameItems_init() internal onlyInitializing;
__ERC6909GameItems_init_unchained
function __ERC6909GameItems_init_unchained() internal onlyInitializing;
Contents
GameItemUpgradeable
Inherits: Initializable, ERC721URIStorageUpgradeable
State Variables
_nextTokenId
uint256 private _nextTokenId;
Functions
__GameItem_init
function __GameItem_init() internal onlyInitializing;
__GameItem_init_unchained
function __GameItem_init_unchained() internal onlyInitializing;
awardItem
function awardItem(address player, string memory tokenURI) public returns (uint256);
Contents
Base64NFTUpgradeable
Inherits: Initializable, ERC721Upgradeable
Functions
__Base64NFT_init
function __Base64NFT_init() internal onlyInitializing;
__Base64NFT_init_unchained
function __Base64NFT_init_unchained() internal onlyInitializing;
tokenURI
function tokenURI(uint256 tokenId) public pure override returns (string memory);
BoxUpgradeable
Inherits: Initializable, MulticallUpgradeable
Functions
__Box_init
function __Box_init() internal onlyInitializing;
__Box_init_unchained
function __Box_init_unchained() internal onlyInitializing;
foo
function foo() public;
bar
function bar() public;
ERC20WithAutoMinerRewardUpgradeable
Inherits: Initializable, ERC20Upgradeable
Functions
__ERC20WithAutoMinerReward_init
function __ERC20WithAutoMinerReward_init() internal onlyInitializing;
__ERC20WithAutoMinerReward_init_unchained
function __ERC20WithAutoMinerReward_init_unchained() internal onlyInitializing;
_mintMinerReward
function _mintMinerReward() internal;
_update
function _update(address from, address to, uint256 value) internal virtual override;
ERC4626FeesUpgradeable
Inherits: Initializable, ERC4626Upgradeable
ERC-4626 vault with entry/exit fees expressed in https://en.wikipedia.org/wiki/Basis_point[basis point (bp)]. NOTE: The contract charges fees in terms of assets, not shares. This means that the fees are calculated based on the amount of assets that are being deposited or withdrawn, and not based on the amount of shares that are being minted or redeemed. This is an opinionated design decision that should be taken into account when integrating this contract. WARNING: This contract has not been audited and shouldn't be considered production ready. Consider using it with caution.
State Variables
_BASIS_POINT_SCALE
uint256 private constant _BASIS_POINT_SCALE = 1e4;
Functions
__ERC4626Fees_init
function __ERC4626Fees_init() internal onlyInitializing;
__ERC4626Fees_init_unchained
function __ERC4626Fees_init_unchained() internal onlyInitializing;
previewDeposit
Preview taking an entry fee on deposit. See IERC4626-previewDeposit.
function previewDeposit(uint256 assets) public view virtual override returns (uint256);
previewMint
Preview adding an entry fee on mint. See IERC4626-previewMint.
function previewMint(uint256 shares) public view virtual override returns (uint256);
previewWithdraw
Preview adding an exit fee on withdraw. See IERC4626-previewWithdraw.
function previewWithdraw(uint256 assets) public view virtual override returns (uint256);
previewRedeem
Preview taking an exit fee on redeem. See IERC4626-previewRedeem.
function previewRedeem(uint256 shares) public view virtual override returns (uint256);
_deposit
Send entry fee to _entryFeeRecipient. See {IERC4626-_deposit}.
function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual override;
_withdraw
Send exit fee to _exitFeeRecipient. See {IERC4626-_deposit}.
function _withdraw(address caller, address receiver, address owner, uint256 assets, uint256 shares)
internal
virtual
override;
_entryFeeBasisPoints
function _entryFeeBasisPoints() internal view virtual returns (uint256);
_exitFeeBasisPoints
function _exitFeeBasisPoints() internal view virtual returns (uint256);
_entryFeeRecipient
function _entryFeeRecipient() internal view virtual returns (address);
_exitFeeRecipient
function _exitFeeRecipient() internal view virtual returns (address);
_feeOnRaw
Calculates the fees that should be added to an amount assets that does not already include fees.
Used in IERC4626-mint and {IERC4626-withdraw} operations.
function _feeOnRaw(uint256 assets, uint256 feeBasisPoints) private pure returns (uint256);
_feeOnTotal
Calculates the fee part of an amount assets that already includes fees.
Used in IERC4626-deposit and {IERC4626-redeem} operations.
function _feeOnTotal(uint256 assets, uint256 feeBasisPoints) private pure returns (uint256);
MyNFTUpgradeable
Inherits: Initializable, ERC721Upgradeable
Functions
__MyNFT_init
function __MyNFT_init() internal onlyInitializing;
__MyNFT_init_unchained
function __MyNFT_init_unchained() internal onlyInitializing;
Contents
- GovernorCountingOverridableMockUpgradeable
- GovernorFractionalMockUpgradeable
- GovernorMockUpgradeable
- GovernorNoncesKeyedMockUpgradeable
- GovernorPreventLateQuorumMockUpgradeable
- GovernorProposalGuardianMockUpgradeable
- GovernorSequentialProposalIdMockUpgradeable
- GovernorStorageMockUpgradeable
- GovernorSuperQuorumMockUpgradeable
- GovernorTimelockAccessMockUpgradeable
- GovernorTimelockCompoundMockUpgradeable
- GovernorTimelockControlMockUpgradeable
- GovernorVoteMocksUpgradeable
- GovernorVotesSuperQuorumFractionMockUpgradeable
- GovernorWithParamsMockUpgradeable
GovernorCountingOverridableMockUpgradeable
Inherits: Initializable, GovernorSettingsUpgradeable, GovernorVotesQuorumFractionUpgradeable, GovernorCountingOverridableUpgradeable
Functions
__GovernorCountingOverridableMock_init
function __GovernorCountingOverridableMock_init() internal onlyInitializing;
__GovernorCountingOverridableMock_init_unchained
function __GovernorCountingOverridableMock_init_unchained() internal onlyInitializing;
proposalThreshold
function proposalThreshold() public view override(GovernorUpgradeable, GovernorSettingsUpgradeable) returns (uint256);
GovernorFractionalMockUpgradeable
Inherits: Initializable, GovernorSettingsUpgradeable, GovernorVotesQuorumFractionUpgradeable, GovernorCountingFractionalUpgradeable
Functions
__GovernorFractionalMock_init
function __GovernorFractionalMock_init() internal onlyInitializing;
__GovernorFractionalMock_init_unchained
function __GovernorFractionalMock_init_unchained() internal onlyInitializing;
proposalThreshold
function proposalThreshold() public view override(GovernorUpgradeable, GovernorSettingsUpgradeable) returns (uint256);
GovernorMockUpgradeable
Inherits: Initializable, GovernorSettingsUpgradeable, GovernorVotesQuorumFractionUpgradeable, GovernorCountingSimpleUpgradeable
Functions
__GovernorMock_init
function __GovernorMock_init() internal onlyInitializing;
__GovernorMock_init_unchained
function __GovernorMock_init_unchained() internal onlyInitializing;
proposalThreshold
function proposalThreshold() public view override(GovernorUpgradeable, GovernorSettingsUpgradeable) returns (uint256);
GovernorNoncesKeyedMockUpgradeable
Inherits: Initializable, GovernorSettingsUpgradeable, GovernorVotesQuorumFractionUpgradeable, GovernorCountingSimpleUpgradeable, GovernorNoncesKeyedUpgradeable
Functions
__GovernorNoncesKeyedMock_init
function __GovernorNoncesKeyedMock_init() internal onlyInitializing;
__GovernorNoncesKeyedMock_init_unchained
function __GovernorNoncesKeyedMock_init_unchained() internal onlyInitializing;
proposalThreshold
function proposalThreshold() public view override(GovernorUpgradeable, GovernorSettingsUpgradeable) returns (uint256);
_validateVoteSig
function _validateVoteSig(uint256 proposalId, uint8 support, address voter, bytes memory signature)
internal
virtual
override(GovernorUpgradeable, GovernorNoncesKeyedUpgradeable)
returns (bool);
_validateExtendedVoteSig
function _validateExtendedVoteSig(
uint256 proposalId,
uint8 support,
address voter,
string memory reason,
bytes memory params,
bytes memory signature
) internal virtual override(GovernorUpgradeable, GovernorNoncesKeyedUpgradeable) returns (bool);
_useCheckedNonce
function _useCheckedNonce(address owner, uint256 nonce)
internal
virtual
override(NoncesUpgradeable, GovernorNoncesKeyedUpgradeable);
GovernorPreventLateQuorumMockUpgradeable
Inherits: Initializable, GovernorSettingsUpgradeable, GovernorVotesUpgradeable, GovernorCountingSimpleUpgradeable, GovernorPreventLateQuorumUpgradeable
State Variables
_quorum
uint256 private _quorum;
Functions
__GovernorPreventLateQuorumMock_init
function __GovernorPreventLateQuorumMock_init(uint256 quorum_) internal onlyInitializing;
__GovernorPreventLateQuorumMock_init_unchained
function __GovernorPreventLateQuorumMock_init_unchained(uint256 quorum_) internal onlyInitializing;
quorum
function quorum(uint256) public view override returns (uint256);
proposalDeadline
function proposalDeadline(uint256 proposalId)
public
view
override(GovernorUpgradeable, GovernorPreventLateQuorumUpgradeable)
returns (uint256);
proposalThreshold
function proposalThreshold() public view override(GovernorUpgradeable, GovernorSettingsUpgradeable) returns (uint256);
_tallyUpdated
function _tallyUpdated(uint256 proposalId)
internal
override(GovernorUpgradeable, GovernorPreventLateQuorumUpgradeable);
GovernorProposalGuardianMockUpgradeable
Inherits: Initializable, GovernorSettingsUpgradeable, GovernorVotesQuorumFractionUpgradeable, GovernorCountingSimpleUpgradeable, GovernorProposalGuardianUpgradeable
Functions
__GovernorProposalGuardianMock_init
function __GovernorProposalGuardianMock_init() internal onlyInitializing;
__GovernorProposalGuardianMock_init_unchained
function __GovernorProposalGuardianMock_init_unchained() internal onlyInitializing;
proposalThreshold
function proposalThreshold() public view override(GovernorUpgradeable, GovernorSettingsUpgradeable) returns (uint256);
_validateCancel
function _validateCancel(uint256 proposalId, address caller)
internal
view
override(GovernorUpgradeable, GovernorProposalGuardianUpgradeable)
returns (bool);
GovernorSequentialProposalIdMockUpgradeable
Inherits: Initializable, GovernorSettingsUpgradeable, GovernorVotesQuorumFractionUpgradeable, GovernorCountingSimpleUpgradeable, GovernorSequentialProposalIdUpgradeable
Functions
__GovernorSequentialProposalIdMock_init
function __GovernorSequentialProposalIdMock_init() internal onlyInitializing;
__GovernorSequentialProposalIdMock_init_unchained
function __GovernorSequentialProposalIdMock_init_unchained() internal onlyInitializing;
proposalThreshold
function proposalThreshold() public view override(GovernorUpgradeable, GovernorSettingsUpgradeable) returns (uint256);
getProposalId
function getProposalId(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) public view virtual override(GovernorUpgradeable, GovernorSequentialProposalIdUpgradeable) returns (uint256);
_propose
function _propose(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
string memory description,
address proposer
)
internal
virtual
override(GovernorUpgradeable, GovernorSequentialProposalIdUpgradeable)
returns (uint256 proposalId);
GovernorStorageMockUpgradeable
Inherits: Initializable, GovernorSettingsUpgradeable, GovernorTimelockControlUpgradeable, GovernorVotesQuorumFractionUpgradeable, GovernorCountingSimpleUpgradeable, GovernorStorageUpgradeable
Functions
__GovernorStorageMock_init
function __GovernorStorageMock_init() internal onlyInitializing;
__GovernorStorageMock_init_unchained
function __GovernorStorageMock_init_unchained() internal onlyInitializing;
quorum
function quorum(uint256 blockNumber)
public
view
override(GovernorUpgradeable, GovernorVotesQuorumFractionUpgradeable)
returns (uint256);
state
function state(uint256 proposalId)
public
view
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable)
returns (ProposalState);
proposalThreshold
function proposalThreshold() public view override(GovernorUpgradeable, GovernorSettingsUpgradeable) returns (uint256);
proposalNeedsQueuing
function proposalNeedsQueuing(uint256 proposalId)
public
view
virtual
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable)
returns (bool);
_propose
function _propose(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
string memory description,
address proposer
) internal virtual override(GovernorUpgradeable, GovernorStorageUpgradeable) returns (uint256);
_queueOperations
function _queueOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) returns (uint48);
_executeOperations
function _executeOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(GovernorUpgradeable, GovernorTimelockControlUpgradeable);
_cancel
function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
internal
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable)
returns (uint256);
_executor
function _executor()
internal
view
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable)
returns (address);
GovernorSuperQuorumMockUpgradeable
Inherits: Initializable, GovernorSettingsUpgradeable, GovernorVotesUpgradeable, GovernorTimelockControlUpgradeable, GovernorSuperQuorumUpgradeable, GovernorCountingSimpleUpgradeable
State Variables
_quorum
uint256 private _quorum;
_superQuorum
uint256 private _superQuorum;
Functions
__GovernorSuperQuorumMock_init
function __GovernorSuperQuorumMock_init(uint256 quorum_, uint256 superQuorum_) internal onlyInitializing;
__GovernorSuperQuorumMock_init_unchained
function __GovernorSuperQuorumMock_init_unchained(uint256 quorum_, uint256 superQuorum_) internal onlyInitializing;
quorum
function quorum(uint256) public view override returns (uint256);
superQuorum
function superQuorum(uint256) public view override returns (uint256);
state
function state(uint256 proposalId)
public
view
override(GovernorUpgradeable, GovernorSuperQuorumUpgradeable, GovernorTimelockControlUpgradeable)
returns (ProposalState);
proposalThreshold
function proposalThreshold() public view override(GovernorUpgradeable, GovernorSettingsUpgradeable) returns (uint256);
proposalVotes
function proposalVotes(uint256 proposalId)
public
view
virtual
override(GovernorCountingSimpleUpgradeable, GovernorSuperQuorumUpgradeable)
returns (uint256 againstVotes, uint256 forVotes, uint256 abstainVotes);
_cancel
function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
internal
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable)
returns (uint256);
_executeOperations
function _executeOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(GovernorUpgradeable, GovernorTimelockControlUpgradeable);
_executor
function _executor()
internal
view
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable)
returns (address);
_queueOperations
function _queueOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) returns (uint48);
proposalNeedsQueuing
function proposalNeedsQueuing(uint256 proposalId)
public
view
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable)
returns (bool);
GovernorTimelockAccessMockUpgradeable
Inherits: Initializable, GovernorSettingsUpgradeable, GovernorTimelockAccessUpgradeable, GovernorVotesQuorumFractionUpgradeable, GovernorCountingSimpleUpgradeable
Functions
__GovernorTimelockAccessMock_init
function __GovernorTimelockAccessMock_init() internal onlyInitializing;
__GovernorTimelockAccessMock_init_unchained
function __GovernorTimelockAccessMock_init_unchained() internal onlyInitializing;
nonGovernanceFunction
function nonGovernanceFunction() external;
quorum
function quorum(uint256 blockNumber)
public
view
override(GovernorUpgradeable, GovernorVotesQuorumFractionUpgradeable)
returns (uint256);
proposalThreshold
function proposalThreshold() public view override(GovernorUpgradeable, GovernorSettingsUpgradeable) returns (uint256);
proposalNeedsQueuing
function proposalNeedsQueuing(uint256 proposalId)
public
view
virtual
override(GovernorUpgradeable, GovernorTimelockAccessUpgradeable)
returns (bool);
propose
function propose(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, string memory description)
public
override(GovernorUpgradeable, GovernorTimelockAccessUpgradeable)
returns (uint256);
_queueOperations
function _queueOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(GovernorUpgradeable, GovernorTimelockAccessUpgradeable) returns (uint48);
_executeOperations
function _executeOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(GovernorUpgradeable, GovernorTimelockAccessUpgradeable);
_cancel
function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
internal
override(GovernorUpgradeable, GovernorTimelockAccessUpgradeable)
returns (uint256);
GovernorTimelockCompoundMockUpgradeable
Inherits: Initializable, GovernorSettingsUpgradeable, GovernorTimelockCompoundUpgradeable, GovernorVotesQuorumFractionUpgradeable, GovernorCountingSimpleUpgradeable
Functions
__GovernorTimelockCompoundMock_init
function __GovernorTimelockCompoundMock_init() internal onlyInitializing;
__GovernorTimelockCompoundMock_init_unchained
function __GovernorTimelockCompoundMock_init_unchained() internal onlyInitializing;
quorum
function quorum(uint256 blockNumber)
public
view
override(GovernorUpgradeable, GovernorVotesQuorumFractionUpgradeable)
returns (uint256);
state
function state(uint256 proposalId)
public
view
override(GovernorUpgradeable, GovernorTimelockCompoundUpgradeable)
returns (ProposalState);
proposalThreshold
function proposalThreshold() public view override(GovernorUpgradeable, GovernorSettingsUpgradeable) returns (uint256);
proposalNeedsQueuing
function proposalNeedsQueuing(uint256 proposalId)
public
view
virtual
override(GovernorUpgradeable, GovernorTimelockCompoundUpgradeable)
returns (bool);
_queueOperations
function _queueOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(GovernorUpgradeable, GovernorTimelockCompoundUpgradeable) returns (uint48);
_executeOperations
function _executeOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(GovernorUpgradeable, GovernorTimelockCompoundUpgradeable);
_cancel
function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
internal
override(GovernorUpgradeable, GovernorTimelockCompoundUpgradeable)
returns (uint256);
_executor
function _executor()
internal
view
override(GovernorUpgradeable, GovernorTimelockCompoundUpgradeable)
returns (address);
GovernorTimelockControlMockUpgradeable
Inherits: Initializable, GovernorSettingsUpgradeable, GovernorTimelockControlUpgradeable, GovernorVotesQuorumFractionUpgradeable, GovernorCountingSimpleUpgradeable
Functions
__GovernorTimelockControlMock_init
function __GovernorTimelockControlMock_init() internal onlyInitializing;
__GovernorTimelockControlMock_init_unchained
function __GovernorTimelockControlMock_init_unchained() internal onlyInitializing;
quorum
function quorum(uint256 blockNumber)
public
view
override(GovernorUpgradeable, GovernorVotesQuorumFractionUpgradeable)
returns (uint256);
state
function state(uint256 proposalId)
public
view
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable)
returns (ProposalState);
proposalThreshold
function proposalThreshold() public view override(GovernorUpgradeable, GovernorSettingsUpgradeable) returns (uint256);
proposalNeedsQueuing
function proposalNeedsQueuing(uint256 proposalId)
public
view
virtual
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable)
returns (bool);
_queueOperations
function _queueOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(GovernorUpgradeable, GovernorTimelockControlUpgradeable) returns (uint48);
_executeOperations
function _executeOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(GovernorUpgradeable, GovernorTimelockControlUpgradeable);
_cancel
function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
internal
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable)
returns (uint256);
_executor
function _executor()
internal
view
override(GovernorUpgradeable, GovernorTimelockControlUpgradeable)
returns (address);
nonGovernanceFunction
function nonGovernanceFunction() external;
GovernorVoteMocksUpgradeable
Inherits: Initializable, GovernorVotesUpgradeable, GovernorCountingSimpleUpgradeable
Functions
__GovernorVoteMocks_init
function __GovernorVoteMocks_init() internal onlyInitializing;
__GovernorVoteMocks_init_unchained
function __GovernorVoteMocks_init_unchained() internal onlyInitializing;
quorum
function quorum(uint256) public pure override returns (uint256);
votingDelay
function votingDelay() public pure override returns (uint256);
votingPeriod
function votingPeriod() public pure override returns (uint256);
GovernorVotesSuperQuorumFractionMockUpgradeable
Inherits: Initializable, GovernorSettingsUpgradeable, GovernorVotesSuperQuorumFractionUpgradeable, GovernorCountingSimpleUpgradeable
Functions
__GovernorVotesSuperQuorumFractionMock_init
function __GovernorVotesSuperQuorumFractionMock_init() internal onlyInitializing;
__GovernorVotesSuperQuorumFractionMock_init_unchained
function __GovernorVotesSuperQuorumFractionMock_init_unchained() internal onlyInitializing;
proposalThreshold
function proposalThreshold() public view override(GovernorUpgradeable, GovernorSettingsUpgradeable) returns (uint256);
proposalVotes
function proposalVotes(uint256 proposalId)
public
view
virtual
override(GovernorCountingSimpleUpgradeable, GovernorSuperQuorumUpgradeable)
returns (uint256 againstVotes, uint256 forVotes, uint256 abstainVotes);
state
function state(uint256 proposalId)
public
view
override(GovernorUpgradeable, GovernorVotesSuperQuorumFractionUpgradeable)
returns (ProposalState);
GovernorWithParamsMockUpgradeable
Inherits: Initializable, GovernorVotesUpgradeable, GovernorCountingSimpleUpgradeable
Functions
__GovernorWithParamsMock_init
function __GovernorWithParamsMock_init() internal onlyInitializing;
__GovernorWithParamsMock_init_unchained
function __GovernorWithParamsMock_init_unchained() internal onlyInitializing;
quorum
function quorum(uint256) public pure override returns (uint256);
votingDelay
function votingDelay() public pure override returns (uint256);
votingPeriod
function votingPeriod() public pure override returns (uint256);
_getVotes
function _getVotes(address account, uint256 blockNumber, bytes memory params)
internal
view
override(GovernorUpgradeable, GovernorVotesUpgradeable)
returns (uint256);
_countVote
function _countVote(uint256 proposalId, address account, uint8 support, uint256 weight, bytes memory params)
internal
override(GovernorUpgradeable, GovernorCountingSimpleUpgradeable)
returns (uint256);
Events
CountParams
event CountParams(uint256 uintParam, string strParam);
Contents
- BadBeaconNoImplUpgradeable
- BadBeaconNotContractUpgradeable
- ClashingImplementationUpgradeable
- NonUpgradeableMockUpgradeable
- UUPSUpgradeableMockUpgradeable
- UUPSUpgradeableUnsafeMockUpgradeable
- UUPSUnsupportedProxiableUUIDUpgradeable
BadBeaconNoImplUpgradeable
Inherits: Initializable
Functions
__BadBeaconNoImpl_init
function __BadBeaconNoImpl_init() internal onlyInitializing;
__BadBeaconNoImpl_init_unchained
function __BadBeaconNoImpl_init_unchained() internal onlyInitializing;
BadBeaconNotContractUpgradeable
Inherits: Initializable
Functions
__BadBeaconNotContract_init
function __BadBeaconNotContract_init() internal onlyInitializing;
__BadBeaconNotContract_init_unchained
function __BadBeaconNotContract_init_unchained() internal onlyInitializing;
implementation
function implementation() external pure returns (address);
ClashingImplementationUpgradeable
Inherits: Initializable
Implementation contract with a payable changeAdmin(address) function made to clash with TransparentUpgradeableProxy's to test correct functioning of the Transparent Proxy feature.
Functions
__ClashingImplementation_init
function __ClashingImplementation_init() internal onlyInitializing;
__ClashingImplementation_init_unchained
function __ClashingImplementation_init_unchained() internal onlyInitializing;
upgradeToAndCall
function upgradeToAndCall(address, bytes calldata) external payable;
delegatedFunction
function delegatedFunction() external pure returns (bool);
Events
ClashingImplementationCall
event ClashingImplementationCall();
NonUpgradeableMockUpgradeable
Inherits: Initializable
State Variables
_counter
uint256 internal _counter;
Functions
__NonUpgradeableMock_init
function __NonUpgradeableMock_init() internal onlyInitializing;
__NonUpgradeableMock_init_unchained
function __NonUpgradeableMock_init_unchained() internal onlyInitializing;
current
function current() external view returns (uint256);
increment
function increment() external;
UUPSUpgradeableMockUpgradeable
Inherits: Initializable, NonUpgradeableMockUpgradeable, UUPSUpgradeable
Functions
__UUPSUpgradeableMock_init
function __UUPSUpgradeableMock_init() internal onlyInitializing;
__UUPSUpgradeableMock_init_unchained
function __UUPSUpgradeableMock_init_unchained() internal onlyInitializing;
_authorizeUpgrade
function _authorizeUpgrade(address) internal override;
UUPSUpgradeableUnsafeMockUpgradeable
Inherits: Initializable, UUPSUpgradeableMockUpgradeable
Functions
__UUPSUpgradeableUnsafeMock_init
function __UUPSUpgradeableUnsafeMock_init() internal onlyInitializing;
__UUPSUpgradeableUnsafeMock_init_unchained
function __UUPSUpgradeableUnsafeMock_init_unchained() internal onlyInitializing;
upgradeToAndCall
function upgradeToAndCall(address newImplementation, bytes memory data) public payable override;
UUPSUnsupportedProxiableUUIDUpgradeable
Inherits: Initializable, UUPSUpgradeableMockUpgradeable
Functions
__UUPSUnsupportedProxiableUUID_init
function __UUPSUnsupportedProxiableUUID_init() internal onlyInitializing;
__UUPSUnsupportedProxiableUUID_init_unchained
function __UUPSUnsupportedProxiableUUID_init_unchained() internal onlyInitializing;
proxiableUUID
function proxiableUUID() external pure override returns (bytes32);
Contents
- ERC1155ReceiverMockUpgradeable
- ERC1363ForceApproveMockUpgradeable
- ERC1363NoReturnMockUpgradeable
- ERC1363ReceiverMockUpgradeable
- ERC1363ReturnFalseOnERC20MockUpgradeable
- ERC1363ReturnFalseMockUpgradeable
- ERC1363SpenderMockUpgradeable
- ERC20ApprovalMockUpgradeable
- ERC20BridgeableMockUpgradeable
- ERC20DecimalsMockUpgradeable
- ERC20ExcessDecimalsMockUpgradeable
- ERC20FlashMintMockUpgradeable
- ERC20ForceApproveMockUpgradeable
- ERC20GetterHelperUpgradeable
- ERC20MockUpgradeable
- ERC20MulticallMockUpgradeable
- ERC20NoReturnMockUpgradeable
- ERC20ReentrantUpgradeable
- ERC20ReturnFalseMockUpgradeable
- ERC20VotesExtendedMockUpgradeable
- ERC20VotesExtendedTimestampMockUpgradeable
- ERC20VotesLegacyMockUpgradeable
- ERC20VotesTimestampMockUpgradeable
- ERC721VotesTimestampMockUpgradeable
- ERC4626LimitsMockUpgradeable
- ERC4626MockUpgradeable
- ERC4626OffsetMockUpgradeable
- ERC4626FeesMockUpgradeable
- ERC721ConsecutiveEnumerableMockUpgradeable
- ERC721ConsecutiveMockUpgradeable
- ERC721ConsecutiveNoConstructorMintMockUpgradeable
- ERC721ReceiverMockUpgradeable
- ERC721URIStorageMockUpgradeable
ERC1155ReceiverMockUpgradeable
Inherits: Initializable, ERC165Upgradeable, IERC1155Receiver
State Variables
_recRetval
bytes4 private _recRetval;
_batRetval
bytes4 private _batRetval;
_error
RevertType private _error;
Functions
__ERC1155ReceiverMock_init
function __ERC1155ReceiverMock_init(bytes4 recRetval, bytes4 batRetval, RevertType error) internal onlyInitializing;
__ERC1155ReceiverMock_init_unchained
function __ERC1155ReceiverMock_init_unchained(bytes4 recRetval, bytes4 batRetval, RevertType error)
internal
onlyInitializing;
onERC1155Received
function onERC1155Received(address operator, address from, uint256 id, uint256 value, bytes calldata data)
external
returns (bytes4);
onERC1155BatchReceived
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
Events
Received
event Received(address operator, address from, uint256 id, uint256 value, bytes data, uint256 gas);
BatchReceived
event BatchReceived(address operator, address from, uint256[] ids, uint256[] values, bytes data, uint256 gas);
Errors
CustomError
error CustomError(bytes4);
Enums
RevertType
enum RevertType {
None,
RevertWithoutMessage,
RevertWithMessage,
RevertWithCustomError,
Panic
}
ERC1363ForceApproveMockUpgradeable
Inherits: Initializable, ERC1363Upgradeable
Functions
__ERC1363ForceApproveMock_init
function __ERC1363ForceApproveMock_init() internal onlyInitializing;
__ERC1363ForceApproveMock_init_unchained
function __ERC1363ForceApproveMock_init_unchained() internal onlyInitializing;
approveAndCall
function approveAndCall(address spender, uint256 amount, bytes memory data) public virtual override returns (bool);
ERC1363NoReturnMockUpgradeable
Inherits: Initializable, ERC1363Upgradeable
Functions
__ERC1363NoReturnMock_init
function __ERC1363NoReturnMock_init() internal onlyInitializing;
__ERC1363NoReturnMock_init_unchained
function __ERC1363NoReturnMock_init_unchained() internal onlyInitializing;
transferAndCall
function transferAndCall(address to, uint256 value, bytes memory data) public override returns (bool);
transferFromAndCall
function transferFromAndCall(address from, address to, uint256 value, bytes memory data)
public
override
returns (bool);
approveAndCall
function approveAndCall(address spender, uint256 value, bytes memory data) public override returns (bool);
ERC1363ReceiverMockUpgradeable
Inherits: Initializable, IERC1363Receiver
State Variables
_retval
bytes4 private _retval;
_error
RevertType private _error;
Functions
__ERC1363ReceiverMock_init
function __ERC1363ReceiverMock_init() internal onlyInitializing;
__ERC1363ReceiverMock_init_unchained
function __ERC1363ReceiverMock_init_unchained() internal onlyInitializing;
setUp
function setUp(bytes4 retval, RevertType error) public;
onTransferReceived
function onTransferReceived(address operator, address from, uint256 value, bytes calldata data)
external
override
returns (bytes4);
Events
Received
event Received(address operator, address from, uint256 value, bytes data);
Errors
CustomError
error CustomError(bytes4);
Enums
RevertType
enum RevertType {
None,
RevertWithoutMessage,
RevertWithMessage,
RevertWithCustomError,
Panic
}
ERC1363ReturnFalseOnERC20MockUpgradeable
Inherits: Initializable, ERC1363Upgradeable
Functions
__ERC1363ReturnFalseOnERC20Mock_init
function __ERC1363ReturnFalseOnERC20Mock_init() internal onlyInitializing;
__ERC1363ReturnFalseOnERC20Mock_init_unchained
function __ERC1363ReturnFalseOnERC20Mock_init_unchained() internal onlyInitializing;
transfer
function transfer(address, uint256) public pure override(IERC20, ERC20Upgradeable) returns (bool);
transferFrom
function transferFrom(address, address, uint256) public pure override(IERC20, ERC20Upgradeable) returns (bool);
approve
function approve(address, uint256) public pure override(IERC20, ERC20Upgradeable) returns (bool);
ERC1363ReturnFalseMockUpgradeable
Inherits: Initializable, ERC1363Upgradeable
Functions
__ERC1363ReturnFalseMock_init
function __ERC1363ReturnFalseMock_init() internal onlyInitializing;
__ERC1363ReturnFalseMock_init_unchained
function __ERC1363ReturnFalseMock_init_unchained() internal onlyInitializing;
transferAndCall
function transferAndCall(address, uint256, bytes memory) public pure override returns (bool);
transferFromAndCall
function transferFromAndCall(address, address, uint256, bytes memory) public pure override returns (bool);
approveAndCall
function approveAndCall(address, uint256, bytes memory) public pure override returns (bool);
ERC1363SpenderMockUpgradeable
Inherits: Initializable, IERC1363Spender
State Variables
_retval
bytes4 private _retval;
_error
RevertType private _error;
Functions
__ERC1363SpenderMock_init
function __ERC1363SpenderMock_init() internal onlyInitializing;
__ERC1363SpenderMock_init_unchained
function __ERC1363SpenderMock_init_unchained() internal onlyInitializing;
setUp
function setUp(bytes4 retval, RevertType error) public;
onApprovalReceived
function onApprovalReceived(address owner, uint256 value, bytes calldata data) external override returns (bytes4);
Events
Approved
event Approved(address owner, uint256 value, bytes data);
Errors
CustomError
error CustomError(bytes4);
Enums
RevertType
enum RevertType {
None,
RevertWithoutMessage,
RevertWithMessage,
RevertWithCustomError,
Panic
}
ERC20ApprovalMockUpgradeable
Inherits: Initializable, ERC20Upgradeable
Functions
__ERC20ApprovalMock_init
function __ERC20ApprovalMock_init() internal onlyInitializing;
__ERC20ApprovalMock_init_unchained
function __ERC20ApprovalMock_init_unchained() internal onlyInitializing;
_approve
function _approve(address owner, address spender, uint256 amount, bool) internal virtual override;
ERC20BridgeableMockUpgradeable
Inherits: Initializable, ERC20BridgeableUpgradeable
State Variables
_bridge
address private _bridge;
Functions
__ERC20BridgeableMock_init
function __ERC20BridgeableMock_init(address bridge) internal onlyInitializing;
__ERC20BridgeableMock_init_unchained
function __ERC20BridgeableMock_init_unchained(address bridge) internal onlyInitializing;
onlyTokenBridgeFn
function onlyTokenBridgeFn() external onlyTokenBridge;
_checkTokenBridge
function _checkTokenBridge(address sender) internal view override;
Events
OnlyTokenBridgeFnCalled
event OnlyTokenBridgeFnCalled(address caller);
Errors
OnlyTokenBridge
error OnlyTokenBridge();
ERC20DecimalsMockUpgradeable
Inherits: Initializable, ERC20Upgradeable
State Variables
_decimals
uint8 private _decimals;
Functions
__ERC20DecimalsMock_init
function __ERC20DecimalsMock_init(uint8 decimals_) internal onlyInitializing;
__ERC20DecimalsMock_init_unchained
function __ERC20DecimalsMock_init_unchained(uint8 decimals_) internal onlyInitializing;
decimals
function decimals() public view override returns (uint8);
ERC20ExcessDecimalsMockUpgradeable
Inherits: Initializable
Functions
__ERC20ExcessDecimalsMock_init
function __ERC20ExcessDecimalsMock_init() internal onlyInitializing;
__ERC20ExcessDecimalsMock_init_unchained
function __ERC20ExcessDecimalsMock_init_unchained() internal onlyInitializing;
decimals
function decimals() public pure returns (uint256);
ERC20FlashMintMockUpgradeable
Inherits: Initializable, ERC20FlashMintUpgradeable
State Variables
_flashFeeAmount
uint256 _flashFeeAmount;
_flashFeeReceiverAddress
address _flashFeeReceiverAddress;
Functions
__ERC20FlashMintMock_init
function __ERC20FlashMintMock_init() internal onlyInitializing;
__ERC20FlashMintMock_init_unchained
function __ERC20FlashMintMock_init_unchained() internal onlyInitializing;
setFlashFee
function setFlashFee(uint256 amount) public;
_flashFee
function _flashFee(address, uint256) internal view override returns (uint256);
setFlashFeeReceiver
function setFlashFeeReceiver(address receiver) public;
_flashFeeReceiver
function _flashFeeReceiver() internal view override returns (address);
ERC20ForceApproveMockUpgradeable
Inherits: Initializable, ERC20Upgradeable
Functions
__ERC20ForceApproveMock_init
function __ERC20ForceApproveMock_init() internal onlyInitializing;
__ERC20ForceApproveMock_init_unchained
function __ERC20ForceApproveMock_init_unchained() internal onlyInitializing;
approve
function approve(address spender, uint256 amount) public virtual override returns (bool);
ERC20GetterHelperUpgradeable
Inherits: Initializable
Functions
__ERC20GetterHelper_init
function __ERC20GetterHelper_init() internal onlyInitializing;
__ERC20GetterHelper_init_unchained
function __ERC20GetterHelper_init_unchained() internal onlyInitializing;
totalSupply
function totalSupply(IERC20 token) external;
balanceOf
function balanceOf(IERC20 token, address account) external;
allowance
function allowance(IERC20 token, address owner, address spender) external;
name
function name(IERC20Metadata token) external;
symbol
function symbol(IERC20Metadata token) external;
decimals
function decimals(IERC20Metadata token) external;
Events
ERC20TotalSupply
event ERC20TotalSupply(IERC20 token, uint256 totalSupply);
ERC20BalanceOf
event ERC20BalanceOf(IERC20 token, address account, uint256 balanceOf);
ERC20Allowance
event ERC20Allowance(IERC20 token, address owner, address spender, uint256 allowance);
ERC20Name
event ERC20Name(IERC20Metadata token, string name);
ERC20Symbol
event ERC20Symbol(IERC20Metadata token, string symbol);
ERC20Decimals
event ERC20Decimals(IERC20Metadata token, uint8 decimals);
ERC20MockUpgradeable
Inherits: Initializable, ERC20Upgradeable
Functions
__ERC20Mock_init
function __ERC20Mock_init() internal onlyInitializing;
__ERC20Mock_init_unchained
function __ERC20Mock_init_unchained() internal onlyInitializing;
mint
function mint(address account, uint256 amount) external;
burn
function burn(address account, uint256 amount) external;
ERC20MulticallMockUpgradeable
Inherits: Initializable, ERC20Upgradeable, MulticallUpgradeable
Functions
__ERC20MulticallMock_init
function __ERC20MulticallMock_init() internal onlyInitializing;
__ERC20MulticallMock_init_unchained
function __ERC20MulticallMock_init_unchained() internal onlyInitializing;
ERC20NoReturnMockUpgradeable
Inherits: Initializable, ERC20Upgradeable
Functions
__ERC20NoReturnMock_init
function __ERC20NoReturnMock_init() internal onlyInitializing;
__ERC20NoReturnMock_init_unchained
function __ERC20NoReturnMock_init_unchained() internal onlyInitializing;
transfer
function transfer(address to, uint256 amount) public override returns (bool);
transferFrom
function transferFrom(address from, address to, uint256 amount) public override returns (bool);
approve
function approve(address spender, uint256 amount) public override returns (bool);
ERC20ReentrantUpgradeable
Inherits: Initializable, ERC20Upgradeable
State Variables
_reenterType
Type private _reenterType;
_reenterTarget
address private _reenterTarget;
_reenterData
bytes private _reenterData;
Functions
__ERC20Reentrant_init
function __ERC20Reentrant_init() internal onlyInitializing;
__ERC20Reentrant_init_unchained
function __ERC20Reentrant_init_unchained() internal onlyInitializing;
scheduleReenter
function scheduleReenter(Type when, address target, bytes calldata data) external;
functionCall
function functionCall(address target, bytes memory data) public returns (bytes memory);
_update
function _update(address from, address to, uint256 amount) internal override;
Enums
Type
enum Type {
No,
Before,
After
}
ERC20ReturnFalseMockUpgradeable
Inherits: Initializable, ERC20Upgradeable
Functions
__ERC20ReturnFalseMock_init
function __ERC20ReturnFalseMock_init() internal onlyInitializing;
__ERC20ReturnFalseMock_init_unchained
function __ERC20ReturnFalseMock_init_unchained() internal onlyInitializing;
transfer
function transfer(address, uint256) public pure override returns (bool);
transferFrom
function transferFrom(address, address, uint256) public pure override returns (bool);
approve
function approve(address, uint256) public pure override returns (bool);
ERC20VotesExtendedMockUpgradeable
Inherits: Initializable, ERC20VotesUpgradeable, VotesExtendedUpgradeable
Functions
__ERC20VotesExtendedMock_init
function __ERC20VotesExtendedMock_init() internal onlyInitializing;
__ERC20VotesExtendedMock_init_unchained
function __ERC20VotesExtendedMock_init_unchained() internal onlyInitializing;
_delegate
function _delegate(address account, address delegatee)
internal
virtual
override(VotesUpgradeable, VotesExtendedUpgradeable);
_transferVotingUnits
function _transferVotingUnits(address from, address to, uint256 amount)
internal
virtual
override(VotesUpgradeable, VotesExtendedUpgradeable);
ERC20VotesExtendedTimestampMockUpgradeable
Inherits: Initializable, ERC20VotesExtendedMockUpgradeable
Functions
__ERC20VotesExtendedTimestampMock_init
function __ERC20VotesExtendedTimestampMock_init() internal onlyInitializing;
__ERC20VotesExtendedTimestampMock_init_unchained
function __ERC20VotesExtendedTimestampMock_init_unchained() internal onlyInitializing;
clock
function clock() public view virtual override returns (uint48);
CLOCK_MODE
function CLOCK_MODE() public view virtual override returns (string memory);
ERC20VotesLegacyMockUpgradeable
Inherits: Initializable, IVotes, ERC20PermitUpgradeable
Copied from the master branch at commit 86de1e8b6c3fa6b4efa4a5435869d2521be0f5f5
State Variables
_DELEGATION_TYPEHASH
bytes32 private constant _DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
_delegatee
mapping(address account => address) private _delegatee;
_checkpoints
mapping(address delegatee => Checkpoint[]) private _checkpoints;
_totalSupplyCheckpoints
Checkpoint[] private _totalSupplyCheckpoints;
Functions
__ERC20VotesLegacyMock_init
function __ERC20VotesLegacyMock_init() internal onlyInitializing;
__ERC20VotesLegacyMock_init_unchained
function __ERC20VotesLegacyMock_init_unchained() internal onlyInitializing;
checkpoints
Get the pos-th checkpoint for account.
function checkpoints(address account, uint32 pos) public view virtual returns (Checkpoint memory);
numCheckpoints
Get number of checkpoints for account.
function numCheckpoints(address account) public view virtual returns (uint32);
delegates
Get the address account is currently delegating to.
function delegates(address account) public view virtual returns (address);
getVotes
Gets the current votes balance for account
function getVotes(address account) public view virtual returns (uint256);
getPastVotes
*Retrieve the number of votes for account at the end of blockNumber.
Requirements:
blockNumbermust have been already mined*
function getPastVotes(address account, uint256 blockNumber) public view virtual returns (uint256);
getPastTotalSupply
*Retrieve the totalSupply at the end of blockNumber. Note, this value is the sum of all balances.
It is NOT the sum of all the delegated votes!
Requirements:
blockNumbermust have been already mined*
function getPastTotalSupply(uint256 blockNumber) public view virtual returns (uint256);
_checkpointsLookup
Lookup a value in a list of (sorted) checkpoints.
function _checkpointsLookup(Checkpoint[] storage ckpts, uint256 blockNumber) private view returns (uint256);
delegate
Delegate votes from the sender to delegatee.
function delegate(address delegatee) public virtual;
delegateBySig
Delegates votes from signer to delegatee
function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s)
public
virtual;
_maxSupply
Maximum token supply. Defaults to type(uint224).max (2^224^ - 1).
function _maxSupply() internal view virtual returns (uint224);
_update
Move voting power when tokens are transferred. Emits a IVotes-DelegateVotesChanged event.
function _update(address from, address to, uint256 amount) internal virtual override;
_delegate
Change delegation for delegator to delegatee.
Emits events IVotes-DelegateChanged and {IVotes-DelegateVotesChanged}.
function _delegate(address delegator, address delegatee) internal virtual;
_moveVotingPower
function _moveVotingPower(address src, address dst, uint256 amount) private;
_writeCheckpoint
function _writeCheckpoint(
Checkpoint[] storage ckpts,
function(uint256, uint256) view returns (uint256) op,
uint256 delta
) private returns (uint256 oldWeight, uint256 newWeight);
_add
function _add(uint256 a, uint256 b) private pure returns (uint256);
_subtract
function _subtract(uint256 a, uint256 b) private pure returns (uint256);
_unsafeAccess
Access an element of the array without performing bounds check. The position is assumed to be within bounds.
function _unsafeAccess(Checkpoint[] storage ckpts, uint256 pos) private pure returns (Checkpoint storage result);
Structs
Checkpoint
struct Checkpoint {
uint32 fromBlock;
uint224 votes;
}
ERC20VotesTimestampMockUpgradeable
Inherits: Initializable, ERC20VotesUpgradeable
Functions
__ERC20VotesTimestampMock_init
function __ERC20VotesTimestampMock_init() internal onlyInitializing;
__ERC20VotesTimestampMock_init_unchained
function __ERC20VotesTimestampMock_init_unchained() internal onlyInitializing;
clock
function clock() public view virtual override returns (uint48);
CLOCK_MODE
function CLOCK_MODE() public view virtual override returns (string memory);
ERC721VotesTimestampMockUpgradeable
Inherits: Initializable, ERC721VotesUpgradeable
Functions
__ERC721VotesTimestampMock_init
function __ERC721VotesTimestampMock_init() internal onlyInitializing;
__ERC721VotesTimestampMock_init_unchained
function __ERC721VotesTimestampMock_init_unchained() internal onlyInitializing;
clock
function clock() public view virtual override returns (uint48);
CLOCK_MODE
function CLOCK_MODE() public view virtual override returns (string memory);
ERC4626LimitsMockUpgradeable
Inherits: Initializable, ERC4626Upgradeable
State Variables
_maxDeposit
uint256 _maxDeposit;
_maxMint
uint256 _maxMint;
Functions
__ERC4626LimitsMock_init
function __ERC4626LimitsMock_init() internal onlyInitializing;
__ERC4626LimitsMock_init_unchained
function __ERC4626LimitsMock_init_unchained() internal onlyInitializing;
maxDeposit
function maxDeposit(address) public view override returns (uint256);
maxMint
function maxMint(address) public view override returns (uint256);
ERC4626MockUpgradeable
Inherits: Initializable, ERC4626Upgradeable
Functions
__ERC4626Mock_init
function __ERC4626Mock_init(address underlying) internal onlyInitializing;
__ERC4626Mock_init_unchained
function __ERC4626Mock_init_unchained(address) internal onlyInitializing;
mint
function mint(address account, uint256 amount) external;
burn
function burn(address account, uint256 amount) external;
ERC4626OffsetMockUpgradeable
Inherits: Initializable, ERC4626Upgradeable
State Variables
_offset
uint8 private _offset;
Functions
__ERC4626OffsetMock_init
function __ERC4626OffsetMock_init(uint8 offset_) internal onlyInitializing;
__ERC4626OffsetMock_init_unchained
function __ERC4626OffsetMock_init_unchained(uint8 offset_) internal onlyInitializing;
_decimalsOffset
function _decimalsOffset() internal view virtual override returns (uint8);
ERC4626FeesMockUpgradeable
Inherits: Initializable, ERC4626FeesUpgradeable
State Variables
_entryFeeBasisPointValue
uint256 private _entryFeeBasisPointValue;
_entryFeeRecipientValue
address private _entryFeeRecipientValue;
_exitFeeBasisPointValue
uint256 private _exitFeeBasisPointValue;
_exitFeeRecipientValue
address private _exitFeeRecipientValue;
Functions
__ERC4626FeesMock_init
function __ERC4626FeesMock_init(
uint256 entryFeeBasisPoints,
address entryFeeRecipient,
uint256 exitFeeBasisPoints,
address exitFeeRecipient
) internal onlyInitializing;
__ERC4626FeesMock_init_unchained
function __ERC4626FeesMock_init_unchained(
uint256 entryFeeBasisPoints,
address entryFeeRecipient,
uint256 exitFeeBasisPoints,
address exitFeeRecipient
) internal onlyInitializing;
_entryFeeBasisPoints
function _entryFeeBasisPoints() internal view virtual override returns (uint256);
_entryFeeRecipient
function _entryFeeRecipient() internal view virtual override returns (address);
_exitFeeBasisPoints
function _exitFeeBasisPoints() internal view virtual override returns (uint256);
_exitFeeRecipient
function _exitFeeRecipient() internal view virtual override returns (address);
ERC721ConsecutiveEnumerableMockUpgradeable
Inherits: Initializable, ERC721ConsecutiveUpgradeable, ERC721EnumerableUpgradeable
Functions
__ERC721ConsecutiveEnumerableMock_init
function __ERC721ConsecutiveEnumerableMock_init(
string memory name,
string memory symbol,
address[] memory receivers,
uint96[] memory amounts
) internal onlyInitializing;
__ERC721ConsecutiveEnumerableMock_init_unchained
function __ERC721ConsecutiveEnumerableMock_init_unchained(
string memory,
string memory,
address[] memory receivers,
uint96[] memory amounts
) internal onlyInitializing;
supportsInterface
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC721Upgradeable, ERC721EnumerableUpgradeable)
returns (bool);
_ownerOf
function _ownerOf(uint256 tokenId)
internal
view
virtual
override(ERC721Upgradeable, ERC721ConsecutiveUpgradeable)
returns (address);
_update
function _update(address to, uint256 tokenId, address auth)
internal
virtual
override(ERC721ConsecutiveUpgradeable, ERC721EnumerableUpgradeable)
returns (address);
_increaseBalance
function _increaseBalance(address account, uint128 amount)
internal
virtual
override(ERC721Upgradeable, ERC721EnumerableUpgradeable);
ERC721ConsecutiveMockUpgradeable
Inherits: Initializable, ERC721ConsecutiveUpgradeable, ERC721PausableUpgradeable, ERC721VotesUpgradeable
State Variables
_offset
uint96 private _offset;
Functions
__ERC721ConsecutiveMock_init
function __ERC721ConsecutiveMock_init(
string memory name,
string memory symbol,
uint96 offset,
address[] memory delegates,
address[] memory receivers,
uint96[] memory amounts
) internal onlyInitializing;
__ERC721ConsecutiveMock_init_unchained
function __ERC721ConsecutiveMock_init_unchained(
string memory,
string memory,
uint96 offset,
address[] memory delegates,
address[] memory receivers,
uint96[] memory amounts
) internal onlyInitializing;
_firstConsecutiveId
function _firstConsecutiveId() internal view virtual override returns (uint96);
_ownerOf
function _ownerOf(uint256 tokenId)
internal
view
virtual
override(ERC721Upgradeable, ERC721ConsecutiveUpgradeable)
returns (address);
_update
function _update(address to, uint256 tokenId, address auth)
internal
virtual
override(ERC721ConsecutiveUpgradeable, ERC721PausableUpgradeable, ERC721VotesUpgradeable)
returns (address);
_increaseBalance
function _increaseBalance(address account, uint128 amount)
internal
virtual
override(ERC721Upgradeable, ERC721VotesUpgradeable);
ERC721ConsecutiveNoConstructorMintMockUpgradeable
Inherits: Initializable, ERC721ConsecutiveUpgradeable
Functions
__ERC721ConsecutiveNoConstructorMintMock_init
function __ERC721ConsecutiveNoConstructorMintMock_init(string memory name, string memory symbol)
internal
onlyInitializing;
__ERC721ConsecutiveNoConstructorMintMock_init_unchained
function __ERC721ConsecutiveNoConstructorMintMock_init_unchained(string memory, string memory)
internal
onlyInitializing;
ERC721ReceiverMockUpgradeable
Inherits: Initializable, IERC721Receiver
State Variables
_retval
bytes4 private _retval;
_error
RevertType private _error;
Functions
__ERC721ReceiverMock_init
function __ERC721ReceiverMock_init(bytes4 retval, RevertType error) internal onlyInitializing;
__ERC721ReceiverMock_init_unchained
function __ERC721ReceiverMock_init_unchained(bytes4 retval, RevertType error) internal onlyInitializing;
onERC721Received
function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data) public returns (bytes4);
Events
Received
event Received(address operator, address from, uint256 tokenId, bytes data, uint256 gas);
Errors
CustomError
error CustomError(bytes4);
Enums
RevertType
enum RevertType {
None,
RevertWithoutMessage,
RevertWithMessage,
RevertWithCustomError,
Panic
}
ERC721URIStorageMockUpgradeable
Inherits: Initializable, ERC721URIStorageUpgradeable
State Variables
_baseTokenURI
string private _baseTokenURI;
Functions
__ERC721URIStorageMock_init
function __ERC721URIStorageMock_init() internal onlyInitializing;
__ERC721URIStorageMock_init_unchained
function __ERC721URIStorageMock_init_unchained() internal onlyInitializing;
_baseURI
function _baseURI() internal view virtual override returns (string memory);
setBaseURI
function setBaseURI(string calldata newBaseTokenURI) public;
Contents
Contents
ERC7739ECDSAMockUpgradeable
Inherits: Initializable, ERC7739Upgradeable, SignerECDSAUpgradeable
Functions
__ERC7739ECDSAMock_init
function __ERC7739ECDSAMock_init() internal onlyInitializing;
__ERC7739ECDSAMock_init_unchained
function __ERC7739ECDSAMock_init_unchained() internal onlyInitializing;
ERC7739P256MockUpgradeable
Inherits: Initializable, ERC7739Upgradeable, SignerP256Upgradeable
Functions
__ERC7739P256Mock_init
function __ERC7739P256Mock_init() internal onlyInitializing;
__ERC7739P256Mock_init_unchained
function __ERC7739P256Mock_init_unchained() internal onlyInitializing;
ERC7739RSAMockUpgradeable
Inherits: Initializable, ERC7739Upgradeable, SignerRSAUpgradeable
Functions
__ERC7739RSAMock_init
function __ERC7739RSAMock_init() internal onlyInitializing;
__ERC7739RSAMock_init_unchained
function __ERC7739RSAMock_init_unchained() internal onlyInitializing;
AccessManagedTargetUpgradeable
Inherits: Initializable, AccessManagedUpgradeable
Functions
__AccessManagedTarget_init
function __AccessManagedTarget_init() internal onlyInitializing;
__AccessManagedTarget_init_unchained
function __AccessManagedTarget_init_unchained() internal onlyInitializing;
fnRestricted
function fnRestricted() public restricted;
fnUnrestricted
function fnUnrestricted() public;
setIsConsumingScheduledOp
function setIsConsumingScheduledOp(bool isConsuming, bytes32 slot) external;
fallback
fallback() external;
Events
CalledRestricted
event CalledRestricted(address caller);
CalledUnrestricted
event CalledUnrestricted(address caller);
CalledFallback
event CalledFallback(address caller);
AccessManagerMockUpgradeable
Inherits: Initializable, AccessManagerUpgradeable
Functions
__AccessManagerMock_init
function __AccessManagerMock_init(address initialAdmin) internal onlyInitializing;
__AccessManagerMock_init_unchained
function __AccessManagerMock_init_unchained(address) internal onlyInitializing;
fnRestricted
function fnRestricted() public onlyAuthorized;
fnUnrestricted
function fnUnrestricted() public;
Events
CalledRestricted
event CalledRestricted(address caller);
CalledUnrestricted
event CalledUnrestricted(address caller);
Uint256ArraysMockUpgradeable
Inherits: Initializable
State Variables
_array
uint256[] private _array;
Functions
__Uint256ArraysMock_init
function __Uint256ArraysMock_init(uint256[] memory array) internal onlyInitializing;
__Uint256ArraysMock_init_unchained
function __Uint256ArraysMock_init_unchained(uint256[] memory array) internal onlyInitializing;
findUpperBound
function findUpperBound(uint256 value) external view returns (uint256);
lowerBound
function lowerBound(uint256 value) external view returns (uint256);
upperBound
function upperBound(uint256 value) external view returns (uint256);
lowerBoundMemory
function lowerBoundMemory(uint256[] memory array, uint256 value) external pure returns (uint256);
upperBoundMemory
function upperBoundMemory(uint256[] memory array, uint256 value) external pure returns (uint256);
unsafeAccess
function unsafeAccess(uint256 pos) external view returns (uint256);
sort
function sort(uint256[] memory array) external pure returns (uint256[] memory);
sortReverse
function sortReverse(uint256[] memory array) external pure returns (uint256[] memory);
_reverse
function _reverse(uint256 a, uint256 b) private pure returns (bool);
unsafeSetLength
function unsafeSetLength(uint256 newLength) external;
length
function length() external view returns (uint256);
AddressArraysMockUpgradeable
Inherits: Initializable
State Variables
_array
address[] private _array;
Functions
__AddressArraysMock_init
function __AddressArraysMock_init(address[] memory array) internal onlyInitializing;
__AddressArraysMock_init_unchained
function __AddressArraysMock_init_unchained(address[] memory array) internal onlyInitializing;
unsafeAccess
function unsafeAccess(uint256 pos) external view returns (address);
sort
function sort(address[] memory array) external pure returns (address[] memory);
sortReverse
function sortReverse(address[] memory array) external pure returns (address[] memory);
_reverse
function _reverse(address a, address b) private pure returns (bool);
unsafeSetLength
function unsafeSetLength(uint256 newLength) external;
length
function length() external view returns (uint256);
Bytes32ArraysMockUpgradeable
Inherits: Initializable
State Variables
_array
bytes32[] private _array;
Functions
__Bytes32ArraysMock_init
function __Bytes32ArraysMock_init(bytes32[] memory array) internal onlyInitializing;
__Bytes32ArraysMock_init_unchained
function __Bytes32ArraysMock_init_unchained(bytes32[] memory array) internal onlyInitializing;
unsafeAccess
function unsafeAccess(uint256 pos) external view returns (bytes32);
sort
function sort(bytes32[] memory array) external pure returns (bytes32[] memory);
sortReverse
function sortReverse(bytes32[] memory array) external pure returns (bytes32[] memory);
_reverse
function _reverse(bytes32 a, bytes32 b) private pure returns (bool);
unsafeSetLength
function unsafeSetLength(uint256 newLength) external;
length
function length() external view returns (uint256);
BytesArraysMockUpgradeable
Inherits: Initializable
State Variables
_array
bytes[] private _array;
Functions
__BytesArraysMock_init
function __BytesArraysMock_init(bytes[] memory array) internal onlyInitializing;
__BytesArraysMock_init_unchained
function __BytesArraysMock_init_unchained(bytes[] memory array) internal onlyInitializing;
unsafeAccess
function unsafeAccess(uint256 pos) external view returns (bytes memory);
unsafeSetLength
function unsafeSetLength(uint256 newLength) external;
length
function length() external view returns (uint256);
StringArraysMockUpgradeable
Inherits: Initializable
State Variables
_array
string[] private _array;
Functions
__StringArraysMock_init
function __StringArraysMock_init(string[] memory array) internal onlyInitializing;
__StringArraysMock_init_unchained
function __StringArraysMock_init_unchained(string[] memory array) internal onlyInitializing;
unsafeAccess
function unsafeAccess(uint256 pos) external view returns (string memory);
unsafeSetLength
function unsafeSetLength(uint256 newLength) external;
length
function length() external view returns (uint256);
NotAuthorityMockUpgradeable
Inherits: Initializable, IAuthority
Functions
__NotAuthorityMock_init
function __NotAuthorityMock_init() internal onlyInitializing;
__NotAuthorityMock_init_unchained
function __NotAuthorityMock_init_unchained() internal onlyInitializing;
canCall
function canCall(address, address, bytes4) external pure returns (bool);
AuthorityNoDelayMockUpgradeable
Inherits: Initializable, IAuthority
State Variables
_immediate
bool private _immediate;
Functions
__AuthorityNoDelayMock_init
function __AuthorityNoDelayMock_init() internal onlyInitializing;
__AuthorityNoDelayMock_init_unchained
function __AuthorityNoDelayMock_init_unchained() internal onlyInitializing;
canCall
function canCall(address, address, bytes4) external view returns (bool immediate);
_setImmediate
function _setImmediate(bool immediate) external;
AuthorityDelayMockUpgradeable
Inherits: Initializable
State Variables
_immediate
bool private _immediate;
_delay
uint256 private _delay;
Functions
__AuthorityDelayMock_init
function __AuthorityDelayMock_init() internal onlyInitializing;
__AuthorityDelayMock_init_unchained
function __AuthorityDelayMock_init_unchained() internal onlyInitializing;
canCall
function canCall(address, address, bytes4) external view returns (bool immediate, uint256 delay);
_setImmediate
function _setImmediate(bool immediate) external;
_setDelay
function _setDelay(uint256 delay) external;
AuthorityNoResponseUpgradeable
Inherits: Initializable
Functions
__AuthorityNoResponse_init
function __AuthorityNoResponse_init() internal onlyInitializing;
__AuthorityNoResponse_init_unchained
function __AuthorityNoResponse_init_unchained() internal onlyInitializing;
canCall
function canCall(address, address, bytes4) external view;
AuthorityObserveIsConsumingUpgradeable
Inherits: Initializable
Functions
__AuthorityObserveIsConsuming_init
function __AuthorityObserveIsConsuming_init() internal onlyInitializing;
__AuthorityObserveIsConsuming_init_unchained
function __AuthorityObserveIsConsuming_init_unchained() internal onlyInitializing;
canCall
function canCall(address, address, bytes4) external pure returns (bool immediate, uint32 delay);
consumeScheduledOp
function consumeScheduledOp(address caller, bytes memory data) public;
Events
ConsumeScheduledOpCalled
event ConsumeScheduledOpCalled(address caller, bytes data, bytes4 isConsuming);
Base64DirtyUpgradeable
Inherits: Initializable
Functions
__Base64Dirty_init
function __Base64Dirty_init() internal onlyInitializing;
__Base64Dirty_init_unchained
function __Base64Dirty_init_unchained() internal onlyInitializing;
encode
function encode(bytes memory input) public pure returns (string memory);
Structs
A
struct A {
uint256 value;
}
BatchCallerUpgradeable
Inherits: Initializable
Functions
__BatchCaller_init
function __BatchCaller_init() internal onlyInitializing;
__BatchCaller_init_unchained
function __BatchCaller_init_unchained() internal onlyInitializing;
execute
function execute(Call[] calldata calls) external returns (bytes[] memory);
Structs
Call
struct Call {
address target;
uint256 value;
bytes data;
}
CallReceiverMockUpgradeable
Inherits: Initializable
State Variables
_array
uint256[] private _array;
Functions
__CallReceiverMock_init
function __CallReceiverMock_init() internal onlyInitializing;
__CallReceiverMock_init_unchained
function __CallReceiverMock_init_unchained() internal onlyInitializing;
mockFunction
function mockFunction() public payable returns (string memory);
mockFunctionEmptyReturn
function mockFunctionEmptyReturn() public payable;
mockFunctionWithArgs
function mockFunctionWithArgs(uint256 a, uint256 b) public payable returns (string memory);
mockFunctionNonPayable
function mockFunctionNonPayable() public returns (string memory);
mockStaticFunction
function mockStaticFunction() public pure returns (string memory);
mockFunctionRevertsNoReason
function mockFunctionRevertsNoReason() public payable;
mockFunctionRevertsReason
function mockFunctionRevertsReason() public payable;
mockFunctionThrows
function mockFunctionThrows() public payable;
mockFunctionOutOfGas
function mockFunctionOutOfGas() public payable;
mockFunctionWritesStorage
function mockFunctionWritesStorage(bytes32 slot, bytes32 value) public returns (string memory);
mockFunctionExtra
function mockFunctionExtra() public payable;
Events
MockFunctionCalled
event MockFunctionCalled();
MockFunctionCalledWithArgs
event MockFunctionCalledWithArgs(uint256 a, uint256 b);
MockFunctionCalledExtra
event MockFunctionCalledExtra(address caller, uint256 value);
CallReceiverMockTrustingForwarderUpgradeable
Inherits: Initializable, CallReceiverMockUpgradeable
State Variables
_trustedForwarder
address private _trustedForwarder;
Functions
__CallReceiverMockTrustingForwarder_init
function __CallReceiverMockTrustingForwarder_init(address trustedForwarder_) internal onlyInitializing;
__CallReceiverMockTrustingForwarder_init_unchained
function __CallReceiverMockTrustingForwarder_init_unchained(address trustedForwarder_) internal onlyInitializing;
isTrustedForwarder
function isTrustedForwarder(address forwarder) public view virtual returns (bool);
ConstructorMockUpgradeable
Inherits: Initializable
State Variables
foo
bool foo;
Functions
__ConstructorMock_init
function __ConstructorMock_init(RevertType error) internal onlyInitializing;
__ConstructorMock_init_unchained
function __ConstructorMock_init_unchained(RevertType error) internal onlyInitializing;
Errors
CustomError
error CustomError();
Enums
RevertType
enum RevertType {
None,
RevertWithoutMessage,
RevertWithMessage,
RevertWithCustomError,
Panic
}
ContextMockUpgradeable
Inherits: Initializable, ContextUpgradeable
Functions
__ContextMock_init
function __ContextMock_init() internal onlyInitializing;
__ContextMock_init_unchained
function __ContextMock_init_unchained() internal onlyInitializing;
msgSender
function msgSender() public;
msgData
function msgData(uint256 integerValue, string memory stringValue) public;
msgDataShort
function msgDataShort() public;
Events
Sender
event Sender(address sender);
Data
event Data(bytes data, uint256 integerValue, string stringValue);
DataShort
event DataShort(bytes data);
ContextMockCallerUpgradeable
Inherits: Initializable
Functions
__ContextMockCaller_init
function __ContextMockCaller_init() internal onlyInitializing;
__ContextMockCaller_init_unchained
function __ContextMockCaller_init_unchained() internal onlyInitializing;
callSender
function callSender(ContextMockUpgradeable context) public;
callData
function callData(ContextMockUpgradeable context, uint256 integerValue, string memory stringValue) public;
ImplUpgradeable
Inherits: Initializable
Functions
__Impl_init
function __Impl_init() internal onlyInitializing;
__Impl_init_unchained
function __Impl_init_unchained() internal onlyInitializing;
version
function version() public pure virtual returns (string memory);
DummyImplementationUpgradeable
Inherits: Initializable
State Variables
value
uint256 public value;
text
string public text;
values
uint256[] public values;
Functions
__DummyImplementation_init
function __DummyImplementation_init() internal onlyInitializing;
__DummyImplementation_init_unchained
function __DummyImplementation_init_unchained() internal onlyInitializing;
initializeNonPayable
function initializeNonPayable() public;
initializePayable
function initializePayable() public payable;
initializeNonPayableWithValue
function initializeNonPayableWithValue(uint256 _value) public;
initializePayableWithValue
function initializePayableWithValue(uint256 _value) public payable;
initialize
function initialize(uint256 _value, string memory _text, uint256[] memory _values) public;
get
function get() public pure returns (bool);
version
function version() public pure virtual returns (string memory);
reverts
function reverts() public pure;
unsafeOverrideAdmin
function unsafeOverrideAdmin(address newAdmin) public;
DummyImplementationV2Upgradeable
Inherits: Initializable, DummyImplementationUpgradeable
Functions
__DummyImplementationV2_init
function __DummyImplementationV2_init() internal onlyInitializing;
__DummyImplementationV2_init_unchained
function __DummyImplementationV2_init_unchained() internal onlyInitializing;
migrate
function migrate(uint256 newVal) public payable;
version
function version() public pure override returns (string memory);
EIP712VerifierUpgradeable
Inherits: Initializable, EIP712Upgradeable
Functions
__EIP712Verifier_init
function __EIP712Verifier_init() internal onlyInitializing;
__EIP712Verifier_init_unchained
function __EIP712Verifier_init_unchained() internal onlyInitializing;
verify
function verify(bytes memory signature, address signer, address mailTo, string memory mailContents) external view;
ERC1271WalletMockUpgradeable
Inherits: Initializable, OwnableUpgradeable, IERC1271
Functions
__ERC1271WalletMock_init
function __ERC1271WalletMock_init(address originalOwner) internal onlyInitializing;
__ERC1271WalletMock_init_unchained
function __ERC1271WalletMock_init_unchained(address) internal onlyInitializing;
isValidSignature
function isValidSignature(bytes32 hash, bytes memory signature) public view returns (bytes4 magicValue);
ERC1271MaliciousMockUpgradeable
Inherits: Initializable, IERC1271
Functions
__ERC1271MaliciousMock_init
function __ERC1271MaliciousMock_init() internal onlyInitializing;
__ERC1271MaliciousMock_init_unchained
function __ERC1271MaliciousMock_init_unchained() internal onlyInitializing;
isValidSignature
function isValidSignature(bytes32, bytes memory) public pure returns (bytes4);
ERC2771ContextMockUpgradeable
Inherits: Initializable, ContextMockUpgradeable, ERC2771ContextUpgradeable, MulticallUpgradeable
Functions
constructor
Note: oz-upgrades-unsafe-allow: constructor
constructor(address trustedForwarder) ERC2771ContextUpgradeable(trustedForwarder);
_msgSender
function _msgSender() internal view override(ContextUpgradeable, ERC2771ContextUpgradeable) returns (address);
_msgData
function _msgData() internal view override(ContextUpgradeable, ERC2771ContextUpgradeable) returns (bytes calldata);
_contextSuffixLength
function _contextSuffixLength()
internal
view
override(ContextUpgradeable, ERC2771ContextUpgradeable)
returns (uint256);
ERC3156FlashBorrowerMockUpgradeable
Inherits: Initializable, IERC3156FlashBorrower
WARNING: this IERC3156FlashBorrower mock implementation is for testing purposes ONLY. Writing a secure flash lock borrower is not an easy task, and should be done with the utmost care. This is not an example of how it should be done, and no pattern present in this mock should be considered secure. Following best practices, always have your contract properly audited before using them to manipulate important funds on live networks.
State Variables
_RETURN_VALUE
bytes32 internal constant _RETURN_VALUE = keccak256("ERC3156FlashBorrower.onFlashLoan");
_enableApprove
bool _enableApprove;
_enableReturn
bool _enableReturn;
Functions
__ERC3156FlashBorrowerMock_init
function __ERC3156FlashBorrowerMock_init(bool enableReturn, bool enableApprove) internal onlyInitializing;
__ERC3156FlashBorrowerMock_init_unchained
function __ERC3156FlashBorrowerMock_init_unchained(bool enableReturn, bool enableApprove) internal onlyInitializing;
onFlashLoan
function onFlashLoan(address, address token, uint256 amount, uint256 fee, bytes calldata data)
public
returns (bytes32);
Events
BalanceOf
event BalanceOf(address token, address account, uint256 value);
TotalSupply
event TotalSupply(address token, uint256 value);
EtherReceiverMockUpgradeable
Inherits: Initializable
State Variables
_acceptEther
bool private _acceptEther;
Functions
__EtherReceiverMock_init
function __EtherReceiverMock_init() internal onlyInitializing;
__EtherReceiverMock_init_unchained
function __EtherReceiverMock_init_unchained() internal onlyInitializing;
setAcceptEther
function setAcceptEther(bool acceptEther) public;
receive
receive() external payable;
InitializableMock
Inherits: Initializable
This contract is a mock to test initializable functionality
State Variables
initializerRan
bool public initializerRan;
onlyInitializingRan
bool public onlyInitializingRan;
x
uint256 public x;
Functions
isInitializing
function isInitializing() public view returns (bool);
initialize
function initialize() public initializer;
initializeOnlyInitializing
function initializeOnlyInitializing() public onlyInitializing;
initializerNested
function initializerNested() public initializer;
onlyInitializingNested
function onlyInitializingNested() public initializer;
initializeWithX
function initializeWithX(uint256 _x) public payable initializer;
nonInitializable
function nonInitializable(uint256 _x) public payable;
fail
function fail() public pure;
ConstructorInitializableMock
Inherits: Initializable
State Variables
initializerRan
bool public initializerRan;
onlyInitializingRan
bool public onlyInitializingRan;
Functions
constructor
constructor() initializer;
initialize
function initialize() public initializer;
initializeOnlyInitializing
function initializeOnlyInitializing() public onlyInitializing;
ChildConstructorInitializableMock
Inherits: ConstructorInitializableMock
State Variables
childInitializerRan
bool public childInitializerRan;
Functions
constructor
constructor() initializer;
childInitialize
function childInitialize() public initializer;
ReinitializerMock
Inherits: Initializable
State Variables
counter
uint256 public counter;
Functions
getInitializedVersion
function getInitializedVersion() public view returns (uint64);
initialize
function initialize() public initializer;
reinitialize
function reinitialize(uint64 i) public reinitializer(i);
nestedReinitialize
function nestedReinitialize(uint64 i, uint64 j) public reinitializer(i);
chainReinitialize
function chainReinitialize(uint64 i, uint64 j) public;
disableInitializers
function disableInitializers() public;
doStuff
function doStuff() public onlyInitializing;
DisableNew
Inherits: Initializable
Functions
constructor
constructor();
DisableOld
Inherits: Initializable
Functions
constructor
constructor() initializer;
DisableBad1
Inherits: DisableNew, DisableOld
DisableBad2
Inherits: Initializable
Functions
constructor
constructor() initializer;
DisableOk
Inherits: DisableOld, DisableNew
MerkleProofCustomHashMockUpgradeable
Inherits: Initializable
Functions
__MerkleProofCustomHashMock_init
function __MerkleProofCustomHashMock_init() internal onlyInitializing;
__MerkleProofCustomHashMock_init_unchained
function __MerkleProofCustomHashMock_init_unchained() internal onlyInitializing;
customHash
function customHash(bytes32 a, bytes32 b) internal pure returns (bytes32);
verify
function verify(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal view returns (bool);
processProof
function processProof(bytes32[] calldata proof, bytes32 leaf) internal view returns (bytes32);
verifyCalldata
function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal view returns (bool);
processProofCalldata
function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal view returns (bytes32);
multiProofVerify
function multiProofVerify(bytes32[] calldata proof, bool[] calldata proofFlags, bytes32 root, bytes32[] calldata leaves)
internal
view
returns (bool);
processMultiProof
function processMultiProof(bytes32[] calldata proof, bool[] calldata proofFlags, bytes32[] calldata leaves)
internal
view
returns (bytes32);
multiProofVerifyCalldata
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] calldata leaves
) internal view returns (bool);
processMultiProofCalldata
function processMultiProofCalldata(bytes32[] calldata proof, bool[] calldata proofFlags, bytes32[] calldata leaves)
internal
view
returns (bytes32);
MerkleTreeMockUpgradeable
Inherits: Initializable
State Variables
_tree
MerkleTree.Bytes32PushTree private _tree;
root
bytes32 public root;
Functions
__MerkleTreeMock_init
function __MerkleTreeMock_init() internal onlyInitializing;
__MerkleTreeMock_init_unchained
function __MerkleTreeMock_init_unchained() internal onlyInitializing;
setup
function setup(uint8 _depth, bytes32 _zero) public;
push
function push(bytes32 leaf) public;
update
function update(uint256 index, bytes32 oldValue, bytes32 newValue, bytes32[] memory proof) public;
depth
function depth() public view returns (uint256);
nextLeafIndex
function nextLeafIndex() public view returns (uint256);
sides
function sides(uint256 i) public view returns (bytes32);
zeros
function zeros(uint256 i) public view returns (bytes32);
Events
LeafInserted
event LeafInserted(bytes32 leaf, uint256 index, bytes32 root);
LeafUpdated
event LeafUpdated(bytes32 oldLeaf, bytes32 newLeaf, uint256 index, bytes32 root);
MulticallHelperUpgradeable
Inherits: Initializable
Functions
__MulticallHelper_init
function __MulticallHelper_init() internal onlyInitializing;
__MulticallHelper_init_unchained
function __MulticallHelper_init_unchained() internal onlyInitializing;
checkReturnValues
function checkReturnValues(
ERC20MulticallMockUpgradeable multicallToken,
address[] calldata recipients,
uint256[] calldata amounts
) external;
SampleHuman
Inherits: Initializable
Sample base initializable contract that is a human
State Variables
isHuman
bool public isHuman;
Functions
initialize
function initialize() public initializer;
__SampleHuman_init
function __SampleHuman_init() internal onlyInitializing;
__SampleHuman_init_unchained
function __SampleHuman_init_unchained() internal onlyInitializing;
SampleMother
Inherits: Initializable, SampleHuman
Sample base initializable contract that defines a field mother
State Variables
mother
uint256 public mother;
Functions
initialize
function initialize(uint256 value) public initializer;
__SampleMother_init
function __SampleMother_init(uint256 value) internal onlyInitializing;
__SampleMother_init_unchained
function __SampleMother_init_unchained(uint256 value) internal onlyInitializing;
SampleGramps
Inherits: Initializable, SampleHuman
Sample base initializable contract that defines a field gramps
State Variables
gramps
string public gramps;
Functions
initialize
function initialize(string memory value) public initializer;
__SampleGramps_init
function __SampleGramps_init(string memory value) internal onlyInitializing;
__SampleGramps_init_unchained
function __SampleGramps_init_unchained(string memory value) internal onlyInitializing;
SampleFather
Inherits: Initializable, SampleGramps
Sample base initializable contract that defines a field father and extends from gramps
State Variables
father
uint256 public father;
Functions
initialize
function initialize(string memory _gramps, uint256 _father) public initializer;
__SampleFather_init
function __SampleFather_init(string memory _gramps, uint256 _father) internal onlyInitializing;
__SampleFather_init_unchained
function __SampleFather_init_unchained(uint256 _father) internal onlyInitializing;
SampleChild
Inherits: Initializable, SampleMother, SampleFather
Child extends from mother, father (gramps)
State Variables
child
uint256 public child;
Functions
initialize
function initialize(uint256 _mother, string memory _gramps, uint256 _father, uint256 _child) public initializer;
__SampleChild_init
function __SampleChild_init(uint256 _mother, string memory _gramps, uint256 _father, uint256 _child)
internal
onlyInitializing;
__SampleChild_init_unchained
function __SampleChild_init_unchained(uint256 _child) internal onlyInitializing;
PausableMockUpgradeable
Inherits: Initializable, PausableUpgradeable
State Variables
drasticMeasureTaken
bool public drasticMeasureTaken;
count
uint256 public count;
Functions
__PausableMock_init
function __PausableMock_init() internal onlyInitializing;
__PausableMock_init_unchained
function __PausableMock_init_unchained() internal onlyInitializing;
normalProcess
function normalProcess() external whenNotPaused;
drasticMeasure
function drasticMeasure() external whenPaused;
pause
function pause() external;
unpause
function unpause() external;
ReentrancyAttackUpgradeable
Inherits: Initializable, ContextUpgradeable
Functions
__ReentrancyAttack_init
function __ReentrancyAttack_init() internal onlyInitializing;
__ReentrancyAttack_init_unchained
function __ReentrancyAttack_init_unchained() internal onlyInitializing;
callSender
function callSender(bytes calldata data) public;
ReentrancyMockUpgradeable
Inherits: Initializable, ReentrancyGuardUpgradeable
State Variables
counter
uint256 public counter;
Functions
__ReentrancyMock_init
function __ReentrancyMock_init() internal onlyInitializing;
__ReentrancyMock_init_unchained
function __ReentrancyMock_init_unchained() internal onlyInitializing;
callback
function callback() external nonReentrant;
countLocalRecursive
function countLocalRecursive(uint256 n) public nonReentrant;
countThisRecursive
function countThisRecursive(uint256 n) public nonReentrant;
countAndCall
function countAndCall(ReentrancyAttackUpgradeable attacker) public nonReentrant;
_count
function _count() private;
guardedCheckEntered
function guardedCheckEntered() public nonReentrant;
unguardedCheckNotEntered
function unguardedCheckNotEntered() public view;
ReentrancyTransientMockUpgradeable
Inherits: Initializable, ReentrancyGuardTransientUpgradeable
State Variables
counter
uint256 public counter;
Functions
__ReentrancyTransientMock_init
function __ReentrancyTransientMock_init() internal onlyInitializing;
__ReentrancyTransientMock_init_unchained
function __ReentrancyTransientMock_init_unchained() internal onlyInitializing;
callback
function callback() external nonReentrant;
countLocalRecursive
function countLocalRecursive(uint256 n) public nonReentrant;
countThisRecursive
function countThisRecursive(uint256 n) public nonReentrant;
countAndCall
function countAndCall(ReentrancyAttackUpgradeable attacker) public nonReentrant;
_count
function _count() private;
guardedCheckEntered
function guardedCheckEntered() public nonReentrant;
unguardedCheckNotEntered
function unguardedCheckNotEntered() public view;
Implementation1
Inherits: Initializable
State Variables
_value
uint256 internal _value;
Functions
initialize
function initialize() public initializer;
setValue
function setValue(uint256 _number) public;
Implementation2
Inherits: Initializable
State Variables
_value
uint256 internal _value;
Functions
initialize
function initialize() public initializer;
setValue
function setValue(uint256 _number) public;
getValue
function getValue() public view returns (uint256);
Implementation3
Inherits: Initializable
State Variables
_value
uint256 internal _value;
Functions
initialize
function initialize() public initializer;
setValue
function setValue(uint256 _number) public;
getValue
function getValue(uint256 _number) public view returns (uint256);
Implementation4
Inherits: Initializable
State Variables
_value
uint256 internal _value;
Functions
initialize
function initialize() public initializer;
setValue
function setValue(uint256 _number) public;
getValue
function getValue() public view returns (uint256);
fallback
fallback() external;
MigratableMockV1
Inherits: Initializable
This contract is a mock to test initializable functionality through migrations
State Variables
x
uint256 public x;
Functions
initialize
function initialize(uint256 value) public payable initializer;
MigratableMockV2
Inherits: MigratableMockV1
This contract is a mock to test migratable functionality with params
State Variables
_migratedV2
bool internal _migratedV2;
y
uint256 public y;
Functions
migrate
function migrate(uint256 value, uint256 anotherValue) public payable;
MigratableMockV3
Inherits: MigratableMockV2
This contract is a mock to test migratable functionality without params
State Variables
_migratedV3
bool internal _migratedV3;
Functions
migrate
function migrate() public payable;
Dummy1234Upgradeable
Inherits: Initializable
Functions
__Dummy1234_init
function __Dummy1234_init() internal onlyInitializing;
__Dummy1234_init_unchained
function __Dummy1234_init_unchained() internal onlyInitializing;
StorageSlotMockUpgradeable
Inherits: Initializable, MulticallUpgradeable
State Variables
stringMap
mapping(uint256 key => string) public stringMap;
bytesMap
mapping(uint256 key => bytes) public bytesMap;
Functions
__StorageSlotMock_init
function __StorageSlotMock_init() internal onlyInitializing;
__StorageSlotMock_init_unchained
function __StorageSlotMock_init_unchained() internal onlyInitializing;
setAddressSlot
function setAddressSlot(bytes32 slot, address value) public;
setBooleanSlot
function setBooleanSlot(bytes32 slot, bool value) public;
setBytes32Slot
function setBytes32Slot(bytes32 slot, bytes32 value) public;
setUint256Slot
function setUint256Slot(bytes32 slot, uint256 value) public;
setInt256Slot
function setInt256Slot(bytes32 slot, int256 value) public;
getAddressSlot
function getAddressSlot(bytes32 slot) public view returns (address);
getBooleanSlot
function getBooleanSlot(bytes32 slot) public view returns (bool);
getBytes32Slot
function getBytes32Slot(bytes32 slot) public view returns (bytes32);
getUint256Slot
function getUint256Slot(bytes32 slot) public view returns (uint256);
getInt256Slot
function getInt256Slot(bytes32 slot) public view returns (int256);
setStringSlot
function setStringSlot(bytes32 slot, string calldata value) public;
setStringStorage
function setStringStorage(uint256 key, string calldata value) public;
getStringSlot
function getStringSlot(bytes32 slot) public view returns (string memory);
getStringStorage
function getStringStorage(uint256 key) public view returns (string memory);
setBytesSlot
function setBytesSlot(bytes32 slot, bytes calldata value) public;
setBytesStorage
function setBytesStorage(uint256 key, bytes calldata value) public;
getBytesSlot
function getBytesSlot(bytes32 slot) public view returns (bytes memory);
getBytesStorage
function getBytesStorage(uint256 key) public view returns (bytes memory);
TimelockReentrantUpgradeable
Inherits: Initializable
State Variables
_reenterTarget
address private _reenterTarget;
_reenterData
bytes private _reenterData;
_reentered
bool _reentered;
Functions
__TimelockReentrant_init
function __TimelockReentrant_init() internal onlyInitializing;
__TimelockReentrant_init_unchained
function __TimelockReentrant_init_unchained() internal onlyInitializing;
disableReentrancy
function disableReentrancy() external;
enableRentrancy
function enableRentrancy(address target, bytes calldata data) external;
reenter
function reenter() external;
TransientSlotMockUpgradeable
Inherits: Initializable, MulticallUpgradeable
Functions
__TransientSlotMock_init
function __TransientSlotMock_init() internal onlyInitializing;
__TransientSlotMock_init_unchained
function __TransientSlotMock_init_unchained() internal onlyInitializing;
tloadAddress
function tloadAddress(bytes32 slot) public;
tstore
function tstore(bytes32 slot, address value) public;
tloadBoolean
function tloadBoolean(bytes32 slot) public;
tstore
function tstore(bytes32 slot, bool value) public;
tloadBytes32
function tloadBytes32(bytes32 slot) public;
tstore
function tstore(bytes32 slot, bytes32 value) public;
tloadUint256
function tloadUint256(bytes32 slot) public;
tstore
function tstore(bytes32 slot, uint256 value) public;
tloadInt256
function tloadInt256(bytes32 slot) public;
tstore
function tstore(bytes32 slot, int256 value) public;
Events
AddressValue
event AddressValue(bytes32 slot, address value);
BooleanValue
event BooleanValue(bytes32 slot, bool value);
Bytes32Value
event Bytes32Value(bytes32 slot, bytes32 value);
Uint256Value
event Uint256Value(bytes32 slot, uint256 value);
Int256Value
event Int256Value(bytes32 slot, int256 value);
UpgradeableBeaconMockUpgradeable
Inherits: Initializable, IBeacon
State Variables
implementation
address public implementation;
Functions
__UpgradeableBeaconMock_init
function __UpgradeableBeaconMock_init(address impl) internal onlyInitializing;
__UpgradeableBeaconMock_init_unchained
function __UpgradeableBeaconMock_init_unchained(address impl) internal onlyInitializing;
UpgradeableBeaconReentrantMockUpgradeable
Inherits: Initializable, IBeacon
Functions
__UpgradeableBeaconReentrantMock_init
function __UpgradeableBeaconReentrantMock_init() internal onlyInitializing;
__UpgradeableBeaconReentrantMock_init_unchained
function __UpgradeableBeaconReentrantMock_init_unchained() internal onlyInitializing;
implementation
function implementation() external view override returns (address);
Errors
BeaconProxyBeaconSlotAddress
error BeaconProxyBeaconSlotAddress(address beacon);
VotesExtendedMockUpgradeable
Inherits: Initializable, VotesExtendedUpgradeable
State Variables
_votingUnits
mapping(address voter => uint256) private _votingUnits;
Functions
__VotesExtendedMock_init
function __VotesExtendedMock_init() internal onlyInitializing;
__VotesExtendedMock_init_unchained
function __VotesExtendedMock_init_unchained() internal onlyInitializing;
getTotalSupply
function getTotalSupply() public view returns (uint256);
delegate
function delegate(address account, address newDelegation) public;
_getVotingUnits
function _getVotingUnits(address account) internal view override returns (uint256);
_mint
function _mint(address account, uint256 votes) internal;
_burn
function _burn(address account, uint256 votes) internal;
VotesExtendedTimestampMockUpgradeable
Inherits: Initializable, VotesExtendedMockUpgradeable
Functions
__VotesExtendedTimestampMock_init
function __VotesExtendedTimestampMock_init() internal onlyInitializing;
__VotesExtendedTimestampMock_init_unchained
function __VotesExtendedTimestampMock_init_unchained() internal onlyInitializing;
clock
function clock() public view override returns (uint48);
CLOCK_MODE
function CLOCK_MODE() public view virtual override returns (string memory);
VotesMockUpgradeable
Inherits: Initializable, VotesUpgradeable
State Variables
_votingUnits
mapping(address voter => uint256) private _votingUnits;
Functions
__VotesMock_init
function __VotesMock_init() internal onlyInitializing;
__VotesMock_init_unchained
function __VotesMock_init_unchained() internal onlyInitializing;
getTotalSupply
function getTotalSupply() public view returns (uint256);
delegate
function delegate(address account, address newDelegation) public;
_getVotingUnits
function _getVotingUnits(address account) internal view override returns (uint256);
_mint
function _mint(address account, uint256 votes) internal;
_burn
function _burn(address account, uint256 votes) internal;
VotesTimestampMockUpgradeable
Inherits: Initializable, VotesMockUpgradeable
Functions
__VotesTimestampMock_init
function __VotesTimestampMock_init() internal onlyInitializing;
__VotesTimestampMock_init_unchained
function __VotesTimestampMock_init_unchained() internal onlyInitializing;
clock
function clock() public view override returns (uint48);
CLOCK_MODE
function CLOCK_MODE() public view virtual override returns (string memory);
AccessControlUpgradeableWithInit
Inherits: AccessControlUpgradeable
Functions
constructor
constructor() payable initializer;
AccessControlDefaultAdminRulesUpgradeableWithInit
Inherits: AccessControlDefaultAdminRulesUpgradeable
Functions
constructor
constructor(uint48 initialDelay, address initialDefaultAdmin) payable initializer;
AccessControlEnumerableUpgradeableWithInit
Inherits: AccessControlEnumerableUpgradeable
Functions
constructor
constructor() payable initializer;
AccessManagedUpgradeableWithInit
Inherits: AccessManagedUpgradeable
Functions
constructor
constructor(address initialAuthority) payable initializer;
AccessManagerUpgradeableWithInit
Inherits: AccessManagerUpgradeable
Functions
constructor
constructor(address initialAdmin) payable initializer;
OwnableUpgradeableWithInit
Inherits: OwnableUpgradeable
Functions
constructor
constructor(address initialOwner) payable initializer;
Ownable2StepUpgradeableWithInit
Inherits: Ownable2StepUpgradeable
Functions
constructor
constructor() payable initializer;
AccountERC7579UpgradeableWithInit
Inherits: AccountERC7579Upgradeable
Functions
constructor
constructor() payable initializer;
AccountERC7579HookedUpgradeableWithInit
Inherits: AccountERC7579HookedUpgradeable
Functions
constructor
constructor() payable initializer;
VestingWalletUpgradeableWithInit
Inherits: VestingWalletUpgradeable
Functions
constructor
constructor(address beneficiary, uint64 startTimestamp, uint64 durationSeconds) payable initializer;
VestingWalletCliffUpgradeableWithInit
Inherits: VestingWalletCliffUpgradeable
Functions
constructor
constructor(uint64 cliffSeconds) payable initializer;
TimelockControllerUpgradeableWithInit
Inherits: TimelockControllerUpgradeable
Functions
constructor
constructor(uint256 minDelay, address[] memory proposers, address[] memory executors, address admin)
payable
initializer;
ERC2771ContextUpgradeableWithInit
Inherits: ERC2771ContextUpgradeable
Functions
constructor
constructor(address trustedForwarder_) payable ERC2771ContextUpgradeable(trustedForwarder_) initializer;
ERC2771ForwarderUpgradeableWithInit
Inherits: ERC2771ForwarderUpgradeable
Functions
constructor
constructor(string memory name) payable initializer;
AccessManagedTargetUpgradeableWithInit
Inherits: AccessManagedTargetUpgradeable
Functions
constructor
constructor() payable initializer;
AccessManagerMockUpgradeableWithInit
Inherits: AccessManagerMockUpgradeable
Functions
constructor
constructor(address initialAdmin) payable initializer;
AccountMockUpgradeableWithInit
Inherits: AccountMockUpgradeable
Functions
constructor
constructor() payable initializer;
AccountECDSAMockUpgradeableWithInit
Inherits: AccountECDSAMockUpgradeable
Functions
constructor
constructor() payable initializer;
AccountP256MockUpgradeableWithInit
Inherits: AccountP256MockUpgradeable
Functions
constructor
constructor() payable initializer;
AccountRSAMockUpgradeableWithInit
Inherits: AccountRSAMockUpgradeable
Functions
constructor
constructor() payable initializer;
AccountERC7702MockUpgradeableWithInit
Inherits: AccountERC7702MockUpgradeable
Functions
constructor
constructor() payable initializer;
AccountERC7702WithModulesMockUpgradeableWithInit
Inherits: AccountERC7702WithModulesMockUpgradeable
Functions
constructor
constructor() payable initializer;
AccountERC7579MockUpgradeableWithInit
Inherits: AccountERC7579MockUpgradeable
Functions
constructor
constructor(address validator, bytes memory initData) payable initializer;
AccountERC7579HookedMockUpgradeableWithInit
Inherits: AccountERC7579HookedMockUpgradeable
Functions
constructor
constructor(address validator, bytes memory initData) payable initializer;
AccountERC7913MockUpgradeableWithInit
Inherits: AccountERC7913MockUpgradeable
Functions
constructor
constructor() payable initializer;
AccountMultiSignerMockUpgradeableWithInit
Inherits: AccountMultiSignerMockUpgradeable
Functions
constructor
constructor() payable initializer;
AccountMultiSignerWeightedMockUpgradeableWithInit
Inherits: AccountMultiSignerWeightedMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC7579ModuleMockUpgradeableWithInit
Inherits: ERC7579ModuleMockUpgradeable
Functions
constructor
constructor(uint256 moduleTypeId) payable initializer;
ERC7579HookMockUpgradeableWithInit
Inherits: ERC7579HookMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC7579FallbackHandlerMockUpgradeableWithInit
Inherits: ERC7579FallbackHandlerMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC7579ValidatorMockUpgradeableWithInit
Inherits: ERC7579ValidatorMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC7579UtilsGlobalMockUpgradeableWithInit
Inherits: ERC7579UtilsGlobalMockUpgradeable
Functions
constructor
constructor() payable initializer;
Uint256ArraysMockUpgradeableWithInit
Inherits: Uint256ArraysMockUpgradeable
Functions
constructor
constructor(uint256[] memory array) payable initializer;
AddressArraysMockUpgradeableWithInit
Inherits: AddressArraysMockUpgradeable
Functions
constructor
constructor(address[] memory array) payable initializer;
Bytes32ArraysMockUpgradeableWithInit
Inherits: Bytes32ArraysMockUpgradeable
Functions
constructor
constructor(bytes32[] memory array) payable initializer;
BytesArraysMockUpgradeableWithInit
Inherits: BytesArraysMockUpgradeable
Functions
constructor
constructor(bytes[] memory array) payable initializer;
StringArraysMockUpgradeableWithInit
Inherits: StringArraysMockUpgradeable
Functions
constructor
constructor(string[] memory array) payable initializer;
NotAuthorityMockUpgradeableWithInit
Inherits: NotAuthorityMockUpgradeable
Functions
constructor
constructor() payable initializer;
AuthorityNoDelayMockUpgradeableWithInit
Inherits: AuthorityNoDelayMockUpgradeable
Functions
constructor
constructor() payable initializer;
AuthorityDelayMockUpgradeableWithInit
Inherits: AuthorityDelayMockUpgradeable
Functions
constructor
constructor() payable initializer;
AuthorityNoResponseUpgradeableWithInit
Inherits: AuthorityNoResponseUpgradeable
Functions
constructor
constructor() payable initializer;
AuthorityObserveIsConsumingUpgradeableWithInit
Inherits: AuthorityObserveIsConsumingUpgradeable
Functions
constructor
constructor() payable initializer;
Base64DirtyUpgradeableWithInit
Inherits: Base64DirtyUpgradeable
Functions
constructor
constructor() payable initializer;
BatchCallerUpgradeableWithInit
Inherits: BatchCallerUpgradeable
Functions
constructor
constructor() payable initializer;
CallReceiverMockUpgradeableWithInit
Inherits: CallReceiverMockUpgradeable
Functions
constructor
constructor() payable initializer;
CallReceiverMockTrustingForwarderUpgradeableWithInit
Inherits: CallReceiverMockTrustingForwarderUpgradeable
Functions
constructor
constructor(address trustedForwarder_) payable initializer;
CompTimelockUpgradeableWithInit
Inherits: CompTimelockUpgradeable
Functions
constructor
constructor(address admin_, uint256 delay_) payable initializer;
ConstructorMockUpgradeableWithInit
Inherits: ConstructorMockUpgradeable
Functions
constructor
constructor(RevertType error) payable initializer;
ContextMockUpgradeableWithInit
Inherits: ContextMockUpgradeable
Functions
constructor
constructor() payable initializer;
ContextMockCallerUpgradeableWithInit
Inherits: ContextMockCallerUpgradeable
Functions
constructor
constructor() payable initializer;
AccessControlERC20MintBaseUpgradeableWithInit
Inherits: AccessControlERC20MintBaseUpgradeable
Functions
constructor
constructor(address minter) payable initializer;
AccessControlERC20MintMissingUpgradeableWithInit
Inherits: AccessControlERC20MintMissingUpgradeable
Functions
constructor
constructor() payable initializer;
AccessControlERC20MintUpgradeableWithInit
Inherits: AccessControlERC20MintUpgradeable
Functions
constructor
constructor(address minter, address burner) payable initializer;
AccessControlModifiedUpgradeableWithInit
Inherits: AccessControlModifiedUpgradeable
Functions
constructor
constructor() payable initializer;
AccessManagedERC20MintUpgradeableWithInit
Inherits: AccessManagedERC20MintUpgradeable
Functions
constructor
constructor(address manager) payable initializer;
MyContractUpgradeableWithInit
Inherits: MyContractUpgradeable
Functions
constructor
constructor(address initialOwner) payable initializer;
MyAccountERC7702UpgradeableWithInit
Inherits: MyAccountERC7702Upgradeable
Functions
constructor
constructor() payable initializer;
MyFactoryAccountUpgradeableWithInit
Inherits: MyFactoryAccountUpgradeable
Functions
constructor
constructor(address impl_) payable initializer;
ERC20WithAutoMinerRewardUpgradeableWithInit
Inherits: ERC20WithAutoMinerRewardUpgradeable
Functions
constructor
constructor() payable initializer;
ERC4626FeesUpgradeableWithInit
Inherits: ERC4626FeesUpgradeable
Functions
constructor
constructor() payable initializer;
MyGovernorUpgradeableWithInit
Inherits: MyGovernorUpgradeable
Functions
constructor
constructor(IVotes _token, TimelockControllerUpgradeable _timelock) payable initializer;
MyTokenUpgradeableWithInit
Inherits: MyTokenUpgradeable
Functions
constructor
constructor() payable initializer;
MyTokenTimestampBasedUpgradeableWithInit
Inherits: MyTokenTimestampBasedUpgradeable
Functions
constructor
constructor() payable initializer;
MyTokenWrappedUpgradeableWithInit
Inherits: MyTokenWrappedUpgradeable
Functions
constructor
constructor(IERC20 wrappedToken) payable initializer;
MyNFTUpgradeableWithInit
Inherits: MyNFTUpgradeable
Functions
constructor
constructor() payable initializer;
GameItemsUpgradeableWithInit
Inherits: GameItemsUpgradeable
Functions
constructor
constructor() payable initializer;
MyERC115HolderContractUpgradeableWithInit
Inherits: MyERC115HolderContractUpgradeable
Functions
constructor
constructor() payable initializer;
GLDTokenUpgradeableWithInit
Inherits: GLDTokenUpgradeable
Functions
constructor
constructor(uint256 initialSupply) payable initializer;
ERC6909GameItemsUpgradeableWithInit
Inherits: ERC6909GameItemsUpgradeable
Functions
constructor
constructor() payable initializer;
GameItemUpgradeableWithInit
Inherits: GameItemUpgradeable
Functions
constructor
constructor() payable initializer;
Base64NFTUpgradeableWithInit
Inherits: Base64NFTUpgradeable
Functions
constructor
constructor() payable initializer;
BoxUpgradeableWithInit
Inherits: BoxUpgradeable
Functions
constructor
constructor() payable initializer;
DummyImplementationUpgradeableWithInit
Inherits: DummyImplementationUpgradeable
Functions
constructor
constructor() payable initializer;
DummyImplementationV2UpgradeableWithInit
Inherits: DummyImplementationV2Upgradeable
Functions
constructor
constructor() payable initializer;
EIP712VerifierUpgradeableWithInit
Inherits: EIP712VerifierUpgradeable
Functions
constructor
constructor() payable initializer;
ERC1271WalletMockUpgradeableWithInit
Inherits: ERC1271WalletMockUpgradeable
Functions
constructor
constructor(address originalOwner) payable initializer;
ERC1271MaliciousMockUpgradeableWithInit
Inherits: ERC1271MaliciousMockUpgradeable
Functions
constructor
constructor() payable initializer;
SupportsInterfaceWithLookupMockUpgradeableWithInit
Inherits: SupportsInterfaceWithLookupMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC165InterfacesSupportedUpgradeableWithInit
Inherits: ERC165InterfacesSupportedUpgradeable
Functions
constructor
constructor(bytes4[] memory interfaceIds) payable initializer;
ERC165MaliciousDataUpgradeableWithInit
Inherits: ERC165MaliciousDataUpgradeable
Functions
constructor
constructor() payable initializer;
ERC165MissingDataUpgradeableWithInit
Inherits: ERC165MissingDataUpgradeable
Functions
constructor
constructor() payable initializer;
ERC165NotSupportedUpgradeableWithInit
Inherits: ERC165NotSupportedUpgradeable
Functions
constructor
constructor() payable initializer;
ERC165ReturnBombMockUpgradeableWithInit
Inherits: ERC165ReturnBombMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC2771ContextMockUpgradeableWithInit
Inherits: ERC2771ContextMockUpgradeable
Functions
constructor
constructor(address trustedForwarder) payable ERC2771ContextMockUpgradeable(trustedForwarder) initializer;
ERC3156FlashBorrowerMockUpgradeableWithInit
Inherits: ERC3156FlashBorrowerMockUpgradeable
Functions
constructor
constructor(bool enableReturn, bool enableApprove) payable initializer;
EtherReceiverMockUpgradeableWithInit
Inherits: EtherReceiverMockUpgradeable
Functions
constructor
constructor() payable initializer;
GovernorCountingOverridableMockUpgradeableWithInit
Inherits: GovernorCountingOverridableMockUpgradeable
Functions
constructor
constructor() payable initializer;
GovernorFractionalMockUpgradeableWithInit
Inherits: GovernorFractionalMockUpgradeable
Functions
constructor
constructor() payable initializer;
GovernorMockUpgradeableWithInit
Inherits: GovernorMockUpgradeable
Functions
constructor
constructor() payable initializer;
GovernorNoncesKeyedMockUpgradeableWithInit
Inherits: GovernorNoncesKeyedMockUpgradeable
Functions
constructor
constructor() payable initializer;
GovernorPreventLateQuorumMockUpgradeableWithInit
Inherits: GovernorPreventLateQuorumMockUpgradeable
Functions
constructor
constructor(uint256 quorum_) payable initializer;
GovernorProposalGuardianMockUpgradeableWithInit
Inherits: GovernorProposalGuardianMockUpgradeable
Functions
constructor
constructor() payable initializer;
GovernorSequentialProposalIdMockUpgradeableWithInit
Inherits: GovernorSequentialProposalIdMockUpgradeable
Functions
constructor
constructor() payable initializer;
GovernorStorageMockUpgradeableWithInit
Inherits: GovernorStorageMockUpgradeable
Functions
constructor
constructor() payable initializer;
GovernorSuperQuorumMockUpgradeableWithInit
Inherits: GovernorSuperQuorumMockUpgradeable
Functions
constructor
constructor(uint256 quorum_, uint256 superQuorum_) payable initializer;
GovernorTimelockAccessMockUpgradeableWithInit
Inherits: GovernorTimelockAccessMockUpgradeable
Functions
constructor
constructor() payable initializer;
GovernorTimelockCompoundMockUpgradeableWithInit
Inherits: GovernorTimelockCompoundMockUpgradeable
Functions
constructor
constructor() payable initializer;
GovernorTimelockControlMockUpgradeableWithInit
Inherits: GovernorTimelockControlMockUpgradeable
Functions
constructor
constructor() payable initializer;
GovernorVoteMocksUpgradeableWithInit
Inherits: GovernorVoteMocksUpgradeable
Functions
constructor
constructor() payable initializer;
GovernorVotesSuperQuorumFractionMockUpgradeableWithInit
Inherits: GovernorVotesSuperQuorumFractionMockUpgradeable
Functions
constructor
constructor() payable initializer;
GovernorWithParamsMockUpgradeableWithInit
Inherits: GovernorWithParamsMockUpgradeable
Functions
constructor
constructor() payable initializer;
MerkleProofCustomHashMockUpgradeableWithInit
Inherits: MerkleProofCustomHashMockUpgradeable
Functions
constructor
constructor() payable initializer;
MerkleTreeMockUpgradeableWithInit
Inherits: MerkleTreeMockUpgradeable
Functions
constructor
constructor() payable initializer;
MulticallHelperUpgradeableWithInit
Inherits: MulticallHelperUpgradeable
Functions
constructor
constructor() payable initializer;
PausableMockUpgradeableWithInit
Inherits: PausableMockUpgradeable
Functions
constructor
constructor() payable initializer;
BadBeaconNoImplUpgradeableWithInit
Inherits: BadBeaconNoImplUpgradeable
Functions
constructor
constructor() payable initializer;
BadBeaconNotContractUpgradeableWithInit
Inherits: BadBeaconNotContractUpgradeable
Functions
constructor
constructor() payable initializer;
ClashingImplementationUpgradeableWithInit
Inherits: ClashingImplementationUpgradeable
Functions
constructor
constructor() payable initializer;
NonUpgradeableMockUpgradeableWithInit
Inherits: NonUpgradeableMockUpgradeable
Functions
constructor
constructor() payable initializer;
UUPSUpgradeableMockUpgradeableWithInit
Inherits: UUPSUpgradeableMockUpgradeable
Functions
constructor
constructor() payable initializer;
UUPSUpgradeableUnsafeMockUpgradeableWithInit
Inherits: UUPSUpgradeableUnsafeMockUpgradeable
Functions
constructor
constructor() payable initializer;
UUPSUnsupportedProxiableUUIDUpgradeableWithInit
Inherits: UUPSUnsupportedProxiableUUIDUpgradeable
Functions
constructor
constructor() payable initializer;
ReentrancyAttackUpgradeableWithInit
Inherits: ReentrancyAttackUpgradeable
Functions
constructor
constructor() payable initializer;
ReentrancyMockUpgradeableWithInit
Inherits: ReentrancyMockUpgradeable
Functions
constructor
constructor() payable initializer;
ReentrancyTransientMockUpgradeableWithInit
Inherits: ReentrancyTransientMockUpgradeable
Functions
constructor
constructor() payable initializer;
Dummy1234UpgradeableWithInit
Inherits: Dummy1234Upgradeable
Functions
constructor
constructor() payable initializer;
StorageSlotMockUpgradeableWithInit
Inherits: StorageSlotMockUpgradeable
Functions
constructor
constructor() payable initializer;
TimelockReentrantUpgradeableWithInit
Inherits: TimelockReentrantUpgradeable
Functions
constructor
constructor() payable initializer;
ERC1155ReceiverMockUpgradeableWithInit
Inherits: ERC1155ReceiverMockUpgradeable
Functions
constructor
constructor(bytes4 recRetval, bytes4 batRetval, RevertType error) payable initializer;
ERC1363ForceApproveMockUpgradeableWithInit
Inherits: ERC1363ForceApproveMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC1363NoReturnMockUpgradeableWithInit
Inherits: ERC1363NoReturnMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC1363ReceiverMockUpgradeableWithInit
Inherits: ERC1363ReceiverMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC1363ReturnFalseOnERC20MockUpgradeableWithInit
Inherits: ERC1363ReturnFalseOnERC20MockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC1363ReturnFalseMockUpgradeableWithInit
Inherits: ERC1363ReturnFalseMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC1363SpenderMockUpgradeableWithInit
Inherits: ERC1363SpenderMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC20ApprovalMockUpgradeableWithInit
Inherits: ERC20ApprovalMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC20BridgeableMockUpgradeableWithInit
Inherits: ERC20BridgeableMockUpgradeable
Functions
constructor
constructor(address bridge) payable initializer;
ERC20DecimalsMockUpgradeableWithInit
Inherits: ERC20DecimalsMockUpgradeable
Functions
constructor
constructor(uint8 decimals_) payable initializer;
ERC20ExcessDecimalsMockUpgradeableWithInit
Inherits: ERC20ExcessDecimalsMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC20FlashMintMockUpgradeableWithInit
Inherits: ERC20FlashMintMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC20ForceApproveMockUpgradeableWithInit
Inherits: ERC20ForceApproveMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC20GetterHelperUpgradeableWithInit
Inherits: ERC20GetterHelperUpgradeable
Functions
constructor
constructor() payable initializer;
ERC20MockUpgradeableWithInit
Inherits: ERC20MockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC20MulticallMockUpgradeableWithInit
Inherits: ERC20MulticallMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC20NoReturnMockUpgradeableWithInit
Inherits: ERC20NoReturnMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC20ReentrantUpgradeableWithInit
Inherits: ERC20ReentrantUpgradeable
Functions
constructor
constructor() payable initializer;
ERC20ReturnFalseMockUpgradeableWithInit
Inherits: ERC20ReturnFalseMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC20VotesExtendedMockUpgradeableWithInit
Inherits: ERC20VotesExtendedMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC20VotesExtendedTimestampMockUpgradeableWithInit
Inherits: ERC20VotesExtendedTimestampMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC20VotesLegacyMockUpgradeableWithInit
Inherits: ERC20VotesLegacyMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC20VotesTimestampMockUpgradeableWithInit
Inherits: ERC20VotesTimestampMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC721VotesTimestampMockUpgradeableWithInit
Inherits: ERC721VotesTimestampMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC4626LimitsMockUpgradeableWithInit
Inherits: ERC4626LimitsMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC4626MockUpgradeableWithInit
Inherits: ERC4626MockUpgradeable
Functions
constructor
constructor(address underlying) payable initializer;
ERC4626OffsetMockUpgradeableWithInit
Inherits: ERC4626OffsetMockUpgradeable
Functions
constructor
constructor(uint8 offset_) payable initializer;
ERC4626FeesMockUpgradeableWithInit
Inherits: ERC4626FeesMockUpgradeable
Functions
constructor
constructor(
uint256 entryFeeBasisPoints,
address entryFeeRecipient,
uint256 exitFeeBasisPoints,
address exitFeeRecipient
) payable initializer;
ERC721ConsecutiveEnumerableMockUpgradeableWithInit
Inherits: ERC721ConsecutiveEnumerableMockUpgradeable
Functions
constructor
constructor(string memory name, string memory symbol, address[] memory receivers, uint96[] memory amounts)
payable
initializer;
ERC721ConsecutiveMockUpgradeableWithInit
Inherits: ERC721ConsecutiveMockUpgradeable
Functions
constructor
constructor(
string memory name,
string memory symbol,
uint96 offset,
address[] memory delegates,
address[] memory receivers,
uint96[] memory amounts
) payable initializer;
ERC721ConsecutiveNoConstructorMintMockUpgradeableWithInit
Inherits: ERC721ConsecutiveNoConstructorMintMockUpgradeable
Functions
constructor
constructor(string memory name, string memory symbol) payable initializer;
ERC721ReceiverMockUpgradeableWithInit
Inherits: ERC721ReceiverMockUpgradeable
Functions
constructor
constructor(bytes4 retval, RevertType error) payable initializer;
ERC721URIStorageMockUpgradeableWithInit
Inherits: ERC721URIStorageMockUpgradeable
Functions
constructor
constructor() payable initializer;
TransientSlotMockUpgradeableWithInit
Inherits: TransientSlotMockUpgradeable
Functions
constructor
constructor() payable initializer;
UpgradeableBeaconMockUpgradeableWithInit
Inherits: UpgradeableBeaconMockUpgradeable
Functions
constructor
constructor(address impl) payable initializer;
UpgradeableBeaconReentrantMockUpgradeableWithInit
Inherits: UpgradeableBeaconReentrantMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC7739ECDSAMockUpgradeableWithInit
Inherits: ERC7739ECDSAMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC7739P256MockUpgradeableWithInit
Inherits: ERC7739P256MockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC7739RSAMockUpgradeableWithInit
Inherits: ERC7739RSAMockUpgradeable
Functions
constructor
constructor() payable initializer;
VotesExtendedMockUpgradeableWithInit
Inherits: VotesExtendedMockUpgradeable
Functions
constructor
constructor() payable initializer;
VotesExtendedTimestampMockUpgradeableWithInit
Inherits: VotesExtendedTimestampMockUpgradeable
Functions
constructor
constructor() payable initializer;
VotesMockUpgradeableWithInit
Inherits: VotesMockUpgradeable
Functions
constructor
constructor() payable initializer;
VotesTimestampMockUpgradeableWithInit
Inherits: VotesTimestampMockUpgradeable
Functions
constructor
constructor() payable initializer;
ERC2981UpgradeableWithInit
Inherits: ERC2981Upgradeable
Functions
constructor
constructor() payable initializer;
ERC1155UpgradeableWithInit
Inherits: ERC1155Upgradeable
Functions
constructor
constructor(string memory uri_) payable initializer;
ERC1155BurnableUpgradeableWithInit
Inherits: ERC1155BurnableUpgradeable
Functions
constructor
constructor() payable initializer;
ERC1155PausableUpgradeableWithInit
Inherits: ERC1155PausableUpgradeable
Functions
constructor
constructor() payable initializer;
ERC1155SupplyUpgradeableWithInit
Inherits: ERC1155SupplyUpgradeable
Functions
constructor
constructor() payable initializer;
ERC1155URIStorageUpgradeableWithInit
Inherits: ERC1155URIStorageUpgradeable
Functions
constructor
constructor() payable initializer;
ERC1155HolderUpgradeableWithInit
Inherits: ERC1155HolderUpgradeable
Functions
constructor
constructor() payable initializer;
ERC20UpgradeableWithInit
Inherits: ERC20Upgradeable
Functions
constructor
constructor(string memory name_, string memory symbol_) payable initializer;
ERC20TemporaryApprovalUpgradeableWithInit
Inherits: ERC20TemporaryApprovalUpgradeable
Functions
constructor
constructor() payable initializer;
ERC1363UpgradeableWithInit
Inherits: ERC1363Upgradeable
Functions
constructor
constructor() payable initializer;
ERC20BurnableUpgradeableWithInit
Inherits: ERC20BurnableUpgradeable
Functions
constructor
constructor() payable initializer;
ERC20CappedUpgradeableWithInit
Inherits: ERC20CappedUpgradeable
Functions
constructor
constructor(uint256 cap_) payable initializer;
ERC20FlashMintUpgradeableWithInit
Inherits: ERC20FlashMintUpgradeable
Functions
constructor
constructor() payable initializer;
ERC20PausableUpgradeableWithInit
Inherits: ERC20PausableUpgradeable
Functions
constructor
constructor() payable initializer;
ERC20PermitUpgradeableWithInit
Inherits: ERC20PermitUpgradeable
Functions
constructor
constructor(string memory name) payable initializer;
ERC20VotesUpgradeableWithInit
Inherits: ERC20VotesUpgradeable
Functions
constructor
constructor() payable initializer;
ERC20WrapperUpgradeableWithInit
Inherits: ERC20WrapperUpgradeable
Functions
constructor
constructor(IERC20 underlyingToken) payable initializer;
ERC4626UpgradeableWithInit
Inherits: ERC4626Upgradeable
Functions
constructor
constructor(IERC20 asset_) payable initializer;
ERC6909UpgradeableWithInit
Inherits: ERC6909Upgradeable
Functions
constructor
constructor() payable initializer;
ERC6909ContentURIUpgradeableWithInit
Inherits: ERC6909ContentURIUpgradeable
Functions
constructor
constructor() payable initializer;
ERC6909MetadataUpgradeableWithInit
Inherits: ERC6909MetadataUpgradeable
Functions
constructor
constructor() payable initializer;
ERC6909TokenSupplyUpgradeableWithInit
Inherits: ERC6909TokenSupplyUpgradeable
Functions
constructor
constructor() payable initializer;
ERC721UpgradeableWithInit
Inherits: ERC721Upgradeable
Functions
constructor
constructor(string memory name_, string memory symbol_) payable initializer;
ERC721BurnableUpgradeableWithInit
Inherits: ERC721BurnableUpgradeable
Functions
constructor
constructor() payable initializer;
ERC721ConsecutiveUpgradeableWithInit
Inherits: ERC721ConsecutiveUpgradeable
Functions
constructor
constructor() payable initializer;
ERC721EnumerableUpgradeableWithInit
Inherits: ERC721EnumerableUpgradeable
Functions
constructor
constructor() payable initializer;
ERC721PausableUpgradeableWithInit
Inherits: ERC721PausableUpgradeable
Functions
constructor
constructor() payable initializer;
ERC721RoyaltyUpgradeableWithInit
Inherits: ERC721RoyaltyUpgradeable
Functions
constructor
constructor() payable initializer;
ERC721URIStorageUpgradeableWithInit
Inherits: ERC721URIStorageUpgradeable
Functions
constructor
constructor() payable initializer;
ERC721VotesUpgradeableWithInit
Inherits: ERC721VotesUpgradeable
Functions
constructor
constructor() payable initializer;
ERC721WrapperUpgradeableWithInit
Inherits: ERC721WrapperUpgradeable
Functions
constructor
constructor(IERC721 underlyingToken) payable initializer;
ERC721HolderUpgradeableWithInit
Inherits: ERC721HolderUpgradeable
Functions
constructor
constructor() payable initializer;
ContextUpgradeableWithInit
Inherits: ContextUpgradeable
Functions
constructor
constructor() payable initializer;
EIP712UpgradeableWithInit
Inherits: EIP712Upgradeable
Functions
constructor
constructor(string memory name, string memory version) payable initializer;
MultiSignerERC7913UpgradeableWithInit
Inherits: MultiSignerERC7913Upgradeable
Functions
constructor
constructor(bytes[] memory signers_, uint64 threshold_) payable initializer;
MultiSignerERC7913WeightedUpgradeableWithInit
Inherits: MultiSignerERC7913WeightedUpgradeable
Functions
constructor
constructor(bytes[] memory signers_, uint64[] memory weights_, uint64 threshold_) payable initializer;
SignerECDSAUpgradeableWithInit
Inherits: SignerECDSAUpgradeable
Functions
constructor
constructor(address signerAddr) payable initializer;
SignerERC7913UpgradeableWithInit
Inherits: SignerERC7913Upgradeable
Functions
constructor
constructor(bytes memory signer_) payable initializer;
SignerP256UpgradeableWithInit
Inherits: SignerP256Upgradeable
Functions
constructor
constructor(bytes32 qx, bytes32 qy) payable initializer;
SignerRSAUpgradeableWithInit
Inherits: SignerRSAUpgradeable
Functions
constructor
constructor(bytes memory e, bytes memory n) payable initializer;
ERC165UpgradeableWithInit
Inherits: ERC165Upgradeable
Functions
constructor
constructor() payable initializer;
MulticallUpgradeableWithInit
Inherits: MulticallUpgradeable
Functions
constructor
constructor() payable initializer;
NoncesUpgradeableWithInit
Inherits: NoncesUpgradeable
Functions
constructor
constructor() payable initializer;
NoncesKeyedUpgradeableWithInit
Inherits: NoncesKeyedUpgradeable
Functions
constructor
constructor() payable initializer;
PausableUpgradeableWithInit
Inherits: PausableUpgradeable
Functions
constructor
constructor() payable initializer;
ReentrancyGuardUpgradeableWithInit
Inherits: ReentrancyGuardUpgradeable
Functions
constructor
constructor() payable initializer;
ReentrancyGuardTransientUpgradeableWithInit
Inherits: ReentrancyGuardTransientUpgradeable
Functions
constructor
constructor() payable initializer;
Contents
Contents
Initializable
*This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
external initializer function, usually called initialize. It then becomes necessary to protect this initializer
function so it can only be called once. The initializer modifier provided by this contract will have this effect.
The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
case an upgrade adds a module that needs to be initialized.
For example:
[.hljs-theme-light.nopadding]
contract MyToken is ERC20Upgradeable {
function initialize() initializer public {
__ERC20_init("MyToken", "MTK");
}
}
contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
function initializeV2() reinitializer(2) public {
__ERC20Permit_init("MyToken");
}
}
TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
possible by providing the encoded function call as the _data argument to {ERC1967Proxy-constructor}.
CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
[CAUTION]
Avoid leaving a contract uninitialized. An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: [.hljs-theme-light.nopadding]
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
====*
State Variables
INITIALIZABLE_STORAGE
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
Functions
initializer
A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
onlyInitializing functions can be used to initialize parent contracts.
Similar to reinitializer(1), except that in the context of a constructor an initializer may be invoked any
number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
production.
Emits an Initialized event.
modifier initializer();
reinitializer
A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
contract hasn't been initialized to a greater version before. In its scope, onlyInitializing functions can be
used to initialize parent contracts.
A reinitializer may be used after the original initialization step. This is essential to configure modules that
are added through upgrades and that require initialization.
When version is 1, this modifier is similar to initializer, except that functions marked with reinitializer
cannot be nested. If one is invoked in the context of another, execution will revert.
Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
a contract, executing them in the right order is up to the developer or operator.
WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
Emits an Initialized event.
modifier reinitializer(uint64 version);
onlyInitializing
Modifier to protect an initialization function so that it can only be invoked by functions with the initializer and {reinitializer} modifiers, directly or indirectly.
modifier onlyInitializing();
_checkInitializing
Reverts if the contract is not in an initializing state. See onlyInitializing.
function _checkInitializing() internal view virtual;
_disableInitializers
Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized to any version. It is recommended to use this to lock implementation contracts that are designed to be called through proxies. Emits an Initialized event the first time it is successfully executed.
function _disableInitializers() internal virtual;
_getInitializedVersion
Returns the highest version that has been initialized. See reinitializer.
function _getInitializedVersion() internal view returns (uint64);
_isInitializing
Returns true if the contract is currently initializing. See onlyInitializing.
function _isInitializing() internal view returns (bool);
_initializableStorageSlot
Pointer to storage slot. Allows integrators to override it with a custom storage location. NOTE: Consider following the ERC-7201 formula to derive storage locations.
function _initializableStorageSlot() internal pure virtual returns (bytes32);
_getInitializableStorage
Returns a pointer to the storage namespace.
function _getInitializableStorage() private pure returns (InitializableStorage storage $);
Events
Initialized
Triggered when the contract has been initialized or reinitialized.
event Initialized(uint64 version);
Errors
InvalidInitialization
The contract is already initialized.
error InvalidInitialization();
NotInitializing
The contract is not initializing.
error NotInitializing();
Structs
InitializableStorage
Storage of the initializable contract. It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions when using with upgradeable contracts.
Note: storage-location: erc7201:openzeppelin.storage.Initializable
struct InitializableStorage {
uint64 _initialized;
bool _initializing;
}
UUPSUpgradeable
Inherits: Initializable, IERC1822Proxiable
An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
{ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
UUPSUpgradeable with a custom implementation of upgrades.
The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
State Variables
__self
Note: oz-upgrades-unsafe-allow: state-variable-immutable
address private immutable __self = address(this);
UPGRADE_INTERFACE_VERSION
The version of the upgrade interface of the contract. If this getter is missing, both upgradeTo(address)
and upgradeToAndCall(address,bytes) are present, and upgradeTo must be used if no function should be called,
while upgradeToAndCall will invoke the receive function if the second argument is the empty byte string.
If the getter returns "5.0.0", only upgradeToAndCall(address,bytes) is present, and the second argument must
be the empty byte string if no function should be called, making it impossible to invoke the receive function
during an upgrade.
string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";
Functions
onlyProxy
Check that the execution is being performed through a delegatecall call and that the execution context is a proxy contract with an implementation (as defined in ERC-1967) pointing to self. This should only be the case for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a function through ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to fail.
modifier onlyProxy();
notDelegated
Check that the execution is not being performed through a delegate call. This allows a function to be callable on the implementing contract but not through proxies.
modifier notDelegated();
__UUPSUpgradeable_init
function __UUPSUpgradeable_init() internal onlyInitializing;
__UUPSUpgradeable_init_unchained
function __UUPSUpgradeable_init_unchained() internal onlyInitializing;
proxiableUUID
Implementation of the ERC-1822 proxiableUUID function. This returns the storage slot used by the
implementation. It is used to validate the implementation's compatibility when performing an upgrade.
IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
function revert if invoked through a proxy. This is guaranteed by the notDelegated modifier.
function proxiableUUID() external view virtual notDelegated returns (bytes32);
upgradeToAndCall
Upgrade the implementation of the proxy to newImplementation, and subsequently execute the function call
encoded in data.
Calls _authorizeUpgrade.
Emits an {Upgraded} event.
Note: oz-upgrades-unsafe-allow-reachable: delegatecall
function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy;
_checkProxy
Reverts if the execution is not performed via delegatecall or the execution context is not of a proxy with an ERC-1967 compliant implementation pointing to self.
function _checkProxy() internal view virtual;
_checkNotDelegated
Reverts if the execution is performed via delegatecall. See notDelegated.
function _checkNotDelegated() internal view virtual;
_authorizeUpgrade
*Function that should revert when msg.sender is not authorized to upgrade the contract. Called by
upgradeToAndCall.
Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
function _authorizeUpgrade(address) internal onlyOwner {}
```*
```solidity
function _authorizeUpgrade(address newImplementation) internal virtual;
_upgradeToAndCallUUPS
Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call. As a security check, proxiableUUID is invoked in the new implementation, and the return value is expected to be the implementation slot in ERC-1967. Emits an {IERC1967-Upgraded} event.
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private;
Errors
UUPSUnauthorizedCallContext
The call is from an unauthorized context.
error UUPSUnauthorizedCallContext();
UUPSUnsupportedProxiableUUID
The storage slot is unsupported as a UUID.
error UUPSUnsupportedProxiableUUID(bytes32 slot);
Contents
Contents
Contents
- ERC1155BurnableUpgradeable
- ERC1155PausableUpgradeable
- ERC1155SupplyUpgradeable
- ERC1155URIStorageUpgradeable
ERC1155BurnableUpgradeable
Inherits: Initializable, ERC1155Upgradeable
Extension of {ERC1155} that allows token holders to destroy both their own tokens and those that they have been approved to use.
Functions
__ERC1155Burnable_init
function __ERC1155Burnable_init() internal onlyInitializing;
__ERC1155Burnable_init_unchained
function __ERC1155Burnable_init_unchained() internal onlyInitializing;
burn
function burn(address account, uint256 id, uint256 value) public virtual;
burnBatch
function burnBatch(address account, uint256[] memory ids, uint256[] memory values) public virtual;
ERC1155PausableUpgradeable
Inherits: Initializable, ERC1155Upgradeable, PausableUpgradeable
ERC-1155 token with pausable token transfers, minting and burning. Useful for scenarios such as preventing trades until the end of an evaluation period, or having an emergency switch for freezing all token transfers in the event of a large bug. IMPORTANT: This contract does not include public pause and unpause functions. In addition to inheriting this contract, you must define both functions, invoking the Pausable-_pause and {Pausable-_unpause} internal functions, with appropriate access control, e.g. using {AccessControl} or {Ownable}. Not doing so will make the contract pause mechanism of the contract unreachable, and thus unusable.
Functions
__ERC1155Pausable_init
function __ERC1155Pausable_init() internal onlyInitializing;
__ERC1155Pausable_init_unchained
function __ERC1155Pausable_init_unchained() internal onlyInitializing;
_update
*See ERC1155-_update. Requirements:
- the contract must not be paused.*
function _update(address from, address to, uint256[] memory ids, uint256[] memory values)
internal
virtual
override
whenNotPaused;
ERC1155SupplyUpgradeable
Inherits: Initializable, ERC1155Upgradeable
Extension of ERC-1155 that adds tracking of total supply per id. Useful for scenarios where Fungible and Non-fungible tokens have to be clearly identified. Note: While a totalSupply of 1 might mean the corresponding is an NFT, there is no guarantees that no other token with the same id are not going to be minted. NOTE: This contract implies a global limit of 2**256 - 1 to the number of tokens that can be minted. CAUTION: This extension should not be added in an upgrade to an already deployed contract.
State Variables
ERC1155SupplyStorageLocation
bytes32 private constant ERC1155SupplyStorageLocation =
0x4a593662ee04d27b6a00ebb31be7fe0c102c2ade82a7c5d764f2df05dc4e2800;
Functions
_getERC1155SupplyStorage
function _getERC1155SupplyStorage() private pure returns (ERC1155SupplyStorage storage $);
__ERC1155Supply_init
function __ERC1155Supply_init() internal onlyInitializing;
__ERC1155Supply_init_unchained
function __ERC1155Supply_init_unchained() internal onlyInitializing;
totalSupply
Total value of tokens in with a given id.
function totalSupply(uint256 id) public view virtual returns (uint256);
totalSupply
Total value of tokens.
function totalSupply() public view virtual returns (uint256);
exists
Indicates whether any token exist with a given id, or not.
function exists(uint256 id) public view virtual returns (bool);
_update
*Transfers a value amount of tokens of type id from from to to. Will mint (or burn) if from
(or to) is the zero address.
Emits a {TransferSingle} event if the arrays contain one element, and {TransferBatch} otherwise.
Requirements:
- If
torefers to a smart contract, it must implement either {IERC1155Receiver-onERC1155Received} or {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value. idsandvaluesmust have the same length. NOTE: The ERC-1155 acceptance check is not performed in this function. See {_updateWithAcceptanceCheck} instead.*
function _update(address from, address to, uint256[] memory ids, uint256[] memory values) internal virtual override;
Structs
ERC1155SupplyStorage
Note: storage-location: erc7201:openzeppelin.storage.ERC1155Supply
struct ERC1155SupplyStorage {
mapping(uint256 id => uint256) _totalSupply;
uint256 _totalSupplyAll;
}
ERC1155URIStorageUpgradeable
Inherits: Initializable, ERC1155Upgradeable
ERC-1155 token with storage based token URI management. Inspired by the {ERC721URIStorage} extension
State Variables
ERC1155URIStorageStorageLocation
bytes32 private constant ERC1155URIStorageStorageLocation =
0x89fc852226e759c7c636cf34d732f0198fc56a54876b2374a52beb7b0c558600;
Functions
_getERC1155URIStorageStorage
function _getERC1155URIStorageStorage() private pure returns (ERC1155URIStorageStorage storage $);
__ERC1155URIStorage_init
function __ERC1155URIStorage_init() internal onlyInitializing;
__ERC1155URIStorage_init_unchained
function __ERC1155URIStorage_init_unchained() internal onlyInitializing;
uri
*See IERC1155MetadataURI-uri.
This implementation returns the concatenation of the _baseURI
and the token-specific uri if the latter is set
This enables the following behaviors:
- if
_tokenURIs[tokenId]is set, then the result is the concatenation of_baseURIand_tokenURIs[tokenId](keep in mind that_baseURIis empty per default); - if
_tokenURIs[tokenId]is NOT set then we fallback tosuper.uri()which in most cases will containERC1155._uri; - if
_tokenURIs[tokenId]is NOT set, and if the parents do not have a uri value set, then the result is empty.*
function uri(uint256 tokenId) public view virtual override returns (string memory);
_setURI
Sets tokenURI as the tokenURI of tokenId.
function _setURI(uint256 tokenId, string memory tokenURI) internal virtual;
_setBaseURI
Sets baseURI as the _baseURI for all tokens
function _setBaseURI(string memory baseURI) internal virtual;
Structs
ERC1155URIStorageStorage
Note: storage-location: erc7201:openzeppelin.storage.ERC1155URIStorage
struct ERC1155URIStorageStorage {
string _baseURI;
mapping(uint256 tokenId => string) _tokenURIs;
}
Contents
ERC1155HolderUpgradeable
Inherits: Initializable, ERC165Upgradeable, IERC1155Receiver
Simple implementation of IERC1155Receiver that will allow a contract to hold ERC-1155 tokens.
IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be
stuck.
Functions
__ERC1155Holder_init
function __ERC1155Holder_init() internal onlyInitializing;
__ERC1155Holder_init_unchained
function __ERC1155Holder_init_unchained() internal onlyInitializing;
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC165Upgradeable, IERC165)
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
onERC1155Received
function onERC1155Received(address, address, uint256, uint256, bytes memory) public virtual override returns (bytes4);
onERC1155BatchReceived
function onERC1155BatchReceived(address, address, uint256[] memory, uint256[] memory, bytes memory)
public
virtual
override
returns (bytes4);
ERC1155Upgradeable
Inherits: Initializable, ContextUpgradeable, ERC165Upgradeable, IERC1155, IERC1155MetadataURI, IERC1155Errors
Implementation of the basic standard multi-token. See https://eips.ethereum.org/EIPS/eip-1155 Originally based on code by Enjin: https://github.com/enjin/erc-1155
State Variables
ERC1155StorageLocation
bytes32 private constant ERC1155StorageLocation = 0x88be536d5240c274a3b1d3a1be54482fd9caa294f08c62a7cde569f49a3c4500;
Functions
_getERC1155Storage
function _getERC1155Storage() private pure returns (ERC1155Storage storage $);
__ERC1155_init
See _setURI.
function __ERC1155_init(string memory uri_) internal onlyInitializing;
__ERC1155_init_unchained
function __ERC1155_init_unchained(string memory uri_) internal onlyInitializing;
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC165Upgradeable, IERC165)
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
uri
See IERC1155MetadataURI-uri.
This implementation returns the same URI for all token types. It relies
on the token type ID substitution mechanism
https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the ERC].
Clients calling this function must replace the \{id\} substring with the
actual token type ID.
function uri(uint256) public view virtual returns (string memory);
balanceOf
Get the balance of an account's tokens.
function balanceOf(address account, uint256 id) public view virtual returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
account | address | |
id | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The _owner's balance of the token type requested |
balanceOfBatch
*See IERC1155-balanceOfBatch. Requirements:
accountsandidsmust have the same length.*
function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
public
view
virtual
returns (uint256[] memory);
setApprovalForAll
Enable or disable approval for a third party ("operator") to manage all of the caller's tokens.
MUST emit the ApprovalForAll event on success.
function setApprovalForAll(address operator, bool approved) public virtual;
Parameters
| Name | Type | Description |
|---|---|---|
operator | address | |
approved | bool |
isApprovedForAll
Queries the approval status of an operator for a given owner.
function isApprovedForAll(address account, address operator) public view virtual returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
account | address | |
operator | address |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the operator is approved, false if not |
safeTransferFrom
Transfers _value amount of an _id from the _from address to the _to address specified (with safety call).
*Caller must be approved to manage the tokens being transferred out of the _from account (see "Approval" section of the standard).
- MUST revert if
_tois the zero address. - MUST revert if balance of holder for token
_idis lower than the_valuesent. - MUST revert on any other error.
- MUST emit the
TransferSingleevent to reflect the balance change (see "Safe Transfer Rules" section of the standard). - After the above conditions are met, this function MUST check if
_tois a smart contract (e.g. code size > 0). If so, it MUST callonERC1155Receivedon_toand act appropriately (see "Safe Transfer Rules" section of the standard).*
function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) public virtual;
Parameters
| Name | Type | Description |
|---|---|---|
from | address | |
to | address | |
id | uint256 | |
value | uint256 | |
data | bytes |
safeBatchTransferFrom
Transfers _values amount(s) of _ids from the _from address to the _to address specified (with safety call).
*Caller must be approved to manage the tokens being transferred out of the _from account (see "Approval" section of the standard).
- MUST revert if
_tois the zero address. - MUST revert if length of
_idsis not the same as length of_values. - MUST revert if any of the balance(s) of the holder(s) for token(s) in
_idsis lower than the respective amount(s) in_valuessent to the recipient. - MUST revert on any other error.
- MUST emit
TransferSingleorTransferBatchevent(s) such that all the balance changes are reflected (see "Safe Transfer Rules" section of the standard). - Balance changes and events MUST follow the ordering of the arrays (_ids[0]/_values[0] before _ids[1]/_values[1], etc).
- After the above conditions for the transfer(s) in the batch are met, this function MUST check if
_tois a smart contract (e.g. code size > 0). If so, it MUST call the relevantERC1155TokenReceiverhook(s) on_toand act appropriately (see "Safe Transfer Rules" section of the standard).*
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
) public virtual;
Parameters
| Name | Type | Description |
|---|---|---|
from | address | |
to | address | |
ids | uint256[] | |
values | uint256[] | |
data | bytes |
_update
*Transfers a value amount of tokens of type id from from to to. Will mint (or burn) if from
(or to) is the zero address.
Emits a {TransferSingle} event if the arrays contain one element, and {TransferBatch} otherwise.
Requirements:
- If
torefers to a smart contract, it must implement either {IERC1155Receiver-onERC1155Received} or {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value. idsandvaluesmust have the same length. NOTE: The ERC-1155 acceptance check is not performed in this function. See {_updateWithAcceptanceCheck} instead.*
function _update(address from, address to, uint256[] memory ids, uint256[] memory values) internal virtual;
_updateWithAcceptanceCheck
Version of _update that performs the token acceptance check by calling {IERC1155Receiver-onERC1155Received} or {IERC1155Receiver-onERC1155BatchReceived} on the receiver address if it contains code (eg. is a smart contract at the moment of execution). IMPORTANT: Overriding this function is discouraged because it poses a reentrancy risk from the receiver. So any update to the contract state after this function would break the check-effect-interaction pattern. Consider overriding {_update} instead.
function _updateWithAcceptanceCheck(
address from,
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
) internal virtual;
_safeTransferFrom
*Transfers a value tokens of token type id from from to to.
Emits a {TransferSingle} event.
Requirements:
tocannot be the zero address.frommust have a balance of tokens of typeidof at leastvalueamount.- If
torefers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value.*
function _safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) internal;
_safeBatchTransferFrom
*xref:ROOT:erc1155.adoc#batch-operations[Batched] version of _safeTransferFrom. Emits a {TransferBatch} event. Requirements:
- If
torefers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value. idsandvaluesmust have the same length.*
function _safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
) internal;
_setURI
Sets a new URI for all token types, by relying on the token type ID
substitution mechanism
https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the ERC].
By this mechanism, any occurrence of the \{id\} substring in either the
URI or any of the values in the JSON file at said URI will be replaced by
clients with the token type ID.
For example, the https://token-cdn-domain/\{id\}.json URI would be
interpreted by clients as
https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json
for token type ID 0x4cce0.
See uri.
Because these URIs cannot be meaningfully represented by the {URI} event,
this function emits no events.
function _setURI(string memory newuri) internal virtual;
_mint
*Creates a value amount of tokens of type id, and assigns them to to.
Emits a {TransferSingle} event.
Requirements:
tocannot be the zero address.- If
torefers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value.*
function _mint(address to, uint256 id, uint256 value, bytes memory data) internal;
_mintBatch
*xref:ROOT:erc1155.adoc#batch-operations[Batched] version of _mint. Emits a {TransferBatch} event. Requirements:
idsandvaluesmust have the same length.tocannot be the zero address.- If
torefers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value.*
function _mintBatch(address to, uint256[] memory ids, uint256[] memory values, bytes memory data) internal;
_burn
*Destroys a value amount of tokens of type id from from
Emits a {TransferSingle} event.
Requirements:
fromcannot be the zero address.frommust have at leastvalueamount of tokens of typeid.*
function _burn(address from, uint256 id, uint256 value) internal;
_burnBatch
*xref:ROOT:erc1155.adoc#batch-operations[Batched] version of _burn. Emits a {TransferBatch} event. Requirements:
fromcannot be the zero address.frommust have at leastvalueamount of tokens of typeid.idsandvaluesmust have the same length.*
function _burnBatch(address from, uint256[] memory ids, uint256[] memory values) internal;
_setApprovalForAll
*Approve operator to operate on all of owner tokens
Emits an {ApprovalForAll} event.
Requirements:
operatorcannot be the zero address.*
function _setApprovalForAll(address owner, address operator, bool approved) internal virtual;
_asSingletonArrays
Creates an array in memory with only one value for each of the elements provided.
function _asSingletonArrays(uint256 element1, uint256 element2)
private
pure
returns (uint256[] memory array1, uint256[] memory array2);
Structs
ERC1155Storage
Note: storage-location: erc7201:openzeppelin.storage.ERC1155
struct ERC1155Storage {
mapping(uint256 id => mapping(address account => uint256)) _balances;
mapping(address account => mapping(address operator => bool)) _operatorApprovals;
string _uri;
}
Contents
Contents
- ERC1363Upgradeable
- ERC20BurnableUpgradeable
- ERC20CappedUpgradeable
- ERC20FlashMintUpgradeable
- ERC20PausableUpgradeable
- ERC20PermitUpgradeable
- ERC20VotesUpgradeable
- ERC20WrapperUpgradeable
- ERC4626Upgradeable
- ERC20BridgeableUpgradeable
- ERC20TemporaryApprovalUpgradeable
ERC1363Upgradeable
Inherits: Initializable, ERC20Upgradeable, ERC165Upgradeable, IERC1363
Extension of {ERC20} tokens that adds support for code execution after transfers and approvals on recipient contracts. Calls after transfers are enabled through the {ERC1363-transferAndCall} and {ERC1363-transferFromAndCall} methods while calls after approvals can be made with {ERC1363-approveAndCall} Available since v5.1.
Functions
__ERC1363_init
function __ERC1363_init() internal onlyInitializing;
__ERC1363_init_unchained
function __ERC1363_init_unchained() internal onlyInitializing;
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC165Upgradeable, IERC165)
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
transferAndCall
*Moves a value amount of tokens from the caller's account to to
and then calls IERC1363Receiver-onTransferReceived on to. Returns a flag that indicates
if the call succeeded.
Requirements:
- The target has code (i.e. is a contract).
- The target
tomust implement the {IERC1363Receiver} interface. - The target must return the {IERC1363Receiver-onTransferReceived} selector to accept the transfer.
- The internal {transfer} must succeed (returned
true).*
function transferAndCall(address to, uint256 value) public returns (bool);
transferAndCall
Variant of transferAndCall that accepts an additional data parameter with
no specified format.
function transferAndCall(address to, uint256 value, bytes memory data) public virtual returns (bool);
transferFromAndCall
*Moves a value amount of tokens from from to to using the allowance mechanism
and then calls IERC1363Receiver-onTransferReceived on to. Returns a flag that indicates
if the call succeeded.
Requirements:
- The target has code (i.e. is a contract).
- The target
tomust implement the {IERC1363Receiver} interface. - The target must return the {IERC1363Receiver-onTransferReceived} selector to accept the transfer.
- The internal {transferFrom} must succeed (returned
true).*
function transferFromAndCall(address from, address to, uint256 value) public returns (bool);
transferFromAndCall
Variant of transferFromAndCall that accepts an additional data parameter with
no specified format.
function transferFromAndCall(address from, address to, uint256 value, bytes memory data)
public
virtual
returns (bool);
approveAndCall
*Sets a value amount of tokens as the allowance of spender over the
caller's tokens and then calls IERC1363Spender-onApprovalReceived on spender.
Returns a flag that indicates if the call succeeded.
Requirements:
- The target has code (i.e. is a contract).
- The target
spendermust implement the {IERC1363Spender} interface. - The target must return the {IERC1363Spender-onApprovalReceived} selector to accept the approval.
- The internal {approve} must succeed (returned
true).*
function approveAndCall(address spender, uint256 value) public returns (bool);
approveAndCall
Variant of approveAndCall that accepts an additional data parameter with
no specified format.
function approveAndCall(address spender, uint256 value, bytes memory data) public virtual returns (bool);
Errors
ERC1363TransferFailed
Indicates a failure within the {transfer} part of a transferAndCall operation.
error ERC1363TransferFailed(address receiver, uint256 value);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | Address to which tokens are being transferred. |
value | uint256 | Amount of tokens to be transferred. |
ERC1363TransferFromFailed
Indicates a failure within the {transferFrom} part of a transferFromAndCall operation.
error ERC1363TransferFromFailed(address sender, address receiver, uint256 value);
Parameters
| Name | Type | Description |
|---|---|---|
sender | address | Address from which to send tokens. |
receiver | address | Address to which tokens are being transferred. |
value | uint256 | Amount of tokens to be transferred. |
ERC1363ApproveFailed
Indicates a failure within the {approve} part of a approveAndCall operation.
error ERC1363ApproveFailed(address spender, uint256 value);
Parameters
| Name | Type | Description |
|---|---|---|
spender | address | Address which will spend the funds. |
value | uint256 | Amount of tokens to be spent. |
ERC20BurnableUpgradeable
Inherits: Initializable, ContextUpgradeable, ERC20Upgradeable
Extension of {ERC20} that allows token holders to destroy both their own tokens and those that they have an allowance for, in a way that can be recognized off-chain (via event analysis).
Functions
__ERC20Burnable_init
function __ERC20Burnable_init() internal onlyInitializing;
__ERC20Burnable_init_unchained
function __ERC20Burnable_init_unchained() internal onlyInitializing;
burn
Destroys a value amount of tokens from the caller.
See ERC20-_burn.
function burn(uint256 value) public virtual;
burnFrom
*Destroys a value amount of tokens from account, deducting from
the caller's allowance.
See ERC20-_burn and {ERC20-allowance}.
Requirements:
- the caller must have allowance for
accounts's tokens of at leastvalue.*
function burnFrom(address account, uint256 value) public virtual;
ERC20CappedUpgradeable
Inherits: Initializable, ERC20Upgradeable
Extension of {ERC20} that adds a cap to the supply of tokens.
State Variables
ERC20CappedStorageLocation
bytes32 private constant ERC20CappedStorageLocation = 0x0f070392f17d5f958cc1ac31867dabecfc5c9758b4a419a200803226d7155d00;
Functions
_getERC20CappedStorage
function _getERC20CappedStorage() private pure returns (ERC20CappedStorage storage $);
__ERC20Capped_init
Sets the value of the cap. This value is immutable, it can only be
set once during construction.
function __ERC20Capped_init(uint256 cap_) internal onlyInitializing;
__ERC20Capped_init_unchained
function __ERC20Capped_init_unchained(uint256 cap_) internal onlyInitializing;
cap
Returns the cap on the token's total supply.
function cap() public view virtual returns (uint256);
_update
Transfers a value amount of tokens from from to to, or alternatively mints (or burns) if from
(or to) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
this function.
Emits a {Transfer} event.
function _update(address from, address to, uint256 value) internal virtual override;
Errors
ERC20ExceededCap
Total supply cap has been exceeded.
error ERC20ExceededCap(uint256 increasedSupply, uint256 cap);
ERC20InvalidCap
The supplied cap is not a valid cap.
error ERC20InvalidCap(uint256 cap);
Structs
ERC20CappedStorage
Note: storage-location: erc7201:openzeppelin.storage.ERC20Capped
struct ERC20CappedStorage {
uint256 _cap;
}
ERC20FlashMintUpgradeable
Inherits: Initializable, ERC20Upgradeable, IERC3156FlashLender
Implementation of the ERC-3156 Flash loans extension, as defined in https://eips.ethereum.org/EIPS/eip-3156[ERC-3156]. Adds the flashLoan method, which provides flash loan support at the token level. By default there is no fee, but this can be changed by overriding {flashFee}. NOTE: When this extension is used along with the {ERC20Capped} or {ERC20Votes} extensions, {maxFlashLoan} will not correctly reflect the maximum that can be flash minted. We recommend overriding {maxFlashLoan} so that it correctly reflects the supply cap.
State Variables
RETURN_VALUE
bytes32 private constant RETURN_VALUE = keccak256("ERC3156FlashBorrower.onFlashLoan");
Functions
__ERC20FlashMint_init
function __ERC20FlashMint_init() internal onlyInitializing;
__ERC20FlashMint_init_unchained
function __ERC20FlashMint_init_unchained() internal onlyInitializing;
maxFlashLoan
Returns the maximum amount of tokens available for loan.
function maxFlashLoan(address token) public view virtual returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | The address of the token that is requested. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The amount of token that can be loaned. NOTE: This function does not consider any form of supply cap, so in case it's used in a token with a cap like {ERC20Capped}, make sure to override this function to integrate the cap instead of type(uint256).max. |
flashFee
Returns the fee applied when doing flash loans. This function calls the _flashFee function which returns the fee applied when doing flash loans.
function flashFee(address token, uint256 value) public view virtual returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | The token to be flash loaned. |
value | uint256 | The amount of tokens to be loaned. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The fees applied to the corresponding flash loan. |
_flashFee
Returns the fee applied when doing flash loans. By default this implementation has 0 fees. This function can be overloaded to make the flash loan mechanism deflationary.
function _flashFee(address token, uint256 value) internal view virtual returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | The token to be flash loaned. |
value | uint256 | The amount of tokens to be loaned. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The fees applied to the corresponding flash loan. |
_flashFeeReceiver
Returns the receiver address of the flash fee. By default this implementation returns the address(0) which means the fee amount will be burnt. This function can be overloaded to change the fee receiver.
function _flashFeeReceiver() internal view virtual returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The address for which the flash fee will be sent to. |
flashLoan
Performs a flash loan. New tokens are minted and sent to the
receiver, who is required to implement the {IERC3156FlashBorrower}
interface. By the end of the flash loan, the receiver is expected to own
value + fee tokens and have them approved back to the token contract itself so
they can be burned.
function flashLoan(IERC3156FlashBorrower receiver, address token, uint256 value, bytes calldata data)
public
virtual
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | IERC3156FlashBorrower | The receiver of the flash loan. Should implement the IERC3156FlashBorrower-onFlashLoan interface. |
token | address | The token to be flash loaned. Only address(this) is supported. |
value | uint256 | The amount of tokens to be loaned. |
data | bytes | An arbitrary datafield that is passed to the receiver. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the flash loan was successful. |
Errors
ERC3156UnsupportedToken
The loan token is not valid.
error ERC3156UnsupportedToken(address token);
ERC3156ExceededMaxLoan
The requested loan exceeds the max loan value for token.
error ERC3156ExceededMaxLoan(uint256 maxLoan);
ERC3156InvalidReceiver
The receiver of a flashloan is not a valid IERC3156FlashBorrower-onFlashLoan implementer.
error ERC3156InvalidReceiver(address receiver);
ERC20PausableUpgradeable
Inherits: Initializable, ERC20Upgradeable, PausableUpgradeable
ERC-20 token with pausable token transfers, minting and burning. Useful for scenarios such as preventing trades until the end of an evaluation period, or having an emergency switch for freezing all token transfers in the event of a large bug. IMPORTANT: This contract does not include public pause and unpause functions. In addition to inheriting this contract, you must define both functions, invoking the Pausable-_pause and {Pausable-_unpause} internal functions, with appropriate access control, e.g. using {AccessControl} or {Ownable}. Not doing so will make the contract pause mechanism of the contract unreachable, and thus unusable.
Functions
__ERC20Pausable_init
function __ERC20Pausable_init() internal onlyInitializing;
__ERC20Pausable_init_unchained
function __ERC20Pausable_init_unchained() internal onlyInitializing;
_update
*See ERC20-_update. Requirements:
- the contract must not be paused.*
function _update(address from, address to, uint256 value) internal virtual override whenNotPaused;
ERC20PermitUpgradeable
Inherits: Initializable, ERC20Upgradeable, IERC20Permit, EIP712Upgradeable, NoncesUpgradeable
Implementation of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in
https://eips.ethereum.org/EIPS/eip-2612[ERC-2612].
Adds the permit method, which can be used to change an account's ERC-20 allowance (see {IERC20-allowance}) by
presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
need to send a transaction, and thus is not required to hold Ether at all.
State Variables
PERMIT_TYPEHASH
bytes32 private constant PERMIT_TYPEHASH =
keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
Functions
__ERC20Permit_init
Initializes the {EIP712} domain separator using the name parameter, and setting version to "1".
It's a good idea to use the same name that is defined as the ERC-20 token name.
function __ERC20Permit_init(string memory name) internal onlyInitializing;
__ERC20Permit_init_unchained
function __ERC20Permit_init_unchained(string memory) internal onlyInitializing;
permit
*Sets value as the allowance of spender over owner's tokens,
given owner's signed approval.
IMPORTANT: The same issues {IERC20-approve} has related to transaction
ordering also apply here.
Emits an {Approval} event.
Requirements:
spendercannot be the zero address.deadlinemust be a timestamp in the future.v,randsmust be a validsecp256k1signature fromownerover the EIP712-formatted function arguments.- the signature must use
owner's current nonce (see {nonces}). For more information on the signature format, see the https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP section]. CAUTION: See Security Considerations above.*
function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
public
virtual;
nonces
Returns the current nonce for owner. This value must be
included whenever a signature is generated for {permit}.
Every successful call to {permit} increases owner's nonce by one. This
prevents a signature from being used multiple times.
function nonces(address owner) public view virtual override(IERC20Permit, NoncesUpgradeable) returns (uint256);
DOMAIN_SEPARATOR
Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
function DOMAIN_SEPARATOR() external view virtual returns (bytes32);
Errors
ERC2612ExpiredSignature
Permit deadline has expired.
error ERC2612ExpiredSignature(uint256 deadline);
ERC2612InvalidSigner
Mismatched signature.
error ERC2612InvalidSigner(address signer, address owner);
ERC20VotesUpgradeable
Inherits: Initializable, ERC20Upgradeable, VotesUpgradeable
Extension of ERC-20 to support Compound-like voting and delegation. This version is more generic than Compound's, and supports token supply up to 2^208^ - 1, while COMP is limited to 2^96^ - 1. NOTE: This contract does not provide interface compatibility with Compound's COMP token. This extension keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either by calling the Votes-delegate function directly, or by providing a signature to be used with {Votes-delegateBySig}. Voting power can be queried through the public accessors {Votes-getVotes} and {Votes-getPastVotes}. By default, token balance does not account for voting power. This makes transfers cheaper. The downside is that it requires users to delegate to themselves in order to activate checkpoints and have their voting power tracked.
Functions
__ERC20Votes_init
function __ERC20Votes_init() internal onlyInitializing;
__ERC20Votes_init_unchained
function __ERC20Votes_init_unchained() internal onlyInitializing;
_maxSupply
Maximum token supply. Defaults to type(uint208).max (2^208^ - 1).
This maximum is enforced in _update. It limits the total supply of the token, which is otherwise a uint256,
so that checkpoints can be stored in the Trace208 structure used by {Votes}. Increasing this value will not
remove the underlying limitation, and will cause {_update} to fail because of a math overflow in
{Votes-_transferVotingUnits}. An override could be used to further restrict the total supply (to a lower value) if
additional logic requires it. When resolving override conflicts on this function, the minimum should be
returned.
function _maxSupply() internal view virtual returns (uint256);
_update
Move voting power when tokens are transferred. Emits a IVotes-DelegateVotesChanged event.
function _update(address from, address to, uint256 value) internal virtual override;
_getVotingUnits
Returns the voting units of an account.
WARNING: Overriding this function may compromise the internal vote accounting.
ERC20Votes assumes tokens map to voting units 1:1 and this is not easy to change.
function _getVotingUnits(address account) internal view virtual override returns (uint256);
numCheckpoints
Get number of checkpoints for account.
function numCheckpoints(address account) public view virtual returns (uint32);
checkpoints
Get the pos-th checkpoint for account.
function checkpoints(address account, uint32 pos) public view virtual returns (Checkpoints.Checkpoint208 memory);
Errors
ERC20ExceededSafeSupply
Total supply cap has been exceeded, introducing a risk of votes overflowing.
error ERC20ExceededSafeSupply(uint256 increasedSupply, uint256 cap);
ERC20WrapperUpgradeable
Inherits: Initializable, ERC20Upgradeable
Extension of the ERC-20 token contract to support token wrapping. Users can deposit and withdraw "underlying tokens" and receive a matching number of "wrapped tokens". This is useful in conjunction with other modules. For example, combining this wrapping mechanism with {ERC20Votes} will allow the wrapping of an existing "basic" ERC-20 into a governance token. WARNING: Any mechanism in which the underlying token changes the {balanceOf} of an account without an explicit transfer may desynchronize this contract's supply and its underlying balance. Please exercise caution when wrapping tokens that may undercollateralize the wrapper (i.e. wrapper's total supply is higher than its underlying balance). See {_recover} for recovering value accrued to the wrapper.
State Variables
ERC20WrapperStorageLocation
bytes32 private constant ERC20WrapperStorageLocation =
0x3b5a617e0d4c238430871a64fe18212794b0c8d05a4eac064a8c9039fb5e0700;
Functions
_getERC20WrapperStorage
function _getERC20WrapperStorage() private pure returns (ERC20WrapperStorage storage $);
__ERC20Wrapper_init
function __ERC20Wrapper_init(IERC20 underlyingToken) internal onlyInitializing;
__ERC20Wrapper_init_unchained
function __ERC20Wrapper_init_unchained(IERC20 underlyingToken) internal onlyInitializing;
decimals
Returns the decimals places of the token.
function decimals() public view virtual override returns (uint8);
underlying
Returns the address of the underlying ERC-20 token that is being wrapped.
function underlying() public view returns (IERC20);
depositFor
Allow a user to deposit underlying tokens and mint the corresponding number of wrapped tokens.
function depositFor(address account, uint256 value) public virtual returns (bool);
withdrawTo
Allow a user to burn a number of wrapped tokens and withdraw the corresponding number of underlying tokens.
function withdrawTo(address account, uint256 value) public virtual returns (bool);
_recover
Mint wrapped token to cover any underlyingTokens that would have been transferred by mistake or acquired from rebasing mechanisms. Internal function that can be exposed with access control if desired.
function _recover(address account) internal virtual returns (uint256);
Errors
ERC20InvalidUnderlying
The underlying token couldn't be wrapped.
error ERC20InvalidUnderlying(address token);
Structs
ERC20WrapperStorage
Note: storage-location: erc7201:openzeppelin.storage.ERC20Wrapper
struct ERC20WrapperStorage {
IERC20 _underlying;
}
ERC4626Upgradeable
Inherits: Initializable, ERC20Upgradeable, IERC4626
*Implementation of the ERC-4626 "Tokenized Vault Standard" as defined in https://eips.ethereum.org/EIPS/eip-4626[ERC-4626]. This extension allows the minting and burning of "shares" (represented using the ERC-20 inheritance) in exchange for underlying "assets" through standardized deposit, {mint}, {redeem} and {burn} workflows. This contract extends the ERC-20 standard. Any additional extensions included along it would affect the "shares" token represented by this contract and not the "assets" token which is an independent contract. [CAUTION]
In empty (or nearly empty) ERC-4626 vaults, deposits are at high risk of being stolen through frontrunning
with a "donation" to the vault that inflates the price of a share. This is variously known as a donation or inflation
attack and is essentially a problem of slippage. Vault deployers can protect against this attack by making an initial
deposit of a non-trivial amount of the asset, such that price manipulation becomes infeasible. Withdrawals may
similarly be affected by slippage. Users can protect against this attack as well as unexpected slippage in general by
verifying the amount received is as expected, using a wrapper that performs these checks such as
https://github.com/fei-protocol/ERC4626#erc4626router-and-base[ERC4626Router].
Since v4.9, this implementation introduces configurable virtual assets and shares to help developers mitigate that risk.
The _decimalsOffset() corresponds to an offset in the decimal representation between the underlying asset's decimals
and the vault decimals. This offset also determines the rate of virtual shares to virtual assets in the vault, which
itself determines the initial exchange rate. While not fully preventing the attack, analysis shows that the default
offset (0) makes it non-profitable even if an attacker is able to capture value from multiple user deposits, as a result
of the value being captured by the virtual shares (out of the attacker's donation) matching the attacker's expected gains.
With a larger offset, the attack becomes orders of magnitude more expensive than it is profitable. More details about the
underlying math can be found xref:ROOT:erc4626.adoc#inflation-attack[here].
The drawback of this approach is that the virtual shares do capture (a very small) part of the value being accrued
to the vault. Also, if the vault experiences losses, the users try to exit the vault, the virtual shares and assets
will cause the first user to exit to experience reduced losses in detriment to the last users that will experience
bigger losses. Developers willing to revert back to the pre-v4.9 behavior just need to override the
_convertToShares and _convertToAssets functions.
To learn more, check out our xref:ROOT:erc4626.adoc[ERC-4626 guide].
====*
State Variables
ERC4626StorageLocation
bytes32 private constant ERC4626StorageLocation = 0x0773e532dfede91f04b12a73d3d2acd361424f41f76b4fb79f090161e36b4e00;
Functions
_getERC4626Storage
function _getERC4626Storage() private pure returns (ERC4626Storage storage $);
__ERC4626_init
Set the underlying asset contract. This must be an ERC20-compatible contract (ERC-20 or ERC-777).
function __ERC4626_init(IERC20 asset_) internal onlyInitializing;
__ERC4626_init_unchained
function __ERC4626_init_unchained(IERC20 asset_) internal onlyInitializing;
_tryGetAssetDecimals
Attempts to fetch the asset decimals. A return value of false indicates that the attempt failed in some way.
function _tryGetAssetDecimals(IERC20 asset_) private view returns (bool ok, uint8 assetDecimals);
decimals
Decimals are computed by adding the decimal offset on top of the underlying asset's decimals. This "original" value is cached during construction of the vault contract. If this read operation fails (e.g., the asset has not been created yet), a default of 18 is used to represent the underlying asset's decimals. See IERC20Metadata-decimals.
function decimals() public view virtual override(IERC20Metadata, ERC20Upgradeable) returns (uint8);
asset
function asset() public view virtual returns (address);
totalAssets
function totalAssets() public view virtual returns (uint256);
convertToShares
function convertToShares(uint256 assets) public view virtual returns (uint256);
convertToAssets
function convertToAssets(uint256 shares) public view virtual returns (uint256);
maxDeposit
function maxDeposit(address) public view virtual returns (uint256);
maxMint
function maxMint(address) public view virtual returns (uint256);
maxWithdraw
function maxWithdraw(address owner) public view virtual returns (uint256);
maxRedeem
function maxRedeem(address owner) public view virtual returns (uint256);
previewDeposit
function previewDeposit(uint256 assets) public view virtual returns (uint256);
previewMint
function previewMint(uint256 shares) public view virtual returns (uint256);
previewWithdraw
function previewWithdraw(uint256 assets) public view virtual returns (uint256);
previewRedeem
function previewRedeem(uint256 shares) public view virtual returns (uint256);
deposit
function deposit(uint256 assets, address receiver) public virtual returns (uint256);
mint
function mint(uint256 shares, address receiver) public virtual returns (uint256);
withdraw
function withdraw(uint256 assets, address receiver, address owner) public virtual returns (uint256);
redeem
function redeem(uint256 shares, address receiver, address owner) public virtual returns (uint256);
_convertToShares
Internal conversion function (from assets to shares) with support for rounding direction.
function _convertToShares(uint256 assets, Math.Rounding rounding) internal view virtual returns (uint256);
_convertToAssets
Internal conversion function (from shares to assets) with support for rounding direction.
function _convertToAssets(uint256 shares, Math.Rounding rounding) internal view virtual returns (uint256);
_deposit
Deposit/mint common workflow.
function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual;
_withdraw
Withdraw/redeem common workflow.
function _withdraw(address caller, address receiver, address owner, uint256 assets, uint256 shares) internal virtual;
_decimalsOffset
function _decimalsOffset() internal view virtual returns (uint8);
Errors
ERC4626ExceededMaxDeposit
Attempted to deposit more assets than the max amount for receiver.
error ERC4626ExceededMaxDeposit(address receiver, uint256 assets, uint256 max);
ERC4626ExceededMaxMint
Attempted to mint more shares than the max amount for receiver.
error ERC4626ExceededMaxMint(address receiver, uint256 shares, uint256 max);
ERC4626ExceededMaxWithdraw
Attempted to withdraw more assets than the max amount for receiver.
error ERC4626ExceededMaxWithdraw(address owner, uint256 assets, uint256 max);
ERC4626ExceededMaxRedeem
Attempted to redeem more shares than the max amount for receiver.
error ERC4626ExceededMaxRedeem(address owner, uint256 shares, uint256 max);
Structs
ERC4626Storage
Note: storage-location: erc7201:openzeppelin.storage.ERC4626
struct ERC4626Storage {
IERC20 _asset;
uint8 _underlyingDecimals;
}
ERC20BridgeableUpgradeable
Inherits: Initializable, ERC20Upgradeable, ERC165Upgradeable, IERC7802
ERC20 extension that implements the standard token interface according to https://eips.ethereum.org/EIPS/eip-7802[ERC-7802].
Functions
onlyTokenBridge
Modifier to restrict access to the token bridge.
modifier onlyTokenBridge();
__ERC20Bridgeable_init
function __ERC20Bridgeable_init() internal onlyInitializing;
__ERC20Bridgeable_init_unchained
function __ERC20Bridgeable_init_unchained() internal onlyInitializing;
supportsInterface
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC165Upgradeable, IERC165)
returns (bool);
crosschainMint
See IERC7802-crosschainMint. Emits a {IERC7802-CrosschainMint} event.
function crosschainMint(address to, uint256 value) public virtual override onlyTokenBridge;
crosschainBurn
See IERC7802-crosschainBurn. Emits a {IERC7802-CrosschainBurn} event.
function crosschainBurn(address from, uint256 value) public virtual override onlyTokenBridge;
_checkTokenBridge
Checks if the caller is a trusted token bridge. MUST revert otherwise. Developers should implement this function using an access control mechanism that allows customizing the list of allowed senders. Consider using {AccessControl} or {AccessManaged}.
function _checkTokenBridge(address caller) internal virtual;
ERC20TemporaryApprovalUpgradeable
Inherits: Initializable, ERC20Upgradeable, IERC7674
Extension of {ERC20} that adds support for temporary allowances following ERC-7674. WARNING: This is a draft contract. The corresponding ERC is still subject to changes. Available since v5.1.
State Variables
ERC20_TEMPORARY_APPROVAL_STORAGE
bytes32 private constant ERC20_TEMPORARY_APPROVAL_STORAGE =
0xea2d0e77a01400d0111492b1321103eed560d8fe44b9a7c2410407714583c400;
Functions
__ERC20TemporaryApproval_init
function __ERC20TemporaryApproval_init() internal onlyInitializing;
__ERC20TemporaryApproval_init_unchained
function __ERC20TemporaryApproval_init_unchained() internal onlyInitializing;
allowance
allowance override that includes the temporary allowance when looking up the current allowance. If adding up the persistent and the temporary allowances result in an overflow, type(uint256).max is returned.
function allowance(address owner, address spender)
public
view
virtual
override(IERC20, ERC20Upgradeable)
returns (uint256);
_temporaryAllowance
Internal getter for the current temporary allowance that spender has over owner tokens.
function _temporaryAllowance(address owner, address spender) internal view virtual returns (uint256);
temporaryApprove
*Alternative to {approve} that sets a value amount of tokens as the temporary allowance of spender over
the caller's tokens.
Returns a boolean value indicating whether the operation succeeded.
Requirements:
spendercannot be the zero address. Does NOT emit an {Approval} event.*
function temporaryApprove(address spender, uint256 value) public virtual returns (bool);
_temporaryApprove
*Sets value as the temporary allowance of spender over the owner's tokens.
This internal function is equivalent to temporaryApprove, and can be used to e.g. set automatic allowances
for certain subsystems, etc.
Requirements:
ownercannot be the zero address.spendercannot be the zero address. Does NOT emit an {Approval} event.*
function _temporaryApprove(address owner, address spender, uint256 value) internal virtual;
_spendAllowance
_spendAllowance override that consumes the temporary allowance (if any) before eventually falling back
to consuming the persistent allowance.
NOTE: This function skips calling super._spendAllowance if the temporary allowance
is enough to cover the spending.
function _spendAllowance(address owner, address spender, uint256 value) internal virtual override;
_temporaryAllowanceSlot
function _temporaryAllowanceSlot(address owner, address spender) private pure returns (TransientSlot.Uint256Slot);
ERC20Upgradeable
Inherits: Initializable, ContextUpgradeable, IERC20, IERC20Metadata, IERC20Errors
Implementation of the {IERC20} interface.
This implementation is agnostic to the way tokens are created. This means
that a supply mechanism has to be added in a derived contract using {_mint}.
TIP: For a detailed writeup see our guide
https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
to implement supply mechanisms].
The default value of {decimals} is 18. To change this, you should override
this function so it returns a different value.
We have followed general OpenZeppelin Contracts guidelines: functions revert
instead returning false on failure. This behavior is nonetheless
conventional and does not conflict with the expectations of ERC-20
applications.
State Variables
ERC20StorageLocation
bytes32 private constant ERC20StorageLocation = 0x52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00;
Functions
_getERC20Storage
function _getERC20Storage() private pure returns (ERC20Storage storage $);
__ERC20_init
Sets the values for name and {symbol}. Both values are immutable: they can only be set once during construction.
function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing;
__ERC20_init_unchained
function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing;
name
Returns the name of the token.
function name() public view virtual returns (string memory);
symbol
Returns the symbol of the token, usually a shorter version of the name.
function symbol() public view virtual returns (string memory);
decimals
Returns the number of decimals used to get its user representation.
For example, if decimals equals 2, a balance of 505 tokens should
be displayed to a user as 5.05 (505 / 10 ** 2).
Tokens usually opt for a value of 18, imitating the relationship between
Ether and Wei. This is the default value returned by this function, unless
it's overridden.
NOTE: This information is only used for display purposes: it in
no way affects any of the arithmetic of the contract, including
IERC20-balanceOf and {IERC20-transfer}.
function decimals() public view virtual returns (uint8);
totalSupply
function totalSupply() public view virtual returns (uint256);
balanceOf
function balanceOf(address account) public view virtual returns (uint256);
transfer
*See IERC20-transfer. Requirements:
tocannot be the zero address.- the caller must have a balance of at least
value.*
function transfer(address to, uint256 value) public virtual returns (bool);
allowance
function allowance(address owner, address spender) public view virtual returns (uint256);
approve
*See IERC20-approve.
NOTE: If value is the maximum uint256, the allowance is not updated on
transferFrom. This is semantically equivalent to an infinite approval.
Requirements:
spendercannot be the zero address.*
function approve(address spender, uint256 value) public virtual returns (bool);
transferFrom
*See IERC20-transferFrom.
Skips emitting an {Approval} event indicating an allowance update. This is not
required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].
NOTE: Does not update the allowance if the current allowance
is the maximum uint256.
Requirements:
fromandtocannot be the zero address.frommust have a balance of at leastvalue.- the caller must have allowance for
from's tokens of at leastvalue.*
function transferFrom(address from, address to, uint256 value) public virtual returns (bool);
_transfer
Moves a value amount of tokens from from to to.
This internal function is equivalent to transfer, and can be used to
e.g. implement automatic token fees, slashing mechanisms, etc.
Emits a {Transfer} event.
NOTE: This function is not virtual, {_update} should be overridden instead.
function _transfer(address from, address to, uint256 value) internal;
_update
Transfers a value amount of tokens from from to to, or alternatively mints (or burns) if from
(or to) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
this function.
Emits a {Transfer} event.
function _update(address from, address to, uint256 value) internal virtual;
_mint
Creates a value amount of tokens and assigns them to account, by transferring it from address(0).
Relies on the _update mechanism
Emits a {Transfer} event with from set to the zero address.
NOTE: This function is not virtual, {_update} should be overridden instead.
function _mint(address account, uint256 value) internal;
_burn
Destroys a value amount of tokens from account, lowering the total supply.
Relies on the _update mechanism.
Emits a {Transfer} event with to set to the zero address.
NOTE: This function is not virtual, {_update} should be overridden instead
function _burn(address account, uint256 value) internal;
_approve
*Sets value as the allowance of spender over the owner's tokens.
This internal function is equivalent to approve, and can be used to
e.g. set automatic allowances for certain subsystems, etc.
Emits an {Approval} event.
Requirements:
ownercannot be the zero address.spendercannot be the zero address. Overrides to this logic should be done to the variant with an additionalbool emitEventargument.*
function _approve(address owner, address spender, uint256 value) internal;
_approve
*Variant of _approve with an optional flag to enable or disable the {Approval} event.
By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
_spendAllowance during the transferFrom operation set the flag to false. This saves gas by not emitting any
Approval event during transferFrom operations.
Anyone who wishes to continue emitting Approval events on thetransferFrom operation can force the flag to
true using the following override:
function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
super._approve(owner, spender, value, true);
}
Requirements are the same as {_approve}.*
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual;
_spendAllowance
Updates owner's allowance for spender based on spent value.
Does not update the allowance value in case of infinite allowance.
Revert if not enough allowance is available.
Does not emit an {Approval} event.
function _spendAllowance(address owner, address spender, uint256 value) internal virtual;
Structs
ERC20Storage
Note: storage-location: erc7201:openzeppelin.storage.ERC20
struct ERC20Storage {
mapping(address account => uint256) _balances;
mapping(address account => mapping(address spender => uint256)) _allowances;
uint256 _totalSupply;
string _name;
string _symbol;
}
Contents
Contents
ERC6909ContentURIUpgradeable
Inherits: Initializable, ERC6909Upgradeable, IERC6909ContentURI
Implementation of the Content URI extension defined in ERC6909.
State Variables
ERC6909ContentURIStorageLocation
bytes32 private constant ERC6909ContentURIStorageLocation =
0x2ada2772a8c4d40c4be8741992e423a9f97d5f4ef76852e5c17a40aa7fb9e500;
Functions
_getERC6909ContentURIStorage
function _getERC6909ContentURIStorage() private pure returns (ERC6909ContentURIStorage storage $);
__ERC6909ContentURI_init
function __ERC6909ContentURI_init() internal onlyInitializing;
__ERC6909ContentURI_init_unchained
function __ERC6909ContentURI_init_unchained() internal onlyInitializing;
contractURI
Returns URI for the contract.
function contractURI() public view virtual override returns (string memory);
tokenURI
Returns the URI for the token of type id.
function tokenURI(uint256 id) public view virtual override returns (string memory);
_setContractURI
Sets the contractURI for the contract. Emits a {ContractURIUpdated} event.
function _setContractURI(string memory newContractURI) internal virtual;
_setTokenURI
Sets the tokenURI for a given token of type id.
Emits a {URI} event.
function _setTokenURI(uint256 id, string memory newTokenURI) internal virtual;
Events
ContractURIUpdated
Event emitted when the contract URI is changed. See https://eips.ethereum.org/EIPS/eip-7572[ERC-7572] for details.
event ContractURIUpdated();
URI
See IERC1155-URI
event URI(string value, uint256 indexed id);
Structs
ERC6909ContentURIStorage
Note: storage-location: erc7201:openzeppelin.storage.ERC6909ContentURI
struct ERC6909ContentURIStorage {
string _contractURI;
mapping(uint256 id => string) _tokenURIs;
}
ERC6909MetadataUpgradeable
Inherits: Initializable, ERC6909Upgradeable, IERC6909Metadata
Implementation of the Metadata extension defined in ERC6909. Exposes the name, symbol, and decimals of each token id.
State Variables
ERC6909MetadataStorageLocation
bytes32 private constant ERC6909MetadataStorageLocation =
0xa0651e3d105d335a33d7d04897e080112be09c416f44637d6543e5b47885f800;
Functions
_getERC6909MetadataStorage
function _getERC6909MetadataStorage() private pure returns (ERC6909MetadataStorage storage $);
__ERC6909Metadata_init
function __ERC6909Metadata_init() internal onlyInitializing;
__ERC6909Metadata_init_unchained
function __ERC6909Metadata_init_unchained() internal onlyInitializing;
name
Returns the name of the token of type id.
function name(uint256 id) public view virtual override returns (string memory);
symbol
Returns the ticker symbol of the token of type id.
function symbol(uint256 id) public view virtual override returns (string memory);
decimals
Returns the number of decimals for the token of type id.
function decimals(uint256 id) public view virtual override returns (uint8);
_setName
Sets the name for a given token of type id.
Emits an ERC6909NameUpdated event.
function _setName(uint256 id, string memory newName) internal virtual;
_setSymbol
Sets the symbol for a given token of type id.
Emits an ERC6909SymbolUpdated event.
function _setSymbol(uint256 id, string memory newSymbol) internal virtual;
_setDecimals
Sets the decimals for a given token of type id.
Emits an ERC6909DecimalsUpdated event.
function _setDecimals(uint256 id, uint8 newDecimals) internal virtual;
Events
ERC6909NameUpdated
The name of the token of type id was updated to newName.
event ERC6909NameUpdated(uint256 indexed id, string newName);
ERC6909SymbolUpdated
The symbol for the token of type id was updated to newSymbol.
event ERC6909SymbolUpdated(uint256 indexed id, string newSymbol);
ERC6909DecimalsUpdated
The decimals value for token of type id was updated to newDecimals.
event ERC6909DecimalsUpdated(uint256 indexed id, uint8 newDecimals);
Structs
TokenMetadata
struct TokenMetadata {
string name;
string symbol;
uint8 decimals;
}
ERC6909MetadataStorage
Note: storage-location: erc7201:openzeppelin.storage.ERC6909Metadata
struct ERC6909MetadataStorage {
mapping(uint256 id => TokenMetadata) _tokenMetadata;
}
ERC6909TokenSupplyUpgradeable
Inherits: Initializable, ERC6909Upgradeable, IERC6909TokenSupply
Implementation of the Token Supply extension defined in ERC6909. Tracks the total supply of each token id individually.
State Variables
ERC6909TokenSupplyStorageLocation
bytes32 private constant ERC6909TokenSupplyStorageLocation =
0x9cc5ac148333cfaf4365d2d67a9c6e8fab8e8f4df7b569f769d68102db719600;
Functions
_getERC6909TokenSupplyStorage
function _getERC6909TokenSupplyStorage() private pure returns (ERC6909TokenSupplyStorage storage $);
__ERC6909TokenSupply_init
function __ERC6909TokenSupply_init() internal onlyInitializing;
__ERC6909TokenSupply_init_unchained
function __ERC6909TokenSupply_init_unchained() internal onlyInitializing;
totalSupply
Returns the total supply of the token of type id.
function totalSupply(uint256 id) public view virtual override returns (uint256);
_update
Override the _update function to update the total supply of each token id as necessary.
function _update(address from, address to, uint256 id, uint256 amount) internal virtual override;
Structs
ERC6909TokenSupplyStorage
Note: storage-location: erc7201:openzeppelin.storage.ERC6909TokenSupply
struct ERC6909TokenSupplyStorage {
mapping(uint256 id => uint256) _totalSupplies;
}
ERC6909Upgradeable
Inherits: Initializable, ContextUpgradeable, ERC165Upgradeable, IERC6909
Implementation of ERC-6909. See https://eips.ethereum.org/EIPS/eip-6909
State Variables
ERC6909StorageLocation
bytes32 private constant ERC6909StorageLocation = 0x9e75074fe7582401cc58901f6bda367c4d687c51437956963a7c06ef5cfaf900;
Functions
_getERC6909Storage
function _getERC6909Storage() private pure returns (ERC6909Storage storage $);
__ERC6909_init
function __ERC6909_init() internal onlyInitializing;
__ERC6909_init_unchained
function __ERC6909_init_unchained() internal onlyInitializing;
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC165Upgradeable, IERC165)
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
balanceOf
Returns the amount of tokens of type id owned by owner.
function balanceOf(address owner, uint256 id) public view virtual override returns (uint256);
allowance
Returns the amount of tokens of type id that spender is allowed to spend on behalf of owner.
NOTE: Does not include operator allowances.
function allowance(address owner, address spender, uint256 id) public view virtual override returns (uint256);
isOperator
Returns true if spender is set as an operator for owner.
function isOperator(address owner, address spender) public view virtual override returns (bool);
approve
Sets an approval to spender for amount of tokens of type id from the caller's tokens. An amount of
type(uint256).max signifies an unlimited approval.
Must return true.
function approve(address spender, uint256 id, uint256 amount) public virtual override returns (bool);
setOperator
Grants or revokes unlimited transfer permission of any token id to spender for the caller's tokens.
Must return true.
function setOperator(address spender, bool approved) public virtual override returns (bool);
transfer
Transfers amount of token type id from the caller's account to receiver.
Must return true.
function transfer(address receiver, uint256 id, uint256 amount) public virtual override returns (bool);
transferFrom
Transfers amount of token type id from sender to receiver.
Must return true.
function transferFrom(address sender, address receiver, uint256 id, uint256 amount)
public
virtual
override
returns (bool);
_mint
Creates amount of token id and assigns them to account, by transferring it from address(0).
Relies on the _update mechanism.
Emits a {Transfer} event with from set to the zero address.
NOTE: This function is not virtual, {_update} should be overridden instead.
function _mint(address to, uint256 id, uint256 amount) internal;
_transfer
Moves amount of token id from from to to without checking for approvals. This function verifies
that neither the sender nor the receiver are address(0), which means it cannot mint or burn tokens.
Relies on the _update mechanism.
Emits a {Transfer} event.
NOTE: This function is not virtual, {_update} should be overridden instead.
function _transfer(address from, address to, uint256 id, uint256 amount) internal;
_burn
Destroys a amount of token id from account.
Relies on the _update mechanism.
Emits a {Transfer} event with to set to the zero address.
NOTE: This function is not virtual, {_update} should be overridden instead
function _burn(address from, uint256 id, uint256 amount) internal;
_update
Transfers amount of token id from from to to, or alternatively mints (or burns) if from
(or to) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
this function.
Emits a {Transfer} event.
function _update(address from, address to, uint256 id, uint256 amount) internal virtual;
_approve
*Sets amount as the allowance of spender over the owner's id tokens.
This internal function is equivalent to approve, and can be used to e.g. set automatic allowances for certain
subsystems, etc.
Emits an {Approval} event.
Requirements:
ownercannot be the zero address.spendercannot be the zero address.*
function _approve(address owner, address spender, uint256 id, uint256 amount) internal virtual;
_setOperator
*Approve spender to operate on all of owner's tokens
This internal function is equivalent to setOperator, and can be used to e.g. set automatic allowances for
certain subsystems, etc.
Emits an {OperatorSet} event.
Requirements:
ownercannot be the zero address.spendercannot be the zero address.*
function _setOperator(address owner, address spender, bool approved) internal virtual;
_spendAllowance
Updates owner's allowance for spender based on spent amount.
Does not update the allowance value in case of infinite allowance.
Revert if not enough allowance is available.
Does not emit an {Approval} event.
function _spendAllowance(address owner, address spender, uint256 id, uint256 amount) internal virtual;
Errors
ERC6909InsufficientBalance
error ERC6909InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 id);
ERC6909InsufficientAllowance
error ERC6909InsufficientAllowance(address spender, uint256 allowance, uint256 needed, uint256 id);
ERC6909InvalidApprover
error ERC6909InvalidApprover(address approver);
ERC6909InvalidReceiver
error ERC6909InvalidReceiver(address receiver);
ERC6909InvalidSender
error ERC6909InvalidSender(address sender);
ERC6909InvalidSpender
error ERC6909InvalidSpender(address spender);
Structs
ERC6909Storage
Note: storage-location: erc7201:openzeppelin.storage.ERC6909
struct ERC6909Storage {
mapping(address owner => mapping(uint256 id => uint256)) _balances;
mapping(address owner => mapping(address operator => bool)) _operatorApprovals;
mapping(address owner => mapping(address spender => mapping(uint256 id => uint256))) _allowances;
}
Contents
Contents
- ERC721BurnableUpgradeable
- ERC721ConsecutiveUpgradeable
- ERC721EnumerableUpgradeable
- ERC721PausableUpgradeable
- ERC721RoyaltyUpgradeable
- ERC721URIStorageUpgradeable
- ERC721VotesUpgradeable
- ERC721WrapperUpgradeable
ERC721BurnableUpgradeable
Inherits: Initializable, ContextUpgradeable, ERC721Upgradeable
ERC-721 Token that can be burned (destroyed).
Functions
__ERC721Burnable_init
function __ERC721Burnable_init() internal onlyInitializing;
__ERC721Burnable_init_unchained
function __ERC721Burnable_init_unchained() internal onlyInitializing;
burn
*Burns tokenId. See ERC721-_burn.
Requirements:
- The caller must own
tokenIdor be an approved operator.*
function burn(uint256 tokenId) public virtual;
ERC721ConsecutiveUpgradeable
Inherits: Initializable, IERC2309, ERC721Upgradeable
Implementation of the ERC-2309 "Consecutive Transfer Extension" as defined in https://eips.ethereum.org/EIPS/eip-2309[ERC-2309]. This extension allows the minting of large batches of tokens, during contract construction only. For upgradeable contracts this implies that batch minting is only available during proxy deployment, and not in subsequent upgrades. These batches are limited to 5000 tokens at a time by default to accommodate off-chain indexers. Using this extension removes the ability to mint single tokens during contract construction. This ability is regained after construction. During construction, only batch minting is allowed. IMPORTANT: This extension does not call the _update function for tokens minted in batch. Any logic added to this function through overrides will not be triggered when token are minted in batch. You may want to also override {_increaseBalance} or {_mintConsecutive} to account for these mints. IMPORTANT: When overriding {_mintConsecutive}, be careful about call ordering. {ownerOf} may return invalid values during the {_mintConsecutive} execution if the super call is not called first. To be safe, execute the super call before your custom logic.
State Variables
ERC721ConsecutiveStorageLocation
bytes32 private constant ERC721ConsecutiveStorageLocation =
0x24de1071a22e1e6f709b09cc0dadb696f919b85b456665cd36195df4bc89ff00;
Functions
_getERC721ConsecutiveStorage
function _getERC721ConsecutiveStorage() private pure returns (ERC721ConsecutiveStorage storage $);
__ERC721Consecutive_init
function __ERC721Consecutive_init() internal onlyInitializing;
__ERC721Consecutive_init_unchained
function __ERC721Consecutive_init_unchained() internal onlyInitializing;
_maxBatchSize
Maximum size of a batch of consecutive tokens. This is designed to limit stress on off-chain indexing services that have to record one entry per token, and have protections against "unreasonably large" batches of tokens. NOTE: Overriding the default value of 5000 will not cause on-chain issues, but may result in the asset not being correctly supported by off-chain indexing services (including marketplaces).
function _maxBatchSize() internal view virtual returns (uint96);
_ownerOf
See ERC721-_ownerOf. Override that checks the sequential ownership structure for tokens that have been minted as part of a batch, and not yet transferred.
function _ownerOf(uint256 tokenId) internal view virtual override returns (address);
_mintConsecutive
*Mint a batch of tokens of length batchSize for to. Returns the token id of the first token minted in the
batch; if batchSize is 0, returns the number of consecutive ids minted so far.
Requirements:
batchSizemust not be greater than _maxBatchSize.- The function is called in the constructor of the contract (directly or indirectly).
CAUTION: Does not emit a
Transferevent. This is ERC-721 compliant as long as it is done inside of the constructor, which is enforced by this function. CAUTION: Does not invokeonERC721Receivedon the receiver. Emits a {IERC2309-ConsecutiveTransfer} event.*
function _mintConsecutive(address to, uint96 batchSize) internal virtual returns (uint96);
_update
See ERC721-_update. Override version that restricts normal minting to after construction. WARNING: Using {ERC721Consecutive} prevents minting during construction in favor of {_mintConsecutive}. After construction, {_mintConsecutive} is no longer available and minting through {_update} becomes available.
function _update(address to, uint256 tokenId, address auth) internal virtual override returns (address);
_firstConsecutiveId
Used to offset the first token id in _nextConsecutiveId
function _firstConsecutiveId() internal view virtual returns (uint96);
_nextConsecutiveId
Returns the next tokenId to mint using _mintConsecutive. It will return {_firstConsecutiveId} if no consecutive tokenId has been minted before.
function _nextConsecutiveId() private view returns (uint96);
Errors
ERC721ForbiddenBatchMint
Batch mint is restricted to the constructor. Any batch mint not emitting the IERC721-Transfer event outside of the constructor is non ERC-721 compliant.
error ERC721ForbiddenBatchMint();
ERC721ExceededMaxBatchMint
Exceeds the max amount of mints per batch.
error ERC721ExceededMaxBatchMint(uint256 batchSize, uint256 maxBatch);
ERC721ForbiddenMint
Individual minting is not allowed.
error ERC721ForbiddenMint();
ERC721ForbiddenBatchBurn
Batch burn is not supported.
error ERC721ForbiddenBatchBurn();
Structs
ERC721ConsecutiveStorage
Note: storage-location: erc7201:openzeppelin.storage.ERC721Consecutive
struct ERC721ConsecutiveStorage {
Checkpoints.Trace160 _sequentialOwnership;
BitMaps.BitMap _sequentialBurn;
}
ERC721EnumerableUpgradeable
Inherits: Initializable, ERC721Upgradeable, IERC721Enumerable
This implements an optional extension of {ERC721} defined in the ERC that adds enumerability
of all the token ids in the contract as well as all token ids owned by each account.
CAUTION: {ERC721} extensions that implement custom balanceOf logic, such as {ERC721Consecutive},
interfere with enumerability and should not be used together with {ERC721Enumerable}.
State Variables
ERC721EnumerableStorageLocation
bytes32 private constant ERC721EnumerableStorageLocation =
0x645e039705490088daad89bae25049a34f4a9072d398537b1ab2425f24cbed00;
Functions
_getERC721EnumerableStorage
function _getERC721EnumerableStorage() private pure returns (ERC721EnumerableStorage storage $);
__ERC721Enumerable_init
function __ERC721Enumerable_init() internal onlyInitializing;
__ERC721Enumerable_init_unchained
function __ERC721Enumerable_init_unchained() internal onlyInitializing;
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(IERC165, ERC721Upgradeable)
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
tokenOfOwnerByIndex
Enumerate NFTs assigned to an owner
Throws if _index >= balanceOf(_owner) or if
_owner is the zero address, representing invalid NFTs.
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
owner | address | |
index | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The token identifier for the _indexth NFT assigned to _owner, (sort order not specified) |
totalSupply
Count NFTs tracked by this contract
function totalSupply() public view virtual returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | A count of valid NFTs tracked by this contract, where each one of them has an assigned and queryable owner not equal to the zero address |
tokenByIndex
Enumerate valid NFTs
Throws if _index >= totalSupply().
function tokenByIndex(uint256 index) public view virtual returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The token identifier for the _indexth NFT, (sort order not specified) |
_update
Transfers tokenId from its current owner to to, or alternatively mints (or burns) if the current owner
(or to) is the zero address. Returns the owner of the tokenId before the update.
The auth argument is optional. If the value passed is non 0, then this function will check that
auth is either the owner of the token, or approved to operate on the token (by the owner).
Emits a {Transfer} event.
NOTE: If overriding this function in a way that tracks balances, see also {_increaseBalance}.
function _update(address to, uint256 tokenId, address auth) internal virtual override returns (address);
_addTokenToOwnerEnumeration
Private function to add a token to this extension's ownership-tracking data structures.
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private;
Parameters
| Name | Type | Description |
|---|---|---|
to | address | address representing the new owner of the given token ID |
tokenId | uint256 | uint256 ID of the token to be added to the tokens list of the given address |
_addTokenToAllTokensEnumeration
Private function to add a token to this extension's token tracking data structures.
function _addTokenToAllTokensEnumeration(uint256 tokenId) private;
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | uint256 ID of the token to be added to the tokens list |
_removeTokenFromOwnerEnumeration
Private function to remove a token from this extension's ownership-tracking data structures. Note that
while the token is not assigned a new owner, the _ownedTokensIndex mapping is not updated: this allows for
gas optimizations e.g. when performing a transfer operation (avoiding double writes).
This has O(1) time complexity, but alters the order of the _ownedTokens array.
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private;
Parameters
| Name | Type | Description |
|---|---|---|
from | address | address representing the previous owner of the given token ID |
tokenId | uint256 | uint256 ID of the token to be removed from the tokens list of the given address |
_removeTokenFromAllTokensEnumeration
Private function to remove a token from this extension's token tracking data structures. This has O(1) time complexity, but alters the order of the _allTokens array.
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private;
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | uint256 ID of the token to be removed from the tokens list |
_increaseBalance
See ERC721-_increaseBalance. We need that to account tokens that were minted in batch
function _increaseBalance(address account, uint128 amount) internal virtual override;
Errors
ERC721OutOfBoundsIndex
An owner's token query was out of bounds for index.
NOTE: The owner being address(0) indicates a global out of bounds index.
error ERC721OutOfBoundsIndex(address owner, uint256 index);
ERC721EnumerableForbiddenBatchMint
Batch mint is not allowed.
error ERC721EnumerableForbiddenBatchMint();
Structs
ERC721EnumerableStorage
Note: storage-location: erc7201:openzeppelin.storage.ERC721Enumerable
struct ERC721EnumerableStorage {
mapping(address owner => mapping(uint256 index => uint256)) _ownedTokens;
mapping(uint256 tokenId => uint256) _ownedTokensIndex;
uint256[] _allTokens;
mapping(uint256 tokenId => uint256) _allTokensIndex;
}
ERC721PausableUpgradeable
Inherits: Initializable, ERC721Upgradeable, PausableUpgradeable
ERC-721 token with pausable token transfers, minting and burning. Useful for scenarios such as preventing trades until the end of an evaluation period, or having an emergency switch for freezing all token transfers in the event of a large bug. IMPORTANT: This contract does not include public pause and unpause functions. In addition to inheriting this contract, you must define both functions, invoking the Pausable-_pause and {Pausable-_unpause} internal functions, with appropriate access control, e.g. using {AccessControl} or {Ownable}. Not doing so will make the contract pause mechanism of the contract unreachable, and thus unusable.
Functions
__ERC721Pausable_init
function __ERC721Pausable_init() internal onlyInitializing;
__ERC721Pausable_init_unchained
function __ERC721Pausable_init_unchained() internal onlyInitializing;
_update
*See ERC721-_update. Requirements:
- the contract must not be paused.*
function _update(address to, uint256 tokenId, address auth) internal virtual override whenNotPaused returns (address);
ERC721RoyaltyUpgradeable
Inherits: Initializable, ERC2981Upgradeable, ERC721Upgradeable
Extension of ERC-721 with the ERC-2981 NFT Royalty Standard, a standardized way to retrieve royalty payment information. Royalty information can be specified globally for all token ids via ERC2981-_setDefaultRoyalty, and/or individually for specific token ids via {ERC2981-_setTokenRoyalty}. The latter takes precedence over the first. IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the ERC. Marketplaces are expected to voluntarily pay royalties together with sales, but note that this standard is not yet widely supported.
Functions
__ERC721Royalty_init
function __ERC721Royalty_init() internal onlyInitializing;
__ERC721Royalty_init_unchained
function __ERC721Royalty_init_unchained() internal onlyInitializing;
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC721Upgradeable, ERC2981Upgradeable)
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
ERC721URIStorageUpgradeable
Inherits: Initializable, IERC4906, ERC721Upgradeable
ERC-721 token with storage based token URI management.
State Variables
ERC4906_INTERFACE_ID
bytes4 private constant ERC4906_INTERFACE_ID = bytes4(0x49064906);
ERC721URIStorageStorageLocation
bytes32 private constant ERC721URIStorageStorageLocation =
0x0542a41881ee128a365a727b282c86fa859579490b9bb45aab8503648c8e7900;
Functions
_getERC721URIStorageStorage
function _getERC721URIStorageStorage() private pure returns (ERC721URIStorageStorage storage $);
__ERC721URIStorage_init
function __ERC721URIStorage_init() internal onlyInitializing;
__ERC721URIStorage_init_unchained
function __ERC721URIStorage_init_unchained() internal onlyInitializing;
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC721Upgradeable, IERC165)
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
tokenURI
A distinct Uniform Resource Identifier (URI) for a given asset.
Throws if _tokenId is not a valid NFT. URIs are defined in RFC
3986. The URI may point to a JSON file that conforms to the "ERC721
Metadata JSON Schema".
function tokenURI(uint256 tokenId) public view virtual override returns (string memory);
_setTokenURI
Sets _tokenURI as the tokenURI of tokenId.
Emits IERC4906-MetadataUpdate.
function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual;
Structs
ERC721URIStorageStorage
Note: storage-location: erc7201:openzeppelin.storage.ERC721URIStorage
struct ERC721URIStorageStorage {
mapping(uint256 tokenId => string) _tokenURIs;
}
ERC721VotesUpgradeable
Inherits: Initializable, ERC721Upgradeable, VotesUpgradeable
Extension of ERC-721 to support voting and delegation as implemented by {Votes}, where each individual NFT counts as 1 vote unit. Tokens do not count as votes until they are delegated, because votes must be tracked which incurs an additional cost on every transfer. Token holders can either delegate to a trusted representative who will decide how to make use of the votes in governance decisions, or they can delegate to themselves to be their own representative.
Functions
__ERC721Votes_init
function __ERC721Votes_init() internal onlyInitializing;
__ERC721Votes_init_unchained
function __ERC721Votes_init_unchained() internal onlyInitializing;
_update
See ERC721-_update. Adjusts votes when tokens are transferred. Emits a {IVotes-DelegateVotesChanged} event.
function _update(address to, uint256 tokenId, address auth) internal virtual override returns (address);
_getVotingUnits
Returns the balance of account.
WARNING: Overriding this function will likely result in incorrect vote tracking.
function _getVotingUnits(address account) internal view virtual override returns (uint256);
_increaseBalance
See ERC721-_increaseBalance. We need that to account tokens that were minted in batch.
function _increaseBalance(address account, uint128 amount) internal virtual override;
ERC721WrapperUpgradeable
Inherits: Initializable, ERC721Upgradeable, IERC721Receiver
Extension of the ERC-721 token contract to support token wrapping. Users can deposit and withdraw an "underlying token" and receive a "wrapped token" with a matching tokenId. This is useful in conjunction with other modules. For example, combining this wrapping mechanism with {ERC721Votes} will allow the wrapping of an existing "basic" ERC-721 into a governance token.
State Variables
ERC721WrapperStorageLocation
bytes32 private constant ERC721WrapperStorageLocation =
0xa27ade666fc2e768f0cfbad659dfd6a7039cae52f9274d2ab808f70dce364400;
Functions
_getERC721WrapperStorage
function _getERC721WrapperStorage() private pure returns (ERC721WrapperStorage storage $);
__ERC721Wrapper_init
function __ERC721Wrapper_init(IERC721 underlyingToken) internal onlyInitializing;
__ERC721Wrapper_init_unchained
function __ERC721Wrapper_init_unchained(IERC721 underlyingToken) internal onlyInitializing;
depositFor
Allow a user to deposit underlying tokens and mint the corresponding tokenIds.
function depositFor(address account, uint256[] memory tokenIds) public virtual returns (bool);
withdrawTo
Allow a user to burn wrapped tokens and withdraw the corresponding tokenIds of the underlying tokens.
function withdrawTo(address account, uint256[] memory tokenIds) public virtual returns (bool);
onERC721Received
Overrides IERC721Receiver-onERC721Received to allow minting on direct ERC-721 transfers to this contract. In case there's data attached, it validates that the operator is this contract, so only trusted data is accepted from {depositFor}. WARNING: Doesn't work with unsafe transfers (eg. {IERC721-transferFrom}). Use {ERC721Wrapper-_recover} for recovering in that scenario.
function onERC721Received(address, address from, uint256 tokenId, bytes memory) public virtual returns (bytes4);
_recover
Mint a wrapped token to cover any underlyingToken that would have been transferred by mistake. Internal function that can be exposed with access control if desired.
function _recover(address account, uint256 tokenId) internal virtual returns (uint256);
underlying
Returns the underlying token.
function underlying() public view virtual returns (IERC721);
Errors
ERC721UnsupportedToken
The received ERC-721 token couldn't be wrapped.
error ERC721UnsupportedToken(address token);
Structs
ERC721WrapperStorage
Note: storage-location: erc7201:openzeppelin.storage.ERC721Wrapper
struct ERC721WrapperStorage {
IERC721 _underlying;
}
Contents
ERC721HolderUpgradeable
Inherits: Initializable, IERC721Receiver
Implementation of the {IERC721Receiver} interface. Accepts all token transfers. Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.
Functions
__ERC721Holder_init
function __ERC721Holder_init() internal onlyInitializing;
__ERC721Holder_init_unchained
function __ERC721Holder_init_unchained() internal onlyInitializing;
onERC721Received
See IERC721Receiver-onERC721Received.
Always returns IERC721Receiver.onERC721Received.selector.
function onERC721Received(address, address, uint256, bytes memory) public virtual returns (bytes4);
ERC721Upgradeable
Inherits: Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721, IERC721Metadata, IERC721Errors
Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC-721] Non-Fungible Token Standard, including the Metadata extension, but not including the Enumerable extension, which is available separately as {ERC721Enumerable}.
State Variables
ERC721StorageLocation
bytes32 private constant ERC721StorageLocation = 0x80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab0079300;
Functions
_getERC721Storage
function _getERC721Storage() private pure returns (ERC721Storage storage $);
__ERC721_init
Initializes the contract by setting a name and a symbol to the token collection.
function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing;
__ERC721_init_unchained
function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing;
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC165Upgradeable, IERC165)
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
balanceOf
Count all NFTs assigned to an owner
NFTs assigned to the zero address are considered invalid, and this function throws for queries about the zero address.
function balanceOf(address owner) public view virtual returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
owner | address |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The number of NFTs owned by _owner, possibly zero |
ownerOf
Find the owner of an NFT
NFTs assigned to zero address are considered invalid, and queries about them do throw.
function ownerOf(uint256 tokenId) public view virtual returns (address);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The address of the owner of the NFT |
name
A descriptive name for a collection of NFTs in this contract
function name() public view virtual returns (string memory);
symbol
An abbreviated name for NFTs in this contract
function symbol() public view virtual returns (string memory);
tokenURI
A distinct Uniform Resource Identifier (URI) for a given asset.
Throws if _tokenId is not a valid NFT. URIs are defined in RFC
3986. The URI may point to a JSON file that conforms to the "ERC721
Metadata JSON Schema".
function tokenURI(uint256 tokenId) public view virtual returns (string memory);
_baseURI
Base URI for computing tokenURI. If set, the resulting URI for each
token will be the concatenation of the baseURI and the tokenId. Empty
by default, can be overridden in child contracts.
function _baseURI() internal view virtual returns (string memory);
approve
Change or reaffirm the approved address for an NFT
The zero address indicates there is no approved address.
Throws unless msg.sender is the current NFT owner, or an authorized
operator of the current owner.
function approve(address to, uint256 tokenId) public virtual;
Parameters
| Name | Type | Description |
|---|---|---|
to | address | |
tokenId | uint256 |
getApproved
Get the approved address for a single NFT
Throws if _tokenId is not a valid NFT.
function getApproved(uint256 tokenId) public view virtual returns (address);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The approved address for this NFT, or the zero address if there is none |
setApprovalForAll
Enable or disable approval for a third party ("operator") to manage
all of msg.sender's assets
Emits the ApprovalForAll event. The contract MUST allow multiple operators per owner.
function setApprovalForAll(address operator, bool approved) public virtual;
Parameters
| Name | Type | Description |
|---|---|---|
operator | address | |
approved | bool |
isApprovedForAll
Query if an address is an authorized operator for another address
function isApprovedForAll(address owner, address operator) public view virtual returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
owner | address | |
operator | address |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if _operator is an approved operator for _owner, false otherwise |
transferFrom
Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE
TO CONFIRM THAT _to IS CAPABLE OF RECEIVING NFTS OR ELSE
THEY MAY BE PERMANENTLY LOST
Throws unless msg.sender is the current owner, an authorized
operator, or the approved address for this NFT. Throws if _from is
not the current owner. Throws if _to is the zero address. Throws if
_tokenId is not a valid NFT.
function transferFrom(address from, address to, uint256 tokenId) public virtual;
Parameters
| Name | Type | Description |
|---|---|---|
from | address | |
to | address | |
tokenId | uint256 |
safeTransferFrom
Transfers the ownership of an NFT from one address to another address
Throws unless msg.sender is the current owner, an authorized
operator, or the approved address for this NFT. Throws if _from is
not the current owner. Throws if _to is the zero address. Throws if
_tokenId is not a valid NFT. When transfer is complete, this function
checks if _to is a smart contract (code size > 0). If so, it calls
onERC721Received on _to and throws if the return value is not
bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")).
function safeTransferFrom(address from, address to, uint256 tokenId) public;
Parameters
| Name | Type | Description |
|---|---|---|
from | address | |
to | address | |
tokenId | uint256 |
safeTransferFrom
Transfers the ownership of an NFT from one address to another address
Throws unless msg.sender is the current owner, an authorized
operator, or the approved address for this NFT. Throws if _from is
not the current owner. Throws if _to is the zero address. Throws if
_tokenId is not a valid NFT. When transfer is complete, this function
checks if _to is a smart contract (code size > 0). If so, it calls
onERC721Received on _to and throws if the return value is not
bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")).
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual;
Parameters
| Name | Type | Description |
|---|---|---|
from | address | |
to | address | |
tokenId | uint256 | |
data | bytes | Additional data with no specified format, sent in call to _to |
_ownerOf
Returns the owner of the tokenId. Does NOT revert if token doesn't exist
IMPORTANT: Any overrides to this function that add ownership of tokens not tracked by the
core ERC-721 logic MUST be matched with the use of _increaseBalance to keep balances
consistent with ownership. The invariant to preserve is that for any address a the value returned by
balanceOf(a) must be equal to the number of tokens such that _ownerOf(tokenId) is a.
function _ownerOf(uint256 tokenId) internal view virtual returns (address);
_getApproved
Returns the approved address for tokenId. Returns 0 if tokenId is not minted.
function _getApproved(uint256 tokenId) internal view virtual returns (address);
_isAuthorized
Returns whether spender is allowed to manage owner's tokens, or tokenId in
particular (ignoring whether it is owned by owner).
WARNING: This function assumes that owner is the actual owner of tokenId and does not verify this
assumption.
function _isAuthorized(address owner, address spender, uint256 tokenId) internal view virtual returns (bool);
_checkAuthorized
*Checks if spender can operate on tokenId, assuming the provided owner is the actual owner.
Reverts if:
spenderdoes not have approval fromownerfortokenId.spenderdoes not have approval to manage all ofowner's assets. WARNING: This function assumes thatowneris the actual owner oftokenIdand does not verify this assumption.*
function _checkAuthorized(address owner, address spender, uint256 tokenId) internal view virtual;
_increaseBalance
Unsafe write access to the balances, used by extensions that "mint" tokens using an ownerOf override. NOTE: the value is limited to type(uint128).max. This protect against _balance overflow. It is unrealistic that a uint256 would ever overflow from increments when these increments are bounded to uint128 values. WARNING: Increasing an account's balance using this function tends to be paired with an override of the {_ownerOf} function to resolve the ownership of the corresponding tokens so that balances and ownership remain consistent with one another.
function _increaseBalance(address account, uint128 value) internal virtual;
_update
Transfers tokenId from its current owner to to, or alternatively mints (or burns) if the current owner
(or to) is the zero address. Returns the owner of the tokenId before the update.
The auth argument is optional. If the value passed is non 0, then this function will check that
auth is either the owner of the token, or approved to operate on the token (by the owner).
Emits a {Transfer} event.
NOTE: If overriding this function in a way that tracks balances, see also {_increaseBalance}.
function _update(address to, uint256 tokenId, address auth) internal virtual returns (address);
_mint
*Mints tokenId and transfers it to to.
WARNING: Usage of this method is discouraged, use _safeMint whenever possible
Requirements:
tokenIdmust not exist.tocannot be the zero address. Emits a {Transfer} event.*
function _mint(address to, uint256 tokenId) internal;
_safeMint
*Mints tokenId, transfers it to to and checks for to acceptance.
Requirements:
tokenIdmust not exist.- If
torefers to a smart contract, it must implement IERC721Receiver-onERC721Received, which is called upon a safe transfer. Emits a {Transfer} event.*
function _safeMint(address to, uint256 tokenId) internal;
_safeMint
Same as _safeMint, with an additional data parameter which is
forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual;
_burn
*Destroys tokenId.
The approval is cleared when the token is burned.
This is an internal function that does not check if the sender is authorized to operate on the token.
Requirements:
tokenIdmust exist. Emits a {Transfer} event.*
function _burn(uint256 tokenId) internal;
_transfer
*Transfers tokenId from from to to.
As opposed to transferFrom, this imposes no restrictions on msg.sender.
Requirements:
tocannot be the zero address.tokenIdtoken must be owned byfrom. Emits a {Transfer} event.*
function _transfer(address from, address to, uint256 tokenId) internal;
_safeTransfer
*Safely transfers tokenId token from from to to, checking that contract recipients
are aware of the ERC-721 standard to prevent tokens from being forever locked.
data is additional data, it has no specified format and it is sent in call to to.
This internal function is like safeTransferFrom in the sense that it invokes
{IERC721Receiver-onERC721Received} on the receiver, and can be used to e.g.
implement alternative mechanisms to perform token transfer, such as signature-based.
Requirements:
tokenIdtoken must exist and be owned byfrom.tocannot be the zero address.fromcannot be the zero address.- If
torefers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. Emits a {Transfer} event.*
function _safeTransfer(address from, address to, uint256 tokenId) internal;
_safeTransfer
Same as _safeTransfer, with an additional data parameter which is
forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual;
_approve
Approve to to operate on tokenId
The auth argument is optional. If the value passed is non 0, then this function will check that auth is
either the owner of the token, or approved to operate on all tokens held by this owner.
Emits an {Approval} event.
Overrides to this logic should be done to the variant with an additional bool emitEvent argument.
function _approve(address to, uint256 tokenId, address auth) internal;
_approve
Variant of _approve with an optional flag to enable or disable the {Approval} event. The event is not
emitted in the context of transfers.
function _approve(address to, uint256 tokenId, address auth, bool emitEvent) internal virtual;
_setApprovalForAll
*Approve operator to operate on all of owner tokens
Requirements:
- operator can't be the address zero. Emits an {ApprovalForAll} event.*
function _setApprovalForAll(address owner, address operator, bool approved) internal virtual;
_requireOwned
Reverts if the tokenId doesn't have a current owner (it hasn't been minted, or it has been burned).
Returns the owner.
Overrides to ownership logic should be done to _ownerOf.
function _requireOwned(uint256 tokenId) internal view returns (address);
Structs
ERC721Storage
Note: storage-location: erc7201:openzeppelin.storage.ERC721
struct ERC721Storage {
string _name;
string _symbol;
mapping(uint256 tokenId => address) _owners;
mapping(address owner => uint256) _balances;
mapping(uint256 tokenId => address) _tokenApprovals;
mapping(address owner => mapping(address operator => bool)) _operatorApprovals;
}
Contents
ERC2981Upgradeable
Inherits: Initializable, IERC2981, ERC165Upgradeable
Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information. Royalty information can be specified globally for all token ids via _setDefaultRoyalty, and/or individually for specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first. Royalty is specified as a fraction of sale price. {_feeDenominator} is overridable but defaults to 10000, meaning the fee is specified in basis points by default. IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the ERC. Marketplaces are expected to voluntarily pay royalties together with sales, but note that this standard is not yet widely supported.
State Variables
ERC2981StorageLocation
bytes32 private constant ERC2981StorageLocation = 0xdaedc9ab023613a7caf35e703657e986ccfad7e3eb0af93a2853f8d65dd86b00;
Functions
_getERC2981Storage
function _getERC2981Storage() private pure returns (ERC2981Storage storage $);
__ERC2981_init
function __ERC2981_init() internal onlyInitializing;
__ERC2981_init_unchained
function __ERC2981_init_unchained() internal onlyInitializing;
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(IERC165, ERC165Upgradeable)
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
royaltyInfo
Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of exchange. The royalty amount is denominated and should be paid in that same unit of exchange. NOTE: ERC-2981 allows setting the royalty to 100% of the price. In that case all the price would be sent to the royalty receiver and 0 tokens to the seller. Contracts dealing with royalty should consider empty transfers.
function royaltyInfo(uint256 tokenId, uint256 salePrice)
public
view
virtual
returns (address receiver, uint256 amount);
_feeDenominator
The denominator with which to interpret the fee set in _setTokenRoyalty and {_setDefaultRoyalty} as a fraction of the sale price. Defaults to 10000 so fees are expressed in basis points, but may be customized by an override.
function _feeDenominator() internal pure virtual returns (uint96);
_setDefaultRoyalty
*Sets the royalty information that all ids in this contract will default to. Requirements:
receivercannot be the zero address.feeNumeratorcannot be greater than the fee denominator.*
function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual;
_deleteDefaultRoyalty
Removes default royalty information.
function _deleteDefaultRoyalty() internal virtual;
_setTokenRoyalty
*Sets the royalty information for a specific token id, overriding the global default. Requirements:
receivercannot be the zero address.feeNumeratorcannot be greater than the fee denominator.*
function _setTokenRoyalty(uint256 tokenId, address receiver, uint96 feeNumerator) internal virtual;
_resetTokenRoyalty
Resets royalty information for the token id back to the global default.
function _resetTokenRoyalty(uint256 tokenId) internal virtual;
Errors
ERC2981InvalidDefaultRoyalty
The default royalty set is invalid (eg. (numerator / denominator) >= 1).
error ERC2981InvalidDefaultRoyalty(uint256 numerator, uint256 denominator);
ERC2981InvalidDefaultRoyaltyReceiver
The default royalty receiver is invalid.
error ERC2981InvalidDefaultRoyaltyReceiver(address receiver);
ERC2981InvalidTokenRoyalty
The royalty set for a specific tokenId is invalid (eg. (numerator / denominator) >= 1).
error ERC2981InvalidTokenRoyalty(uint256 tokenId, uint256 numerator, uint256 denominator);
ERC2981InvalidTokenRoyaltyReceiver
The royalty receiver for tokenId is invalid.
error ERC2981InvalidTokenRoyaltyReceiver(uint256 tokenId, address receiver);
Structs
RoyaltyInfo
struct RoyaltyInfo {
address receiver;
uint96 royaltyFraction;
}
ERC2981Storage
Note: storage-location: erc7201:openzeppelin.storage.ERC2981
struct ERC2981Storage {
RoyaltyInfo _defaultRoyaltyInfo;
mapping(uint256 tokenId => RoyaltyInfo) _tokenRoyaltyInfo;
}
Contents
- cryptography
- introspection
- ContextUpgradeable
- MulticallUpgradeable
- NoncesKeyedUpgradeable
- NoncesUpgradeable
- PausableUpgradeable
- ReentrancyGuardTransientUpgradeable
- ReentrancyGuardUpgradeable
Contents
Contents
- MultiSignerERC7913Upgradeable
- MultiSignerERC7913WeightedUpgradeable
- SignerECDSAUpgradeable
- SignerERC7913Upgradeable
- SignerP256Upgradeable
- SignerRSAUpgradeable
- ERC7739Upgradeable
MultiSignerERC7913Upgradeable
Inherits: Initializable, AbstractSigner
*Implementation of {AbstractSigner} using multiple ERC-7913 signers with a threshold-based signature verification system. This contract allows managing a set of authorized signers and requires a minimum number of signatures (threshold) to approve operations. It uses ERC-7913 formatted signers, which makes it natively compatible with ECDSA and ERC-1271 signers. Example of usage:
contract MyMultiSignerAccount is Account, MultiSignerERC7913, Initializable {
function initialize(bytes[] memory signers, uint64 threshold) public initializer {
_addSigners(signers);
_setThreshold(threshold);
}
function addSigners(bytes[] memory signers) public onlyEntryPointOrSelf {
_addSigners(signers);
}
function removeSigners(bytes[] memory signers) public onlyEntryPointOrSelf {
_removeSigners(signers);
}
function setThreshold(uint64 threshold) public onlyEntryPointOrSelf {
_setThreshold(threshold);
}
}
IMPORTANT: Failing to properly initialize the signers and threshold either during construction (if used standalone) or during initialization (if used as a clone) may leave the contract either front-runnable or unusable.*
State Variables
MultiSignerERC7913StorageLocation
bytes32 private constant MultiSignerERC7913StorageLocation =
0xdfe169305a533e288e0557da8d289146d3cc75fa6e04c87599b048a60a4e5600;
Functions
_getMultiSignerERC7913Storage
function _getMultiSignerERC7913Storage() private pure returns (MultiSignerERC7913Storage storage $);
__MultiSignerERC7913_init
function __MultiSignerERC7913_init(bytes[] memory signers_, uint64 threshold_) internal onlyInitializing;
__MultiSignerERC7913_init_unchained
function __MultiSignerERC7913_init_unchained(bytes[] memory signers_, uint64 threshold_) internal onlyInitializing;
getSigners
Returns a slice of the set of authorized signers.
Using start = 0 and end = type(uint64).max will return the entire set of signers.
WARNING: Depending on the start and end, this operation can copy a large amount of data to memory, which
can be expensive. This is designed for view accessors queried without gas fees. Using it in state-changing
functions may become uncallable if the slice grows too large.
function getSigners(uint64 start, uint64 end) public view virtual returns (bytes[] memory);
getSignerCount
Returns the number of authorized signers
function getSignerCount() public view virtual returns (uint256);
isSigner
Returns whether the signer is an authorized signer.
function isSigner(bytes memory signer) public view virtual returns (bool);
threshold
Returns the minimum number of signers required to approve a multisignature operation.
function threshold() public view virtual returns (uint64);
_addSigners
Adds the newSigners to those allowed to sign on behalf of this contract.
Internal version without access control.
Requirements:
Each of newSigners must be at least 20 bytes long. Reverts with MultiSignerERC7913InvalidSigner if not.
Each of newSigners must not be authorized. See {isSigner}. Reverts with {MultiSignerERC7913AlreadyExists} if so.
function _addSigners(bytes[] memory newSigners) internal virtual;
_removeSigners
Removes the oldSigners from the authorized signers. Internal version without access control.
Requirements:
Each of oldSigners must be authorized. See isSigner. Otherwise {MultiSignerERC7913NonexistentSigner} is thrown.
See {_validateReachableThreshold} for the threshold validation.
function _removeSigners(bytes[] memory oldSigners) internal virtual;
_setThreshold
Sets the signatures threshold required to approve a multisignature operation.
Internal version without access control.
Requirements:
See _validateReachableThreshold for the threshold validation.
function _setThreshold(uint64 newThreshold) internal virtual;
_validateReachableThreshold
Validates the current threshold is reachable. Requirements: The getSignerCount must be greater or equal than to the {threshold}. Throws {MultiSignerERC7913UnreachableThreshold} if not.
function _validateReachableThreshold() internal view virtual;
_rawSignatureValidation
*Decodes, validates the signature and checks the signers are authorized. See _validateSignatures and {_validateThreshold} for more details. Example of signature encoding:
// Encode signers (verifier || key)
bytes memory signer1 = abi.encodePacked(verifier1, key1);
bytes memory signer2 = abi.encodePacked(verifier2, key2);
// Order signers by their id
if (keccak256(signer1) > keccak256(signer2)) {
(signer1, signer2) = (signer2, signer1);
(signature1, signature2) = (signature2, signature1);
}
// Assign ordered signers and signatures
bytes[] memory signers = new bytes[](2);
bytes[] memory signatures = new bytes[](2);
signers[0] = signer1;
signatures[0] = signature1;
signers[1] = signer2;
signatures[1] = signature2;
// Encode the multi signature
bytes memory signature = abi.encode(signers, signatures);
Requirements:
The signature must be encoded as abi.encode(signers, signatures).*
function _rawSignatureValidation(bytes32 hash, bytes calldata signature)
internal
view
virtual
override
returns (bool);
_validateSignatures
Validates the signatures using the signers and their corresponding signatures.
Returns whether the signers are authorized and the signatures are valid for the given hash.
IMPORTANT: Sorting the signers by their keccak256 hash will improve the gas efficiency of this function.
See {SignatureChecker-areValidSignaturesNow-bytes32-bytes[]-bytes[]} for more details.
Requirements:
The signatures and signers arrays must be equal in length. Returns false otherwise.
function _validateSignatures(bytes32 hash, bytes[] memory signers, bytes[] memory signatures)
internal
view
virtual
returns (bool valid);
_validateThreshold
Validates that the number of signers meets the threshold requirement. Assumes the signers were already validated. See {_validateSignatures} for more details.
function _validateThreshold(bytes[] memory validatingSigners) internal view virtual returns (bool);
Events
ERC7913SignerAdded
Emitted when a signer is added.
event ERC7913SignerAdded(bytes indexed signers);
ERC7913SignerRemoved
Emitted when a signers is removed.
event ERC7913SignerRemoved(bytes indexed signers);
ERC7913ThresholdSet
Emitted when the threshold is updated.
event ERC7913ThresholdSet(uint64 threshold);
Errors
MultiSignerERC7913AlreadyExists
The signer already exists.
error MultiSignerERC7913AlreadyExists(bytes signer);
MultiSignerERC7913NonexistentSigner
The signer does not exist.
error MultiSignerERC7913NonexistentSigner(bytes signer);
MultiSignerERC7913InvalidSigner
The signer is less than 20 bytes long.
error MultiSignerERC7913InvalidSigner(bytes signer);
MultiSignerERC7913ZeroThreshold
The threshold is zero.
error MultiSignerERC7913ZeroThreshold();
MultiSignerERC7913UnreachableThreshold
The threshold is unreachable given the number of signers.
error MultiSignerERC7913UnreachableThreshold(uint64 signers, uint64 threshold);
Structs
MultiSignerERC7913Storage
Note: storage-location: erc7201:openzeppelin.storage.MultiSignerERC7913
struct MultiSignerERC7913Storage {
EnumerableSet.BytesSet _signers;
uint64 _threshold;
}
MultiSignerERC7913WeightedUpgradeable
Inherits: Initializable, MultiSignerERC7913Upgradeable
*Extension of {MultiSignerERC7913} that supports weighted signatures. This contract allows assigning different weights to each signer, enabling more flexible governance schemes. For example, some signers could have higher weight than others, allowing for weighted voting or prioritized authorization. Example of usage:
contract MyWeightedMultiSignerAccount is Account, MultiSignerERC7913Weighted, Initializable {
function initialize(bytes[] memory signers, uint64[] memory weights, uint64 threshold) public initializer {
_addSigners(signers);
_setSignerWeights(signers, weights);
_setThreshold(threshold);
}
function addSigners(bytes[] memory signers) public onlyEntryPointOrSelf {
_addSigners(signers);
}
function removeSigners(bytes[] memory signers) public onlyEntryPointOrSelf {
_removeSigners(signers);
}
function setThreshold(uint64 threshold) public onlyEntryPointOrSelf {
_setThreshold(threshold);
}
function setSignerWeights(bytes[] memory signers, uint64[] memory weights) public onlyEntryPointOrSelf {
_setSignerWeights(signers, weights);
}
}
IMPORTANT: When setting a threshold value, ensure it matches the scale used for signer weights. For example, if signers have weights like 1, 2, or 3, then a threshold of 4 would require at least two signers (e.g., one with weight 1 and one with weight 3). See {signerWeight}.*
State Variables
MultiSignerERC7913WeightedStorageLocation
bytes32 private constant MultiSignerERC7913WeightedStorageLocation =
0x5ec62f110612a7ff5e720b9a2f4970583e308ad11d9cde77cb7db3ea251b1f00;
Functions
_getMultiSignerERC7913WeightedStorage
function _getMultiSignerERC7913WeightedStorage() private pure returns (MultiSignerERC7913WeightedStorage storage $);
__MultiSignerERC7913Weighted_init
function __MultiSignerERC7913Weighted_init(bytes[] memory signers_, uint64[] memory weights_, uint64 threshold_)
internal
onlyInitializing;
__MultiSignerERC7913Weighted_init_unchained
function __MultiSignerERC7913Weighted_init_unchained(
bytes[] memory signers_,
uint64[] memory weights_,
uint64 threshold_
) internal onlyInitializing;
signerWeight
Gets the weight of a signer. Returns 0 if the signer is not authorized.
function signerWeight(bytes memory signer) public view virtual returns (uint64);
totalWeight
Gets the total weight of all signers.
function totalWeight() public view virtual returns (uint64);
_setSignerWeights
Sets weights for multiple signers at once. Internal version without access control.
Requirements:
signers and weights arrays must have the same length. Reverts with MultiSignerERC7913WeightedMismatchedLength on mismatch.
Each signer must exist in the set of authorized signers. Otherwise reverts with {MultiSignerERC7913NonexistentSigner}
Each weight must be greater than 0. Otherwise reverts with {MultiSignerERC7913WeightedInvalidWeight}
See {_validateReachableThreshold} for the threshold validation.
Emits {ERC7913SignerWeightChanged} for each signer.
function _setSignerWeights(bytes[] memory signers, uint64[] memory weights) internal virtual;
_addSigners
See MultiSignerERC7913-_addSigners.
In cases where {totalWeight} is almost type(uint64).max (due to a large _totalExtraWeight), adding new
signers could cause the {totalWeight} computation to overflow. Adding a {totalWeight} calls after the new
signers are added ensures no such overflow happens.
function _addSigners(bytes[] memory newSigners) internal virtual override;
_removeSigners
See MultiSignerERC7913-_removeSigners. Just like {_addSigners}, this function does not emit {ERC7913SignerWeightChanged} events. The {ERC7913SignerRemoved} event emitted by {MultiSignerERC7913-_removeSigners} is enough to track weights here.
function _removeSigners(bytes[] memory signers) internal virtual override;
_validateReachableThreshold
Sets the threshold for the multisignature operation. Internal version without access control.
Requirements:
The totalWeight must be >= the {threshold}. Otherwise reverts with {MultiSignerERC7913UnreachableThreshold}
NOTE: This function intentionally does not call super._validateReachableThreshold because the base implementation
assumes each signer has a weight of 1, which is a subset of this weighted implementation. Consider that multiple
implementations of this function may exist in the contract, so important side effects may be missed
depending on the linearization order.
function _validateReachableThreshold() internal view virtual override;
_validateThreshold
Validates that the total weight of signers meets the threshold requirement.
NOTE: This function intentionally does not call super._validateThreshold because the base implementation
assumes each signer has a weight of 1, which is a subset of this weighted implementation. Consider that multiple
implementations of this function may exist in the contract, so important side effects may be missed
depending on the linearization order.
function _validateThreshold(bytes[] memory signers) internal view virtual override returns (bool);
Events
ERC7913SignerWeightChanged
Emitted when a signer's weight is changed. NOTE: Not emitted in _addSigners or {_removeSigners}. Indexers must rely on {ERC7913SignerAdded} and {ERC7913SignerRemoved} to index a default weight of 1. See {signerWeight}.
event ERC7913SignerWeightChanged(bytes indexed signer, uint64 weight);
Errors
MultiSignerERC7913WeightedInvalidWeight
Thrown when a signer's weight is invalid.
error MultiSignerERC7913WeightedInvalidWeight(bytes signer, uint64 weight);
MultiSignerERC7913WeightedMismatchedLength
Thrown when the arrays lengths don't match. See _setSignerWeights.
error MultiSignerERC7913WeightedMismatchedLength();
Structs
MultiSignerERC7913WeightedStorage
Note: storage-location: erc7201:openzeppelin.storage.MultiSignerERC7913Weighted
struct MultiSignerERC7913WeightedStorage {
uint64 _totalExtraWeight;
mapping(bytes signer => uint64) _extraWeights;
}
SignerECDSAUpgradeable
Inherits: Initializable, AbstractSigner
*Implementation of {AbstractSigner} using xref:api:utils/cryptography#ECDSA[ECDSA] signatures. For {Account} usage, a {_setSigner} function is provided to set the {signer} address. Doing so is easier for a factory, who is likely to use initializable clones of this contract. Example of usage:
contract MyAccountECDSA is Account, SignerECDSA, Initializable {
function initialize(address signerAddr) public initializer {
_setSigner(signerAddr);
}
}
IMPORTANT: Failing to call {_setSigner} either during construction (if used standalone) or during initialization (if used as a clone) may leave the signer either front-runnable or unusable.*
State Variables
SignerECDSAStorageLocation
bytes32 private constant SignerECDSAStorageLocation = 0x21a2a8bb424898f7a6033d112ec6057811f27c903c45eccf7ad7cefcbbc0d200;
Functions
_getSignerECDSAStorage
function _getSignerECDSAStorage() private pure returns (SignerECDSAStorage storage $);
__SignerECDSA_init
function __SignerECDSA_init(address signerAddr) internal onlyInitializing;
__SignerECDSA_init_unchained
function __SignerECDSA_init_unchained(address signerAddr) internal onlyInitializing;
_setSigner
Sets the signer with the address of the native signer. This function should be called during construction or through an initializer.
function _setSigner(address signerAddr) internal;
signer
Return the signer's address.
function signer() public view virtual returns (address);
_rawSignatureValidation
Signature validation algorithm. WARNING: Implementing a signature validation algorithm is a security-sensitive operation as it involves cryptographic verification. It is important to review and test thoroughly before deployment. Consider using one of the signature verification libraries (xref:api:utils/cryptography#ECDSA[ECDSA], xref:api:utils/cryptography#P256[P256] or xref:api:utils/cryptography#RSA[RSA]).
function _rawSignatureValidation(bytes32 hash, bytes calldata signature)
internal
view
virtual
override
returns (bool);
Structs
SignerECDSAStorage
Note: storage-location: erc7201:openzeppelin.storage.SignerECDSA
struct SignerECDSAStorage {
address _signer;
}
SignerERC7913Upgradeable
Inherits: Initializable, AbstractSigner
*Implementation of {AbstractSigner} using
https://eips.ethereum.org/EIPS/eip-7913[ERC-7913] signature verification.
For {Account} usage, a {_setSigner} function is provided to set the ERC-7913 formatted {signer}.
Doing so is easier for a factory, who is likely to use initializable clones of this contract.
The signer is a bytes object that concatenates a verifier address and a key: verifier || key.
Example of usage:
contract MyAccountERC7913 is Account, SignerERC7913, Initializable {
function initialize(bytes memory signer_) public initializer {
_setSigner(signer_);
}
function setSigner(bytes memory signer_) public onlyEntryPointOrSelf {
_setSigner(signer_);
}
}
IMPORTANT: Failing to call {_setSigner} either during construction (if used standalone) or during initialization (if used as a clone) may leave the signer either front-runnable or unusable.*
State Variables
SignerERC7913StorageLocation
bytes32 private constant SignerERC7913StorageLocation =
0x170786af7cf7b78916dca5a937f25e3b9b70ae3faee6f0db68cda91b7e818e00;
Functions
_getSignerERC7913Storage
function _getSignerERC7913Storage() private pure returns (SignerERC7913Storage storage $);
__SignerERC7913_init
function __SignerERC7913_init(bytes memory signer_) internal onlyInitializing;
__SignerERC7913_init_unchained
function __SignerERC7913_init_unchained(bytes memory signer_) internal onlyInitializing;
signer
Return the ERC-7913 signer (i.e. verifier || key).
function signer() public view virtual returns (bytes memory);
_setSigner
Sets the signer (i.e. verifier || key) with an ERC-7913 formatted signer.
function _setSigner(bytes memory signer_) internal;
_rawSignatureValidation
Verifies a signature using SignatureChecker-isValidSignatureNow-bytes-bytes32-bytes-
with {signer}, hash and signature.
function _rawSignatureValidation(bytes32 hash, bytes calldata signature)
internal
view
virtual
override
returns (bool);
Structs
SignerERC7913Storage
Note: storage-location: erc7201:openzeppelin.storage.SignerERC7913
struct SignerERC7913Storage {
bytes _signer;
}
SignerP256Upgradeable
Inherits: Initializable, AbstractSigner
*Implementation of {AbstractSigner} using xref:api:utils/cryptography#P256[P256] signatures. For {Account} usage, a {_setSigner} function is provided to set the {signer} public key. Doing so is easier for a factory, who is likely to use initializable clones of this contract. Example of usage:
contract MyAccountP256 is Account, SignerP256, Initializable {
function initialize(bytes32 qx, bytes32 qy) public initializer {
_setSigner(qx, qy);
}
}
IMPORTANT: Failing to call {_setSigner} either during construction (if used standalone) or during initialization (if used as a clone) may leave the signer either front-runnable or unusable.*
State Variables
SignerP256StorageLocation
bytes32 private constant SignerP256StorageLocation = 0x6c6e681eb9c9937bb0e9a845af882a34f03801b1b670c4e5431f8b41c16a2700;
Functions
_getSignerP256Storage
function _getSignerP256Storage() private pure returns (SignerP256Storage storage $);
__SignerP256_init
function __SignerP256_init(bytes32 qx, bytes32 qy) internal onlyInitializing;
__SignerP256_init_unchained
function __SignerP256_init_unchained(bytes32 qx, bytes32 qy) internal onlyInitializing;
_setSigner
Sets the signer with a P256 public key. This function should be called during construction or through an initializer.
function _setSigner(bytes32 qx, bytes32 qy) internal;
signer
Return the signer's P256 public key.
function signer() public view virtual returns (bytes32 qx, bytes32 qy);
_rawSignatureValidation
Signature validation algorithm. WARNING: Implementing a signature validation algorithm is a security-sensitive operation as it involves cryptographic verification. It is important to review and test thoroughly before deployment. Consider using one of the signature verification libraries (xref:api:utils/cryptography#ECDSA[ECDSA], xref:api:utils/cryptography#P256[P256] or xref:api:utils/cryptography#RSA[RSA]).
function _rawSignatureValidation(bytes32 hash, bytes calldata signature)
internal
view
virtual
override
returns (bool);
Errors
SignerP256InvalidPublicKey
error SignerP256InvalidPublicKey(bytes32 qx, bytes32 qy);
Structs
SignerP256Storage
Note: storage-location: erc7201:openzeppelin.storage.SignerP256
struct SignerP256Storage {
bytes32 _qx;
bytes32 _qy;
}
SignerRSAUpgradeable
Inherits: Initializable, AbstractSigner
*Implementation of {AbstractSigner} using xref:api:utils/cryptography#RSA[RSA] signatures. For {Account} usage, a {_setSigner} function is provided to set the {signer} public key. Doing so is easier for a factory, who is likely to use initializable clones of this contract. Example of usage:
contract MyAccountRSA is Account, SignerRSA, Initializable {
function initialize(bytes memory e, bytes memory n) public initializer {
_setSigner(e, n);
}
}
IMPORTANT: Failing to call {_setSigner} either during construction (if used standalone) or during initialization (if used as a clone) may leave the signer either front-runnable or unusable.*
State Variables
SignerRSAStorageLocation
bytes32 private constant SignerRSAStorageLocation = 0x8bf15870295cd9a811d81afc339672ef68c88b80db19b9fcfad708cc10d31600;
Functions
_getSignerRSAStorage
function _getSignerRSAStorage() private pure returns (SignerRSAStorage storage $);
__SignerRSA_init
function __SignerRSA_init(bytes memory e, bytes memory n) internal onlyInitializing;
__SignerRSA_init_unchained
function __SignerRSA_init_unchained(bytes memory e, bytes memory n) internal onlyInitializing;
_setSigner
Sets the signer with a RSA public key. This function should be called during construction or through an initializer.
function _setSigner(bytes memory e, bytes memory n) internal;
signer
Return the signer's RSA public key.
function signer() public view virtual returns (bytes memory e, bytes memory n);
_rawSignatureValidation
See AbstractSigner-_rawSignatureValidation. Verifies a PKCSv1.5 signature by calling
xref:api:utils/cryptography.adoc#RSA-pkcs1Sha256-bytes-bytes-bytes-bytes-[RSA.pkcs1Sha256].
IMPORTANT: Following the RSASSA-PKCS1-V1_5-VERIFY procedure outlined in RFC8017 (section 8.2.2), the
provided hash is used as the M (message) and rehashed using SHA256 according to EMSA-PKCS1-v1_5
encoding as per section 9.2 (step 1) of the RFC.
function _rawSignatureValidation(bytes32 hash, bytes calldata signature)
internal
view
virtual
override
returns (bool);
Structs
SignerRSAStorage
Note: storage-location: erc7201:openzeppelin.storage.SignerRSA
struct SignerRSAStorage {
bytes _e;
bytes _n;
}
ERC7739Upgradeable
Inherits: Initializable, AbstractSigner, EIP712Upgradeable, IERC1271
Validates signatures wrapping the message hash in a nested EIP712 type. See {ERC7739Utils}. Linking the signature to the EIP-712 domain separator is a security measure to prevent signature replay across different EIP-712 domains (e.g. a single offchain owner of multiple contracts). This contract requires implementing the {_rawSignatureValidation} function, which passes the wrapped message hash, which may be either an typed data or a personal sign nested type. NOTE: xref:api:utils/cryptography#EIP712[EIP-712] uses xref:api:utils/cryptography#ShortStrings[ShortStrings] to optimize gas costs for short strings (up to 31 characters). Consider that strings longer than that will use storage, which may limit the ability of the signer to be used within the ERC-4337 validation phase (due to https://eips.ethereum.org/EIPS/eip-7562#storage-rules[ERC-7562 storage access rules]).
Functions
__ERC7739_init
function __ERC7739_init() internal onlyInitializing;
__ERC7739_init_unchained
function __ERC7739_init_unchained() internal onlyInitializing;
isValidSignature
*Attempts validating the signature in a nested EIP-712 type. A nested EIP-712 type might be presented in 2 different ways:
- As a nested EIP-712 typed data
- As a personal signature (an EIP-712 mimic of the
eth_personalSignfor a smart contract)*
function isValidSignature(bytes32 hash, bytes calldata signature) public view virtual returns (bytes4 result);
_isValidNestedPersonalSignSignature
Nested personal signature verification.
function _isValidNestedPersonalSignSignature(bytes32 hash, bytes calldata signature) private view returns (bool);
_isValidNestedTypedDataSignature
Nested EIP-712 typed data verification.
function _isValidNestedTypedDataSignature(bytes32 hash, bytes calldata encodedSignature) private view returns (bool);
EIP712Upgradeable
Inherits: Initializable, IERC5267
https://eips.ethereum.org/EIPS/eip-712[EIP-712] is a standard for hashing and signing of typed structured data.
The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose
encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract
does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to
produce the hash of their typed data using a combination of abi.encode and keccak256.
This contract implements the EIP-712 domain separator (_domainSeparatorV4) that is used as part of the encoding
scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
({_hashTypedDataV4}).
The implementation of the domain separator was designed to be as efficient as possible while still properly updating
the chain id to protect against replay attacks on an eventual fork of the chain.
NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
https://docs.metamask.io/guide/signing-data.html[eth_signTypedDataV4 in MetaMask].
NOTE: The upgradeable version of this contract does not use an immutable cache and recomputes the domain separator
each time {_domainSeparatorV4} is called. That is cheaper than accessing a cached version in cold storage.
State Variables
TYPE_HASH
bytes32 private constant TYPE_HASH =
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
EIP712StorageLocation
bytes32 private constant EIP712StorageLocation = 0xa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100;
Functions
_getEIP712Storage
function _getEIP712Storage() private pure returns (EIP712Storage storage $);
__EIP712_init
*Initializes the domain separator and parameter caches.
The meaning of name and version is specified in
https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP-712]:
name: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.version: the current major version of the signing domain. NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart contract upgrade].*
function __EIP712_init(string memory name, string memory version) internal onlyInitializing;
__EIP712_init_unchained
function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing;
_domainSeparatorV4
Returns the domain separator for the current chain.
function _domainSeparatorV4() internal view returns (bytes32);
_buildDomainSeparator
function _buildDomainSeparator() private view returns (bytes32);
_hashTypedDataV4
*Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this function returns the hash of the fully encoded EIP712 message for this domain. This hash can be used together with ECDSA-recover to obtain the signer of a message. For example:
bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
keccak256("Mail(address to,string contents)"),
mailTo,
keccak256(bytes(mailContents))
)));
address signer = ECDSA.recover(digest, signature);
```*
```solidity
function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32);
eip712Domain
returns the fields and values that describe the domain separator used by this contract for EIP-712 signature.
function eip712Domain()
public
view
virtual
returns (
bytes1 fields,
string memory name,
string memory version,
uint256 chainId,
address verifyingContract,
bytes32 salt,
uint256[] memory extensions
);
_EIP712Name
The name parameter for the EIP712 domain. NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs are a concern.
function _EIP712Name() internal view virtual returns (string memory);
_EIP712Version
The version parameter for the EIP712 domain. NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs are a concern.
function _EIP712Version() internal view virtual returns (string memory);
_EIP712NameHash
The hash of the name parameter for the EIP712 domain.
NOTE: In previous versions this function was virtual. In this version you should override _EIP712Name instead.
function _EIP712NameHash() internal view returns (bytes32);
_EIP712VersionHash
The hash of the version parameter for the EIP712 domain.
NOTE: In previous versions this function was virtual. In this version you should override _EIP712Version instead.
function _EIP712VersionHash() internal view returns (bytes32);
Structs
EIP712Storage
Note: storage-location: erc7201:openzeppelin.storage.EIP712
struct EIP712Storage {
bytes32 _hashedName;
bytes32 _hashedVersion;
string _name;
string _version;
}
Contents
ERC165Upgradeable
Inherits: Initializable, IERC165
*Implementation of the {IERC165} interface. Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check for the additional interface id that will be supported. For example:
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
}
```*
## Functions
### __ERC165_init
```solidity
function __ERC165_init() internal onlyInitializing;
__ERC165_init_unchained
function __ERC165_init_unchained() internal onlyInitializing;
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
ContextUpgradeable
Inherits: Initializable
Provides information about the current execution context, including the sender of the transaction and its data. While these are generally available via msg.sender and msg.data, they should not be accessed in such a direct manner, since when dealing with meta-transactions the account sending and paying for execution may not be the actual sender (as far as an application is concerned). This contract is only required for intermediate, library-like contracts.
Functions
__Context_init
function __Context_init() internal onlyInitializing;
__Context_init_unchained
function __Context_init_unchained() internal onlyInitializing;
_msgSender
function _msgSender() internal view virtual returns (address);
_msgData
function _msgData() internal view virtual returns (bytes calldata);
_contextSuffixLength
function _contextSuffixLength() internal view virtual returns (uint256);
MulticallUpgradeable
Inherits: Initializable, ContextUpgradeable
Provides a function to batch together multiple calls in a single external call.
Consider any assumption about calldata validation performed by the sender may be violated if it's not especially
careful about sending transactions invoking multicall. For example, a relay address that filters function
selectors won't filter calls nested within a {multicall} operation.
NOTE: Since 5.0.1 and 4.9.4, this contract identifies non-canonical contexts (i.e. msg.sender is not {Context-_msgSender}).
If a non-canonical context is identified, the following self delegatecall appends the last bytes of msg.data
to the subcall. This makes it safe to use with {ERC2771Context}. Contexts that don't affect the resolution of
{Context-_msgSender} are not propagated to subcalls.
Functions
__Multicall_init
function __Multicall_init() internal onlyInitializing;
__Multicall_init_unchained
function __Multicall_init_unchained() internal onlyInitializing;
multicall
Receives and executes a batch of function calls on this contract.
Note: oz-upgrades-unsafe-allow-reachable: delegatecall
function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results);
NoncesKeyedUpgradeable
Inherits: Initializable, NoncesUpgradeable
Alternative to {Nonces}, that supports key-ed nonces.
Follows the https://eips.ethereum.org/EIPS/eip-4337#semi-abstracted-nonce-support[ERC-4337's semi-abstracted nonce system].
NOTE: This contract inherits from {Nonces} and reuses its storage for the first nonce key (i.e. 0). This
makes upgrading from {Nonces} to {NoncesKeyed} safe when using their upgradeable versions (e.g. NoncesKeyedUpgradeable).
Doing so will NOT reset the current state of nonces, avoiding replay attacks where a nonce is reused after the upgrade.
State Variables
NoncesKeyedStorageLocation
bytes32 private constant NoncesKeyedStorageLocation = 0x06e302b11020b9cca26edb75da0d4c952e2c49f7ac00d8954230e81bd5769c00;
Functions
_getNoncesKeyedStorage
function _getNoncesKeyedStorage() private pure returns (NoncesKeyedStorage storage $);
__NoncesKeyed_init
function __NoncesKeyed_init() internal onlyInitializing;
__NoncesKeyed_init_unchained
function __NoncesKeyed_init_unchained() internal onlyInitializing;
nonces
Returns the next unused nonce for an address and key. Result contains the key prefix.
function nonces(address owner, uint192 key) public view virtual returns (uint256);
_useNonce
Consumes the next unused nonce for an address and key. Returns the current value without the key prefix. Consumed nonce is increased, so calling this function twice with the same arguments will return different (sequential) results.
function _useNonce(address owner, uint192 key) internal virtual returns (uint256);
_useCheckedNonce
*Same as _useNonce but checking that nonce is the next valid for owner.
This version takes the key and the nonce in a single uint256 parameter:
- use the first 24 bytes for the key
- use the last 8 bytes for the nonce*
function _useCheckedNonce(address owner, uint256 keyNonce) internal virtual override;
_useCheckedNonce
Same as _useNonce but checking that nonce is the next valid for owner.
This version takes the key and the nonce as two different parameters.
function _useCheckedNonce(address owner, uint192 key, uint64 nonce) internal virtual;
_pack
Pack key and nonce into a keyNonce
function _pack(uint192 key, uint64 nonce) private pure returns (uint256);
_unpack
Unpack a keyNonce into its key and nonce components
function _unpack(uint256 keyNonce) private pure returns (uint192 key, uint64 nonce);
Structs
NoncesKeyedStorage
Note: storage-location: erc7201:openzeppelin.storage.NoncesKeyed
struct NoncesKeyedStorage {
mapping(address owner => mapping(uint192 key => uint64)) _nonces;
}
NoncesUpgradeable
Inherits: Initializable
Provides tracking nonces for addresses. Nonces will only increment.
State Variables
NoncesStorageLocation
bytes32 private constant NoncesStorageLocation = 0x5ab42ced628888259c08ac98db1eb0cf702fc1501344311d8b100cd1bfe4bb00;
Functions
_getNoncesStorage
function _getNoncesStorage() private pure returns (NoncesStorage storage $);
__Nonces_init
function __Nonces_init() internal onlyInitializing;
__Nonces_init_unchained
function __Nonces_init_unchained() internal onlyInitializing;
nonces
Returns the next unused nonce for an address.
function nonces(address owner) public view virtual returns (uint256);
_useNonce
Consumes a nonce. Returns the current value and increments nonce.
function _useNonce(address owner) internal virtual returns (uint256);
_useCheckedNonce
Same as _useNonce but checking that nonce is the next valid for owner.
function _useCheckedNonce(address owner, uint256 nonce) internal virtual;
Errors
InvalidAccountNonce
The nonce used for an account is not the expected current nonce.
error InvalidAccountNonce(address account, uint256 currentNonce);
Structs
NoncesStorage
Note: storage-location: erc7201:openzeppelin.storage.Nonces
struct NoncesStorage {
mapping(address account => uint256) _nonces;
}
PausableUpgradeable
Inherits: Initializable, ContextUpgradeable
Contract module which allows children to implement an emergency stop
mechanism that can be triggered by an authorized account.
This module is used through inheritance. It will make available the
modifiers whenNotPaused and whenPaused, which can be applied to
the functions of your contract. Note that they will not be pausable by
simply including this module, only once the modifiers are put in place.
State Variables
PausableStorageLocation
bytes32 private constant PausableStorageLocation = 0xcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300;
Functions
_getPausableStorage
function _getPausableStorage() private pure returns (PausableStorage storage $);
whenNotPaused
*Modifier to make a function callable only when the contract is not paused. Requirements:
- The contract must not be paused.*
modifier whenNotPaused();
whenPaused
*Modifier to make a function callable only when the contract is paused. Requirements:
- The contract must be paused.*
modifier whenPaused();
__Pausable_init
function __Pausable_init() internal onlyInitializing;
__Pausable_init_unchained
function __Pausable_init_unchained() internal onlyInitializing;
paused
Returns true if the contract is paused, and false otherwise.
function paused() public view virtual returns (bool);
_requireNotPaused
Throws if the contract is paused.
function _requireNotPaused() internal view virtual;
_requirePaused
Throws if the contract is not paused.
function _requirePaused() internal view virtual;
_pause
*Triggers stopped state. Requirements:
- The contract must not be paused.*
function _pause() internal virtual whenNotPaused;
_unpause
*Returns to normal state. Requirements:
- The contract must be paused.*
function _unpause() internal virtual whenPaused;
Events
Paused
Emitted when the pause is triggered by account.
event Paused(address account);
Unpaused
Emitted when the pause is lifted by account.
event Unpaused(address account);
Errors
EnforcedPause
The operation failed because the contract is paused.
error EnforcedPause();
ExpectedPause
The operation failed because the contract is not paused.
error ExpectedPause();
Structs
PausableStorage
Note: storage-location: erc7201:openzeppelin.storage.Pausable
struct PausableStorage {
bool _paused;
}
ReentrancyGuardTransientUpgradeable
Inherits: Initializable
Variant of {ReentrancyGuard} that uses transient storage. NOTE: This variant only works on networks where EIP-1153 is available. Available since v5.1.
State Variables
REENTRANCY_GUARD_STORAGE
bytes32 private constant REENTRANCY_GUARD_STORAGE = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;
Functions
nonReentrant
Prevents a contract from calling itself, directly or indirectly.
Calling a nonReentrant function from another nonReentrant
function is not supported. It is possible to prevent this from happening
by making the nonReentrant function external, and making it call a
private function that does the actual work.
modifier nonReentrant();
__ReentrancyGuardTransient_init
function __ReentrancyGuardTransient_init() internal onlyInitializing;
__ReentrancyGuardTransient_init_unchained
function __ReentrancyGuardTransient_init_unchained() internal onlyInitializing;
_nonReentrantBefore
function _nonReentrantBefore() private;
_nonReentrantAfter
function _nonReentrantAfter() private;
_reentrancyGuardEntered
Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
nonReentrant function in the call stack.
function _reentrancyGuardEntered() internal view returns (bool);
Errors
ReentrancyGuardReentrantCall
Unauthorized reentrant call.
error ReentrancyGuardReentrantCall();
ReentrancyGuardUpgradeable
Inherits: Initializable
Contract module that helps prevent reentrant calls to a function.
Inheriting from ReentrancyGuard will make the nonReentrant modifier
available, which can be applied to functions to make sure there are no nested
(reentrant) calls to them.
Note that because there is a single nonReentrant guard, functions marked as
nonReentrant may not call one another. This can be worked around by making
those functions private, and then adding external nonReentrant entry
points to them.
TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
consider using {ReentrancyGuardTransient} instead.
TIP: If you would like to learn more about reentrancy and alternative ways
to protect against it, check out our blog post
https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
State Variables
NOT_ENTERED
uint256 private constant NOT_ENTERED = 1;
ENTERED
uint256 private constant ENTERED = 2;
ReentrancyGuardStorageLocation
bytes32 private constant ReentrancyGuardStorageLocation =
0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;
Functions
_getReentrancyGuardStorage
function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $);
__ReentrancyGuard_init
function __ReentrancyGuard_init() internal onlyInitializing;
__ReentrancyGuard_init_unchained
function __ReentrancyGuard_init_unchained() internal onlyInitializing;
nonReentrant
Prevents a contract from calling itself, directly or indirectly.
Calling a nonReentrant function from another nonReentrant
function is not supported. It is possible to prevent this from happening
by making the nonReentrant function external, and making it call a
private function that does the actual work.
modifier nonReentrant();
_nonReentrantBefore
function _nonReentrantBefore() private;
_nonReentrantAfter
function _nonReentrantAfter() private;
_reentrancyGuardEntered
Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
nonReentrant function in the call stack.
function _reentrancyGuardEntered() internal view returns (bool);
Errors
ReentrancyGuardReentrantCall
Unauthorized reentrant call.
error ReentrancyGuardReentrantCall();
Structs
ReentrancyGuardStorage
Note: storage-location: erc7201:openzeppelin.storage.ReentrancyGuard
struct ReentrancyGuardStorage {
uint256 _status;
}
Contents
Contents
IERC20
Functions
totalSupply
function totalSupply() external view returns (uint256);
balanceOf
function balanceOf(address account) external view returns (uint256);
transfer
function transfer(address to, uint256 amount) external returns (bool);
allowance
function allowance(address owner, address spender) external view returns (uint256);
approve
function approve(address spender, uint256 amount) external returns (bool);
transferFrom
function transferFrom(address from, address to, uint256 amount) external returns (bool);
Events
Transfer
event Transfer(address indexed from, address indexed to, uint256 value);
Approval
event Approval(address indexed owner, address indexed spender, uint256 value);
IERC4626
Inherits: IERC20
Functions
asset
function asset() external view returns (address assetTokenAddress);
totalAssets
function totalAssets() external view returns (uint256 totalManagedAssets);
convertToShares
function convertToShares(uint256 assets) external view returns (uint256 shares);
convertToAssets
function convertToAssets(uint256 shares) external view returns (uint256 assets);
maxDeposit
function maxDeposit(address receiver) external view returns (uint256 maxAssets);
previewDeposit
function previewDeposit(uint256 assets) external view returns (uint256 shares);
deposit
function deposit(uint256 assets, address receiver) external returns (uint256 shares);
maxMint
function maxMint(address receiver) external view returns (uint256 maxShares);
previewMint
function previewMint(uint256 shares) external view returns (uint256 assets);
mint
function mint(uint256 shares, address receiver) external returns (uint256 assets);
maxWithdraw
function maxWithdraw(address owner) external view returns (uint256 maxAssets);
previewWithdraw
function previewWithdraw(uint256 assets) external view returns (uint256 shares);
withdraw
function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);
maxRedeem
function maxRedeem(address owner) external view returns (uint256 maxShares);
previewRedeem
function previewRedeem(uint256 shares) external view returns (uint256 assets);
redeem
function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);
Events
Deposit
event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares);
Withdraw
event Withdraw(address indexed caller, address indexed receiver, address indexed owner, uint256 assets, uint256 shares);
ERC4626Prop
Inherits: Test
State Variables
delta
uint256 internal _delta_;
underlying
address internal _underlying_;
vault
address internal _vault_;
_vaultMayBeEmpty
bool internal _vaultMayBeEmpty;
_unlimitedAmount
bool internal _unlimitedAmount;
Functions
prop_asset
function prop_asset(address caller) public;
prop_totalAssets
function prop_totalAssets(address caller) public;
prop_convertToShares
function prop_convertToShares(address caller1, address caller2, uint256 assets) public;
prop_convertToAssets
function prop_convertToAssets(address caller1, address caller2, uint256 shares) public;
prop_maxDeposit
function prop_maxDeposit(address caller, address receiver) public;
prop_previewDeposit
function prop_previewDeposit(address caller, address receiver, address other, uint256 assets) public;
prop_deposit
function prop_deposit(address caller, address receiver, uint256 assets) public;
prop_maxMint
function prop_maxMint(address caller, address receiver) public;
prop_previewMint
function prop_previewMint(address caller, address receiver, address other, uint256 shares) public;
prop_mint
function prop_mint(address caller, address receiver, uint256 shares) public;
prop_maxWithdraw
function prop_maxWithdraw(address caller, address owner) public;
prop_previewWithdraw
function prop_previewWithdraw(address caller, address receiver, address owner, address other, uint256 assets) public;
prop_withdraw
function prop_withdraw(address caller, address receiver, address owner, uint256 assets) public;
prop_maxRedeem
function prop_maxRedeem(address caller, address owner) public;
prop_previewRedeem
function prop_previewRedeem(address caller, address receiver, address owner, address other, uint256 shares) public;
prop_redeem
function prop_redeem(address caller, address receiver, address owner, uint256 shares) public;
prop_RT_deposit_redeem
function prop_RT_deposit_redeem(address caller, uint256 assets) public;
prop_RT_deposit_withdraw
function prop_RT_deposit_withdraw(address caller, uint256 assets) public;
prop_RT_redeem_deposit
function prop_RT_redeem_deposit(address caller, uint256 shares) public;
prop_RT_redeem_mint
function prop_RT_redeem_mint(address caller, uint256 shares) public;
prop_RT_mint_withdraw
function prop_RT_mint_withdraw(address caller, uint256 shares) public;
prop_RT_mint_redeem
function prop_RT_mint_redeem(address caller, uint256 shares) public;
prop_RT_withdraw_mint
function prop_RT_withdraw_mint(address caller, uint256 assets) public;
prop_RT_withdraw_deposit
function prop_RT_withdraw_deposit(address caller, uint256 assets) public;
vault_convertToShares
function vault_convertToShares(uint256 assets) internal returns (uint256);
vault_convertToAssets
function vault_convertToAssets(uint256 shares) internal returns (uint256);
vault_maxDeposit
function vault_maxDeposit(address receiver) internal returns (uint256);
vault_maxMint
function vault_maxMint(address receiver) internal returns (uint256);
vault_maxWithdraw
function vault_maxWithdraw(address owner) internal returns (uint256);
vault_maxRedeem
function vault_maxRedeem(address owner) internal returns (uint256);
vault_previewDeposit
function vault_previewDeposit(uint256 assets) internal returns (uint256);
vault_previewMint
function vault_previewMint(uint256 shares) internal returns (uint256);
vault_previewWithdraw
function vault_previewWithdraw(uint256 assets) internal returns (uint256);
vault_previewRedeem
function vault_previewRedeem(uint256 shares) internal returns (uint256);
vault_deposit
function vault_deposit(uint256 assets, address receiver) internal returns (uint256);
vault_mint
function vault_mint(uint256 shares, address receiver) internal returns (uint256);
vault_withdraw
function vault_withdraw(uint256 assets, address receiver, address owner) internal returns (uint256);
vault_redeem
function vault_redeem(uint256 shares, address receiver, address owner) internal returns (uint256);
_call_vault
function _call_vault(bytes memory data) internal returns (uint256);
assertApproxGeAbs
function assertApproxGeAbs(uint256 a, uint256 b, uint256 maxDelta) internal;
assertApproxLeAbs
function assertApproxLeAbs(uint256 a, uint256 b, uint256 maxDelta) internal;
IMockERC20
Inherits: IERC20
Functions
mint
function mint(address to, uint256 value) external;
burn
function burn(address from, uint256 value) external;
ERC4626Test
Inherits: ERC4626Prop
State Variables
N
uint256 constant N = 4;
Functions
setUp
function setUp() public virtual;
setUpVault
function setUpVault(Init memory init) public virtual;
setUpYield
function setUpYield(Init memory init) public virtual;
test_asset
function test_asset(Init memory init) public virtual;
test_totalAssets
function test_totalAssets(Init memory init) public virtual;
test_convertToShares
function test_convertToShares(Init memory init, uint256 assets) public virtual;
test_convertToAssets
function test_convertToAssets(Init memory init, uint256 shares) public virtual;
test_maxDeposit
function test_maxDeposit(Init memory init) public virtual;
test_previewDeposit
function test_previewDeposit(Init memory init, uint256 assets) public virtual;
test_deposit
function test_deposit(Init memory init, uint256 assets, uint256 allowance) public virtual;
test_maxMint
function test_maxMint(Init memory init) public virtual;
test_previewMint
function test_previewMint(Init memory init, uint256 shares) public virtual;
test_mint
function test_mint(Init memory init, uint256 shares, uint256 allowance) public virtual;
test_maxWithdraw
function test_maxWithdraw(Init memory init) public virtual;
test_previewWithdraw
function test_previewWithdraw(Init memory init, uint256 assets) public virtual;
test_withdraw
function test_withdraw(Init memory init, uint256 assets, uint256 allowance) public virtual;
test_withdraw_zero_allowance
function test_withdraw_zero_allowance(Init memory init, uint256 assets) public virtual;
test_maxRedeem
function test_maxRedeem(Init memory init) public virtual;
test_previewRedeem
function test_previewRedeem(Init memory init, uint256 shares) public virtual;
test_redeem
function test_redeem(Init memory init, uint256 shares, uint256 allowance) public virtual;
test_redeem_zero_allowance
function test_redeem_zero_allowance(Init memory init, uint256 shares) public virtual;
test_RT_deposit_redeem
function test_RT_deposit_redeem(Init memory init, uint256 assets) public virtual;
test_RT_deposit_withdraw
function test_RT_deposit_withdraw(Init memory init, uint256 assets) public virtual;
test_RT_redeem_deposit
function test_RT_redeem_deposit(Init memory init, uint256 shares) public virtual;
test_RT_redeem_mint
function test_RT_redeem_mint(Init memory init, uint256 shares) public virtual;
test_RT_mint_withdraw
function test_RT_mint_withdraw(Init memory init, uint256 shares) public virtual;
test_RT_mint_redeem
function test_RT_mint_redeem(Init memory init, uint256 shares) public virtual;
test_RT_withdraw_mint
function test_RT_withdraw_mint(Init memory init, uint256 assets) public virtual;
test_RT_withdraw_deposit
function test_RT_withdraw_deposit(Init memory init, uint256 assets) public virtual;
_isContract
function _isContract(address account) internal view returns (bool);
_isEOA
function _isEOA(address account) internal view returns (bool);
_approve
function _approve(address token, address owner, address spender, uint256 amount) internal;
_safeApprove
function _safeApprove(address token, address spender, uint256 amount) internal;
_max_deposit
function _max_deposit(address from) internal virtual returns (uint256);
_max_mint
function _max_mint(address from) internal virtual returns (uint256);
_max_withdraw
function _max_withdraw(address from) internal virtual returns (uint256);
_max_redeem
function _max_redeem(address from) internal virtual returns (uint256);
Structs
Init
struct Init {
address[N] user;
uint256[N] share;
uint256[N] asset;
int256 yield;
}
Contents
Contents
- interfaces
- CommonBase
- TestBase
- ScriptBase
- Script
- StdAssertions
- StdChains
- StdCheatsSafe
- StdCheats
- stdError
- StdInvariant
- stdJson
- stdMath
- FindData
- StdStorage
- stdStorageSafe
- stdStorage
- StdStyle
- stdToml
- StdUtils
- Test
- VmSafe
- Vm
- console
- safeconsole
Contents
- IERC1155
- IERC165
- IERC20
- IERC4626
- IERC721
- IERC721TokenReceiver
- IERC721Metadata
- IERC721Enumerable
- IMulticall3
IERC1155
Inherits: IERC165
See https://eips.ethereum.org/EIPS/eip-1155 Note: The ERC-165 identifier for this interface is 0xd9b67a26.
Functions
safeTransferFrom
Transfers _value amount of an _id from the _from address to the _to address specified (with safety call).
*Caller must be approved to manage the tokens being transferred out of the _from account (see "Approval" section of the standard).
- MUST revert if
_tois the zero address. - MUST revert if balance of holder for token
_idis lower than the_valuesent. - MUST revert on any other error.
- MUST emit the
TransferSingleevent to reflect the balance change (see "Safe Transfer Rules" section of the standard). - After the above conditions are met, this function MUST check if
_tois a smart contract (e.g. code size > 0). If so, it MUST callonERC1155Receivedon_toand act appropriately (see "Safe Transfer Rules" section of the standard).*
function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _value, bytes calldata _data) external;
Parameters
| Name | Type | Description |
|---|---|---|
_from | address | Source address |
_to | address | Target address |
_id | uint256 | ID of the token type |
_value | uint256 | Transfer amount |
_data | bytes | Additional data with no specified format, MUST be sent unaltered in call to onERC1155Received on _to |
safeBatchTransferFrom
Transfers _values amount(s) of _ids from the _from address to the _to address specified (with safety call).
*Caller must be approved to manage the tokens being transferred out of the _from account (see "Approval" section of the standard).
- MUST revert if
_tois the zero address. - MUST revert if length of
_idsis not the same as length of_values. - MUST revert if any of the balance(s) of the holder(s) for token(s) in
_idsis lower than the respective amount(s) in_valuessent to the recipient. - MUST revert on any other error.
- MUST emit
TransferSingleorTransferBatchevent(s) such that all the balance changes are reflected (see "Safe Transfer Rules" section of the standard). - Balance changes and events MUST follow the ordering of the arrays (_ids[0]/_values[0] before _ids[1]/_values[1], etc).
- After the above conditions for the transfer(s) in the batch are met, this function MUST check if
_tois a smart contract (e.g. code size > 0). If so, it MUST call the relevantERC1155TokenReceiverhook(s) on_toand act appropriately (see "Safe Transfer Rules" section of the standard).*
function safeBatchTransferFrom(
address _from,
address _to,
uint256[] calldata _ids,
uint256[] calldata _values,
bytes calldata _data
) external;
Parameters
| Name | Type | Description |
|---|---|---|
_from | address | Source address |
_to | address | Target address |
_ids | uint256[] | IDs of each token type (order and length must match _values array) |
_values | uint256[] | Transfer amounts per token type (order and length must match _ids array) |
_data | bytes | Additional data with no specified format, MUST be sent unaltered in call to the ERC1155TokenReceiver hook(s) on _to |
balanceOf
Get the balance of an account's tokens.
function balanceOf(address _owner, uint256 _id) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_owner | address | The address of the token holder |
_id | uint256 | ID of the token |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The _owner's balance of the token type requested |
balanceOfBatch
Get the balance of multiple account/token pairs
function balanceOfBatch(address[] calldata _owners, uint256[] calldata _ids) external view returns (uint256[] memory);
Parameters
| Name | Type | Description |
|---|---|---|
_owners | address[] | The addresses of the token holders |
_ids | uint256[] | ID of the tokens |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256[] | The _owner's balance of the token types requested (i.e. balance for each (owner, id) pair) |
setApprovalForAll
Enable or disable approval for a third party ("operator") to manage all of the caller's tokens.
MUST emit the ApprovalForAll event on success.
function setApprovalForAll(address _operator, bool _approved) external;
Parameters
| Name | Type | Description |
|---|---|---|
_operator | address | Address to add to the set of authorized operators |
_approved | bool | True if the operator is approved, false to revoke approval |
isApprovedForAll
Queries the approval status of an operator for a given owner.
function isApprovedForAll(address _owner, address _operator) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
_owner | address | The owner of the tokens |
_operator | address | Address of authorized operator |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the operator is approved, false if not |
Events
TransferSingle
- Either
TransferSingleorTransferBatchMUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see "Safe Transfer Rules" section of the standard). - The
_operatorargument MUST be the address of an account/contract that is approved to make the transfer (SHOULD be msg.sender). - The
_fromargument MUST be the address of the holder whose balance is decreased. - The
_toargument MUST be the address of the recipient whose balance is increased. - The
_idargument MUST be the token type being transferred. - The
_valueargument MUST be the number of tokens the holder balance is decreased by and match what the recipient balance is increased by. - When minting/creating tokens, the
_fromargument MUST be set to0x0(i.e. zero address). - When burning/destroying tokens, the
_toargument MUST be set to0x0(i.e. zero address).*
event TransferSingle(
address indexed _operator, address indexed _from, address indexed _to, uint256 _id, uint256 _value
);
TransferBatch
- Either
TransferSingleorTransferBatchMUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see "Safe Transfer Rules" section of the standard). - The
_operatorargument MUST be the address of an account/contract that is approved to make the transfer (SHOULD be msg.sender). - The
_fromargument MUST be the address of the holder whose balance is decreased. - The
_toargument MUST be the address of the recipient whose balance is increased. - The
_idsargument MUST be the list of tokens being transferred. - The
_valuesargument MUST be the list of number of tokens (matching the list and order of tokens specified in _ids) the holder balance is decreased by and match what the recipient balance is increased by. - When minting/creating tokens, the
_fromargument MUST be set to0x0(i.e. zero address). - When burning/destroying tokens, the
_toargument MUST be set to0x0(i.e. zero address).*
event TransferBatch(
address indexed _operator, address indexed _from, address indexed _to, uint256[] _ids, uint256[] _values
);
ApprovalForAll
MUST emit when approval for a second party/operator address to manage all tokens for an owner address is enabled or disabled (absence of an event assumes disabled).
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
URI
MUST emit when the URI is updated for a token ID. URIs are defined in RFC 3986. The URI MUST point to a JSON file that conforms to the "ERC-1155 Metadata URI JSON Schema".
event URI(string _value, uint256 indexed _id);
IERC165
Functions
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceID) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceID | bytes4 | The interface identifier, as specified in ERC-165 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
IERC20
Interface of the ERC20 standard as defined in the EIP.
This includes the optional name, symbol, and decimals metadata.
Functions
totalSupply
Returns the amount of tokens in existence.
function totalSupply() external view returns (uint256);
balanceOf
Returns the amount of tokens owned by account.
function balanceOf(address account) external view returns (uint256);
transfer
Moves amount tokens from the caller's account to to.
function transfer(address to, uint256 amount) external returns (bool);
allowance
Returns the remaining number of tokens that spender is allowed
to spend on behalf of owner
function allowance(address owner, address spender) external view returns (uint256);
approve
Sets amount as the allowance of spender over the caller's tokens.
Be aware of front-running risks: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
function approve(address spender, uint256 amount) external returns (bool);
transferFrom
Moves amount tokens from from to to using the allowance mechanism.
amount is then deducted from the caller's allowance.
function transferFrom(address from, address to, uint256 amount) external returns (bool);
name
Returns the name of the token.
function name() external view returns (string memory);
symbol
Returns the symbol of the token.
function symbol() external view returns (string memory);
decimals
Returns the decimals places of the token.
function decimals() external view returns (uint8);
Events
Transfer
Emitted when value tokens are moved from one account (from) to another (to).
event Transfer(address indexed from, address indexed to, uint256 value);
Approval
Emitted when the allowance of a spender for an owner is set, where value
is the new allowance.
event Approval(address indexed owner, address indexed spender, uint256 value);
IERC4626
Inherits: IERC20
Interface of the ERC4626 "Tokenized Vault Standard", as defined in https://eips.ethereum.org/EIPS/eip-4626
Functions
asset
Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.
- MUST be an ERC-20 token contract.
- MUST NOT revert.*
function asset() external view returns (address assetTokenAddress);
totalAssets
Returns the total amount of the underlying asset that is “managed” by Vault.
- SHOULD include any compounding that occurs from yield.
- MUST be inclusive of any fees that are charged against assets in the Vault.
- MUST NOT revert.*
function totalAssets() external view returns (uint256 totalManagedAssets);
convertToShares
Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal scenario where all the conditions are met.
- MUST NOT be inclusive of any fees that are charged against assets in the Vault.
- MUST NOT show any variations depending on the caller.
- MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
- MUST NOT revert. NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and from.*
function convertToShares(uint256 assets) external view returns (uint256 shares);
convertToAssets
Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal scenario where all the conditions are met.
- MUST NOT be inclusive of any fees that are charged against assets in the Vault.
- MUST NOT show any variations depending on the caller.
- MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
- MUST NOT revert. NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and from.*
function convertToAssets(uint256 shares) external view returns (uint256 assets);
maxDeposit
Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver, through a deposit call.
- MUST return a limited value if receiver is subject to some deposit limit.
- MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.
- MUST NOT revert.*
function maxDeposit(address receiver) external view returns (uint256 maxAssets);
previewDeposit
Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given current on-chain conditions.
- MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called in the same transaction.
- MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the deposit would be accepted, regardless if the user has enough tokens approved, etc.
- MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
- MUST NOT revert. NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by depositing.*
function previewDeposit(uint256 assets) external view returns (uint256 shares);
deposit
Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.
- MUST emit the Deposit event.
- MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the deposit execution, and are accounted for during deposit.
- MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not approving enough underlying tokens to the Vault contract, etc). NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.*
function deposit(uint256 assets, address receiver) external returns (uint256 shares);
maxMint
Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.
- MUST return a limited value if receiver is subject to some mint limit.
- MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.
- MUST NOT revert.*
function maxMint(address receiver) external view returns (uint256 maxShares);
previewMint
Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given current on-chain conditions.
- MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the same transaction.
- MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint would be accepted, regardless if the user has enough tokens approved, etc.
- MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
- MUST NOT revert. NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by minting.*
function previewMint(uint256 shares) external view returns (uint256 assets);
mint
Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.
- MUST emit the Deposit event.
- MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint execution, and are accounted for during mint.
- MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not approving enough underlying tokens to the Vault contract, etc). NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.*
function mint(uint256 shares, address receiver) external returns (uint256 assets);
maxWithdraw
Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the Vault, through a withdrawal call.
- MUST return a limited value if owner is subject to some withdrawal limit or timelock.
- MUST NOT revert.*
function maxWithdraw(address owner) external view returns (uint256 maxAssets);
previewWithdraw
Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block, given current on-chain conditions.
- MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if called in the same transaction.
- MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though the withdrawal would be accepted, regardless if the user has enough shares, etc.
- MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
- MUST NOT revert. NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by depositing.*
function previewWithdraw(uint256 assets) external view returns (uint256 shares);
withdraw
Burns shares from owner and sends exactly assets of underlying tokens to receiver.
- MUST emit the Withdraw event.
- MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the withdraw execution, and are accounted for during withdrawal.
- MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner not having enough shares, etc). Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed. Those methods should be performed separately.*
function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);
maxRedeem
Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, through a redeem call.
- MUST return a limited value if owner is subject to some withdrawal limit or timelock.
- MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.
- MUST NOT revert.*
function maxRedeem(address owner) external view returns (uint256 maxShares);
previewRedeem
Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block, given current on-chain conditions.
- MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the same transaction.
- MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the redemption would be accepted, regardless if the user has enough shares, etc.
- MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
- MUST NOT revert. NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by redeeming.*
function previewRedeem(uint256 shares) external view returns (uint256 assets);
redeem
Burns exactly shares from owner and sends assets of underlying tokens to receiver.
- MUST emit the Withdraw event.
- MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the redeem execution, and are accounted for during redeem.
- MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner not having enough shares, etc). NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed. Those methods should be performed separately.*
function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);
Events
Deposit
event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);
Withdraw
event Withdraw(address indexed sender, address indexed receiver, address indexed owner, uint256 assets, uint256 shares);
IERC721
Inherits: IERC165
See https://eips.ethereum.org/EIPS/eip-721 Note: the ERC-165 identifier for this interface is 0x80ac58cd.
Functions
balanceOf
Count all NFTs assigned to an owner
NFTs assigned to the zero address are considered invalid, and this function throws for queries about the zero address.
function balanceOf(address _owner) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_owner | address | An address for whom to query the balance |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The number of NFTs owned by _owner, possibly zero |
ownerOf
Find the owner of an NFT
NFTs assigned to zero address are considered invalid, and queries about them do throw.
function ownerOf(uint256 _tokenId) external view returns (address);
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | The identifier for an NFT |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The address of the owner of the NFT |
safeTransferFrom
Transfers the ownership of an NFT from one address to another address
Throws unless msg.sender is the current owner, an authorized
operator, or the approved address for this NFT. Throws if _from is
not the current owner. Throws if _to is the zero address. Throws if
_tokenId is not a valid NFT. When transfer is complete, this function
checks if _to is a smart contract (code size > 0). If so, it calls
onERC721Received on _to and throws if the return value is not
bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")).
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes calldata data) external payable;
Parameters
| Name | Type | Description |
|---|---|---|
_from | address | The current owner of the NFT |
_to | address | The new owner |
_tokenId | uint256 | The NFT to transfer |
data | bytes | Additional data with no specified format, sent in call to _to |
safeTransferFrom
Transfers the ownership of an NFT from one address to another address
This works identically to the other function with an extra data parameter, except this function just sets data to "".
function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable;
Parameters
| Name | Type | Description |
|---|---|---|
_from | address | The current owner of the NFT |
_to | address | The new owner |
_tokenId | uint256 | The NFT to transfer |
transferFrom
Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE
TO CONFIRM THAT _to IS CAPABLE OF RECEIVING NFTS OR ELSE
THEY MAY BE PERMANENTLY LOST
Throws unless msg.sender is the current owner, an authorized
operator, or the approved address for this NFT. Throws if _from is
not the current owner. Throws if _to is the zero address. Throws if
_tokenId is not a valid NFT.
function transferFrom(address _from, address _to, uint256 _tokenId) external payable;
Parameters
| Name | Type | Description |
|---|---|---|
_from | address | The current owner of the NFT |
_to | address | The new owner |
_tokenId | uint256 | The NFT to transfer |
approve
Change or reaffirm the approved address for an NFT
The zero address indicates there is no approved address.
Throws unless msg.sender is the current NFT owner, or an authorized
operator of the current owner.
function approve(address _approved, uint256 _tokenId) external payable;
Parameters
| Name | Type | Description |
|---|---|---|
_approved | address | The new approved NFT controller |
_tokenId | uint256 | The NFT to approve |
setApprovalForAll
Enable or disable approval for a third party ("operator") to manage
all of msg.sender's assets
Emits the ApprovalForAll event. The contract MUST allow multiple operators per owner.
function setApprovalForAll(address _operator, bool _approved) external;
Parameters
| Name | Type | Description |
|---|---|---|
_operator | address | Address to add to the set of authorized operators |
_approved | bool | True if the operator is approved, false to revoke approval |
getApproved
Get the approved address for a single NFT
Throws if _tokenId is not a valid NFT.
function getApproved(uint256 _tokenId) external view returns (address);
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | The NFT to find the approved address for |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The approved address for this NFT, or the zero address if there is none |
isApprovedForAll
Query if an address is an authorized operator for another address
function isApprovedForAll(address _owner, address _operator) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
_owner | address | The address that owns the NFTs |
_operator | address | The address that acts on behalf of the owner |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if _operator is an approved operator for _owner, false otherwise |
Events
Transfer
This emits when ownership of any NFT changes by any mechanism.
This event emits when NFTs are created (from == 0) and destroyed
(to == 0). Exception: during contract creation, any number of NFTs
may be created and assigned without emitting Transfer. At the time of
any transfer, the approved address for that NFT (if any) is reset to none.
event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);
Approval
This emits when the approved address for an NFT is changed or reaffirmed. The zero address indicates there is no approved address. When a Transfer event emits, this also indicates that the approved address for that NFT (if any) is reset to none.
event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId);
ApprovalForAll
This emits when an operator is enabled or disabled for an owner. The operator can manage all NFTs of the owner.
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
IERC721TokenReceiver
Note: the ERC-165 identifier for this interface is 0x150b7a02.
Functions
onERC721Received
Handle the receipt of an NFT
The ERC721 smart contract calls this function on the recipient
after a transfer. This function MAY throw to revert and reject the
transfer. Return of other than the magic value MUST result in the
transaction being reverted.
Note: the contract address is always the message sender.
function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes calldata _data)
external
returns (bytes4);
Parameters
| Name | Type | Description |
|---|---|---|
_operator | address | The address which called safeTransferFrom function |
_from | address | The address which previously owned the token |
_tokenId | uint256 | The NFT identifier which is being transferred |
_data | bytes | Additional data with no specified format |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes4 | bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")) unless throwing |
IERC721Metadata
Inherits: IERC721
See https://eips.ethereum.org/EIPS/eip-721 Note: the ERC-165 identifier for this interface is 0x5b5e139f.
Functions
name
A descriptive name for a collection of NFTs in this contract
function name() external view returns (string memory _name);
symbol
An abbreviated name for NFTs in this contract
function symbol() external view returns (string memory _symbol);
tokenURI
A distinct Uniform Resource Identifier (URI) for a given asset.
Throws if _tokenId is not a valid NFT. URIs are defined in RFC
3986. The URI may point to a JSON file that conforms to the "ERC721
Metadata JSON Schema".
function tokenURI(uint256 _tokenId) external view returns (string memory);
IERC721Enumerable
Inherits: IERC721
See https://eips.ethereum.org/EIPS/eip-721 Note: the ERC-165 identifier for this interface is 0x780e9d63.
Functions
totalSupply
Count NFTs tracked by this contract
function totalSupply() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | A count of valid NFTs tracked by this contract, where each one of them has an assigned and queryable owner not equal to the zero address |
tokenByIndex
Enumerate valid NFTs
Throws if _index >= totalSupply().
function tokenByIndex(uint256 _index) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_index | uint256 | A counter less than totalSupply() |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The token identifier for the _indexth NFT, (sort order not specified) |
tokenOfOwnerByIndex
Enumerate NFTs assigned to an owner
Throws if _index >= balanceOf(_owner) or if
_owner is the zero address, representing invalid NFTs.
function tokenOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_owner | address | An address where we are interested in NFTs owned by them |
_index | uint256 | A counter less than balanceOf(_owner) |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The token identifier for the _indexth NFT assigned to _owner, (sort order not specified) |
IMulticall3
Functions
aggregate
function aggregate(Call[] calldata calls) external payable returns (uint256 blockNumber, bytes[] memory returnData);
aggregate3
function aggregate3(Call3[] calldata calls) external payable returns (Result[] memory returnData);
aggregate3Value
function aggregate3Value(Call3Value[] calldata calls) external payable returns (Result[] memory returnData);
blockAndAggregate
function blockAndAggregate(Call[] calldata calls)
external
payable
returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData);
getBasefee
function getBasefee() external view returns (uint256 basefee);
getBlockHash
function getBlockHash(uint256 blockNumber) external view returns (bytes32 blockHash);
getBlockNumber
function getBlockNumber() external view returns (uint256 blockNumber);
getChainId
function getChainId() external view returns (uint256 chainid);
getCurrentBlockCoinbase
function getCurrentBlockCoinbase() external view returns (address coinbase);
getCurrentBlockDifficulty
function getCurrentBlockDifficulty() external view returns (uint256 difficulty);
getCurrentBlockGasLimit
function getCurrentBlockGasLimit() external view returns (uint256 gaslimit);
getCurrentBlockTimestamp
function getCurrentBlockTimestamp() external view returns (uint256 timestamp);
getEthBalance
function getEthBalance(address addr) external view returns (uint256 balance);
getLastBlockHash
function getLastBlockHash() external view returns (bytes32 blockHash);
tryAggregate
function tryAggregate(bool requireSuccess, Call[] calldata calls)
external
payable
returns (Result[] memory returnData);
tryBlockAndAggregate
function tryBlockAndAggregate(bool requireSuccess, Call[] calldata calls)
external
payable
returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData);
Structs
Call
struct Call {
address target;
bytes callData;
}
Call3
struct Call3 {
address target;
bool allowFailure;
bytes callData;
}
Call3Value
struct Call3Value {
address target;
bool allowFailure;
uint256 value;
bytes callData;
}
Result
struct Result {
bool success;
bytes returnData;
}
CommonBase
State Variables
VM_ADDRESS
address internal constant VM_ADDRESS = address(uint160(uint256(keccak256("hevm cheat code"))));
CONSOLE
address internal constant CONSOLE = 0x000000000000000000636F6e736F6c652e6c6f67;
CREATE2_FACTORY
address internal constant CREATE2_FACTORY = 0x4e59b44847b379578588920cA78FbF26c0B4956C;
DEFAULT_SENDER
address internal constant DEFAULT_SENDER = address(uint160(uint256(keccak256("foundry default caller"))));
DEFAULT_TEST_CONTRACT
address internal constant DEFAULT_TEST_CONTRACT = 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f;
MULTICALL3_ADDRESS
address internal constant MULTICALL3_ADDRESS = 0xcA11bde05977b3631167028862bE2a173976CA11;
SECP256K1_ORDER
uint256 internal constant SECP256K1_ORDER =
115792089237316195423570985008687907852837564279074904382605163141518161494337;
UINT256_MAX
uint256 internal constant UINT256_MAX = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
vm
Vm internal constant vm = Vm(VM_ADDRESS);
stdstore
StdStorage internal stdstore;
TestBase
Inherits: CommonBase
ScriptBase
Inherits: CommonBase
State Variables
vmSafe
VmSafe internal constant vmSafe = VmSafe(VM_ADDRESS);
Script
Inherits: ScriptBase, StdChains, StdCheatsSafe, StdUtils
State Variables
IS_SCRIPT
bool public IS_SCRIPT = true;
StdAssertions
State Variables
vm
Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));
_failed
bool private _failed;
Functions
failed
function failed() public view returns (bool);
fail
function fail() internal virtual;
assertTrue
function assertTrue(bool data) internal pure virtual;
assertTrue
function assertTrue(bool data, string memory err) internal pure virtual;
assertFalse
function assertFalse(bool data) internal pure virtual;
assertFalse
function assertFalse(bool data, string memory err) internal pure virtual;
assertEq
function assertEq(bool left, bool right) internal pure virtual;
assertEq
function assertEq(bool left, bool right, string memory err) internal pure virtual;
assertEq
function assertEq(uint256 left, uint256 right) internal pure virtual;
assertEq
function assertEq(uint256 left, uint256 right, string memory err) internal pure virtual;
assertEqDecimal
function assertEqDecimal(uint256 left, uint256 right, uint256 decimals) internal pure virtual;
assertEqDecimal
function assertEqDecimal(uint256 left, uint256 right, uint256 decimals, string memory err) internal pure virtual;
assertEq
function assertEq(int256 left, int256 right) internal pure virtual;
assertEq
function assertEq(int256 left, int256 right, string memory err) internal pure virtual;
assertEqDecimal
function assertEqDecimal(int256 left, int256 right, uint256 decimals) internal pure virtual;
assertEqDecimal
function assertEqDecimal(int256 left, int256 right, uint256 decimals, string memory err) internal pure virtual;
assertEq
function assertEq(address left, address right) internal pure virtual;
assertEq
function assertEq(address left, address right, string memory err) internal pure virtual;
assertEq
function assertEq(bytes32 left, bytes32 right) internal pure virtual;
assertEq
function assertEq(bytes32 left, bytes32 right, string memory err) internal pure virtual;
assertEq32
function assertEq32(bytes32 left, bytes32 right) internal pure virtual;
assertEq32
function assertEq32(bytes32 left, bytes32 right, string memory err) internal pure virtual;
assertEq
function assertEq(string memory left, string memory right) internal pure virtual;
assertEq
function assertEq(string memory left, string memory right, string memory err) internal pure virtual;
assertEq
function assertEq(bytes memory left, bytes memory right) internal pure virtual;
assertEq
function assertEq(bytes memory left, bytes memory right, string memory err) internal pure virtual;
assertEq
function assertEq(bool[] memory left, bool[] memory right) internal pure virtual;
assertEq
function assertEq(bool[] memory left, bool[] memory right, string memory err) internal pure virtual;
assertEq
function assertEq(uint256[] memory left, uint256[] memory right) internal pure virtual;
assertEq
function assertEq(uint256[] memory left, uint256[] memory right, string memory err) internal pure virtual;
assertEq
function assertEq(int256[] memory left, int256[] memory right) internal pure virtual;
assertEq
function assertEq(int256[] memory left, int256[] memory right, string memory err) internal pure virtual;
assertEq
function assertEq(address[] memory left, address[] memory right) internal pure virtual;
assertEq
function assertEq(address[] memory left, address[] memory right, string memory err) internal pure virtual;
assertEq
function assertEq(bytes32[] memory left, bytes32[] memory right) internal pure virtual;
assertEq
function assertEq(bytes32[] memory left, bytes32[] memory right, string memory err) internal pure virtual;
assertEq
function assertEq(string[] memory left, string[] memory right) internal pure virtual;
assertEq
function assertEq(string[] memory left, string[] memory right, string memory err) internal pure virtual;
assertEq
function assertEq(bytes[] memory left, bytes[] memory right) internal pure virtual;
assertEq
function assertEq(bytes[] memory left, bytes[] memory right, string memory err) internal pure virtual;
assertEqUint
function assertEqUint(uint256 left, uint256 right) internal pure virtual;
assertNotEq
function assertNotEq(bool left, bool right) internal pure virtual;
assertNotEq
function assertNotEq(bool left, bool right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(uint256 left, uint256 right) internal pure virtual;
assertNotEq
function assertNotEq(uint256 left, uint256 right, string memory err) internal pure virtual;
assertNotEqDecimal
function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals) internal pure virtual;
assertNotEqDecimal
function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(int256 left, int256 right) internal pure virtual;
assertNotEq
function assertNotEq(int256 left, int256 right, string memory err) internal pure virtual;
assertNotEqDecimal
function assertNotEqDecimal(int256 left, int256 right, uint256 decimals) internal pure virtual;
assertNotEqDecimal
function assertNotEqDecimal(int256 left, int256 right, uint256 decimals, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(address left, address right) internal pure virtual;
assertNotEq
function assertNotEq(address left, address right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(bytes32 left, bytes32 right) internal pure virtual;
assertNotEq
function assertNotEq(bytes32 left, bytes32 right, string memory err) internal pure virtual;
assertNotEq32
function assertNotEq32(bytes32 left, bytes32 right) internal pure virtual;
assertNotEq32
function assertNotEq32(bytes32 left, bytes32 right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(string memory left, string memory right) internal pure virtual;
assertNotEq
function assertNotEq(string memory left, string memory right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(bytes memory left, bytes memory right) internal pure virtual;
assertNotEq
function assertNotEq(bytes memory left, bytes memory right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(bool[] memory left, bool[] memory right) internal pure virtual;
assertNotEq
function assertNotEq(bool[] memory left, bool[] memory right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(uint256[] memory left, uint256[] memory right) internal pure virtual;
assertNotEq
function assertNotEq(uint256[] memory left, uint256[] memory right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(int256[] memory left, int256[] memory right) internal pure virtual;
assertNotEq
function assertNotEq(int256[] memory left, int256[] memory right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(address[] memory left, address[] memory right) internal pure virtual;
assertNotEq
function assertNotEq(address[] memory left, address[] memory right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(bytes32[] memory left, bytes32[] memory right) internal pure virtual;
assertNotEq
function assertNotEq(bytes32[] memory left, bytes32[] memory right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(string[] memory left, string[] memory right) internal pure virtual;
assertNotEq
function assertNotEq(string[] memory left, string[] memory right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(bytes[] memory left, bytes[] memory right) internal pure virtual;
assertNotEq
function assertNotEq(bytes[] memory left, bytes[] memory right, string memory err) internal pure virtual;
assertLt
function assertLt(uint256 left, uint256 right) internal pure virtual;
assertLt
function assertLt(uint256 left, uint256 right, string memory err) internal pure virtual;
assertLtDecimal
function assertLtDecimal(uint256 left, uint256 right, uint256 decimals) internal pure virtual;
assertLtDecimal
function assertLtDecimal(uint256 left, uint256 right, uint256 decimals, string memory err) internal pure virtual;
assertLt
function assertLt(int256 left, int256 right) internal pure virtual;
assertLt
function assertLt(int256 left, int256 right, string memory err) internal pure virtual;
assertLtDecimal
function assertLtDecimal(int256 left, int256 right, uint256 decimals) internal pure virtual;
assertLtDecimal
function assertLtDecimal(int256 left, int256 right, uint256 decimals, string memory err) internal pure virtual;
assertGt
function assertGt(uint256 left, uint256 right) internal pure virtual;
assertGt
function assertGt(uint256 left, uint256 right, string memory err) internal pure virtual;
assertGtDecimal
function assertGtDecimal(uint256 left, uint256 right, uint256 decimals) internal pure virtual;
assertGtDecimal
function assertGtDecimal(uint256 left, uint256 right, uint256 decimals, string memory err) internal pure virtual;
assertGt
function assertGt(int256 left, int256 right) internal pure virtual;
assertGt
function assertGt(int256 left, int256 right, string memory err) internal pure virtual;
assertGtDecimal
function assertGtDecimal(int256 left, int256 right, uint256 decimals) internal pure virtual;
assertGtDecimal
function assertGtDecimal(int256 left, int256 right, uint256 decimals, string memory err) internal pure virtual;
assertLe
function assertLe(uint256 left, uint256 right) internal pure virtual;
assertLe
function assertLe(uint256 left, uint256 right, string memory err) internal pure virtual;
assertLeDecimal
function assertLeDecimal(uint256 left, uint256 right, uint256 decimals) internal pure virtual;
assertLeDecimal
function assertLeDecimal(uint256 left, uint256 right, uint256 decimals, string memory err) internal pure virtual;
assertLe
function assertLe(int256 left, int256 right) internal pure virtual;
assertLe
function assertLe(int256 left, int256 right, string memory err) internal pure virtual;
assertLeDecimal
function assertLeDecimal(int256 left, int256 right, uint256 decimals) internal pure virtual;
assertLeDecimal
function assertLeDecimal(int256 left, int256 right, uint256 decimals, string memory err) internal pure virtual;
assertGe
function assertGe(uint256 left, uint256 right) internal pure virtual;
assertGe
function assertGe(uint256 left, uint256 right, string memory err) internal pure virtual;
assertGeDecimal
function assertGeDecimal(uint256 left, uint256 right, uint256 decimals) internal pure virtual;
assertGeDecimal
function assertGeDecimal(uint256 left, uint256 right, uint256 decimals, string memory err) internal pure virtual;
assertGe
function assertGe(int256 left, int256 right) internal pure virtual;
assertGe
function assertGe(int256 left, int256 right, string memory err) internal pure virtual;
assertGeDecimal
function assertGeDecimal(int256 left, int256 right, uint256 decimals) internal pure virtual;
assertGeDecimal
function assertGeDecimal(int256 left, int256 right, uint256 decimals, string memory err) internal pure virtual;
assertApproxEqAbs
function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta) internal pure virtual;
assertApproxEqAbs
function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta, string memory err) internal pure virtual;
assertApproxEqAbsDecimal
function assertApproxEqAbsDecimal(uint256 left, uint256 right, uint256 maxDelta, uint256 decimals)
internal
pure
virtual;
assertApproxEqAbsDecimal
function assertApproxEqAbsDecimal(uint256 left, uint256 right, uint256 maxDelta, uint256 decimals, string memory err)
internal
pure
virtual;
assertApproxEqAbs
function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta) internal pure virtual;
assertApproxEqAbs
function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta, string memory err) internal pure virtual;
assertApproxEqAbsDecimal
function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals)
internal
pure
virtual;
assertApproxEqAbsDecimal
function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals, string memory err)
internal
pure
virtual;
assertApproxEqRel
function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta) internal pure virtual;
assertApproxEqRel
function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta, string memory err)
internal
pure
virtual;
assertApproxEqRelDecimal
function assertApproxEqRelDecimal(uint256 left, uint256 right, uint256 maxPercentDelta, uint256 decimals)
internal
pure
virtual;
assertApproxEqRelDecimal
function assertApproxEqRelDecimal(
uint256 left,
uint256 right,
uint256 maxPercentDelta,
uint256 decimals,
string memory err
) internal pure virtual;
assertApproxEqRel
function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta) internal pure virtual;
assertApproxEqRel
function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta, string memory err)
internal
pure
virtual;
assertApproxEqRelDecimal
function assertApproxEqRelDecimal(int256 left, int256 right, uint256 maxPercentDelta, uint256 decimals)
internal
pure
virtual;
assertApproxEqRelDecimal
function assertApproxEqRelDecimal(
int256 left,
int256 right,
uint256 maxPercentDelta,
uint256 decimals,
string memory err
) internal pure virtual;
checkEq0
function checkEq0(bytes memory left, bytes memory right) internal pure returns (bool);
assertEq0
function assertEq0(bytes memory left, bytes memory right) internal pure virtual;
assertEq0
function assertEq0(bytes memory left, bytes memory right, string memory err) internal pure virtual;
assertNotEq0
function assertNotEq0(bytes memory left, bytes memory right) internal pure virtual;
assertNotEq0
function assertNotEq0(bytes memory left, bytes memory right, string memory err) internal pure virtual;
assertEqCall
function assertEqCall(address target, bytes memory callDataA, bytes memory callDataB) internal virtual;
assertEqCall
function assertEqCall(address targetA, bytes memory callDataA, address targetB, bytes memory callDataB)
internal
virtual;
assertEqCall
function assertEqCall(address target, bytes memory callDataA, bytes memory callDataB, bool strictRevertData)
internal
virtual;
assertEqCall
function assertEqCall(
address targetA,
bytes memory callDataA,
address targetB,
bytes memory callDataB,
bool strictRevertData
) internal virtual;
Events
log
event log(string);
logs
event logs(bytes);
log_address
event log_address(address);
log_bytes32
event log_bytes32(bytes32);
log_int
event log_int(int256);
log_uint
event log_uint(uint256);
log_bytes
event log_bytes(bytes);
log_string
event log_string(string);
log_named_address
event log_named_address(string key, address val);
log_named_bytes32
event log_named_bytes32(string key, bytes32 val);
log_named_decimal_int
event log_named_decimal_int(string key, int256 val, uint256 decimals);
log_named_decimal_uint
event log_named_decimal_uint(string key, uint256 val, uint256 decimals);
log_named_int
event log_named_int(string key, int256 val);
log_named_uint
event log_named_uint(string key, uint256 val);
log_named_bytes
event log_named_bytes(string key, bytes val);
log_named_string
event log_named_string(string key, string val);
log_array
event log_array(uint256[] val);
log_array
event log_array(int256[] val);
log_array
event log_array(address[] val);
log_named_array
event log_named_array(string key, uint256[] val);
log_named_array
event log_named_array(string key, int256[] val);
log_named_array
event log_named_array(string key, address[] val);
StdChains
StdChains provides information about EVM compatible chains that can be used in scripts/tests.
For each chain, the chain's name, chain ID, and a default RPC URL are provided. Chains are
identified by their alias, which is the same as the alias in the [rpc_endpoints] section of
the foundry.toml file. For best UX, ensure the alias in the foundry.toml file match the
alias used in this contract, which can be found as the first argument to the
setChainWithDefaultRpcUrl call in the initializeStdChains function.
There are two main ways to use this contract:
- Set a chain with
setChain(string memory chainAlias, ChainData memory chain)orsetChain(string memory chainAlias, Chain memory chain) - Get a chain with
getChain(string memory chainAlias)orgetChain(uint256 chainId). The first time either of those are used, chains are initialized with the default set of RPC URLs. This is done ininitializeStdChains, which usessetChainWithDefaultRpcUrl. Defaults are recorded indefaultRpcUrls. ThesetChainfunction is straightforward, and it simply saves off the given chain data. ThegetChainmethods usegetChainWithUpdatedRpcUrlto return a chain. For example, let's say we want to retrieve the RPC URL formainnet:
- If you have specified data with
setChain, it will return that. - If you have configured a mainnet RPC URL in
foundry.toml, it will return the URL, provided it is valid (e.g. a URL is specified, or an environment variable is given and exists). - If neither of the above conditions is met, the default data is returned.
Summarizing the above, the prioritization hierarchy is
setChain->foundry.toml-> environment variable -> defaults.
State Variables
vm
VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));
stdChainsInitialized
bool private stdChainsInitialized;
chains
mapping(string => Chain) private chains;
defaultRpcUrls
mapping(string => string) private defaultRpcUrls;
idToAlias
mapping(uint256 => string) private idToAlias;
fallbackToDefaultRpcUrls
bool private fallbackToDefaultRpcUrls = true;
Functions
getChain
function getChain(string memory chainAlias) internal virtual returns (Chain memory chain);
getChain
function getChain(uint256 chainId) internal virtual returns (Chain memory chain);
setChain
function setChain(string memory chainAlias, ChainData memory chain) internal virtual;
setChain
function setChain(string memory chainAlias, Chain memory chain) internal virtual;
_toUpper
function _toUpper(string memory str) private pure returns (string memory);
getChainWithUpdatedRpcUrl
function getChainWithUpdatedRpcUrl(string memory chainAlias, Chain memory chain) private view returns (Chain memory);
setFallbackToDefaultRpcUrls
function setFallbackToDefaultRpcUrls(bool useDefault) internal;
initializeStdChains
function initializeStdChains() private;
setChainWithDefaultRpcUrl
function setChainWithDefaultRpcUrl(string memory chainAlias, ChainData memory chain) private;
Structs
ChainData
struct ChainData {
string name;
uint256 chainId;
string rpcUrl;
}
Chain
struct Chain {
string name;
uint256 chainId;
string chainAlias;
string rpcUrl;
}
StdCheatsSafe
State Variables
vm
Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));
UINT256_MAX
uint256 private constant UINT256_MAX = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
gasMeteringOff
bool private gasMeteringOff;
Functions
assumeNotBlacklisted
function assumeNotBlacklisted(address token, address addr) internal view virtual;
assumeNoBlacklisted
function assumeNoBlacklisted(address token, address addr) internal view virtual;
assumeAddressIsNot
function assumeAddressIsNot(address addr, AddressType addressType) internal virtual;
assumeAddressIsNot
function assumeAddressIsNot(address addr, AddressType addressType1, AddressType addressType2) internal virtual;
assumeAddressIsNot
function assumeAddressIsNot(address addr, AddressType addressType1, AddressType addressType2, AddressType addressType3)
internal
virtual;
assumeAddressIsNot
function assumeAddressIsNot(
address addr,
AddressType addressType1,
AddressType addressType2,
AddressType addressType3,
AddressType addressType4
) internal virtual;
_isPayable
function _isPayable(address addr) private returns (bool);
assumePayable
function assumePayable(address addr) internal virtual;
assumeNotPayable
function assumeNotPayable(address addr) internal virtual;
assumeNotZeroAddress
function assumeNotZeroAddress(address addr) internal pure virtual;
assumeNotPrecompile
function assumeNotPrecompile(address addr) internal pure virtual;
assumeNotPrecompile
function assumeNotPrecompile(address addr, uint256 chainId) internal pure virtual;
assumeNotForgeAddress
function assumeNotForgeAddress(address addr) internal pure virtual;
assumeUnusedAddress
function assumeUnusedAddress(address addr) internal view virtual;
readEIP1559ScriptArtifact
function readEIP1559ScriptArtifact(string memory path) internal view virtual returns (EIP1559ScriptArtifact memory);
rawToConvertedEIPTx1559s
function rawToConvertedEIPTx1559s(RawTx1559[] memory rawTxs) internal pure virtual returns (Tx1559[] memory);
rawToConvertedEIPTx1559
function rawToConvertedEIPTx1559(RawTx1559 memory rawTx) internal pure virtual returns (Tx1559 memory);
rawToConvertedEIP1559Detail
function rawToConvertedEIP1559Detail(RawTx1559Detail memory rawDetail)
internal
pure
virtual
returns (Tx1559Detail memory);
readTx1559s
function readTx1559s(string memory path) internal view virtual returns (Tx1559[] memory);
readTx1559
function readTx1559(string memory path, uint256 index) internal view virtual returns (Tx1559 memory);
readReceipts
function readReceipts(string memory path) internal view virtual returns (Receipt[] memory);
readReceipt
function readReceipt(string memory path, uint256 index) internal view virtual returns (Receipt memory);
rawToConvertedReceipts
function rawToConvertedReceipts(RawReceipt[] memory rawReceipts) internal pure virtual returns (Receipt[] memory);
rawToConvertedReceipt
function rawToConvertedReceipt(RawReceipt memory rawReceipt) internal pure virtual returns (Receipt memory);
rawToConvertedReceiptLogs
function rawToConvertedReceiptLogs(RawReceiptLog[] memory rawLogs)
internal
pure
virtual
returns (ReceiptLog[] memory);
deployCode
function deployCode(string memory what, bytes memory args) internal virtual returns (address addr);
deployCode
function deployCode(string memory what) internal virtual returns (address addr);
deployCode
deploy contract with value on construction
function deployCode(string memory what, bytes memory args, uint256 val) internal virtual returns (address addr);
deployCode
function deployCode(string memory what, uint256 val) internal virtual returns (address addr);
makeAddrAndKey
function makeAddrAndKey(string memory name) internal virtual returns (address addr, uint256 privateKey);
makeAddr
function makeAddr(string memory name) internal virtual returns (address addr);
destroyAccount
function destroyAccount(address who, address beneficiary) internal virtual;
makeAccount
function makeAccount(string memory name) internal virtual returns (Account memory account);
deriveRememberKey
function deriveRememberKey(string memory mnemonic, uint32 index)
internal
virtual
returns (address who, uint256 privateKey);
_bytesToUint
function _bytesToUint(bytes memory b) private pure returns (uint256);
isFork
function isFork() internal view virtual returns (bool status);
skipWhenForking
modifier skipWhenForking();
skipWhenNotForking
modifier skipWhenNotForking();
noGasMetering
modifier noGasMetering();
_viewChainId
function _viewChainId() private view returns (uint256 chainId);
_pureChainId
function _pureChainId() private pure returns (uint256 chainId);
Structs
RawTx1559
struct RawTx1559 {
string[] arguments;
address contractAddress;
string contractName;
string functionSig;
bytes32 hash;
RawTx1559Detail txDetail;
string opcode;
}
RawTx1559Detail
struct RawTx1559Detail {
AccessList[] accessList;
bytes data;
address from;
bytes gas;
bytes nonce;
address to;
bytes txType;
bytes value;
}
Tx1559
struct Tx1559 {
string[] arguments;
address contractAddress;
string contractName;
string functionSig;
bytes32 hash;
Tx1559Detail txDetail;
string opcode;
}
Tx1559Detail
struct Tx1559Detail {
AccessList[] accessList;
bytes data;
address from;
uint256 gas;
uint256 nonce;
address to;
uint256 txType;
uint256 value;
}
TxLegacy
struct TxLegacy {
string[] arguments;
address contractAddress;
string contractName;
string functionSig;
string hash;
string opcode;
TxDetailLegacy transaction;
}
TxDetailLegacy
struct TxDetailLegacy {
AccessList[] accessList;
uint256 chainId;
bytes data;
address from;
uint256 gas;
uint256 gasPrice;
bytes32 hash;
uint256 nonce;
bytes1 opcode;
bytes32 r;
bytes32 s;
uint256 txType;
address to;
uint8 v;
uint256 value;
}
AccessList
struct AccessList {
address accessAddress;
bytes32[] storageKeys;
}
RawReceipt
struct RawReceipt {
bytes32 blockHash;
bytes blockNumber;
address contractAddress;
bytes cumulativeGasUsed;
bytes effectiveGasPrice;
address from;
bytes gasUsed;
RawReceiptLog[] logs;
bytes logsBloom;
bytes status;
address to;
bytes32 transactionHash;
bytes transactionIndex;
}
Receipt
struct Receipt {
bytes32 blockHash;
uint256 blockNumber;
address contractAddress;
uint256 cumulativeGasUsed;
uint256 effectiveGasPrice;
address from;
uint256 gasUsed;
ReceiptLog[] logs;
bytes logsBloom;
uint256 status;
address to;
bytes32 transactionHash;
uint256 transactionIndex;
}
EIP1559ScriptArtifact
struct EIP1559ScriptArtifact {
string[] libraries;
string path;
string[] pending;
Receipt[] receipts;
uint256 timestamp;
Tx1559[] transactions;
TxReturn[] txReturns;
}
RawEIP1559ScriptArtifact
struct RawEIP1559ScriptArtifact {
string[] libraries;
string path;
string[] pending;
RawReceipt[] receipts;
TxReturn[] txReturns;
uint256 timestamp;
RawTx1559[] transactions;
}
RawReceiptLog
struct RawReceiptLog {
address logAddress;
bytes32 blockHash;
bytes blockNumber;
bytes data;
bytes logIndex;
bool removed;
bytes32[] topics;
bytes32 transactionHash;
bytes transactionIndex;
bytes transactionLogIndex;
}
ReceiptLog
struct ReceiptLog {
address logAddress;
bytes32 blockHash;
uint256 blockNumber;
bytes data;
uint256 logIndex;
bytes32[] topics;
uint256 transactionIndex;
uint256 transactionLogIndex;
bool removed;
}
TxReturn
struct TxReturn {
string internalType;
string value;
}
Account
struct Account {
address addr;
uint256 key;
}
Enums
AddressType
enum AddressType {
Payable,
NonPayable,
ZeroAddress,
Precompile,
ForgeAddress
}
StdCheats
Inherits: StdCheatsSafe
State Variables
stdstore
StdStorage private stdstore;
vm
Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));
CONSOLE2_ADDRESS
address private constant CONSOLE2_ADDRESS = 0x000000000000000000636F6e736F6c652e6c6f67;
Functions
skip
function skip(uint256 time) internal virtual;
rewind
function rewind(uint256 time) internal virtual;
hoax
function hoax(address msgSender) internal virtual;
hoax
function hoax(address msgSender, uint256 give) internal virtual;
hoax
function hoax(address msgSender, address origin) internal virtual;
hoax
function hoax(address msgSender, address origin, uint256 give) internal virtual;
startHoax
function startHoax(address msgSender) internal virtual;
startHoax
function startHoax(address msgSender, uint256 give) internal virtual;
startHoax
function startHoax(address msgSender, address origin) internal virtual;
startHoax
function startHoax(address msgSender, address origin, uint256 give) internal virtual;
changePrank
function changePrank(address msgSender) internal virtual;
changePrank
function changePrank(address msgSender, address txOrigin) internal virtual;
deal
function deal(address to, uint256 give) internal virtual;
deal
function deal(address token, address to, uint256 give) internal virtual;
dealERC1155
function dealERC1155(address token, address to, uint256 id, uint256 give) internal virtual;
deal
function deal(address token, address to, uint256 give, bool adjust) internal virtual;
dealERC1155
function dealERC1155(address token, address to, uint256 id, uint256 give, bool adjust) internal virtual;
dealERC721
function dealERC721(address token, address to, uint256 id) internal virtual;
deployCodeTo
function deployCodeTo(string memory what, address where) internal virtual;
deployCodeTo
function deployCodeTo(string memory what, bytes memory args, address where) internal virtual;
deployCodeTo
function deployCodeTo(string memory what, bytes memory args, uint256 value, address where) internal virtual;
console2_log_StdCheats
function console2_log_StdCheats(string memory p0) private view;
stdError
State Variables
assertionError
bytes public constant assertionError = abi.encodeWithSignature("Panic(uint256)", 0x01);
arithmeticError
bytes public constant arithmeticError = abi.encodeWithSignature("Panic(uint256)", 0x11);
divisionError
bytes public constant divisionError = abi.encodeWithSignature("Panic(uint256)", 0x12);
enumConversionError
bytes public constant enumConversionError = abi.encodeWithSignature("Panic(uint256)", 0x21);
encodeStorageError
bytes public constant encodeStorageError = abi.encodeWithSignature("Panic(uint256)", 0x22);
popError
bytes public constant popError = abi.encodeWithSignature("Panic(uint256)", 0x31);
indexOOBError
bytes public constant indexOOBError = abi.encodeWithSignature("Panic(uint256)", 0x32);
memOverflowError
bytes public constant memOverflowError = abi.encodeWithSignature("Panic(uint256)", 0x41);
zeroVarError
bytes public constant zeroVarError = abi.encodeWithSignature("Panic(uint256)", 0x51);
StdInvariant
State Variables
_excludedContracts
address[] private _excludedContracts;
_excludedSenders
address[] private _excludedSenders;
_targetedContracts
address[] private _targetedContracts;
_targetedSenders
address[] private _targetedSenders;
_excludedArtifacts
string[] private _excludedArtifacts;
_targetedArtifacts
string[] private _targetedArtifacts;
_targetedArtifactSelectors
FuzzArtifactSelector[] private _targetedArtifactSelectors;
_excludedSelectors
FuzzSelector[] private _excludedSelectors;
_targetedSelectors
FuzzSelector[] private _targetedSelectors;
_targetedInterfaces
FuzzInterface[] private _targetedInterfaces;
Functions
excludeContract
function excludeContract(address newExcludedContract_) internal;
excludeSelector
function excludeSelector(FuzzSelector memory newExcludedSelector_) internal;
excludeSender
function excludeSender(address newExcludedSender_) internal;
excludeArtifact
function excludeArtifact(string memory newExcludedArtifact_) internal;
targetArtifact
function targetArtifact(string memory newTargetedArtifact_) internal;
targetArtifactSelector
function targetArtifactSelector(FuzzArtifactSelector memory newTargetedArtifactSelector_) internal;
targetContract
function targetContract(address newTargetedContract_) internal;
targetSelector
function targetSelector(FuzzSelector memory newTargetedSelector_) internal;
targetSender
function targetSender(address newTargetedSender_) internal;
targetInterface
function targetInterface(FuzzInterface memory newTargetedInterface_) internal;
excludeArtifacts
function excludeArtifacts() public view returns (string[] memory excludedArtifacts_);
excludeContracts
function excludeContracts() public view returns (address[] memory excludedContracts_);
excludeSelectors
function excludeSelectors() public view returns (FuzzSelector[] memory excludedSelectors_);
excludeSenders
function excludeSenders() public view returns (address[] memory excludedSenders_);
targetArtifacts
function targetArtifacts() public view returns (string[] memory targetedArtifacts_);
targetArtifactSelectors
function targetArtifactSelectors() public view returns (FuzzArtifactSelector[] memory targetedArtifactSelectors_);
targetContracts
function targetContracts() public view returns (address[] memory targetedContracts_);
targetSelectors
function targetSelectors() public view returns (FuzzSelector[] memory targetedSelectors_);
targetSenders
function targetSenders() public view returns (address[] memory targetedSenders_);
targetInterfaces
function targetInterfaces() public view returns (FuzzInterface[] memory targetedInterfaces_);
Structs
FuzzSelector
struct FuzzSelector {
address addr;
bytes4[] selectors;
}
FuzzArtifactSelector
struct FuzzArtifactSelector {
string artifact;
bytes4[] selectors;
}
FuzzInterface
struct FuzzInterface {
address addr;
string[] artifacts;
}
stdJson
State Variables
vm
VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));
Functions
keyExists
function keyExists(string memory json, string memory key) internal view returns (bool);
parseRaw
function parseRaw(string memory json, string memory key) internal pure returns (bytes memory);
readUint
function readUint(string memory json, string memory key) internal pure returns (uint256);
readUintArray
function readUintArray(string memory json, string memory key) internal pure returns (uint256[] memory);
readInt
function readInt(string memory json, string memory key) internal pure returns (int256);
readIntArray
function readIntArray(string memory json, string memory key) internal pure returns (int256[] memory);
readBytes32
function readBytes32(string memory json, string memory key) internal pure returns (bytes32);
readBytes32Array
function readBytes32Array(string memory json, string memory key) internal pure returns (bytes32[] memory);
readString
function readString(string memory json, string memory key) internal pure returns (string memory);
readStringArray
function readStringArray(string memory json, string memory key) internal pure returns (string[] memory);
readAddress
function readAddress(string memory json, string memory key) internal pure returns (address);
readAddressArray
function readAddressArray(string memory json, string memory key) internal pure returns (address[] memory);
readBool
function readBool(string memory json, string memory key) internal pure returns (bool);
readBoolArray
function readBoolArray(string memory json, string memory key) internal pure returns (bool[] memory);
readBytes
function readBytes(string memory json, string memory key) internal pure returns (bytes memory);
readBytesArray
function readBytesArray(string memory json, string memory key) internal pure returns (bytes[] memory);
readUintOr
function readUintOr(string memory json, string memory key, uint256 defaultValue) internal view returns (uint256);
readUintArrayOr
function readUintArrayOr(string memory json, string memory key, uint256[] memory defaultValue)
internal
view
returns (uint256[] memory);
readIntOr
function readIntOr(string memory json, string memory key, int256 defaultValue) internal view returns (int256);
readIntArrayOr
function readIntArrayOr(string memory json, string memory key, int256[] memory defaultValue)
internal
view
returns (int256[] memory);
readBytes32Or
function readBytes32Or(string memory json, string memory key, bytes32 defaultValue) internal view returns (bytes32);
readBytes32ArrayOr
function readBytes32ArrayOr(string memory json, string memory key, bytes32[] memory defaultValue)
internal
view
returns (bytes32[] memory);
readStringOr
function readStringOr(string memory json, string memory key, string memory defaultValue)
internal
view
returns (string memory);
readStringArrayOr
function readStringArrayOr(string memory json, string memory key, string[] memory defaultValue)
internal
view
returns (string[] memory);
readAddressOr
function readAddressOr(string memory json, string memory key, address defaultValue) internal view returns (address);
readAddressArrayOr
function readAddressArrayOr(string memory json, string memory key, address[] memory defaultValue)
internal
view
returns (address[] memory);
readBoolOr
function readBoolOr(string memory json, string memory key, bool defaultValue) internal view returns (bool);
readBoolArrayOr
function readBoolArrayOr(string memory json, string memory key, bool[] memory defaultValue)
internal
view
returns (bool[] memory);
readBytesOr
function readBytesOr(string memory json, string memory key, bytes memory defaultValue)
internal
view
returns (bytes memory);
readBytesArrayOr
function readBytesArrayOr(string memory json, string memory key, bytes[] memory defaultValue)
internal
view
returns (bytes[] memory);
serialize
function serialize(string memory jsonKey, string memory rootObject) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bool value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bool[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, uint256 value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, uint256[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, int256 value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, int256[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, address value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, address[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bytes32 value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bytes32[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bytes memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bytes[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, string memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, string[] memory value) internal returns (string memory);
write
function write(string memory jsonKey, string memory path) internal;
write
function write(string memory jsonKey, string memory path, string memory valueKey) internal;
stdMath
State Variables
INT256_MIN
int256 private constant INT256_MIN = -57896044618658097711785492504343953926634992332820282019728792003956564819968;
Functions
abs
function abs(int256 a) internal pure returns (uint256);
delta
function delta(uint256 a, uint256 b) internal pure returns (uint256);
delta
function delta(int256 a, int256 b) internal pure returns (uint256);
percentDelta
function percentDelta(uint256 a, uint256 b) internal pure returns (uint256);
percentDelta
function percentDelta(int256 a, int256 b) internal pure returns (uint256);
FindData
struct FindData {
uint256 slot;
uint256 offsetLeft;
uint256 offsetRight;
bool found;
}
StdStorage
struct StdStorage {
mapping(address => mapping(bytes4 => mapping(bytes32 => FindData))) finds;
bytes32[] _keys;
bytes4 _sig;
uint256 _depth;
address _target;
bytes32 _set;
bool _enable_packed_slots;
bytes _calldata;
}
stdStorageSafe
State Variables
vm
Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));
UINT256_MAX
uint256 constant UINT256_MAX = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
Functions
sigs
function sigs(string memory sigStr) internal pure returns (bytes4);
getCallParams
function getCallParams(StdStorage storage self) internal view returns (bytes memory);
callTarget
function callTarget(StdStorage storage self) internal view returns (bool, bytes32);
checkSlotMutatesCall
function checkSlotMutatesCall(StdStorage storage self, bytes32 slot) internal returns (bool);
findOffset
function findOffset(StdStorage storage self, bytes32 slot, bool left) internal returns (bool, uint256);
findOffsets
function findOffsets(StdStorage storage self, bytes32 slot) internal returns (bool, uint256, uint256);
find
function find(StdStorage storage self) internal returns (FindData storage);
find
find an arbitrary storage slot given a function sig, input data, address of the contract and a value to check against
function find(StdStorage storage self, bool _clear) internal returns (FindData storage);
target
function target(StdStorage storage self, address _target) internal returns (StdStorage storage);
sig
function sig(StdStorage storage self, bytes4 _sig) internal returns (StdStorage storage);
sig
function sig(StdStorage storage self, string memory _sig) internal returns (StdStorage storage);
with_calldata
function with_calldata(StdStorage storage self, bytes memory _calldata) internal returns (StdStorage storage);
with_key
function with_key(StdStorage storage self, address who) internal returns (StdStorage storage);
with_key
function with_key(StdStorage storage self, uint256 amt) internal returns (StdStorage storage);
with_key
function with_key(StdStorage storage self, bytes32 key) internal returns (StdStorage storage);
enable_packed_slots
function enable_packed_slots(StdStorage storage self) internal returns (StdStorage storage);
depth
function depth(StdStorage storage self, uint256 _depth) internal returns (StdStorage storage);
read
function read(StdStorage storage self) private returns (bytes memory);
read_bytes32
function read_bytes32(StdStorage storage self) internal returns (bytes32);
read_bool
function read_bool(StdStorage storage self) internal returns (bool);
read_address
function read_address(StdStorage storage self) internal returns (address);
read_uint
function read_uint(StdStorage storage self) internal returns (uint256);
read_int
function read_int(StdStorage storage self) internal returns (int256);
parent
function parent(StdStorage storage self) internal returns (uint256, bytes32);
root
function root(StdStorage storage self) internal returns (uint256);
bytesToBytes32
function bytesToBytes32(bytes memory b, uint256 offset) private pure returns (bytes32);
flatten
function flatten(bytes32[] memory b) private pure returns (bytes memory);
clear
function clear(StdStorage storage self) internal;
getMaskByOffsets
function getMaskByOffsets(uint256 offsetLeft, uint256 offsetRight) internal pure returns (uint256 mask);
getUpdatedSlotValue
function getUpdatedSlotValue(bytes32 curValue, uint256 varValue, uint256 offsetLeft, uint256 offsetRight)
internal
pure
returns (bytes32 newValue);
Events
SlotFound
event SlotFound(address who, bytes4 fsig, bytes32 keysHash, uint256 slot);
WARNING_UninitedSlot
event WARNING_UninitedSlot(address who, uint256 slot);
stdStorage
State Variables
vm
Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));
Functions
sigs
function sigs(string memory sigStr) internal pure returns (bytes4);
find
function find(StdStorage storage self) internal returns (uint256);
find
function find(StdStorage storage self, bool _clear) internal returns (uint256);
target
function target(StdStorage storage self, address _target) internal returns (StdStorage storage);
sig
function sig(StdStorage storage self, bytes4 _sig) internal returns (StdStorage storage);
sig
function sig(StdStorage storage self, string memory _sig) internal returns (StdStorage storage);
with_key
function with_key(StdStorage storage self, address who) internal returns (StdStorage storage);
with_key
function with_key(StdStorage storage self, uint256 amt) internal returns (StdStorage storage);
with_key
function with_key(StdStorage storage self, bytes32 key) internal returns (StdStorage storage);
with_calldata
function with_calldata(StdStorage storage self, bytes memory _calldata) internal returns (StdStorage storage);
enable_packed_slots
function enable_packed_slots(StdStorage storage self) internal returns (StdStorage storage);
depth
function depth(StdStorage storage self, uint256 _depth) internal returns (StdStorage storage);
clear
function clear(StdStorage storage self) internal;
checked_write
function checked_write(StdStorage storage self, address who) internal;
checked_write
function checked_write(StdStorage storage self, uint256 amt) internal;
checked_write_int
function checked_write_int(StdStorage storage self, int256 val) internal;
checked_write
function checked_write(StdStorage storage self, bool write) internal;
checked_write
function checked_write(StdStorage storage self, bytes32 set) internal;
read_bytes32
function read_bytes32(StdStorage storage self) internal returns (bytes32);
read_bool
function read_bool(StdStorage storage self) internal returns (bool);
read_address
function read_address(StdStorage storage self) internal returns (address);
read_uint
function read_uint(StdStorage storage self) internal returns (uint256);
read_int
function read_int(StdStorage storage self) internal returns (int256);
parent
function parent(StdStorage storage self) internal returns (uint256, bytes32);
root
function root(StdStorage storage self) internal returns (uint256);
StdStyle
State Variables
vm
VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));
RED
string constant RED = "\u001b[91m";
GREEN
string constant GREEN = "\u001b[92m";
YELLOW
string constant YELLOW = "\u001b[93m";
BLUE
string constant BLUE = "\u001b[94m";
MAGENTA
string constant MAGENTA = "\u001b[95m";
CYAN
string constant CYAN = "\u001b[96m";
BOLD
string constant BOLD = "\u001b[1m";
DIM
string constant DIM = "\u001b[2m";
ITALIC
string constant ITALIC = "\u001b[3m";
UNDERLINE
string constant UNDERLINE = "\u001b[4m";
INVERSE
string constant INVERSE = "\u001b[7m";
RESET
string constant RESET = "\u001b[0m";
Functions
styleConcat
function styleConcat(string memory style, string memory self) private pure returns (string memory);
red
function red(string memory self) internal pure returns (string memory);
red
function red(uint256 self) internal pure returns (string memory);
red
function red(int256 self) internal pure returns (string memory);
red
function red(address self) internal pure returns (string memory);
red
function red(bool self) internal pure returns (string memory);
redBytes
function redBytes(bytes memory self) internal pure returns (string memory);
redBytes32
function redBytes32(bytes32 self) internal pure returns (string memory);
green
function green(string memory self) internal pure returns (string memory);
green
function green(uint256 self) internal pure returns (string memory);
green
function green(int256 self) internal pure returns (string memory);
green
function green(address self) internal pure returns (string memory);
green
function green(bool self) internal pure returns (string memory);
greenBytes
function greenBytes(bytes memory self) internal pure returns (string memory);
greenBytes32
function greenBytes32(bytes32 self) internal pure returns (string memory);
yellow
function yellow(string memory self) internal pure returns (string memory);
yellow
function yellow(uint256 self) internal pure returns (string memory);
yellow
function yellow(int256 self) internal pure returns (string memory);
yellow
function yellow(address self) internal pure returns (string memory);
yellow
function yellow(bool self) internal pure returns (string memory);
yellowBytes
function yellowBytes(bytes memory self) internal pure returns (string memory);
yellowBytes32
function yellowBytes32(bytes32 self) internal pure returns (string memory);
blue
function blue(string memory self) internal pure returns (string memory);
blue
function blue(uint256 self) internal pure returns (string memory);
blue
function blue(int256 self) internal pure returns (string memory);
blue
function blue(address self) internal pure returns (string memory);
blue
function blue(bool self) internal pure returns (string memory);
blueBytes
function blueBytes(bytes memory self) internal pure returns (string memory);
blueBytes32
function blueBytes32(bytes32 self) internal pure returns (string memory);
magenta
function magenta(string memory self) internal pure returns (string memory);
magenta
function magenta(uint256 self) internal pure returns (string memory);
magenta
function magenta(int256 self) internal pure returns (string memory);
magenta
function magenta(address self) internal pure returns (string memory);
magenta
function magenta(bool self) internal pure returns (string memory);
magentaBytes
function magentaBytes(bytes memory self) internal pure returns (string memory);
magentaBytes32
function magentaBytes32(bytes32 self) internal pure returns (string memory);
cyan
function cyan(string memory self) internal pure returns (string memory);
cyan
function cyan(uint256 self) internal pure returns (string memory);
cyan
function cyan(int256 self) internal pure returns (string memory);
cyan
function cyan(address self) internal pure returns (string memory);
cyan
function cyan(bool self) internal pure returns (string memory);
cyanBytes
function cyanBytes(bytes memory self) internal pure returns (string memory);
cyanBytes32
function cyanBytes32(bytes32 self) internal pure returns (string memory);
bold
function bold(string memory self) internal pure returns (string memory);
bold
function bold(uint256 self) internal pure returns (string memory);
bold
function bold(int256 self) internal pure returns (string memory);
bold
function bold(address self) internal pure returns (string memory);
bold
function bold(bool self) internal pure returns (string memory);
boldBytes
function boldBytes(bytes memory self) internal pure returns (string memory);
boldBytes32
function boldBytes32(bytes32 self) internal pure returns (string memory);
dim
function dim(string memory self) internal pure returns (string memory);
dim
function dim(uint256 self) internal pure returns (string memory);
dim
function dim(int256 self) internal pure returns (string memory);
dim
function dim(address self) internal pure returns (string memory);
dim
function dim(bool self) internal pure returns (string memory);
dimBytes
function dimBytes(bytes memory self) internal pure returns (string memory);
dimBytes32
function dimBytes32(bytes32 self) internal pure returns (string memory);
italic
function italic(string memory self) internal pure returns (string memory);
italic
function italic(uint256 self) internal pure returns (string memory);
italic
function italic(int256 self) internal pure returns (string memory);
italic
function italic(address self) internal pure returns (string memory);
italic
function italic(bool self) internal pure returns (string memory);
italicBytes
function italicBytes(bytes memory self) internal pure returns (string memory);
italicBytes32
function italicBytes32(bytes32 self) internal pure returns (string memory);
underline
function underline(string memory self) internal pure returns (string memory);
underline
function underline(uint256 self) internal pure returns (string memory);
underline
function underline(int256 self) internal pure returns (string memory);
underline
function underline(address self) internal pure returns (string memory);
underline
function underline(bool self) internal pure returns (string memory);
underlineBytes
function underlineBytes(bytes memory self) internal pure returns (string memory);
underlineBytes32
function underlineBytes32(bytes32 self) internal pure returns (string memory);
inverse
function inverse(string memory self) internal pure returns (string memory);
inverse
function inverse(uint256 self) internal pure returns (string memory);
inverse
function inverse(int256 self) internal pure returns (string memory);
inverse
function inverse(address self) internal pure returns (string memory);
inverse
function inverse(bool self) internal pure returns (string memory);
inverseBytes
function inverseBytes(bytes memory self) internal pure returns (string memory);
inverseBytes32
function inverseBytes32(bytes32 self) internal pure returns (string memory);
stdToml
State Variables
vm
VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));
Functions
keyExists
function keyExists(string memory toml, string memory key) internal view returns (bool);
parseRaw
function parseRaw(string memory toml, string memory key) internal pure returns (bytes memory);
readUint
function readUint(string memory toml, string memory key) internal pure returns (uint256);
readUintArray
function readUintArray(string memory toml, string memory key) internal pure returns (uint256[] memory);
readInt
function readInt(string memory toml, string memory key) internal pure returns (int256);
readIntArray
function readIntArray(string memory toml, string memory key) internal pure returns (int256[] memory);
readBytes32
function readBytes32(string memory toml, string memory key) internal pure returns (bytes32);
readBytes32Array
function readBytes32Array(string memory toml, string memory key) internal pure returns (bytes32[] memory);
readString
function readString(string memory toml, string memory key) internal pure returns (string memory);
readStringArray
function readStringArray(string memory toml, string memory key) internal pure returns (string[] memory);
readAddress
function readAddress(string memory toml, string memory key) internal pure returns (address);
readAddressArray
function readAddressArray(string memory toml, string memory key) internal pure returns (address[] memory);
readBool
function readBool(string memory toml, string memory key) internal pure returns (bool);
readBoolArray
function readBoolArray(string memory toml, string memory key) internal pure returns (bool[] memory);
readBytes
function readBytes(string memory toml, string memory key) internal pure returns (bytes memory);
readBytesArray
function readBytesArray(string memory toml, string memory key) internal pure returns (bytes[] memory);
readUintOr
function readUintOr(string memory toml, string memory key, uint256 defaultValue) internal view returns (uint256);
readUintArrayOr
function readUintArrayOr(string memory toml, string memory key, uint256[] memory defaultValue)
internal
view
returns (uint256[] memory);
readIntOr
function readIntOr(string memory toml, string memory key, int256 defaultValue) internal view returns (int256);
readIntArrayOr
function readIntArrayOr(string memory toml, string memory key, int256[] memory defaultValue)
internal
view
returns (int256[] memory);
readBytes32Or
function readBytes32Or(string memory toml, string memory key, bytes32 defaultValue) internal view returns (bytes32);
readBytes32ArrayOr
function readBytes32ArrayOr(string memory toml, string memory key, bytes32[] memory defaultValue)
internal
view
returns (bytes32[] memory);
readStringOr
function readStringOr(string memory toml, string memory key, string memory defaultValue)
internal
view
returns (string memory);
readStringArrayOr
function readStringArrayOr(string memory toml, string memory key, string[] memory defaultValue)
internal
view
returns (string[] memory);
readAddressOr
function readAddressOr(string memory toml, string memory key, address defaultValue) internal view returns (address);
readAddressArrayOr
function readAddressArrayOr(string memory toml, string memory key, address[] memory defaultValue)
internal
view
returns (address[] memory);
readBoolOr
function readBoolOr(string memory toml, string memory key, bool defaultValue) internal view returns (bool);
readBoolArrayOr
function readBoolArrayOr(string memory toml, string memory key, bool[] memory defaultValue)
internal
view
returns (bool[] memory);
readBytesOr
function readBytesOr(string memory toml, string memory key, bytes memory defaultValue)
internal
view
returns (bytes memory);
readBytesArrayOr
function readBytesArrayOr(string memory toml, string memory key, bytes[] memory defaultValue)
internal
view
returns (bytes[] memory);
serialize
function serialize(string memory jsonKey, string memory rootObject) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bool value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bool[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, uint256 value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, uint256[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, int256 value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, int256[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, address value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, address[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bytes32 value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bytes32[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bytes memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bytes[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, string memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, string[] memory value) internal returns (string memory);
write
function write(string memory jsonKey, string memory path) internal;
write
function write(string memory jsonKey, string memory path, string memory valueKey) internal;
StdUtils
State Variables
multicall
IMulticall3 private constant multicall = IMulticall3(0xcA11bde05977b3631167028862bE2a173976CA11);
vm
VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));
CONSOLE2_ADDRESS
address private constant CONSOLE2_ADDRESS = 0x000000000000000000636F6e736F6c652e6c6f67;
INT256_MIN_ABS
uint256 private constant INT256_MIN_ABS = 57896044618658097711785492504343953926634992332820282019728792003956564819968;
SECP256K1_ORDER
uint256 private constant SECP256K1_ORDER =
115792089237316195423570985008687907852837564279074904382605163141518161494337;
UINT256_MAX
uint256 private constant UINT256_MAX = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
CREATE2_FACTORY
address private constant CREATE2_FACTORY = 0x4e59b44847b379578588920cA78FbF26c0B4956C;
Functions
_bound
function _bound(uint256 x, uint256 min, uint256 max) internal pure virtual returns (uint256 result);
bound
function bound(uint256 x, uint256 min, uint256 max) internal pure virtual returns (uint256 result);
_bound
function _bound(int256 x, int256 min, int256 max) internal pure virtual returns (int256 result);
bound
function bound(int256 x, int256 min, int256 max) internal pure virtual returns (int256 result);
boundPrivateKey
function boundPrivateKey(uint256 privateKey) internal pure virtual returns (uint256 result);
bytesToUint
function bytesToUint(bytes memory b) internal pure virtual returns (uint256);
computeCreateAddress
adapted from Solmate implementation (https://github.com/Rari-Capital/solmate/blob/main/src/utils/LibRLP.sol)
Compute the address a contract will be deployed at for a given deployer address and nonce
function computeCreateAddress(address deployer, uint256 nonce) internal pure virtual returns (address);
computeCreate2Address
function computeCreate2Address(bytes32 salt, bytes32 initcodeHash, address deployer)
internal
pure
virtual
returns (address);
computeCreate2Address
returns the address of a contract created with CREATE2 using the default CREATE2 deployer
function computeCreate2Address(bytes32 salt, bytes32 initCodeHash) internal pure returns (address);
hashInitCode
returns the hash of the init code (creation code + no args) used in CREATE2 with no constructor arguments
function hashInitCode(bytes memory creationCode) internal pure returns (bytes32);
Parameters
| Name | Type | Description |
|---|---|---|
creationCode | bytes | the creation code of a contract C, as returned by type(C).creationCode |
hashInitCode
returns the hash of the init code (creation code + ABI-encoded args) used in CREATE2
function hashInitCode(bytes memory creationCode, bytes memory args) internal pure returns (bytes32);
Parameters
| Name | Type | Description |
|---|---|---|
creationCode | bytes | the creation code of a contract C, as returned by type(C).creationCode |
args | bytes | the ABI-encoded arguments to the constructor of C |
getTokenBalances
function getTokenBalances(address token, address[] memory addresses)
internal
virtual
returns (uint256[] memory balances);
addressFromLast20Bytes
function addressFromLast20Bytes(bytes32 bytesValue) private pure returns (address);
_castLogPayloadViewToPure
function _castLogPayloadViewToPure(function(bytes memory) internal view fnIn)
internal
pure
returns (function(bytes memory) internal pure fnOut);
_sendLogPayload
function _sendLogPayload(bytes memory payload) internal pure;
_sendLogPayloadView
function _sendLogPayloadView(bytes memory payload) private view;
console2_log_StdUtils
function console2_log_StdUtils(string memory p0) private pure;
console2_log_StdUtils
function console2_log_StdUtils(string memory p0, uint256 p1) private pure;
console2_log_StdUtils
function console2_log_StdUtils(string memory p0, string memory p1) private pure;
Test
Inherits: TestBase, StdAssertions, StdChains, StdCheats, StdInvariant, StdUtils
State Variables
IS_TEST
bool public IS_TEST = true;
VmSafe
The VmSafe interface does not allow manipulation of the EVM state or other actions that may
result in Script simulations differing from on-chain execution. It is recommended to only use
these cheats in scripts.
Functions
createWallet
Derives a private key from the name, labels the account with that name, and returns the wallet.
function createWallet(string calldata walletLabel) external returns (Wallet memory wallet);
createWallet
Generates a wallet from the private key and returns the wallet.
function createWallet(uint256 privateKey) external returns (Wallet memory wallet);
createWallet
Generates a wallet from the private key, labels the account with that name, and returns the wallet.
function createWallet(uint256 privateKey, string calldata walletLabel) external returns (Wallet memory wallet);
deriveKey
Derive a private key from a provided mnenomic string (or mnenomic file path)
at the derivation path m/44'/60'/0'/0/{index}.
function deriveKey(string calldata mnemonic, uint32 index) external pure returns (uint256 privateKey);
deriveKey
Derive a private key from a provided mnenomic string (or mnenomic file path)
at {derivationPath}{index}.
function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index)
external
pure
returns (uint256 privateKey);
deriveKey
Derive a private key from a provided mnenomic string (or mnenomic file path) in the specified language
at the derivation path m/44'/60'/0'/0/{index}.
function deriveKey(string calldata mnemonic, uint32 index, string calldata language)
external
pure
returns (uint256 privateKey);
deriveKey
Derive a private key from a provided mnenomic string (or mnenomic file path) in the specified language
at {derivationPath}{index}.
function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index, string calldata language)
external
pure
returns (uint256 privateKey);
publicKeyP256
Derives secp256r1 public key from the provided privateKey.
function publicKeyP256(uint256 privateKey) external pure returns (uint256 publicKeyX, uint256 publicKeyY);
rememberKey
Adds a private key to the local forge wallet and returns the address.
function rememberKey(uint256 privateKey) external returns (address keyAddr);
rememberKeys
Derive a set number of wallets from a mnemonic at the derivation path m/44'/60'/0'/0/{0..count}.
The respective private keys are saved to the local forge wallet for later use and their addresses are returned.
function rememberKeys(string calldata mnemonic, string calldata derivationPath, uint32 count)
external
returns (address[] memory keyAddrs);
rememberKeys
Derive a set number of wallets from a mnemonic in the specified language at the derivation path m/44'/60'/0'/0/{0..count}.
The respective private keys are saved to the local forge wallet for later use and their addresses are returned.
function rememberKeys(string calldata mnemonic, string calldata derivationPath, string calldata language, uint32 count)
external
returns (address[] memory keyAddrs);
signCompact
Signs data with a Wallet.
Returns a compact signature (r, vs) as per EIP-2098, where vs encodes both the
signature's s value, and the recovery id v in a single bytes32.
This format reduces the signature size from 65 to 64 bytes.
function signCompact(Wallet calldata wallet, bytes32 digest) external returns (bytes32 r, bytes32 vs);
signCompact
Signs digest with privateKey using the secp256k1 curve.
Returns a compact signature (r, vs) as per EIP-2098, where vs encodes both the
signature's s value, and the recovery id v in a single bytes32.
This format reduces the signature size from 65 to 64 bytes.
function signCompact(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
signCompact
Signs digest with signer provided to script using the secp256k1 curve.
Returns a compact signature (r, vs) as per EIP-2098, where vs encodes both the
signature's s value, and the recovery id v in a single bytes32.
This format reduces the signature size from 65 to 64 bytes.
If --sender is provided, the signer with provided address is used, otherwise,
if exactly one signer is provided to the script, that signer is used.
Raises error if signer passed through --sender does not match any unlocked signers or
if --sender is not provided and not exactly one signer is passed to the script.
function signCompact(bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
signCompact
Signs digest with signer provided to script using the secp256k1 curve.
Returns a compact signature (r, vs) as per EIP-2098, where vs encodes both the
signature's s value, and the recovery id v in a single bytes32.
This format reduces the signature size from 65 to 64 bytes.
Raises error if none of the signers passed into the script have provided address.
function signCompact(address signer, bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
signP256
Signs digest with privateKey using the secp256r1 curve.
function signP256(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 s);
sign
Signs data with a Wallet.
function sign(Wallet calldata wallet, bytes32 digest) external returns (uint8 v, bytes32 r, bytes32 s);
sign
Signs digest with privateKey using the secp256k1 curve.
function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
sign
Signs digest with signer provided to script using the secp256k1 curve.
If --sender is provided, the signer with provided address is used, otherwise,
if exactly one signer is provided to the script, that signer is used.
Raises error if signer passed through --sender does not match any unlocked signers or
if --sender is not provided and not exactly one signer is passed to the script.
function sign(bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
sign
Signs digest with signer provided to script using the secp256k1 curve.
Raises error if none of the signers passed into the script have provided address.
function sign(address signer, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
envAddress
Gets the environment variable name and parses it as address.
Reverts if the variable was not found or could not be parsed.
function envAddress(string calldata name) external view returns (address value);
envAddress
Gets the environment variable name and parses it as an array of address, delimited by delim.
Reverts if the variable was not found or could not be parsed.
function envAddress(string calldata name, string calldata delim) external view returns (address[] memory value);
envBool
Gets the environment variable name and parses it as bool.
Reverts if the variable was not found or could not be parsed.
function envBool(string calldata name) external view returns (bool value);
envBool
Gets the environment variable name and parses it as an array of bool, delimited by delim.
Reverts if the variable was not found or could not be parsed.
function envBool(string calldata name, string calldata delim) external view returns (bool[] memory value);
envBytes32
Gets the environment variable name and parses it as bytes32.
Reverts if the variable was not found or could not be parsed.
function envBytes32(string calldata name) external view returns (bytes32 value);
envBytes32
Gets the environment variable name and parses it as an array of bytes32, delimited by delim.
Reverts if the variable was not found or could not be parsed.
function envBytes32(string calldata name, string calldata delim) external view returns (bytes32[] memory value);
envBytes
Gets the environment variable name and parses it as bytes.
Reverts if the variable was not found or could not be parsed.
function envBytes(string calldata name) external view returns (bytes memory value);
envBytes
Gets the environment variable name and parses it as an array of bytes, delimited by delim.
Reverts if the variable was not found or could not be parsed.
function envBytes(string calldata name, string calldata delim) external view returns (bytes[] memory value);
envExists
Gets the environment variable name and returns true if it exists, else returns false.
function envExists(string calldata name) external view returns (bool result);
envInt
Gets the environment variable name and parses it as int256.
Reverts if the variable was not found or could not be parsed.
function envInt(string calldata name) external view returns (int256 value);
envInt
Gets the environment variable name and parses it as an array of int256, delimited by delim.
Reverts if the variable was not found or could not be parsed.
function envInt(string calldata name, string calldata delim) external view returns (int256[] memory value);
envOr
Gets the environment variable name and parses it as bool.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, bool defaultValue) external view returns (bool value);
envOr
Gets the environment variable name and parses it as uint256.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, uint256 defaultValue) external view returns (uint256 value);
envOr
Gets the environment variable name and parses it as an array of address, delimited by delim.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, string calldata delim, address[] calldata defaultValue)
external
view
returns (address[] memory value);
envOr
Gets the environment variable name and parses it as an array of bytes32, delimited by delim.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, string calldata delim, bytes32[] calldata defaultValue)
external
view
returns (bytes32[] memory value);
envOr
Gets the environment variable name and parses it as an array of string, delimited by delim.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, string calldata delim, string[] calldata defaultValue)
external
view
returns (string[] memory value);
envOr
Gets the environment variable name and parses it as an array of bytes, delimited by delim.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, string calldata delim, bytes[] calldata defaultValue)
external
view
returns (bytes[] memory value);
envOr
Gets the environment variable name and parses it as int256.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, int256 defaultValue) external view returns (int256 value);
envOr
Gets the environment variable name and parses it as address.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, address defaultValue) external view returns (address value);
envOr
Gets the environment variable name and parses it as bytes32.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, bytes32 defaultValue) external view returns (bytes32 value);
envOr
Gets the environment variable name and parses it as string.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, string calldata defaultValue) external view returns (string memory value);
envOr
Gets the environment variable name and parses it as bytes.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, bytes calldata defaultValue) external view returns (bytes memory value);
envOr
Gets the environment variable name and parses it as an array of bool, delimited by delim.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, string calldata delim, bool[] calldata defaultValue)
external
view
returns (bool[] memory value);
envOr
Gets the environment variable name and parses it as an array of uint256, delimited by delim.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, string calldata delim, uint256[] calldata defaultValue)
external
view
returns (uint256[] memory value);
envOr
Gets the environment variable name and parses it as an array of int256, delimited by delim.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, string calldata delim, int256[] calldata defaultValue)
external
view
returns (int256[] memory value);
envString
Gets the environment variable name and parses it as string.
Reverts if the variable was not found or could not be parsed.
function envString(string calldata name) external view returns (string memory value);
envString
Gets the environment variable name and parses it as an array of string, delimited by delim.
Reverts if the variable was not found or could not be parsed.
function envString(string calldata name, string calldata delim) external view returns (string[] memory value);
envUint
Gets the environment variable name and parses it as uint256.
Reverts if the variable was not found or could not be parsed.
function envUint(string calldata name) external view returns (uint256 value);
envUint
Gets the environment variable name and parses it as an array of uint256, delimited by delim.
Reverts if the variable was not found or could not be parsed.
function envUint(string calldata name, string calldata delim) external view returns (uint256[] memory value);
isContext
Returns true if forge command was executed in given context.
function isContext(ForgeContext context) external view returns (bool result);
setEnv
Sets environment variables.
function setEnv(string calldata name, string calldata value) external;
accesses
Gets all accessed reads and write slot from a vm.record session, for a given address.
function accesses(address target) external returns (bytes32[] memory readSlots, bytes32[] memory writeSlots);
addr
Gets the address for a given private key.
function addr(uint256 privateKey) external pure returns (address keyAddr);
eth_getLogs
Gets all the logs according to specified filter.
function eth_getLogs(uint256 fromBlock, uint256 toBlock, address target, bytes32[] calldata topics)
external
returns (EthGetLogs[] memory logs);
getBlobBaseFee
Gets the current block.blobbasefee.
You should use this instead of block.blobbasefee if you use vm.blobBaseFee, as block.blobbasefee is assumed to be constant across a transaction,
and as a result will get optimized out by the compiler.
See https://github.com/foundry-rs/foundry/issues/6180
function getBlobBaseFee() external view returns (uint256 blobBaseFee);
getBlockNumber
Gets the current block.number.
You should use this instead of block.number if you use vm.roll, as block.number is assumed to be constant across a transaction,
and as a result will get optimized out by the compiler.
See https://github.com/foundry-rs/foundry/issues/6180
function getBlockNumber() external view returns (uint256 height);
getBlockTimestamp
Gets the current block.timestamp.
You should use this instead of block.timestamp if you use vm.warp, as block.timestamp is assumed to be constant across a transaction,
and as a result will get optimized out by the compiler.
See https://github.com/foundry-rs/foundry/issues/6180
function getBlockTimestamp() external view returns (uint256 timestamp);
getMappingKeyAndParentOf
Gets the map key and parent of a mapping at a given slot, for a given address.
function getMappingKeyAndParentOf(address target, bytes32 elementSlot)
external
returns (bool found, bytes32 key, bytes32 parent);
getMappingLength
Gets the number of elements in the mapping at the given slot, for a given address.
function getMappingLength(address target, bytes32 mappingSlot) external returns (uint256 length);
getMappingSlotAt
Gets the elements at index idx of the mapping at the given slot, for a given address. The index must be less than the length of the mapping (i.e. the number of keys in the mapping).
function getMappingSlotAt(address target, bytes32 mappingSlot, uint256 idx) external returns (bytes32 value);
getNonce
Gets the nonce of an account.
function getNonce(address account) external view returns (uint64 nonce);
getNonce
Get the nonce of a Wallet.
function getNonce(Wallet calldata wallet) external returns (uint64 nonce);
getRecordedLogs
Gets all the recorded logs.
function getRecordedLogs() external returns (Log[] memory logs);
getStateDiff
Returns state diffs from current vm.startStateDiffRecording session.
function getStateDiff() external view returns (string memory diff);
getStateDiffJson
Returns state diffs from current vm.startStateDiffRecording session, in json format.
function getStateDiffJson() external view returns (string memory diff);
lastCallGas
Gets the gas used in the last call from the callee perspective.
function lastCallGas() external view returns (Gas memory gas);
load
Loads a storage slot from an address.
function load(address target, bytes32 slot) external view returns (bytes32 data);
pauseGasMetering
Pauses gas metering (i.e. gas usage is not counted). Noop if already paused.
function pauseGasMetering() external;
record
Records all storage reads and writes.
function record() external;
recordLogs
Record all the transaction logs.
function recordLogs() external;
resetGasMetering
Reset gas metering (i.e. gas usage is set to gas limit).
function resetGasMetering() external;
resumeGasMetering
Resumes gas metering (i.e. gas usage is counted again). Noop if already on.
function resumeGasMetering() external;
rpc
Performs an Ethereum JSON-RPC request to the current fork URL.
function rpc(string calldata method, string calldata params) external returns (bytes memory data);
rpc
Performs an Ethereum JSON-RPC request to the given endpoint.
function rpc(string calldata urlOrAlias, string calldata method, string calldata params)
external
returns (bytes memory data);
startDebugTraceRecording
Records the debug trace during the run.
function startDebugTraceRecording() external;
startMappingRecording
Starts recording all map SSTOREs for later retrieval.
function startMappingRecording() external;
startStateDiffRecording
Record all account accesses as part of CREATE, CALL or SELFDESTRUCT opcodes in order, along with the context of the calls
function startStateDiffRecording() external;
stopAndReturnDebugTraceRecording
Stop debug trace recording and returns the recorded debug trace.
function stopAndReturnDebugTraceRecording() external returns (DebugStep[] memory step);
stopAndReturnStateDiff
Returns an ordered array of all account accesses from a vm.startStateDiffRecording session.
function stopAndReturnStateDiff() external returns (AccountAccess[] memory accountAccesses);
stopMappingRecording
Stops recording all map SSTOREs for later retrieval and clears the recorded data.
function stopMappingRecording() external;
closeFile
Closes file for reading, resetting the offset and allowing to read it from beginning with readLine.
path is relative to the project root.
function closeFile(string calldata path) external;
copyFile
Copies the contents of one file to another. This function will overwrite the contents of to.
On success, the total number of bytes copied is returned and it is equal to the length of the to file as reported by metadata.
Both from and to are relative to the project root.
function copyFile(string calldata from, string calldata to) external returns (uint64 copied);
createDir
Creates a new, empty directory at the provided path. This cheatcode will revert in the following situations, but is not limited to just these cases:
- User lacks permissions to modify
path. - A parent of the given path doesn't exist and
recursiveis false. pathalready exists andrecursiveis false.pathis relative to the project root.
function createDir(string calldata path, bool recursive) external;
deployCode
Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the
artifact in the form of
function deployCode(string calldata artifactPath) external returns (address deployedAddress);
deployCode
Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the
artifact in the form of
function deployCode(string calldata artifactPath, bytes calldata constructorArgs)
external
returns (address deployedAddress);
exists
Returns true if the given path points to an existing entity, else returns false.
function exists(string calldata path) external view returns (bool result);
ffi
Performs a foreign function call via the terminal.
function ffi(string[] calldata commandInput) external returns (bytes memory result);
fsMetadata
Given a path, query the file system to get information about a file, directory, etc.
function fsMetadata(string calldata path) external view returns (FsMetadata memory metadata);
getArtifactPathByCode
Gets the artifact path from code (aka. creation code).
function getArtifactPathByCode(bytes calldata code) external view returns (string memory path);
getArtifactPathByDeployedCode
Gets the artifact path from deployed code (aka. runtime code).
function getArtifactPathByDeployedCode(bytes calldata deployedCode) external view returns (string memory path);
getBroadcast
Returns the most recent broadcast for the given contract on chainId matching txType.
For example:
The most recent deployment can be fetched by passing txType as CREATE or CREATE2.
The most recent call can be fetched by passing txType as CALL.
function getBroadcast(string calldata contractName, uint64 chainId, BroadcastTxType txType)
external
view
returns (BroadcastTxSummary memory);
getBroadcasts
Returns all broadcasts for the given contract on chainId with the specified txType.
Sorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber.
function getBroadcasts(string calldata contractName, uint64 chainId, BroadcastTxType txType)
external
view
returns (BroadcastTxSummary[] memory);
getBroadcasts
Returns all broadcasts for the given contract on chainId.
Sorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber.
function getBroadcasts(string calldata contractName, uint64 chainId)
external
view
returns (BroadcastTxSummary[] memory);
getCode
Gets the creation bytecode from an artifact file. Takes in the relative path to the json file or the path to the
artifact in the form of
function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode);
getDeployedCode
Gets the deployed bytecode from an artifact file. Takes in the relative path to the json file or the path to the
artifact in the form of
function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode);
getDeployment
Returns the most recent deployment for the current chainId.
function getDeployment(string calldata contractName) external view returns (address deployedAddress);
getDeployment
Returns the most recent deployment for the given contract on chainId
function getDeployment(string calldata contractName, uint64 chainId) external view returns (address deployedAddress);
getDeployments
Returns all deployments for the given contract on chainId
Sorted in descending order of deployment time i.e descending order of BroadcastTxSummary.blockNumber.
The most recent deployment is the first element, and the oldest is the last.
function getDeployments(string calldata contractName, uint64 chainId)
external
view
returns (address[] memory deployedAddresses);
isDir
Returns true if the path exists on disk and is pointing at a directory, else returns false.
function isDir(string calldata path) external view returns (bool result);
isFile
Returns true if the path exists on disk and is pointing at a regular file, else returns false.
function isFile(string calldata path) external view returns (bool result);
projectRoot
Get the path of the current project root.
function projectRoot() external view returns (string memory path);
prompt
Prompts the user for a string value in the terminal.
function prompt(string calldata promptText) external returns (string memory input);
promptAddress
Prompts the user for an address in the terminal.
function promptAddress(string calldata promptText) external returns (address);
promptSecret
Prompts the user for a hidden string value in the terminal.
function promptSecret(string calldata promptText) external returns (string memory input);
promptSecretUint
Prompts the user for hidden uint256 in the terminal (usually pk).
function promptSecretUint(string calldata promptText) external returns (uint256);
promptUint
Prompts the user for uint256 in the terminal.
function promptUint(string calldata promptText) external returns (uint256);
readDir
Reads the directory at the given path recursively, up to maxDepth.
maxDepth defaults to 1, meaning only the direct children of the given directory will be returned.
Follows symbolic links if followLinks is true.
function readDir(string calldata path) external view returns (DirEntry[] memory entries);
readDir
See readDir(string).
function readDir(string calldata path, uint64 maxDepth) external view returns (DirEntry[] memory entries);
readDir
See readDir(string).
function readDir(string calldata path, uint64 maxDepth, bool followLinks)
external
view
returns (DirEntry[] memory entries);
readFile
Reads the entire content of file to string. path is relative to the project root.
function readFile(string calldata path) external view returns (string memory data);
readFileBinary
Reads the entire content of file as binary. path is relative to the project root.
function readFileBinary(string calldata path) external view returns (bytes memory data);
readLine
Reads next line of file to string.
function readLine(string calldata path) external view returns (string memory line);
readLink
Reads a symbolic link, returning the path that the link points to. This cheatcode will revert in the following situations, but is not limited to just these cases:
pathis not a symbolic link.pathdoes not exist.
function readLink(string calldata linkPath) external view returns (string memory targetPath);
removeDir
Removes a directory at the provided path. This cheatcode will revert in the following situations, but is not limited to just these cases:
pathdoesn't exist.pathisn't a directory.- User lacks permissions to modify
path. - The directory is not empty and
recursiveis false.pathis relative to the project root.
function removeDir(string calldata path, bool recursive) external;
removeFile
Removes a file from the filesystem. This cheatcode will revert in the following situations, but is not limited to just these cases:
pathpoints to a directory.- The file doesn't exist.
- The user lacks permissions to remove the file.
pathis relative to the project root.
function removeFile(string calldata path) external;
tryFfi
Performs a foreign function call via terminal and returns the exit code, stdout, and stderr.
function tryFfi(string[] calldata commandInput) external returns (FfiResult memory result);
unixTime
Returns the time since unix epoch in milliseconds.
function unixTime() external view returns (uint256 milliseconds);
writeFile
Writes data to file, creating a file if it does not exist, and entirely replacing its contents if it does.
path is relative to the project root.
function writeFile(string calldata path, string calldata data) external;
writeFileBinary
Writes binary data to a file, creating a file if it does not exist, and entirely replacing its contents if it does.
path is relative to the project root.
function writeFileBinary(string calldata path, bytes calldata data) external;
writeLine
Writes line to file, creating a file if it does not exist.
path is relative to the project root.
function writeLine(string calldata path, string calldata data) external;
keyExistsJson
Checks if key exists in a JSON object.
function keyExistsJson(string calldata json, string calldata key) external view returns (bool);
parseJsonAddress
Parses a string of JSON data at key and coerces it to address.
function parseJsonAddress(string calldata json, string calldata key) external pure returns (address);
parseJsonAddressArray
Parses a string of JSON data at key and coerces it to address[].
function parseJsonAddressArray(string calldata json, string calldata key) external pure returns (address[] memory);
parseJsonBool
Parses a string of JSON data at key and coerces it to bool.
function parseJsonBool(string calldata json, string calldata key) external pure returns (bool);
parseJsonBoolArray
Parses a string of JSON data at key and coerces it to bool[].
function parseJsonBoolArray(string calldata json, string calldata key) external pure returns (bool[] memory);
parseJsonBytes
Parses a string of JSON data at key and coerces it to bytes.
function parseJsonBytes(string calldata json, string calldata key) external pure returns (bytes memory);
parseJsonBytes32
Parses a string of JSON data at key and coerces it to bytes32.
function parseJsonBytes32(string calldata json, string calldata key) external pure returns (bytes32);
parseJsonBytes32Array
Parses a string of JSON data at key and coerces it to bytes32[].
function parseJsonBytes32Array(string calldata json, string calldata key) external pure returns (bytes32[] memory);
parseJsonBytesArray
Parses a string of JSON data at key and coerces it to bytes[].
function parseJsonBytesArray(string calldata json, string calldata key) external pure returns (bytes[] memory);
parseJsonInt
Parses a string of JSON data at key and coerces it to int256.
function parseJsonInt(string calldata json, string calldata key) external pure returns (int256);
parseJsonIntArray
Parses a string of JSON data at key and coerces it to int256[].
function parseJsonIntArray(string calldata json, string calldata key) external pure returns (int256[] memory);
parseJsonKeys
Returns an array of all the keys in a JSON object.
function parseJsonKeys(string calldata json, string calldata key) external pure returns (string[] memory keys);
parseJsonString
Parses a string of JSON data at key and coerces it to string.
function parseJsonString(string calldata json, string calldata key) external pure returns (string memory);
parseJsonStringArray
Parses a string of JSON data at key and coerces it to string[].
function parseJsonStringArray(string calldata json, string calldata key) external pure returns (string[] memory);
parseJsonTypeArray
Parses a string of JSON data at key and coerces it to type array corresponding to typeDescription.
function parseJsonTypeArray(string calldata json, string calldata key, string calldata typeDescription)
external
pure
returns (bytes memory);
parseJsonType
Parses a string of JSON data and coerces it to type corresponding to typeDescription.
function parseJsonType(string calldata json, string calldata typeDescription) external pure returns (bytes memory);
parseJsonType
Parses a string of JSON data at key and coerces it to type corresponding to typeDescription.
function parseJsonType(string calldata json, string calldata key, string calldata typeDescription)
external
pure
returns (bytes memory);
parseJsonUint
Parses a string of JSON data at key and coerces it to uint256.
function parseJsonUint(string calldata json, string calldata key) external pure returns (uint256);
parseJsonUintArray
Parses a string of JSON data at key and coerces it to uint256[].
function parseJsonUintArray(string calldata json, string calldata key) external pure returns (uint256[] memory);
parseJson
ABI-encodes a JSON object.
function parseJson(string calldata json) external pure returns (bytes memory abiEncodedData);
parseJson
ABI-encodes a JSON object at key.
function parseJson(string calldata json, string calldata key) external pure returns (bytes memory abiEncodedData);
serializeAddress
See serializeJson.
function serializeAddress(string calldata objectKey, string calldata valueKey, address value)
external
returns (string memory json);
serializeAddress
See serializeJson.
function serializeAddress(string calldata objectKey, string calldata valueKey, address[] calldata values)
external
returns (string memory json);
serializeBool
See serializeJson.
function serializeBool(string calldata objectKey, string calldata valueKey, bool value)
external
returns (string memory json);
serializeBool
See serializeJson.
function serializeBool(string calldata objectKey, string calldata valueKey, bool[] calldata values)
external
returns (string memory json);
serializeBytes32
See serializeJson.
function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32 value)
external
returns (string memory json);
serializeBytes32
See serializeJson.
function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32[] calldata values)
external
returns (string memory json);
serializeBytes
See serializeJson.
function serializeBytes(string calldata objectKey, string calldata valueKey, bytes calldata value)
external
returns (string memory json);
serializeBytes
See serializeJson.
function serializeBytes(string calldata objectKey, string calldata valueKey, bytes[] calldata values)
external
returns (string memory json);
serializeInt
See serializeJson.
function serializeInt(string calldata objectKey, string calldata valueKey, int256 value)
external
returns (string memory json);
serializeInt
See serializeJson.
function serializeInt(string calldata objectKey, string calldata valueKey, int256[] calldata values)
external
returns (string memory json);
serializeJson
Serializes a key and value to a JSON object stored in-memory that can be later written to a file. Returns the stringified version of the specific JSON file up to that moment.
function serializeJson(string calldata objectKey, string calldata value) external returns (string memory json);
serializeJsonType
See serializeJson.
function serializeJsonType(string calldata typeDescription, bytes calldata value)
external
pure
returns (string memory json);
serializeJsonType
See serializeJson.
function serializeJsonType(
string calldata objectKey,
string calldata valueKey,
string calldata typeDescription,
bytes calldata value
) external returns (string memory json);
serializeString
See serializeJson.
function serializeString(string calldata objectKey, string calldata valueKey, string calldata value)
external
returns (string memory json);
serializeString
See serializeJson.
function serializeString(string calldata objectKey, string calldata valueKey, string[] calldata values)
external
returns (string memory json);
serializeUintToHex
See serializeJson.
function serializeUintToHex(string calldata objectKey, string calldata valueKey, uint256 value)
external
returns (string memory json);
serializeUint
See serializeJson.
function serializeUint(string calldata objectKey, string calldata valueKey, uint256 value)
external
returns (string memory json);
serializeUint
See serializeJson.
function serializeUint(string calldata objectKey, string calldata valueKey, uint256[] calldata values)
external
returns (string memory json);
writeJson
Write a serialized JSON object to a file. If the file exists, it will be overwritten.
function writeJson(string calldata json, string calldata path) external;
writeJson
Write a serialized JSON object to an existing JSON file, replacing a value with key = <value_key.> This is useful to replace a specific value of a JSON file, without having to parse the entire thing.
function writeJson(string calldata json, string calldata path, string calldata valueKey) external;
keyExists
Checks if key exists in a JSON object
keyExists is being deprecated in favor of keyExistsJson. It will be removed in future versions.
function keyExists(string calldata json, string calldata key) external view returns (bool);
attachDelegation
Designate the next call as an EIP-7702 transaction
function attachDelegation(SignedDelegation calldata signedDelegation) external;
broadcastRawTransaction
Takes a signed transaction and broadcasts it to the network.
function broadcastRawTransaction(bytes calldata data) external;
broadcast
Has the next call (at this call depth only) create transactions that can later be signed and sent onchain. Broadcasting address is determined by checking the following in order:
- If
--senderargument was provided, that address is used. - If exactly one signer (e.g. private key, hw wallet, keystore) is set when
forge broadcastis invoked, that signer is used. - Otherwise, default foundry sender (1804c8AB1F12E6bbf3894d4083f33e07309d1f38) is used.
function broadcast() external;
broadcast
Has the next call (at this call depth only) create a transaction with the address provided as the sender that can later be signed and sent onchain.
function broadcast(address signer) external;
broadcast
Has the next call (at this call depth only) create a transaction with the private key provided as the sender that can later be signed and sent onchain.
function broadcast(uint256 privateKey) external;
getWallets
Returns addresses of available unlocked wallets in the script environment.
function getWallets() external returns (address[] memory wallets);
signAndAttachDelegation
Sign an EIP-7702 authorization and designate the next call as an EIP-7702 transaction
function signAndAttachDelegation(address implementation, uint256 privateKey)
external
returns (SignedDelegation memory signedDelegation);
signDelegation
Sign an EIP-7702 authorization for delegation
function signDelegation(address implementation, uint256 privateKey)
external
returns (SignedDelegation memory signedDelegation);
startBroadcast
Has all subsequent calls (at this call depth only) create transactions that can later be signed and sent onchain. Broadcasting address is determined by checking the following in order:
- If
--senderargument was provided, that address is used. - If exactly one signer (e.g. private key, hw wallet, keystore) is set when
forge broadcastis invoked, that signer is used. - Otherwise, default foundry sender (1804c8AB1F12E6bbf3894d4083f33e07309d1f38) is used.
function startBroadcast() external;
startBroadcast
Has all subsequent calls (at this call depth only) create transactions with the address provided that can later be signed and sent onchain.
function startBroadcast(address signer) external;
startBroadcast
Has all subsequent calls (at this call depth only) create transactions with the private key provided that can later be signed and sent onchain.
function startBroadcast(uint256 privateKey) external;
stopBroadcast
Stops collecting onchain transactions.
function stopBroadcast() external;
contains
Returns true if search is found in subject, false otherwise.
function contains(string calldata subject, string calldata search) external returns (bool result);
indexOf
Returns the index of the first occurrence of a key in an input string.
Returns NOT_FOUND (i.e. type(uint256).max) if the key is not found.
Returns 0 in case of an empty key.
function indexOf(string calldata input, string calldata key) external pure returns (uint256);
parseAddress
Parses the given string into an address.
function parseAddress(string calldata stringifiedValue) external pure returns (address parsedValue);
parseBool
Parses the given string into a bool.
function parseBool(string calldata stringifiedValue) external pure returns (bool parsedValue);
parseBytes
Parses the given string into bytes.
function parseBytes(string calldata stringifiedValue) external pure returns (bytes memory parsedValue);
parseBytes32
Parses the given string into a bytes32.
function parseBytes32(string calldata stringifiedValue) external pure returns (bytes32 parsedValue);
parseInt
Parses the given string into a int256.
function parseInt(string calldata stringifiedValue) external pure returns (int256 parsedValue);
parseUint
Parses the given string into a uint256.
function parseUint(string calldata stringifiedValue) external pure returns (uint256 parsedValue);
replace
Replaces occurrences of from in the given string with to.
function replace(string calldata input, string calldata from, string calldata to)
external
pure
returns (string memory output);
split
Splits the given string into an array of strings divided by the delimiter.
function split(string calldata input, string calldata delimiter) external pure returns (string[] memory outputs);
toLowercase
Converts the given string value to Lowercase.
function toLowercase(string calldata input) external pure returns (string memory output);
toString
Converts the given value to a string.
function toString(address value) external pure returns (string memory stringifiedValue);
toString
Converts the given value to a string.
function toString(bytes calldata value) external pure returns (string memory stringifiedValue);
toString
Converts the given value to a string.
function toString(bytes32 value) external pure returns (string memory stringifiedValue);
toString
Converts the given value to a string.
function toString(bool value) external pure returns (string memory stringifiedValue);
toString
Converts the given value to a string.
function toString(uint256 value) external pure returns (string memory stringifiedValue);
toString
Converts the given value to a string.
function toString(int256 value) external pure returns (string memory stringifiedValue);
toUppercase
Converts the given string value to Uppercase.
function toUppercase(string calldata input) external pure returns (string memory output);
trim
Trims leading and trailing whitespace from the given string value.
function trim(string calldata input) external pure returns (string memory output);
assertApproxEqAbsDecimal
Compares two uint256 values. Expects difference to be less than or equal to maxDelta.
Formats values with decimals in failure message.
function assertApproxEqAbsDecimal(uint256 left, uint256 right, uint256 maxDelta, uint256 decimals) external pure;
assertApproxEqAbsDecimal
Compares two uint256 values. Expects difference to be less than or equal to maxDelta.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertApproxEqAbsDecimal(
uint256 left,
uint256 right,
uint256 maxDelta,
uint256 decimals,
string calldata error
) external pure;
assertApproxEqAbsDecimal
Compares two int256 values. Expects difference to be less than or equal to maxDelta.
Formats values with decimals in failure message.
function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals) external pure;
assertApproxEqAbsDecimal
Compares two int256 values. Expects difference to be less than or equal to maxDelta.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals, string calldata error)
external
pure;
assertApproxEqAbs
Compares two uint256 values. Expects difference to be less than or equal to maxDelta.
function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta) external pure;
assertApproxEqAbs
Compares two uint256 values. Expects difference to be less than or equal to maxDelta.
Includes error message into revert string on failure.
function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta, string calldata error) external pure;
assertApproxEqAbs
Compares two int256 values. Expects difference to be less than or equal to maxDelta.
function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta) external pure;
assertApproxEqAbs
Compares two int256 values. Expects difference to be less than or equal to maxDelta.
Includes error message into revert string on failure.
function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta, string calldata error) external pure;
assertApproxEqRelDecimal
Compares two uint256 values. Expects relative difference in percents to be less than or equal to maxPercentDelta.
maxPercentDelta is an 18 decimal fixed point number, where 1e18 == 100%
Formats values with decimals in failure message.
function assertApproxEqRelDecimal(uint256 left, uint256 right, uint256 maxPercentDelta, uint256 decimals)
external
pure;
assertApproxEqRelDecimal
Compares two uint256 values. Expects relative difference in percents to be less than or equal to maxPercentDelta.
maxPercentDelta is an 18 decimal fixed point number, where 1e18 == 100%
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertApproxEqRelDecimal(
uint256 left,
uint256 right,
uint256 maxPercentDelta,
uint256 decimals,
string calldata error
) external pure;
assertApproxEqRelDecimal
Compares two int256 values. Expects relative difference in percents to be less than or equal to maxPercentDelta.
maxPercentDelta is an 18 decimal fixed point number, where 1e18 == 100%
Formats values with decimals in failure message.
function assertApproxEqRelDecimal(int256 left, int256 right, uint256 maxPercentDelta, uint256 decimals) external pure;
assertApproxEqRelDecimal
Compares two int256 values. Expects relative difference in percents to be less than or equal to maxPercentDelta.
maxPercentDelta is an 18 decimal fixed point number, where 1e18 == 100%
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertApproxEqRelDecimal(
int256 left,
int256 right,
uint256 maxPercentDelta,
uint256 decimals,
string calldata error
) external pure;
assertApproxEqRel
Compares two uint256 values. Expects relative difference in percents to be less than or equal to maxPercentDelta.
maxPercentDelta is an 18 decimal fixed point number, where 1e18 == 100%
function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta) external pure;
assertApproxEqRel
Compares two uint256 values. Expects relative difference in percents to be less than or equal to maxPercentDelta.
maxPercentDelta is an 18 decimal fixed point number, where 1e18 == 100%
Includes error message into revert string on failure.
function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta, string calldata error) external pure;
assertApproxEqRel
Compares two int256 values. Expects relative difference in percents to be less than or equal to maxPercentDelta.
maxPercentDelta is an 18 decimal fixed point number, where 1e18 == 100%
function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta) external pure;
assertApproxEqRel
Compares two int256 values. Expects relative difference in percents to be less than or equal to maxPercentDelta.
maxPercentDelta is an 18 decimal fixed point number, where 1e18 == 100%
Includes error message into revert string on failure.
function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta, string calldata error) external pure;
assertEqDecimal
Asserts that two uint256 values are equal, formatting them with decimals in failure message.
function assertEqDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
assertEqDecimal
Asserts that two uint256 values are equal, formatting them with decimals in failure message.
Includes error message into revert string on failure.
function assertEqDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
assertEqDecimal
Asserts that two int256 values are equal, formatting them with decimals in failure message.
function assertEqDecimal(int256 left, int256 right, uint256 decimals) external pure;
assertEqDecimal
Asserts that two int256 values are equal, formatting them with decimals in failure message.
Includes error message into revert string on failure.
function assertEqDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
assertEq
Asserts that two bool values are equal.
function assertEq(bool left, bool right) external pure;
assertEq
Asserts that two bool values are equal and includes error message into revert string on failure.
function assertEq(bool left, bool right, string calldata error) external pure;
assertEq
Asserts that two string values are equal.
function assertEq(string calldata left, string calldata right) external pure;
assertEq
Asserts that two string values are equal and includes error message into revert string on failure.
function assertEq(string calldata left, string calldata right, string calldata error) external pure;
assertEq
Asserts that two bytes values are equal.
function assertEq(bytes calldata left, bytes calldata right) external pure;
assertEq
Asserts that two bytes values are equal and includes error message into revert string on failure.
function assertEq(bytes calldata left, bytes calldata right, string calldata error) external pure;
assertEq
Asserts that two arrays of bool values are equal.
function assertEq(bool[] calldata left, bool[] calldata right) external pure;
assertEq
Asserts that two arrays of bool values are equal and includes error message into revert string on failure.
function assertEq(bool[] calldata left, bool[] calldata right, string calldata error) external pure;
assertEq
Asserts that two arrays of `uint256 values are equal.
function assertEq(uint256[] calldata left, uint256[] calldata right) external pure;
assertEq
Asserts that two arrays of uint256 values are equal and includes error message into revert string on failure.
function assertEq(uint256[] calldata left, uint256[] calldata right, string calldata error) external pure;
assertEq
Asserts that two arrays of int256 values are equal.
function assertEq(int256[] calldata left, int256[] calldata right) external pure;
assertEq
Asserts that two arrays of int256 values are equal and includes error message into revert string on failure.
function assertEq(int256[] calldata left, int256[] calldata right, string calldata error) external pure;
assertEq
Asserts that two uint256 values are equal.
function assertEq(uint256 left, uint256 right) external pure;
assertEq
Asserts that two arrays of address values are equal.
function assertEq(address[] calldata left, address[] calldata right) external pure;
assertEq
Asserts that two arrays of address values are equal and includes error message into revert string on failure.
function assertEq(address[] calldata left, address[] calldata right, string calldata error) external pure;
assertEq
Asserts that two arrays of bytes32 values are equal.
function assertEq(bytes32[] calldata left, bytes32[] calldata right) external pure;
assertEq
Asserts that two arrays of bytes32 values are equal and includes error message into revert string on failure.
function assertEq(bytes32[] calldata left, bytes32[] calldata right, string calldata error) external pure;
assertEq
Asserts that two arrays of string values are equal.
function assertEq(string[] calldata left, string[] calldata right) external pure;
assertEq
Asserts that two arrays of string values are equal and includes error message into revert string on failure.
function assertEq(string[] calldata left, string[] calldata right, string calldata error) external pure;
assertEq
Asserts that two arrays of bytes values are equal.
function assertEq(bytes[] calldata left, bytes[] calldata right) external pure;
assertEq
Asserts that two arrays of bytes values are equal and includes error message into revert string on failure.
function assertEq(bytes[] calldata left, bytes[] calldata right, string calldata error) external pure;
assertEq
Asserts that two uint256 values are equal and includes error message into revert string on failure.
function assertEq(uint256 left, uint256 right, string calldata error) external pure;
assertEq
Asserts that two int256 values are equal.
function assertEq(int256 left, int256 right) external pure;
assertEq
Asserts that two int256 values are equal and includes error message into revert string on failure.
function assertEq(int256 left, int256 right, string calldata error) external pure;
assertEq
Asserts that two address values are equal.
function assertEq(address left, address right) external pure;
assertEq
Asserts that two address values are equal and includes error message into revert string on failure.
function assertEq(address left, address right, string calldata error) external pure;
assertEq
Asserts that two bytes32 values are equal.
function assertEq(bytes32 left, bytes32 right) external pure;
assertEq
Asserts that two bytes32 values are equal and includes error message into revert string on failure.
function assertEq(bytes32 left, bytes32 right, string calldata error) external pure;
assertFalse
Asserts that the given condition is false.
function assertFalse(bool condition) external pure;
assertFalse
Asserts that the given condition is false and includes error message into revert string on failure.
function assertFalse(bool condition, string calldata error) external pure;
assertGeDecimal
Compares two uint256 values. Expects first value to be greater than or equal to second.
Formats values with decimals in failure message.
function assertGeDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
assertGeDecimal
Compares two uint256 values. Expects first value to be greater than or equal to second.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertGeDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
assertGeDecimal
Compares two int256 values. Expects first value to be greater than or equal to second.
Formats values with decimals in failure message.
function assertGeDecimal(int256 left, int256 right, uint256 decimals) external pure;
assertGeDecimal
Compares two int256 values. Expects first value to be greater than or equal to second.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertGeDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
assertGe
Compares two uint256 values. Expects first value to be greater than or equal to second.
function assertGe(uint256 left, uint256 right) external pure;
assertGe
Compares two uint256 values. Expects first value to be greater than or equal to second.
Includes error message into revert string on failure.
function assertGe(uint256 left, uint256 right, string calldata error) external pure;
assertGe
Compares two int256 values. Expects first value to be greater than or equal to second.
function assertGe(int256 left, int256 right) external pure;
assertGe
Compares two int256 values. Expects first value to be greater than or equal to second.
Includes error message into revert string on failure.
function assertGe(int256 left, int256 right, string calldata error) external pure;
assertGtDecimal
Compares two uint256 values. Expects first value to be greater than second.
Formats values with decimals in failure message.
function assertGtDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
assertGtDecimal
Compares two uint256 values. Expects first value to be greater than second.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertGtDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
assertGtDecimal
Compares two int256 values. Expects first value to be greater than second.
Formats values with decimals in failure message.
function assertGtDecimal(int256 left, int256 right, uint256 decimals) external pure;
assertGtDecimal
Compares two int256 values. Expects first value to be greater than second.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertGtDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
assertGt
Compares two uint256 values. Expects first value to be greater than second.
function assertGt(uint256 left, uint256 right) external pure;
assertGt
Compares two uint256 values. Expects first value to be greater than second.
Includes error message into revert string on failure.
function assertGt(uint256 left, uint256 right, string calldata error) external pure;
assertGt
Compares two int256 values. Expects first value to be greater than second.
function assertGt(int256 left, int256 right) external pure;
assertGt
Compares two int256 values. Expects first value to be greater than second.
Includes error message into revert string on failure.
function assertGt(int256 left, int256 right, string calldata error) external pure;
assertLeDecimal
Compares two uint256 values. Expects first value to be less than or equal to second.
Formats values with decimals in failure message.
function assertLeDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
assertLeDecimal
Compares two uint256 values. Expects first value to be less than or equal to second.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertLeDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
assertLeDecimal
Compares two int256 values. Expects first value to be less than or equal to second.
Formats values with decimals in failure message.
function assertLeDecimal(int256 left, int256 right, uint256 decimals) external pure;
assertLeDecimal
Compares two int256 values. Expects first value to be less than or equal to second.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertLeDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
assertLe
Compares two uint256 values. Expects first value to be less than or equal to second.
function assertLe(uint256 left, uint256 right) external pure;
assertLe
Compares two uint256 values. Expects first value to be less than or equal to second.
Includes error message into revert string on failure.
function assertLe(uint256 left, uint256 right, string calldata error) external pure;
assertLe
Compares two int256 values. Expects first value to be less than or equal to second.
function assertLe(int256 left, int256 right) external pure;
assertLe
Compares two int256 values. Expects first value to be less than or equal to second.
Includes error message into revert string on failure.
function assertLe(int256 left, int256 right, string calldata error) external pure;
assertLtDecimal
Compares two uint256 values. Expects first value to be less than second.
Formats values with decimals in failure message.
function assertLtDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
assertLtDecimal
Compares two uint256 values. Expects first value to be less than second.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertLtDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
assertLtDecimal
Compares two int256 values. Expects first value to be less than second.
Formats values with decimals in failure message.
function assertLtDecimal(int256 left, int256 right, uint256 decimals) external pure;
assertLtDecimal
Compares two int256 values. Expects first value to be less than second.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertLtDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
assertLt
Compares two uint256 values. Expects first value to be less than second.
function assertLt(uint256 left, uint256 right) external pure;
assertLt
Compares two uint256 values. Expects first value to be less than second.
Includes error message into revert string on failure.
function assertLt(uint256 left, uint256 right, string calldata error) external pure;
assertLt
Compares two int256 values. Expects first value to be less than second.
function assertLt(int256 left, int256 right) external pure;
assertLt
Compares two int256 values. Expects first value to be less than second.
Includes error message into revert string on failure.
function assertLt(int256 left, int256 right, string calldata error) external pure;
assertNotEqDecimal
Asserts that two uint256 values are not equal, formatting them with decimals in failure message.
function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
assertNotEqDecimal
Asserts that two uint256 values are not equal, formatting them with decimals in failure message.
Includes error message into revert string on failure.
function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
assertNotEqDecimal
Asserts that two int256 values are not equal, formatting them with decimals in failure message.
function assertNotEqDecimal(int256 left, int256 right, uint256 decimals) external pure;
assertNotEqDecimal
Asserts that two int256 values are not equal, formatting them with decimals in failure message.
Includes error message into revert string on failure.
function assertNotEqDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
assertNotEq
Asserts that two bool values are not equal.
function assertNotEq(bool left, bool right) external pure;
assertNotEq
Asserts that two bool values are not equal and includes error message into revert string on failure.
function assertNotEq(bool left, bool right, string calldata error) external pure;
assertNotEq
Asserts that two string values are not equal.
function assertNotEq(string calldata left, string calldata right) external pure;
assertNotEq
Asserts that two string values are not equal and includes error message into revert string on failure.
function assertNotEq(string calldata left, string calldata right, string calldata error) external pure;
assertNotEq
Asserts that two bytes values are not equal.
function assertNotEq(bytes calldata left, bytes calldata right) external pure;
assertNotEq
Asserts that two bytes values are not equal and includes error message into revert string on failure.
function assertNotEq(bytes calldata left, bytes calldata right, string calldata error) external pure;
assertNotEq
Asserts that two arrays of bool values are not equal.
function assertNotEq(bool[] calldata left, bool[] calldata right) external pure;
assertNotEq
Asserts that two arrays of bool values are not equal and includes error message into revert string on failure.
function assertNotEq(bool[] calldata left, bool[] calldata right, string calldata error) external pure;
assertNotEq
Asserts that two arrays of uint256 values are not equal.
function assertNotEq(uint256[] calldata left, uint256[] calldata right) external pure;
assertNotEq
Asserts that two arrays of uint256 values are not equal and includes error message into revert string on failure.
function assertNotEq(uint256[] calldata left, uint256[] calldata right, string calldata error) external pure;
assertNotEq
Asserts that two arrays of int256 values are not equal.
function assertNotEq(int256[] calldata left, int256[] calldata right) external pure;
assertNotEq
Asserts that two arrays of int256 values are not equal and includes error message into revert string on failure.
function assertNotEq(int256[] calldata left, int256[] calldata right, string calldata error) external pure;
assertNotEq
Asserts that two uint256 values are not equal.
function assertNotEq(uint256 left, uint256 right) external pure;
assertNotEq
Asserts that two arrays of address values are not equal.
function assertNotEq(address[] calldata left, address[] calldata right) external pure;
assertNotEq
Asserts that two arrays of address values are not equal and includes error message into revert string on failure.
function assertNotEq(address[] calldata left, address[] calldata right, string calldata error) external pure;
assertNotEq
Asserts that two arrays of bytes32 values are not equal.
function assertNotEq(bytes32[] calldata left, bytes32[] calldata right) external pure;
assertNotEq
Asserts that two arrays of bytes32 values are not equal and includes error message into revert string on failure.
function assertNotEq(bytes32[] calldata left, bytes32[] calldata right, string calldata error) external pure;
assertNotEq
Asserts that two arrays of string values are not equal.
function assertNotEq(string[] calldata left, string[] calldata right) external pure;
assertNotEq
Asserts that two arrays of string values are not equal and includes error message into revert string on failure.
function assertNotEq(string[] calldata left, string[] calldata right, string calldata error) external pure;
assertNotEq
Asserts that two arrays of bytes values are not equal.
function assertNotEq(bytes[] calldata left, bytes[] calldata right) external pure;
assertNotEq
Asserts that two arrays of bytes values are not equal and includes error message into revert string on failure.
function assertNotEq(bytes[] calldata left, bytes[] calldata right, string calldata error) external pure;
assertNotEq
Asserts that two uint256 values are not equal and includes error message into revert string on failure.
function assertNotEq(uint256 left, uint256 right, string calldata error) external pure;
assertNotEq
Asserts that two int256 values are not equal.
function assertNotEq(int256 left, int256 right) external pure;
assertNotEq
Asserts that two int256 values are not equal and includes error message into revert string on failure.
function assertNotEq(int256 left, int256 right, string calldata error) external pure;
assertNotEq
Asserts that two address values are not equal.
function assertNotEq(address left, address right) external pure;
assertNotEq
Asserts that two address values are not equal and includes error message into revert string on failure.
function assertNotEq(address left, address right, string calldata error) external pure;
assertNotEq
Asserts that two bytes32 values are not equal.
function assertNotEq(bytes32 left, bytes32 right) external pure;
assertNotEq
Asserts that two bytes32 values are not equal and includes error message into revert string on failure.
function assertNotEq(bytes32 left, bytes32 right, string calldata error) external pure;
assertTrue
Asserts that the given condition is true.
function assertTrue(bool condition) external pure;
assertTrue
Asserts that the given condition is true and includes error message into revert string on failure.
function assertTrue(bool condition, string calldata error) external pure;
assume
If the condition is false, discard this run's fuzz inputs and generate new ones.
function assume(bool condition) external pure;
assumeNoRevert
Discard this run's fuzz inputs and generate new ones if next call reverted.
function assumeNoRevert() external pure;
assumeNoRevert
Discard this run's fuzz inputs and generate new ones if next call reverts with the potential revert parameters.
function assumeNoRevert(PotentialRevert calldata potentialRevert) external pure;
assumeNoRevert
Discard this run's fuzz inputs and generate new ones if next call reverts with the any of the potential revert parameters.
function assumeNoRevert(PotentialRevert[] calldata potentialReverts) external pure;
breakpoint
Writes a breakpoint to jump to in the debugger.
function breakpoint(string calldata char) external pure;
breakpoint
Writes a conditional breakpoint to jump to in the debugger.
function breakpoint(string calldata char, bool value) external pure;
getFoundryVersion
Returns the Foundry version.
Format: <cargo_version>-
function getFoundryVersion() external view returns (string memory version);
rpcUrl
Returns the RPC url for the given alias.
function rpcUrl(string calldata rpcAlias) external view returns (string memory json);
rpcUrlStructs
Returns all rpc urls and their aliases as structs.
function rpcUrlStructs() external view returns (Rpc[] memory urls);
rpcUrls
Returns all rpc urls and their aliases [alias, url][].
function rpcUrls() external view returns (string[2][] memory urls);
sleep
Suspends execution of the main thread for duration milliseconds.
function sleep(uint256 duration) external;
keyExistsToml
Checks if key exists in a TOML table.
function keyExistsToml(string calldata toml, string calldata key) external view returns (bool);
parseTomlAddress
Parses a string of TOML data at key and coerces it to address.
function parseTomlAddress(string calldata toml, string calldata key) external pure returns (address);
parseTomlAddressArray
Parses a string of TOML data at key and coerces it to address[].
function parseTomlAddressArray(string calldata toml, string calldata key) external pure returns (address[] memory);
parseTomlBool
Parses a string of TOML data at key and coerces it to bool.
function parseTomlBool(string calldata toml, string calldata key) external pure returns (bool);
parseTomlBoolArray
Parses a string of TOML data at key and coerces it to bool[].
function parseTomlBoolArray(string calldata toml, string calldata key) external pure returns (bool[] memory);
parseTomlBytes
Parses a string of TOML data at key and coerces it to bytes.
function parseTomlBytes(string calldata toml, string calldata key) external pure returns (bytes memory);
parseTomlBytes32
Parses a string of TOML data at key and coerces it to bytes32.
function parseTomlBytes32(string calldata toml, string calldata key) external pure returns (bytes32);
parseTomlBytes32Array
Parses a string of TOML data at key and coerces it to bytes32[].
function parseTomlBytes32Array(string calldata toml, string calldata key) external pure returns (bytes32[] memory);
parseTomlBytesArray
Parses a string of TOML data at key and coerces it to bytes[].
function parseTomlBytesArray(string calldata toml, string calldata key) external pure returns (bytes[] memory);
parseTomlInt
Parses a string of TOML data at key and coerces it to int256.
function parseTomlInt(string calldata toml, string calldata key) external pure returns (int256);
parseTomlIntArray
Parses a string of TOML data at key and coerces it to int256[].
function parseTomlIntArray(string calldata toml, string calldata key) external pure returns (int256[] memory);
parseTomlKeys
Returns an array of all the keys in a TOML table.
function parseTomlKeys(string calldata toml, string calldata key) external pure returns (string[] memory keys);
parseTomlString
Parses a string of TOML data at key and coerces it to string.
function parseTomlString(string calldata toml, string calldata key) external pure returns (string memory);
parseTomlStringArray
Parses a string of TOML data at key and coerces it to string[].
function parseTomlStringArray(string calldata toml, string calldata key) external pure returns (string[] memory);
parseTomlTypeArray
Parses a string of TOML data at key and coerces it to type array corresponding to typeDescription.
function parseTomlTypeArray(string calldata toml, string calldata key, string calldata typeDescription)
external
pure
returns (bytes memory);
parseTomlType
Parses a string of TOML data and coerces it to type corresponding to typeDescription.
function parseTomlType(string calldata toml, string calldata typeDescription) external pure returns (bytes memory);
parseTomlType
Parses a string of TOML data at key and coerces it to type corresponding to typeDescription.
function parseTomlType(string calldata toml, string calldata key, string calldata typeDescription)
external
pure
returns (bytes memory);
parseTomlUint
Parses a string of TOML data at key and coerces it to uint256.
function parseTomlUint(string calldata toml, string calldata key) external pure returns (uint256);
parseTomlUintArray
Parses a string of TOML data at key and coerces it to uint256[].
function parseTomlUintArray(string calldata toml, string calldata key) external pure returns (uint256[] memory);
parseToml
ABI-encodes a TOML table.
function parseToml(string calldata toml) external pure returns (bytes memory abiEncodedData);
parseToml
ABI-encodes a TOML table at key.
function parseToml(string calldata toml, string calldata key) external pure returns (bytes memory abiEncodedData);
writeToml
Takes serialized JSON, converts to TOML and write a serialized TOML to a file.
function writeToml(string calldata json, string calldata path) external;
writeToml
Takes serialized JSON, converts to TOML and write a serialized TOML table to an existing TOML file, replacing a value with key = <value_key.> This is useful to replace a specific value of a TOML file, without having to parse the entire thing.
function writeToml(string calldata json, string calldata path, string calldata valueKey) external;
computeCreate2Address
Compute the address of a contract created with CREATE2 using the given CREATE2 deployer.
function computeCreate2Address(bytes32 salt, bytes32 initCodeHash, address deployer) external pure returns (address);
computeCreate2Address
Compute the address of a contract created with CREATE2 using the default CREATE2 deployer.
function computeCreate2Address(bytes32 salt, bytes32 initCodeHash) external pure returns (address);
computeCreateAddress
Compute the address a contract will be deployed at for a given deployer address and nonce.
function computeCreateAddress(address deployer, uint256 nonce) external pure returns (address);
copyStorage
Utility cheatcode to copy storage of from contract to another to contract.
function copyStorage(address from, address to) external;
ensNamehash
Returns ENS namehash for provided string.
function ensNamehash(string calldata name) external pure returns (bytes32);
getLabel
Gets the label for the specified address.
function getLabel(address account) external view returns (string memory currentLabel);
label
Labels an address in call traces.
function label(address account, string calldata newLabel) external;
pauseTracing
Pauses collection of call traces. Useful in cases when you want to skip tracing of complex calls which are not useful for debugging.
function pauseTracing() external view;
randomAddress
Returns a random address.
function randomAddress() external returns (address);
randomBool
Returns a random bool.
function randomBool() external view returns (bool);
randomBytes
Returns a random byte array value of the given length.
function randomBytes(uint256 len) external view returns (bytes memory);
randomBytes4
Returns a random fixed-size byte array of length 4.
function randomBytes4() external view returns (bytes4);
randomBytes8
Returns a random fixed-size byte array of length 8.
function randomBytes8() external view returns (bytes8);
randomInt
Returns a random int256 value.
function randomInt() external view returns (int256);
randomInt
Returns a random int256 value of given bits.
function randomInt(uint256 bits) external view returns (int256);
randomUint
Returns a random uint256 value.
function randomUint() external returns (uint256);
randomUint
Returns random uint256 value between the provided range (=min..=max).
function randomUint(uint256 min, uint256 max) external returns (uint256);
randomUint
Returns a random uint256 value of given bits.
function randomUint(uint256 bits) external view returns (uint256);
resumeTracing
Unpauses collection of call traces.
function resumeTracing() external view;
setArbitraryStorage
Utility cheatcode to set arbitrary storage for given target address.
function setArbitraryStorage(address target) external;
toBase64URL
Encodes a bytes value to a base64url string.
function toBase64URL(bytes calldata data) external pure returns (string memory);
toBase64URL
Encodes a string value to a base64url string.
function toBase64URL(string calldata data) external pure returns (string memory);
toBase64
Encodes a bytes value to a base64 string.
function toBase64(bytes calldata data) external pure returns (string memory);
toBase64
Encodes a string value to a base64 string.
function toBase64(string calldata data) external pure returns (string memory);
Structs
Log
An Ethereum log. Returned by getRecordedLogs.
struct Log {
bytes32[] topics;
bytes data;
address emitter;
}
Rpc
An RPC URL and its alias. Returned by rpcUrlStructs.
struct Rpc {
string key;
string url;
}
EthGetLogs
An RPC log object. Returned by eth_getLogs.
struct EthGetLogs {
address emitter;
bytes32[] topics;
bytes data;
bytes32 blockHash;
uint64 blockNumber;
bytes32 transactionHash;
uint64 transactionIndex;
uint256 logIndex;
bool removed;
}
DirEntry
A single entry in a directory listing. Returned by readDir.
struct DirEntry {
string errorMessage;
string path;
uint64 depth;
bool isDir;
bool isSymlink;
}
FsMetadata
Metadata information about a file.
This structure is returned from the fsMetadata function and represents known
metadata about a file such as its permissions, size, modification
times, etc.
struct FsMetadata {
bool isDir;
bool isSymlink;
uint256 length;
bool readOnly;
uint256 modified;
uint256 accessed;
uint256 created;
}
Wallet
A wallet with a public and private key.
struct Wallet {
address addr;
uint256 publicKeyX;
uint256 publicKeyY;
uint256 privateKey;
}
FfiResult
The result of a tryFfi call.
struct FfiResult {
int32 exitCode;
bytes stdout;
bytes stderr;
}
ChainInfo
Information on the chain and fork.
struct ChainInfo {
uint256 forkId;
uint256 chainId;
}
AccountAccess
The result of a stopAndReturnStateDiff call.
struct AccountAccess {
ChainInfo chainInfo;
AccountAccessKind kind;
address account;
address accessor;
bool initialized;
uint256 oldBalance;
uint256 newBalance;
bytes deployedCode;
uint256 value;
bytes data;
bool reverted;
StorageAccess[] storageAccesses;
uint64 depth;
}
StorageAccess
The storage accessed during an AccountAccess.
struct StorageAccess {
address account;
bytes32 slot;
bool isWrite;
bytes32 previousValue;
bytes32 newValue;
bool reverted;
}
Gas
Gas used. Returned by lastCallGas.
struct Gas {
uint64 gasLimit;
uint64 gasTotalUsed;
uint64 gasMemoryUsed;
int64 gasRefunded;
uint64 gasRemaining;
}
DebugStep
The result of the stopDebugTraceRecording call
struct DebugStep {
uint256[] stack;
bytes memoryInput;
uint8 opcode;
uint64 depth;
bool isOutOfGas;
address contractAddr;
}
BroadcastTxSummary
Represents a transaction's broadcast details.
struct BroadcastTxSummary {
bytes32 txHash;
BroadcastTxType txType;
address contractAddress;
uint64 blockNumber;
bool success;
}
SignedDelegation
Holds a signed EIP-7702 authorization for an authority account to delegate to an implementation.
struct SignedDelegation {
uint8 v;
bytes32 r;
bytes32 s;
uint64 nonce;
address implementation;
}
PotentialRevert
Represents a "potential" revert reason from a single subsequent call when using vm.assumeNoReverts.
Reverts that match will result in a FOUNDRY::ASSUME rejection, whereas unmatched reverts will be surfaced
as normal.
struct PotentialRevert {
address reverter;
bool partialMatch;
bytes revertData;
}
Enums
CallerMode
A modification applied to either msg.sender or tx.origin. Returned by readCallers.
enum CallerMode {
None,
Broadcast,
RecurrentBroadcast,
Prank,
RecurrentPrank
}
AccountAccessKind
The kind of account access that occurred.
enum AccountAccessKind {
Call,
DelegateCall,
CallCode,
StaticCall,
Create,
SelfDestruct,
Resume,
Balance,
Extcodesize,
Extcodehash,
Extcodecopy
}
ForgeContext
Forge execution contexts.
enum ForgeContext {
TestGroup,
Test,
Coverage,
Snapshot,
ScriptGroup,
ScriptDryRun,
ScriptBroadcast,
ScriptResume,
Unknown
}
BroadcastTxType
The transaction type (txType) of the broadcast.
enum BroadcastTxType {
Call,
Create,
Create2
}
Vm
Inherits: VmSafe
The Vm interface does allow manipulation of the EVM state. These are all intended to be used
in tests, but it is not recommended to use these cheats in scripts.
Functions
activeFork
Returns the identifier of the currently active fork. Reverts if no fork is currently active.
function activeFork() external view returns (uint256 forkId);
allowCheatcodes
In forking mode, explicitly grant the given address cheatcode access.
function allowCheatcodes(address account) external;
blobBaseFee
Sets block.blobbasefee
function blobBaseFee(uint256 newBlobBaseFee) external;
blobhashes
Sets the blobhashes in the transaction. Not available on EVM versions before Cancun. If used on unsupported EVM versions it will revert.
function blobhashes(bytes32[] calldata hashes) external;
chainId
Sets block.chainid.
function chainId(uint256 newChainId) external;
clearMockedCalls
Clears all mocked calls.
function clearMockedCalls() external;
cloneAccount
Clones a source account code, state, balance and nonce to a target account and updates in-memory EVM state.
function cloneAccount(address source, address target) external;
coinbase
Sets block.coinbase.
function coinbase(address newCoinbase) external;
createFork
Creates a new fork with the given endpoint and the latest block and returns the identifier of the fork.
function createFork(string calldata urlOrAlias) external returns (uint256 forkId);
createFork
Creates a new fork with the given endpoint and block and returns the identifier of the fork.
function createFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);
createFork
Creates a new fork with the given endpoint and at the block the given transaction was mined in, replays all transaction mined in the block before the transaction, and returns the identifier of the fork.
function createFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);
createSelectFork
Creates and also selects a new fork with the given endpoint and the latest block and returns the identifier of the fork.
function createSelectFork(string calldata urlOrAlias) external returns (uint256 forkId);
createSelectFork
Creates and also selects a new fork with the given endpoint and block and returns the identifier of the fork.
function createSelectFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);
createSelectFork
Creates and also selects new fork with the given endpoint and at the block the given transaction was mined in, replays all transaction mined in the block before the transaction, returns the identifier of the fork.
function createSelectFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);
deal
Sets an address' balance.
function deal(address account, uint256 newBalance) external;
deleteStateSnapshot
Removes the snapshot with the given ID created by snapshot.
Takes the snapshot ID to delete.
Returns true if the snapshot was successfully deleted.
Returns false if the snapshot does not exist.
function deleteStateSnapshot(uint256 snapshotId) external returns (bool success);
deleteStateSnapshots
Removes all snapshots previously created by snapshot.
function deleteStateSnapshots() external;
difficulty
Sets block.difficulty.
Not available on EVM versions from Paris onwards. Use prevrandao instead.
Reverts if used on unsupported EVM versions.
function difficulty(uint256 newDifficulty) external;
dumpState
Dump a genesis JSON file's allocs to disk.
function dumpState(string calldata pathToStateJson) external;
etch
Sets an address' code.
function etch(address target, bytes calldata newRuntimeBytecode) external;
fee
Sets block.basefee.
function fee(uint256 newBasefee) external;
getBlobhashes
Gets the blockhashes from the current transaction. Not available on EVM versions before Cancun. If used on unsupported EVM versions it will revert.
function getBlobhashes() external view returns (bytes32[] memory hashes);
isPersistent
Returns true if the account is marked as persistent.
function isPersistent(address account) external view returns (bool persistent);
loadAllocs
Load a genesis JSON file's allocs into the in-memory EVM state.
function loadAllocs(string calldata pathToAllocsJson) external;
makePersistent
Marks that the account(s) should use persistent storage across fork swaps in a multifork setup Meaning, changes made to the state of this account will be kept when switching forks.
function makePersistent(address account) external;
makePersistent
See makePersistent(address).
function makePersistent(address account0, address account1) external;
makePersistent
See makePersistent(address).
function makePersistent(address account0, address account1, address account2) external;
makePersistent
See makePersistent(address).
function makePersistent(address[] calldata accounts) external;
mockCallRevert
Reverts a call to an address with specified revert data.
function mockCallRevert(address callee, bytes calldata data, bytes calldata revertData) external;
mockCallRevert
Reverts a call to an address with a specific msg.value, with specified revert data.
function mockCallRevert(address callee, uint256 msgValue, bytes calldata data, bytes calldata revertData) external;
mockCallRevert
Reverts a call to an address with specified revert data.
Overload to pass the function selector directly token.approve.selector instead of abi.encodeWithSelector(token.approve.selector).
function mockCallRevert(address callee, bytes4 data, bytes calldata revertData) external;
mockCallRevert
Reverts a call to an address with a specific msg.value, with specified revert data.
Overload to pass the function selector directly token.approve.selector instead of abi.encodeWithSelector(token.approve.selector).
function mockCallRevert(address callee, uint256 msgValue, bytes4 data, bytes calldata revertData) external;
mockCall
Mocks a call to an address, returning specified data. Calldata can either be strict or a partial match, e.g. if you only pass a Solidity selector to the expected calldata, then the entire Solidity function will be mocked.
function mockCall(address callee, bytes calldata data, bytes calldata returnData) external;
mockCall
Mocks a call to an address with a specific msg.value, returning specified data.
Calldata match takes precedence over msg.value in case of ambiguity.
function mockCall(address callee, uint256 msgValue, bytes calldata data, bytes calldata returnData) external;
mockCall
Mocks a call to an address, returning specified data.
Calldata can either be strict or a partial match, e.g. if you only
pass a Solidity selector to the expected calldata, then the entire Solidity
function will be mocked.
Overload to pass the function selector directly token.approve.selector instead of abi.encodeWithSelector(token.approve.selector).
function mockCall(address callee, bytes4 data, bytes calldata returnData) external;
mockCall
Mocks a call to an address with a specific msg.value, returning specified data.
Calldata match takes precedence over msg.value in case of ambiguity.
Overload to pass the function selector directly token.approve.selector instead of abi.encodeWithSelector(token.approve.selector).
function mockCall(address callee, uint256 msgValue, bytes4 data, bytes calldata returnData) external;
mockCalls
Mocks multiple calls to an address, returning specified data for each call.
function mockCalls(address callee, bytes calldata data, bytes[] calldata returnData) external;
mockCalls
Mocks multiple calls to an address with a specific msg.value, returning specified data for each call.
function mockCalls(address callee, uint256 msgValue, bytes calldata data, bytes[] calldata returnData) external;
mockFunction
Whenever a call is made to callee with calldata data, this cheatcode instead calls
target with the same calldata. This functionality is similar to a delegate call made to
target contract from callee.
Can be used to substitute a call to a function with another implementation that captures
the primary logic of the original function but is easier to reason about.
If calldata is not a strict match then partial match by selector is attempted.
function mockFunction(address callee, address target, bytes calldata data) external;
prank
Sets the next call's msg.sender to be the input address.
function prank(address msgSender) external;
prank
Sets the next call's msg.sender to be the input address, and the tx.origin to be the second input.
function prank(address msgSender, address txOrigin) external;
prank
Sets the next delegate call's msg.sender to be the input address.
function prank(address msgSender, bool delegateCall) external;
prank
Sets the next delegate call's msg.sender to be the input address, and the tx.origin to be the second input.
function prank(address msgSender, address txOrigin, bool delegateCall) external;
prevrandao
Sets block.prevrandao.
Not available on EVM versions before Paris. Use difficulty instead.
If used on unsupported EVM versions it will revert.
function prevrandao(bytes32 newPrevrandao) external;
prevrandao
Sets block.prevrandao.
Not available on EVM versions before Paris. Use difficulty instead.
If used on unsupported EVM versions it will revert.
function prevrandao(uint256 newPrevrandao) external;
readCallers
Reads the current msg.sender and tx.origin from state and reports if there is any active caller modification.
function readCallers() external returns (CallerMode callerMode, address msgSender, address txOrigin);
resetNonce
Resets the nonce of an account to 0 for EOAs and 1 for contract accounts.
function resetNonce(address account) external;
revertToState
Revert the state of the EVM to a previous snapshot
Takes the snapshot ID to revert to.
Returns true if the snapshot was successfully reverted.
Returns false if the snapshot does not exist.
Note: This does not automatically delete the snapshot. To delete the snapshot use deleteStateSnapshot.
function revertToState(uint256 snapshotId) external returns (bool success);
revertToStateAndDelete
Revert the state of the EVM to a previous snapshot and automatically deletes the snapshots
Takes the snapshot ID to revert to.
Returns true if the snapshot was successfully reverted and deleted.
Returns false if the snapshot does not exist.
function revertToStateAndDelete(uint256 snapshotId) external returns (bool success);
revokePersistent
Revokes persistent status from the address, previously added via makePersistent.
function revokePersistent(address account) external;
revokePersistent
See revokePersistent(address).
function revokePersistent(address[] calldata accounts) external;
roll
Sets block.height.
function roll(uint256 newHeight) external;
rollFork
Updates the currently active fork to given block number
This is similar to roll but for the currently active fork.
function rollFork(uint256 blockNumber) external;
rollFork
Updates the currently active fork to given transaction. This will rollFork with the number
of the block the transaction was mined in and replays all transaction mined before it in the block.
function rollFork(bytes32 txHash) external;
rollFork
Updates the given fork to given block number.
function rollFork(uint256 forkId, uint256 blockNumber) external;
rollFork
Updates the given fork to block number of the given transaction and replays all transaction mined before it in the block.
function rollFork(uint256 forkId, bytes32 txHash) external;
selectFork
Takes a fork identifier created by createFork and sets the corresponding forked state as active.
function selectFork(uint256 forkId) external;
setBlockhash
Set blockhash for the current block.
It only sets the blockhash for blocks where block.number - 256 <= number < block.number.
function setBlockhash(uint256 blockNumber, bytes32 blockHash) external;
setNonce
Sets the nonce of an account. Must be higher than the current nonce of the account.
function setNonce(address account, uint64 newNonce) external;
setNonceUnsafe
Sets the nonce of an account to an arbitrary value.
function setNonceUnsafe(address account, uint64 newNonce) external;
snapshotGasLastCall
Snapshot capture the gas usage of the last call by name from the callee perspective.
function snapshotGasLastCall(string calldata name) external returns (uint256 gasUsed);
snapshotGasLastCall
Snapshot capture the gas usage of the last call by name in a group from the callee perspective.
function snapshotGasLastCall(string calldata group, string calldata name) external returns (uint256 gasUsed);
snapshotState
Snapshot the current state of the evm.
Returns the ID of the snapshot that was created.
To revert a snapshot use revertToState.
function snapshotState() external returns (uint256 snapshotId);
snapshotValue
Snapshot capture an arbitrary numerical value by name. The group name is derived from the contract name.
function snapshotValue(string calldata name, uint256 value) external;
snapshotValue
Snapshot capture an arbitrary numerical value by name in a group.
function snapshotValue(string calldata group, string calldata name, uint256 value) external;
startPrank
Sets all subsequent calls' msg.sender to be the input address until stopPrank is called.
function startPrank(address msgSender) external;
startPrank
Sets all subsequent calls' msg.sender to be the input address until stopPrank is called, and the tx.origin to be the second input.
function startPrank(address msgSender, address txOrigin) external;
startPrank
Sets all subsequent delegate calls' msg.sender to be the input address until stopPrank is called.
function startPrank(address msgSender, bool delegateCall) external;
startPrank
Sets all subsequent delegate calls' msg.sender to be the input address until stopPrank is called, and the tx.origin to be the second input.
function startPrank(address msgSender, address txOrigin, bool delegateCall) external;
startSnapshotGas
Start a snapshot capture of the current gas usage by name. The group name is derived from the contract name.
function startSnapshotGas(string calldata name) external;
startSnapshotGas
Start a snapshot capture of the current gas usage by name in a group.
function startSnapshotGas(string calldata group, string calldata name) external;
stopPrank
Resets subsequent calls' msg.sender to be address(this).
function stopPrank() external;
stopSnapshotGas
Stop the snapshot capture of the current gas by latest snapshot name, capturing the gas used since the start.
function stopSnapshotGas() external returns (uint256 gasUsed);
stopSnapshotGas
Stop the snapshot capture of the current gas usage by name, capturing the gas used since the start. The group name is derived from the contract name.
function stopSnapshotGas(string calldata name) external returns (uint256 gasUsed);
stopSnapshotGas
Stop the snapshot capture of the current gas usage by name in a group, capturing the gas used since the start.
function stopSnapshotGas(string calldata group, string calldata name) external returns (uint256 gasUsed);
store
Stores a value to an address' storage slot.
function store(address target, bytes32 slot, bytes32 value) external;
transact
Fetches the given transaction from the active fork and executes it on the current state.
function transact(bytes32 txHash) external;
transact
Fetches the given transaction from the given fork and executes it on the current state.
function transact(uint256 forkId, bytes32 txHash) external;
txGasPrice
Sets tx.gasprice.
function txGasPrice(uint256 newGasPrice) external;
warp
Sets block.timestamp.
function warp(uint256 newTimestamp) external;
deleteSnapshot
deleteSnapshot is being deprecated in favor of deleteStateSnapshot. It will be removed in future versions.
function deleteSnapshot(uint256 snapshotId) external returns (bool success);
deleteSnapshots
deleteSnapshots is being deprecated in favor of deleteStateSnapshots. It will be removed in future versions.
function deleteSnapshots() external;
revertToAndDelete
revertToAndDelete is being deprecated in favor of revertToStateAndDelete. It will be removed in future versions.
function revertToAndDelete(uint256 snapshotId) external returns (bool success);
revertTo
revertTo is being deprecated in favor of revertToState. It will be removed in future versions.
function revertTo(uint256 snapshotId) external returns (bool success);
snapshot
snapshot is being deprecated in favor of snapshotState. It will be removed in future versions.
function snapshot() external returns (uint256 snapshotId);
expectCallMinGas
Expect a call to an address with the specified msg.value and calldata, and a minimum amount of gas.
function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data) external;
expectCallMinGas
Expect given number of calls to an address with the specified msg.value and calldata, and a minimum amount of gas.
function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data, uint64 count)
external;
expectCall
Expects a call to an address with the specified calldata. Calldata can either be a strict or a partial match.
function expectCall(address callee, bytes calldata data) external;
expectCall
Expects given number of calls to an address with the specified calldata.
function expectCall(address callee, bytes calldata data, uint64 count) external;
expectCall
Expects a call to an address with the specified msg.value and calldata.
function expectCall(address callee, uint256 msgValue, bytes calldata data) external;
expectCall
Expects given number of calls to an address with the specified msg.value and calldata.
function expectCall(address callee, uint256 msgValue, bytes calldata data, uint64 count) external;
expectCall
Expect a call to an address with the specified msg.value, gas, and calldata.
function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data) external;
expectCall
Expects given number of calls to an address with the specified msg.value, gas, and calldata.
function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data, uint64 count) external;
expectEmitAnonymous
Prepare an expected anonymous log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData.). Call this function, then emit an anonymous event, then call a function. Internally after the call, we check if logs were emitted in the expected order with the expected topics and data (as specified by the booleans).
function expectEmitAnonymous(bool checkTopic0, bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData)
external;
expectEmitAnonymous
Same as the previous method, but also checks supplied address against emitting contract.
function expectEmitAnonymous(
bool checkTopic0,
bool checkTopic1,
bool checkTopic2,
bool checkTopic3,
bool checkData,
address emitter
) external;
expectEmitAnonymous
Prepare an expected anonymous log with all topic and data checks enabled. Call this function, then emit an anonymous event, then call a function. Internally after the call, we check if logs were emitted in the expected order with the expected topics and data.
function expectEmitAnonymous() external;
expectEmitAnonymous
Same as the previous method, but also checks supplied address against emitting contract.
function expectEmitAnonymous(address emitter) external;
expectEmit
Prepare an expected log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData.). Call this function, then emit an event, then call a function. Internally after the call, we check if logs were emitted in the expected order with the expected topics and data (as specified by the booleans).
function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external;
expectEmit
Same as the previous method, but also checks supplied address against emitting contract.
function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter) external;
expectEmit
Prepare an expected log with all topic and data checks enabled. Call this function, then emit an event, then call a function. Internally after the call, we check if logs were emitted in the expected order with the expected topics and data.
function expectEmit() external;
expectEmit
Same as the previous method, but also checks supplied address against emitting contract.
function expectEmit(address emitter) external;
expectEmit
Expect a given number of logs with the provided topics.
function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, uint64 count) external;
expectEmit
Expect a given number of logs from a specific emitter with the provided topics.
function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter, uint64 count)
external;
expectEmit
Expect a given number of logs with all topic and data checks enabled.
function expectEmit(uint64 count) external;
expectEmit
Expect a given number of logs from a specific emitter with all topic and data checks enabled.
function expectEmit(address emitter, uint64 count) external;
expectPartialRevert
Expects an error on next call that starts with the revert data.
function expectPartialRevert(bytes4 revertData) external;
expectPartialRevert
Expects an error on next call to reverter address, that starts with the revert data.
function expectPartialRevert(bytes4 revertData, address reverter) external;
expectRevert
Expects an error on next call with any revert data.
function expectRevert() external;
expectRevert
Expects an error on next call that exactly matches the revert data.
function expectRevert(bytes4 revertData) external;
expectRevert
Expects a count number of reverts from the upcoming calls from the reverter address that match the revert data.
function expectRevert(bytes4 revertData, address reverter, uint64 count) external;
expectRevert
Expects a count number of reverts from the upcoming calls from the reverter address that exactly match the revert data.
function expectRevert(bytes calldata revertData, address reverter, uint64 count) external;
expectRevert
Expects an error on next call that exactly matches the revert data.
function expectRevert(bytes calldata revertData) external;
expectRevert
Expects an error with any revert data on next call to reverter address.
function expectRevert(address reverter) external;
expectRevert
Expects an error from reverter address on next call, with any revert data.
function expectRevert(bytes4 revertData, address reverter) external;
expectRevert
Expects an error from reverter address on next call, that exactly matches the revert data.
function expectRevert(bytes calldata revertData, address reverter) external;
expectRevert
Expects a count number of reverts from the upcoming calls with any revert data or reverter.
function expectRevert(uint64 count) external;
expectRevert
Expects a count number of reverts from the upcoming calls that match the revert data.
function expectRevert(bytes4 revertData, uint64 count) external;
expectRevert
Expects a count number of reverts from the upcoming calls that exactly match the revert data.
function expectRevert(bytes calldata revertData, uint64 count) external;
expectRevert
Expects a count number of reverts from the upcoming calls from the reverter address.
function expectRevert(address reverter, uint64 count) external;
expectSafeMemory
Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the current subcontext. If any other memory is written to, the test will fail. Can be called multiple times to add more ranges to the set.
function expectSafeMemory(uint64 min, uint64 max) external;
expectSafeMemoryCall
Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the next created subcontext. If any other memory is written to, the test will fail. Can be called multiple times to add more ranges to the set.
function expectSafeMemoryCall(uint64 min, uint64 max) external;
skip
Marks a test as skipped. Must be called at the top level of a test.
function skip(bool skipTest) external;
skip
Marks a test as skipped with a reason. Must be called at the top level of a test.
function skip(bool skipTest, string calldata reason) external;
stopExpectSafeMemory
Stops all safe memory expectation in the current subcontext.
function stopExpectSafeMemory() external;
console
State Variables
CONSOLE_ADDRESS
address constant CONSOLE_ADDRESS = 0x000000000000000000636F6e736F6c652e6c6f67;
Functions
_sendLogPayloadImplementation
function _sendLogPayloadImplementation(bytes memory payload) internal view;
_castToPure
function _castToPure(function(bytes memory) internal view fnIn)
internal
pure
returns (function(bytes memory) pure fnOut);
_sendLogPayload
function _sendLogPayload(bytes memory payload) internal pure;
log
function log() internal pure;
logInt
function logInt(int256 p0) internal pure;
logUint
function logUint(uint256 p0) internal pure;
logString
function logString(string memory p0) internal pure;
logBool
function logBool(bool p0) internal pure;
logAddress
function logAddress(address p0) internal pure;
logBytes
function logBytes(bytes memory p0) internal pure;
logBytes1
function logBytes1(bytes1 p0) internal pure;
logBytes2
function logBytes2(bytes2 p0) internal pure;
logBytes3
function logBytes3(bytes3 p0) internal pure;
logBytes4
function logBytes4(bytes4 p0) internal pure;
logBytes5
function logBytes5(bytes5 p0) internal pure;
logBytes6
function logBytes6(bytes6 p0) internal pure;
logBytes7
function logBytes7(bytes7 p0) internal pure;
logBytes8
function logBytes8(bytes8 p0) internal pure;
logBytes9
function logBytes9(bytes9 p0) internal pure;
logBytes10
function logBytes10(bytes10 p0) internal pure;
logBytes11
function logBytes11(bytes11 p0) internal pure;
logBytes12
function logBytes12(bytes12 p0) internal pure;
logBytes13
function logBytes13(bytes13 p0) internal pure;
logBytes14
function logBytes14(bytes14 p0) internal pure;
logBytes15
function logBytes15(bytes15 p0) internal pure;
logBytes16
function logBytes16(bytes16 p0) internal pure;
logBytes17
function logBytes17(bytes17 p0) internal pure;
logBytes18
function logBytes18(bytes18 p0) internal pure;
logBytes19
function logBytes19(bytes19 p0) internal pure;
logBytes20
function logBytes20(bytes20 p0) internal pure;
logBytes21
function logBytes21(bytes21 p0) internal pure;
logBytes22
function logBytes22(bytes22 p0) internal pure;
logBytes23
function logBytes23(bytes23 p0) internal pure;
logBytes24
function logBytes24(bytes24 p0) internal pure;
logBytes25
function logBytes25(bytes25 p0) internal pure;
logBytes26
function logBytes26(bytes26 p0) internal pure;
logBytes27
function logBytes27(bytes27 p0) internal pure;
logBytes28
function logBytes28(bytes28 p0) internal pure;
logBytes29
function logBytes29(bytes29 p0) internal pure;
logBytes30
function logBytes30(bytes30 p0) internal pure;
logBytes31
function logBytes31(bytes31 p0) internal pure;
logBytes32
function logBytes32(bytes32 p0) internal pure;
log
function log(uint256 p0) internal pure;
log
function log(int256 p0) internal pure;
log
function log(string memory p0) internal pure;
log
function log(bool p0) internal pure;
log
function log(address p0) internal pure;
log
function log(uint256 p0, uint256 p1) internal pure;
log
function log(uint256 p0, string memory p1) internal pure;
log
function log(uint256 p0, bool p1) internal pure;
log
function log(uint256 p0, address p1) internal pure;
log
function log(string memory p0, uint256 p1) internal pure;
log
function log(string memory p0, int256 p1) internal pure;
log
function log(string memory p0, string memory p1) internal pure;
log
function log(string memory p0, bool p1) internal pure;
log
function log(string memory p0, address p1) internal pure;
log
function log(bool p0, uint256 p1) internal pure;
log
function log(bool p0, string memory p1) internal pure;
log
function log(bool p0, bool p1) internal pure;
log
function log(bool p0, address p1) internal pure;
log
function log(address p0, uint256 p1) internal pure;
log
function log(address p0, string memory p1) internal pure;
log
function log(address p0, bool p1) internal pure;
log
function log(address p0, address p1) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2) internal pure;
log
function log(uint256 p0, uint256 p1, string memory p2) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2) internal pure;
log
function log(uint256 p0, uint256 p1, address p2) internal pure;
log
function log(uint256 p0, string memory p1, uint256 p2) internal pure;
log
function log(uint256 p0, string memory p1, string memory p2) internal pure;
log
function log(uint256 p0, string memory p1, bool p2) internal pure;
log
function log(uint256 p0, string memory p1, address p2) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2) internal pure;
log
function log(uint256 p0, bool p1, string memory p2) internal pure;
log
function log(uint256 p0, bool p1, bool p2) internal pure;
log
function log(uint256 p0, bool p1, address p2) internal pure;
log
function log(uint256 p0, address p1, uint256 p2) internal pure;
log
function log(uint256 p0, address p1, string memory p2) internal pure;
log
function log(uint256 p0, address p1, bool p2) internal pure;
log
function log(uint256 p0, address p1, address p2) internal pure;
log
function log(string memory p0, uint256 p1, uint256 p2) internal pure;
log
function log(string memory p0, uint256 p1, string memory p2) internal pure;
log
function log(string memory p0, uint256 p1, bool p2) internal pure;
log
function log(string memory p0, uint256 p1, address p2) internal pure;
log
function log(string memory p0, string memory p1, uint256 p2) internal pure;
log
function log(string memory p0, string memory p1, string memory p2) internal pure;
log
function log(string memory p0, string memory p1, bool p2) internal pure;
log
function log(string memory p0, string memory p1, address p2) internal pure;
log
function log(string memory p0, bool p1, uint256 p2) internal pure;
log
function log(string memory p0, bool p1, string memory p2) internal pure;
log
function log(string memory p0, bool p1, bool p2) internal pure;
log
function log(string memory p0, bool p1, address p2) internal pure;
log
function log(string memory p0, address p1, uint256 p2) internal pure;
log
function log(string memory p0, address p1, string memory p2) internal pure;
log
function log(string memory p0, address p1, bool p2) internal pure;
log
function log(string memory p0, address p1, address p2) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2) internal pure;
log
function log(bool p0, uint256 p1, string memory p2) internal pure;
log
function log(bool p0, uint256 p1, bool p2) internal pure;
log
function log(bool p0, uint256 p1, address p2) internal pure;
log
function log(bool p0, string memory p1, uint256 p2) internal pure;
log
function log(bool p0, string memory p1, string memory p2) internal pure;
log
function log(bool p0, string memory p1, bool p2) internal pure;
log
function log(bool p0, string memory p1, address p2) internal pure;
log
function log(bool p0, bool p1, uint256 p2) internal pure;
log
function log(bool p0, bool p1, string memory p2) internal pure;
log
function log(bool p0, bool p1, bool p2) internal pure;
log
function log(bool p0, bool p1, address p2) internal pure;
log
function log(bool p0, address p1, uint256 p2) internal pure;
log
function log(bool p0, address p1, string memory p2) internal pure;
log
function log(bool p0, address p1, bool p2) internal pure;
log
function log(bool p0, address p1, address p2) internal pure;
log
function log(address p0, uint256 p1, uint256 p2) internal pure;
log
function log(address p0, uint256 p1, string memory p2) internal pure;
log
function log(address p0, uint256 p1, bool p2) internal pure;
log
function log(address p0, uint256 p1, address p2) internal pure;
log
function log(address p0, string memory p1, uint256 p2) internal pure;
log
function log(address p0, string memory p1, string memory p2) internal pure;
log
function log(address p0, string memory p1, bool p2) internal pure;
log
function log(address p0, string memory p1, address p2) internal pure;
log
function log(address p0, bool p1, uint256 p2) internal pure;
log
function log(address p0, bool p1, string memory p2) internal pure;
log
function log(address p0, bool p1, bool p2) internal pure;
log
function log(address p0, bool p1, address p2) internal pure;
log
function log(address p0, address p1, uint256 p2) internal pure;
log
function log(address p0, address p1, string memory p2) internal pure;
log
function log(address p0, address p1, bool p2) internal pure;
log
function log(address p0, address p1, address p2) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2, uint256 p3) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2, string memory p3) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2, bool p3) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2, address p3) internal pure;
log
function log(uint256 p0, uint256 p1, string memory p2, uint256 p3) internal pure;
log
function log(uint256 p0, uint256 p1, string memory p2, string memory p3) internal pure;
log
function log(uint256 p0, uint256 p1, string memory p2, bool p3) internal pure;
log
function log(uint256 p0, uint256 p1, string memory p2, address p3) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2, uint256 p3) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2, string memory p3) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2, bool p3) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2, address p3) internal pure;
log
function log(uint256 p0, uint256 p1, address p2, uint256 p3) internal pure;
log
function log(uint256 p0, uint256 p1, address p2, string memory p3) internal pure;
log
function log(uint256 p0, uint256 p1, address p2, bool p3) internal pure;
log
function log(uint256 p0, uint256 p1, address p2, address p3) internal pure;
log
function log(uint256 p0, string memory p1, uint256 p2, uint256 p3) internal pure;
log
function log(uint256 p0, string memory p1, uint256 p2, string memory p3) internal pure;
log
function log(uint256 p0, string memory p1, uint256 p2, bool p3) internal pure;
log
function log(uint256 p0, string memory p1, uint256 p2, address p3) internal pure;
log
function log(uint256 p0, string memory p1, string memory p2, uint256 p3) internal pure;
log
function log(uint256 p0, string memory p1, string memory p2, string memory p3) internal pure;
log
function log(uint256 p0, string memory p1, string memory p2, bool p3) internal pure;
log
function log(uint256 p0, string memory p1, string memory p2, address p3) internal pure;
log
function log(uint256 p0, string memory p1, bool p2, uint256 p3) internal pure;
log
function log(uint256 p0, string memory p1, bool p2, string memory p3) internal pure;
log
function log(uint256 p0, string memory p1, bool p2, bool p3) internal pure;
log
function log(uint256 p0, string memory p1, bool p2, address p3) internal pure;
log
function log(uint256 p0, string memory p1, address p2, uint256 p3) internal pure;
log
function log(uint256 p0, string memory p1, address p2, string memory p3) internal pure;
log
function log(uint256 p0, string memory p1, address p2, bool p3) internal pure;
log
function log(uint256 p0, string memory p1, address p2, address p3) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2, uint256 p3) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2, string memory p3) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2, bool p3) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2, address p3) internal pure;
log
function log(uint256 p0, bool p1, string memory p2, uint256 p3) internal pure;
log
function log(uint256 p0, bool p1, string memory p2, string memory p3) internal pure;
log
function log(uint256 p0, bool p1, string memory p2, bool p3) internal pure;
log
function log(uint256 p0, bool p1, string memory p2, address p3) internal pure;
log
function log(uint256 p0, bool p1, bool p2, uint256 p3) internal pure;
log
function log(uint256 p0, bool p1, bool p2, string memory p3) internal pure;
log
function log(uint256 p0, bool p1, bool p2, bool p3) internal pure;
log
function log(uint256 p0, bool p1, bool p2, address p3) internal pure;
log
function log(uint256 p0, bool p1, address p2, uint256 p3) internal pure;
log
function log(uint256 p0, bool p1, address p2, string memory p3) internal pure;
log
function log(uint256 p0, bool p1, address p2, bool p3) internal pure;
log
function log(uint256 p0, bool p1, address p2, address p3) internal pure;
log
function log(uint256 p0, address p1, uint256 p2, uint256 p3) internal pure;
log
function log(uint256 p0, address p1, uint256 p2, string memory p3) internal pure;
log
function log(uint256 p0, address p1, uint256 p2, bool p3) internal pure;
log
function log(uint256 p0, address p1, uint256 p2, address p3) internal pure;
log
function log(uint256 p0, address p1, string memory p2, uint256 p3) internal pure;
log
function log(uint256 p0, address p1, string memory p2, string memory p3) internal pure;
log
function log(uint256 p0, address p1, string memory p2, bool p3) internal pure;
log
function log(uint256 p0, address p1, string memory p2, address p3) internal pure;
log
function log(uint256 p0, address p1, bool p2, uint256 p3) internal pure;
log
function log(uint256 p0, address p1, bool p2, string memory p3) internal pure;
log
function log(uint256 p0, address p1, bool p2, bool p3) internal pure;
log
function log(uint256 p0, address p1, bool p2, address p3) internal pure;
log
function log(uint256 p0, address p1, address p2, uint256 p3) internal pure;
log
function log(uint256 p0, address p1, address p2, string memory p3) internal pure;
log
function log(uint256 p0, address p1, address p2, bool p3) internal pure;
log
function log(uint256 p0, address p1, address p2, address p3) internal pure;
log
function log(string memory p0, uint256 p1, uint256 p2, uint256 p3) internal pure;
log
function log(string memory p0, uint256 p1, uint256 p2, string memory p3) internal pure;
log
function log(string memory p0, uint256 p1, uint256 p2, bool p3) internal pure;
log
function log(string memory p0, uint256 p1, uint256 p2, address p3) internal pure;
log
function log(string memory p0, uint256 p1, string memory p2, uint256 p3) internal pure;
log
function log(string memory p0, uint256 p1, string memory p2, string memory p3) internal pure;
log
function log(string memory p0, uint256 p1, string memory p2, bool p3) internal pure;
log
function log(string memory p0, uint256 p1, string memory p2, address p3) internal pure;
log
function log(string memory p0, uint256 p1, bool p2, uint256 p3) internal pure;
log
function log(string memory p0, uint256 p1, bool p2, string memory p3) internal pure;
log
function log(string memory p0, uint256 p1, bool p2, bool p3) internal pure;
log
function log(string memory p0, uint256 p1, bool p2, address p3) internal pure;
log
function log(string memory p0, uint256 p1, address p2, uint256 p3) internal pure;
log
function log(string memory p0, uint256 p1, address p2, string memory p3) internal pure;
log
function log(string memory p0, uint256 p1, address p2, bool p3) internal pure;
log
function log(string memory p0, uint256 p1, address p2, address p3) internal pure;
log
function log(string memory p0, string memory p1, uint256 p2, uint256 p3) internal pure;
log
function log(string memory p0, string memory p1, uint256 p2, string memory p3) internal pure;
log
function log(string memory p0, string memory p1, uint256 p2, bool p3) internal pure;
log
function log(string memory p0, string memory p1, uint256 p2, address p3) internal pure;
log
function log(string memory p0, string memory p1, string memory p2, uint256 p3) internal pure;
log
function log(string memory p0, string memory p1, string memory p2, string memory p3) internal pure;
log
function log(string memory p0, string memory p1, string memory p2, bool p3) internal pure;
log
function log(string memory p0, string memory p1, string memory p2, address p3) internal pure;
log
function log(string memory p0, string memory p1, bool p2, uint256 p3) internal pure;
log
function log(string memory p0, string memory p1, bool p2, string memory p3) internal pure;
log
function log(string memory p0, string memory p1, bool p2, bool p3) internal pure;
log
function log(string memory p0, string memory p1, bool p2, address p3) internal pure;
log
function log(string memory p0, string memory p1, address p2, uint256 p3) internal pure;
log
function log(string memory p0, string memory p1, address p2, string memory p3) internal pure;
log
function log(string memory p0, string memory p1, address p2, bool p3) internal pure;
log
function log(string memory p0, string memory p1, address p2, address p3) internal pure;
log
function log(string memory p0, bool p1, uint256 p2, uint256 p3) internal pure;
log
function log(string memory p0, bool p1, uint256 p2, string memory p3) internal pure;
log
function log(string memory p0, bool p1, uint256 p2, bool p3) internal pure;
log
function log(string memory p0, bool p1, uint256 p2, address p3) internal pure;
log
function log(string memory p0, bool p1, string memory p2, uint256 p3) internal pure;
log
function log(string memory p0, bool p1, string memory p2, string memory p3) internal pure;
log
function log(string memory p0, bool p1, string memory p2, bool p3) internal pure;
log
function log(string memory p0, bool p1, string memory p2, address p3) internal pure;
log
function log(string memory p0, bool p1, bool p2, uint256 p3) internal pure;
log
function log(string memory p0, bool p1, bool p2, string memory p3) internal pure;
log
function log(string memory p0, bool p1, bool p2, bool p3) internal pure;
log
function log(string memory p0, bool p1, bool p2, address p3) internal pure;
log
function log(string memory p0, bool p1, address p2, uint256 p3) internal pure;
log
function log(string memory p0, bool p1, address p2, string memory p3) internal pure;
log
function log(string memory p0, bool p1, address p2, bool p3) internal pure;
log
function log(string memory p0, bool p1, address p2, address p3) internal pure;
log
function log(string memory p0, address p1, uint256 p2, uint256 p3) internal pure;
log
function log(string memory p0, address p1, uint256 p2, string memory p3) internal pure;
log
function log(string memory p0, address p1, uint256 p2, bool p3) internal pure;
log
function log(string memory p0, address p1, uint256 p2, address p3) internal pure;
log
function log(string memory p0, address p1, string memory p2, uint256 p3) internal pure;
log
function log(string memory p0, address p1, string memory p2, string memory p3) internal pure;
log
function log(string memory p0, address p1, string memory p2, bool p3) internal pure;
log
function log(string memory p0, address p1, string memory p2, address p3) internal pure;
log
function log(string memory p0, address p1, bool p2, uint256 p3) internal pure;
log
function log(string memory p0, address p1, bool p2, string memory p3) internal pure;
log
function log(string memory p0, address p1, bool p2, bool p3) internal pure;
log
function log(string memory p0, address p1, bool p2, address p3) internal pure;
log
function log(string memory p0, address p1, address p2, uint256 p3) internal pure;
log
function log(string memory p0, address p1, address p2, string memory p3) internal pure;
log
function log(string memory p0, address p1, address p2, bool p3) internal pure;
log
function log(string memory p0, address p1, address p2, address p3) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2, uint256 p3) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2, string memory p3) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2, bool p3) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2, address p3) internal pure;
log
function log(bool p0, uint256 p1, string memory p2, uint256 p3) internal pure;
log
function log(bool p0, uint256 p1, string memory p2, string memory p3) internal pure;
log
function log(bool p0, uint256 p1, string memory p2, bool p3) internal pure;
log
function log(bool p0, uint256 p1, string memory p2, address p3) internal pure;
log
function log(bool p0, uint256 p1, bool p2, uint256 p3) internal pure;
log
function log(bool p0, uint256 p1, bool p2, string memory p3) internal pure;
log
function log(bool p0, uint256 p1, bool p2, bool p3) internal pure;
log
function log(bool p0, uint256 p1, bool p2, address p3) internal pure;
log
function log(bool p0, uint256 p1, address p2, uint256 p3) internal pure;
log
function log(bool p0, uint256 p1, address p2, string memory p3) internal pure;
log
function log(bool p0, uint256 p1, address p2, bool p3) internal pure;
log
function log(bool p0, uint256 p1, address p2, address p3) internal pure;
log
function log(bool p0, string memory p1, uint256 p2, uint256 p3) internal pure;
log
function log(bool p0, string memory p1, uint256 p2, string memory p3) internal pure;
log
function log(bool p0, string memory p1, uint256 p2, bool p3) internal pure;
log
function log(bool p0, string memory p1, uint256 p2, address p3) internal pure;
log
function log(bool p0, string memory p1, string memory p2, uint256 p3) internal pure;
log
function log(bool p0, string memory p1, string memory p2, string memory p3) internal pure;
log
function log(bool p0, string memory p1, string memory p2, bool p3) internal pure;
log
function log(bool p0, string memory p1, string memory p2, address p3) internal pure;
log
function log(bool p0, string memory p1, bool p2, uint256 p3) internal pure;
log
function log(bool p0, string memory p1, bool p2, string memory p3) internal pure;
log
function log(bool p0, string memory p1, bool p2, bool p3) internal pure;
log
function log(bool p0, string memory p1, bool p2, address p3) internal pure;
log
function log(bool p0, string memory p1, address p2, uint256 p3) internal pure;
log
function log(bool p0, string memory p1, address p2, string memory p3) internal pure;
log
function log(bool p0, string memory p1, address p2, bool p3) internal pure;
log
function log(bool p0, string memory p1, address p2, address p3) internal pure;
log
function log(bool p0, bool p1, uint256 p2, uint256 p3) internal pure;
log
function log(bool p0, bool p1, uint256 p2, string memory p3) internal pure;
log
function log(bool p0, bool p1, uint256 p2, bool p3) internal pure;
log
function log(bool p0, bool p1, uint256 p2, address p3) internal pure;
log
function log(bool p0, bool p1, string memory p2, uint256 p3) internal pure;
log
function log(bool p0, bool p1, string memory p2, string memory p3) internal pure;
log
function log(bool p0, bool p1, string memory p2, bool p3) internal pure;
log
function log(bool p0, bool p1, string memory p2, address p3) internal pure;
log
function log(bool p0, bool p1, bool p2, uint256 p3) internal pure;
log
function log(bool p0, bool p1, bool p2, string memory p3) internal pure;
log
function log(bool p0, bool p1, bool p2, bool p3) internal pure;
log
function log(bool p0, bool p1, bool p2, address p3) internal pure;
log
function log(bool p0, bool p1, address p2, uint256 p3) internal pure;
log
function log(bool p0, bool p1, address p2, string memory p3) internal pure;
log
function log(bool p0, bool p1, address p2, bool p3) internal pure;
log
function log(bool p0, bool p1, address p2, address p3) internal pure;
log
function log(bool p0, address p1, uint256 p2, uint256 p3) internal pure;
log
function log(bool p0, address p1, uint256 p2, string memory p3) internal pure;
log
function log(bool p0, address p1, uint256 p2, bool p3) internal pure;
log
function log(bool p0, address p1, uint256 p2, address p3) internal pure;
log
function log(bool p0, address p1, string memory p2, uint256 p3) internal pure;
log
function log(bool p0, address p1, string memory p2, string memory p3) internal pure;
log
function log(bool p0, address p1, string memory p2, bool p3) internal pure;
log
function log(bool p0, address p1, string memory p2, address p3) internal pure;
log
function log(bool p0, address p1, bool p2, uint256 p3) internal pure;
log
function log(bool p0, address p1, bool p2, string memory p3) internal pure;
log
function log(bool p0, address p1, bool p2, bool p3) internal pure;
log
function log(bool p0, address p1, bool p2, address p3) internal pure;
log
function log(bool p0, address p1, address p2, uint256 p3) internal pure;
log
function log(bool p0, address p1, address p2, string memory p3) internal pure;
log
function log(bool p0, address p1, address p2, bool p3) internal pure;
log
function log(bool p0, address p1, address p2, address p3) internal pure;
log
function log(address p0, uint256 p1, uint256 p2, uint256 p3) internal pure;
log
function log(address p0, uint256 p1, uint256 p2, string memory p3) internal pure;
log
function log(address p0, uint256 p1, uint256 p2, bool p3) internal pure;
log
function log(address p0, uint256 p1, uint256 p2, address p3) internal pure;
log
function log(address p0, uint256 p1, string memory p2, uint256 p3) internal pure;
log
function log(address p0, uint256 p1, string memory p2, string memory p3) internal pure;
log
function log(address p0, uint256 p1, string memory p2, bool p3) internal pure;
log
function log(address p0, uint256 p1, string memory p2, address p3) internal pure;
log
function log(address p0, uint256 p1, bool p2, uint256 p3) internal pure;
log
function log(address p0, uint256 p1, bool p2, string memory p3) internal pure;
log
function log(address p0, uint256 p1, bool p2, bool p3) internal pure;
log
function log(address p0, uint256 p1, bool p2, address p3) internal pure;
log
function log(address p0, uint256 p1, address p2, uint256 p3) internal pure;
log
function log(address p0, uint256 p1, address p2, string memory p3) internal pure;
log
function log(address p0, uint256 p1, address p2, bool p3) internal pure;
log
function log(address p0, uint256 p1, address p2, address p3) internal pure;
log
function log(address p0, string memory p1, uint256 p2, uint256 p3) internal pure;
log
function log(address p0, string memory p1, uint256 p2, string memory p3) internal pure;
log
function log(address p0, string memory p1, uint256 p2, bool p3) internal pure;
log
function log(address p0, string memory p1, uint256 p2, address p3) internal pure;
log
function log(address p0, string memory p1, string memory p2, uint256 p3) internal pure;
log
function log(address p0, string memory p1, string memory p2, string memory p3) internal pure;
log
function log(address p0, string memory p1, string memory p2, bool p3) internal pure;
log
function log(address p0, string memory p1, string memory p2, address p3) internal pure;
log
function log(address p0, string memory p1, bool p2, uint256 p3) internal pure;
log
function log(address p0, string memory p1, bool p2, string memory p3) internal pure;
log
function log(address p0, string memory p1, bool p2, bool p3) internal pure;
log
function log(address p0, string memory p1, bool p2, address p3) internal pure;
log
function log(address p0, string memory p1, address p2, uint256 p3) internal pure;
log
function log(address p0, string memory p1, address p2, string memory p3) internal pure;
log
function log(address p0, string memory p1, address p2, bool p3) internal pure;
log
function log(address p0, string memory p1, address p2, address p3) internal pure;
log
function log(address p0, bool p1, uint256 p2, uint256 p3) internal pure;
log
function log(address p0, bool p1, uint256 p2, string memory p3) internal pure;
log
function log(address p0, bool p1, uint256 p2, bool p3) internal pure;
log
function log(address p0, bool p1, uint256 p2, address p3) internal pure;
log
function log(address p0, bool p1, string memory p2, uint256 p3) internal pure;
log
function log(address p0, bool p1, string memory p2, string memory p3) internal pure;
log
function log(address p0, bool p1, string memory p2, bool p3) internal pure;
log
function log(address p0, bool p1, string memory p2, address p3) internal pure;
log
function log(address p0, bool p1, bool p2, uint256 p3) internal pure;
log
function log(address p0, bool p1, bool p2, string memory p3) internal pure;
log
function log(address p0, bool p1, bool p2, bool p3) internal pure;
log
function log(address p0, bool p1, bool p2, address p3) internal pure;
log
function log(address p0, bool p1, address p2, uint256 p3) internal pure;
log
function log(address p0, bool p1, address p2, string memory p3) internal pure;
log
function log(address p0, bool p1, address p2, bool p3) internal pure;
log
function log(address p0, bool p1, address p2, address p3) internal pure;
log
function log(address p0, address p1, uint256 p2, uint256 p3) internal pure;
log
function log(address p0, address p1, uint256 p2, string memory p3) internal pure;
log
function log(address p0, address p1, uint256 p2, bool p3) internal pure;
log
function log(address p0, address p1, uint256 p2, address p3) internal pure;
log
function log(address p0, address p1, string memory p2, uint256 p3) internal pure;
log
function log(address p0, address p1, string memory p2, string memory p3) internal pure;
log
function log(address p0, address p1, string memory p2, bool p3) internal pure;
log
function log(address p0, address p1, string memory p2, address p3) internal pure;
log
function log(address p0, address p1, bool p2, uint256 p3) internal pure;
log
function log(address p0, address p1, bool p2, string memory p3) internal pure;
log
function log(address p0, address p1, bool p2, bool p3) internal pure;
log
function log(address p0, address p1, bool p2, address p3) internal pure;
log
function log(address p0, address p1, address p2, uint256 p3) internal pure;
log
function log(address p0, address p1, address p2, string memory p3) internal pure;
log
function log(address p0, address p1, address p2, bool p3) internal pure;
log
function log(address p0, address p1, address p2, address p3) internal pure;
safeconsole
Author: philogy https://github.com/philogy
Code generated automatically by script.
State Variables
CONSOLE_ADDR
uint256 constant CONSOLE_ADDR = 0x000000000000000000000000000000000000000000636F6e736F6c652e6c6f67;
Functions
_sendLogPayload
function _sendLogPayload(uint256 offset, uint256 size) private pure;
_sendLogPayloadView
function _sendLogPayloadView(uint256 offset, uint256 size) private view;
_memcopy
function _memcopy(uint256 fromOffset, uint256 toOffset, uint256 length) private pure;
_memcopyView
function _memcopyView(uint256 fromOffset, uint256 toOffset, uint256 length) private view;
logMemory
function logMemory(uint256 offset, uint256 length) internal pure;
log
function log(address p0) internal pure;
log
function log(bool p0) internal pure;
log
function log(uint256 p0) internal pure;
log
function log(bytes32 p0) internal pure;
log
function log(address p0, address p1) internal pure;
log
function log(address p0, bool p1) internal pure;
log
function log(address p0, uint256 p1) internal pure;
log
function log(address p0, bytes32 p1) internal pure;
log
function log(bool p0, address p1) internal pure;
log
function log(bool p0, bool p1) internal pure;
log
function log(bool p0, uint256 p1) internal pure;
log
function log(bool p0, bytes32 p1) internal pure;
log
function log(uint256 p0, address p1) internal pure;
log
function log(uint256 p0, bool p1) internal pure;
log
function log(uint256 p0, uint256 p1) internal pure;
log
function log(uint256 p0, bytes32 p1) internal pure;
log
function log(bytes32 p0, address p1) internal pure;
log
function log(bytes32 p0, bool p1) internal pure;
log
function log(bytes32 p0, uint256 p1) internal pure;
log
function log(bytes32 p0, bytes32 p1) internal pure;
log
function log(address p0, address p1, address p2) internal pure;
log
function log(address p0, address p1, bool p2) internal pure;
log
function log(address p0, address p1, uint256 p2) internal pure;
log
function log(address p0, address p1, bytes32 p2) internal pure;
log
function log(address p0, bool p1, address p2) internal pure;
log
function log(address p0, bool p1, bool p2) internal pure;
log
function log(address p0, bool p1, uint256 p2) internal pure;
log
function log(address p0, bool p1, bytes32 p2) internal pure;
log
function log(address p0, uint256 p1, address p2) internal pure;
log
function log(address p0, uint256 p1, bool p2) internal pure;
log
function log(address p0, uint256 p1, uint256 p2) internal pure;
log
function log(address p0, uint256 p1, bytes32 p2) internal pure;
log
function log(address p0, bytes32 p1, address p2) internal pure;
log
function log(address p0, bytes32 p1, bool p2) internal pure;
log
function log(address p0, bytes32 p1, uint256 p2) internal pure;
log
function log(address p0, bytes32 p1, bytes32 p2) internal pure;
log
function log(bool p0, address p1, address p2) internal pure;
log
function log(bool p0, address p1, bool p2) internal pure;
log
function log(bool p0, address p1, uint256 p2) internal pure;
log
function log(bool p0, address p1, bytes32 p2) internal pure;
log
function log(bool p0, bool p1, address p2) internal pure;
log
function log(bool p0, bool p1, bool p2) internal pure;
log
function log(bool p0, bool p1, uint256 p2) internal pure;
log
function log(bool p0, bool p1, bytes32 p2) internal pure;
log
function log(bool p0, uint256 p1, address p2) internal pure;
log
function log(bool p0, uint256 p1, bool p2) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2) internal pure;
log
function log(bool p0, uint256 p1, bytes32 p2) internal pure;
log
function log(bool p0, bytes32 p1, address p2) internal pure;
log
function log(bool p0, bytes32 p1, bool p2) internal pure;
log
function log(bool p0, bytes32 p1, uint256 p2) internal pure;
log
function log(bool p0, bytes32 p1, bytes32 p2) internal pure;
log
function log(uint256 p0, address p1, address p2) internal pure;
log
function log(uint256 p0, address p1, bool p2) internal pure;
log
function log(uint256 p0, address p1, uint256 p2) internal pure;
log
function log(uint256 p0, address p1, bytes32 p2) internal pure;
log
function log(uint256 p0, bool p1, address p2) internal pure;
log
function log(uint256 p0, bool p1, bool p2) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2) internal pure;
log
function log(uint256 p0, bool p1, bytes32 p2) internal pure;
log
function log(uint256 p0, uint256 p1, address p2) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2) internal pure;
log
function log(uint256 p0, uint256 p1, bytes32 p2) internal pure;
log
function log(uint256 p0, bytes32 p1, address p2) internal pure;
log
function log(uint256 p0, bytes32 p1, bool p2) internal pure;
log
function log(uint256 p0, bytes32 p1, uint256 p2) internal pure;
log
function log(uint256 p0, bytes32 p1, bytes32 p2) internal pure;
log
function log(bytes32 p0, address p1, address p2) internal pure;
log
function log(bytes32 p0, address p1, bool p2) internal pure;
log
function log(bytes32 p0, address p1, uint256 p2) internal pure;
log
function log(bytes32 p0, address p1, bytes32 p2) internal pure;
log
function log(bytes32 p0, bool p1, address p2) internal pure;
log
function log(bytes32 p0, bool p1, bool p2) internal pure;
log
function log(bytes32 p0, bool p1, uint256 p2) internal pure;
log
function log(bytes32 p0, bool p1, bytes32 p2) internal pure;
log
function log(bytes32 p0, uint256 p1, address p2) internal pure;
log
function log(bytes32 p0, uint256 p1, bool p2) internal pure;
log
function log(bytes32 p0, uint256 p1, uint256 p2) internal pure;
log
function log(bytes32 p0, uint256 p1, bytes32 p2) internal pure;
log
function log(bytes32 p0, bytes32 p1, address p2) internal pure;
log
function log(bytes32 p0, bytes32 p1, bool p2) internal pure;
log
function log(bytes32 p0, bytes32 p1, uint256 p2) internal pure;
log
function log(bytes32 p0, bytes32 p1, bytes32 p2) internal pure;
log
function log(address p0, address p1, address p2, address p3) internal pure;
log
function log(address p0, address p1, address p2, bool p3) internal pure;
log
function log(address p0, address p1, address p2, uint256 p3) internal pure;
log
function log(address p0, address p1, address p2, bytes32 p3) internal pure;
log
function log(address p0, address p1, bool p2, address p3) internal pure;
log
function log(address p0, address p1, bool p2, bool p3) internal pure;
log
function log(address p0, address p1, bool p2, uint256 p3) internal pure;
log
function log(address p0, address p1, bool p2, bytes32 p3) internal pure;
log
function log(address p0, address p1, uint256 p2, address p3) internal pure;
log
function log(address p0, address p1, uint256 p2, bool p3) internal pure;
log
function log(address p0, address p1, uint256 p2, uint256 p3) internal pure;
log
function log(address p0, address p1, uint256 p2, bytes32 p3) internal pure;
log
function log(address p0, address p1, bytes32 p2, address p3) internal pure;
log
function log(address p0, address p1, bytes32 p2, bool p3) internal pure;
log
function log(address p0, address p1, bytes32 p2, uint256 p3) internal pure;
log
function log(address p0, address p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(address p0, bool p1, address p2, address p3) internal pure;
log
function log(address p0, bool p1, address p2, bool p3) internal pure;
log
function log(address p0, bool p1, address p2, uint256 p3) internal pure;
log
function log(address p0, bool p1, address p2, bytes32 p3) internal pure;
log
function log(address p0, bool p1, bool p2, address p3) internal pure;
log
function log(address p0, bool p1, bool p2, bool p3) internal pure;
log
function log(address p0, bool p1, bool p2, uint256 p3) internal pure;
log
function log(address p0, bool p1, bool p2, bytes32 p3) internal pure;
log
function log(address p0, bool p1, uint256 p2, address p3) internal pure;
log
function log(address p0, bool p1, uint256 p2, bool p3) internal pure;
log
function log(address p0, bool p1, uint256 p2, uint256 p3) internal pure;
log
function log(address p0, bool p1, uint256 p2, bytes32 p3) internal pure;
log
function log(address p0, bool p1, bytes32 p2, address p3) internal pure;
log
function log(address p0, bool p1, bytes32 p2, bool p3) internal pure;
log
function log(address p0, bool p1, bytes32 p2, uint256 p3) internal pure;
log
function log(address p0, bool p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(address p0, uint256 p1, address p2, address p3) internal pure;
log
function log(address p0, uint256 p1, address p2, bool p3) internal pure;
log
function log(address p0, uint256 p1, address p2, uint256 p3) internal pure;
log
function log(address p0, uint256 p1, address p2, bytes32 p3) internal pure;
log
function log(address p0, uint256 p1, bool p2, address p3) internal pure;
log
function log(address p0, uint256 p1, bool p2, bool p3) internal pure;
log
function log(address p0, uint256 p1, bool p2, uint256 p3) internal pure;
log
function log(address p0, uint256 p1, bool p2, bytes32 p3) internal pure;
log
function log(address p0, uint256 p1, uint256 p2, address p3) internal pure;
log
function log(address p0, uint256 p1, uint256 p2, bool p3) internal pure;
log
function log(address p0, uint256 p1, uint256 p2, uint256 p3) internal pure;
log
function log(address p0, uint256 p1, uint256 p2, bytes32 p3) internal pure;
log
function log(address p0, uint256 p1, bytes32 p2, address p3) internal pure;
log
function log(address p0, uint256 p1, bytes32 p2, bool p3) internal pure;
log
function log(address p0, uint256 p1, bytes32 p2, uint256 p3) internal pure;
log
function log(address p0, uint256 p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(address p0, bytes32 p1, address p2, address p3) internal pure;
log
function log(address p0, bytes32 p1, address p2, bool p3) internal pure;
log
function log(address p0, bytes32 p1, address p2, uint256 p3) internal pure;
log
function log(address p0, bytes32 p1, address p2, bytes32 p3) internal pure;
log
function log(address p0, bytes32 p1, bool p2, address p3) internal pure;
log
function log(address p0, bytes32 p1, bool p2, bool p3) internal pure;
log
function log(address p0, bytes32 p1, bool p2, uint256 p3) internal pure;
log
function log(address p0, bytes32 p1, bool p2, bytes32 p3) internal pure;
log
function log(address p0, bytes32 p1, uint256 p2, address p3) internal pure;
log
function log(address p0, bytes32 p1, uint256 p2, bool p3) internal pure;
log
function log(address p0, bytes32 p1, uint256 p2, uint256 p3) internal pure;
log
function log(address p0, bytes32 p1, uint256 p2, bytes32 p3) internal pure;
log
function log(address p0, bytes32 p1, bytes32 p2, address p3) internal pure;
log
function log(address p0, bytes32 p1, bytes32 p2, bool p3) internal pure;
log
function log(address p0, bytes32 p1, bytes32 p2, uint256 p3) internal pure;
log
function log(address p0, bytes32 p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(bool p0, address p1, address p2, address p3) internal pure;
log
function log(bool p0, address p1, address p2, bool p3) internal pure;
log
function log(bool p0, address p1, address p2, uint256 p3) internal pure;
log
function log(bool p0, address p1, address p2, bytes32 p3) internal pure;
log
function log(bool p0, address p1, bool p2, address p3) internal pure;
log
function log(bool p0, address p1, bool p2, bool p3) internal pure;
log
function log(bool p0, address p1, bool p2, uint256 p3) internal pure;
log
function log(bool p0, address p1, bool p2, bytes32 p3) internal pure;
log
function log(bool p0, address p1, uint256 p2, address p3) internal pure;
log
function log(bool p0, address p1, uint256 p2, bool p3) internal pure;
log
function log(bool p0, address p1, uint256 p2, uint256 p3) internal pure;
log
function log(bool p0, address p1, uint256 p2, bytes32 p3) internal pure;
log
function log(bool p0, address p1, bytes32 p2, address p3) internal pure;
log
function log(bool p0, address p1, bytes32 p2, bool p3) internal pure;
log
function log(bool p0, address p1, bytes32 p2, uint256 p3) internal pure;
log
function log(bool p0, address p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(bool p0, bool p1, address p2, address p3) internal pure;
log
function log(bool p0, bool p1, address p2, bool p3) internal pure;
log
function log(bool p0, bool p1, address p2, uint256 p3) internal pure;
log
function log(bool p0, bool p1, address p2, bytes32 p3) internal pure;
log
function log(bool p0, bool p1, bool p2, address p3) internal pure;
log
function log(bool p0, bool p1, bool p2, bool p3) internal pure;
log
function log(bool p0, bool p1, bool p2, uint256 p3) internal pure;
log
function log(bool p0, bool p1, bool p2, bytes32 p3) internal pure;
log
function log(bool p0, bool p1, uint256 p2, address p3) internal pure;
log
function log(bool p0, bool p1, uint256 p2, bool p3) internal pure;
log
function log(bool p0, bool p1, uint256 p2, uint256 p3) internal pure;
log
function log(bool p0, bool p1, uint256 p2, bytes32 p3) internal pure;
log
function log(bool p0, bool p1, bytes32 p2, address p3) internal pure;
log
function log(bool p0, bool p1, bytes32 p2, bool p3) internal pure;
log
function log(bool p0, bool p1, bytes32 p2, uint256 p3) internal pure;
log
function log(bool p0, bool p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(bool p0, uint256 p1, address p2, address p3) internal pure;
log
function log(bool p0, uint256 p1, address p2, bool p3) internal pure;
log
function log(bool p0, uint256 p1, address p2, uint256 p3) internal pure;
log
function log(bool p0, uint256 p1, address p2, bytes32 p3) internal pure;
log
function log(bool p0, uint256 p1, bool p2, address p3) internal pure;
log
function log(bool p0, uint256 p1, bool p2, bool p3) internal pure;
log
function log(bool p0, uint256 p1, bool p2, uint256 p3) internal pure;
log
function log(bool p0, uint256 p1, bool p2, bytes32 p3) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2, address p3) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2, bool p3) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2, uint256 p3) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2, bytes32 p3) internal pure;
log
function log(bool p0, uint256 p1, bytes32 p2, address p3) internal pure;
log
function log(bool p0, uint256 p1, bytes32 p2, bool p3) internal pure;
log
function log(bool p0, uint256 p1, bytes32 p2, uint256 p3) internal pure;
log
function log(bool p0, uint256 p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(bool p0, bytes32 p1, address p2, address p3) internal pure;
log
function log(bool p0, bytes32 p1, address p2, bool p3) internal pure;
log
function log(bool p0, bytes32 p1, address p2, uint256 p3) internal pure;
log
function log(bool p0, bytes32 p1, address p2, bytes32 p3) internal pure;
log
function log(bool p0, bytes32 p1, bool p2, address p3) internal pure;
log
function log(bool p0, bytes32 p1, bool p2, bool p3) internal pure;
log
function log(bool p0, bytes32 p1, bool p2, uint256 p3) internal pure;
log
function log(bool p0, bytes32 p1, bool p2, bytes32 p3) internal pure;
log
function log(bool p0, bytes32 p1, uint256 p2, address p3) internal pure;
log
function log(bool p0, bytes32 p1, uint256 p2, bool p3) internal pure;
log
function log(bool p0, bytes32 p1, uint256 p2, uint256 p3) internal pure;
log
function log(bool p0, bytes32 p1, uint256 p2, bytes32 p3) internal pure;
log
function log(bool p0, bytes32 p1, bytes32 p2, address p3) internal pure;
log
function log(bool p0, bytes32 p1, bytes32 p2, bool p3) internal pure;
log
function log(bool p0, bytes32 p1, bytes32 p2, uint256 p3) internal pure;
log
function log(bool p0, bytes32 p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(uint256 p0, address p1, address p2, address p3) internal pure;
log
function log(uint256 p0, address p1, address p2, bool p3) internal pure;
log
function log(uint256 p0, address p1, address p2, uint256 p3) internal pure;
log
function log(uint256 p0, address p1, address p2, bytes32 p3) internal pure;
log
function log(uint256 p0, address p1, bool p2, address p3) internal pure;
log
function log(uint256 p0, address p1, bool p2, bool p3) internal pure;
log
function log(uint256 p0, address p1, bool p2, uint256 p3) internal pure;
log
function log(uint256 p0, address p1, bool p2, bytes32 p3) internal pure;
log
function log(uint256 p0, address p1, uint256 p2, address p3) internal pure;
log
function log(uint256 p0, address p1, uint256 p2, bool p3) internal pure;
log
function log(uint256 p0, address p1, uint256 p2, uint256 p3) internal pure;
log
function log(uint256 p0, address p1, uint256 p2, bytes32 p3) internal pure;
log
function log(uint256 p0, address p1, bytes32 p2, address p3) internal pure;
log
function log(uint256 p0, address p1, bytes32 p2, bool p3) internal pure;
log
function log(uint256 p0, address p1, bytes32 p2, uint256 p3) internal pure;
log
function log(uint256 p0, address p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(uint256 p0, bool p1, address p2, address p3) internal pure;
log
function log(uint256 p0, bool p1, address p2, bool p3) internal pure;
log
function log(uint256 p0, bool p1, address p2, uint256 p3) internal pure;
log
function log(uint256 p0, bool p1, address p2, bytes32 p3) internal pure;
log
function log(uint256 p0, bool p1, bool p2, address p3) internal pure;
log
function log(uint256 p0, bool p1, bool p2, bool p3) internal pure;
log
function log(uint256 p0, bool p1, bool p2, uint256 p3) internal pure;
log
function log(uint256 p0, bool p1, bool p2, bytes32 p3) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2, address p3) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2, bool p3) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2, uint256 p3) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2, bytes32 p3) internal pure;
log
function log(uint256 p0, bool p1, bytes32 p2, address p3) internal pure;
log
function log(uint256 p0, bool p1, bytes32 p2, bool p3) internal pure;
log
function log(uint256 p0, bool p1, bytes32 p2, uint256 p3) internal pure;
log
function log(uint256 p0, bool p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(uint256 p0, uint256 p1, address p2, address p3) internal pure;
log
function log(uint256 p0, uint256 p1, address p2, bool p3) internal pure;
log
function log(uint256 p0, uint256 p1, address p2, uint256 p3) internal pure;
log
function log(uint256 p0, uint256 p1, address p2, bytes32 p3) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2, address p3) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2, bool p3) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2, uint256 p3) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2, bytes32 p3) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2, address p3) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2, bool p3) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2, uint256 p3) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2, bytes32 p3) internal pure;
log
function log(uint256 p0, uint256 p1, bytes32 p2, address p3) internal pure;
log
function log(uint256 p0, uint256 p1, bytes32 p2, bool p3) internal pure;
log
function log(uint256 p0, uint256 p1, bytes32 p2, uint256 p3) internal pure;
log
function log(uint256 p0, uint256 p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(uint256 p0, bytes32 p1, address p2, address p3) internal pure;
log
function log(uint256 p0, bytes32 p1, address p2, bool p3) internal pure;
log
function log(uint256 p0, bytes32 p1, address p2, uint256 p3) internal pure;
log
function log(uint256 p0, bytes32 p1, address p2, bytes32 p3) internal pure;
log
function log(uint256 p0, bytes32 p1, bool p2, address p3) internal pure;
log
function log(uint256 p0, bytes32 p1, bool p2, bool p3) internal pure;
log
function log(uint256 p0, bytes32 p1, bool p2, uint256 p3) internal pure;
log
function log(uint256 p0, bytes32 p1, bool p2, bytes32 p3) internal pure;
log
function log(uint256 p0, bytes32 p1, uint256 p2, address p3) internal pure;
log
function log(uint256 p0, bytes32 p1, uint256 p2, bool p3) internal pure;
log
function log(uint256 p0, bytes32 p1, uint256 p2, uint256 p3) internal pure;
log
function log(uint256 p0, bytes32 p1, uint256 p2, bytes32 p3) internal pure;
log
function log(uint256 p0, bytes32 p1, bytes32 p2, address p3) internal pure;
log
function log(uint256 p0, bytes32 p1, bytes32 p2, bool p3) internal pure;
log
function log(uint256 p0, bytes32 p1, bytes32 p2, uint256 p3) internal pure;
log
function log(uint256 p0, bytes32 p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, address p1, address p2, address p3) internal pure;
log
function log(bytes32 p0, address p1, address p2, bool p3) internal pure;
log
function log(bytes32 p0, address p1, address p2, uint256 p3) internal pure;
log
function log(bytes32 p0, address p1, address p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, address p1, bool p2, address p3) internal pure;
log
function log(bytes32 p0, address p1, bool p2, bool p3) internal pure;
log
function log(bytes32 p0, address p1, bool p2, uint256 p3) internal pure;
log
function log(bytes32 p0, address p1, bool p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, address p1, uint256 p2, address p3) internal pure;
log
function log(bytes32 p0, address p1, uint256 p2, bool p3) internal pure;
log
function log(bytes32 p0, address p1, uint256 p2, uint256 p3) internal pure;
log
function log(bytes32 p0, address p1, uint256 p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, address p1, bytes32 p2, address p3) internal pure;
log
function log(bytes32 p0, address p1, bytes32 p2, bool p3) internal pure;
log
function log(bytes32 p0, address p1, bytes32 p2, uint256 p3) internal pure;
log
function log(bytes32 p0, address p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, bool p1, address p2, address p3) internal pure;
log
function log(bytes32 p0, bool p1, address p2, bool p3) internal pure;
log
function log(bytes32 p0, bool p1, address p2, uint256 p3) internal pure;
log
function log(bytes32 p0, bool p1, address p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, bool p1, bool p2, address p3) internal pure;
log
function log(bytes32 p0, bool p1, bool p2, bool p3) internal pure;
log
function log(bytes32 p0, bool p1, bool p2, uint256 p3) internal pure;
log
function log(bytes32 p0, bool p1, bool p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, bool p1, uint256 p2, address p3) internal pure;
log
function log(bytes32 p0, bool p1, uint256 p2, bool p3) internal pure;
log
function log(bytes32 p0, bool p1, uint256 p2, uint256 p3) internal pure;
log
function log(bytes32 p0, bool p1, uint256 p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, bool p1, bytes32 p2, address p3) internal pure;
log
function log(bytes32 p0, bool p1, bytes32 p2, bool p3) internal pure;
log
function log(bytes32 p0, bool p1, bytes32 p2, uint256 p3) internal pure;
log
function log(bytes32 p0, bool p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, uint256 p1, address p2, address p3) internal pure;
log
function log(bytes32 p0, uint256 p1, address p2, bool p3) internal pure;
log
function log(bytes32 p0, uint256 p1, address p2, uint256 p3) internal pure;
log
function log(bytes32 p0, uint256 p1, address p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, uint256 p1, bool p2, address p3) internal pure;
log
function log(bytes32 p0, uint256 p1, bool p2, bool p3) internal pure;
log
function log(bytes32 p0, uint256 p1, bool p2, uint256 p3) internal pure;
log
function log(bytes32 p0, uint256 p1, bool p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, uint256 p1, uint256 p2, address p3) internal pure;
log
function log(bytes32 p0, uint256 p1, uint256 p2, bool p3) internal pure;
log
function log(bytes32 p0, uint256 p1, uint256 p2, uint256 p3) internal pure;
log
function log(bytes32 p0, uint256 p1, uint256 p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, uint256 p1, bytes32 p2, address p3) internal pure;
log
function log(bytes32 p0, uint256 p1, bytes32 p2, bool p3) internal pure;
log
function log(bytes32 p0, uint256 p1, bytes32 p2, uint256 p3) internal pure;
log
function log(bytes32 p0, uint256 p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, address p2, address p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, address p2, bool p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, address p2, uint256 p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, address p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, bool p2, address p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, bool p2, bool p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, bool p2, uint256 p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, bool p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, uint256 p2, address p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, uint256 p2, bool p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, uint256 p2, uint256 p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, uint256 p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, bytes32 p2, address p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, bytes32 p2, bool p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, bytes32 p2, uint256 p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, bytes32 p2, bytes32 p3) internal pure;
Contents
- compilation
- VmInternal
- StdAssertionsTest
- TestMockCall
- StdChainsMock
- StdChainsTest
- StdCheatsTest
- StdCheatsMock
- StdCheatsForkTest
- Bar
- BarERC1155
- BarERC721
- USDCLike
- USDTLike
- RevertingContract
- MockContractWithConstructorArgs
- MockContractPayable
- StdErrorsTest
- ErrorsTest
- StdJsonTest
- StdMathMock
- StdMathTest
- StdStorageTest
- StorageTestTarget
- StorageTest
- StdStyleTest
- StdTomlTest
- StdUtilsMock
- StdUtilsTest
- StdUtilsForkTest
- VmTest
Contents
CompilationScript
Inherits: Script
CompilationScriptBase
Inherits: ScriptBase
CompilationTest
Inherits: Test
CompilationTestBase
Inherits: TestBase
VmInternal
Inherits: Vm
Functions
_expectCheatcodeRevert
function _expectCheatcodeRevert(bytes memory message) external;
StdAssertionsTest
Inherits: StdAssertions
State Variables
errorMessage
string constant errorMessage = "User provided message";
maxDecimals
uint256 constant maxDecimals = 77;
SHOULD_REVERT
bool constant SHOULD_REVERT = true;
SHOULD_RETURN
bool constant SHOULD_RETURN = false;
STRICT_REVERT_DATA
bool constant STRICT_REVERT_DATA = true;
NON_STRICT_REVERT_DATA
bool constant NON_STRICT_REVERT_DATA = false;
vm
VmInternal constant vm = VmInternal(address(uint160(uint256(keccak256("hevm cheat code")))));
Functions
testFuzz_AssertEqCall_Return_Pass
function testFuzz_AssertEqCall_Return_Pass(
bytes memory callDataA,
bytes memory callDataB,
bytes memory returnData,
bool strictRevertData
) external;
testFuzz_RevertWhenCalled_AssertEqCall_Return_Fail
function testFuzz_RevertWhenCalled_AssertEqCall_Return_Fail(
bytes memory callDataA,
bytes memory callDataB,
bytes memory returnDataA,
bytes memory returnDataB,
bool strictRevertData
) external;
testFuzz_AssertEqCall_Revert_Pass
function testFuzz_AssertEqCall_Revert_Pass(
bytes memory callDataA,
bytes memory callDataB,
bytes memory revertDataA,
bytes memory revertDataB
) external;
testFuzz_RevertWhenCalled_AssertEqCall_Revert_Fail
function testFuzz_RevertWhenCalled_AssertEqCall_Revert_Fail(
bytes memory callDataA,
bytes memory callDataB,
bytes memory revertDataA,
bytes memory revertDataB
) external;
testFuzz_RevertWhenCalled_AssertEqCall_Fail
function testFuzz_RevertWhenCalled_AssertEqCall_Fail(
bytes memory callDataA,
bytes memory callDataB,
bytes memory returnDataA,
bytes memory returnDataB,
bool strictRevertData
) external;
assertEqCallExternal
function assertEqCallExternal(
address targetA,
bytes memory callDataA,
address targetB,
bytes memory callDataB,
bool strictRevertData
) public;
TestMockCall
State Variables
returnData
bytes returnData;
shouldRevert
bool shouldRevert;
Functions
constructor
constructor(bytes memory returnData_, bool shouldRevert_);
fallback
fallback() external payable;
StdChainsMock
Inherits: Test
Functions
exposed_getChain
function exposed_getChain(string memory chainAlias) public returns (Chain memory);
exposed_getChain
function exposed_getChain(uint256 chainId) public returns (Chain memory);
exposed_setChain
function exposed_setChain(string memory chainAlias, ChainData memory chainData) public;
exposed_setFallbackToDefaultRpcUrls
function exposed_setFallbackToDefaultRpcUrls(bool useDefault) public;
StdChainsTest
Inherits: Test
Functions
test_ChainRpcInitialization
function test_ChainRpcInitialization() public;
_testRpc
function _testRpc(string memory rpcAlias) internal;
test_RevertIf_ChainNotFound
function test_RevertIf_ChainNotFound() public;
test_RevertIf_SetChain_ChainIdExist_FirstTest
function test_RevertIf_SetChain_ChainIdExist_FirstTest() public;
test_RevertIf_ChainBubbleUp
function test_RevertIf_ChainBubbleUp() public;
test_RevertIf_SetChain_ChainIdExists_SecondTest
function test_RevertIf_SetChain_ChainIdExists_SecondTest() public;
test_SetChain
function test_SetChain() public;
test_RevertIf_SetEmptyAlias
function test_RevertIf_SetEmptyAlias() public;
test_RevertIf_SetNoChainId0
function test_RevertIf_SetNoChainId0() public;
test_RevertIf_GetNoChainId0
function test_RevertIf_GetNoChainId0() public;
test_RevertIf_GetNoEmptyAlias
function test_RevertIf_GetNoEmptyAlias() public;
test_RevertIf_ChainIdNotFound
function test_RevertIf_ChainIdNotFound() public;
test_RevertIf_ChainAliasNotFound
function test_RevertIf_ChainAliasNotFound() public;
test_SetChain_ExistingOne
function test_SetChain_ExistingOne() public;
test_RevertIf_DontUseDefaultRpcUrl
function test_RevertIf_DontUseDefaultRpcUrl() public;
StdCheatsTest
Inherits: Test
State Variables
test
Bar test;
Functions
setUp
function setUp() public;
test_Skip
function test_Skip() public;
test_Rewind
function test_Rewind() public;
test_Hoax
function test_Hoax() public;
test_HoaxOrigin
function test_HoaxOrigin() public;
test_HoaxDifferentAddresses
function test_HoaxDifferentAddresses() public;
test_StartHoax
function test_StartHoax() public;
test_StartHoaxOrigin
function test_StartHoaxOrigin() public;
test_ChangePrankMsgSender
function test_ChangePrankMsgSender() public;
test_ChangePrankMsgSenderAndTxOrigin
function test_ChangePrankMsgSenderAndTxOrigin() public;
test_MakeAccountEquivalence
function test_MakeAccountEquivalence() public;
test_MakeAddrEquivalence
function test_MakeAddrEquivalence() public;
test_MakeAddrSigning
function test_MakeAddrSigning() public;
test_Deal
function test_Deal() public;
test_DealToken
function test_DealToken() public;
test_DealTokenAdjustTotalSupply
function test_DealTokenAdjustTotalSupply() public;
test_DealERC1155Token
function test_DealERC1155Token() public;
test_DealERC1155TokenAdjustTotalSupply
function test_DealERC1155TokenAdjustTotalSupply() public;
test_DealERC721Token
function test_DealERC721Token() public;
test_DeployCode
function test_DeployCode() public;
test_DestroyAccount
function test_DestroyAccount() public;
test_DeployCodeNoArgs
function test_DeployCodeNoArgs() public;
test_DeployCodeVal
function test_DeployCodeVal() public;
test_DeployCodeValNoArgs
function test_DeployCodeValNoArgs() public;
deployCodeHelper
function deployCodeHelper(string memory what) external;
test_RevertIf_DeployCodeFail
function test_RevertIf_DeployCodeFail() public;
getCode
function getCode(address who) internal view returns (bytes memory o_code);
test_DeriveRememberKey
function test_DeriveRememberKey() public;
test_BytesToUint
function test_BytesToUint() public pure;
test_ParseJsonTxDetail
function test_ParseJsonTxDetail() public view;
test_ReadEIP1559Transaction
function test_ReadEIP1559Transaction() public view;
test_ReadEIP1559Transactions
function test_ReadEIP1559Transactions() public view;
test_ReadReceipt
function test_ReadReceipt() public view;
test_ReadReceipts
function test_ReadReceipts() public view;
test_GasMeteringModifier
function test_GasMeteringModifier() public;
addInLoop
function addInLoop() internal pure returns (uint256);
addInLoopNoGas
function addInLoopNoGas() internal noGasMetering returns (uint256);
addInLoopNoGasNoGas
function addInLoopNoGasNoGas() internal noGasMetering returns (uint256);
bytesToUint_test
function bytesToUint_test(bytes memory b) private pure returns (uint256);
testFuzz_AssumeAddressIsNot
function testFuzz_AssumeAddressIsNot(address addr) external;
test_AssumePayable
function test_AssumePayable() external;
test_AssumeNotPayable
function test_AssumeNotPayable() external;
testFuzz_AssumeNotPrecompile
function testFuzz_AssumeNotPrecompile(address addr) external;
testFuzz_AssumeNotForgeAddress
function testFuzz_AssumeNotForgeAddress(address addr) external pure;
test_RevertIf_CannotDeployCodeTo
function test_RevertIf_CannotDeployCodeTo() external;
_revertDeployCodeTo
function _revertDeployCodeTo() external;
test_DeployCodeTo
function test_DeployCodeTo() external;
StdCheatsMock
Inherits: StdCheats
Functions
exposed_assumePayable
function exposed_assumePayable(address addr) external;
exposed_assumeNotPayable
function exposed_assumeNotPayable(address addr) external;
exposed_assumeNotBlacklisted
function exposed_assumeNotBlacklisted(address token, address addr) external view;
StdCheatsForkTest
Inherits: Test
State Variables
SHIB
address internal constant SHIB = 0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE;
USDC
address internal constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
USDC_BLACKLISTED_USER
address internal constant USDC_BLACKLISTED_USER = 0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD;
USDT
address internal constant USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
USDT_BLACKLISTED_USER
address internal constant USDT_BLACKLISTED_USER = 0x8f8a8F4B54a2aAC7799d7bc81368aC27b852822A;
Functions
setUp
function setUp() public;
test_RevertIf_CannotAssumeNoBlacklisted_EOA
function test_RevertIf_CannotAssumeNoBlacklisted_EOA() external;
testFuzz_AssumeNotBlacklisted_TokenWithoutBlacklist
function testFuzz_AssumeNotBlacklisted_TokenWithoutBlacklist(address addr) external view;
test_RevertIf_AssumeNoBlacklisted_USDC
function test_RevertIf_AssumeNoBlacklisted_USDC() external;
testFuzz_AssumeNotBlacklisted_USDC
function testFuzz_AssumeNotBlacklisted_USDC(address addr) external view;
test_RevertIf_AssumeNoBlacklisted_USDT
function test_RevertIf_AssumeNoBlacklisted_USDT() external;
testFuzz_AssumeNotBlacklisted_USDT
function testFuzz_AssumeNotBlacklisted_USDT(address addr) external view;
test_dealUSDC
function test_dealUSDC() external;
Bar
State Variables
balanceOf
DEAL STDCHEAT
mapping(address => uint256) public balanceOf;
totalSupply
uint256 public totalSupply;
Functions
constructor
constructor() payable;
bar
HOAX and CHANGEPRANK STDCHEATS
function bar(address expectedSender) public payable;
origin
function origin(address expectedSender) public payable;
origin
function origin(address expectedSender, address expectedOrigin) public payable;
BarERC1155
State Variables
_balances
DEALERC1155 STDCHEAT
mapping(uint256 => mapping(address => uint256)) private _balances;
_totalSupply
mapping(uint256 => uint256) private _totalSupply;
Functions
constructor
constructor() payable;
balanceOf
function balanceOf(address account, uint256 id) public view virtual returns (uint256);
totalSupply
function totalSupply(uint256 id) public view virtual returns (uint256);
BarERC721
State Variables
_owners
mapping(uint256 => address) private _owners;
_balances
mapping(address => uint256) private _balances;
Functions
constructor
constructor() payable;
balanceOf
function balanceOf(address owner) public view virtual returns (uint256);
ownerOf
function ownerOf(uint256 tokenId) public view virtual returns (address);
USDCLike
Functions
isBlacklisted
function isBlacklisted(address) external view returns (bool);
USDTLike
Functions
isBlackListed
function isBlackListed(address) external view returns (bool);
RevertingContract
Functions
constructor
constructor();
MockContractWithConstructorArgs
State Variables
x
uint256 public immutable x;
y
bool public y;
z
bytes20 public z;
Functions
constructor
constructor(uint256 _x, bool _y, bytes20 _z) payable;
MockContractPayable
Functions
receive
receive() external payable;
StdErrorsTest
Inherits: Test
State Variables
test
ErrorsTest test;
Functions
setUp
function setUp() public;
test_RevertIf_AssertionError
function test_RevertIf_AssertionError() public;
test_RevertIf_ArithmeticError
function test_RevertIf_ArithmeticError() public;
test_RevertIf_DivisionError
function test_RevertIf_DivisionError() public;
test_RevertIf_ModError
function test_RevertIf_ModError() public;
test_RevertIf_EnumConversionError
function test_RevertIf_EnumConversionError() public;
test_RevertIf_EncodeStgError
function test_RevertIf_EncodeStgError() public;
test_RevertIf_PopError
function test_RevertIf_PopError() public;
test_RevertIf_IndexOOBError
function test_RevertIf_IndexOOBError() public;
test_RevertIf_MemOverflowError
function test_RevertIf_MemOverflowError() public;
test_RevertIf_InternError
function test_RevertIf_InternError() public;
ErrorsTest
State Variables
someArr
uint256[] public someArr;
someBytes
bytes someBytes;
Functions
assertionError
function assertionError() public pure;
arithmeticError
function arithmeticError(uint256 a) public pure;
divError
function divError(uint256 a) public pure;
modError
function modError(uint256 a) public pure;
enumConversion
function enumConversion(uint256 a) public pure;
encodeStgError
function encodeStgError() public;
pop
function pop() public;
indexOOBError
function indexOOBError(uint256 a) public pure;
mem
function mem() public pure;
intern
function intern() public returns (uint256);
Enums
T
enum T {
T1
}
StdJsonTest
Inherits: Test
State Variables
root
string root;
path
string path;
Functions
setUp
function setUp() public;
test_readJson
function test_readJson() public view;
test_writeJson
function test_writeJson() public;
Structs
SimpleJson
struct SimpleJson {
uint256 a;
string b;
}
NestedJson
struct NestedJson {
uint256 a;
string b;
SimpleJson c;
}
StdMathMock
Inherits: Test
Functions
exposed_percentDelta
function exposed_percentDelta(uint256 a, uint256 b) public pure returns (uint256);
exposed_percentDelta
function exposed_percentDelta(int256 a, int256 b) public pure returns (uint256);
StdMathTest
Inherits: Test
Functions
test_GetAbs
function test_GetAbs() external pure;
testFuzz_GetAbs
function testFuzz_GetAbs(int256 a) external pure;
test_GetDelta_Uint
function test_GetDelta_Uint() external pure;
testFuzz_GetDelta_Uint
function testFuzz_GetDelta_Uint(uint256 a, uint256 b) external pure;
test_GetDelta_Int
function test_GetDelta_Int() external pure;
testFuzz_GetDelta_Int
function testFuzz_GetDelta_Int(int256 a, int256 b) external pure;
test_GetPercentDelta_Uint
function test_GetPercentDelta_Uint() external;
testFuzz_GetPercentDelta_Uint
function testFuzz_GetPercentDelta_Uint(uint192 a, uint192 b) external pure;
test_GetPercentDelta_Int
function test_GetPercentDelta_Int() external;
testFuzz_GetPercentDelta_Int
function testFuzz_GetPercentDelta_Int(int192 a, int192 b) external pure;
getAbs
function getAbs(int256 a) private pure returns (uint256);
StdStorageTest
Inherits: Test
State Variables
test
StorageTest internal test;
Functions
setUp
function setUp() public;
test_StorageHidden
function test_StorageHidden() public;
test_StorageObvious
function test_StorageObvious() public;
test_StorageExtraSload
function test_StorageExtraSload() public;
test_StorageCheckedWriteHidden
function test_StorageCheckedWriteHidden() public;
test_StorageCheckedWriteObvious
function test_StorageCheckedWriteObvious() public;
test_StorageCheckedWriteSignedIntegerHidden
function test_StorageCheckedWriteSignedIntegerHidden() public;
test_StorageCheckedWriteSignedIntegerObvious
function test_StorageCheckedWriteSignedIntegerObvious() public;
test_StorageMapStructA
function test_StorageMapStructA() public;
test_StorageMapStructB
function test_StorageMapStructB() public;
test_StorageDeepMap
function test_StorageDeepMap() public;
test_StorageCheckedWriteDeepMap
function test_StorageCheckedWriteDeepMap() public;
test_StorageDeepMapStructA
function test_StorageDeepMapStructA() public;
test_StorageDeepMapStructB
function test_StorageDeepMapStructB() public;
test_StorageCheckedWriteDeepMapStructA
function test_StorageCheckedWriteDeepMapStructA() public;
test_StorageCheckedWriteDeepMapStructB
function test_StorageCheckedWriteDeepMapStructB() public;
test_StorageCheckedWriteMapStructA
function test_StorageCheckedWriteMapStructA() public;
test_StorageCheckedWriteMapStructB
function test_StorageCheckedWriteMapStructB() public;
test_StorageStructA
function test_StorageStructA() public;
test_StorageStructB
function test_StorageStructB() public;
test_StorageCheckedWriteStructA
function test_StorageCheckedWriteStructA() public;
test_StorageCheckedWriteStructB
function test_StorageCheckedWriteStructB() public;
test_StorageMapAddrFound
function test_StorageMapAddrFound() public;
test_StorageMapAddrRoot
function test_StorageMapAddrRoot() public;
test_StorageMapUintFound
function test_StorageMapUintFound() public;
test_StorageCheckedWriteMapUint
function test_StorageCheckedWriteMapUint() public;
test_StorageCheckedWriteMapAddr
function test_StorageCheckedWriteMapAddr() public;
test_StorageCheckedWriteMapBool
function test_StorageCheckedWriteMapBool() public;
testFuzz_StorageCheckedWriteMapPacked
function testFuzz_StorageCheckedWriteMapPacked(address addr, uint128 value) public;
test_StorageCheckedWriteMapPackedFullSuccess
function test_StorageCheckedWriteMapPackedFullSuccess() public;
test_RevertStorageConst
function test_RevertStorageConst() public;
testFuzz_StorageNativePack
function testFuzz_StorageNativePack(uint248 val1, uint248 val2, bool boolVal1, bool boolVal2) public;
test_StorageReadBytes32
function test_StorageReadBytes32() public;
test_StorageReadBool_False
function test_StorageReadBool_False() public;
test_StorageReadBool_True
function test_StorageReadBool_True() public;
test_RevertIf_ReadingNonBoolValue
function test_RevertIf_ReadingNonBoolValue() public;
readNonBoolValue
function readNonBoolValue() public;
test_StorageReadAddress
function test_StorageReadAddress() public;
test_StorageReadUint
function test_StorageReadUint() public;
test_StorageReadInt
function test_StorageReadInt() public;
testFuzz_Packed
function testFuzz_Packed(uint256 val, uint8 elemToGet) public;
testFuzz_Packed2
function testFuzz_Packed2(uint256 nvars, uint256 seed) public;
testEdgeCaseArray
function testEdgeCaseArray() public;
StorageTestTarget
State Variables
stdstore
StdStorage internal stdstore;
test
StorageTest internal test;
Functions
constructor
constructor(StorageTest test_);
expectRevertStorageConst
function expectRevertStorageConst() public;
StorageTest
State Variables
exists
uint256 public exists = 1;
map_addr
mapping(address => uint256) public map_addr;
map_uint
mapping(uint256 => uint256) public map_uint;
map_packed
mapping(address => uint256) public map_packed;
map_struct
mapping(address => UnpackedStruct) public map_struct;
deep_map
mapping(address => mapping(address => uint256)) public deep_map;
deep_map_struct
mapping(address => mapping(address => UnpackedStruct)) public deep_map_struct;
basic
UnpackedStruct public basic;
tA
uint248 public tA;
tB
bool public tB;
tC
bool public tC = false;
tD
uint248 public tD = 1;
map_bool
mapping(address => bool) public map_bool;
tE
bytes32 public tE = hex"1337";
tF
address public tF = address(1337);
tG
int256 public tG = type(int256).min;
tH
bool public tH = true;
tI
bytes32 private tI = ~bytes32(hex"1337");
randomPacking
uint256 randomPacking;
edgeCaseArray
uint256[] public edgeCaseArray = [3, 3, 3];
Functions
constructor
constructor();
read_struct_upper
function read_struct_upper(address who) public view returns (uint256);
read_struct_lower
function read_struct_lower(address who) public view returns (uint256);
hidden
function hidden() public view returns (bytes32 t);
const
function const() public pure returns (bytes32 t);
extra_sload
function extra_sload() public view returns (bytes32 t);
setRandomPacking
function setRandomPacking(uint256 val) public;
_getMask
function _getMask(uint256 size) internal pure returns (uint256 mask);
setRandomPacking
function setRandomPacking(uint256 val, uint256 size, uint256 offset) public;
getRandomPacked
function getRandomPacked(uint256 size, uint256 offset) public view returns (uint256);
getRandomPacked
function getRandomPacked(uint8 shifts, uint8[] memory shiftSizes, uint8 elem) public view returns (uint256);
Structs
UnpackedStruct
struct UnpackedStruct {
uint256 a;
uint256 b;
}
StdStyleTest
Inherits: Test
Functions
test_StyleColor
function test_StyleColor() public pure;
test_StyleFontWeight
function test_StyleFontWeight() public pure;
test_StyleCombined
function test_StyleCombined() public pure;
test_StyleCustom
function test_StyleCustom() public pure;
h1
function h1(string memory a) private pure returns (string memory);
h2
function h2(string memory a) private pure returns (string memory);
StdTomlTest
Inherits: Test
State Variables
root
string root;
path
string path;
Functions
setUp
function setUp() public;
test_readToml
function test_readToml() public view;
test_writeToml
function test_writeToml() public;
Structs
SimpleToml
struct SimpleToml {
uint256 a;
string b;
}
NestedToml
struct NestedToml {
uint256 a;
string b;
SimpleToml c;
}
StdUtilsMock
Inherits: StdUtils
Functions
exposed_getTokenBalances
function exposed_getTokenBalances(address token, address[] memory addresses)
external
returns (uint256[] memory balances);
exposed_bound
function exposed_bound(int256 num, int256 min, int256 max) external pure returns (int256);
exposed_bound
function exposed_bound(uint256 num, uint256 min, uint256 max) external pure returns (uint256);
exposed_bytesToUint
function exposed_bytesToUint(bytes memory b) external pure returns (uint256);
StdUtilsTest
Inherits: Test
Functions
test_Bound
function test_Bound() public pure;
test_Bound_WithinRange
function test_Bound_WithinRange() public pure;
test_Bound_EdgeCoverage
function test_Bound_EdgeCoverage() public pure;
testFuzz_Bound_DistributionIsEven
function testFuzz_Bound_DistributionIsEven(uint256 min, uint256 size) public pure;
testFuzz_Bound
function testFuzz_Bound(uint256 num, uint256 min, uint256 max) public pure;
test_BoundUint256Max
function test_BoundUint256Max() public pure;
test_RevertIf_BoundMaxLessThanMin
function test_RevertIf_BoundMaxLessThanMin() public;
testFuzz_RevertIf_BoundMaxLessThanMin
function testFuzz_RevertIf_BoundMaxLessThanMin(uint256 num, uint256 min, uint256 max) public;
test_BoundInt
function test_BoundInt() public pure;
test_BoundInt_WithinRange
function test_BoundInt_WithinRange() public pure;
test_BoundInt_EdgeCoverage
function test_BoundInt_EdgeCoverage() public pure;
testFuzz_BoundInt_DistributionIsEven
function testFuzz_BoundInt_DistributionIsEven(int256 min, uint256 size) public pure;
testFuzz_BoundInt
function testFuzz_BoundInt(int256 num, int256 min, int256 max) public pure;
test_BoundIntInt256Max
function test_BoundIntInt256Max() public pure;
test_BoundIntInt256Min
function test_BoundIntInt256Min() public pure;
test_RevertIf_BoundIntMaxLessThanMin
function test_RevertIf_BoundIntMaxLessThanMin() public;
testFuzz_RevertIf_BoundIntMaxLessThanMin
function testFuzz_RevertIf_BoundIntMaxLessThanMin(int256 num, int256 min, int256 max) public;
test_BoundPrivateKey
function test_BoundPrivateKey() public pure;
test_BytesToUint
function test_BytesToUint() external pure;
test_RevertIf_BytesLengthExceeds32
function test_RevertIf_BytesLengthExceeds32() external;
test_ComputeCreateAddress
function test_ComputeCreateAddress() external pure;
test_ComputeCreate2Address
function test_ComputeCreate2Address() external pure;
test_ComputeCreate2AddressWithDefaultDeployer
function test_ComputeCreate2AddressWithDefaultDeployer() external pure;
StdUtilsForkTest
Inherits: Test
State Variables
SHIB
address internal SHIB = 0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE;
SHIB_HOLDER_0
address internal SHIB_HOLDER_0 = 0x855F5981e831D83e6A4b4EBFCAdAa68D92333170;
SHIB_HOLDER_1
address internal SHIB_HOLDER_1 = 0x8F509A90c2e47779cA408Fe00d7A72e359229AdA;
SHIB_HOLDER_2
address internal SHIB_HOLDER_2 = 0x0e3bbc0D04fF62211F71f3e4C45d82ad76224385;
USDC
address internal USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
USDC_HOLDER_0
address internal USDC_HOLDER_0 = 0xDa9CE944a37d218c3302F6B82a094844C6ECEb17;
USDC_HOLDER_1
address internal USDC_HOLDER_1 = 0x3e67F4721E6d1c41a015f645eFa37BEd854fcf52;
Functions
setUp
function setUp() public;
test_RevertIf_CannotGetTokenBalances_NonTokenContract
function test_RevertIf_CannotGetTokenBalances_NonTokenContract() external;
test_RevertIf_CannotGetTokenBalances_EOA
function test_RevertIf_CannotGetTokenBalances_EOA() external;
test_GetTokenBalances_Empty
function test_GetTokenBalances_Empty() external;
test_GetTokenBalances_USDC
function test_GetTokenBalances_USDC() external;
test_GetTokenBalances_SHIB
function test_GetTokenBalances_SHIB() external;
VmTest
Inherits: Test
Functions
test_VmInterfaceId
function test_VmInterfaceId() public pure;
test_VmSafeInterfaceId
function test_VmSafeInterfaceId() public pure;
Contents
Contents
SVM
Symbolic Virtual Machine
Functions
createUint
function createUint(uint256 bitSize, string memory name) external pure returns (uint256 value);
createUint256
function createUint256(string memory name) external pure returns (uint256 value);
createInt
function createInt(uint256 bitSize, string memory name) external pure returns (int256 value);
createInt256
function createInt256(string memory name) external pure returns (int256 value);
createBytes
function createBytes(uint256 byteSize, string memory name) external pure returns (bytes memory value);
createString
function createString(uint256 byteSize, string memory name) external pure returns (string memory value);
createBytes32
function createBytes32(string memory name) external pure returns (bytes32 value);
createBytes4
function createBytes4(string memory name) external pure returns (bytes4 value);
createAddress
function createAddress(string memory name) external pure returns (address value);
createBool
function createBool(string memory name) external pure returns (bool value);
createCalldata
function createCalldata(string memory contractOrInterfaceName) external pure returns (bytes memory data);
createCalldata
function createCalldata(string memory contractOrInterfaceName, bool includeViewAndPureFunctions)
external
pure
returns (bytes memory data);
createCalldata
function createCalldata(string memory filename, string memory contractOrInterfaceName)
external
pure
returns (bytes memory data);
createCalldata
function createCalldata(string memory filename, string memory contractOrInterfaceName, bool includeViewAndPureFunctions)
external
pure
returns (bytes memory data);
enableSymbolicStorage
function enableSymbolicStorage(address) external;
snapshotStorage
function snapshotStorage(address) external returns (uint256 id);
SymTest
State Variables
SVM_ADDRESS
address internal constant SVM_ADDRESS = address(uint160(uint256(keccak256("svm cheat code"))));
svm
SVM internal constant svm = SVM(SVM_ADDRESS);
Contents
Contents
Contents
- AccessControlDefaultAdminRulesHarness
- AccessControlHarness
- AccessManagedHarness
- AccessManagerHarness
- DoubleEndedQueueHarness
- ERC20FlashMintHarness
- ERC20PermitHarness
- ERC20WrapperHarness
- ERC3156FlashBorrowerHarness
- ERC721Harness
- ERC721ReceiverHarness
- EnumerableMapHarness
- EnumerableSetHarness
- InitializableHarness
- NoncesHarness
- Ownable2StepHarness
- OwnableHarness
- PausableHarness
- TimelockControllerHarness
AccessControlDefaultAdminRulesHarness
Inherits: AccessControlDefaultAdminRules
State Variables
_delayIncreaseWait
uint48 private _delayIncreaseWait;
Functions
constructor
constructor(uint48 initialDelay, address initialDefaultAdmin, uint48 delayIncreaseWait)
AccessControlDefaultAdminRules(initialDelay, initialDefaultAdmin);
pendingDefaultAdmin_
function pendingDefaultAdmin_() external view returns (address);
pendingDefaultAdminSchedule_
function pendingDefaultAdminSchedule_() external view returns (uint48);
pendingDelay_
function pendingDelay_() external view returns (uint48);
pendingDelaySchedule_
function pendingDelaySchedule_() external view returns (uint48);
delayChangeWait_
function delayChangeWait_(uint48 newDelay) external view returns (uint48);
defaultAdminDelayIncreaseWait
function defaultAdminDelayIncreaseWait() public view override returns (uint48);
AccessControlHarness
Inherits: AccessControl
AccessManagedHarness
Inherits: AccessManaged
State Variables
SOME_FUNCTION_CALLDATA
bytes internal SOME_FUNCTION_CALLDATA = abi.encodeCall(this.someFunction, ());
Functions
constructor
constructor(address initialAuthority) AccessManaged(initialAuthority);
someFunction
function someFunction() public restricted;
authority_canCall_immediate
function authority_canCall_immediate(address caller) public view returns (bool result);
authority_canCall_delay
function authority_canCall_delay(address caller) public view returns (uint32 result);
authority_getSchedule
function authority_getSchedule(address caller) public view returns (uint48);
AccessManagerHarness
Inherits: AccessManager
State Variables
_minSetback
uint32 private _minSetback;
Functions
constructor
constructor(address initialAdmin) AccessManager(initialAdmin);
minSetback
function minSetback() public view override returns (uint32);
canCall_immediate
function canCall_immediate(address caller, address target, bytes4 selector) external view returns (bool result);
canCall_delay
function canCall_delay(address caller, address target, bytes4 selector) external view returns (uint32 result);
canCallExtended
function canCallExtended(address caller, address target, bytes calldata data) external view returns (bool, uint32);
canCallExtended_immediate
function canCallExtended_immediate(address caller, address target, bytes calldata data)
external
view
returns (bool result);
canCallExtended_delay
function canCallExtended_delay(address caller, address target, bytes calldata data)
external
view
returns (uint32 result);
getAdminRestrictions_restricted
function getAdminRestrictions_restricted(bytes calldata data) external view returns (bool result);
getAdminRestrictions_roleAdminId
function getAdminRestrictions_roleAdminId(bytes calldata data) external view returns (uint64 result);
getAdminRestrictions_executionDelay
function getAdminRestrictions_executionDelay(bytes calldata data) external view returns (uint32 result);
hasRole_isMember
function hasRole_isMember(uint64 roleId, address account) external view returns (bool result);
hasRole_executionDelay
function hasRole_executionDelay(uint64 roleId, address account) external view returns (uint32 result);
getAccess_since
function getAccess_since(uint64 roleId, address account) external view returns (uint48 result);
getAccess_currentDelay
function getAccess_currentDelay(uint64 roleId, address account) external view returns (uint32 result);
getAccess_pendingDelay
function getAccess_pendingDelay(uint64 roleId, address account) external view returns (uint32 result);
getAccess_effect
function getAccess_effect(uint64 roleId, address account) external view returns (uint48 result);
getTargetAdminDelay_after
function getTargetAdminDelay_after(address target) public view virtual returns (uint32 result);
getTargetAdminDelay_effect
function getTargetAdminDelay_effect(address target) public view virtual returns (uint48 result);
getRoleGrantDelay_after
function getRoleGrantDelay_after(uint64 roleId) public view virtual returns (uint32 result);
getRoleGrantDelay_effect
function getRoleGrantDelay_effect(uint64 roleId) public view virtual returns (uint48 result);
hashExecutionId
function hashExecutionId(address target, bytes4 selector) external pure returns (bytes32);
executionId
function executionId() external view returns (bytes32);
getSelector
function getSelector(bytes calldata data) external pure returns (bytes4);
getFirstArgumentAsAddress
function getFirstArgumentAsAddress(bytes calldata data) external pure returns (address);
getFirstArgumentAsUint64
function getFirstArgumentAsUint64(bytes calldata data) external pure returns (uint64);
_checkAuthorized
function _checkAuthorized() internal override;
DoubleEndedQueueHarness
State Variables
_deque
DoubleEndedQueue.Bytes32Deque private _deque;
Functions
pushFront
function pushFront(bytes32 value) external;
pushBack
function pushBack(bytes32 value) external;
popFront
function popFront() external returns (bytes32 value);
popBack
function popBack() external returns (bytes32 value);
clear
function clear() external;
begin
function begin() external view returns (uint128);
end
function end() external view returns (uint128);
length
function length() external view returns (uint256);
empty
function empty() external view returns (bool);
front
function front() external view returns (bytes32 value);
back
function back() external view returns (bytes32 value);
at_
function at_(uint256 index) external view returns (bytes32 value);
ERC20FlashMintHarness
Inherits: ERC20, ERC20Permit, ERC20FlashMint
State Variables
someFee
uint256 someFee;
someFeeReceiver
address someFeeReceiver;
Functions
constructor
constructor(string memory name, string memory symbol) ERC20(name, symbol) ERC20Permit(name);
mint
function mint(address account, uint256 amount) external;
burn
function burn(address account, uint256 amount) external;
flashFeeReceiver
function flashFeeReceiver() public view returns (address);
_flashFee
function _flashFee(address, uint256) internal view override returns (uint256);
_flashFeeReceiver
function _flashFeeReceiver() internal view override returns (address);
ERC20PermitHarness
Inherits: ERC20Permit
Functions
constructor
constructor(string memory name, string memory symbol) ERC20(name, symbol) ERC20Permit(name);
mint
function mint(address account, uint256 amount) external;
burn
function burn(address account, uint256 amount) external;
ERC20WrapperHarness
Inherits: ERC20Permit, ERC20Wrapper
Functions
constructor
constructor(IERC20 _underlying, string memory _name, string memory _symbol)
ERC20(_name, _symbol)
ERC20Permit(_name)
ERC20Wrapper(_underlying);
underlyingTotalSupply
function underlyingTotalSupply() public view returns (uint256);
underlyingBalanceOf
function underlyingBalanceOf(address account) public view returns (uint256);
underlyingAllowanceToThis
function underlyingAllowanceToThis(address account) public view returns (uint256);
recover
function recover(address account) public returns (uint256);
decimals
function decimals() public view override(ERC20Wrapper, ERC20) returns (uint8);
ERC3156FlashBorrowerHarness
Inherits: IERC3156FlashBorrower
State Variables
somethingToReturn
bytes32 somethingToReturn;
Functions
onFlashLoan
function onFlashLoan(address, address, uint256, uint256, bytes calldata) external view override returns (bytes32);
ERC721Harness
Inherits: ERC721
Functions
constructor
constructor(string memory name, string memory symbol) ERC721(name, symbol);
mint
function mint(address account, uint256 tokenId) external;
safeMint
function safeMint(address to, uint256 tokenId) external;
safeMint
function safeMint(address to, uint256 tokenId, bytes memory data) external;
burn
function burn(uint256 tokenId) external;
unsafeOwnerOf
function unsafeOwnerOf(uint256 tokenId) external view returns (address);
unsafeGetApproved
function unsafeGetApproved(uint256 tokenId) external view returns (address);
ERC721ReceiverHarness
Inherits: IERC721Receiver
Functions
onERC721Received
function onERC721Received(address, address, uint256, bytes calldata) external pure returns (bytes4);
EnumerableMapHarness
State Variables
_map
EnumerableMap.Bytes32ToBytes32Map private _map;
Functions
set
function set(bytes32 key, bytes32 value) public returns (bool);
remove
function remove(bytes32 key) public returns (bool);
contains
function contains(bytes32 key) public view returns (bool);
length
function length() public view returns (uint256);
key_at
function key_at(uint256 index) public view returns (bytes32);
value_at
function value_at(uint256 index) public view returns (bytes32);
tryGet_contains
function tryGet_contains(bytes32 key) public view returns (bool);
tryGet_value
function tryGet_value(bytes32 key) public view returns (bytes32);
get
function get(bytes32 key) public view returns (bytes32);
_positionOf
function _positionOf(bytes32 key) public view returns (uint256);
EnumerableSetHarness
State Variables
_set
EnumerableSet.Bytes32Set private _set;
Functions
add
function add(bytes32 value) public returns (bool);
remove
function remove(bytes32 value) public returns (bool);
contains
function contains(bytes32 value) public view returns (bool);
length
function length() public view returns (uint256);
at_
function at_(uint256 index) public view returns (bytes32);
_positionOf
function _positionOf(bytes32 value) public view returns (uint256);
InitializableHarness
Inherits: Initializable
Functions
initialize
function initialize() public initializer;
reinitialize
function reinitialize(uint64 n) public reinitializer(n);
disable
function disable() public;
nested_init_init
function nested_init_init() public initializer;
nested_init_reinit
function nested_init_reinit(uint64 m) public initializer;
nested_reinit_init
function nested_reinit_init(uint64 n) public reinitializer(n);
nested_reinit_reinit
function nested_reinit_reinit(uint64 n, uint64 m) public reinitializer(n);
version
function version() public view returns (uint64);
initializing
function initializing() public view returns (bool);
NoncesHarness
Inherits: Nonces
Functions
useNonce
function useNonce(address account) external returns (uint256);
useCheckedNonce
function useCheckedNonce(address account, uint256 nonce) external;
Ownable2StepHarness
Inherits: Ownable2Step
Functions
constructor
constructor(address initialOwner) Ownable(initialOwner);
restricted
function restricted() external onlyOwner;
OwnableHarness
Inherits: Ownable
Functions
constructor
constructor(address initialOwner) Ownable(initialOwner);
restricted
function restricted() external onlyOwner;
PausableHarness
Inherits: Pausable
Functions
pause
function pause() external;
unpause
function unpause() external;
onlyWhenPaused
function onlyWhenPaused() external whenPaused;
onlyWhenNotPaused
function onlyWhenNotPaused() external whenNotPaused;
TimelockControllerHarness
Inherits: TimelockController
Functions
constructor
constructor(uint256 minDelay, address[] memory proposers, address[] memory executors, address admin)
TimelockController(minDelay, proposers, executors, admin);
Contents
Contents
Contents
- AccessControlDefaultAdminRules
- AccessControlEnumerable
- IAccessControlDefaultAdminRules
- IAccessControlEnumerable
AccessControlDefaultAdminRules
Inherits: IAccessControlDefaultAdminRules, IERC5313, AccessControl
*Extension of {AccessControl} that allows specifying special rules to manage
the DEFAULT_ADMIN_ROLE holder, which is a sensitive role with special permissions
over other roles that may potentially have privileged rights in the system.
If a specific role doesn't have an admin role assigned, the holder of the
DEFAULT_ADMIN_ROLE will have the ability to grant it and revoke it.
This contract implements the following risk mitigations on top of {AccessControl}:
Only one account holds the DEFAULT_ADMIN_ROLE since deployment until it's potentially renounced.
Enforces a 2-step process to transfer the DEFAULT_ADMIN_ROLE to another account.
Enforces a configurable delay between the two steps, with the ability to cancel before the transfer is accepted.
The delay can be changed by scheduling, see {changeDefaultAdminDelay}.
Role transfers must wait at least one block after scheduling before it can be accepted.
It is not possible to use another role to manage the DEFAULT_ADMIN_ROLE.
Example usage:
contract MyToken is AccessControlDefaultAdminRules {
constructor() AccessControlDefaultAdminRules(
3 days,
msg.sender // Explicit initial `DEFAULT_ADMIN_ROLE` holder
) {}
}
```*
## State Variables
### _pendingDefaultAdmin
```solidity
address private _pendingDefaultAdmin;
_pendingDefaultAdminSchedule
uint48 private _pendingDefaultAdminSchedule;
_currentDelay
uint48 private _currentDelay;
_currentDefaultAdmin
address private _currentDefaultAdmin;
_pendingDelay
uint48 private _pendingDelay;
_pendingDelaySchedule
uint48 private _pendingDelaySchedule;
Functions
constructor
Sets the initial values for defaultAdminDelay and {defaultAdmin} address.
constructor(uint48 initialDelay, address initialDefaultAdmin);
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
owner
Gets the address of the owner.
function owner() public view virtual returns (address);
grantRole
Override AccessControl role management
See AccessControl-grantRole. Reverts for DEFAULT_ADMIN_ROLE.
function grantRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl);
revokeRole
See AccessControl-revokeRole. Reverts for DEFAULT_ADMIN_ROLE.
function revokeRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl);
renounceRole
See AccessControl-renounceRole.
For the DEFAULT_ADMIN_ROLE, it only allows renouncing in two steps by first calling
{beginDefaultAdminTransfer} to the address(0), so it's required that the {pendingDefaultAdmin} schedule
has also passed when calling this function.
After its execution, it will not be possible to call onlyRole(DEFAULT_ADMIN_ROLE) functions.
NOTE: Renouncing DEFAULT_ADMIN_ROLE will leave the contract without a {defaultAdmin},
thereby disabling any functionality that is only available for it, and the possibility of reassigning a
non-administrated role.
function renounceRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl);
_grantRole
See AccessControl-_grantRole.
For DEFAULT_ADMIN_ROLE, it only allows granting if there isn't already a {defaultAdmin} or if the
role has been previously renounced.
NOTE: Exposing this function through another mechanism may make the DEFAULT_ADMIN_ROLE
assignable again. Make sure to guarantee this is the expected behavior in your implementation.
function _grantRole(bytes32 role, address account) internal virtual override returns (bool);
_revokeRole
Attempts to revoke role from account and returns a boolean indicating if role was revoked.
Internal function without access restriction.
May emit a {RoleRevoked} event.
function _revokeRole(bytes32 role, address account) internal virtual override returns (bool);
_setRoleAdmin
See AccessControl-_setRoleAdmin. Reverts for DEFAULT_ADMIN_ROLE.
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual override;
defaultAdmin
AccessControlDefaultAdminRules accessors
Returns the address of the current DEFAULT_ADMIN_ROLE holder.
function defaultAdmin() public view virtual returns (address);
pendingDefaultAdmin
Returns a tuple of a newAdmin and an accept schedule.
After the schedule passes, the newAdmin will be able to accept the {defaultAdmin} role
by calling {acceptDefaultAdminTransfer}, completing the role transfer.
A zero value only in acceptSchedule indicates no pending admin transfer.
NOTE: A zero address newAdmin means that {defaultAdmin} is being renounced.
function pendingDefaultAdmin() public view virtual returns (address newAdmin, uint48 schedule);
defaultAdminDelay
Returns the delay required to schedule the acceptance of a {defaultAdmin} transfer started. This delay will be added to the current timestamp when calling {beginDefaultAdminTransfer} to set the acceptance schedule. NOTE: If a delay change has been scheduled, it will take effect as soon as the schedule passes, making this function returns the new delay. See {changeDefaultAdminDelay}.
function defaultAdminDelay() public view virtual returns (uint48);
pendingDefaultAdminDelay
Returns a tuple of newDelay and an effect schedule.
After the schedule passes, the newDelay will get into effect immediately for every
new {defaultAdmin} transfer started with {beginDefaultAdminTransfer}.
A zero value only in effectSchedule indicates no pending delay change.
NOTE: A zero value only for newDelay means that the next {defaultAdminDelay}
will be zero after the effect schedule.
function pendingDefaultAdminDelay() public view virtual returns (uint48 newDelay, uint48 schedule);
defaultAdminDelayIncreaseWait
Maximum time in seconds for an increase to {defaultAdminDelay} (that is scheduled using {changeDefaultAdminDelay}) to take effect. Default to 5 days. When the {defaultAdminDelay} is scheduled to be increased, it goes into effect after the new delay has passed with the purpose of giving enough time for reverting any accidental change (i.e. using milliseconds instead of seconds) that may lock the contract. However, to avoid excessive schedules, the wait is capped by this function and it can be overrode for a custom {defaultAdminDelay} increase scheduling. IMPORTANT: Make sure to add a reasonable amount of time while overriding this value, otherwise, there's a risk of setting a high new delay that goes into effect almost immediately without the possibility of human intervention in the case of an input error (eg. set milliseconds instead of seconds).
function defaultAdminDelayIncreaseWait() public view virtual returns (uint48);
beginDefaultAdminTransfer
AccessControlDefaultAdminRules public and internal setters for defaultAdmin/pendingDefaultAdmin
*Starts a {defaultAdmin} transfer by setting a {pendingDefaultAdmin} scheduled for acceptance after the current timestamp plus a {defaultAdminDelay}. Requirements:
- Only can be called by the current {defaultAdmin}. Emits a DefaultAdminRoleChangeStarted event.*
function beginDefaultAdminTransfer(address newAdmin) public virtual onlyRole(DEFAULT_ADMIN_ROLE);
_beginDefaultAdminTransfer
See beginDefaultAdminTransfer. Internal function without access restriction.
function _beginDefaultAdminTransfer(address newAdmin) internal virtual;
cancelDefaultAdminTransfer
*Cancels a {defaultAdmin} transfer previously started with {beginDefaultAdminTransfer}. A {pendingDefaultAdmin} not yet accepted can also be cancelled with this function. Requirements:
- Only can be called by the current {defaultAdmin}. May emit a DefaultAdminTransferCanceled event.*
function cancelDefaultAdminTransfer() public virtual onlyRole(DEFAULT_ADMIN_ROLE);
_cancelDefaultAdminTransfer
See cancelDefaultAdminTransfer. Internal function without access restriction.
function _cancelDefaultAdminTransfer() internal virtual;
acceptDefaultAdminTransfer
*Completes a {defaultAdmin} transfer previously started with {beginDefaultAdminTransfer}. After calling the function:
DEFAULT_ADMIN_ROLEshould be granted to the caller.DEFAULT_ADMIN_ROLEshould be revoked from the previous holder.- {pendingDefaultAdmin} should be reset to zero values. Requirements:
- Only can be called by the {pendingDefaultAdmin}'s
newAdmin. - The {pendingDefaultAdmin}'s
acceptScheduleshould've passed.*
function acceptDefaultAdminTransfer() public virtual;
_acceptDefaultAdminTransfer
See acceptDefaultAdminTransfer. Internal function without access restriction.
function _acceptDefaultAdminTransfer() internal virtual;
changeDefaultAdminDelay
AccessControlDefaultAdminRules public and internal setters for defaultAdminDelay/pendingDefaultAdminDelay
*Initiates a {defaultAdminDelay} update by setting a {pendingDefaultAdminDelay} scheduled for getting into effect after the current timestamp plus a {defaultAdminDelay}. This function guarantees that any call to {beginDefaultAdminTransfer} done between the timestamp this method is called and the {pendingDefaultAdminDelay} effect schedule will use the current {defaultAdminDelay} set before calling. The {pendingDefaultAdminDelay}'s effect schedule is defined in a way that waiting until the schedule and then calling {beginDefaultAdminTransfer} with the new delay will take at least the same as another {defaultAdmin} complete transfer (including acceptance). The schedule is designed for two scenarios:
- When the delay is changed for a larger one the schedule is
block.timestamp + newDelaycapped by {defaultAdminDelayIncreaseWait}. - When the delay is changed for a shorter one, the schedule is
block.timestamp + (current delay - new delay). A {pendingDefaultAdminDelay} that never got into effect will be canceled in favor of a new scheduled change. Requirements: - Only can be called by the current {defaultAdmin}. Emits a DefaultAdminDelayChangeScheduled event and may emit a DefaultAdminDelayChangeCanceled event.*
function changeDefaultAdminDelay(uint48 newDelay) public virtual onlyRole(DEFAULT_ADMIN_ROLE);
_changeDefaultAdminDelay
See changeDefaultAdminDelay. Internal function without access restriction.
function _changeDefaultAdminDelay(uint48 newDelay) internal virtual;
rollbackDefaultAdminDelay
*Cancels a scheduled {defaultAdminDelay} change. Requirements:
- Only can be called by the current {defaultAdmin}. May emit a DefaultAdminDelayChangeCanceled event.*
function rollbackDefaultAdminDelay() public virtual onlyRole(DEFAULT_ADMIN_ROLE);
_rollbackDefaultAdminDelay
See rollbackDefaultAdminDelay. Internal function without access restriction.
function _rollbackDefaultAdminDelay() internal virtual;
_delayChangeWait
Returns the amount of seconds to wait after the newDelay will
become the new defaultAdminDelay.
The value returned guarantees that if the delay is reduced, it will go into effect
after a wait that honors the previously set delay.
See {defaultAdminDelayIncreaseWait}.
function _delayChangeWait(uint48 newDelay) internal view virtual returns (uint48);
_setPendingDefaultAdmin
Private setters
Setter of the tuple for pending admin and its schedule. May emit a DefaultAdminTransferCanceled event.
function _setPendingDefaultAdmin(address newAdmin, uint48 newSchedule) private;
_setPendingDelay
Setter of the tuple for pending delay and its schedule. May emit a DefaultAdminDelayChangeCanceled event.
function _setPendingDelay(uint48 newDelay, uint48 newSchedule) private;
_isScheduleSet
Private helpers
Defines if an schedule is considered set. For consistency purposes.
function _isScheduleSet(uint48 schedule) private pure returns (bool);
_hasSchedulePassed
Defines if an schedule is considered passed. For consistency purposes.
function _hasSchedulePassed(uint48 schedule) private view returns (bool);
AccessControlEnumerable
Inherits: IAccessControlEnumerable, AccessControl
Extension of {AccessControl} that allows enumerating the members of each role.
State Variables
_roleMembers
mapping(bytes32 role => EnumerableSet.AddressSet) private _roleMembers;
Functions
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
getRoleMember
Returns one of the accounts that have role. index must be a
value between 0 and getRoleMemberCount, non-inclusive.
Role bearers are not sorted in any particular way, and their ordering may
change at any point.
WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
you perform all queries on the same block. See the following
https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
for more information.
function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address);
getRoleMemberCount
Returns the number of accounts that have role. Can be used
together with getRoleMember to enumerate all bearers of a role.
function getRoleMemberCount(bytes32 role) public view virtual returns (uint256);
getRoleMembers
Return all accounts that have role
WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
this function has an unbounded cost, and using it as part of a state-changing function may render the function
uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
function getRoleMembers(bytes32 role) public view virtual returns (address[] memory);
_grantRole
Overload AccessControl-_grantRole to track enumerable memberships
function _grantRole(bytes32 role, address account) internal virtual override returns (bool);
_revokeRole
Overload AccessControl-_revokeRole to track enumerable memberships
function _revokeRole(bytes32 role, address account) internal virtual override returns (bool);
IAccessControlDefaultAdminRules
Inherits: IAccessControl
External interface of AccessControlDefaultAdminRules declared to support ERC-165 detection.
Functions
defaultAdmin
Returns the address of the current DEFAULT_ADMIN_ROLE holder.
function defaultAdmin() external view returns (address);
pendingDefaultAdmin
Returns a tuple of a newAdmin and an accept schedule.
After the schedule passes, the newAdmin will be able to accept the defaultAdmin role
by calling {acceptDefaultAdminTransfer}, completing the role transfer.
A zero value only in acceptSchedule indicates no pending admin transfer.
NOTE: A zero address newAdmin means that {defaultAdmin} is being renounced.
function pendingDefaultAdmin() external view returns (address newAdmin, uint48 acceptSchedule);
defaultAdminDelay
Returns the delay required to schedule the acceptance of a defaultAdmin transfer started. This delay will be added to the current timestamp when calling {beginDefaultAdminTransfer} to set the acceptance schedule. NOTE: If a delay change has been scheduled, it will take effect as soon as the schedule passes, making this function returns the new delay. See {changeDefaultAdminDelay}.
function defaultAdminDelay() external view returns (uint48);
pendingDefaultAdminDelay
Returns a tuple of newDelay and an effect schedule.
After the schedule passes, the newDelay will get into effect immediately for every
new defaultAdmin transfer started with {beginDefaultAdminTransfer}.
A zero value only in effectSchedule indicates no pending delay change.
NOTE: A zero value only for newDelay means that the next {defaultAdminDelay}
will be zero after the effect schedule.
function pendingDefaultAdminDelay() external view returns (uint48 newDelay, uint48 effectSchedule);
beginDefaultAdminTransfer
*Starts a defaultAdmin transfer by setting a {pendingDefaultAdmin} scheduled for acceptance after the current timestamp plus a {defaultAdminDelay}. Requirements:
- Only can be called by the current {defaultAdmin}. Emits a DefaultAdminRoleChangeStarted event.*
function beginDefaultAdminTransfer(address newAdmin) external;
cancelDefaultAdminTransfer
*Cancels a defaultAdmin transfer previously started with {beginDefaultAdminTransfer}. A {pendingDefaultAdmin} not yet accepted can also be cancelled with this function. Requirements:
- Only can be called by the current {defaultAdmin}. May emit a DefaultAdminTransferCanceled event.*
function cancelDefaultAdminTransfer() external;
acceptDefaultAdminTransfer
*Completes a defaultAdmin transfer previously started with {beginDefaultAdminTransfer}. After calling the function:
DEFAULT_ADMIN_ROLEshould be granted to the caller.DEFAULT_ADMIN_ROLEshould be revoked from the previous holder.- {pendingDefaultAdmin} should be reset to zero values. Requirements:
- Only can be called by the {pendingDefaultAdmin}'s
newAdmin. - The {pendingDefaultAdmin}'s
acceptScheduleshould've passed.*
function acceptDefaultAdminTransfer() external;
changeDefaultAdminDelay
*Initiates a defaultAdminDelay update by setting a {pendingDefaultAdminDelay} scheduled for getting into effect after the current timestamp plus a {defaultAdminDelay}. This function guarantees that any call to {beginDefaultAdminTransfer} done between the timestamp this method is called and the {pendingDefaultAdminDelay} effect schedule will use the current {defaultAdminDelay} set before calling. The {pendingDefaultAdminDelay}'s effect schedule is defined in a way that waiting until the schedule and then calling {beginDefaultAdminTransfer} with the new delay will take at least the same as another {defaultAdmin} complete transfer (including acceptance). The schedule is designed for two scenarios:
- When the delay is changed for a larger one the schedule is
block.timestamp + newDelaycapped by {defaultAdminDelayIncreaseWait}. - When the delay is changed for a shorter one, the schedule is
block.timestamp + (current delay - new delay). A {pendingDefaultAdminDelay} that never got into effect will be canceled in favor of a new scheduled change. Requirements: - Only can be called by the current {defaultAdmin}. Emits a DefaultAdminDelayChangeScheduled event and may emit a DefaultAdminDelayChangeCanceled event.*
function changeDefaultAdminDelay(uint48 newDelay) external;
rollbackDefaultAdminDelay
*Cancels a scheduled defaultAdminDelay change. Requirements:
- Only can be called by the current {defaultAdmin}. May emit a DefaultAdminDelayChangeCanceled event.*
function rollbackDefaultAdminDelay() external;
defaultAdminDelayIncreaseWait
Maximum time in seconds for an increase to defaultAdminDelay (that is scheduled using {changeDefaultAdminDelay}) to take effect. Default to 5 days. When the {defaultAdminDelay} is scheduled to be increased, it goes into effect after the new delay has passed with the purpose of giving enough time for reverting any accidental change (i.e. using milliseconds instead of seconds) that may lock the contract. However, to avoid excessive schedules, the wait is capped by this function and it can be overrode for a custom {defaultAdminDelay} increase scheduling. IMPORTANT: Make sure to add a reasonable amount of time while overriding this value, otherwise, there's a risk of setting a high new delay that goes into effect almost immediately without the possibility of human intervention in the case of an input error (eg. set milliseconds instead of seconds).
function defaultAdminDelayIncreaseWait() external view returns (uint48);
Events
DefaultAdminTransferScheduled
Emitted when a defaultAdmin transfer is started, setting newAdmin as the next
address to become the {defaultAdmin} by calling {acceptDefaultAdminTransfer} only after acceptSchedule
passes.
event DefaultAdminTransferScheduled(address indexed newAdmin, uint48 acceptSchedule);
DefaultAdminTransferCanceled
Emitted when a pendingDefaultAdmin is reset if it was never accepted, regardless of its schedule.
event DefaultAdminTransferCanceled();
DefaultAdminDelayChangeScheduled
Emitted when a defaultAdminDelay change is started, setting newDelay as the next
delay to be applied between default admin transfer after effectSchedule has passed.
event DefaultAdminDelayChangeScheduled(uint48 newDelay, uint48 effectSchedule);
DefaultAdminDelayChangeCanceled
Emitted when a pendingDefaultAdminDelay is reset if its schedule didn't pass.
event DefaultAdminDelayChangeCanceled();
Errors
AccessControlInvalidDefaultAdmin
The new default admin is not a valid default admin.
error AccessControlInvalidDefaultAdmin(address defaultAdmin);
AccessControlEnforcedDefaultAdminRules
*At least one of the following rules was violated:
- The
DEFAULT_ADMIN_ROLEmust only be managed by itself. - The
DEFAULT_ADMIN_ROLEmust only be held by one account at the time. - Any
DEFAULT_ADMIN_ROLEtransfer must be in two delayed steps.*
error AccessControlEnforcedDefaultAdminRules();
AccessControlEnforcedDefaultAdminDelay
The delay for transferring the default admin delay is enforced and
the operation must wait until schedule.
NOTE: schedule can be 0 indicating there's no transfer scheduled.
error AccessControlEnforcedDefaultAdminDelay(uint48 schedule);
IAccessControlEnumerable
Inherits: IAccessControl
External interface of AccessControlEnumerable declared to support ERC-165 detection.
Functions
getRoleMember
Returns one of the accounts that have role. index must be a
value between 0 and getRoleMemberCount, non-inclusive.
Role bearers are not sorted in any particular way, and their ordering may
change at any point.
WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
you perform all queries on the same block. See the following
https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
for more information.
function getRoleMember(bytes32 role, uint256 index) external view returns (address);
getRoleMemberCount
Returns the number of accounts that have role. Can be used
together with getRoleMember to enumerate all bearers of a role.
function getRoleMemberCount(bytes32 role) external view returns (uint256);
Contents
AccessManaged
Inherits: Context, IAccessManaged
This contract module makes available a restricted modifier. Functions decorated with this modifier will be
permissioned according to an "authority": a contract like {AccessManager} that follows the {IAuthority} interface,
implementing a policy that allows certain callers to access certain functions.
IMPORTANT: The restricted modifier should never be used on internal functions, judiciously used in public
functions, and ideally only used in external functions. See {restricted}.
State Variables
_authority
address private _authority;
_consumingSchedule
bool private _consumingSchedule;
Functions
constructor
Initializes the contract connected to an initial authority.
constructor(address initialAuthority);
restricted
*Restricts access to a function as defined by the connected Authority for this contract and the caller and selector of the function that entered the contract. [IMPORTANT]
In general, this modifier should only be used on external functions. It is okay to use it on public
functions that are used as external entry points and are not called internally. Unless you know what you're
doing, it should never be used on internal functions. Failure to follow these rules can have critical security
implications! This is because the permissions are determined by the function that entered the contract, i.e. the
function at the bottom of the call stack, and not the function where the modifier is visible in the source code.
[WARNING]
Avoid adding this modifier to the https://docs.soliditylang.org/en/v0.8.20/contracts.html#receive-ether-function[receive()]
function or the https://docs.soliditylang.org/en/v0.8.20/contracts.html#fallback-function[fallback()]. These
functions are the only execution paths where a function selector cannot be unambiguously determined from the calldata
since the selector defaults to 0x00000000 in the receive() function and similarly in the fallback() function
if no calldata is provided. (See _checkCanCall).
The receive() function will always panic whereas the fallback() may panic depending on the calldata length.
====*
modifier restricted();
authority
Returns the current authority.
function authority() public view virtual returns (address);
setAuthority
Transfers control to a new authority. The caller must be the current authority.
function setAuthority(address newAuthority) public virtual;
isConsumingScheduledOp
Returns true only in the context of a delayed restricted call, at the moment that the scheduled operation is being consumed. Prevents denial of service for delayed restricted calls in the case that the contract performs attacker controlled calls.
function isConsumingScheduledOp() public view returns (bytes4);
_setAuthority
Transfers control to a new authority. Internal function with no access restriction. Allows bypassing the permissions set by the current authority.
function _setAuthority(address newAuthority) internal virtual;
_checkCanCall
Reverts if the caller is not allowed to call the function identified by a selector. Panics if the calldata is less than 4 bytes long.
function _checkCanCall(address caller, bytes calldata data) internal virtual;
AccessManager
Inherits: Context, Multicall, IAccessManager
AccessManager is a central contract to store the permissions of a system.
A smart contract under the control of an AccessManager instance is known as a target, and will inherit from the
{AccessManaged} contract, be connected to this contract as its manager and implement the {AccessManaged-restricted}
modifier on a set of functions selected to be permissioned. Note that any function without this setup won't be
effectively restricted.
The restriction rules for such functions are defined in terms of "roles" identified by an uint64 and scoped
by target (address) and function selectors (bytes4). These roles are stored in this contract and can be
configured by admins (ADMIN_ROLE members) after a delay (see {getTargetAdminDelay}).
For each target contract, admins can configure the following without any delay:
The target's {AccessManaged-authority} via {updateAuthority}.
Close or open a target via {setTargetClosed} keeping the permissions intact.
The roles that are allowed (or disallowed) to call a given function (identified by its selector) through {setTargetFunctionRole}.
By default every address is member of the PUBLIC_ROLE and every target function is restricted to the ADMIN_ROLE until configured otherwise.
Additionally, each role has the following configuration options restricted to this manager's admins:
A role's admin role via {setRoleAdmin} who can grant or revoke roles.
A role's guardian role via {setRoleGuardian} who's allowed to cancel operations.
A delay in which a role takes effect after being granted through {setGrantDelay}.
A delay of any target's admin action via {setTargetAdminDelay}.
A role label for discoverability purposes with {labelRole}.
Any account can be added and removed into any number of these roles by using the {grantRole} and {revokeRole} functions
restricted to each role's admin (see {getRoleAdmin}).
Since all the permissions of the managed system can be modified by the admins of this instance, it is expected that
they will be highly secured (e.g., a multisig or a well-configured DAO).
NOTE: This contract implements a form of the {IAuthority} interface, but {canCall} has additional return data so it
doesn't inherit IAuthority. It is however compatible with the IAuthority interface since the first 32 bytes of
the return data are a boolean as expected by that interface.
NOTE: Systems that implement other access control mechanisms (for example using {Ownable}) can be paired with an
{AccessManager} by transferring permissions (ownership in the case of {Ownable}) directly to the {AccessManager}.
Users will be able to interact with these contracts through the {execute} function, following the access rules
registered in the {AccessManager}. Keep in mind that in that context, the msg.sender seen by restricted functions
will be {AccessManager} itself.
WARNING: When granting permissions over an {Ownable} or {AccessControl} contract to an {AccessManager}, be very
mindful of the danger associated with functions such as {Ownable-renounceOwnership} or
{AccessControl-renounceRole}.
State Variables
ADMIN_ROLE
The identifier of the admin role. Required to perform most configuration operations including other roles' management and target restrictions.
uint64 public constant ADMIN_ROLE = type(uint64).min;
PUBLIC_ROLE
The identifier of the public role. Automatically granted to all addresses with no delay.
uint64 public constant PUBLIC_ROLE = type(uint64).max;
_targets
mapping(address target => TargetConfig mode) private _targets;
_roles
mapping(uint64 roleId => Role) private _roles;
_schedules
mapping(bytes32 operationId => Schedule) private _schedules;
_executionId
bytes32 private _executionId;
Functions
onlyAuthorized
Check that the caller is authorized to perform the operation. See AccessManager description for a detailed breakdown of the authorization logic.
modifier onlyAuthorized();
constructor
constructor(address initialAdmin);
canCall
Check if an address (caller) is authorised to call a given function on a given contract directly (with
no restriction). Additionally, it returns the delay needed to perform the call indirectly through the {schedule}
& {execute} workflow.
This function is usually called by the targeted contract to control immediate execution of restricted functions.
Therefore we only return true if the call can be performed without any delay. If the call is subject to a
previously set delay (not zero), then the function should return false and the caller should schedule the operation
for future execution.
If allowed is true, the delay can be disregarded and the operation can be immediately executed, otherwise
the operation can be executed if and only if delay is greater than 0.
NOTE: The IAuthority interface does not include the uint32 delay. This is an extension of that interface that
is backward compatible. Some contracts may thus ignore the second return argument. In that case they will fail
to identify the indirect workflow, and will consider calls that require a delay to be forbidden.
NOTE: This function does not report the permissions of the admin functions in the manager itself. These are defined by the
{AccessManager} documentation.
function canCall(address caller, address target, bytes4 selector)
public
view
virtual
returns (bool immediate, uint32 delay);
expiration
Expiration delay for scheduled proposals. Defaults to 1 week. IMPORTANT: Avoid overriding the expiration with 0. Otherwise every contract proposal will be expired immediately, disabling any scheduling usage.
function expiration() public view virtual returns (uint32);
minSetback
Minimum setback for all delay updates, with the exception of execution delays. It can be increased without setback (and reset via {revokeRole} in the case event of an accidental increase). Defaults to 5 days.
function minSetback() public view virtual returns (uint32);
isTargetClosed
Get whether the contract is closed disabling any access. Otherwise role permissions are applied. NOTE: When the manager itself is closed, admin functions are still accessible to avoid locking the contract.
function isTargetClosed(address target) public view virtual returns (bool);
getTargetFunctionRole
Get the role required to call a function.
function getTargetFunctionRole(address target, bytes4 selector) public view virtual returns (uint64);
getTargetAdminDelay
Get the admin delay for a target contract. Changes to contract configuration are subject to this delay.
function getTargetAdminDelay(address target) public view virtual returns (uint32);
getRoleAdmin
Get the id of the role that acts as an admin for the given role. The admin permission is required to grant the role, revoke the role and update the execution delay to execute an operation that is restricted to this role.
function getRoleAdmin(uint64 roleId) public view virtual returns (uint64);
getRoleGuardian
Get the role that acts as a guardian for a given role. The guardian permission allows canceling operations that have been scheduled under the role.
function getRoleGuardian(uint64 roleId) public view virtual returns (uint64);
getRoleGrantDelay
Get the role current grant delay. Its value may change at any point without an event emitted following a call to {setGrantDelay}. Changes to this value, including effect timepoint are notified in advance by the {RoleGrantDelayChanged} event.
function getRoleGrantDelay(uint64 roleId) public view virtual returns (uint32);
getAccess
Get the access details for a given account for a given role. These details include the timepoint at which membership becomes active, and the delay applied to all operation by this user that requires this permission level. Returns: [0] Timestamp at which the account membership becomes valid. 0 means role is not granted. [1] Current execution delay for the account. [2] Pending execution delay for the account. [3] Timestamp at which the pending execution delay will become active. 0 means no delay update is scheduled.
function getAccess(uint64 roleId, address account)
public
view
virtual
returns (uint48 since, uint32 currentDelay, uint32 pendingDelay, uint48 effect);
hasRole
Check if a given account currently has the permission level corresponding to a given role. Note that this permission might be associated with an execution delay. {getAccess} can provide more details.
function hasRole(uint64 roleId, address account) public view virtual returns (bool isMember, uint32 executionDelay);
labelRole
*Give a label to a role, for improved role discoverability by UIs. Requirements:
- the caller must be a global admin Emits a {RoleLabel} event.*
function labelRole(uint64 roleId, string calldata label) public virtual onlyAuthorized;
grantRole
*Add account to roleId, or change its execution delay.
This gives the account the authorization to call any function that is restricted to this role. An optional
execution delay (in seconds) can be set. If that delay is non 0, the user is required to schedule any operation
that is restricted to members of this role. The user will only be able to execute the operation after the delay has
passed, before it has expired. During this period, admin and guardians can cancel the operation (see {cancel}).
If the account has already been granted this role, the execution delay will be updated. This update is not
immediate and follows the delay rules. For example, if a user currently has a delay of 3 hours, and this is
called to reduce that delay to 1 hour, the new delay will take some time to take effect, enforcing that any
operation executed in the 3 hours that follows this update was indeed scheduled before this update.
Requirements:
- the caller must be an admin for the role (see {getRoleAdmin})
- granted role must not be the
PUBLIC_ROLEEmits a {RoleGranted} event.*
function grantRole(uint64 roleId, address account, uint32 executionDelay) public virtual onlyAuthorized;
revokeRole
*Remove an account from a role, with immediate effect. If the account does not have the role, this call has no effect. Requirements:
- the caller must be an admin for the role (see {getRoleAdmin})
- revoked role must not be the
PUBLIC_ROLEEmits a {RoleRevoked} event if the account had the role.*
function revokeRole(uint64 roleId, address account) public virtual onlyAuthorized;
renounceRole
*Renounce role permissions for the calling account with immediate effect. If the sender is not in the role this call has no effect. Requirements:
- the caller must be
callerConfirmation. Emits a {RoleRevoked} event if the account had the role.*
function renounceRole(uint64 roleId, address callerConfirmation) public virtual;
setRoleAdmin
*Change admin role for a given role. Requirements:
- the caller must be a global admin Emits a {RoleAdminChanged} event*
function setRoleAdmin(uint64 roleId, uint64 admin) public virtual onlyAuthorized;
setRoleGuardian
*Change guardian role for a given role. Requirements:
- the caller must be a global admin Emits a {RoleGuardianChanged} event*
function setRoleGuardian(uint64 roleId, uint64 guardian) public virtual onlyAuthorized;
setGrantDelay
*Update the delay for granting a roleId.
Requirements:
- the caller must be a global admin Emits a {RoleGrantDelayChanged} event.*
function setGrantDelay(uint64 roleId, uint32 newDelay) public virtual onlyAuthorized;
_grantRole
Internal version of grantRole without access control. Returns true if the role was newly granted. Emits a {RoleGranted} event.
function _grantRole(uint64 roleId, address account, uint32 grantDelay, uint32 executionDelay)
internal
virtual
returns (bool);
_revokeRole
Internal version of revokeRole without access control. This logic is also used by {renounceRole}. Returns true if the role was previously granted. Emits a {RoleRevoked} event if the account had the role.
function _revokeRole(uint64 roleId, address account) internal virtual returns (bool);
_setRoleAdmin
Internal version of setRoleAdmin without access control.
Emits a {RoleAdminChanged} event.
NOTE: Setting the admin role as the PUBLIC_ROLE is allowed, but it will effectively allow
anyone to set grant or revoke such role.
function _setRoleAdmin(uint64 roleId, uint64 admin) internal virtual;
_setRoleGuardian
Internal version of setRoleGuardian without access control.
Emits a {RoleGuardianChanged} event.
NOTE: Setting the guardian role as the PUBLIC_ROLE is allowed, but it will effectively allow
anyone to cancel any scheduled operation for such role.
function _setRoleGuardian(uint64 roleId, uint64 guardian) internal virtual;
_setGrantDelay
Internal version of setGrantDelay without access control. Emits a {RoleGrantDelayChanged} event.
function _setGrantDelay(uint64 roleId, uint32 newDelay) internal virtual;
setTargetFunctionRole
*Set the role required to call functions identified by the selectors in the target contract.
Requirements:
- the caller must be a global admin Emits a {TargetFunctionRoleUpdated} event per selector.*
function setTargetFunctionRole(address target, bytes4[] calldata selectors, uint64 roleId)
public
virtual
onlyAuthorized;
_setTargetFunctionRole
Internal version of setTargetFunctionRole without access control. Emits a {TargetFunctionRoleUpdated} event.
function _setTargetFunctionRole(address target, bytes4 selector, uint64 roleId) internal virtual;
setTargetAdminDelay
*Set the delay for changing the configuration of a given target contract. Requirements:
- the caller must be a global admin Emits a {TargetAdminDelayUpdated} event.*
function setTargetAdminDelay(address target, uint32 newDelay) public virtual onlyAuthorized;
_setTargetAdminDelay
Internal version of setTargetAdminDelay without access control. Emits a {TargetAdminDelayUpdated} event.
function _setTargetAdminDelay(address target, uint32 newDelay) internal virtual;
setTargetClosed
*Set the closed flag for a contract. Closing the manager itself won't disable access to admin methods to avoid locking the contract. Requirements:
- the caller must be a global admin Emits a {TargetClosed} event.*
function setTargetClosed(address target, bool closed) public virtual onlyAuthorized;
_setTargetClosed
Set the closed flag for a contract. This is an internal setter with no access restrictions. Emits a {TargetClosed} event.
function _setTargetClosed(address target, bool closed) internal virtual;
getSchedule
Return the timepoint at which a scheduled operation will be ready for execution. This returns 0 if the operation is not yet scheduled, has expired, was executed, or was canceled.
function getSchedule(bytes32 id) public view virtual returns (uint48);
getNonce
Return the nonce for the latest scheduled operation with a given id. Returns 0 if the operation has never been scheduled.
function getNonce(bytes32 id) public view virtual returns (uint32);
schedule
Schedule a delayed operation for future execution, and return the operation identifier. It is possible to
choose the timestamp at which the operation becomes executable as long as it satisfies the execution delays
required for the caller. The special value zero will automatically set the earliest possible time.
Returns the operationId that was scheduled. Since this value is a hash of the parameters, it can reoccur when
the same parameters are used; if this is relevant, the returned nonce can be used to uniquely identify this
scheduled operation from other occurrences of the same operationId in invocations of {execute} and {cancel}.
Emits a {OperationScheduled} event.
NOTE: It is not possible to concurrently schedule more than one operation with the same target and data. If
this is necessary, a random byte can be appended to data to act as a salt that will be ignored by the target
contract if it is using standard Solidity ABI encoding.
function schedule(address target, bytes calldata data, uint48 when)
public
virtual
returns (bytes32 operationId, uint32 nonce);
_checkNotScheduled
Reverts if the operation is currently scheduled and has not expired. NOTE: This function was introduced due to stack too deep errors in schedule.
function _checkNotScheduled(bytes32 operationId) private view;
execute
Execute a function that is delay restricted, provided it was properly scheduled beforehand, or the execution delay is 0. Returns the nonce that identifies the previously scheduled operation that is executed, or 0 if the operation wasn't previously scheduled (if the caller doesn't have an execution delay). Emits an {OperationExecuted} event only if the call was scheduled and delayed.
function execute(address target, bytes calldata data) public payable virtual returns (uint32);
cancel
*Cancel a scheduled (delayed) operation. Returns the nonce that identifies the previously scheduled operation that is cancelled. Requirements:
- the caller must be the proposer, a guardian of the targeted function, or a global admin Emits a {OperationCanceled} event.*
function cancel(address caller, address target, bytes calldata data) public virtual returns (uint32);
consumeScheduledOp
Consume a scheduled operation targeting the caller. If such an operation exists, mark it as consumed (emit an {OperationExecuted} event and clean the state). Otherwise, throw an error. This is useful for contract that want to enforce that calls targeting them were scheduled on the manager, with all the verifications that it implies. Emit a {OperationExecuted} event.
function consumeScheduledOp(address caller, bytes calldata data) public virtual;
_consumeScheduledOp
Internal variant of consumeScheduledOp that operates on bytes32 operationId. Returns the nonce of the scheduled operation that is consumed.
function _consumeScheduledOp(bytes32 operationId) internal virtual returns (uint32);
hashOperation
Hashing function for delayed operations.
function hashOperation(address caller, address target, bytes calldata data) public view virtual returns (bytes32);
updateAuthority
*Changes the authority of a target managed by this manager instance. Requirements:
- the caller must be a global admin*
function updateAuthority(address target, address newAuthority) public virtual onlyAuthorized;
_checkAuthorized
Check if the current call is authorized according to admin and roles logic. WARNING: Carefully review the considerations of AccessManaged-restricted since they apply to this modifier.
function _checkAuthorized() private;
_getAdminRestrictions
*Get the admin restrictions of a given function call based on the function and arguments involved. Returns:
- bool restricted: does this data match a restricted operation
- uint64: which role is this operation restricted to
- uint32: minimum delay to enforce for that operation (max between operation's delay and admin's execution delay)*
function _getAdminRestrictions(bytes calldata data)
private
view
returns (bool adminRestricted, uint64 roleAdminId, uint32 executionDelay);
_canCallExtended
*An extended version of canCall for internal usage that checks {_canCallSelf} when the target is this contract. Returns:
- bool immediate: whether the operation can be executed immediately (with no delay)
- uint32 delay: the execution delay*
function _canCallExtended(address caller, address target, bytes calldata data)
private
view
returns (bool immediate, uint32 delay);
_canCallSelf
A version of canCall that checks for restrictions in this contract.
function _canCallSelf(address caller, bytes calldata data) private view returns (bool immediate, uint32 delay);
_isExecuting
Returns true if a call with target and selector is being executed via {executed}.
function _isExecuting(address target, bytes4 selector) private view returns (bool);
_isExpired
Returns true if a schedule timepoint is past its expiration deadline.
function _isExpired(uint48 timepoint) private view returns (bool);
_checkSelector
Extracts the selector from calldata. Panics if data is not at least 4 bytes
function _checkSelector(bytes calldata data) private pure returns (bytes4);
_hashExecutionId
Hashing function for execute protection
function _hashExecutionId(address target, bytes4 selector) private pure returns (bytes32);
Structs
TargetConfig
struct TargetConfig {
mapping(bytes4 selector => uint64 roleId) allowedRoles;
Time.Delay adminDelay;
bool closed;
}
Access
struct Access {
uint48 since;
Time.Delay delay;
}
Role
struct Role {
mapping(address user => Access access) members;
uint64 admin;
uint64 guardian;
Time.Delay grantDelay;
}
Schedule
struct Schedule {
uint48 timepoint;
uint32 nonce;
}
AuthorityUtils
Functions
canCallWithDelay
Since AccessManager implements an extended IAuthority interface, invoking canCall with backwards compatibility
for the preexisting IAuthority interface requires special care to avoid reverting on insufficient return data.
This helper function takes care of invoking canCall in a backwards compatible way without reverting.
function canCallWithDelay(address authority, address caller, address target, bytes4 selector)
internal
view
returns (bool immediate, uint32 delay);
IAccessManaged
Functions
authority
Returns the current authority.
function authority() external view returns (address);
setAuthority
Transfers control to a new authority. The caller must be the current authority.
function setAuthority(address) external;
isConsumingScheduledOp
Returns true only in the context of a delayed restricted call, at the moment that the scheduled operation is being consumed. Prevents denial of service for delayed restricted calls in the case that the contract performs attacker controlled calls.
function isConsumingScheduledOp() external view returns (bytes4);
Events
AuthorityUpdated
Authority that manages this contract was updated.
event AuthorityUpdated(address authority);
Errors
AccessManagedUnauthorized
error AccessManagedUnauthorized(address caller);
AccessManagedRequiredDelay
error AccessManagedRequiredDelay(address caller, uint32 delay);
AccessManagedInvalidAuthority
error AccessManagedInvalidAuthority(address authority);
IAccessManager
Functions
canCall
Check if an address (caller) is authorised to call a given function on a given contract directly (with
no restriction). Additionally, it returns the delay needed to perform the call indirectly through the schedule
& {execute} workflow.
This function is usually called by the targeted contract to control immediate execution of restricted functions.
Therefore we only return true if the call can be performed without any delay. If the call is subject to a
previously set delay (not zero), then the function should return false and the caller should schedule the operation
for future execution.
If allowed is true, the delay can be disregarded and the operation can be immediately executed, otherwise
the operation can be executed if and only if delay is greater than 0.
NOTE: The IAuthority interface does not include the uint32 delay. This is an extension of that interface that
is backward compatible. Some contracts may thus ignore the second return argument. In that case they will fail
to identify the indirect workflow, and will consider calls that require a delay to be forbidden.
NOTE: This function does not report the permissions of the admin functions in the manager itself. These are defined by the
{AccessManager} documentation.
function canCall(address caller, address target, bytes4 selector) external view returns (bool allowed, uint32 delay);
expiration
Expiration delay for scheduled proposals. Defaults to 1 week. IMPORTANT: Avoid overriding the expiration with 0. Otherwise every contract proposal will be expired immediately, disabling any scheduling usage.
function expiration() external view returns (uint32);
minSetback
Minimum setback for all delay updates, with the exception of execution delays. It can be increased without setback (and reset via revokeRole in the case event of an accidental increase). Defaults to 5 days.
function minSetback() external view returns (uint32);
isTargetClosed
Get whether the contract is closed disabling any access. Otherwise role permissions are applied. NOTE: When the manager itself is closed, admin functions are still accessible to avoid locking the contract.
function isTargetClosed(address target) external view returns (bool);
getTargetFunctionRole
Get the role required to call a function.
function getTargetFunctionRole(address target, bytes4 selector) external view returns (uint64);
getTargetAdminDelay
Get the admin delay for a target contract. Changes to contract configuration are subject to this delay.
function getTargetAdminDelay(address target) external view returns (uint32);
getRoleAdmin
Get the id of the role that acts as an admin for the given role. The admin permission is required to grant the role, revoke the role and update the execution delay to execute an operation that is restricted to this role.
function getRoleAdmin(uint64 roleId) external view returns (uint64);
getRoleGuardian
Get the role that acts as a guardian for a given role. The guardian permission allows canceling operations that have been scheduled under the role.
function getRoleGuardian(uint64 roleId) external view returns (uint64);
getRoleGrantDelay
Get the role current grant delay. Its value may change at any point without an event emitted following a call to setGrantDelay. Changes to this value, including effect timepoint are notified in advance by the {RoleGrantDelayChanged} event.
function getRoleGrantDelay(uint64 roleId) external view returns (uint32);
getAccess
Get the access details for a given account for a given role. These details include the timepoint at which membership becomes active, and the delay applied to all operation by this user that requires this permission level. Returns: [0] Timestamp at which the account membership becomes valid. 0 means role is not granted. [1] Current execution delay for the account. [2] Pending execution delay for the account. [3] Timestamp at which the pending execution delay will become active. 0 means no delay update is scheduled.
function getAccess(uint64 roleId, address account)
external
view
returns (uint48 since, uint32 currentDelay, uint32 pendingDelay, uint48 effect);
hasRole
Check if a given account currently has the permission level corresponding to a given role. Note that this permission might be associated with an execution delay. getAccess can provide more details.
function hasRole(uint64 roleId, address account) external view returns (bool isMember, uint32 executionDelay);
labelRole
*Give a label to a role, for improved role discoverability by UIs. Requirements:
- the caller must be a global admin Emits a RoleLabel event.*
function labelRole(uint64 roleId, string calldata label) external;
grantRole
*Add account to roleId, or change its execution delay.
This gives the account the authorization to call any function that is restricted to this role. An optional
execution delay (in seconds) can be set. If that delay is non 0, the user is required to schedule any operation
that is restricted to members of this role. The user will only be able to execute the operation after the delay has
passed, before it has expired. During this period, admin and guardians can cancel the operation (see cancel).
If the account has already been granted this role, the execution delay will be updated. This update is not
immediate and follows the delay rules. For example, if a user currently has a delay of 3 hours, and this is
called to reduce that delay to 1 hour, the new delay will take some time to take effect, enforcing that any
operation executed in the 3 hours that follows this update was indeed scheduled before this update.
Requirements:
- the caller must be an admin for the role (see {getRoleAdmin})
- granted role must not be the
PUBLIC_ROLEEmits a {RoleGranted} event.*
function grantRole(uint64 roleId, address account, uint32 executionDelay) external;
revokeRole
*Remove an account from a role, with immediate effect. If the account does not have the role, this call has no effect. Requirements:
- the caller must be an admin for the role (see getRoleAdmin)
- revoked role must not be the
PUBLIC_ROLEEmits a {RoleRevoked} event if the account had the role.*
function revokeRole(uint64 roleId, address account) external;
renounceRole
*Renounce role permissions for the calling account with immediate effect. If the sender is not in the role this call has no effect. Requirements:
- the caller must be
callerConfirmation. Emits a RoleRevoked event if the account had the role.*
function renounceRole(uint64 roleId, address callerConfirmation) external;
setRoleAdmin
*Change admin role for a given role. Requirements:
- the caller must be a global admin Emits a RoleAdminChanged event*
function setRoleAdmin(uint64 roleId, uint64 admin) external;
setRoleGuardian
*Change guardian role for a given role. Requirements:
- the caller must be a global admin Emits a RoleGuardianChanged event*
function setRoleGuardian(uint64 roleId, uint64 guardian) external;
setGrantDelay
*Update the delay for granting a roleId.
Requirements:
- the caller must be a global admin Emits a RoleGrantDelayChanged event.*
function setGrantDelay(uint64 roleId, uint32 newDelay) external;
setTargetFunctionRole
*Set the role required to call functions identified by the selectors in the target contract.
Requirements:
- the caller must be a global admin Emits a TargetFunctionRoleUpdated event per selector.*
function setTargetFunctionRole(address target, bytes4[] calldata selectors, uint64 roleId) external;
setTargetAdminDelay
*Set the delay for changing the configuration of a given target contract. Requirements:
- the caller must be a global admin Emits a TargetAdminDelayUpdated event.*
function setTargetAdminDelay(address target, uint32 newDelay) external;
setTargetClosed
*Set the closed flag for a contract. Closing the manager itself won't disable access to admin methods to avoid locking the contract. Requirements:
- the caller must be a global admin Emits a TargetClosed event.*
function setTargetClosed(address target, bool closed) external;
getSchedule
Return the timepoint at which a scheduled operation will be ready for execution. This returns 0 if the operation is not yet scheduled, has expired, was executed, or was canceled.
function getSchedule(bytes32 id) external view returns (uint48);
getNonce
Return the nonce for the latest scheduled operation with a given id. Returns 0 if the operation has never been scheduled.
function getNonce(bytes32 id) external view returns (uint32);
schedule
Schedule a delayed operation for future execution, and return the operation identifier. It is possible to
choose the timestamp at which the operation becomes executable as long as it satisfies the execution delays
required for the caller. The special value zero will automatically set the earliest possible time.
Returns the operationId that was scheduled. Since this value is a hash of the parameters, it can reoccur when
the same parameters are used; if this is relevant, the returned nonce can be used to uniquely identify this
scheduled operation from other occurrences of the same operationId in invocations of execute and {cancel}.
Emits a {OperationScheduled} event.
NOTE: It is not possible to concurrently schedule more than one operation with the same target and data. If
this is necessary, a random byte can be appended to data to act as a salt that will be ignored by the target
contract if it is using standard Solidity ABI encoding.
function schedule(address target, bytes calldata data, uint48 when)
external
returns (bytes32 operationId, uint32 nonce);
execute
Execute a function that is delay restricted, provided it was properly scheduled beforehand, or the execution delay is 0. Returns the nonce that identifies the previously scheduled operation that is executed, or 0 if the operation wasn't previously scheduled (if the caller doesn't have an execution delay). Emits an OperationExecuted event only if the call was scheduled and delayed.
function execute(address target, bytes calldata data) external payable returns (uint32);
cancel
*Cancel a scheduled (delayed) operation. Returns the nonce that identifies the previously scheduled operation that is cancelled. Requirements:
- the caller must be the proposer, a guardian of the targeted function, or a global admin Emits a OperationCanceled event.*
function cancel(address caller, address target, bytes calldata data) external returns (uint32);
consumeScheduledOp
Consume a scheduled operation targeting the caller. If such an operation exists, mark it as consumed (emit an OperationExecuted event and clean the state). Otherwise, throw an error. This is useful for contract that want to enforce that calls targeting them were scheduled on the manager, with all the verifications that it implies. Emit a {OperationExecuted} event.
function consumeScheduledOp(address caller, bytes calldata data) external;
hashOperation
Hashing function for delayed operations.
function hashOperation(address caller, address target, bytes calldata data) external view returns (bytes32);
updateAuthority
*Changes the authority of a target managed by this manager instance. Requirements:
- the caller must be a global admin*
function updateAuthority(address target, address newAuthority) external;
Events
OperationScheduled
A delayed operation was scheduled.
event OperationScheduled(
bytes32 indexed operationId, uint32 indexed nonce, uint48 schedule, address caller, address target, bytes data
);
OperationExecuted
A scheduled operation was executed.
event OperationExecuted(bytes32 indexed operationId, uint32 indexed nonce);
OperationCanceled
A scheduled operation was canceled.
event OperationCanceled(bytes32 indexed operationId, uint32 indexed nonce);
RoleLabel
Informational labelling for a roleId.
event RoleLabel(uint64 indexed roleId, string label);
RoleGranted
Emitted when account is granted roleId.
NOTE: The meaning of the since argument depends on the newMember argument.
If the role is granted to a new member, the since argument indicates when the account becomes a member of the role,
otherwise it indicates the execution delay for this account and roleId is updated.
event RoleGranted(uint64 indexed roleId, address indexed account, uint32 delay, uint48 since, bool newMember);
RoleRevoked
Emitted when account membership or roleId is revoked. Unlike granting, revoking is instantaneous.
event RoleRevoked(uint64 indexed roleId, address indexed account);
RoleAdminChanged
Role acting as admin over a given roleId is updated.
event RoleAdminChanged(uint64 indexed roleId, uint64 indexed admin);
RoleGuardianChanged
Role acting as guardian over a given roleId is updated.
event RoleGuardianChanged(uint64 indexed roleId, uint64 indexed guardian);
RoleGrantDelayChanged
Grant delay for a given roleId will be updated to delay when since is reached.
event RoleGrantDelayChanged(uint64 indexed roleId, uint32 delay, uint48 since);
TargetClosed
Target mode is updated (true = closed, false = open).
event TargetClosed(address indexed target, bool closed);
TargetFunctionRoleUpdated
Role required to invoke selector on target is updated to roleId.
event TargetFunctionRoleUpdated(address indexed target, bytes4 selector, uint64 indexed roleId);
TargetAdminDelayUpdated
Admin delay for a given target will be updated to delay when since is reached.
event TargetAdminDelayUpdated(address indexed target, uint32 delay, uint48 since);
Errors
AccessManagerAlreadyScheduled
error AccessManagerAlreadyScheduled(bytes32 operationId);
AccessManagerNotScheduled
error AccessManagerNotScheduled(bytes32 operationId);
AccessManagerNotReady
error AccessManagerNotReady(bytes32 operationId);
AccessManagerExpired
error AccessManagerExpired(bytes32 operationId);
AccessManagerLockedRole
error AccessManagerLockedRole(uint64 roleId);
AccessManagerBadConfirmation
error AccessManagerBadConfirmation();
AccessManagerUnauthorizedAccount
error AccessManagerUnauthorizedAccount(address msgsender, uint64 roleId);
AccessManagerUnauthorizedCall
error AccessManagerUnauthorizedCall(address caller, address target, bytes4 selector);
AccessManagerUnauthorizedConsume
error AccessManagerUnauthorizedConsume(address target);
AccessManagerUnauthorizedCancel
error AccessManagerUnauthorizedCancel(address msgsender, address caller, address target, bytes4 selector);
AccessManagerInvalidInitialAdmin
error AccessManagerInvalidInitialAdmin(address initialAdmin);
IAuthority
Standard interface for permissioning originally defined in Dappsys.
Functions
canCall
Returns true if the caller can invoke on a target the function identified by a function selector.
function canCall(address caller, address target, bytes4 selector) external view returns (bool allowed);
AccessControl
Inherits: Context, IAccessControl, ERC165
*Contract module that allows children to implement role-based access
control mechanisms. This is a lightweight version that doesn't allow enumerating role
members except through off-chain means by accessing the contract event logs. Some
applications may benefit from on-chain enumerability, for those cases see
{AccessControlEnumerable}.
Roles are referred to by their bytes32 identifier. These should be exposed
in the external API and be unique. The best way to achieve this is by
using public constant hash digests:
bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
Roles can be used to represent a set of permissions. To restrict access to a function call, use {hasRole}:
function foo() public {
require(hasRole(MY_ROLE, msg.sender));
...
}
Roles can be granted and revoked dynamically via the {grantRole} and
{revokeRole} functions. Each role has an associated admin role, and only
accounts that have a role's admin role can call {grantRole} and {revokeRole}.
By default, the admin role for all roles is DEFAULT_ADMIN_ROLE, which means
that only accounts with this role will be able to grant or revoke other
roles. More complex role relationships can be created by using
{_setRoleAdmin}.
WARNING: The DEFAULT_ADMIN_ROLE is also its own admin: it has permission to
grant and revoke this role. Extra precautions should be taken to secure
accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
to enforce additional security measures for this role.*
State Variables
_roles
mapping(bytes32 role => RoleData) private _roles;
DEFAULT_ADMIN_ROLE
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
Functions
onlyRole
Modifier that checks that an account has a specific role. Reverts with an {AccessControlUnauthorizedAccount} error including the required role.
modifier onlyRole(bytes32 role);
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
hasRole
Returns true if account has been granted role.
function hasRole(bytes32 role, address account) public view virtual returns (bool);
_checkRole
Reverts with an {AccessControlUnauthorizedAccount} error if _msgSender()
is missing role. Overriding this function changes the behavior of the {onlyRole} modifier.
function _checkRole(bytes32 role) internal view virtual;
_checkRole
Reverts with an {AccessControlUnauthorizedAccount} error if account
is missing role.
function _checkRole(bytes32 role, address account) internal view virtual;
getRoleAdmin
Returns the admin role that controls role. See grantRole and
{revokeRole}.
To change a role's admin, use {_setRoleAdmin}.
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32);
grantRole
*Grants role to account.
If account had not been already granted role, emits a {RoleGranted}
event.
Requirements:
- the caller must have
role's admin role. May emit a {RoleGranted} event.*
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role));
revokeRole
*Revokes role from account.
If account had been granted role, emits a {RoleRevoked} event.
Requirements:
- the caller must have
role's admin role. May emit a {RoleRevoked} event.*
function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role));
renounceRole
*Revokes role from the calling account.
Roles are often managed via grantRole and {revokeRole}: this function's
purpose is to provide a mechanism for accounts to lose their privileges
if they are compromised (such as when a trusted device is misplaced).
If the calling account had been revoked role, emits a {RoleRevoked}
event.
Requirements:
- the caller must be
callerConfirmation. May emit a {RoleRevoked} event.*
function renounceRole(bytes32 role, address callerConfirmation) public virtual;
_setRoleAdmin
Sets adminRole as role's admin role.
Emits a {RoleAdminChanged} event.
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual;
_grantRole
Attempts to grant role to account and returns a boolean indicating if role was granted.
Internal function without access restriction.
May emit a {RoleGranted} event.
function _grantRole(bytes32 role, address account) internal virtual returns (bool);
_revokeRole
Attempts to revoke role from account and returns a boolean indicating if role was revoked.
Internal function without access restriction.
May emit a {RoleRevoked} event.
function _revokeRole(bytes32 role, address account) internal virtual returns (bool);
Structs
RoleData
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
IAccessControl
External interface of AccessControl declared to support ERC-165 detection.
Functions
hasRole
Returns true if account has been granted role.
function hasRole(bytes32 role, address account) external view returns (bool);
getRoleAdmin
Returns the admin role that controls role. See grantRole and
{revokeRole}.
To change a role's admin, use {AccessControl-_setRoleAdmin}.
function getRoleAdmin(bytes32 role) external view returns (bytes32);
grantRole
*Grants role to account.
If account had not been already granted role, emits a RoleGranted
event.
Requirements:
- the caller must have
role's admin role.*
function grantRole(bytes32 role, address account) external;
revokeRole
*Revokes role from account.
If account had been granted role, emits a RoleRevoked event.
Requirements:
- the caller must have
role's admin role.*
function revokeRole(bytes32 role, address account) external;
renounceRole
*Revokes role from the calling account.
Roles are often managed via grantRole and {revokeRole}: this function's
purpose is to provide a mechanism for accounts to lose their privileges
if they are compromised (such as when a trusted device is misplaced).
If the calling account had been granted role, emits a {RoleRevoked}
event.
Requirements:
- the caller must be
callerConfirmation.*
function renounceRole(bytes32 role, address callerConfirmation) external;
Events
RoleAdminChanged
Emitted when newAdminRole is set as role's admin role, replacing previousAdminRole
DEFAULT_ADMIN_ROLE is the starting admin for all roles, despite
RoleAdminChanged not being emitted to signal this.
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
RoleGranted
Emitted when account is granted role.
sender is the account that originated the contract call. This account bears the admin role (for the granted role).
Expected in cases where the role was granted using the internal AccessControl-_grantRole.
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
RoleRevoked
*Emitted when account is revoked role.
sender is the account that originated the contract call:
- if using
revokeRole, it is the admin role bearer - if using
renounceRole, it is the role bearer (i.e.account)*
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
Errors
AccessControlUnauthorizedAccount
The account is missing a role.
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
AccessControlBadConfirmation
The caller of a function is not the expected one. NOTE: Don't confuse with AccessControlUnauthorizedAccount.
error AccessControlBadConfirmation();
Ownable
Inherits: Context
Contract module which provides a basic access control mechanism, where
there is an account (an owner) that can be granted exclusive access to
specific functions.
The initial owner is set to the address provided by the deployer. This can
later be changed with transferOwnership.
This module is used through inheritance. It will make available the modifier
onlyOwner, which can be applied to your functions to restrict their use to
the owner.
State Variables
_owner
address private _owner;
Functions
constructor
Initializes the contract setting the address provided by the deployer as the initial owner.
constructor(address initialOwner);
onlyOwner
Throws if called by any account other than the owner.
modifier onlyOwner();
owner
Returns the address of the current owner.
function owner() public view virtual returns (address);
_checkOwner
Throws if the sender is not the owner.
function _checkOwner() internal view virtual;
renounceOwnership
Leaves the contract without owner. It will not be possible to call
onlyOwner functions. Can only be called by the current owner.
NOTE: Renouncing ownership will leave the contract without an owner,
thereby disabling any functionality that is only available to the owner.
function renounceOwnership() public virtual onlyOwner;
transferOwnership
Transfers ownership of the contract to a new account (newOwner).
Can only be called by the current owner.
function transferOwnership(address newOwner) public virtual onlyOwner;
_transferOwnership
Transfers ownership of the contract to a new account (newOwner).
Internal function without access restriction.
function _transferOwnership(address newOwner) internal virtual;
Events
OwnershipTransferred
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
Errors
OwnableUnauthorizedAccount
The caller account is not authorized to perform an operation.
error OwnableUnauthorizedAccount(address account);
OwnableInvalidOwner
The owner is not a valid owner account. (eg. address(0))
error OwnableInvalidOwner(address owner);
Ownable2Step
Inherits: Ownable
Contract module which provides access control mechanism, where
there is an account (an owner) that can be granted exclusive access to
specific functions.
This extension of the {Ownable} contract includes a two-step mechanism to transfer
ownership, where the new owner must call {acceptOwnership} in order to replace the
old one. This can help prevent common mistakes, such as transfers of ownership to
incorrect accounts, or to contracts that are unable to interact with the
permission system.
The initial owner is specified at deployment time in the constructor for Ownable. This
can later be changed with {transferOwnership} and {acceptOwnership}.
This module is used through inheritance. It will make available all functions
from parent (Ownable).
State Variables
_pendingOwner
address private _pendingOwner;
Functions
pendingOwner
Returns the address of the pending owner.
function pendingOwner() public view virtual returns (address);
transferOwnership
Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
Can only be called by the current owner.
Setting newOwner to the zero address is allowed; this can be used to cancel an initiated ownership transfer.
function transferOwnership(address newOwner) public virtual override onlyOwner;
_transferOwnership
Transfers ownership of the contract to a new account (newOwner) and deletes any pending owner.
Internal function without access restriction.
function _transferOwnership(address newOwner) internal virtual override;
acceptOwnership
The new owner accepts the ownership transfer.
function acceptOwnership() public virtual;
Events
OwnershipTransferStarted
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
Contents
Contents
AccountERC7579
Inherits: Account, IERC1271, IERC7579Execution, IERC7579AccountConfig, IERC7579ModuleConfig
*Extension of {Account} that implements support for ERC-7579 modules. To comply with the ERC-1271 support requirement, this contract defers signature validation to installed validator modules by calling {IERC7579Validator-isValidSignatureWithSender}. This contract does not implement validation logic for user operations since this functionality is often delegated to self-contained validation modules. Developers must install a validator module upon initialization (or any other mechanism to enable execution from the account):
contract MyAccountERC7579 is AccountERC7579, Initializable {
function initializeAccount(address validator, bytes calldata validatorData) public initializer {
_installModule(MODULE_TYPE_VALIDATOR, validator, validatorData);
}
}
[NOTE]
Hook support is not included. See {AccountERC7579Hooked} for a version that hooks to execution.
Validator selection, when verifying either ERC-1271 signature or ERC-4337 UserOperation is implemented in
internal virtual functions {_extractUserOpValidator} and {_extractSignatureValidator}. Both are implemented
following common practices. However, this part is not standardized in ERC-7579 (or in any follow-up ERC). Some
accounts may want to override these internal functions.
When combined with {ERC7739}, resolution ordering of {isValidSignature} may have an impact ({ERC7739} does not
call super). Manual resolution might be necessary.
Static calls (using callType 0xfe) are currently NOT supported.
WARNING: Removing all validator modules will render the account inoperable, as no user operations can be validated thereafter.*
State Variables
_validators
EnumerableSet.AddressSet private _validators;
_executors
EnumerableSet.AddressSet private _executors;
_fallbacks
mapping(bytes4 selector => address) private _fallbacks;
Functions
onlyModule
Modifier that checks if the caller is an installed module of the given type.
modifier onlyModule(uint256 moduleTypeId, bytes calldata additionalContext);
fallback
See _fallback.
fallback(bytes calldata) external payable virtual returns (bytes memory);
accountId
Returns the account id of the smart account
function accountId() public view virtual returns (string memory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | string | accountImplementationId the account id of the smart account MUST return a non-empty string The accountId SHOULD be structured like so: "vendorname.accountname.semver" The id SHOULD be unique across all smart accounts |
supportsExecutionMode
Supported call types:
Single (0x00): A single transaction execution.
Batch (0x01): A batch of transactions execution.
Delegate (0xff): A delegate call execution.
Supported exec types:
Default (0x00): Default execution type (revert on failure).
Try (0x01): Try execution type (emits ERC7579TryExecuteFail on failure).
function supportsExecutionMode(bytes32 encodedMode) public view virtual returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
encodedMode | bytes32 | the encoded mode MUST return true if the account supports the mode and false otherwise |
supportsModule
Supported module types: Validator: A module used during the validation phase to determine if a transaction is valid and should be executed on the account. Executor: A module that can execute transactions on behalf of the smart account via a callback. Fallback Handler: A module that can extend the fallback functionality of a smart account.
function supportsModule(uint256 moduleTypeId) public view virtual returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
moduleTypeId | uint256 | the module type ID according to the ERC-7579 spec MUST return true if the account supports the module type and false otherwise |
installModule
Installs a Module of a certain type on the smart account
function installModule(uint256 moduleTypeId, address module, bytes calldata initData)
public
virtual
onlyEntryPointOrSelf;
Parameters
| Name | Type | Description |
|---|---|---|
moduleTypeId | uint256 | the module type ID according to the ERC-7579 spec |
module | address | the module address |
initData | bytes | arbitrary data that may be passed to the module during onInstall initialization. MUST implement authorization control MUST call onInstall on the module with the initData parameter if provided MUST emit ModuleInstalled event MUST revert if the module is already installed or the initialization on the module failed |
uninstallModule
Uninstalls a Module of a certain type on the smart account
function uninstallModule(uint256 moduleTypeId, address module, bytes calldata deInitData)
public
virtual
onlyEntryPointOrSelf;
Parameters
| Name | Type | Description |
|---|---|---|
moduleTypeId | uint256 | the module type ID according the ERC-7579 spec |
module | address | the module address |
deInitData | bytes | arbitrary data that may be passed to the module during onUninstall deinitialization. MUST implement authorization control MUST call onUninstall on the module with the deInitData parameter if provided MUST emit ModuleUninstalled event MUST revert if the module is not installed or the deInitialization on the module failed |
isModuleInstalled
Returns whether a module is installed on the smart account
function isModuleInstalled(uint256 moduleTypeId, address module, bytes calldata additionalContext)
public
view
virtual
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
moduleTypeId | uint256 | the module type ID according the ERC-7579 spec |
module | address | the module address |
additionalContext | bytes | arbitrary data that may be passed to determine if the module is installed MUST return true if the module is installed and false otherwise |
execute
Executes a transaction on behalf of the account.
function execute(bytes32 mode, bytes calldata executionCalldata) public payable virtual onlyEntryPointOrSelf;
Parameters
| Name | Type | Description |
|---|---|---|
mode | bytes32 | The encoded execution mode of the transaction. See ModeLib.sol for details |
executionCalldata | bytes | The encoded execution call data MUST ensure adequate authorization control: e.g. onlyEntryPointOrSelf if used with ERC-4337 If a mode is requested that is not supported by the Account, it MUST revert |
executeFromExecutor
Executes a transaction on behalf of the account. This function is intended to be called by Executor Modules
function executeFromExecutor(bytes32 mode, bytes calldata executionCalldata)
public
payable
virtual
onlyModule(MODULE_TYPE_EXECUTOR, Calldata.emptyBytes())
returns (bytes[] memory returnData);
Parameters
| Name | Type | Description |
|---|---|---|
mode | bytes32 | The encoded execution mode of the transaction. See ModeLib.sol for details |
executionCalldata | bytes | The encoded execution call data |
Returns
| Name | Type | Description |
|---|---|---|
returnData | bytes[] | An array with the returned data of each executed subcall MUST ensure adequate authorization control: i.e. onlyExecutorModule If a mode is requested that is not supported by the Account, it MUST revert |
isValidSignature
Implement ERC-1271 through IERC7579Validator modules. If module based validation fails, fallback to "native" validation by the abstract signer. NOTE: when combined with {ERC7739}, resolution ordering may have an impact ({ERC7739} does not call super). Manual resolution might be necessary.
function isValidSignature(bytes32 hash, bytes calldata signature) public view virtual returns (bytes4);
_validateUserOp
Validates a user operation with {_signableUserOpHash} and returns the validation data if the module specified by the first 20 bytes of the nonce key is installed. Falls back to {Account-_validateUserOp} otherwise. See {_extractUserOpValidator} for the module extraction logic.
function _validateUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash)
internal
virtual
override
returns (uint256);
_execute
ERC-7579 execution logic. See supportsExecutionMode for supported modes. Reverts if the call type is not supported.
function _execute(Mode mode, bytes calldata executionCalldata) internal virtual returns (bytes[] memory returnData);
_installModule
Installs a module of the given type with the given initialization data.
For the fallback module type, the initData is expected to be the (packed) concatenation of a 4-byte
selector and the rest of the data to be sent to the handler when calling IERC7579Module-onInstall.
Requirements:
Module type must be supported. See {supportsModule}. Reverts with {ERC7579Utils-ERC7579UnsupportedModuleType}.
Module must be of the given type. Reverts with {ERC7579Utils-ERC7579MismatchedModuleTypeId}.
Module must not be already installed. Reverts with {ERC7579Utils-ERC7579AlreadyInstalledModule}.
Emits a {IERC7579ModuleConfig-ModuleInstalled} event.
function _installModule(uint256 moduleTypeId, address module, bytes memory initData) internal virtual;
_uninstallModule
Uninstalls a module of the given type with the given de-initialization data.
For the fallback module type, the deInitData is expected to be the (packed) concatenation of a 4-byte
selector and the rest of the data to be sent to the handler when calling IERC7579Module-onUninstall.
Requirements:
Module must be already installed. Reverts with {ERC7579Utils-ERC7579UninstalledModule} otherwise.
function _uninstallModule(uint256 moduleTypeId, address module, bytes memory deInitData) internal virtual;
_fallback
Fallback function that delegates the call to the installed handler for the given selector.
Reverts with ERC7579MissingFallbackHandler if the handler is not installed.
Calls the handler with the original msg.sender appended at the end of the calldata following
the ERC-2771 format.
function _fallback() internal virtual returns (bytes memory);
_fallbackHandler
Returns the fallback handler for the given selector. Returns address(0) if not installed.
function _fallbackHandler(bytes4 selector) internal view virtual returns (address);
_checkModule
Checks if the module is installed. Reverts if the module is not installed.
function _checkModule(uint256 moduleTypeId, address module, bytes calldata additionalContext) internal view virtual;
_extractUserOpValidator
*Extracts the nonce validator from the user operation. To construct a nonce key, set nonce as follows:
<module address (20 bytes)> | <key (4 bytes)> | <nonce (8 bytes)>
NOTE: The default behavior of this function replicates the behavior of https://github.com/rhinestonewtf/safe7579/blob/bb29e8b1a66658790c4169e72608e27d220f79be/src/Safe7579.sol#L266[Safe adapter], https://github.com/etherspot/etherspot-prime-contracts/blob/cfcdb48c4172cea0d66038324c0bae3288aa8caa/src/modular-etherspot-wallet/wallet/ModularEtherspotWallet.sol#L227[Etherspot's Prime Account], and https://github.com/erc7579/erc7579-implementation/blob/16138d1afd4e9711f6c1425133538837bd7787b5/src/MSAAdvanced.sol#L247[ERC7579 reference implementation]. This is not standardized in ERC-7579 (or in any follow-up ERC). Some accounts may want to override these internal functions. For example, https://github.com/bcnmy/nexus/blob/54f4e19baaff96081a8843672977caf712ef19f4/contracts/lib/NonceLib.sol#L17[Biconomy's Nexus] uses a similar yet incompatible approach (the validator address is also part of the nonce, but not at the same location)*
function _extractUserOpValidator(PackedUserOperation calldata userOp) internal pure virtual returns (address);
_extractSignatureValidator
*Extracts the signature validator from the signature. To construct a signature, set the first 20 bytes as the module address and the remaining bytes as the signature data:
<module address (20 bytes)> | <signature data>
NOTE: The default behavior of this function replicates the behavior of https://github.com/rhinestonewtf/safe7579/blob/bb29e8b1a66658790c4169e72608e27d220f79be/src/Safe7579.sol#L350[Safe adapter], https://github.com/bcnmy/nexus/blob/54f4e19baaff96081a8843672977caf712ef19f4/contracts/Nexus.sol#L239[Biconomy's Nexus], https://github.com/etherspot/etherspot-prime-contracts/blob/cfcdb48c4172cea0d66038324c0bae3288aa8caa/src/modular-etherspot-wallet/wallet/ModularEtherspotWallet.sol#L252[Etherspot's Prime Account], and https://github.com/erc7579/erc7579-implementation/blob/16138d1afd4e9711f6c1425133538837bd7787b5/src/MSAAdvanced.sol#L296[ERC7579 reference implementation]. This is not standardized in ERC-7579 (or in any follow-up ERC). Some accounts may want to override these internal functions.*
function _extractSignatureValidator(bytes calldata signature)
internal
pure
virtual
returns (address module, bytes calldata innerSignature);
_decodeFallbackData
Extract the function selector from initData/deInitData for MODULE_TYPE_FALLBACK
NOTE: If we had calldata here, we could use calldata slice which are cheaper to manipulate and don't require
actual copy. However, this would require _installModule to get a calldata bytes object instead of a memory
bytes object. This would prevent calling _installModule from a contract constructor and would force the use
of external initializers. That may change in the future, as most accounts will probably be deployed as
clones/proxy/ERC-7702 delegates and therefore rely on initializers anyway.
function _decodeFallbackData(bytes memory data)
internal
pure
virtual
returns (bytes4 selector, bytes memory remaining);
_rawSignatureValidation
By default, only use the modules for validation of userOp and signature. Disable raw signatures.
function _rawSignatureValidation(bytes32, bytes calldata) internal view virtual override returns (bool);
Errors
ERC7579MissingFallbackHandler
The account's {fallback} was called with a selector that doesn't have an installed handler.
error ERC7579MissingFallbackHandler(bytes4 selector);
AccountERC7579Hooked
Inherits: AccountERC7579
Extension of {AccountERC7579} with support for a single hook module (type 4).
If installed, this extension will call the hook module's {IERC7579Hook-preCheck} before executing any operation
with {_execute} (including {execute} and {executeFromExecutor} by default) and {IERC7579Hook-postCheck} thereafter.
NOTE: Hook modules break the check-effect-interaction pattern. In particular, the {IERC7579Hook-preCheck} hook can
lead to potentially dangerous reentrancy. Using the withHook() modifier is safe if no effect is performed
before the preHook or after the postHook. That is the case on all functions here, but it may not be the case if
functions that have this modifier are overridden. Developers should be extremely careful when implementing hook
modules or further overriding functions that involve hooks.
State Variables
_hook
address private _hook;
Functions
withHook
Calls IERC7579Hook-preCheck before executing the modified function and {IERC7579Hook-postCheck} thereafter.
modifier withHook();
accountId
function accountId() public view virtual override returns (string memory);
hook
Returns the hook module address if installed, or address(0) otherwise.
function hook() public view virtual returns (address);
supportsModule
Supports hook modules. See AccountERC7579-supportsModule
function supportsModule(uint256 moduleTypeId) public view virtual override returns (bool);
isModuleInstalled
function isModuleInstalled(uint256 moduleTypeId, address module, bytes calldata data)
public
view
virtual
override
returns (bool);
_installModule
Installs a module with support for hook modules. See {AccountERC7579-_installModule}
function _installModule(uint256 moduleTypeId, address module, bytes memory initData)
internal
virtual
override
withHook;
_uninstallModule
Uninstalls a module with support for hook modules. See {AccountERC7579-_uninstallModule}
function _uninstallModule(uint256 moduleTypeId, address module, bytes memory deInitData)
internal
virtual
override
withHook;
_execute
Hooked version of AccountERC7579-_execute.
function _execute(Mode mode, bytes calldata executionCalldata)
internal
virtual
override
withHook
returns (bytes[] memory);
_fallback
Hooked version of AccountERC7579-_fallback.
function _fallback() internal virtual override withHook returns (bytes memory);
Errors
ERC7579HookModuleAlreadyPresent
A hook module is already present. This contract only supports one hook module.
error ERC7579HookModuleAlreadyPresent(address hook);
ERC7821
Inherits: IERC7821
Minimal batch executor following ERC-7821.
Only supports supports single batch mode (0x01000000000000000000). Does not support optional "opData".
Note: stateless:
Functions
execute
Executes the calls in executionData with no optional opData support.
NOTE: Access to this function is controlled by _erc7821AuthorizedExecutor. Changing access permissions, for
example to approve calls by the ERC-4337 entrypoint, should be implemented by overriding it.
Reverts and bubbles up error if any call fails.
function execute(bytes32 mode, bytes calldata executionData) public payable virtual;
supportsExecutionMode
*This function is provided for frontends to detect support. Only returns true for:
bytes32(0x01000000000000000000...): does not support optionalopData.bytes32(0x01000000000078210001...): supports optionalopData.*
function supportsExecutionMode(bytes32 mode) public view virtual returns (bool result);
_erc7821AuthorizedExecutor
*Access control mechanism for the execute function. By default, only the contract itself is allowed to execute. Override this function to implement custom access control, for example to allow the ERC-4337 entrypoint to execute.
function _erc7821AuthorizedExecutor(
address caller,
bytes32 mode,
bytes calldata executionData
) internal view virtual override returns (bool) {
return caller == address(entryPoint()) || super._erc7821AuthorizedExecutor(caller, mode, executionData);
}
```*
```solidity
function _erc7821AuthorizedExecutor(address caller, bytes32, bytes calldata) internal view virtual returns (bool);
Errors
UnsupportedExecutionMode
error UnsupportedExecutionMode();
Contents
- EIP7702Utils
- IEntryPointExtra
- ERC4337Utils
- Mode
- CallType
- ExecType
- ModeSelector
- ModePayload
- ERC7579Utils
- eqModePayload
- eqCallType
- eqExecType
- eqModeSelector
EIP7702Utils
Library with common EIP-7702 utility functions. See https://eips.ethereum.org/EIPS/eip-7702[ERC-7702].
State Variables
EIP7702_PREFIX
bytes3 internal constant EIP7702_PREFIX = 0xef0100;
Functions
fetchDelegate
Returns the address of the delegate if account as an EIP-7702 delegation setup, or address(0) otherwise.
function fetchDelegate(address account) internal view returns (address);
IEntryPointExtra
This is available on all entrypoint since v0.4.0, but is not formally part of the ERC.
Functions
getUserOpHash
function getUserOpHash(PackedUserOperation calldata userOp) external view returns (bytes32);
ERC4337Utils
Library with common ERC-4337 utility functions. See https://eips.ethereum.org/EIPS/eip-4337[ERC-4337].
State Variables
ENTRYPOINT_V07
Address of the entrypoint v0.7.0
IEntryPoint internal constant ENTRYPOINT_V07 = IEntryPoint(0x0000000071727De22E5E9d8BAf0edAc6f37da032);
ENTRYPOINT_V08
Address of the entrypoint v0.8.0
IEntryPoint internal constant ENTRYPOINT_V08 = IEntryPoint(0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108);
SIG_VALIDATION_SUCCESS
For simulation purposes, validateUserOp (and validatePaymasterUserOp) return this value on success.
uint256 internal constant SIG_VALIDATION_SUCCESS = 0;
SIG_VALIDATION_FAILED
For simulation purposes, validateUserOp (and validatePaymasterUserOp) must return this value in case of signature failure, instead of revert.
uint256 internal constant SIG_VALIDATION_FAILED = 1;
Functions
parseValidationData
Parses the validation data into its components. See packValidationData.
function parseValidationData(uint256 validationData)
internal
pure
returns (address aggregator, uint48 validAfter, uint48 validUntil);
packValidationData
Packs the validation data into a single uint256. See parseValidationData.
function packValidationData(address aggregator, uint48 validAfter, uint48 validUntil) internal pure returns (uint256);
packValidationData
Same as packValidationData, but with a boolean signature success flag.
function packValidationData(bool sigSuccess, uint48 validAfter, uint48 validUntil) internal pure returns (uint256);
combineValidationData
Combines two validation data into a single one.
The aggregator is set to {SIG_VALIDATION_SUCCESS} if both are successful, while
the validAfter is the maximum and the validUntil is the minimum of both.
function combineValidationData(uint256 validationData1, uint256 validationData2) internal pure returns (uint256);
getValidationData
Returns the aggregator of the validationData and whether it is out of time range.
function getValidationData(uint256 validationData) internal view returns (address aggregator, bool outOfTimeRange);
hash
Get the hash of a user operation for a given entrypoint
function hash(PackedUserOperation calldata self, address entrypoint) internal view returns (bytes32);
factory
Returns factory from the {PackedUserOperation}, or address(0) if the initCode is empty or not properly formatted.
function factory(PackedUserOperation calldata self) internal pure returns (address);
factoryData
Returns factoryData from the {PackedUserOperation}, or empty bytes if the initCode is empty or not properly formatted.
function factoryData(PackedUserOperation calldata self) internal pure returns (bytes calldata);
verificationGasLimit
Returns verificationGasLimit from the {PackedUserOperation}.
function verificationGasLimit(PackedUserOperation calldata self) internal pure returns (uint256);
callGasLimit
Returns callGasLimit from the {PackedUserOperation}.
function callGasLimit(PackedUserOperation calldata self) internal pure returns (uint256);
maxPriorityFeePerGas
Returns the first section of gasFees from the {PackedUserOperation}.
function maxPriorityFeePerGas(PackedUserOperation calldata self) internal pure returns (uint256);
maxFeePerGas
Returns the second section of gasFees from the {PackedUserOperation}.
function maxFeePerGas(PackedUserOperation calldata self) internal pure returns (uint256);
gasPrice
Returns the total gas price for the {PackedUserOperation} (ie. maxFeePerGas or maxPriorityFeePerGas + basefee).
function gasPrice(PackedUserOperation calldata self) internal view returns (uint256);
paymaster
Returns the first section of paymasterAndData from the {PackedUserOperation}.
function paymaster(PackedUserOperation calldata self) internal pure returns (address);
paymasterVerificationGasLimit
Returns the second section of paymasterAndData from the {PackedUserOperation}.
function paymasterVerificationGasLimit(PackedUserOperation calldata self) internal pure returns (uint256);
paymasterPostOpGasLimit
Returns the third section of paymasterAndData from the {PackedUserOperation}.
function paymasterPostOpGasLimit(PackedUserOperation calldata self) internal pure returns (uint256);
paymasterData
Returns the fourth section of paymasterAndData from the {PackedUserOperation}.
function paymasterData(PackedUserOperation calldata self) internal pure returns (bytes calldata);
Mode
type Mode is bytes32;
CallType
type CallType is bytes1;
ExecType
type ExecType is bytes1;
ModeSelector
type ModeSelector is bytes4;
ModePayload
type ModePayload is bytes22;
ERC7579Utils
Library with common ERC-7579 utility functions. See https://eips.ethereum.org/EIPS/eip-7579[ERC-7579].
State Variables
CALLTYPE_SINGLE
A single call execution.
CallType internal constant CALLTYPE_SINGLE = CallType.wrap(0x00);
CALLTYPE_BATCH
A batch of call executions.
CallType internal constant CALLTYPE_BATCH = CallType.wrap(0x01);
CALLTYPE_DELEGATECALL
A delegatecall execution.
CallType internal constant CALLTYPE_DELEGATECALL = CallType.wrap(0xFF);
EXECTYPE_DEFAULT
Default execution type that reverts on failure.
ExecType internal constant EXECTYPE_DEFAULT = ExecType.wrap(0x00);
EXECTYPE_TRY
Execution type that does not revert on failure.
ExecType internal constant EXECTYPE_TRY = ExecType.wrap(0x01);
Functions
execSingle
Executes a single call.
function execSingle(bytes calldata executionCalldata, ExecType execType) internal returns (bytes[] memory returnData);
execBatch
Executes a batch of calls.
function execBatch(bytes calldata executionCalldata, ExecType execType) internal returns (bytes[] memory returnData);
execDelegateCall
Executes a delegate call.
function execDelegateCall(bytes calldata executionCalldata, ExecType execType)
internal
returns (bytes[] memory returnData);
encodeMode
Encodes the mode with the provided parameters. See decodeMode.
function encodeMode(CallType callType, ExecType execType, ModeSelector selector, ModePayload payload)
internal
pure
returns (Mode mode);
decodeMode
Decodes the mode into its parameters. See encodeMode.
function decodeMode(Mode mode)
internal
pure
returns (CallType callType, ExecType execType, ModeSelector selector, ModePayload payload);
encodeSingle
Encodes a single call execution. See decodeSingle.
function encodeSingle(address target, uint256 value, bytes calldata callData)
internal
pure
returns (bytes memory executionCalldata);
decodeSingle
Decodes a single call execution. See encodeSingle.
function decodeSingle(bytes calldata executionCalldata)
internal
pure
returns (address target, uint256 value, bytes calldata callData);
encodeDelegate
Encodes a delegate call execution. See decodeDelegate.
function encodeDelegate(address target, bytes calldata callData)
internal
pure
returns (bytes memory executionCalldata);
decodeDelegate
Decodes a delegate call execution. See encodeDelegate.
function decodeDelegate(bytes calldata executionCalldata)
internal
pure
returns (address target, bytes calldata callData);
encodeBatch
Encodes a batch of executions. See decodeBatch.
function encodeBatch(Execution[] memory executionBatch) internal pure returns (bytes memory executionCalldata);
decodeBatch
Decodes a batch of executions. See encodeBatch. NOTE: This function runs some checks and will throw a {ERC7579DecodingError} if the input is not properly formatted.
function decodeBatch(bytes calldata executionCalldata) internal pure returns (Execution[] calldata executionBatch);
_call
Executes a call to the target with the provided {ExecType}.
function _call(uint256 index, ExecType execType, address target, uint256 value, bytes calldata data)
private
returns (bytes memory);
_delegatecall
Executes a delegatecall to the target with the provided {ExecType}.
function _delegatecall(uint256 index, ExecType execType, address target, bytes calldata data)
private
returns (bytes memory);
_validateExecutionMode
Validates the execution mode and returns the returndata.
function _validateExecutionMode(uint256 index, ExecType execType, bool success, bytes memory returndata)
private
returns (bytes memory);
Events
ERC7579TryExecuteFail
Emits when an {EXECTYPE_TRY} execution fails.
event ERC7579TryExecuteFail(uint256 batchExecutionIndex, bytes returndata);
Parameters
| Name | Type | Description |
|---|---|---|
batchExecutionIndex | uint256 | The index of the failed call in the execution batch. |
returndata | bytes | The returned data from the failed call. |
Errors
ERC7579UnsupportedCallType
The provided {CallType} is not supported.
error ERC7579UnsupportedCallType(CallType callType);
ERC7579UnsupportedExecType
The provided {ExecType} is not supported.
error ERC7579UnsupportedExecType(ExecType execType);
ERC7579MismatchedModuleTypeId
The provided module doesn't match the provided module type.
error ERC7579MismatchedModuleTypeId(uint256 moduleTypeId, address module);
ERC7579UninstalledModule
The module is not installed.
error ERC7579UninstalledModule(uint256 moduleTypeId, address module);
ERC7579AlreadyInstalledModule
The module is already installed.
error ERC7579AlreadyInstalledModule(uint256 moduleTypeId, address module);
ERC7579UnsupportedModuleType
The module type is not supported.
error ERC7579UnsupportedModuleType(uint256 moduleTypeId);
ERC7579DecodingError
Input calldata not properly formatted and possibly malicious.
error ERC7579DecodingError();
eqModePayload
Compares two ModePayload values for equality.
function eqModePayload(ModePayload a, ModePayload b) pure returns (bool);
eqCallType
Compares two CallType values for equality.
function eqCallType(CallType a, CallType b) pure returns (bool);
eqExecType
Compares two ExecType values for equality.
function eqExecType(ExecType a, ExecType b) pure returns (bool);
eqModeSelector
Compares two ModeSelector values for equality.
function eqModeSelector(ModeSelector a, ModeSelector b) pure returns (bool);
Account
Inherits: AbstractSigner, IAccount
A simple ERC4337 account implementation. This base implementation only includes the minimal logic to process user operations. Developers must implement the {AbstractSigner-_rawSignatureValidation} function to define the account's validation logic. NOTE: This core account doesn't include any mechanism for performing arbitrary external calls. This is an essential feature that all Account should have. We leave it up to the developers to implement the mechanism of their choice. Common choices include ERC-6900, ERC-7579 and ERC-7821 (among others). IMPORTANT: Implementing a mechanism to validate signatures is a security-sensitive operation as it may allow an attacker to bypass the account's security measures. Check out {SignerECDSA}, {SignerP256}, or {SignerRSA} for digital signature validation implementations.
Note: stateless:
Functions
onlyEntryPointOrSelf
Revert if the caller is not the entry point or the account itself.
modifier onlyEntryPointOrSelf();
onlyEntryPoint
Revert if the caller is not the entry point.
modifier onlyEntryPoint();
entryPoint
Canonical entry point for the account that forwards and validates user operations.
function entryPoint() public view virtual returns (IEntryPoint);
getNonce
Return the account nonce for the canonical sequence.
function getNonce() public view virtual returns (uint256);
getNonce
Return the account nonce for a given sequence (key).
function getNonce(uint192 key) public view virtual returns (uint256);
validateUserOp
*Validates a user operation. MUST validate the caller is a trusted EntryPoint MUST validate that the signature is a valid signature of the userOpHash, and SHOULD return SIG_VALIDATION_FAILED (and not revert) on signature mismatch. Any other error MUST revert. MUST pay the entryPoint (caller) at least the “missingAccountFunds” (which might be zero, in case the current account’s deposit is high enough) Returns an encoded packed validation data that is composed of the following elements:
authorizer(address): 0 for success, 1 for failure, otherwise the address of an authorizer contractvalidUntil(uint48): The UserOp is valid only up to this time. Zero for “infinite”.validAfter(uint48): The UserOp is valid only after this time.*
function validateUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash, uint256 missingAccountFunds)
public
virtual
onlyEntryPoint
returns (uint256);
_validateUserOp
Returns the validationData for a given user operation. By default, this checks the signature of the signable hash (produced by _signableUserOpHash) using the abstract signer ({AbstractSigner-_rawSignatureValidation}). NOTE: The userOpHash is assumed to be correct. Calling this function with a userOpHash that does not match the userOp will result in undefined behavior.
function _validateUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash) internal virtual returns (uint256);
_signableUserOpHash
Virtual function that returns the signable hash for a user operations. Since v0.8.0 of the entrypoint,
userOpHash is an EIP-712 hash that can be signed directly.
function _signableUserOpHash(PackedUserOperation calldata, bytes32 userOpHash)
internal
view
virtual
returns (bytes32);
_payPrefund
Sends the missing funds for executing the user operation to the {entrypoint}.
The missingAccountFunds must be defined by the entrypoint when calling {validateUserOp}.
function _payPrefund(uint256 missingAccountFunds) internal virtual;
_checkEntryPoint
Ensures the caller is the {entrypoint}.
function _checkEntryPoint() internal view virtual;
_checkEntryPointOrSelf
Ensures the caller is the {entrypoint} or the account itself.
function _checkEntryPointOrSelf() internal view virtual;
receive
Receive Ether.
receive() external payable virtual;
Errors
AccountUnauthorized
Unauthorized call to the account.
error AccountUnauthorized(address sender);
Contents
VestingWallet
A vesting wallet is an ownable contract that can receive native currency and ERC-20 tokens, and release these assets to the wallet owner, also referred to as "beneficiary", according to a vesting schedule. Any assets transferred to this contract will follow the vesting schedule as if they were locked from the beginning. Consequently, if the vesting has already started, any amount of tokens sent to this contract will (at least partly) be immediately releasable. By setting the duration to 0, one can configure this contract to behave like an asset timelock that holds tokens for a beneficiary until a specified time. NOTE: Since the wallet is {Ownable}, and ownership can be transferred, it is possible to sell unvested tokens. Preventing this in a smart contract is difficult, considering that: 1) a beneficiary address could be a counterfactually deployed contract, 2) there is likely to be a migration path for EOAs to become contracts in the near future. NOTE: When using this contract with any token whose balance is adjusted automatically (i.e. a rebase token), make sure to account the supply/balance adjustment in the vesting schedule to ensure the vested amount is as intended. NOTE: Chains with support for native ERC20s may allow the vesting wallet to withdraw the underlying asset as both an ERC20 and as native currency. For example, if chain C supports token A and the wallet gets deposited 100 A, then at 50% of the vesting period, the beneficiary can withdraw 50 A as ERC20 and 25 A as native currency (totaling 75 A). Consider disabling one of the withdrawal methods.
State Variables
_released
uint256 private _released;
_erc20Released
mapping(address token => uint256) private _erc20Released;
_start
uint64 private immutable _start;
_duration
uint64 private immutable _duration;
Functions
constructor
Sets the beneficiary (owner), the start timestamp and the vesting duration (in seconds) of the vesting wallet.
constructor(address beneficiary, uint64 startTimestamp, uint64 durationSeconds) payable Ownable(beneficiary);
receive
The contract should be able to receive Eth.
receive() external payable virtual;
start
Getter for the start timestamp.
function start() public view virtual returns (uint256);
duration
Getter for the vesting duration.
function duration() public view virtual returns (uint256);
end
Getter for the end timestamp.
function end() public view virtual returns (uint256);
released
Amount of eth already released
function released() public view virtual returns (uint256);
released
Amount of token already released
function released(address token) public view virtual returns (uint256);
releasable
Getter for the amount of releasable eth.
function releasable() public view virtual returns (uint256);
releasable
Getter for the amount of releasable token tokens. token should be the address of an
{IERC20} contract.
function releasable(address token) public view virtual returns (uint256);
release
Release the native token (ether) that have already vested. Emits a EtherReleased event.
function release() public virtual;
release
Release the tokens that have already vested. Emits a ERC20Released event.
function release(address token) public virtual;
vestedAmount
Calculates the amount of ether that has already vested. Default implementation is a linear vesting curve.
function vestedAmount(uint64 timestamp) public view virtual returns (uint256);
vestedAmount
Calculates the amount of tokens that has already vested. Default implementation is a linear vesting curve.
function vestedAmount(address token, uint64 timestamp) public view virtual returns (uint256);
_vestingSchedule
Virtual implementation of the vesting formula. This returns the amount vested, as a function of time, for an asset given its total historical allocation.
function _vestingSchedule(uint256 totalAllocation, uint64 timestamp) internal view virtual returns (uint256);
Events
EtherReleased
event EtherReleased(uint256 amount);
ERC20Released
event ERC20Released(address indexed token, uint256 amount);
VestingWalletCliff
Inherits: VestingWallet
Extension of {VestingWallet} that adds a cliff to the vesting schedule. Available since v5.1.
State Variables
_cliff
uint64 private immutable _cliff;
Functions
constructor
Set the duration of the cliff, in seconds. The cliff starts vesting schedule (see {VestingWallet}'s
constructor) and ends cliffSeconds later.
constructor(uint64 cliffSeconds);
cliff
Getter for the cliff timestamp.
function cliff() public view virtual returns (uint256);
_vestingSchedule
Virtual implementation of the vesting formula. This returns the amount vested, as a function of time, for
an asset given its total historical allocation. Returns 0 if the cliff timestamp is not met.
IMPORTANT: The cliff not only makes the schedule return 0, but it also ignores every possible side
effect from calling the inherited implementation (i.e. super._vestingSchedule). Carefully consider
this caveat if the overridden implementation of this function has any (e.g. writing to memory or reverting).
function _vestingSchedule(uint256 totalAllocation, uint64 timestamp) internal view virtual override returns (uint256);
Errors
InvalidCliffDuration
The specified cliff duration is larger than the vesting duration.
error InvalidCliffDuration(uint64 cliffSeconds, uint64 durationSeconds);
Contents
Contents
- GovernorCountingFractional
- GovernorCountingOverridable
- GovernorCountingSimple
- GovernorNoncesKeyed
- GovernorPreventLateQuorum
- GovernorProposalGuardian
- GovernorSequentialProposalId
- GovernorSettings
- GovernorStorage
- GovernorSuperQuorum
- GovernorTimelockAccess
- GovernorTimelockCompound
- GovernorTimelockControl
- GovernorVotes
- GovernorVotesQuorumFraction
- GovernorVotesSuperQuorumFraction
GovernorCountingFractional
Inherits: Governor
Extension of {Governor} for fractional voting.
Similar to {GovernorCountingSimple}, this contract is a votes counting module for {Governor} that supports 3 options:
Against, For, Abstain. Additionally, it includes a fourth option: Fractional, which allows voters to split their voting
power amongst the other 3 options.
Votes cast with the Fractional support must be accompanied by a params argument that is three packed uint128 values
representing the weight the delegate assigns to Against, For, and Abstain respectively. For those votes cast for the other
3 options, the params argument must be empty.
This is mostly useful when the delegate is a contract that implements its own rules for voting. These delegate-contracts
can cast fractional votes according to the preferences of multiple entities delegating their voting power.
Some example use cases include:
Voting from tokens that are held by a DeFi pool
Voting from an L2 with tokens held by a bridge
Voting privately from a shielded pool using zero knowledge proofs.
Based on ScopeLift's https://github.com/ScopeLift/flexible-voting/blob/e5de2efd1368387b840931f19f3c184c85842761/src/GovernorCountingFractional.sol[GovernorCountingFractional]
Available since v5.1.
State Variables
VOTE_TYPE_FRACTIONAL
uint8 internal constant VOTE_TYPE_FRACTIONAL = 255;
_proposalVotes
Mapping from proposal ID to vote tallies for that proposal.
mapping(uint256 proposalId => ProposalVote) private _proposalVotes;
Functions
COUNTING_MODE
module:voting
*A description of the possible support values for {castVote} and the way these votes are counted, meant to
be consumed by UIs to show correct vote options and interpret the results. The string is a URL-encoded sequence of
key-value pairs that each describe one aspect, for example support=bravo&quorum=for,abstain.
There are 2 standard keys: support and quorum.
support=bravorefers to the vote options 0 = Against, 1 = For, 2 = Abstain, as inGovernorBravo.quorum=bravomeans that only For votes are counted towards quorum.quorum=for,abstainmeans that both For and Abstain votes are counted towards quorum. If a counting module makes use of encodedparams, it should include this under aparamskey with a unique name that describes the behavior. For example:params=fractionalmight refer to a scheme where votes are divided fractionally between for/against/abstain.params=erc721might refer to a scheme where specific NFTs are delegated to vote. NOTE: The string can be decoded by the standard https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams[URLSearchParams] JavaScript class.*
function COUNTING_MODE() public pure virtual override returns (string memory);
hasVoted
module:voting
Returns whether account has cast a vote on proposalId.
function hasVoted(uint256 proposalId, address account) public view virtual override returns (bool);
usedVotes
Get the number of votes already cast by account for a proposal with proposalId. Useful for
integrations that allow delegates to cast rolling, partial votes.
function usedVotes(uint256 proposalId, address account) public view virtual returns (uint256);
proposalVotes
Get current distribution of votes for a given proposal.
function proposalVotes(uint256 proposalId)
public
view
virtual
returns (uint256 againstVotes, uint256 forVotes, uint256 abstainVotes);
_quorumReached
Amount of votes already cast passes the threshold limit.
function _quorumReached(uint256 proposalId) internal view virtual override returns (bool);
_voteSucceeded
See Governor-_voteSucceeded. In this module, forVotes must be > againstVotes.
function _voteSucceeded(uint256 proposalId) internal view virtual override returns (bool);
_countVote
*See Governor-_countVote. Function that records the delegate's votes.
Executing this function consumes (part of) the delegate's weight on the proposal. This weight can be
distributed amongst the 3 options (Against, For, Abstain) by specifying a fractional support.
This counting module supports two vote casting modes: nominal and fractional.
- Nominal: A nominal vote is cast by setting
supportto one of the 3 bravo options (Against, For, Abstain). - Fractional: A fractional vote is cast by setting
supporttotype(uint8).max(255). Casting a nominal vote requiresparamsto be empty and consumes the delegate's full remaining weight on the proposal for the specifiedsupportoption. This is similar to the {GovernorCountingSimple} module and follows theVoteTypeenum from Governor Bravo. As a consequence, no vote weight remains unspent so no further voting is possible (for thisproposalIdand thisaccount). Casting a fractional vote consumes a fraction of the delegate's remaining weight on the proposal according to the weights the delegate assigns to each support option (Against, For, Abstain respectively). The sum total of the three decoded vote weights must be less than or equal to the delegate's remaining weight on the proposal (i.e. their checkpointed total weight minus votes already cast on the proposal). This format can be produced using:abi.encodePacked(uint128(againstVotes), uint128(forVotes), uint128(abstainVotes))NOTE: Consider that fractional voting restricts the number of casted votes (in each category) to 128 bits. Depending on how many decimals the underlying token has, a single voter may require to split their vote into multiple vote operations. For precision higher than ~30 decimals, large token holders may require a potentially large number of calls to cast all their votes. The voter has the possibility to cast all the remaining votes in a single operation using the traditional "bravo" vote.*
function _countVote(uint256 proposalId, address account, uint8 support, uint256 totalWeight, bytes memory params)
internal
virtual
override
returns (uint256);
Errors
GovernorExceedRemainingWeight
A fractional vote params uses more votes than are available for that user.
error GovernorExceedRemainingWeight(address voter, uint256 usedVotes, uint256 remainingWeight);
Structs
ProposalVote
struct ProposalVote {
uint256 againstVotes;
uint256 forVotes;
uint256 abstainVotes;
mapping(address voter => uint256) usedVotes;
}
GovernorCountingOverridable
Inherits: GovernorVotes
Extension of {Governor} which enables delegators to override the vote of their delegates. This module requires a token that inherits {VotesExtended}.
State Variables
OVERRIDE_BALLOT_TYPEHASH
bytes32 public constant OVERRIDE_BALLOT_TYPEHASH =
keccak256("OverrideBallot(uint256 proposalId,uint8 support,address voter,uint256 nonce,string reason)");
_proposalVotes
mapping(uint256 proposalId => ProposalVote) private _proposalVotes;
Functions
COUNTING_MODE
module:voting
*A description of the possible support values for {castVote} and the way these votes are counted, meant to
be consumed by UIs to show correct vote options and interpret the results. The string is a URL-encoded sequence of
key-value pairs that each describe one aspect, for example support=bravo&quorum=for,abstain.
There are 2 standard keys: support and quorum.
support=bravorefers to the vote options 0 = Against, 1 = For, 2 = Abstain, as inGovernorBravo.quorum=bravomeans that only For votes are counted towards quorum.quorum=for,abstainmeans that both For and Abstain votes are counted towards quorum. If a counting module makes use of encodedparams, it should include this under aparamskey with a unique name that describes the behavior. For example:params=fractionalmight refer to a scheme where votes are divided fractionally between for/against/abstain.params=erc721might refer to a scheme where specific NFTs are delegated to vote. NOTE: The string can be decoded by the standard https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams[URLSearchParams] JavaScript class.*
function COUNTING_MODE() public pure virtual override returns (string memory);
hasVoted
See IGovernor-hasVoted. NOTE: Calling {castVote} (or similar) casts a vote using the voting power that is delegated to the voter. Conversely, calling {castOverrideVote} (or similar) uses the voting power of the account itself, from its asset balances. Casting an "override vote" does not count as voting and won't be reflected by this getter. Consider using {hasVotedOverride} to check if an account has casted an "override vote" for a given proposal id.
function hasVoted(uint256 proposalId, address account) public view virtual override returns (bool);
hasVotedOverride
Check if an account has overridden their delegate for a proposal.
function hasVotedOverride(uint256 proposalId, address account) public view virtual returns (bool);
proposalVotes
Accessor to the internal vote counts.
function proposalVotes(uint256 proposalId)
public
view
virtual
returns (uint256 againstVotes, uint256 forVotes, uint256 abstainVotes);
_quorumReached
Amount of votes already cast passes the threshold limit.
function _quorumReached(uint256 proposalId) internal view virtual override returns (bool);
_voteSucceeded
See Governor-_voteSucceeded. In this module, the forVotes must be strictly over the againstVotes.
function _voteSucceeded(uint256 proposalId) internal view virtual override returns (bool);
_countVote
See Governor-_countVote. In this module, the support follows the VoteType enum (from Governor Bravo).
NOTE: called by {Governor-_castVote} which emits the {IGovernor-VoteCast} (or {IGovernor-VoteCastWithParams})
event.
function _countVote(uint256 proposalId, address account, uint8 support, uint256 totalWeight, bytes memory)
internal
virtual
override
returns (uint256);
_countOverride
Variant of Governor-_countVote that deals with vote overrides. NOTE: See {hasVoted} for more details about the difference between {castVote} and {castOverrideVote}.
function _countOverride(uint256 proposalId, address account, uint8 support) internal virtual returns (uint256);
_castOverride
Variant of Governor-_castVote that deals with vote overrides. Returns the overridden weight.
function _castOverride(uint256 proposalId, address account, uint8 support, string calldata reason)
internal
virtual
returns (uint256);
castOverrideVote
Public function for casting an override vote. Returns the overridden weight.
function castOverrideVote(uint256 proposalId, uint8 support, string calldata reason) public virtual returns (uint256);
castOverrideVoteBySig
Public function for casting an override vote using a voter's signature. Returns the overridden weight.
function castOverrideVoteBySig(
uint256 proposalId,
uint8 support,
address voter,
string calldata reason,
bytes calldata signature
) public virtual returns (uint256);
Events
VoteReduced
The votes casted by delegate were reduced by weight after an override vote was casted by the original token holder
event VoteReduced(address indexed delegate, uint256 proposalId, uint8 support, uint256 weight);
OverrideVoteCast
A delegated vote on proposalId was overridden by weight
event OverrideVoteCast(address indexed voter, uint256 proposalId, uint8 support, uint256 weight, string reason);
Errors
GovernorAlreadyOverriddenVote
error GovernorAlreadyOverriddenVote(address account);
Structs
VoteReceipt
struct VoteReceipt {
uint8 casted;
bool hasOverridden;
uint208 overriddenWeight;
}
ProposalVote
struct ProposalVote {
uint256[3] votes;
mapping(address voter => VoteReceipt) voteReceipt;
}
Enums
VoteType
Supported vote types. Matches Governor Bravo ordering.
enum VoteType {
Against,
For,
Abstain
}
GovernorCountingSimple
Inherits: Governor
Extension of {Governor} for simple, 3 options, vote counting.
State Variables
_proposalVotes
mapping(uint256 proposalId => ProposalVote) private _proposalVotes;
Functions
COUNTING_MODE
module:voting
*A description of the possible support values for {castVote} and the way these votes are counted, meant to
be consumed by UIs to show correct vote options and interpret the results. The string is a URL-encoded sequence of
key-value pairs that each describe one aspect, for example support=bravo&quorum=for,abstain.
There are 2 standard keys: support and quorum.
support=bravorefers to the vote options 0 = Against, 1 = For, 2 = Abstain, as inGovernorBravo.quorum=bravomeans that only For votes are counted towards quorum.quorum=for,abstainmeans that both For and Abstain votes are counted towards quorum. If a counting module makes use of encodedparams, it should include this under aparamskey with a unique name that describes the behavior. For example:params=fractionalmight refer to a scheme where votes are divided fractionally between for/against/abstain.params=erc721might refer to a scheme where specific NFTs are delegated to vote. NOTE: The string can be decoded by the standard https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams[URLSearchParams] JavaScript class.*
function COUNTING_MODE() public pure virtual override returns (string memory);
hasVoted
module:voting
Returns whether account has cast a vote on proposalId.
function hasVoted(uint256 proposalId, address account) public view virtual override returns (bool);
proposalVotes
Accessor to the internal vote counts.
function proposalVotes(uint256 proposalId)
public
view
virtual
returns (uint256 againstVotes, uint256 forVotes, uint256 abstainVotes);
_quorumReached
Amount of votes already cast passes the threshold limit.
function _quorumReached(uint256 proposalId) internal view virtual override returns (bool);
_voteSucceeded
See Governor-_voteSucceeded. In this module, the forVotes must be strictly over the againstVotes.
function _voteSucceeded(uint256 proposalId) internal view virtual override returns (bool);
_countVote
See Governor-_countVote. In this module, the support follows the VoteType enum (from Governor Bravo).
function _countVote(uint256 proposalId, address account, uint8 support, uint256 totalWeight, bytes memory)
internal
virtual
override
returns (uint256);
Structs
ProposalVote
struct ProposalVote {
uint256 againstVotes;
uint256 forVotes;
uint256 abstainVotes;
mapping(address voter => bool) hasVoted;
}
Enums
VoteType
Supported vote types. Matches Governor Bravo ordering.
enum VoteType {
Against,
For,
Abstain
}
GovernorNoncesKeyed
Inherits: Governor, NoncesKeyed
An extension of {Governor} that extends existing nonce management to use {NoncesKeyed}, where the key is the low-order 192 bits of the proposalId.
This is useful for voting by signature while maintaining separate sequences of nonces for each proposal.
NOTE: Traditional (un-keyed) nonces are still supported and can continue to be used as if this extension was not present.
Functions
_useCheckedNonce
function _useCheckedNonce(address owner, uint256 nonce) internal virtual override(Nonces, NoncesKeyed);
_validateVoteSig
Check the signature against keyed nonce and falls back to the traditional nonce.
NOTE: This function won't call super._validateVoteSig if the keyed nonce is valid.
Side effects may be skipped depending on the linearization of the function.
function _validateVoteSig(uint256 proposalId, uint8 support, address voter, bytes memory signature)
internal
virtual
override
returns (bool);
_validateExtendedVoteSig
Check the signature against keyed nonce and falls back to the traditional nonce.
NOTE: This function won't call super._validateExtendedVoteSig if the keyed nonce is valid.
Side effects may be skipped depending on the linearization of the function.
function _validateExtendedVoteSig(
uint256 proposalId,
uint8 support,
address voter,
string memory reason,
bytes memory params,
bytes memory signature
) internal virtual override returns (bool);
GovernorPreventLateQuorum
Inherits: Governor
A module that ensures there is a minimum voting period after quorum is reached. This prevents a large voter from swaying a vote and triggering quorum at the last minute, by ensuring there is always time for other voters to react and try to oppose the decision. If a vote causes quorum to be reached, the proposal's voting period may be extended so that it does not end before at least a specified time has passed (the "vote extension" parameter). This parameter can be set through a governance proposal.
State Variables
_voteExtension
uint48 private _voteExtension;
_extendedDeadlines
mapping(uint256 proposalId => uint48) private _extendedDeadlines;
Functions
constructor
Initializes the vote extension parameter: the time in either number of blocks or seconds (depending on the governor clock mode) that is required to pass since the moment a proposal reaches quorum until its voting period ends. If necessary the voting period will be extended beyond the one set during proposal creation.
constructor(uint48 initialVoteExtension);
proposalDeadline
Returns the proposal deadline, which may have been extended beyond that set at proposal creation, if the proposal reached quorum late in the voting period. See Governor-proposalDeadline.
function proposalDeadline(uint256 proposalId) public view virtual override returns (uint256);
_tallyUpdated
Vote tally updated and detects if it caused quorum to be reached, potentially extending the voting period. May emit a ProposalExtended event.
function _tallyUpdated(uint256 proposalId) internal virtual override;
lateQuorumVoteExtension
Returns the current value of the vote extension parameter: the number of blocks that are required to pass from the time a proposal reaches quorum until its voting period ends.
function lateQuorumVoteExtension() public view virtual returns (uint48);
setLateQuorumVoteExtension
Changes the lateQuorumVoteExtension. This operation can only be performed by the governance executor, generally through a governance proposal. Emits a {LateQuorumVoteExtensionSet} event.
function setLateQuorumVoteExtension(uint48 newVoteExtension) public virtual onlyGovernance;
_setLateQuorumVoteExtension
Changes the lateQuorumVoteExtension. This is an internal function that can be exposed in a public function like {setLateQuorumVoteExtension} if another access control mechanism is needed. Emits a {LateQuorumVoteExtensionSet} event.
function _setLateQuorumVoteExtension(uint48 newVoteExtension) internal virtual;
Events
ProposalExtended
Emitted when a proposal deadline is pushed back due to reaching quorum late in its voting period.
event ProposalExtended(uint256 indexed proposalId, uint64 extendedDeadline);
LateQuorumVoteExtensionSet
Emitted when the lateQuorumVoteExtension parameter is changed.
event LateQuorumVoteExtensionSet(uint64 oldVoteExtension, uint64 newVoteExtension);
GovernorProposalGuardian
Inherits: Governor
Extension of {Governor} which adds a proposal guardian that can cancel proposals at any stage in the proposal's lifecycle. NOTE: if the proposal guardian is not configured, then proposers take this role for their proposals.
State Variables
_proposalGuardian
address private _proposalGuardian;
Functions
proposalGuardian
Getter that returns the address of the proposal guardian.
function proposalGuardian() public view virtual returns (address);
setProposalGuardian
Update the proposal guardian's address. This operation can only be performed through a governance proposal. Emits a ProposalGuardianSet event.
function setProposalGuardian(address newProposalGuardian) public virtual onlyGovernance;
_setProposalGuardian
Internal setter for the proposal guardian. Emits a ProposalGuardianSet event.
function _setProposalGuardian(address newProposalGuardian) internal virtual;
_validateCancel
Override Governor-_validateCancel to implement the extended cancellation logic. The {proposalGuardian} can cancel any proposal at any point. If no proposal guardian is set, the {IGovernor-proposalProposer} can cancel their proposals at any point. In any case, permissions defined in {Governor-_validateCancel} (or another override) remains valid.
function _validateCancel(uint256 proposalId, address caller) internal view virtual override returns (bool);
Events
ProposalGuardianSet
event ProposalGuardianSet(address oldProposalGuardian, address newProposalGuardian);
GovernorSequentialProposalId
Inherits: Governor
Extension of {Governor} that changes the numbering of proposal ids from the default hash-based approach to sequential ids.
State Variables
_latestProposalId
uint256 private _latestProposalId;
_proposalIds
mapping(uint256 proposalHash => uint256 proposalId) private _proposalIds;
Functions
getProposalId
module:core
Function used to get the proposal id from the proposal details.
function getProposalId(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) public view virtual override returns (uint256);
latestProposalId
Returns the latest proposal id. A return value of 0 means no proposals have been created yet.
function latestProposalId() public view virtual returns (uint256);
_propose
See IGovernor-_propose. Hook into the proposing mechanism to increment proposal count.
function _propose(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
string memory description,
address proposer
) internal virtual override returns (uint256);
_initializeLatestProposalId
Internal function to set the latestProposalId. This function is helpful when transitioning
from another governance system. The next proposal id will be newLatestProposalId + 1.
May only call this function if the current value of {latestProposalId} is 0.
function _initializeLatestProposalId(uint256 newLatestProposalId) internal virtual;
Errors
GovernorAlreadyInitializedLatestProposalId
The latestProposalId may only be initialized if it hasn't been set yet (through initialization or the creation of a proposal).
error GovernorAlreadyInitializedLatestProposalId();
GovernorSettings
Inherits: Governor
Extension of {Governor} for settings updatable through governance.
State Variables
_proposalThreshold
uint256 private _proposalThreshold;
_votingDelay
uint48 private _votingDelay;
_votingPeriod
uint32 private _votingPeriod;
Functions
constructor
Initialize the governance parameters.
constructor(uint48 initialVotingDelay, uint32 initialVotingPeriod, uint256 initialProposalThreshold);
votingDelay
module:user-config
Delay, between the proposal is created and the vote starts. The unit this duration is expressed in depends on the clock (see ERC-6372) this contract uses. This can be increased to leave time for users to buy voting power, or delegate it, before the voting of a proposal starts. NOTE: While this interface returns a uint256, timepoints are stored as uint48 following the ERC-6372 clock type. Consequently this value must fit in a uint48 (when added to the current clock). See {IERC6372-clock}.
function votingDelay() public view virtual override returns (uint256);
votingPeriod
module:user-config
Delay between the vote start and vote end. The unit this duration is expressed in depends on the clock (see ERC-6372) this contract uses. NOTE: The {votingDelay} can delay the start of the vote. This must be considered when setting the voting duration compared to the voting delay. NOTE: This value is stored when the proposal is submitted so that possible changes to the value do not affect proposals that have already been submitted. The type used to save it is a uint32. Consequently, while this interface returns a uint256, the value it returns should fit in a uint32.
function votingPeriod() public view virtual override returns (uint256);
proposalThreshold
function proposalThreshold() public view virtual override returns (uint256);
setVotingDelay
Update the voting delay. This operation can only be performed through a governance proposal. Emits a VotingDelaySet event.
function setVotingDelay(uint48 newVotingDelay) public virtual onlyGovernance;
setVotingPeriod
Update the voting period. This operation can only be performed through a governance proposal. Emits a VotingPeriodSet event.
function setVotingPeriod(uint32 newVotingPeriod) public virtual onlyGovernance;
setProposalThreshold
Update the proposal threshold. This operation can only be performed through a governance proposal. Emits a ProposalThresholdSet event.
function setProposalThreshold(uint256 newProposalThreshold) public virtual onlyGovernance;
_setVotingDelay
Internal setter for the voting delay. Emits a VotingDelaySet event.
function _setVotingDelay(uint48 newVotingDelay) internal virtual;
_setVotingPeriod
Internal setter for the voting period. Emits a VotingPeriodSet event.
function _setVotingPeriod(uint32 newVotingPeriod) internal virtual;
_setProposalThreshold
Internal setter for the proposal threshold. Emits a ProposalThresholdSet event.
function _setProposalThreshold(uint256 newProposalThreshold) internal virtual;
Events
VotingDelaySet
event VotingDelaySet(uint256 oldVotingDelay, uint256 newVotingDelay);
VotingPeriodSet
event VotingPeriodSet(uint256 oldVotingPeriod, uint256 newVotingPeriod);
ProposalThresholdSet
event ProposalThresholdSet(uint256 oldProposalThreshold, uint256 newProposalThreshold);
GovernorStorage
Inherits: Governor
*Extension of {Governor} that implements storage of proposal details. This modules also provides primitives for the enumerability of proposals. Use cases for this module include:
- UIs that explore the proposal state without relying on event indexing.
- Using only the proposalId as an argument in the {Governor-queue} and {Governor-execute} functions for L2 chains where storage is cheap compared to calldata.*
State Variables
_proposalIds
uint256[] private _proposalIds;
_proposalDetails
mapping(uint256 proposalId => ProposalDetails) private _proposalDetails;
Functions
_propose
Hook into the proposing mechanism
function _propose(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
string memory description,
address proposer
) internal virtual override returns (uint256);
queue
Version of IGovernor-queue with only proposalId as an argument.
function queue(uint256 proposalId) public virtual;
execute
Version of IGovernor-execute with only proposalId as an argument.
function execute(uint256 proposalId) public payable virtual;
cancel
ProposalId version of IGovernor-cancel.
function cancel(uint256 proposalId) public virtual;
proposalCount
Returns the number of stored proposals.
function proposalCount() public view virtual returns (uint256);
proposalDetails
Returns the details of a proposalId. Reverts if proposalId is not a known proposal.
function proposalDetails(uint256 proposalId)
public
view
virtual
returns (address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash);
proposalDetailsAt
Returns the details (including the proposalId) of a proposal given its sequential index.
function proposalDetailsAt(uint256 index)
public
view
virtual
returns (
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
);
Structs
ProposalDetails
struct ProposalDetails {
address[] targets;
uint256[] values;
bytes[] calldatas;
bytes32 descriptionHash;
}
GovernorSuperQuorum
Inherits: Governor
Extension of {Governor} with a super quorum. Proposals that meet the super quorum (and have a majority of for
votes) advance to the Succeeded state before the proposal deadline. Counting modules that want to use this
extension must implement {proposalVotes}.
Functions
superQuorum
Minimum number of cast votes required for a proposal to reach super quorum. Only FOR votes are counted
towards the super quorum. Once the super quorum is reached, an active proposal can proceed to the next state
without waiting for the proposal deadline.
NOTE: The timepoint parameter corresponds to the snapshot used for counting the vote. This enables scaling of the
quorum depending on values such as the totalSupply of a token at this timepoint (see {ERC20Votes}).
NOTE: Make sure the value specified for the super quorum is greater than {quorum}, otherwise, it may be
possible to pass a proposal with less votes than the default quorum.
function superQuorum(uint256 timepoint) public view virtual returns (uint256);
proposalVotes
Accessor to the internal vote counts. This must be implemented by the counting module. Counting modules that don't implement this function are incompatible with this module
function proposalVotes(uint256 proposalId)
public
view
virtual
returns (uint256 againstVotes, uint256 forVotes, uint256 abstainVotes);
state
Overridden version of the Governor-state function that checks if the proposal has reached the super quorum. NOTE: If the proposal reaches super quorum but {_voteSucceeded} returns false, eg, assuming the super quorum has been set low enough that both FOR and AGAINST votes have exceeded it and AGAINST votes exceed FOR votes, the proposal continues to be active until {_voteSucceeded} returns true or the proposal deadline is reached. This means that with a low super quorum it is also possible that a vote can succeed prematurely before enough AGAINST voters have a chance to vote. Hence, it is recommended to set a high enough super quorum to avoid these types of scenarios.
function state(uint256 proposalId) public view virtual override returns (ProposalState);
GovernorTimelockAccess
Inherits: Governor
This module connects a {Governor} instance to an {AccessManager} instance, allowing the governor to make calls
that are delay-restricted by the manager using the normal {queue} workflow. An optional base delay is applied to
operations that are not delayed externally by the manager. Execution of a proposal will be delayed as much as
necessary to meet the required delays of all of its operations.
This extension allows the governor to hold and use its own assets and permissions, unlike {GovernorTimelockControl}
and {GovernorTimelockCompound}, where the timelock is a separate contract that must be the one to hold assets and
permissions. Operations that are delay-restricted by the manager, however, will be executed through the
{AccessManager-execute} function.
==== Security Considerations
Some operations may be cancelable in the AccessManager by the admin or a set of guardians, depending on the
restricted function being invoked. Since proposals are atomic, the cancellation by a guardian of a single operation
in a proposal will cause all of the proposal to become unable to execute. Consider proposing cancellable operations
separately.
By default, function calls will be routed through the associated AccessManager whenever it claims the target
function to be restricted by it. However, admins may configure the manager to make that claim for functions that a
governor would want to call directly (e.g., token transfers) in an attempt to deny it access to those functions. To
mitigate this attack vector, the governor is able to ignore the restrictions claimed by the AccessManager using
{setAccessManagerIgnored}. While permanent denial of service is mitigated, temporary DoS may still be technically
possible. All of the governor's own functions (e.g., {setBaseDelaySeconds}) ignore the AccessManager by default.
NOTE: AccessManager does not support scheduling more than one operation with the same target and calldata at
the same time. See {AccessManager-schedule} for a workaround.
State Variables
_ignoreToggle
mapping(address target => mapping(bytes4 selector => bool)) private _ignoreToggle;
_executionPlan
mapping(uint256 proposalId => ExecutionPlan) private _executionPlan;
_baseDelay
uint32 private _baseDelay;
_manager
IAccessManager private immutable _manager;
Functions
constructor
Initialize the governor with an {AccessManager} and initial base delay.
constructor(address manager, uint32 initialBaseDelay);
accessManager
Returns the {AccessManager} instance associated to this governor.
function accessManager() public view virtual returns (IAccessManager);
baseDelaySeconds
Base delay that will be applied to all function calls. Some may be further delayed by their associated
AccessManager authority; in this case the final delay will be the maximum of the base delay and the one
demanded by the authority.
NOTE: Execution delays are processed by the AccessManager contracts, and according to that contract are
expressed in seconds. Therefore, the base delay is also in seconds, regardless of the governor's clock mode.
function baseDelaySeconds() public view virtual returns (uint32);
setBaseDelaySeconds
Change the value of baseDelaySeconds. This operation can only be invoked through a governance proposal.
function setBaseDelaySeconds(uint32 newBaseDelay) public virtual onlyGovernance;
_setBaseDelaySeconds
Change the value of baseDelaySeconds. Internal function without access control.
function _setBaseDelaySeconds(uint32 newBaseDelay) internal virtual;
isAccessManagerIgnored
Check if restrictions from the associated {AccessManager} are ignored for a target function. Returns true
when the target function will be invoked directly regardless of AccessManager settings for the function.
See {setAccessManagerIgnored} and Security Considerations above.
function isAccessManagerIgnored(address target, bytes4 selector) public view virtual returns (bool);
setAccessManagerIgnored
Configure whether restrictions from the associated {AccessManager} are ignored for a target function. See Security Considerations above.
function setAccessManagerIgnored(address target, bytes4[] calldata selectors, bool ignored)
public
virtual
onlyGovernance;
_setAccessManagerIgnored
Internal version of setAccessManagerIgnored without access restriction.
function _setAccessManagerIgnored(address target, bytes4 selector, bool ignored) internal virtual;
proposalExecutionPlan
Public accessor to check the execution plan, including the number of seconds that the proposal will be
delayed since queuing, an array indicating which of the proposal actions will be executed indirectly through
the associated {AccessManager}, and another indicating which will be scheduled in {queue}. Note that
those that must be scheduled are cancellable by AccessManager guardians.
function proposalExecutionPlan(uint256 proposalId)
public
view
returns (uint32 delay, bool[] memory indirect, bool[] memory withDelay);
proposalNeedsQueuing
module:core
Whether a proposal needs to be queued before execution.
function proposalNeedsQueuing(uint256 proposalId) public view virtual override returns (bool);
propose
Create a new proposal. Vote start after a delay specified by {IGovernor-votingDelay} and lasts for a
duration specified by {IGovernor-votingPeriod}.
Emits a {ProposalCreated} event.
NOTE: The state of the Governor and targets may change between the proposal creation and its execution.
This may be the result of third party actions on the targeted contracts, or other governor proposals.
For example, the balance of this contract could be updated or its access control permissions may be modified,
possibly compromising the proposal's ability to execute successfully (e.g. the governor doesn't have enough
value to cover a proposal with multiple transfers).
function propose(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, string memory description)
public
virtual
override
returns (uint256);
_queueOperations
Mechanism to queue a proposal, potentially scheduling some of its operations in the AccessManager. NOTE: The execution delay is chosen based on the delay information retrieved in propose. This value may be off if the delay was updated since proposal creation. In this case, the proposal needs to be recreated.
function _queueOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory,
bytes[] memory calldatas,
bytes32
) internal virtual override returns (uint48);
_executeOperations
Mechanism to execute a proposal, potentially going through AccessManager-execute for delayed operations.
function _executeOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32
) internal virtual override;
_cancel
Internal cancel mechanism with minimal restrictions. A proposal can be cancelled in any state other than Canceled, Expired, or Executed. Once cancelled a proposal can't be re-submitted. Emits a {IGovernor-ProposalCanceled} event.
function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
internal
virtual
override
returns (uint256);
_getManagerData
Returns whether the operation at an index is delayed by the manager, and its scheduling nonce once queued.
function _getManagerData(ExecutionPlan storage plan, uint256 index)
private
view
returns (bool controlled, bool withDelay, uint32 nonce);
_setManagerData
Marks an operation at an index as permissioned by the manager, potentially delayed, and when delayed sets its scheduling nonce.
function _setManagerData(ExecutionPlan storage plan, uint256 index, bool withDelay, uint32 nonce) private;
_getManagerDataIndices
Returns bucket and subindex for reading manager data from the packed array mapping.
function _getManagerDataIndices(uint256 index) private pure returns (uint256 bucket, uint256 subindex);
Events
BaseDelaySet
event BaseDelaySet(uint32 oldBaseDelaySeconds, uint32 newBaseDelaySeconds);
AccessManagerIgnoredSet
event AccessManagerIgnoredSet(address target, bytes4 selector, bool ignored);
Errors
GovernorUnmetDelay
error GovernorUnmetDelay(uint256 proposalId, uint256 neededTimestamp);
GovernorMismatchedNonce
error GovernorMismatchedNonce(uint256 proposalId, uint256 expectedNonce, uint256 actualNonce);
GovernorLockedIgnore
error GovernorLockedIgnore();
Structs
ExecutionPlan
struct ExecutionPlan {
uint16 length;
uint32 delay;
mapping(uint256 operationBucket => uint32[8]) managerData;
}
GovernorTimelockCompound
Inherits: Governor
Extension of {Governor} that binds the execution process to a Compound Timelock. This adds a delay, enforced by the external timelock to all successful proposals (in addition to the voting duration). The {Governor} needs to be the admin of the timelock for any operation to be performed. A public, unrestricted, {GovernorTimelockCompound-__acceptAdmin} is available to accept ownership of the timelock. Using this model means the proposal will be operated by the {TimelockController} and not by the {Governor}. Thus, the assets and permissions must be attached to the {TimelockController}. Any asset sent to the {Governor} will be inaccessible from a proposal, unless executed via {Governor-relay}.
State Variables
_timelock
ICompoundTimelock private _timelock;
Functions
constructor
Set the timelock.
constructor(ICompoundTimelock timelockAddress);
state
Overridden version of the Governor-state function with added support for the Expired state.
function state(uint256 proposalId) public view virtual override returns (ProposalState);
timelock
Public accessor to check the address of the timelock
function timelock() public view virtual returns (address);
proposalNeedsQueuing
module:core
Whether a proposal needs to be queued before execution.
function proposalNeedsQueuing(uint256) public view virtual override returns (bool);
_queueOperations
Function to queue a proposal to the timelock.
function _queueOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32
) internal virtual override returns (uint48);
_executeOperations
Overridden version of the Governor-_executeOperations function that run the already queued proposal through the timelock.
function _executeOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32
) internal virtual override;
_cancel
Overridden version of the Governor-_cancel function to cancel the timelocked proposal if it has already been queued.
function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
internal
virtual
override
returns (uint256);
_executor
Address through which the governor executes action. In this case, the timelock.
function _executor() internal view virtual override returns (address);
__acceptAdmin
Accept admin right over the timelock.
function __acceptAdmin() public;
updateTimelock
Public endpoint to update the underlying timelock instance. Restricted to the timelock itself, so updates must be proposed, scheduled, and executed through governance proposals. For security reasons, the timelock must be handed over to another admin before setting up a new one. The two operations (hand over the timelock) and do the update can be batched in a single proposal. Note that if the timelock admin has been handed over in a previous operation, we refuse updates made through the timelock if admin of the timelock has already been accepted and the operation is executed outside the scope of governance. CAUTION: It is not recommended to change the timelock while there are other queued governance proposals.
function updateTimelock(ICompoundTimelock newTimelock) external virtual onlyGovernance;
_updateTimelock
function _updateTimelock(ICompoundTimelock newTimelock) private;
Events
TimelockChange
Emitted when the timelock controller used for proposal execution is modified.
event TimelockChange(address oldTimelock, address newTimelock);
GovernorTimelockControl
Inherits: Governor
Extension of {Governor} that binds the execution process to an instance of {TimelockController}. This adds a delay, enforced by the {TimelockController} to all successful proposal (in addition to the voting duration). The {Governor} needs the proposer (and ideally the executor and canceller) roles for the {Governor} to work properly. Using this model means the proposal will be operated by the {TimelockController} and not by the {Governor}. Thus, the assets and permissions must be attached to the {TimelockController}. Any asset sent to the {Governor} will be inaccessible from a proposal, unless executed via {Governor-relay}. WARNING: Setting up the TimelockController to have additional proposers or cancelers besides the governor is very risky, as it grants them the ability to: 1) execute operations as the timelock, and thus possibly performing operations or accessing funds that are expected to only be accessible through a vote, and 2) block governance proposals that have been approved by the voters, effectively executing a Denial of Service attack.
State Variables
_timelock
TimelockController private _timelock;
_timelockIds
mapping(uint256 proposalId => bytes32) private _timelockIds;
Functions
constructor
Set the timelock.
constructor(TimelockController timelockAddress);
state
Overridden version of the Governor-state function that considers the status reported by the timelock.
function state(uint256 proposalId) public view virtual override returns (ProposalState);
timelock
Public accessor to check the address of the timelock
function timelock() public view virtual returns (address);
proposalNeedsQueuing
module:core
Whether a proposal needs to be queued before execution.
function proposalNeedsQueuing(uint256) public view virtual override returns (bool);
_queueOperations
Function to queue a proposal to the timelock.
function _queueOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal virtual override returns (uint48);
_executeOperations
Overridden version of the Governor-_executeOperations function that runs the already queued proposal through the timelock.
function _executeOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal virtual override;
_cancel
Overridden version of the Governor-_cancel function to cancel the timelocked proposal if it has already been queued.
function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
internal
virtual
override
returns (uint256);
_executor
Address through which the governor executes action. In this case, the timelock.
function _executor() internal view virtual override returns (address);
updateTimelock
Public endpoint to update the underlying timelock instance. Restricted to the timelock itself, so updates must be proposed, scheduled, and executed through governance proposals. CAUTION: It is not recommended to change the timelock while there are other queued governance proposals.
function updateTimelock(TimelockController newTimelock) external virtual onlyGovernance;
_updateTimelock
function _updateTimelock(TimelockController newTimelock) private;
_timelockSalt
Computes the {TimelockController} operation salt. It is computed with the governor address itself to avoid collisions across governor instances using the same timelock.
function _timelockSalt(bytes32 descriptionHash) private view returns (bytes32);
Events
TimelockChange
Emitted when the timelock controller used for proposal execution is modified.
event TimelockChange(address oldTimelock, address newTimelock);
GovernorVotes
Inherits: Governor
Extension of {Governor} for voting weight extraction from an {ERC20Votes} token, or since v4.5 an {ERC721Votes} token.
State Variables
_token
IERC5805 private immutable _token;
Functions
constructor
constructor(IVotes tokenAddress);
token
The token that voting power is sourced from.
function token() public view virtual returns (IERC5805);
clock
Clock (as specified in ERC-6372) is set to match the token's clock. Fallback to block numbers if the token does not implement ERC-6372.
function clock() public view virtual override returns (uint48);
CLOCK_MODE
Machine-readable description of the clock as specified in ERC-6372.
function CLOCK_MODE() public view virtual override returns (string memory);
_getVotes
Read the voting weight from the token's built in snapshot mechanism (see Governor-_getVotes).
function _getVotes(address account, uint256 timepoint, bytes memory) internal view virtual override returns (uint256);
GovernorVotesQuorumFraction
Inherits: GovernorVotes
Extension of {Governor} for voting weight extraction from an {ERC20Votes} token and a quorum expressed as a fraction of the total supply.
State Variables
_quorumNumeratorHistory
Checkpoints.Trace208 private _quorumNumeratorHistory;
Functions
constructor
Initialize quorum as a fraction of the token's total supply.
The fraction is specified as numerator / denominator. By default the denominator is 100, so quorum is
specified as a percent: a numerator of 10 corresponds to quorum being 10% of total supply. The denominator can be
customized by overriding quorumDenominator.
constructor(uint256 quorumNumeratorValue);
quorumNumerator
Returns the current quorum numerator. See quorumDenominator.
function quorumNumerator() public view virtual returns (uint256);
quorumNumerator
Returns the quorum numerator at a specific timepoint. See quorumDenominator.
function quorumNumerator(uint256 timepoint) public view virtual returns (uint256);
quorumDenominator
Returns the quorum denominator. Defaults to 100, but may be overridden.
function quorumDenominator() public view virtual returns (uint256);
quorum
Returns the quorum for a timepoint, in terms of number of votes: supply * numerator / denominator.
function quorum(uint256 timepoint) public view virtual override returns (uint256);
updateQuorumNumerator
*Changes the quorum numerator. Emits a QuorumNumeratorUpdated event. Requirements:
- Must be called through a governance proposal.
- New numerator must be smaller or equal to the denominator.*
function updateQuorumNumerator(uint256 newQuorumNumerator) external virtual onlyGovernance;
_updateQuorumNumerator
*Changes the quorum numerator. Emits a QuorumNumeratorUpdated event. Requirements:
- New numerator must be smaller or equal to the denominator.*
function _updateQuorumNumerator(uint256 newQuorumNumerator) internal virtual;
_optimisticUpperLookupRecent
Returns the numerator at a specific timepoint.
function _optimisticUpperLookupRecent(Checkpoints.Trace208 storage ckpts, uint256 timepoint)
internal
view
returns (uint256);
Events
QuorumNumeratorUpdated
event QuorumNumeratorUpdated(uint256 oldQuorumNumerator, uint256 newQuorumNumerator);
Errors
GovernorInvalidQuorumFraction
The quorum set is not a valid fraction.
error GovernorInvalidQuorumFraction(uint256 quorumNumerator, uint256 quorumDenominator);
GovernorVotesSuperQuorumFraction
Inherits: GovernorVotesQuorumFraction, GovernorSuperQuorum
Extension of {GovernorVotesQuorumFraction} with a super quorum expressed as a
fraction of the total supply. Proposals that meet the super quorum (and have a majority of for votes) advance to
the Succeeded state before the proposal deadline.
State Variables
_superQuorumNumeratorHistory
Checkpoints.Trace208 private _superQuorumNumeratorHistory;
Functions
constructor
Initialize super quorum as a fraction of the token's total supply. The super quorum is specified as a fraction of the token's total supply and has to be greater than the quorum.
constructor(uint256 superQuorumNumeratorValue);
superQuorumNumerator
Returns the current super quorum numerator.
function superQuorumNumerator() public view virtual returns (uint256);
superQuorumNumerator
Returns the super quorum numerator at a specific timepoint.
function superQuorumNumerator(uint256 timepoint) public view virtual returns (uint256);
superQuorum
Returns the super quorum for a timepoint, in terms of number of votes: supply * numerator / denominator.
See GovernorSuperQuorum-superQuorum for more details.
function superQuorum(uint256 timepoint) public view virtual override returns (uint256);
updateSuperQuorumNumerator
*Changes the super quorum numerator. Emits a SuperQuorumNumeratorUpdated event. Requirements:
- Must be called through a governance proposal.
- New super quorum numerator must be smaller or equal to the denominator.
- New super quorum numerator must be greater than or equal to the quorum numerator.*
function updateSuperQuorumNumerator(uint256 newSuperQuorumNumerator) public virtual onlyGovernance;
_updateSuperQuorumNumerator
*Changes the super quorum numerator. Emits a SuperQuorumNumeratorUpdated event. Requirements:
- New super quorum numerator must be smaller or equal to the denominator.
- New super quorum numerator must be greater than or equal to the quorum numerator.*
function _updateSuperQuorumNumerator(uint256 newSuperQuorumNumerator) internal virtual;
_updateQuorumNumerator
Overrides {GovernorVotesQuorumFraction-_updateQuorumNumerator} to ensure the super quorum numerator is greater than or equal to the quorum numerator.
function _updateQuorumNumerator(uint256 newQuorumNumerator) internal virtual override;
state
Overridden version of the {Governor-state} function that checks if the proposal has reached the super quorum. NOTE: If the proposal reaches super quorum but {_voteSucceeded} returns false, eg, assuming the super quorum has been set low enough that both FOR and AGAINST votes have exceeded it and AGAINST votes exceed FOR votes, the proposal continues to be active until {_voteSucceeded} returns true or the proposal deadline is reached. This means that with a low super quorum it is also possible that a vote can succeed prematurely before enough AGAINST voters have a chance to vote. Hence, it is recommended to set a high enough super quorum to avoid these types of scenarios.
function state(uint256 proposalId)
public
view
virtual
override(Governor, GovernorSuperQuorum)
returns (ProposalState);
Events
SuperQuorumNumeratorUpdated
event SuperQuorumNumeratorUpdated(uint256 oldSuperQuorumNumerator, uint256 newSuperQuorumNumerator);
Errors
GovernorInvalidSuperQuorumFraction
The super quorum set is not valid as it exceeds the quorum denominator.
error GovernorInvalidSuperQuorumFraction(uint256 superQuorumNumerator, uint256 denominator);
GovernorInvalidSuperQuorumTooSmall
The super quorum set is not valid as it is smaller or equal to the quorum.
error GovernorInvalidSuperQuorumTooSmall(uint256 superQuorumNumerator, uint256 quorumNumerator);
GovernorInvalidQuorumTooLarge
The quorum set is not valid as it exceeds the super quorum.
error GovernorInvalidQuorumTooLarge(uint256 quorumNumerator, uint256 superQuorumNumerator);
Contents
IVotes
Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts.
Functions
getVotes
Returns the current amount of votes that account has.
function getVotes(address account) external view returns (uint256);
getPastVotes
Returns the amount of votes that account had at a specific moment in the past. If the clock() is
configured to use block numbers, this will return the value at the end of the corresponding block.
function getPastVotes(address account, uint256 timepoint) external view returns (uint256);
getPastTotalSupply
Returns the total supply of votes available at a specific moment in the past. If the clock() is
configured to use block numbers, this will return the value at the end of the corresponding block.
NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.
Votes that have not been delegated are still part of total supply, even though they would not participate in a
vote.
function getPastTotalSupply(uint256 timepoint) external view returns (uint256);
delegates
Returns the delegate that account has chosen.
function delegates(address account) external view returns (address);
delegate
Delegates votes from the sender to delegatee.
function delegate(address delegatee) external;
delegateBySig
Delegates votes from signer to delegatee.
function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external;
Events
DelegateChanged
Emitted when an account changes their delegate.
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
DelegateVotesChanged
Emitted when a token transfer or delegate change results in changes to a delegate's number of voting units.
event DelegateVotesChanged(address indexed delegate, uint256 previousVotes, uint256 newVotes);
Errors
VotesExpiredSignature
The signature used has expired.
error VotesExpiredSignature(uint256 expiry);
Votes
Inherits: Context, EIP712, Nonces, IERC5805
This is a base abstract contract that tracks voting units, which are a measure of voting power that can be transferred, and provides a system of vote delegation, where an account can delegate its voting units to a sort of "representative" that will pool delegated voting units from different accounts and can then use it to vote in decisions. In fact, voting units must be delegated in order to count as actual votes, and an account has to delegate those votes to itself if it wishes to participate in decisions and does not have a trusted representative. This contract is often combined with a token contract such that voting units correspond to token units. For an example, see {ERC721Votes}. The full history of delegate votes is tracked on-chain so that governance protocols can consider votes as distributed at a particular block number to protect against flash loans and double voting. The opt-in delegate system makes the cost of this history tracking optional. When using this module the derived contract must implement {_getVotingUnits} (for example, make it return {ERC721-balanceOf}), and can use {_transferVotingUnits} to track a change in the distribution of those units (in the previous example, it would be included in {ERC721-_update}).
State Variables
DELEGATION_TYPEHASH
bytes32 private constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
_delegatee
mapping(address account => address) private _delegatee;
_delegateCheckpoints
mapping(address delegatee => Checkpoints.Trace208) private _delegateCheckpoints;
_totalCheckpoints
Checkpoints.Trace208 private _totalCheckpoints;
Functions
clock
Clock used for flagging checkpoints. Can be overridden to implement timestamp based checkpoints (and voting), in which case CLOCK_MODE should be overridden as well to match.
function clock() public view virtual returns (uint48);
CLOCK_MODE
Machine-readable description of the clock as specified in ERC-6372.
function CLOCK_MODE() public view virtual returns (string memory);
_validateTimepoint
Validate that a timepoint is in the past, and return it as a uint48.
function _validateTimepoint(uint256 timepoint) internal view returns (uint48);
getVotes
Returns the current amount of votes that account has.
function getVotes(address account) public view virtual returns (uint256);
getPastVotes
*Returns the amount of votes that account had at a specific moment in the past. If the clock() is
configured to use block numbers, this will return the value at the end of the corresponding block.
Requirements:
timepointmust be in the past. If operating using block numbers, the block must be already mined.*
function getPastVotes(address account, uint256 timepoint) public view virtual returns (uint256);
getPastTotalSupply
*Returns the total supply of votes available at a specific moment in the past. If the clock() is
configured to use block numbers, this will return the value at the end of the corresponding block.
NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.
Votes that have not been delegated are still part of total supply, even though they would not participate in a
vote.
Requirements:
timepointmust be in the past. If operating using block numbers, the block must be already mined.*
function getPastTotalSupply(uint256 timepoint) public view virtual returns (uint256);
_getTotalSupply
Returns the current total supply of votes.
function _getTotalSupply() internal view virtual returns (uint256);
delegates
Returns the delegate that account has chosen.
function delegates(address account) public view virtual returns (address);
delegate
Delegates votes from the sender to delegatee.
function delegate(address delegatee) public virtual;
delegateBySig
Delegates votes from signer to delegatee.
function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s)
public
virtual;
_delegate
Delegate all of account's voting units to delegatee.
Emits events {IVotes-DelegateChanged} and {IVotes-DelegateVotesChanged}.
function _delegate(address account, address delegatee) internal virtual;
_transferVotingUnits
Transfers, mints, or burns voting units. To register a mint, from should be zero. To register a burn, to
should be zero. Total supply of voting units will be adjusted with mints and burns.
function _transferVotingUnits(address from, address to, uint256 amount) internal virtual;
_moveDelegateVotes
Moves delegated votes from one delegate to another.
function _moveDelegateVotes(address from, address to, uint256 amount) internal virtual;
_numCheckpoints
Get number of checkpoints for account.
function _numCheckpoints(address account) internal view virtual returns (uint32);
_checkpoints
Get the pos-th checkpoint for account.
function _checkpoints(address account, uint32 pos) internal view virtual returns (Checkpoints.Checkpoint208 memory);
_push
function _push(Checkpoints.Trace208 storage store, function(uint208, uint208) view returns (uint208) op, uint208 delta)
private
returns (uint208 oldValue, uint208 newValue);
_add
function _add(uint208 a, uint208 b) private pure returns (uint208);
_subtract
function _subtract(uint208 a, uint208 b) private pure returns (uint208);
_getVotingUnits
Must return the voting units held by an account.
function _getVotingUnits(address) internal view virtual returns (uint256);
Errors
ERC6372InconsistentClock
The clock was incorrectly modified.
error ERC6372InconsistentClock();
ERC5805FutureLookup
Lookup to future votes is not available.
error ERC5805FutureLookup(uint256 timepoint, uint48 clock);
VotesExtended
Inherits: Votes
*Extension of {Votes} that adds checkpoints for delegations and balances. WARNING: While this contract extends {Votes}, valid uses of {Votes} may not be compatible with {VotesExtended} without additional considerations. This implementation of {_transferVotingUnits} must run AFTER the voting weight movement is registered, such that it is reflected on {_getVotingUnits}. Said differently, {VotesExtended} MUST be integrated in a way that calls {_transferVotingUnits} AFTER the asset transfer is registered and balances are updated:
contract VotingToken is Token, VotesExtended {
function transfer(address from, address to, uint256 tokenId) public override {
super.transfer(from, to, tokenId); // <- Perform the transfer first ...
_transferVotingUnits(from, to, 1); // <- ... then call _transferVotingUnits.
}
function _getVotingUnits(address account) internal view override returns (uint256) {
return balanceOf(account);
}
}
{ERC20Votes} and {ERC721Votes} follow this pattern and are thus safe to use with {VotesExtended}.*
State Variables
_userDelegationCheckpoints
mapping(address delegator => Checkpoints.Trace160) private _userDelegationCheckpoints;
_userVotingUnitsCheckpoints
mapping(address account => Checkpoints.Trace208) private _userVotingUnitsCheckpoints;
Functions
getPastDelegate
*Returns the delegate of an account at a specific moment in the past. If the clock() is
configured to use block numbers, this will return the value at the end of the corresponding block.
Requirements:
timepointmust be in the past. If operating using block numbers, the block must be already mined.*
function getPastDelegate(address account, uint256 timepoint) public view virtual returns (address);
getPastBalanceOf
*Returns the balanceOf of an account at a specific moment in the past. If the clock() is
configured to use block numbers, this will return the value at the end of the corresponding block.
Requirements:
timepointmust be in the past. If operating using block numbers, the block must be already mined.*
function getPastBalanceOf(address account, uint256 timepoint) public view virtual returns (uint256);
_delegate
Delegate all of account's voting units to delegatee.
Emits events {IVotes-DelegateChanged} and {IVotes-DelegateVotesChanged}.
function _delegate(address account, address delegatee) internal virtual override;
_transferVotingUnits
Transfers, mints, or burns voting units. To register a mint, from should be zero. To register a burn, to
should be zero. Total supply of voting units will be adjusted with mints and burns.
function _transferVotingUnits(address from, address to, uint256 amount) internal virtual override;
Governor
Inherits: Context, ERC165, EIP712, Nonces, IGovernor, IERC721Receiver, IERC1155Receiver
*Core of the governance system, designed to be extended through various modules. This contract is abstract and requires several functions to be implemented in various modules:
- A counting module must implement _quorumReached, {_voteSucceeded} and {_countVote}
- A voting module must implement {_getVotes}
- Additionally, {votingPeriod}, {votingDelay}, and {quorum} must also be implemented*
State Variables
BALLOT_TYPEHASH
bytes32 public constant BALLOT_TYPEHASH =
keccak256("Ballot(uint256 proposalId,uint8 support,address voter,uint256 nonce)");
EXTENDED_BALLOT_TYPEHASH
bytes32 public constant EXTENDED_BALLOT_TYPEHASH =
keccak256("ExtendedBallot(uint256 proposalId,uint8 support,address voter,uint256 nonce,string reason,bytes params)");
ALL_PROPOSAL_STATES_BITMAP
bytes32 private constant ALL_PROPOSAL_STATES_BITMAP = bytes32((2 ** (uint8(type(ProposalState).max) + 1)) - 1);
_name
string private _name;
_proposals
mapping(uint256 proposalId => ProposalCore) private _proposals;
_governanceCall
DoubleEndedQueue.Bytes32Deque private _governanceCall;
Functions
onlyGovernance
Restricts a function so it can only be executed through governance proposals. For example, governance parameter setters in {GovernorSettings} are protected using this modifier. The governance executing address may be different from the Governor's own address, for example it could be a timelock. This can be customized by modules by overriding {_executor}. The executor is only able to invoke these functions during the execution of the governor's {execute} function, and not under any other circumstances. Thus, for example, additional timelock proposers are not able to change governance parameters without going through the governance protocol (since v4.6).
modifier onlyGovernance();
constructor
Sets the value for name and {version}
constructor(string memory name_) EIP712(name_, version());
receive
Function to receive ETH that will be handled by the governor (disabled if executor is a third party contract)
receive() external payable virtual;
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165) returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
name
module:core
Name of the governor instance (used in building the EIP-712 domain separator).
function name() public view virtual returns (string memory);
version
module:core
Version of the governor instance (used in building the EIP-712 domain separator). Default: "1"
function version() public view virtual returns (string memory);
hashProposal
See {IGovernor-hashProposal}.
The proposal id is produced by hashing the ABI encoded targets array, the values array, the calldatas array
and the descriptionHash (bytes32 which itself is the keccak256 hash of the description string). This proposal id
can be produced from the proposal data which is part of the {ProposalCreated} event. It can even be computed in
advance, before the proposal is submitted.
Note that the chainId and the governor address are not part of the proposal id computation. Consequently, the
same proposal (with same operation and same description) will have the same id if submitted on multiple governors
across multiple networks. This also means that in order to execute the same operation twice (on the same
governor) the proposer will have to change the description in order to avoid proposal id conflicts.
function hashProposal(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) public pure virtual returns (uint256);
getProposalId
module:core
Function used to get the proposal id from the proposal details.
function getProposalId(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) public view virtual returns (uint256);
state
module:core
Current state of a proposal, following Compound's convention
function state(uint256 proposalId) public view virtual returns (ProposalState);
proposalThreshold
module:core
The number of votes required in order for a voter to become a proposer.
function proposalThreshold() public view virtual returns (uint256);
proposalSnapshot
module:core
Timepoint used to retrieve user's votes and quorum. If using block number (as per Compound's Comp), the snapshot is performed at the end of this block. Hence, voting for this proposal starts at the beginning of the following block.
function proposalSnapshot(uint256 proposalId) public view virtual returns (uint256);
proposalDeadline
module:core
Timepoint at which votes close. If using block number, votes close at the end of this block, so it is possible to cast a vote during this block.
function proposalDeadline(uint256 proposalId) public view virtual returns (uint256);
proposalProposer
module:core
The account that created a proposal.
function proposalProposer(uint256 proposalId) public view virtual returns (address);
proposalEta
module:core
The time when a queued proposal becomes executable ("ETA"). Unlike {proposalSnapshot} and {proposalDeadline}, this doesn't use the governor clock, and instead relies on the executor's clock which may be different. In most cases this will be a timestamp.
function proposalEta(uint256 proposalId) public view virtual returns (uint256);
proposalNeedsQueuing
module:core
Whether a proposal needs to be queued before execution.
function proposalNeedsQueuing(uint256) public view virtual returns (bool);
_checkGovernance
Reverts if the msg.sender is not the executor. In case the executor is not this contract
itself, the function reverts if msg.data is not whitelisted as a result of an execute
operation. See {onlyGovernance}.
function _checkGovernance() internal virtual;
_quorumReached
Amount of votes already cast passes the threshold limit.
function _quorumReached(uint256 proposalId) internal view virtual returns (bool);
_voteSucceeded
Is the proposal successful or not.
function _voteSucceeded(uint256 proposalId) internal view virtual returns (bool);
_getVotes
Get the voting weight of account at a specific timepoint, for a vote as described by params.
function _getVotes(address account, uint256 timepoint, bytes memory params) internal view virtual returns (uint256);
_countVote
Register a vote for proposalId by account with a given support, voting weight and voting params.
Note: Support is generic and can represent various things depending on the voting system used.
function _countVote(uint256 proposalId, address account, uint8 support, uint256 totalWeight, bytes memory params)
internal
virtual
returns (uint256);
_tallyUpdated
Hook that should be called every time the tally for a proposal is updated. Note: This function must run successfully. Reverts will result in the bricking of governance
function _tallyUpdated(uint256 proposalId) internal virtual;
_defaultParams
Default additional encoded parameters used by castVote methods that don't include them Note: Should be overridden by specific implementations to use an appropriate value, the meaning of the additional params, in the context of that implementation
function _defaultParams() internal view virtual returns (bytes memory);
propose
See IGovernor-propose. This function has opt-in frontrunning protection, described in {_isValidDescriptionForProposer}.
function propose(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, string memory description)
public
virtual
returns (uint256);
_propose
Internal propose mechanism. Can be overridden to add more logic on proposal creation. Emits a {IGovernor-ProposalCreated} event.
function _propose(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
string memory description,
address proposer
) internal virtual returns (uint256 proposalId);
queue
Queue a proposal. Some governors require this step to be performed before execution can happen. If queuing is not necessary, this function may revert. Queuing a proposal requires the quorum to be reached, the vote to be successful, and the deadline to be reached. Emits a {ProposalQueued} event.
function queue(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
public
virtual
returns (uint256);
_queueOperations
Internal queuing mechanism. Can be overridden (without a super call) to modify the way queuing is
performed (for example adding a vault/timelock).
This is empty by default, and must be overridden to implement queuing.
This function returns a timestamp that describes the expected ETA for execution. If the returned value is 0
(which is the default value), the core will consider queueing did not succeed, and the public queue function
will revert.
NOTE: Calling this function directly will NOT check the current state of the proposal, or emit the
ProposalQueued event. Queuing a proposal should be done using {queue}.
function _queueOperations(uint256, address[] memory, uint256[] memory, bytes[] memory, bytes32)
internal
virtual
returns (uint48);
execute
Execute a successful proposal. This requires the quorum to be reached, the vote to be successful, and the deadline to be reached. Depending on the governor it might also be required that the proposal was queued and that some delay passed. Emits a {ProposalExecuted} event. NOTE: Some modules can modify the requirements for execution, for example by adding an additional timelock.
function execute(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
public
payable
virtual
returns (uint256);
_executeOperations
Internal execution mechanism. Can be overridden (without a super call) to modify the way execution is
performed (for example adding a vault/timelock).
NOTE: Calling this function directly will NOT check the current state of the proposal, set the executed flag to
true or emit the ProposalExecuted event. Executing a proposal should be done using execute.
function _executeOperations(
uint256,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32
) internal virtual;
cancel
Cancel a proposal. A proposal is cancellable by the proposer, but only while it is Pending state, i.e. before the vote starts. Emits a {ProposalCanceled} event.
function cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
public
virtual
returns (uint256);
_cancel
Internal cancel mechanism with minimal restrictions. A proposal can be cancelled in any state other than Canceled, Expired, or Executed. Once cancelled a proposal can't be re-submitted. Emits a {IGovernor-ProposalCanceled} event.
function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
internal
virtual
returns (uint256);
getVotes
module:reputation
Voting power of an account at a specific timepoint.
Note: this can be implemented in a number of ways, for example by reading the delegated balance from one (or
multiple), {ERC20Votes} tokens.
function getVotes(address account, uint256 timepoint) public view virtual returns (uint256);
getVotesWithParams
module:reputation
Voting power of an account at a specific timepoint given additional encoded parameters.
function getVotesWithParams(address account, uint256 timepoint, bytes memory params)
public
view
virtual
returns (uint256);
castVote
Cast a vote Emits a {VoteCast} event.
function castVote(uint256 proposalId, uint8 support) public virtual returns (uint256);
castVoteWithReason
Cast a vote with a reason Emits a {VoteCast} event.
function castVoteWithReason(uint256 proposalId, uint8 support, string calldata reason)
public
virtual
returns (uint256);
castVoteWithReasonAndParams
Cast a vote with a reason and additional encoded parameters Emits a {VoteCast} or {VoteCastWithParams} event depending on the length of params.
function castVoteWithReasonAndParams(uint256 proposalId, uint8 support, string calldata reason, bytes memory params)
public
virtual
returns (uint256);
castVoteBySig
Cast a vote using the voter's signature, including ERC-1271 signature support. Emits a {VoteCast} event.
function castVoteBySig(uint256 proposalId, uint8 support, address voter, bytes memory signature)
public
virtual
returns (uint256);
castVoteWithReasonAndParamsBySig
Cast a vote with a reason and additional encoded parameters using the voter's signature, including ERC-1271 signature support. Emits a {VoteCast} or {VoteCastWithParams} event depending on the length of params.
function castVoteWithReasonAndParamsBySig(
uint256 proposalId,
uint8 support,
address voter,
string calldata reason,
bytes memory params,
bytes memory signature
) public virtual returns (uint256);
_validateVoteSig
Validate the signature used in castVoteBySig function.
function _validateVoteSig(uint256 proposalId, uint8 support, address voter, bytes memory signature)
internal
virtual
returns (bool);
_validateExtendedVoteSig
Validate the signature used in castVoteWithReasonAndParamsBySig function.
function _validateExtendedVoteSig(
uint256 proposalId,
uint8 support,
address voter,
string memory reason,
bytes memory params,
bytes memory signature
) internal virtual returns (bool);
_castVote
Internal vote casting mechanism: Check that the vote is pending, that it has not been cast yet, retrieve voting weight using IGovernor-getVotes and call the {_countVote} internal function. Uses the _defaultParams(). Emits a {IGovernor-VoteCast} event.
function _castVote(uint256 proposalId, address account, uint8 support, string memory reason)
internal
virtual
returns (uint256);
_castVote
Internal vote casting mechanism: Check that the vote is pending, that it has not been cast yet, retrieve voting weight using IGovernor-getVotes and call the {_countVote} internal function. Emits a {IGovernor-VoteCast} event.
function _castVote(uint256 proposalId, address account, uint8 support, string memory reason, bytes memory params)
internal
virtual
returns (uint256);
relay
Relays a transaction or function call to an arbitrary target. In cases where the governance executor
is some contract other than the governor itself, like when using a timelock, this function can be invoked
in a governance proposal to recover tokens or Ether that was sent to the governor contract by mistake.
Note that if the executor is simply the governor itself, use of relay is redundant.
function relay(address target, uint256 value, bytes calldata data) external payable virtual onlyGovernance;
_executor
Address through which the governor executes action. Will be overloaded by module that execute actions through another contract such as a timelock.
function _executor() internal view virtual returns (address);
onERC721Received
See IERC721Receiver-onERC721Received. Receiving tokens is disabled if the governance executor is other than the governor itself (eg. when using with a timelock).
function onERC721Received(address, address, uint256, bytes memory) public virtual returns (bytes4);
onERC1155Received
See IERC1155Receiver-onERC1155Received. Receiving tokens is disabled if the governance executor is other than the governor itself (eg. when using with a timelock).
function onERC1155Received(address, address, uint256, uint256, bytes memory) public virtual returns (bytes4);
onERC1155BatchReceived
See IERC1155Receiver-onERC1155BatchReceived. Receiving tokens is disabled if the governance executor is other than the governor itself (eg. when using with a timelock).
function onERC1155BatchReceived(address, address, uint256[] memory, uint256[] memory, bytes memory)
public
virtual
returns (bytes4);
_encodeStateBitmap
Encodes a ProposalState into a bytes32 representation where each bit enabled corresponds to
the underlying position in the ProposalState enum. For example:
0x000...10000
^^^^^^------ ...
^----- Succeeded
^---- Defeated
^--- Canceled
^-- Active
^- Pending
function _encodeStateBitmap(ProposalState proposalState) internal pure returns (bytes32);
_validateStateBitmap
Check that the current state of a proposal matches the requirements described by the allowedStates bitmap.
This bitmap should be built using _encodeStateBitmap.
If requirements are not met, reverts with a {GovernorUnexpectedProposalState} error.
function _validateStateBitmap(uint256 proposalId, bytes32 allowedStates) internal view returns (ProposalState);
_isValidDescriptionForProposer
function _isValidDescriptionForProposer(address proposer, string memory description)
internal
view
virtual
returns (bool);
_validateCancel
Check if the caller can cancel the proposal with the given proposalId.
The default implementation allows the proposal proposer to cancel the proposal during the pending state.
function _validateCancel(uint256 proposalId, address caller) internal view virtual returns (bool);
clock
Clock used for flagging checkpoints. Can be overridden to implement timestamp based checkpoints (and voting).
function clock() public view virtual returns (uint48);
CLOCK_MODE
Description of the clock
function CLOCK_MODE() public view virtual returns (string memory);
votingDelay
module:user-config
Delay, between the proposal is created and the vote starts. The unit this duration is expressed in depends on the clock (see ERC-6372) this contract uses. This can be increased to leave time for users to buy voting power, or delegate it, before the voting of a proposal starts. NOTE: While this interface returns a uint256, timepoints are stored as uint48 following the ERC-6372 clock type. Consequently this value must fit in a uint48 (when added to the current clock). See {IERC6372-clock}.
function votingDelay() public view virtual returns (uint256);
votingPeriod
module:user-config
Delay between the vote start and vote end. The unit this duration is expressed in depends on the clock (see ERC-6372) this contract uses. NOTE: The {votingDelay} can delay the start of the vote. This must be considered when setting the voting duration compared to the voting delay. NOTE: This value is stored when the proposal is submitted so that possible changes to the value do not affect proposals that have already been submitted. The type used to save it is a uint32. Consequently, while this interface returns a uint256, the value it returns should fit in a uint32.
function votingPeriod() public view virtual returns (uint256);
quorum
module:user-config
Minimum number of cast voted required for a proposal to be successful.
NOTE: The timepoint parameter corresponds to the snapshot used for counting vote. This allows to scale the
quorum depending on values such as the totalSupply of a token at this timepoint (see {ERC20Votes}).
function quorum(uint256 timepoint) public view virtual returns (uint256);
_unsafeReadBytesOffset
Reads a bytes32 from a bytes array without bounds checking. NOTE: making this function internal would mean it could be used with memory unsafe offset, and marking the assembly block as such would prevent some optimizations.
function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value);
Structs
ProposalCore
struct ProposalCore {
address proposer;
uint48 voteStart;
uint32 voteDuration;
bool executed;
bool canceled;
uint48 etaSeconds;
}
IGovernor
Interface of the {Governor} core.
NOTE: Event parameters lack the indexed keyword for compatibility with GovernorBravo events.
Making event parameters indexed affects how events are decoded, potentially breaking existing indexers.
Functions
name
module:core
Name of the governor instance (used in building the EIP-712 domain separator).
function name() external view returns (string memory);
version
module:core
Version of the governor instance (used in building the EIP-712 domain separator). Default: "1"
function version() external view returns (string memory);
COUNTING_MODE
module:voting
*A description of the possible support values for castVote and the way these votes are counted, meant to
be consumed by UIs to show correct vote options and interpret the results. The string is a URL-encoded sequence of
key-value pairs that each describe one aspect, for example support=bravo&quorum=for,abstain.
There are 2 standard keys: support and quorum.
support=bravorefers to the vote options 0 = Against, 1 = For, 2 = Abstain, as inGovernorBravo.quorum=bravomeans that only For votes are counted towards quorum.quorum=for,abstainmeans that both For and Abstain votes are counted towards quorum. If a counting module makes use of encodedparams, it should include this under aparamskey with a unique name that describes the behavior. For example:params=fractionalmight refer to a scheme where votes are divided fractionally between for/against/abstain.params=erc721might refer to a scheme where specific NFTs are delegated to vote. NOTE: The string can be decoded by the standard https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams[URLSearchParams] JavaScript class.*
function COUNTING_MODE() external view returns (string memory);
hashProposal
module:core
Hashing function used to (re)build the proposal id from the proposal details. NOTE: For all off-chain and external calls, use getProposalId.
function hashProposal(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) external pure returns (uint256);
getProposalId
module:core
Function used to get the proposal id from the proposal details.
function getProposalId(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) external view returns (uint256);
state
module:core
Current state of a proposal, following Compound's convention
function state(uint256 proposalId) external view returns (ProposalState);
proposalThreshold
module:core
The number of votes required in order for a voter to become a proposer.
function proposalThreshold() external view returns (uint256);
proposalSnapshot
module:core
Timepoint used to retrieve user's votes and quorum. If using block number (as per Compound's Comp), the snapshot is performed at the end of this block. Hence, voting for this proposal starts at the beginning of the following block.
function proposalSnapshot(uint256 proposalId) external view returns (uint256);
proposalDeadline
module:core
Timepoint at which votes close. If using block number, votes close at the end of this block, so it is possible to cast a vote during this block.
function proposalDeadline(uint256 proposalId) external view returns (uint256);
proposalProposer
module:core
The account that created a proposal.
function proposalProposer(uint256 proposalId) external view returns (address);
proposalEta
module:core
The time when a queued proposal becomes executable ("ETA"). Unlike proposalSnapshot and {proposalDeadline}, this doesn't use the governor clock, and instead relies on the executor's clock which may be different. In most cases this will be a timestamp.
function proposalEta(uint256 proposalId) external view returns (uint256);
proposalNeedsQueuing
module:core
Whether a proposal needs to be queued before execution.
function proposalNeedsQueuing(uint256 proposalId) external view returns (bool);
votingDelay
module:user-config
Delay, between the proposal is created and the vote starts. The unit this duration is expressed in depends on the clock (see ERC-6372) this contract uses. This can be increased to leave time for users to buy voting power, or delegate it, before the voting of a proposal starts. NOTE: While this interface returns a uint256, timepoints are stored as uint48 following the ERC-6372 clock type. Consequently this value must fit in a uint48 (when added to the current clock). See IERC6372-clock.
function votingDelay() external view returns (uint256);
votingPeriod
module:user-config
Delay between the vote start and vote end. The unit this duration is expressed in depends on the clock (see ERC-6372) this contract uses. NOTE: The votingDelay can delay the start of the vote. This must be considered when setting the voting duration compared to the voting delay. NOTE: This value is stored when the proposal is submitted so that possible changes to the value do not affect proposals that have already been submitted. The type used to save it is a uint32. Consequently, while this interface returns a uint256, the value it returns should fit in a uint32.
function votingPeriod() external view returns (uint256);
quorum
module:user-config
Minimum number of cast voted required for a proposal to be successful.
NOTE: The timepoint parameter corresponds to the snapshot used for counting vote. This allows to scale the
quorum depending on values such as the totalSupply of a token at this timepoint (see {ERC20Votes}).
function quorum(uint256 timepoint) external view returns (uint256);
getVotes
module:reputation
Voting power of an account at a specific timepoint.
Note: this can be implemented in a number of ways, for example by reading the delegated balance from one (or
multiple), {ERC20Votes} tokens.
function getVotes(address account, uint256 timepoint) external view returns (uint256);
getVotesWithParams
module:reputation
Voting power of an account at a specific timepoint given additional encoded parameters.
function getVotesWithParams(address account, uint256 timepoint, bytes memory params) external view returns (uint256);
hasVoted
module:voting
Returns whether account has cast a vote on proposalId.
function hasVoted(uint256 proposalId, address account) external view returns (bool);
propose
Create a new proposal. Vote start after a delay specified by IGovernor-votingDelay and lasts for a
duration specified by {IGovernor-votingPeriod}.
Emits a {ProposalCreated} event.
NOTE: The state of the Governor and targets may change between the proposal creation and its execution.
This may be the result of third party actions on the targeted contracts, or other governor proposals.
For example, the balance of this contract could be updated or its access control permissions may be modified,
possibly compromising the proposal's ability to execute successfully (e.g. the governor doesn't have enough
value to cover a proposal with multiple transfers).
function propose(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, string memory description)
external
returns (uint256 proposalId);
queue
Queue a proposal. Some governors require this step to be performed before execution can happen. If queuing is not necessary, this function may revert. Queuing a proposal requires the quorum to be reached, the vote to be successful, and the deadline to be reached. Emits a ProposalQueued event.
function queue(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
external
returns (uint256 proposalId);
execute
Execute a successful proposal. This requires the quorum to be reached, the vote to be successful, and the deadline to be reached. Depending on the governor it might also be required that the proposal was queued and that some delay passed. Emits a ProposalExecuted event. NOTE: Some modules can modify the requirements for execution, for example by adding an additional timelock.
function execute(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
external
payable
returns (uint256 proposalId);
cancel
Cancel a proposal. A proposal is cancellable by the proposer, but only while it is Pending state, i.e. before the vote starts. Emits a ProposalCanceled event.
function cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
external
returns (uint256 proposalId);
castVote
Cast a vote Emits a VoteCast event.
function castVote(uint256 proposalId, uint8 support) external returns (uint256 balance);
castVoteWithReason
Cast a vote with a reason Emits a VoteCast event.
function castVoteWithReason(uint256 proposalId, uint8 support, string calldata reason)
external
returns (uint256 balance);
castVoteWithReasonAndParams
Cast a vote with a reason and additional encoded parameters Emits a VoteCast or {VoteCastWithParams} event depending on the length of params.
function castVoteWithReasonAndParams(uint256 proposalId, uint8 support, string calldata reason, bytes memory params)
external
returns (uint256 balance);
castVoteBySig
Cast a vote using the voter's signature, including ERC-1271 signature support. Emits a VoteCast event.
function castVoteBySig(uint256 proposalId, uint8 support, address voter, bytes memory signature)
external
returns (uint256 balance);
castVoteWithReasonAndParamsBySig
Cast a vote with a reason and additional encoded parameters using the voter's signature, including ERC-1271 signature support. Emits a VoteCast or {VoteCastWithParams} event depending on the length of params.
function castVoteWithReasonAndParamsBySig(
uint256 proposalId,
uint8 support,
address voter,
string calldata reason,
bytes memory params,
bytes memory signature
) external returns (uint256 balance);
Events
ProposalCreated
Emitted when a proposal is created.
event ProposalCreated(
uint256 proposalId,
address proposer,
address[] targets,
uint256[] values,
string[] signatures,
bytes[] calldatas,
uint256 voteStart,
uint256 voteEnd,
string description
);
ProposalQueued
Emitted when a proposal is queued.
event ProposalQueued(uint256 proposalId, uint256 etaSeconds);
ProposalExecuted
Emitted when a proposal is executed.
event ProposalExecuted(uint256 proposalId);
ProposalCanceled
Emitted when a proposal is canceled.
event ProposalCanceled(uint256 proposalId);
VoteCast
Emitted when a vote is cast without params.
Note: support values should be seen as buckets. Their interpretation depends on the voting module used.
event VoteCast(address indexed voter, uint256 proposalId, uint8 support, uint256 weight, string reason);
VoteCastWithParams
Emitted when a vote is cast with params.
Note: support values should be seen as buckets. Their interpretation depends on the voting module used.
params are additional encoded parameters. Their interpretation also depends on the voting module used.
event VoteCastWithParams(
address indexed voter, uint256 proposalId, uint8 support, uint256 weight, string reason, bytes params
);
Errors
GovernorInvalidProposalLength
Empty proposal or a mismatch between the parameters length for a proposal call.
error GovernorInvalidProposalLength(uint256 targets, uint256 calldatas, uint256 values);
GovernorAlreadyCastVote
The vote was already cast.
error GovernorAlreadyCastVote(address voter);
GovernorDisabledDeposit
Token deposits are disabled in this contract.
error GovernorDisabledDeposit();
GovernorOnlyExecutor
The account is not the governance executor.
error GovernorOnlyExecutor(address account);
GovernorNonexistentProposal
The proposalId doesn't exist.
error GovernorNonexistentProposal(uint256 proposalId);
GovernorUnexpectedProposalState
The current state of a proposal is not the required for performing an operation.
The expectedStates is a bitmap with the bits enabled for each ProposalState enum position
counting from right to left.
NOTE: If expectedState is bytes32(0), the proposal is expected to not be in any state (i.e. not exist).
This is the case when a proposal that is expected to be unset is already initiated (the proposal is duplicated).
See Governor-_encodeStateBitmap.
error GovernorUnexpectedProposalState(uint256 proposalId, ProposalState current, bytes32 expectedStates);
GovernorInvalidVotingPeriod
The voting period set is not a valid period.
error GovernorInvalidVotingPeriod(uint256 votingPeriod);
GovernorInsufficientProposerVotes
The proposer does not have the required votes to create a proposal.
error GovernorInsufficientProposerVotes(address proposer, uint256 votes, uint256 threshold);
GovernorRestrictedProposer
The proposer is not allowed to create a proposal.
error GovernorRestrictedProposer(address proposer);
GovernorInvalidVoteType
The vote type used is not valid for the corresponding counting module.
error GovernorInvalidVoteType();
GovernorInvalidVoteParams
The provided params buffer is not supported by the counting module.
error GovernorInvalidVoteParams();
GovernorQueueNotImplemented
Queue operation is not implemented for this governor. Execute should be called directly.
error GovernorQueueNotImplemented();
GovernorNotQueuedProposal
The proposal hasn't been queued yet.
error GovernorNotQueuedProposal(uint256 proposalId);
GovernorAlreadyQueuedProposal
The proposal has already been queued.
error GovernorAlreadyQueuedProposal(uint256 proposalId);
GovernorInvalidSignature
The provided signature is not valid for the expected voter.
If the voter is a contract, the signature is not valid using IERC1271-isValidSignature.
error GovernorInvalidSignature(address voter);
GovernorUnableToCancel
The given account is unable to cancel the proposal with given proposalId.
error GovernorUnableToCancel(uint256 proposalId, address account);
Enums
ProposalState
enum ProposalState {
Pending,
Active,
Canceled,
Defeated,
Succeeded,
Queued,
Expired,
Executed
}
TimelockController
Inherits: AccessControl, ERC721Holder, ERC1155Holder
Contract module which acts as a timelocked controller. When set as the
owner of an Ownable smart contract, it enforces a timelock on all
onlyOwner maintenance operations. This gives time for users of the
controlled contract to exit before a potentially dangerous maintenance
operation is applied.
By default, this contract is self administered, meaning administration tasks
have to go through the timelock process. The proposer (resp executor) role
is in charge of proposing (resp executing) operations. A common use case is
to position this TimelockController as the owner of a smart contract, with
a multisig or a DAO as the sole proposer.
State Variables
PROPOSER_ROLE
bytes32 public constant PROPOSER_ROLE = keccak256("PROPOSER_ROLE");
EXECUTOR_ROLE
bytes32 public constant EXECUTOR_ROLE = keccak256("EXECUTOR_ROLE");
CANCELLER_ROLE
bytes32 public constant CANCELLER_ROLE = keccak256("CANCELLER_ROLE");
_DONE_TIMESTAMP
uint256 internal constant _DONE_TIMESTAMP = uint256(1);
_timestamps
mapping(bytes32 id => uint256) private _timestamps;
_minDelay
uint256 private _minDelay;
Functions
constructor
*Initializes the contract with the following parameters:
minDelay: initial minimum delay in seconds for operationsproposers: accounts to be granted proposer and canceller rolesexecutors: accounts to be granted executor roleadmin: optional account to be granted admin role; disable with zero address IMPORTANT: The optional admin can aid with initial configuration of roles after deployment without being subject to delay, but this role should be subsequently renounced in favor of administration through timelocked proposals. Previous versions of this contract would assign this admin to the deployer automatically and should be renounced as well.*
constructor(uint256 minDelay, address[] memory proposers, address[] memory executors, address admin);
onlyRoleOrOpenRole
Modifier to make a function callable only by a certain role. In
addition to checking the sender's role, address(0) 's role is also
considered. Granting a role to address(0) is equivalent to enabling
this role for everyone.
modifier onlyRoleOrOpenRole(bytes32 role);
receive
Contract might receive/hold ETH as part of the maintenance process.
receive() external payable virtual;
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(AccessControl, ERC1155Holder)
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
isOperation
Returns whether an id corresponds to a registered operation. This includes both Waiting, Ready, and Done operations.
function isOperation(bytes32 id) public view returns (bool);
isOperationPending
Returns whether an operation is pending or not. Note that a "pending" operation may also be "ready".
function isOperationPending(bytes32 id) public view returns (bool);
isOperationReady
Returns whether an operation is ready for execution. Note that a "ready" operation is also "pending".
function isOperationReady(bytes32 id) public view returns (bool);
isOperationDone
Returns whether an operation is done or not.
function isOperationDone(bytes32 id) public view returns (bool);
getTimestamp
Returns the timestamp at which an operation becomes ready (0 for unset operations, 1 for done operations).
function getTimestamp(bytes32 id) public view virtual returns (uint256);
getOperationState
Returns operation state.
function getOperationState(bytes32 id) public view virtual returns (OperationState);
getMinDelay
Returns the minimum delay in seconds for an operation to become valid.
This value can be changed by executing an operation that calls updateDelay.
function getMinDelay() public view virtual returns (uint256);
hashOperation
Returns the identifier of an operation containing a single transaction.
function hashOperation(address target, uint256 value, bytes calldata data, bytes32 predecessor, bytes32 salt)
public
pure
virtual
returns (bytes32);
hashOperationBatch
Returns the identifier of an operation containing a batch of transactions.
function hashOperationBatch(
address[] calldata targets,
uint256[] calldata values,
bytes[] calldata payloads,
bytes32 predecessor,
bytes32 salt
) public pure virtual returns (bytes32);
schedule
*Schedule an operation containing a single transaction. Emits CallSalt if salt is nonzero, and {CallScheduled}. Requirements:
- the caller must have the 'proposer' role.*
function schedule(address target, uint256 value, bytes calldata data, bytes32 predecessor, bytes32 salt, uint256 delay)
public
virtual
onlyRole(PROPOSER_ROLE);
scheduleBatch
*Schedule an operation containing a batch of transactions. Emits CallSalt if salt is nonzero, and one {CallScheduled} event per transaction in the batch. Requirements:
- the caller must have the 'proposer' role.*
function scheduleBatch(
address[] calldata targets,
uint256[] calldata values,
bytes[] calldata payloads,
bytes32 predecessor,
bytes32 salt,
uint256 delay
) public virtual onlyRole(PROPOSER_ROLE);
_schedule
Schedule an operation that is to become valid after a given delay.
function _schedule(bytes32 id, uint256 delay) private;
cancel
*Cancel an operation. Requirements:
- the caller must have the 'canceller' role.*
function cancel(bytes32 id) public virtual onlyRole(CANCELLER_ROLE);
execute
*Execute an (ready) operation containing a single transaction. Emits a CallExecuted event. Requirements:
- the caller must have the 'executor' role.*
function execute(address target, uint256 value, bytes calldata payload, bytes32 predecessor, bytes32 salt)
public
payable
virtual
onlyRoleOrOpenRole(EXECUTOR_ROLE);
executeBatch
*Execute an (ready) operation containing a batch of transactions. Emits one CallExecuted event per transaction in the batch. Requirements:
- the caller must have the 'executor' role.*
function executeBatch(
address[] calldata targets,
uint256[] calldata values,
bytes[] calldata payloads,
bytes32 predecessor,
bytes32 salt
) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE);
_execute
Execute an operation's call.
function _execute(address target, uint256 value, bytes calldata data) internal virtual;
_beforeCall
Checks before execution of an operation's calls.
function _beforeCall(bytes32 id, bytes32 predecessor) private view;
_afterCall
Checks after execution of an operation's calls.
function _afterCall(bytes32 id) private;
updateDelay
*Changes the minimum timelock duration for future operations. Emits a MinDelayChange event. Requirements:
- the caller must be the timelock itself. This can only be achieved by scheduling and later executing an operation where the timelock is the target and the data is the ABI-encoded call to this function.*
function updateDelay(uint256 newDelay) external virtual;
_encodeStateBitmap
Encodes a OperationState into a bytes32 representation where each bit enabled corresponds to
the underlying position in the OperationState enum. For example:
0x000...1000
^^^^^^----- ...
^---- Done
^--- Ready
^-- Waiting
^- Unset
function _encodeStateBitmap(OperationState operationState) internal pure returns (bytes32);
Events
CallScheduled
Emitted when a call is scheduled as part of operation id.
event CallScheduled(
bytes32 indexed id,
uint256 indexed index,
address target,
uint256 value,
bytes data,
bytes32 predecessor,
uint256 delay
);
CallExecuted
Emitted when a call is performed as part of operation id.
event CallExecuted(bytes32 indexed id, uint256 indexed index, address target, uint256 value, bytes data);
CallSalt
Emitted when new proposal is scheduled with non-zero salt.
event CallSalt(bytes32 indexed id, bytes32 salt);
Cancelled
Emitted when operation id is cancelled.
event Cancelled(bytes32 indexed id);
MinDelayChange
Emitted when the minimum delay for future operations is modified.
event MinDelayChange(uint256 oldDuration, uint256 newDuration);
Errors
TimelockInvalidOperationLength
Mismatch between the parameters length for an operation call.
error TimelockInvalidOperationLength(uint256 targets, uint256 payloads, uint256 values);
TimelockInsufficientDelay
The schedule operation doesn't meet the minimum delay.
error TimelockInsufficientDelay(uint256 delay, uint256 minDelay);
TimelockUnexpectedOperationState
The current state of an operation is not as required.
The expectedStates is a bitmap with the bits enabled for each OperationState enum position
counting from right to left.
See _encodeStateBitmap.
error TimelockUnexpectedOperationState(bytes32 operationId, bytes32 expectedStates);
TimelockUnexecutedPredecessor
The predecessor to an operation not yet done.
error TimelockUnexecutedPredecessor(bytes32 predecessorId);
TimelockUnauthorizedCaller
The caller account is not authorized.
error TimelockUnauthorizedCaller(address caller);
Enums
OperationState
enum OperationState {
Unset,
Waiting,
Ready,
Done
}
Contents
- IERC1271
- IERC1363
- IERC1363Receiver
- IERC1363Spender
- IERC1820Implementer
- IERC1820Registry
- IERC1967
- IERC2309
- IERC2612
- IERC2981
- IERC3156FlashBorrower
- IERC3156FlashLender
- IERC4626
- IERC4906
- IERC5267
- IERC5313
- IERC5805
- IERC6372
- IERC777
- IERC777Recipient
- IERC777Sender
- IERC7913SignatureVerifier
- IERC1822Proxiable
- PackedUserOperation
- IAggregator
- IEntryPointNonces
- IEntryPointStake
- IEntryPoint
- IAccount
- IAccountExecute
- IPaymaster
- IERC20Errors
- IERC721Errors
- IERC1155Errors
- IERC6909
- IERC6909Metadata
- IERC6909ContentURI
- IERC6909TokenSupply
- IERC7579Module
- IERC7579Validator
- IERC7579Hook
- Execution
- IERC7579Execution
- IERC7579AccountConfig
- IERC7579ModuleConfig
- draft-IERC7579 constants
- IERC7674
- IERC7802
- IERC7821
IERC1271
Interface of the ERC-1271 standard signature validation method for contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].
Functions
isValidSignature
Should return whether the signature provided is valid for the provided data
function isValidSignature(bytes32 hash, bytes calldata signature) external view returns (bytes4 magicValue);
Parameters
| Name | Type | Description |
|---|---|---|
hash | bytes32 | Hash of the data to be signed |
signature | bytes | Signature byte array associated with hash |
IERC1363
Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
after transfer or transferFrom, or code on a spender contract after approve, in a single transaction.
Functions
transferAndCall
Moves a value amount of tokens from the caller's account to to
and then calls {IERC1363Receiver-onTransferReceived} on to.
function transferAndCall(address to, uint256 value) external returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
to | address | The address which you want to transfer to. |
value | uint256 | The amount of tokens to be transferred. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | A boolean value indicating whether the operation succeeded unless throwing. |
transferAndCall
Moves a value amount of tokens from the caller's account to to
and then calls {IERC1363Receiver-onTransferReceived} on to.
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
to | address | The address which you want to transfer to. |
value | uint256 | The amount of tokens to be transferred. |
data | bytes | Additional data with no specified format, sent in call to to. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | A boolean value indicating whether the operation succeeded unless throwing. |
transferFromAndCall
Moves a value amount of tokens from from to to using the allowance mechanism
and then calls {IERC1363Receiver-onTransferReceived} on to.
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
from | address | The address which you want to send tokens from. |
to | address | The address which you want to transfer to. |
value | uint256 | The amount of tokens to be transferred. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | A boolean value indicating whether the operation succeeded unless throwing. |
transferFromAndCall
Moves a value amount of tokens from from to to using the allowance mechanism
and then calls {IERC1363Receiver-onTransferReceived} on to.
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
from | address | The address which you want to send tokens from. |
to | address | The address which you want to transfer to. |
value | uint256 | The amount of tokens to be transferred. |
data | bytes | Additional data with no specified format, sent in call to to. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | A boolean value indicating whether the operation succeeded unless throwing. |
approveAndCall
Sets a value amount of tokens as the allowance of spender over the
caller's tokens and then calls IERC1363Spender-onApprovalReceived on spender.
function approveAndCall(address spender, uint256 value) external returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
spender | address | The address which will spend the funds. |
value | uint256 | The amount of tokens to be spent. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | A boolean value indicating whether the operation succeeded unless throwing. |
approveAndCall
Sets a value amount of tokens as the allowance of spender over the
caller's tokens and then calls IERC1363Spender-onApprovalReceived on spender.
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
spender | address | The address which will spend the funds. |
value | uint256 | The amount of tokens to be spent. |
data | bytes | Additional data with no specified format, sent in call to spender. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | A boolean value indicating whether the operation succeeded unless throwing. |
IERC1363Receiver
Interface for any contract that wants to support transferAndCall or transferFromAndCall
from ERC-1363 token contracts.
Functions
onTransferReceived
Whenever ERC-1363 tokens are transferred to this contract via transferAndCall or transferFromAndCall
by operator from from, this function is called.
NOTE: To accept the transfer, this must return
bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))
(i.e. 0x88a7ca5c, or its own function selector).
function onTransferReceived(address operator, address from, uint256 value, bytes calldata data)
external
returns (bytes4);
Parameters
| Name | Type | Description |
|---|---|---|
operator | address | The address which called transferAndCall or transferFromAndCall function. |
from | address | The address which the tokens are transferred from. |
value | uint256 | The amount of tokens transferred. |
data | bytes | Additional data with no specified format. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes4 | bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)")) if transfer is allowed unless throwing. |
IERC1363Spender
Interface for any contract that wants to support approveAndCall
from ERC-1363 token contracts.
Functions
onApprovalReceived
Whenever an ERC-1363 token owner approves this contract via approveAndCall
to spend their tokens, this function is called.
NOTE: To accept the approval, this must return
bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))
(i.e. 0x7b04a2d0, or its own function selector).
function onApprovalReceived(address owner, uint256 value, bytes calldata data) external returns (bytes4);
Parameters
| Name | Type | Description |
|---|---|---|
owner | address | The address which called approveAndCall function and previously owned the tokens. |
value | uint256 | The amount of tokens to be spent. |
data | bytes | Additional data with no specified format. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes4 | bytes4(keccak256("onApprovalReceived(address,uint256,bytes)")) if approval is allowed unless throwing. |
IERC1820Implementer
Interface for an ERC-1820 implementer, as defined in the https://eips.ethereum.org/EIPS/eip-1820#interface-implementation-erc1820implementerinterface[ERC]. Used by contracts that will be registered as implementers in the {IERC1820Registry}.
Functions
canImplementInterfaceForAddress
Returns a special value (ERC1820_ACCEPT_MAGIC) if this contract
implements interfaceHash for account.
See IERC1820Registry-setInterfaceImplementer.
function canImplementInterfaceForAddress(bytes32 interfaceHash, address account) external view returns (bytes32);
IERC1820Registry
Interface of the global ERC-1820 Registry, as defined in the https://eips.ethereum.org/EIPS/eip-1820[ERC]. Accounts may register implementers for interfaces in this registry, as well as query support. Implementers may be shared by multiple accounts, and can also implement more than a single interface for each account. Contracts can implement interfaces for themselves, but externally-owned accounts (EOA) must delegate this to a contract. {IERC165} interfaces can also be queried via the registry. For an in-depth explanation and source code analysis, see the ERC text.
Functions
setManager
*Sets newManager as the manager for account. A manager of an
account is able to set interface implementers for it.
By default, each account is its own manager. Passing a value of 0x0 in
newManager will reset the manager to this initial state.
Emits a ManagerChanged event.
Requirements:
- the caller must be the current manager for
account.*
function setManager(address account, address newManager) external;
getManager
Returns the manager for account.
See setManager.
function getManager(address account) external view returns (address);
setInterfaceImplementer
*Sets the implementer contract as account's implementer for
interfaceHash.
account being the zero address is an alias for the caller's address.
The zero address can also be used in implementer to remove an old one.
See interfaceHash to learn how these are created.
Emits an {InterfaceImplementerSet} event.
Requirements:
- the caller must be the current manager for
account. interfaceHashmust not be an {IERC165} interface id (i.e. it must not end in 28 zeroes).implementermust implement {IERC1820Implementer} and return true when queried for support, unlessimplementeris the caller. See {IERC1820Implementer-canImplementInterfaceForAddress}.*
function setInterfaceImplementer(address account, bytes32 _interfaceHash, address implementer) external;
getInterfaceImplementer
Returns the implementer of interfaceHash for account. If no such
implementer is registered, returns the zero address.
If interfaceHash is an {IERC165} interface id (i.e. it ends with 28
zeroes), account will be queried for support of it.
account being the zero address is an alias for the caller's address.
function getInterfaceImplementer(address account, bytes32 _interfaceHash) external view returns (address);
interfaceHash
Returns the interface hash for an interfaceName, as defined in the
corresponding
https://eips.ethereum.org/EIPS/eip-1820#interface-name[section of the ERC].
function interfaceHash(string calldata interfaceName) external pure returns (bytes32);
updateERC165Cache
Updates the cache with whether the contract implements an ERC-165 interface or not.
function updateERC165Cache(address account, bytes4 interfaceId) external;
Parameters
| Name | Type | Description |
|---|---|---|
account | address | Address of the contract for which to update the cache. |
interfaceId | bytes4 | ERC-165 interface for which to update the cache. |
implementsERC165Interface
Checks whether a contract implements an ERC-165 interface or not. If the result is not cached a direct lookup on the contract address is performed. If the result is not cached or the cached value is out-of-date, the cache MUST be updated manually by calling updateERC165Cache with the contract address.
function implementsERC165Interface(address account, bytes4 interfaceId) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
account | address | Address of the contract to check. |
interfaceId | bytes4 | ERC-165 interface to check. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if account implements interfaceId, false otherwise. |
implementsERC165InterfaceNoCache
Checks whether a contract implements an ERC-165 interface or not without using or updating the cache.
function implementsERC165InterfaceNoCache(address account, bytes4 interfaceId) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
account | address | Address of the contract to check. |
interfaceId | bytes4 | ERC-165 interface to check. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if account implements interfaceId, false otherwise. |
Events
InterfaceImplementerSet
event InterfaceImplementerSet(address indexed account, bytes32 indexed interfaceHash, address indexed implementer);
ManagerChanged
event ManagerChanged(address indexed account, address indexed newManager);
IERC1967
ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
Events
Upgraded
Emitted when the implementation is upgraded.
event Upgraded(address indexed implementation);
AdminChanged
Emitted when the admin account has changed.
event AdminChanged(address previousAdmin, address newAdmin);
BeaconUpgraded
Emitted when the beacon is changed.
event BeaconUpgraded(address indexed beacon);
IERC2309
ERC-2309: ERC-721 Consecutive Transfer Extension.
Events
ConsecutiveTransfer
Emitted when the tokens from fromTokenId to toTokenId are transferred from fromAddress to toAddress.
event ConsecutiveTransfer(
uint256 indexed fromTokenId, uint256 toTokenId, address indexed fromAddress, address indexed toAddress
);
IERC2612
Inherits: IERC20Permit
IERC2981
Inherits: IERC165
Interface for the NFT Royalty Standard. A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal support for royalty payments across all NFT marketplaces and ecosystem participants.
Functions
royaltyInfo
Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of exchange. The royalty amount is denominated and should be paid in that same unit of exchange. NOTE: ERC-2981 allows setting the royalty to 100% of the price. In that case all the price would be sent to the royalty receiver and 0 tokens to the seller. Contracts dealing with royalty should consider empty transfers.
function royaltyInfo(uint256 tokenId, uint256 salePrice)
external
view
returns (address receiver, uint256 royaltyAmount);
IERC3156FlashBorrower
Interface of the ERC-3156 FlashBorrower, as defined in https://eips.ethereum.org/EIPS/eip-3156[ERC-3156].
Functions
onFlashLoan
Receive a flash loan.
function onFlashLoan(address initiator, address token, uint256 amount, uint256 fee, bytes calldata data)
external
returns (bytes32);
Parameters
| Name | Type | Description |
|---|---|---|
initiator | address | The initiator of the loan. |
token | address | The loan currency. |
amount | uint256 | The amount of tokens lent. |
fee | uint256 | The additional amount of tokens to repay. |
data | bytes | Arbitrary data structure, intended to contain user-defined parameters. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes32 | The keccak256 hash of "ERC3156FlashBorrower.onFlashLoan" |
IERC3156FlashLender
Interface of the ERC-3156 FlashLender, as defined in https://eips.ethereum.org/EIPS/eip-3156[ERC-3156].
Functions
maxFlashLoan
The amount of currency available to be lended.
function maxFlashLoan(address token) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | The loan currency. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The amount of token that can be borrowed. |
flashFee
The fee to be charged for a given loan.
function flashFee(address token, uint256 amount) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | The loan currency. |
amount | uint256 | The amount of tokens lent. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The amount of token to be charged for the loan, on top of the returned principal. |
flashLoan
Initiate a flash loan.
function flashLoan(IERC3156FlashBorrower receiver, address token, uint256 amount, bytes calldata data)
external
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | IERC3156FlashBorrower | The receiver of the tokens in the loan, and the receiver of the callback. |
token | address | The loan currency. |
amount | uint256 | The amount of tokens lent. |
data | bytes | Arbitrary data structure, intended to contain user-defined parameters. |
IERC4626
Inherits: IERC20, IERC20Metadata
Interface of the ERC-4626 "Tokenized Vault Standard", as defined in https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].
Functions
asset
*Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.
- MUST be an ERC-20 token contract.
- MUST NOT revert.*
function asset() external view returns (address assetTokenAddress);
totalAssets
*Returns the total amount of the underlying asset that is “managed” by Vault.
- SHOULD include any compounding that occurs from yield.
- MUST be inclusive of any fees that are charged against assets in the Vault.
- MUST NOT revert.*
function totalAssets() external view returns (uint256 totalManagedAssets);
convertToShares
*Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal scenario where all the conditions are met.
- MUST NOT be inclusive of any fees that are charged against assets in the Vault.
- MUST NOT show any variations depending on the caller.
- MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
- MUST NOT revert. NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and from.*
function convertToShares(uint256 assets) external view returns (uint256 shares);
convertToAssets
*Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal scenario where all the conditions are met.
- MUST NOT be inclusive of any fees that are charged against assets in the Vault.
- MUST NOT show any variations depending on the caller.
- MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
- MUST NOT revert. NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and from.*
function convertToAssets(uint256 shares) external view returns (uint256 assets);
maxDeposit
*Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver, through a deposit call.
- MUST return a limited value if receiver is subject to some deposit limit.
- MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.
- MUST NOT revert.*
function maxDeposit(address receiver) external view returns (uint256 maxAssets);
previewDeposit
*Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given current on-chain conditions.
- MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called in the same transaction.
- MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the deposit would be accepted, regardless if the user has enough tokens approved, etc.
- MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
- MUST NOT revert. NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by depositing.*
function previewDeposit(uint256 assets) external view returns (uint256 shares);
deposit
*Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.
- MUST emit the Deposit event.
- MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the deposit execution, and are accounted for during deposit.
- MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not approving enough underlying tokens to the Vault contract, etc). NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.*
function deposit(uint256 assets, address receiver) external returns (uint256 shares);
maxMint
*Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.
- MUST return a limited value if receiver is subject to some mint limit.
- MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.
- MUST NOT revert.*
function maxMint(address receiver) external view returns (uint256 maxShares);
previewMint
*Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given current on-chain conditions.
- MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the same transaction.
- MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint would be accepted, regardless if the user has enough tokens approved, etc.
- MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
- MUST NOT revert. NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by minting.*
function previewMint(uint256 shares) external view returns (uint256 assets);
mint
*Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.
- MUST emit the Deposit event.
- MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint execution, and are accounted for during mint.
- MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not approving enough underlying tokens to the Vault contract, etc). NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.*
function mint(uint256 shares, address receiver) external returns (uint256 assets);
maxWithdraw
*Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the Vault, through a withdraw call.
- MUST return a limited value if owner is subject to some withdrawal limit or timelock.
- MUST NOT revert.*
function maxWithdraw(address owner) external view returns (uint256 maxAssets);
previewWithdraw
*Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block, given current on-chain conditions.
- MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if called in the same transaction.
- MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though the withdrawal would be accepted, regardless if the user has enough shares, etc.
- MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
- MUST NOT revert. NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by depositing.*
function previewWithdraw(uint256 assets) external view returns (uint256 shares);
withdraw
*Burns shares from owner and sends exactly assets of underlying tokens to receiver.
- MUST emit the Withdraw event.
- MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the withdraw execution, and are accounted for during withdraw.
- MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner not having enough shares, etc). Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed. Those methods should be performed separately.*
function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);
maxRedeem
*Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, through a redeem call.
- MUST return a limited value if owner is subject to some withdrawal limit or timelock.
- MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.
- MUST NOT revert.*
function maxRedeem(address owner) external view returns (uint256 maxShares);
previewRedeem
*Allows an on-chain or off-chain user to simulate the effects of their redemption at the current block, given current on-chain conditions.
- MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the same transaction.
- MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the redemption would be accepted, regardless if the user has enough shares, etc.
- MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
- MUST NOT revert. NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by redeeming.*
function previewRedeem(uint256 shares) external view returns (uint256 assets);
redeem
*Burns exactly shares from owner and sends assets of underlying tokens to receiver.
- MUST emit the Withdraw event.
- MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the redeem execution, and are accounted for during redeem.
- MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner not having enough shares, etc). NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed. Those methods should be performed separately.*
function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);
Events
Deposit
event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);
Withdraw
event Withdraw(address indexed sender, address indexed receiver, address indexed owner, uint256 assets, uint256 shares);
IERC4906
Events
MetadataUpdate
This event emits when the metadata of a token is changed. So that the third-party platforms such as NFT market could timely update the images and related attributes of the NFT.
event MetadataUpdate(uint256 _tokenId);
BatchMetadataUpdate
This event emits when the metadata of a range of tokens is changed. So that the third-party platforms such as NFT market could timely update the images and related attributes of the NFTs.
event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);
IERC5267
Functions
eip712Domain
returns the fields and values that describe the domain separator used by this contract for EIP-712 signature.
function eip712Domain()
external
view
returns (
bytes1 fields,
string memory name,
string memory version,
uint256 chainId,
address verifyingContract,
bytes32 salt,
uint256[] memory extensions
);
Events
EIP712DomainChanged
MAY be emitted to signal that the domain could have changed.
event EIP712DomainChanged();
IERC5313
Interface for the Light Contract Ownership Standard. A standardized minimal interface required to identify an account that controls a contract
Functions
owner
Gets the address of the owner.
function owner() external view returns (address);
IERC5805
IERC6372
Functions
clock
Clock used for flagging checkpoints. Can be overridden to implement timestamp based checkpoints (and voting).
function clock() external view returns (uint48);
CLOCK_MODE
Description of the clock
function CLOCK_MODE() external view returns (string memory);
IERC777
Interface of the ERC-777 Token standard as defined in the ERC. This contract uses the https://eips.ethereum.org/EIPS/eip-1820[ERC-1820 registry standard] to let token holders and recipients react to token movements by using setting implementers for the associated interfaces in said registry. See {IERC1820Registry} and {IERC1820Implementer}.
Functions
name
Returns the name of the token.
function name() external view returns (string memory);
symbol
Returns the symbol of the token, usually a shorter version of the name.
function symbol() external view returns (string memory);
granularity
Returns the smallest part of the token that is not divisible. This means all token operations (creation, movement and destruction) must have amounts that are a multiple of this number. For most token contracts, this value will equal 1.
function granularity() external view returns (uint256);
totalSupply
Returns the amount of tokens in existence.
function totalSupply() external view returns (uint256);
balanceOf
Returns the amount of tokens owned by an account (owner).
function balanceOf(address owner) external view returns (uint256);
send
*Moves amount tokens from the caller's account to recipient.
If send or receive hooks are registered for the caller and recipient,
the corresponding functions will be called with data and empty
operatorData. See {IERC777Sender} and {IERC777Recipient}.
Emits a {Sent} event.
Requirements
- the caller must have at least
amounttokens. recipientcannot be the zero address.- if
recipientis a contract, it must implement the {IERC777Recipient} interface.*
function send(address recipient, uint256 amount, bytes calldata data) external;
burn
*Destroys amount tokens from the caller's account, reducing the
total supply.
If a send hook is registered for the caller, the corresponding function
will be called with data and empty operatorData. See {IERC777Sender}.
Emits a {Burned} event.
Requirements
- the caller must have at least
amounttokens.*
function burn(uint256 amount, bytes calldata data) external;
isOperatorFor
Returns true if an account is an operator of tokenHolder.
Operators can send and burn tokens on behalf of their owners. All
accounts are their own operator.
See operatorSend and {operatorBurn}.
function isOperatorFor(address operator, address tokenHolder) external view returns (bool);
authorizeOperator
*Make an account an operator of the caller. See isOperatorFor. Emits an {AuthorizedOperator} event. Requirements
operatorcannot be calling address.*
function authorizeOperator(address operator) external;
revokeOperator
*Revoke an account's operator status for the caller. See isOperatorFor and {defaultOperators}. Emits a {RevokedOperator} event. Requirements
operatorcannot be calling address.*
function revokeOperator(address operator) external;
defaultOperators
Returns the list of default operators. These accounts are operators for all token holders, even if authorizeOperator was never called on them. This list is immutable, but individual holders may revoke these via {revokeOperator}, in which case {isOperatorFor} will return false.
function defaultOperators() external view returns (address[] memory);
operatorSend
*Moves amount tokens from sender to recipient. The caller must
be an operator of sender.
If send or receive hooks are registered for sender and recipient,
the corresponding functions will be called with data and
operatorData. See {IERC777Sender} and {IERC777Recipient}.
Emits a {Sent} event.
Requirements
sendercannot be the zero address.sendermust have at leastamounttokens.- the caller must be an operator for
sender. recipientcannot be the zero address.- if
recipientis a contract, it must implement the {IERC777Recipient} interface.*
function operatorSend(
address sender,
address recipient,
uint256 amount,
bytes calldata data,
bytes calldata operatorData
) external;
operatorBurn
*Destroys amount tokens from account, reducing the total supply.
The caller must be an operator of account.
If a send hook is registered for account, the corresponding function
will be called with data and operatorData. See {IERC777Sender}.
Emits a {Burned} event.
Requirements
accountcannot be the zero address.accountmust have at leastamounttokens.- the caller must be an operator for
account.*
function operatorBurn(address account, uint256 amount, bytes calldata data, bytes calldata operatorData) external;
Events
Minted
Emitted when amount tokens are created by operator and assigned to to.
Note that some additional user data and operatorData can be logged in the event.
event Minted(address indexed operator, address indexed to, uint256 amount, bytes data, bytes operatorData);
Burned
Emitted when operator destroys amount tokens from account.
Note that some additional user data and operatorData can be logged in the event.
event Burned(address indexed operator, address indexed from, uint256 amount, bytes data, bytes operatorData);
AuthorizedOperator
Emitted when operator is made operator for tokenHolder.
event AuthorizedOperator(address indexed operator, address indexed tokenHolder);
RevokedOperator
Emitted when operator is revoked its operator status for tokenHolder.
event RevokedOperator(address indexed operator, address indexed tokenHolder);
Sent
event Sent(
address indexed operator, address indexed from, address indexed to, uint256 amount, bytes data, bytes operatorData
);
IERC777Recipient
Interface of the ERC-777 Tokens Recipient standard as defined in the ERC. Accounts can be notified of {IERC777} tokens being sent to them by having a contract implement this interface (contract holders can be their own implementer) and registering it on the https://eips.ethereum.org/EIPS/eip-1820[ERC-1820 global registry]. See {IERC1820Registry} and {IERC1820Implementer}.
Functions
tokensReceived
Called by an {IERC777} token contract whenever tokens are being
moved or created into a registered account (to). The type of operation
is conveyed by from being the zero address or not.
This call occurs after the token contract's state is updated, so
{IERC777-balanceOf}, etc., can be used to query the post-operation state.
This function may revert to prevent the operation from being executed.
function tokensReceived(
address operator,
address from,
address to,
uint256 amount,
bytes calldata userData,
bytes calldata operatorData
) external;
IERC777Sender
Interface of the ERC-777 Tokens Sender standard as defined in the ERC. {IERC777} Token holders can be notified of operations performed on their tokens by having a contract implement this interface (contract holders can be their own implementer) and registering it on the https://eips.ethereum.org/EIPS/eip-1820[ERC-1820 global registry]. See {IERC1820Registry} and {IERC1820Implementer}.
Functions
tokensToSend
Called by an {IERC777} token contract whenever a registered holder's
(from) tokens are about to be moved or destroyed. The type of operation
is conveyed by to being the zero address or not.
This call occurs before the token contract's state is updated, so
{IERC777-balanceOf}, etc., can be used to query the pre-operation state.
This function may revert to prevent the operation from being executed.
function tokensToSend(
address operator,
address from,
address to,
uint256 amount,
bytes calldata userData,
bytes calldata operatorData
) external;
IERC7913SignatureVerifier
Signature verifier interface.
Functions
verify
Verifies signature as a valid signature of hash by key.
MUST return the bytes4 magic value IERC7913SignatureVerifier.verify.selector if the signature is valid.
SHOULD return 0xffffffff or revert if the signature is not valid.
SHOULD return 0xffffffff or revert if the key is empty
function verify(bytes calldata key, bytes32 hash, bytes calldata signature) external view returns (bytes4);
IERC1822Proxiable
ERC-1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified proxy whose upgrades are fully controlled by the current implementation.
Functions
proxiableUUID
Returns the storage slot that the proxiable contract assumes is being used to store the implementation address. IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this function revert if invoked through a proxy.
function proxiableUUID() external view returns (bytes32);
PackedUserOperation
*A https://github.com/ethereum/ercs/blob/master/ERCS/erc-4337.md#useroperation[user operation] is composed of the following elements:
sender(address): The account making the operationnonce(uint256): Anti-replay parameter (see “Semi-abstracted Nonce Support” )factory(address): account factory, only for new accountsfactoryData(bytes): data for account factory (only if account factory exists)callData(bytes): The data to pass to the sender during the main execution callcallGasLimit(uint256): The amount of gas to allocate the main execution callverificationGasLimit(uint256): The amount of gas to allocate for the verification steppreVerificationGas(uint256): Extra gas to pay the bundlermaxFeePerGas(uint256): Maximum fee per gas (similar to EIP-1559 max_fee_per_gas)maxPriorityFeePerGas(uint256): Maximum priority fee per gas (similar to EIP-1559 max_priority_fee_per_gas)paymaster(address): Address of paymaster contract, (or empty, if account pays for itself)paymasterVerificationGasLimit(uint256): The amount of gas to allocate for the paymaster validation codepaymasterPostOpGasLimit(uint256): The amount of gas to allocate for the paymaster post-operation codepaymasterData(bytes): Data for paymaster (only if paymaster exists)signature(bytes): Data passed into the account to verify authorization When passed to on-chain contracts, the following packed version is used.sender(address)nonce(uint256)initCode(bytes): concatenation of factory address and factoryData (or empty)callData(bytes)accountGasLimits(bytes32): concatenation of verificationGas (16 bytes) and callGas (16 bytes)preVerificationGas(uint256)gasFees(bytes32): concatenation of maxPriorityFeePerGas (16 bytes) and maxFeePerGas (16 bytes)paymasterAndData(bytes): concatenation of paymaster fields (or empty)signature(bytes)*
struct PackedUserOperation {
address sender;
uint256 nonce;
bytes initCode;
bytes callData;
bytes32 accountGasLimits;
uint256 preVerificationGas;
bytes32 gasFees;
bytes paymasterAndData;
bytes signature;
}
IAggregator
Aggregates and validates multiple signatures for a batch of user operations. A contract could implement this interface with custom validation schemes that allow signature aggregation, enabling significant optimizations and gas savings for execution and transaction data cost. Bundlers and clients whitelist supported aggregators. See https://eips.ethereum.org/EIPS/eip-7766[ERC-7766]
Functions
validateUserOpSignature
Validates the signature for a user operation. Returns an alternative signature that should be used during bundling.
function validateUserOpSignature(PackedUserOperation calldata userOp)
external
view
returns (bytes memory sigForUserOp);
aggregateSignatures
Returns an aggregated signature for a batch of user operation's signatures.
function aggregateSignatures(PackedUserOperation[] calldata userOps)
external
view
returns (bytes memory aggregatesSignature);
validateSignatures
*Validates that the aggregated signature is valid for the user operations. Requirements:
- The aggregated signature MUST match the given list of operations.*
function validateSignatures(PackedUserOperation[] calldata userOps, bytes calldata signature) external view;
IEntryPointNonces
Handle nonce management for accounts.
Nonces are used in accounts as a replay protection mechanism and to ensure the order of user operations.
To avoid limiting the number of operations an account can perform, the interface allows using parallel
nonces by using a key parameter.
See https://eips.ethereum.org/EIPS/eip-4337#semi-abstracted-nonce-support[ERC-4337 semi-abstracted nonce support].
Functions
getNonce
Returns the nonce for a sender account and a key.
Nonces for a certain key are always increasing.
function getNonce(address sender, uint192 key) external view returns (uint256 nonce);
IEntryPointStake
Handle stake management for entities (i.e. accounts, paymasters, factories). The EntryPoint must implement the following API to let entities like paymasters have a stake, and thus have more flexibility in their storage access (see https://eips.ethereum.org/EIPS/eip-4337#reputation-scoring-and-throttlingbanning-for-global-entities[reputation, throttling and banning.])
Functions
balanceOf
Returns the balance of the account.
function balanceOf(address account) external view returns (uint256);
depositTo
Deposits msg.value to the account.
function depositTo(address account) external payable;
withdrawTo
Withdraws withdrawAmount from the account to withdrawAddress.
function withdrawTo(address payable withdrawAddress, uint256 withdrawAmount) external;
addStake
Adds stake to the account with an unstake delay of unstakeDelaySec.
function addStake(uint32 unstakeDelaySec) external payable;
unlockStake
Unlocks the stake of the account.
function unlockStake() external;
withdrawStake
Withdraws the stake of the account to withdrawAddress.
function withdrawStake(address payable withdrawAddress) external;
IEntryPoint
Inherits: IEntryPointNonces, IEntryPointStake
Entry point for user operations. User operations are validated and executed by this contract.
Functions
handleOps
Executes a batch of user operations.
function handleOps(PackedUserOperation[] calldata ops, address payable beneficiary) external;
Parameters
| Name | Type | Description |
|---|---|---|
ops | PackedUserOperation[] | |
beneficiary | address payable | Address to which gas is refunded upon completing the execution. |
handleAggregatedOps
Executes a batch of aggregated user operations per aggregator.
function handleAggregatedOps(UserOpsPerAggregator[] calldata opsPerAggregator, address payable beneficiary) external;
Parameters
| Name | Type | Description |
|---|---|---|
opsPerAggregator | UserOpsPerAggregator[] | |
beneficiary | address payable | Address to which gas is refunded upon completing the execution. |
Errors
FailedOp
A user operation at opIndex failed with reason.
error FailedOp(uint256 opIndex, string reason);
FailedOpWithRevert
A user operation at opIndex failed with reason and inner returned data.
error FailedOpWithRevert(uint256 opIndex, string reason, bytes inner);
Structs
UserOpsPerAggregator
Batch of aggregated user operations per aggregator.
struct UserOpsPerAggregator {
PackedUserOperation[] userOps;
IAggregator aggregator;
bytes signature;
}
IAccount
Base interface for an ERC-4337 account.
Functions
validateUserOp
*Validates a user operation. MUST validate the caller is a trusted EntryPoint MUST validate that the signature is a valid signature of the userOpHash, and SHOULD return SIG_VALIDATION_FAILED (and not revert) on signature mismatch. Any other error MUST revert. MUST pay the entryPoint (caller) at least the “missingAccountFunds” (which might be zero, in case the current account’s deposit is high enough) Returns an encoded packed validation data that is composed of the following elements:
authorizer(address): 0 for success, 1 for failure, otherwise the address of an authorizer contractvalidUntil(uint48): The UserOp is valid only up to this time. Zero for “infinite”.validAfter(uint48): The UserOp is valid only after this time.*
function validateUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash, uint256 missingAccountFunds)
external
returns (uint256 validationData);
IAccountExecute
Support for executing user operations by prepending the executeUserOp function selector
to the UserOperation's callData.
Functions
executeUserOp
Executes a user operation.
function executeUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash) external;
IPaymaster
Interface for a paymaster contract that agrees to pay for the gas costs of a user operation. NOTE: A paymaster must hold a stake to cover the required entrypoint stake and also the gas for the transaction.
Functions
validatePaymasterUserOp
Validates whether the paymaster is willing to pay for the user operation. See IAccount-validateUserOp for additional information on the return value. NOTE: Bundlers will reject this method if it modifies the state, unless it's whitelisted.
function validatePaymasterUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash, uint256 maxCost)
external
returns (bytes memory context, uint256 validationData);
postOp
Verifies the sender is the entrypoint.
function postOp(PostOpMode mode, bytes calldata context, uint256 actualGasCost, uint256 actualUserOpFeePerGas)
external;
Parameters
| Name | Type | Description |
|---|---|---|
mode | PostOpMode | |
context | bytes | |
actualGasCost | uint256 | the actual amount paid (by account or paymaster) for this UserOperation |
actualUserOpFeePerGas | uint256 | total gas used by this UserOperation (including preVerification, creation, validation and execution) |
Enums
PostOpMode
enum PostOpMode {
opSucceeded,
opReverted,
postOpReverted
}
IERC20Errors
Standard ERC-20 Errors Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
Errors
ERC20InsufficientBalance
Indicates an error related to the current balance of a sender. Used in transfers.
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
Parameters
| Name | Type | Description |
|---|---|---|
sender | address | Address whose tokens are being transferred. |
balance | uint256 | Current balance for the interacting account. |
needed | uint256 | Minimum amount required to perform a transfer. |
ERC20InvalidSender
Indicates a failure with the token sender. Used in transfers.
error ERC20InvalidSender(address sender);
Parameters
| Name | Type | Description |
|---|---|---|
sender | address | Address whose tokens are being transferred. |
ERC20InvalidReceiver
Indicates a failure with the token receiver. Used in transfers.
error ERC20InvalidReceiver(address receiver);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | Address to which tokens are being transferred. |
ERC20InsufficientAllowance
Indicates a failure with the spender’s allowance. Used in transfers.
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
Parameters
| Name | Type | Description |
|---|---|---|
spender | address | Address that may be allowed to operate on tokens without being their owner. |
allowance | uint256 | Amount of tokens a spender is allowed to operate with. |
needed | uint256 | Minimum amount required to perform a transfer. |
ERC20InvalidApprover
Indicates a failure with the approver of a token to be approved. Used in approvals.
error ERC20InvalidApprover(address approver);
Parameters
| Name | Type | Description |
|---|---|---|
approver | address | Address initiating an approval operation. |
ERC20InvalidSpender
Indicates a failure with the spender to be approved. Used in approvals.
error ERC20InvalidSpender(address spender);
Parameters
| Name | Type | Description |
|---|---|---|
spender | address | Address that may be allowed to operate on tokens without being their owner. |
IERC721Errors
Standard ERC-721 Errors Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
Errors
ERC721InvalidOwner
Indicates that an address can't be an owner. For example, address(0) is a forbidden owner in ERC-20.
Used in balance queries.
error ERC721InvalidOwner(address owner);
Parameters
| Name | Type | Description |
|---|---|---|
owner | address | Address of the current owner of a token. |
ERC721NonexistentToken
Indicates a tokenId whose owner is the zero address.
error ERC721NonexistentToken(uint256 tokenId);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | Identifier number of a token. |
ERC721IncorrectOwner
Indicates an error related to the ownership over a particular token. Used in transfers.
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
Parameters
| Name | Type | Description |
|---|---|---|
sender | address | Address whose tokens are being transferred. |
tokenId | uint256 | Identifier number of a token. |
owner | address | Address of the current owner of a token. |
ERC721InvalidSender
Indicates a failure with the token sender. Used in transfers.
error ERC721InvalidSender(address sender);
Parameters
| Name | Type | Description |
|---|---|---|
sender | address | Address whose tokens are being transferred. |
ERC721InvalidReceiver
Indicates a failure with the token receiver. Used in transfers.
error ERC721InvalidReceiver(address receiver);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | Address to which tokens are being transferred. |
ERC721InsufficientApproval
Indicates a failure with the operator’s approval. Used in transfers.
error ERC721InsufficientApproval(address operator, uint256 tokenId);
Parameters
| Name | Type | Description |
|---|---|---|
operator | address | Address that may be allowed to operate on tokens without being their owner. |
tokenId | uint256 | Identifier number of a token. |
ERC721InvalidApprover
Indicates a failure with the approver of a token to be approved. Used in approvals.
error ERC721InvalidApprover(address approver);
Parameters
| Name | Type | Description |
|---|---|---|
approver | address | Address initiating an approval operation. |
ERC721InvalidOperator
Indicates a failure with the operator to be approved. Used in approvals.
error ERC721InvalidOperator(address operator);
Parameters
| Name | Type | Description |
|---|---|---|
operator | address | Address that may be allowed to operate on tokens without being their owner. |
IERC1155Errors
Standard ERC-1155 Errors Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
Errors
ERC1155InsufficientBalance
Indicates an error related to the current balance of a sender. Used in transfers.
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
Parameters
| Name | Type | Description |
|---|---|---|
sender | address | Address whose tokens are being transferred. |
balance | uint256 | Current balance for the interacting account. |
needed | uint256 | Minimum amount required to perform a transfer. |
tokenId | uint256 | Identifier number of a token. |
ERC1155InvalidSender
Indicates a failure with the token sender. Used in transfers.
error ERC1155InvalidSender(address sender);
Parameters
| Name | Type | Description |
|---|---|---|
sender | address | Address whose tokens are being transferred. |
ERC1155InvalidReceiver
Indicates a failure with the token receiver. Used in transfers.
error ERC1155InvalidReceiver(address receiver);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | Address to which tokens are being transferred. |
ERC1155MissingApprovalForAll
Indicates a failure with the operator’s approval. Used in transfers.
error ERC1155MissingApprovalForAll(address operator, address owner);
Parameters
| Name | Type | Description |
|---|---|---|
operator | address | Address that may be allowed to operate on tokens without being their owner. |
owner | address | Address of the current owner of a token. |
ERC1155InvalidApprover
Indicates a failure with the approver of a token to be approved. Used in approvals.
error ERC1155InvalidApprover(address approver);
Parameters
| Name | Type | Description |
|---|---|---|
approver | address | Address initiating an approval operation. |
ERC1155InvalidOperator
Indicates a failure with the operator to be approved. Used in approvals.
error ERC1155InvalidOperator(address operator);
Parameters
| Name | Type | Description |
|---|---|---|
operator | address | Address that may be allowed to operate on tokens without being their owner. |
ERC1155InvalidArrayLength
Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. Used in batch transfers.
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
Parameters
| Name | Type | Description |
|---|---|---|
idsLength | uint256 | Length of the array of token identifiers |
valuesLength | uint256 | Length of the array of token amounts |
IERC6909
Inherits: IERC165
Required interface of an ERC-6909 compliant contract, as defined in the https://eips.ethereum.org/EIPS/eip-6909[ERC].
Functions
balanceOf
Returns the amount of tokens of type id owned by owner.
function balanceOf(address owner, uint256 id) external view returns (uint256);
allowance
Returns the amount of tokens of type id that spender is allowed to spend on behalf of owner.
NOTE: Does not include operator allowances.
function allowance(address owner, address spender, uint256 id) external view returns (uint256);
isOperator
Returns true if spender is set as an operator for owner.
function isOperator(address owner, address spender) external view returns (bool);
approve
Sets an approval to spender for amount of tokens of type id from the caller's tokens. An amount of
type(uint256).max signifies an unlimited approval.
Must return true.
function approve(address spender, uint256 id, uint256 amount) external returns (bool);
setOperator
Grants or revokes unlimited transfer permission of any token id to spender for the caller's tokens.
Must return true.
function setOperator(address spender, bool approved) external returns (bool);
transfer
Transfers amount of token type id from the caller's account to receiver.
Must return true.
function transfer(address receiver, uint256 id, uint256 amount) external returns (bool);
transferFrom
Transfers amount of token type id from sender to receiver.
Must return true.
function transferFrom(address sender, address receiver, uint256 id, uint256 amount) external returns (bool);
Events
Approval
Emitted when the allowance of a spender for an owner is set for a token of type id.
The new allowance is amount.
event Approval(address indexed owner, address indexed spender, uint256 indexed id, uint256 amount);
OperatorSet
Emitted when owner grants or revokes operator status for a spender.
event OperatorSet(address indexed owner, address indexed spender, bool approved);
Transfer
Emitted when amount tokens of type id are moved from sender to receiver initiated by caller.
event Transfer(address caller, address indexed sender, address indexed receiver, uint256 indexed id, uint256 amount);
IERC6909Metadata
Inherits: IERC6909
Optional extension of {IERC6909} that adds metadata functions.
Functions
name
Returns the name of the token of type id.
function name(uint256 id) external view returns (string memory);
symbol
Returns the ticker symbol of the token of type id.
function symbol(uint256 id) external view returns (string memory);
decimals
Returns the number of decimals for the token of type id.
function decimals(uint256 id) external view returns (uint8);
IERC6909ContentURI
Inherits: IERC6909
Optional extension of {IERC6909} that adds content URI functions.
Functions
contractURI
Returns URI for the contract.
function contractURI() external view returns (string memory);
tokenURI
Returns the URI for the token of type id.
function tokenURI(uint256 id) external view returns (string memory);
IERC6909TokenSupply
Inherits: IERC6909
Optional extension of {IERC6909} that adds a token supply function.
Functions
totalSupply
Returns the total supply of the token of type id.
function totalSupply(uint256 id) external view returns (uint256);
IERC7579Module
Minimal configuration interface for ERC-7579 modules
Functions
onInstall
This function is called by the smart account during installation of the module
function onInstall(bytes calldata data) external;
Parameters
| Name | Type | Description |
|---|---|---|
data | bytes | arbitrary data that may be passed to the module during onInstall initialization MUST revert on error (e.g. if module is already enabled) |
onUninstall
This function is called by the smart account during uninstallation of the module
function onUninstall(bytes calldata data) external;
Parameters
| Name | Type | Description |
|---|---|---|
data | bytes | arbitrary data that may be passed to the module during onUninstall de-initialization MUST revert on error |
isModuleType
Returns boolean value if module is a certain type
function isModuleType(uint256 moduleTypeId) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
moduleTypeId | uint256 | the module type ID according the ERC-7579 spec MUST return true if the module is of the given type and false otherwise |
IERC7579Validator
Inherits: IERC7579Module
ERC-7579 Validation module (type 1). A module that implements logic to validate user operations and signatures.
Functions
validateUserOp
Validates a UserOperation
function validateUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash) external returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
userOp | PackedUserOperation | the ERC-4337 PackedUserOperation |
userOpHash | bytes32 | the hash of the ERC-4337 PackedUserOperation MUST validate that the signature is a valid signature of the userOpHash SHOULD return ERC-4337's SIG_VALIDATION_FAILED (and not revert) on signature mismatch See {IAccount-validateUserOp} for additional information on the return value |
isValidSignatureWithSender
Validates a signature using ERC-1271
function isValidSignatureWithSender(address sender, bytes32 hash, bytes calldata signature)
external
view
returns (bytes4);
Parameters
| Name | Type | Description |
|---|---|---|
sender | address | the address that sent the ERC-1271 request to the smart account |
hash | bytes32 | the hash of the ERC-1271 request |
signature | bytes | the signature of the ERC-1271 request MUST return the ERC-1271 MAGIC_VALUE if the signature is valid MUST NOT modify state |
IERC7579Hook
Inherits: IERC7579Module
ERC-7579 Hooks module (type 4). A module that implements logic to execute before and after the account executes a user operation, either individually or batched.
Functions
preCheck
Called by the smart account before execution
function preCheck(address msgSender, uint256 value, bytes calldata msgData) external returns (bytes memory hookData);
Parameters
| Name | Type | Description |
|---|---|---|
msgSender | address | the address that called the smart account |
value | uint256 | the value that was sent to the smart account |
msgData | bytes | the data that was sent to the smart account MAY return arbitrary data in the hookData return value |
postCheck
Called by the smart account after execution
function postCheck(bytes calldata hookData) external;
Parameters
| Name | Type | Description |
|---|---|---|
hookData | bytes | the data that was returned by the preCheck function MAY validate the hookData to validate transaction context of the preCheck function |
Execution
struct Execution {
address target;
uint256 value;
bytes callData;
}
IERC7579Execution
ERC-7579 Execution. Accounts should implement this interface so that the Entrypoint and ERC-7579 modules can execute operations.
Functions
execute
Executes a transaction on behalf of the account.
function execute(bytes32 mode, bytes calldata executionCalldata) external payable;
Parameters
| Name | Type | Description |
|---|---|---|
mode | bytes32 | The encoded execution mode of the transaction. See ModeLib.sol for details |
executionCalldata | bytes | The encoded execution call data MUST ensure adequate authorization control: e.g. onlyEntryPointOrSelf if used with ERC-4337 If a mode is requested that is not supported by the Account, it MUST revert |
executeFromExecutor
Executes a transaction on behalf of the account. This function is intended to be called by Executor Modules
function executeFromExecutor(bytes32 mode, bytes calldata executionCalldata)
external
payable
returns (bytes[] memory returnData);
Parameters
| Name | Type | Description |
|---|---|---|
mode | bytes32 | The encoded execution mode of the transaction. See ModeLib.sol for details |
executionCalldata | bytes | The encoded execution call data |
Returns
| Name | Type | Description |
|---|---|---|
returnData | bytes[] | An array with the returned data of each executed subcall MUST ensure adequate authorization control: i.e. onlyExecutorModule If a mode is requested that is not supported by the Account, it MUST revert |
IERC7579AccountConfig
ERC-7579 Account Config. Accounts should implement this interface to expose information that identifies the account, supported modules and capabilities.
Functions
accountId
Returns the account id of the smart account
function accountId() external view returns (string memory accountImplementationId);
Returns
| Name | Type | Description |
|---|---|---|
accountImplementationId | string | the account id of the smart account MUST return a non-empty string The accountId SHOULD be structured like so: "vendorname.accountname.semver" The id SHOULD be unique across all smart accounts |
supportsExecutionMode
Function to check if the account supports a certain execution mode (see above)
function supportsExecutionMode(bytes32 encodedMode) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
encodedMode | bytes32 | the encoded mode MUST return true if the account supports the mode and false otherwise |
supportsModule
Function to check if the account supports a certain module typeId
function supportsModule(uint256 moduleTypeId) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
moduleTypeId | uint256 | the module type ID according to the ERC-7579 spec MUST return true if the account supports the module type and false otherwise |
IERC7579ModuleConfig
ERC-7579 Module Config. Accounts should implement this interface to allow installing and uninstalling modules.
Functions
installModule
Installs a Module of a certain type on the smart account
function installModule(uint256 moduleTypeId, address module, bytes calldata initData) external;
Parameters
| Name | Type | Description |
|---|---|---|
moduleTypeId | uint256 | the module type ID according to the ERC-7579 spec |
module | address | the module address |
initData | bytes | arbitrary data that may be passed to the module during onInstall initialization. MUST implement authorization control MUST call onInstall on the module with the initData parameter if provided MUST emit ModuleInstalled event MUST revert if the module is already installed or the initialization on the module failed |
uninstallModule
Uninstalls a Module of a certain type on the smart account
function uninstallModule(uint256 moduleTypeId, address module, bytes calldata deInitData) external;
Parameters
| Name | Type | Description |
|---|---|---|
moduleTypeId | uint256 | the module type ID according the ERC-7579 spec |
module | address | the module address |
deInitData | bytes | arbitrary data that may be passed to the module during onUninstall deinitialization. MUST implement authorization control MUST call onUninstall on the module with the deInitData parameter if provided MUST emit ModuleUninstalled event MUST revert if the module is not installed or the deInitialization on the module failed |
isModuleInstalled
Returns whether a module is installed on the smart account
function isModuleInstalled(uint256 moduleTypeId, address module, bytes calldata additionalContext)
external
view
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
moduleTypeId | uint256 | the module type ID according the ERC-7579 spec |
module | address | the module address |
additionalContext | bytes | arbitrary data that may be passed to determine if the module is installed MUST return true if the module is installed and false otherwise |
Events
ModuleInstalled
event ModuleInstalled(uint256 moduleTypeId, address module);
ModuleUninstalled
event ModuleUninstalled(uint256 moduleTypeId, address module);
Constants
VALIDATION_SUCCESS
uint256 constant VALIDATION_SUCCESS = 0;
VALIDATION_FAILED
uint256 constant VALIDATION_FAILED = 1;
MODULE_TYPE_VALIDATOR
uint256 constant MODULE_TYPE_VALIDATOR = 1;
MODULE_TYPE_EXECUTOR
uint256 constant MODULE_TYPE_EXECUTOR = 2;
MODULE_TYPE_FALLBACK
uint256 constant MODULE_TYPE_FALLBACK = 3;
MODULE_TYPE_HOOK
uint256 constant MODULE_TYPE_HOOK = 4;
IERC7674
Inherits: IERC20
Temporary Approval Extension for ERC-20 (https://github.com/ethereum/ERCs/pull/358[ERC-7674])
Functions
temporaryApprove
Set the temporary allowance, allowing spender to withdraw (within the same transaction) assets
held by the caller.
function temporaryApprove(address spender, uint256 value) external returns (bool success);
IERC7802
Inherits: IERC165
Defines the interface for crosschain ERC20 transfers.
Functions
crosschainMint
Mint tokens through a crosschain transfer.
function crosschainMint(address _to, uint256 _amount) external;
Parameters
| Name | Type | Description |
|---|---|---|
_to | address | Address to mint tokens to. |
_amount | uint256 | Amount of tokens to mint. |
crosschainBurn
Burn tokens through a crosschain transfer.
function crosschainBurn(address _from, uint256 _amount) external;
Parameters
| Name | Type | Description |
|---|---|---|
_from | address | Address to burn tokens from. |
_amount | uint256 | Amount of tokens to burn. |
Events
CrosschainMint
Emitted when a crosschain transfer mints tokens.
event CrosschainMint(address indexed to, uint256 amount, address indexed sender);
Parameters
| Name | Type | Description |
|---|---|---|
to | address | Address of the account tokens are being minted for. |
amount | uint256 | Amount of tokens minted. |
sender | address | Address of the caller (msg.sender) who invoked crosschainMint. |
CrosschainBurn
Emitted when a crosschain transfer burns tokens.
event CrosschainBurn(address indexed from, uint256 amount, address indexed sender);
Parameters
| Name | Type | Description |
|---|---|---|
from | address | Address of the account tokens are being burned from. |
amount | uint256 | Amount of tokens burned. |
sender | address | Address of the caller (msg.sender) who invoked crosschainBurn. |
IERC7821
Interface for minimal batch executor.
Functions
execute
*Executes the calls in executionData.
Reverts and bubbles up error if any call fails.
executionData encoding:
- If
opDatais empty,executionDatais simplyabi.encode(calls). - Else,
executionDataisabi.encode(calls, opData). See: https://eips.ethereum.org/EIPS/eip-7579 Supported modes: bytes32(0x01000000000000000000...): does not support optionalopData.bytes32(0x01000000000078210001...): supports optionalopData. Authorization checks:- If
opDatais empty, the implementation SHOULD require thatmsg.sender == address(this). - If
opDatais not empty, the implementation SHOULD use the signature encoded inopDatato determine if the caller can perform the execution.opDatamay be used to store additional data for authentication, paymaster data, gas limits, etc. For calldata compression efficiency, if a Call.to isaddress(0), it will be replaced withaddress(this).*
function execute(bytes32 mode, bytes calldata executionData) external payable;
supportsExecutionMode
*This function is provided for frontends to detect support. Only returns true for:
bytes32(0x01000000000000000000...): does not support optionalopData.bytes32(0x01000000000078210001...): supports optionalopData.*
function supportsExecutionMode(bytes32 mode) external view returns (bool);
Contents
ERC2771Context
Inherits: Context
Context variant with ERC-2771 support.
WARNING: Avoid using this pattern in contracts that rely in a specific calldata length as they'll
be affected by any forwarder whose msg.data is suffixed with the from address according to the ERC-2771
specification adding the address size in bytes (20) to the calldata size. An example of an unexpected
behavior could be an unintended fallback (or another function) invocation while trying to invoke the receive
function only accessible if msg.data.length == 0.
WARNING: The usage of delegatecall in this contract is dangerous and may result in context corruption.
Any forwarded request to this contract triggering a delegatecall to itself will result in an invalid _msgSender
recovery.
State Variables
_trustedForwarder
Note: oz-upgrades-unsafe-allow: state-variable-immutable
address private immutable _trustedForwarder;
Functions
constructor
Initializes the contract with a trusted forwarder, which will be able to invoke functions on this contract on behalf of other accounts. NOTE: The trusted forwarder can be replaced by overriding trustedForwarder.
Note: oz-upgrades-unsafe-allow: constructor
constructor(address trustedForwarder_);
trustedForwarder
Returns the address of the trusted forwarder.
function trustedForwarder() public view virtual returns (address);
isTrustedForwarder
Indicates whether any particular address is the trusted forwarder.
function isTrustedForwarder(address forwarder) public view virtual returns (bool);
_msgSender
Override for msg.sender. Defaults to the original msg.sender whenever
a call is not performed by the trusted forwarder or the calldata length is less than
20 bytes (an address length).
function _msgSender() internal view virtual override returns (address);
_msgData
Override for msg.data. Defaults to the original msg.data whenever
a call is not performed by the trusted forwarder or the calldata length is less than
20 bytes (an address length).
function _msgData() internal view virtual override returns (bytes calldata);
_contextSuffixLength
ERC-2771 specifies the context as being a single address (20 bytes).
function _contextSuffixLength() internal view virtual override returns (uint256);
ERC2771Forwarder
A forwarder compatible with ERC-2771 contracts. See {ERC2771Context}.
This forwarder operates on forward requests that include:
from: An address to operate on behalf of. It is required to be equal to the request signer.
to: The address that should be called.
value: The amount of native token to attach with the requested call.
gas: The amount of gas limit that will be forwarded with the requested call.
nonce: A unique transaction ordering identifier to avoid replayability and request invalidation.
deadline: A timestamp after which the request is not executable anymore.
data: Encoded msg.data to send with the requested call.
Relayers are able to submit batches if they are processing a high volume of requests. With high
throughput, relayers may run into limitations of the chain such as limits on the number of
transactions in the mempool. In these cases the recommendation is to distribute the load among
multiple accounts.
NOTE: Batching requests includes an optional refund for unused msg.value that is achieved by
performing a call with empty calldata. While this is within the bounds of ERC-2771 compliance,
if the refund receiver happens to consider the forwarder a trusted forwarder, it MUST properly
handle msg.data.length == 0. ERC2771Context in OpenZeppelin Contracts versions prior to 4.9.3
do not handle this properly.
==== Security Considerations
If a relayer submits a forward request, it should be willing to pay up to 100% of the gas amount
specified in the request. This contract does not implement any kind of retribution for this gas,
and it is assumed that there is an out of band incentive for relayers to pay for execution on
behalf of signers. Often, the relayer is operated by a project that will consider it a user
acquisition cost.
By offering to pay for gas, relayers are at risk of having that gas used by an attacker toward
some other purpose that is not aligned with the expected out of band incentives. If you operate a
relayer, consider whitelisting target contracts and function selectors. When relaying ERC-721 or
ERC-1155 transfers specifically, consider rejecting the use of the data field, since it can be
used to execute arbitrary code.
State Variables
_FORWARD_REQUEST_TYPEHASH
bytes32 internal constant _FORWARD_REQUEST_TYPEHASH = keccak256(
"ForwardRequest(address from,address to,uint256 value,uint256 gas,uint256 nonce,uint48 deadline,bytes data)"
);
Functions
constructor
See EIP712-constructor.
constructor(string memory name) EIP712(name, "1");
verify
Returns true if a request is valid for a provided signature at the current block timestamp.
A transaction is considered valid when the target trusts this forwarder, the request hasn't expired
(deadline is not met), and the signer matches the from parameter of the signed request.
NOTE: A request may return false here but it won't cause executeBatch to revert if a refund
receiver is provided.
function verify(ForwardRequestData calldata request) public view virtual returns (bool);
execute
*Executes a request on behalf of signature's signer using the ERC-2771 protocol. The gas
provided to the requested call may not be exactly the amount requested, but the call will not run
out of gas. Will revert if the request is invalid or the call reverts, in this case the nonce is not consumed.
Requirements:
- The request value should be equal to the provided
msg.value. - The request should be valid according to verify.*
function execute(ForwardRequestData calldata request) public payable virtual;
executeBatch
*Batch version of execute with optional refunding and atomic execution.
In case a batch contains at least one invalid request (see {verify}), the
request will be skipped and the refundReceiver parameter will receive back the
unused requested value at the end of the execution. This is done to prevent reverting
the entire batch when a request is invalid or has already been submitted.
If the refundReceiver is the address(0), this function will revert when at least
one of the requests was not valid instead of skipping it. This could be useful if
a batch is required to get executed atomically (at least at the top-level). For example,
refunding (and thus atomicity) can be opt-out if the relayer is using a service that avoids
including reverted transactions.
Requirements:
- The sum of the requests' values should be equal to the provided
msg.value. - All of the requests should be valid (see {verify}) when
refundReceiveris the zero address. NOTE: Setting a zerorefundReceiverguarantees an all-or-nothing requests execution only for the first-level forwarded calls. In case a forwarded request calls to a contract with another subcall, the second-level call may revert without the top-level call reverting.*
function executeBatch(ForwardRequestData[] calldata requests, address payable refundReceiver) public payable virtual;
_validate
Validates if the provided request can be executed at current block timestamp with
the given request.signature on behalf of request.signer.
function _validate(ForwardRequestData calldata request)
internal
view
virtual
returns (bool isTrustedForwarder, bool active, bool signerMatch, address signer);
_recoverForwardRequestSigner
Returns a tuple with the recovered the signer of an EIP712 forward request message hash and a boolean indicating if the signature is valid. NOTE: The signature is considered valid if {ECDSA-tryRecover} indicates no recover error for it.
function _recoverForwardRequestSigner(ForwardRequestData calldata request)
internal
view
virtual
returns (bool isValid, address signer);
_execute
*Validates and executes a signed request returning the request call success value.
Internal function without msg.value validation.
Requirements:
- The caller must have provided enough gas to forward with the call.
- The request must be valid (see verify) if the
requireValidRequestis true. Emits an {ExecutedForwardRequest} event. IMPORTANT: Using this function doesn't check that all themsg.valuewas sent, potentially leaving value stuck in the contract.*
function _execute(ForwardRequestData calldata request, bool requireValidRequest)
internal
virtual
returns (bool success);
_isTrustedByTarget
Returns whether the target trusts this forwarder. This function performs a static call to the target contract calling the {ERC2771Context-isTrustedForwarder} function. NOTE: Consider the execution of this forwarder is permissionless. Without this check, anyone may transfer assets that are owned by, or are approved to this forwarder.
function _isTrustedByTarget(address target) internal view virtual returns (bool);
_checkForwardedGas
*Checks if the requested gas was correctly forwarded to the callee. As a consequence of https://eips.ethereum.org/EIPS/eip-150[EIP-150]:
- At most
gasleft() - floor(gasleft() / 64)is forwarded to the callee. - At least
floor(gasleft() / 64)is kept in the caller. It reverts consuming all the available gas if the forwarded gas is not the requested gas. IMPORTANT: ThegasLeftparameter should be measured exactly at the end of the forwarded call. Any gas consumed in between will make room for bypassing this check.*
function _checkForwardedGas(uint256 gasLeft, ForwardRequestData calldata request) private pure;
Events
ExecutedForwardRequest
Emitted when a ForwardRequest is executed.
NOTE: An unsuccessful forward request could be due to an invalid signature, an expired deadline,
or simply a revert in the requested call. The contract guarantees that the relayer is not able to force
the requested call to run out of gas.
event ExecutedForwardRequest(address indexed signer, uint256 nonce, bool success);
Errors
ERC2771ForwarderInvalidSigner
The request from doesn't match with the recovered signer.
error ERC2771ForwarderInvalidSigner(address signer, address from);
ERC2771ForwarderMismatchedValue
The requestedValue doesn't match with the available msgValue.
error ERC2771ForwarderMismatchedValue(uint256 requestedValue, uint256 msgValue);
ERC2771ForwarderExpiredRequest
The request deadline has expired.
error ERC2771ForwarderExpiredRequest(uint48 deadline);
ERC2771UntrustfulTarget
The request target doesn't trust the forwarder.
error ERC2771UntrustfulTarget(address target, address forwarder);
Structs
ForwardRequestData
struct ForwardRequestData {
address from;
address to;
uint256 value;
uint256 gas;
uint48 deadline;
bytes data;
bytes signature;
}
Contents
- ERC165
- account
- compound
- docs
- governance
- proxy
- token
- utils
- AccessManagedTarget
- AccessManagerMock
- Uint256ArraysMock
- AddressArraysMock
- Bytes32ArraysMock
- BytesArraysMock
- StringArraysMock
- NotAuthorityMock
- AuthorityNoDelayMock
- AuthorityDelayMock
- AuthorityNoResponse
- AuthorityObserveIsConsuming
- Base64Dirty
- BatchCaller
- CallReceiverMock
- CallReceiverMockTrustingForwarder
- ConstructorMock
- ContextMock
- ContextMockCaller
- Impl
- DummyImplementation
- DummyImplementationV2
- EIP712Verifier
- ERC1271WalletMock
- ERC1271MaliciousMock
- ERC2771ContextMock
- ERC3156FlashBorrowerMock
- EtherReceiverMock
- InitializableMock
- ConstructorInitializableMock
- ChildConstructorInitializableMock
- ReinitializerMock
- DisableNew
- DisableOld
- DisableBad1
- DisableBad2
- DisableOk
- MerkleProofCustomHashMock
- MerkleTreeMock
- MulticallHelper
- SampleHuman
- SampleMother
- SampleGramps
- SampleFather
- SampleChild
- PausableMock
- ReentrancyAttack
- ReentrancyMock
- ReentrancyTransientMock
- Implementation1
- Implementation2
- Implementation3
- Implementation4
- MigratableMockV1
- MigratableMockV2
- MigratableMockV3
- Dummy1234
- StorageSlotMock
- TimelockReentrant
- TransientSlotMock
- UpgradeableBeaconMock
- IProxyExposed
- UpgradeableBeaconReentrantMock
- VotesExtendedMock
- VotesExtendedTimestampMock
- VotesMock
- VotesTimestampMock
Contents
- SupportsInterfaceWithLookupMock
- ERC165InterfacesSupported
- ERC165MaliciousData
- ERC165MissingData
- ERC165NotSupported
- ERC165ReturnBombMock
SupportsInterfaceWithLookupMock
Inherits: IERC165
https://eips.ethereum.org/EIPS/eip-214#specification From the specification:
Any attempts to make state-changing operations inside an execution instance with STATIC set to true will instead throw an exception. These operations include [...], LOG0, LOG1, LOG2, [...] therefore, because this contract is staticcall'd we need to not emit events (which is how solidity-coverage works) solidity-coverage ignores the /mocks folder, so we duplicate its implementation here to avoid instrumenting it
State Variables
INTERFACE_ID_ERC165
bytes4 public constant INTERFACE_ID_ERC165 = 0x01ffc9a7;
_supportedInterfaces
A mapping of interface id to whether or not it's supported.
mapping(bytes4 interfaceId => bool) private _supportedInterfaces;
Functions
constructor
A contract implementing SupportsInterfaceWithLookup implement ERC-165 itself.
constructor();
supportsInterface
Implement supportsInterface(bytes4) using a lookup table.
function supportsInterface(bytes4 interfaceId) public view override returns (bool);
_registerInterface
Private method for registering an interface.
function _registerInterface(bytes4 interfaceId) internal;
ERC165InterfacesSupported
Inherits: SupportsInterfaceWithLookupMock
Functions
constructor
constructor(bytes4[] memory interfaceIds);
ERC165MaliciousData
Functions
supportsInterface
function supportsInterface(bytes4) public pure returns (bool);
ERC165MissingData
Functions
supportsInterface
function supportsInterface(bytes4 interfaceId) public view;
ERC165NotSupported
ERC165ReturnBombMock
Inherits: IERC165
Functions
supportsInterface
function supportsInterface(bytes4 interfaceId) public pure override returns (bool);
Contents
- modules
- utils
- AccountMock
- AccountECDSAMock
- AccountP256Mock
- AccountRSAMock
- AccountERC7702Mock
- AccountERC7702WithModulesMock
- AccountERC7579Mock
- AccountERC7579HookedMock
- AccountERC7913Mock
- AccountMultiSignerMock
- AccountMultiSignerWeightedMock
Contents
ERC7579ModuleMock
Inherits: IERC7579Module
State Variables
_moduleTypeId
uint256 private _moduleTypeId;
Functions
constructor
constructor(uint256 moduleTypeId);
onInstall
function onInstall(bytes calldata data) public virtual;
onUninstall
function onUninstall(bytes calldata data) public virtual;
isModuleType
function isModuleType(uint256 moduleTypeId) external view returns (bool);
Events
ModuleInstalledReceived
event ModuleInstalledReceived(address account, bytes data);
ModuleUninstalledReceived
event ModuleUninstalledReceived(address account, bytes data);
ERC7579HookMock
Inherits: ERC7579ModuleMock, IERC7579Hook
Functions
preCheck
function preCheck(address msgSender, uint256 value, bytes calldata msgData) external returns (bytes memory hookData);
postCheck
function postCheck(bytes calldata hookData) external;
Events
PreCheck
event PreCheck(address sender, uint256 value, bytes data);
PostCheck
event PostCheck(bytes hookData);
ERC7579FallbackHandlerMock
Inherits: ERC7579ModuleMock
Functions
_msgAccount
function _msgAccount() internal view returns (address);
_msgSender
function _msgSender() internal pure returns (address);
_msgData
function _msgData() internal pure returns (bytes calldata);
callPayable
function callPayable() public payable;
callView
function callView() public view returns (address, address);
callRevert
function callRevert() public pure;
Events
ERC7579FallbackHandlerMockCalled
event ERC7579FallbackHandlerMockCalled(address account, address sender, uint256 value, bytes data);
Errors
ERC7579FallbackHandlerMockRevert
error ERC7579FallbackHandlerMockRevert();
ERC7579ValidatorMock
Inherits: ERC7579ModuleMock, IERC7579Validator
State Variables
_associatedSigners
mapping(address sender => address signer) private _associatedSigners;
Functions
onInstall
function onInstall(bytes calldata data) public virtual override(IERC7579Module, ERC7579ModuleMock);
onUninstall
function onUninstall(bytes calldata data) public virtual override(IERC7579Module, ERC7579ModuleMock);
validateUserOp
function validateUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash)
public
view
virtual
returns (uint256);
isValidSignatureWithSender
function isValidSignatureWithSender(address, bytes32 hash, bytes calldata signature)
public
view
virtual
returns (bytes4);
Contents
ERC7579UtilsGlobalMock
Functions
eqCallTypeGlobal
function eqCallTypeGlobal(CallType callType1, CallType callType2) internal pure returns (bool);
eqExecTypeGlobal
function eqExecTypeGlobal(ExecType execType1, ExecType execType2) internal pure returns (bool);
eqModeSelectorGlobal
function eqModeSelectorGlobal(ModeSelector modeSelector1, ModeSelector modeSelector2) internal pure returns (bool);
eqModePayloadGlobal
function eqModePayloadGlobal(ModePayload modePayload1, ModePayload modePayload2) internal pure returns (bool);
AccountMock
Inherits: Account, ERC7739, ERC7821, ERC721Holder, ERC1155Holder
Functions
_rawSignatureValidation
Validates a user operation with a boolean signature.
function _rawSignatureValidation(bytes32 hash, bytes calldata signature) internal pure override returns (bool);
_erc7821AuthorizedExecutor
*Access control mechanism for the {execute} function. By default, only the contract itself is allowed to execute. Override this function to implement custom access control, for example to allow the ERC-4337 entrypoint to execute.
function _erc7821AuthorizedExecutor(
address caller,
bytes32 mode,
bytes calldata executionData
) internal view virtual override returns (bool) {
return caller == address(entryPoint()) || super._erc7821AuthorizedExecutor(caller, mode, executionData);
}
```*
```solidity
function _erc7821AuthorizedExecutor(address caller, bytes32 mode, bytes calldata executionData)
internal
view
virtual
override
returns (bool);
AccountECDSAMock
Inherits: Account, SignerECDSA, ERC7739, ERC7821, ERC721Holder, ERC1155Holder
Functions
_erc7821AuthorizedExecutor
*Access control mechanism for the {execute} function. By default, only the contract itself is allowed to execute. Override this function to implement custom access control, for example to allow the ERC-4337 entrypoint to execute.
function _erc7821AuthorizedExecutor(
address caller,
bytes32 mode,
bytes calldata executionData
) internal view virtual override returns (bool) {
return caller == address(entryPoint()) || super._erc7821AuthorizedExecutor(caller, mode, executionData);
}
```*
```solidity
function _erc7821AuthorizedExecutor(address caller, bytes32 mode, bytes calldata executionData)
internal
view
virtual
override
returns (bool);
AccountP256Mock
Inherits: Account, SignerP256, ERC7739, ERC7821, ERC721Holder, ERC1155Holder
Functions
_erc7821AuthorizedExecutor
*Access control mechanism for the {execute} function. By default, only the contract itself is allowed to execute. Override this function to implement custom access control, for example to allow the ERC-4337 entrypoint to execute.
function _erc7821AuthorizedExecutor(
address caller,
bytes32 mode,
bytes calldata executionData
) internal view virtual override returns (bool) {
return caller == address(entryPoint()) || super._erc7821AuthorizedExecutor(caller, mode, executionData);
}
```*
```solidity
function _erc7821AuthorizedExecutor(address caller, bytes32 mode, bytes calldata executionData)
internal
view
virtual
override
returns (bool);
AccountRSAMock
Inherits: Account, SignerRSA, ERC7739, ERC7821, ERC721Holder, ERC1155Holder
Functions
_erc7821AuthorizedExecutor
*Access control mechanism for the {execute} function. By default, only the contract itself is allowed to execute. Override this function to implement custom access control, for example to allow the ERC-4337 entrypoint to execute.
function _erc7821AuthorizedExecutor(
address caller,
bytes32 mode,
bytes calldata executionData
) internal view virtual override returns (bool) {
return caller == address(entryPoint()) || super._erc7821AuthorizedExecutor(caller, mode, executionData);
}
```*
```solidity
function _erc7821AuthorizedExecutor(address caller, bytes32 mode, bytes calldata executionData)
internal
view
virtual
override
returns (bool);
AccountERC7702Mock
Inherits: Account, SignerERC7702, ERC7739, ERC7821, ERC721Holder, ERC1155Holder
Functions
_erc7821AuthorizedExecutor
*Access control mechanism for the {execute} function. By default, only the contract itself is allowed to execute. Override this function to implement custom access control, for example to allow the ERC-4337 entrypoint to execute.
function _erc7821AuthorizedExecutor(
address caller,
bytes32 mode,
bytes calldata executionData
) internal view virtual override returns (bool) {
return caller == address(entryPoint()) || super._erc7821AuthorizedExecutor(caller, mode, executionData);
}
```*
```solidity
function _erc7821AuthorizedExecutor(address caller, bytes32 mode, bytes calldata executionData)
internal
view
virtual
override
returns (bool);
AccountERC7702WithModulesMock
Inherits: Account, AccountERC7579, SignerERC7702, ERC7739, ERC721Holder, ERC1155Holder
Functions
_validateUserOp
function _validateUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash)
internal
virtual
override(Account, AccountERC7579)
returns (uint256);
isValidSignature
Resolve implementation of ERC-1271 by both ERC7739 and AccountERC7579 to support both schemes.
function isValidSignature(bytes32 hash, bytes calldata signature)
public
view
virtual
override(ERC7739, AccountERC7579)
returns (bytes4);
_rawSignatureValidation
Enable signature using the ERC-7702 signer.
function _rawSignatureValidation(bytes32 hash, bytes calldata signature)
internal
view
virtual
override(AbstractSigner, AccountERC7579, SignerERC7702)
returns (bool);
AccountERC7579Mock
Inherits: AccountERC7579
Functions
constructor
constructor(address validator, bytes memory initData);
AccountERC7579HookedMock
Inherits: AccountERC7579Hooked
Functions
constructor
constructor(address validator, bytes memory initData);
AccountERC7913Mock
Inherits: Account, SignerERC7913, ERC7739, ERC7821, ERC721Holder, ERC1155Holder
Functions
_erc7821AuthorizedExecutor
*Access control mechanism for the {execute} function. By default, only the contract itself is allowed to execute. Override this function to implement custom access control, for example to allow the ERC-4337 entrypoint to execute.
function _erc7821AuthorizedExecutor(
address caller,
bytes32 mode,
bytes calldata executionData
) internal view virtual override returns (bool) {
return caller == address(entryPoint()) || super._erc7821AuthorizedExecutor(caller, mode, executionData);
}
```*
```solidity
function _erc7821AuthorizedExecutor(address caller, bytes32 mode, bytes calldata executionData)
internal
view
virtual
override
returns (bool);
AccountMultiSignerMock
Inherits: Account, MultiSignerERC7913, ERC7739, ERC7821, ERC721Holder, ERC1155Holder
Functions
_erc7821AuthorizedExecutor
*Access control mechanism for the {execute} function. By default, only the contract itself is allowed to execute. Override this function to implement custom access control, for example to allow the ERC-4337 entrypoint to execute.
function _erc7821AuthorizedExecutor(
address caller,
bytes32 mode,
bytes calldata executionData
) internal view virtual override returns (bool) {
return caller == address(entryPoint()) || super._erc7821AuthorizedExecutor(caller, mode, executionData);
}
```*
```solidity
function _erc7821AuthorizedExecutor(address caller, bytes32 mode, bytes calldata executionData)
internal
view
virtual
override
returns (bool);
AccountMultiSignerWeightedMock
Inherits: Account, MultiSignerERC7913Weighted, ERC7739, ERC7821, ERC721Holder, ERC1155Holder
Functions
_erc7821AuthorizedExecutor
*Access control mechanism for the {execute} function. By default, only the contract itself is allowed to execute. Override this function to implement custom access control, for example to allow the ERC-4337 entrypoint to execute.
function _erc7821AuthorizedExecutor(
address caller,
bytes32 mode,
bytes calldata executionData
) internal view virtual override returns (bool) {
return caller == address(entryPoint()) || super._erc7821AuthorizedExecutor(caller, mode, executionData);
}
```*
```solidity
function _erc7821AuthorizedExecutor(address caller, bytes32 mode, bytes calldata executionData)
internal
view
virtual
override
returns (bool);
Contents
CompTimelock
Copyright 2020 Compound Labs, Inc. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
State Variables
GRACE_PERIOD
uint256 public constant GRACE_PERIOD = 14 days;
MINIMUM_DELAY
uint256 public constant MINIMUM_DELAY = 2 days;
MAXIMUM_DELAY
uint256 public constant MAXIMUM_DELAY = 30 days;
admin
address public admin;
pendingAdmin
address public pendingAdmin;
delay
uint256 public delay;
queuedTransactions
mapping(bytes32 => bool) public queuedTransactions;
Functions
constructor
constructor(address admin_, uint256 delay_);
receive
receive() external payable;
setDelay
function setDelay(uint256 delay_) public;
acceptAdmin
function acceptAdmin() public;
setPendingAdmin
function setPendingAdmin(address pendingAdmin_) public;
queueTransaction
function queueTransaction(address target, uint256 value, string memory signature, bytes memory data, uint256 eta)
public
returns (bytes32);
cancelTransaction
function cancelTransaction(address target, uint256 value, string memory signature, bytes memory data, uint256 eta)
public;
executeTransaction
function executeTransaction(address target, uint256 value, string memory signature, bytes memory data, uint256 eta)
public
payable
returns (bytes memory);
getBlockTimestamp
function getBlockTimestamp() internal view returns (uint256);
Events
NewAdmin
event NewAdmin(address indexed newAdmin);
NewPendingAdmin
event NewPendingAdmin(address indexed newPendingAdmin);
NewDelay
event NewDelay(uint256 indexed newDelay);
CancelTransaction
event CancelTransaction(
bytes32 indexed txHash, address indexed target, uint256 value, string signature, bytes data, uint256 eta
);
ExecuteTransaction
event ExecuteTransaction(
bytes32 indexed txHash, address indexed target, uint256 value, string signature, bytes data, uint256 eta
);
QueueTransaction
event QueueTransaction(
bytes32 indexed txHash, address indexed target, uint256 value, string signature, bytes data, uint256 eta
);
Contents
Contents
- AccessControlERC20MintBase
- AccessControlERC20MintMissing
- AccessControlERC20Mint
- AccessControlModified
- AccessManagedERC20Mint
- MyContract
AccessControlERC20MintBase
Inherits: ERC20, AccessControl
State Variables
MINTER_ROLE
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
Functions
constructor
constructor(address minter) ERC20("MyToken", "TKN");
mint
function mint(address to, uint256 amount) public;
Errors
CallerNotMinter
error CallerNotMinter(address caller);
AccessControlERC20MintMissing
Inherits: ERC20, AccessControl
State Variables
MINTER_ROLE
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
BURNER_ROLE
bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");
Functions
constructor
constructor() ERC20("MyToken", "TKN");
mint
function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE);
burn
function burn(address from, uint256 amount) public onlyRole(BURNER_ROLE);
AccessControlERC20Mint
Inherits: ERC20, AccessControl
State Variables
MINTER_ROLE
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
BURNER_ROLE
bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");
Functions
constructor
constructor(address minter, address burner) ERC20("MyToken", "TKN");
mint
function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE);
burn
function burn(address from, uint256 amount) public onlyRole(BURNER_ROLE);
AccessControlModified
Inherits: AccessControl
Functions
revokeRole
function revokeRole(bytes32, address) public pure override;
Errors
AccessControlNonRevocable
error AccessControlNonRevocable();
AccessManagedERC20Mint
Inherits: ERC20, AccessManaged
Functions
constructor
constructor(address manager) ERC20("MyToken", "TKN") AccessManaged(manager);
mint
function mint(address to, uint256 amount) public restricted;
MyContract
Inherits: Ownable
Functions
constructor
constructor(address initialOwner) Ownable(initialOwner);
normalThing
function normalThing() public;
specialThing
function specialThing() public onlyOwner;
Contents
MyAccountERC7702
Inherits: Account, SignerERC7702, ERC7821, ERC721Holder, ERC1155Holder
Functions
_erc7821AuthorizedExecutor
Allows the entry point as an authorized executor.
function _erc7821AuthorizedExecutor(address caller, bytes32 mode, bytes calldata executionData)
internal
view
virtual
override
returns (bool);
MyFactoryAccount
A factory contract to create accounts on demand.
State Variables
_impl
address private immutable _impl;
Functions
constructor
constructor(address impl_);
predictAddress
Predict the address of the account
function predictAddress(bytes calldata callData) public view returns (address);
cloneAndInitialize
Create clone accounts on demand
function cloneAndInitialize(bytes calldata callData) public returns (address);
Contents
MyGovernor
Inherits: Governor, GovernorCountingSimple, GovernorVotes, GovernorVotesQuorumFraction, GovernorTimelockControl
Functions
constructor
constructor(IVotes _token, TimelockController _timelock)
Governor("MyGovernor")
GovernorVotes(_token)
GovernorVotesQuorumFraction(4)
GovernorTimelockControl(_timelock);
votingDelay
function votingDelay() public pure override returns (uint256);
votingPeriod
function votingPeriod() public pure override returns (uint256);
proposalThreshold
function proposalThreshold() public pure override returns (uint256);
state
function state(uint256 proposalId) public view override(Governor, GovernorTimelockControl) returns (ProposalState);
proposalNeedsQueuing
function proposalNeedsQueuing(uint256 proposalId)
public
view
virtual
override(Governor, GovernorTimelockControl)
returns (bool);
_queueOperations
function _queueOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(Governor, GovernorTimelockControl) returns (uint48);
_executeOperations
function _executeOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(Governor, GovernorTimelockControl);
_cancel
function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
internal
override(Governor, GovernorTimelockControl)
returns (uint256);
_executor
function _executor() internal view override(Governor, GovernorTimelockControl) returns (address);
MyToken
Inherits: ERC20, ERC20Permit, ERC20Votes
Functions
constructor
constructor() ERC20("MyToken", "MTK") ERC20Permit("MyToken");
_update
function _update(address from, address to, uint256 amount) internal override(ERC20, ERC20Votes);
nonces
function nonces(address owner) public view virtual override(ERC20Permit, Nonces) returns (uint256);
MyTokenTimestampBased
Inherits: ERC20, ERC20Permit, ERC20Votes
Functions
constructor
constructor() ERC20("MyTokenTimestampBased", "MTK") ERC20Permit("MyTokenTimestampBased");
clock
function clock() public view override returns (uint48);
CLOCK_MODE
function CLOCK_MODE() public pure override returns (string memory);
_update
function _update(address from, address to, uint256 amount) internal override(ERC20, ERC20Votes);
nonces
function nonces(address owner) public view virtual override(ERC20Permit, Nonces) returns (uint256);
MyTokenWrapped
Inherits: ERC20, ERC20Permit, ERC20Votes, ERC20Wrapper
Functions
constructor
constructor(IERC20 wrappedToken)
ERC20("MyTokenWrapped", "MTK")
ERC20Permit("MyTokenWrapped")
ERC20Wrapper(wrappedToken);
decimals
function decimals() public view override(ERC20, ERC20Wrapper) returns (uint8);
_update
function _update(address from, address to, uint256 amount) internal override(ERC20, ERC20Votes);
nonces
function nonces(address owner) public view virtual override(ERC20Permit, Nonces) returns (uint256);
Contents
Contents
GameItems
Inherits: ERC1155
State Variables
GOLD
uint256 public constant GOLD = 0;
SILVER
uint256 public constant SILVER = 1;
THORS_HAMMER
uint256 public constant THORS_HAMMER = 2;
SWORD
uint256 public constant SWORD = 3;
SHIELD
uint256 public constant SHIELD = 4;
Functions
constructor
constructor() ERC1155("https://game.example/api/item/{id}.json");
MyERC115HolderContract
Inherits: ERC1155Holder
Contents
GLDToken
Inherits: ERC20
Functions
constructor
constructor(uint256 initialSupply) ERC20("Gold", "GLD");
Contents
ERC6909GameItems
Inherits: ERC6909Metadata
State Variables
GOLD
uint256 public constant GOLD = 0;
SILVER
uint256 public constant SILVER = 1;
THORS_HAMMER
uint256 public constant THORS_HAMMER = 2;
SWORD
uint256 public constant SWORD = 3;
SHIELD
uint256 public constant SHIELD = 4;
Functions
constructor
constructor();
Contents
GameItem
Inherits: ERC721URIStorage
State Variables
_nextTokenId
uint256 private _nextTokenId;
Functions
constructor
constructor() ERC721("GameItem", "ITM");
awardItem
function awardItem(address player, string memory tokenURI) public returns (uint256);
Contents
Base64NFT
Inherits: ERC721
Functions
constructor
constructor() ERC721("Base64NFT", "MTK");
tokenURI
function tokenURI(uint256 tokenId) public pure override returns (string memory);
Box
Inherits: Multicall
Functions
foo
function foo() public;
bar
function bar() public;
ERC20WithAutoMinerReward
Inherits: ERC20
Functions
constructor
constructor() ERC20("Reward", "RWD");
_mintMinerReward
function _mintMinerReward() internal;
_update
function _update(address from, address to, uint256 value) internal virtual override;
ERC4626Fees
Inherits: ERC4626
ERC-4626 vault with entry/exit fees expressed in https://en.wikipedia.org/wiki/Basis_point[basis point (bp)]. NOTE: The contract charges fees in terms of assets, not shares. This means that the fees are calculated based on the amount of assets that are being deposited or withdrawn, and not based on the amount of shares that are being minted or redeemed. This is an opinionated design decision that should be taken into account when integrating this contract. WARNING: This contract has not been audited and shouldn't be considered production ready. Consider using it with caution.
State Variables
_BASIS_POINT_SCALE
uint256 private constant _BASIS_POINT_SCALE = 1e4;
Functions
previewDeposit
Preview taking an entry fee on deposit. See IERC4626-previewDeposit.
function previewDeposit(uint256 assets) public view virtual override returns (uint256);
previewMint
Preview adding an entry fee on mint. See IERC4626-previewMint.
function previewMint(uint256 shares) public view virtual override returns (uint256);
previewWithdraw
Preview adding an exit fee on withdraw. See IERC4626-previewWithdraw.
function previewWithdraw(uint256 assets) public view virtual override returns (uint256);
previewRedeem
Preview taking an exit fee on redeem. See IERC4626-previewRedeem.
function previewRedeem(uint256 shares) public view virtual override returns (uint256);
_deposit
Send entry fee to _entryFeeRecipient. See {IERC4626-_deposit}.
function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual override;
_withdraw
Send exit fee to _exitFeeRecipient. See {IERC4626-_deposit}.
function _withdraw(address caller, address receiver, address owner, uint256 assets, uint256 shares)
internal
virtual
override;
_entryFeeBasisPoints
function _entryFeeBasisPoints() internal view virtual returns (uint256);
_exitFeeBasisPoints
function _exitFeeBasisPoints() internal view virtual returns (uint256);
_entryFeeRecipient
function _entryFeeRecipient() internal view virtual returns (address);
_exitFeeRecipient
function _exitFeeRecipient() internal view virtual returns (address);
_feeOnRaw
Calculates the fees that should be added to an amount assets that does not already include fees.
Used in IERC4626-mint and {IERC4626-withdraw} operations.
function _feeOnRaw(uint256 assets, uint256 feeBasisPoints) private pure returns (uint256);
_feeOnTotal
Calculates the fee part of an amount assets that already includes fees.
Used in IERC4626-deposit and {IERC4626-redeem} operations.
function _feeOnTotal(uint256 assets, uint256 feeBasisPoints) private pure returns (uint256);
MyNFT
Inherits: ERC721
Functions
constructor
constructor() ERC721("MyNFT", "MNFT");
Contents
- GovernorCountingOverridableMock
- GovernorFractionalMock
- GovernorMock
- GovernorNoncesKeyedMock
- GovernorPreventLateQuorumMock
- GovernorProposalGuardianMock
- GovernorSequentialProposalIdMock
- GovernorStorageMock
- GovernorSuperQuorumMock
- GovernorTimelockAccessMock
- GovernorTimelockCompoundMock
- GovernorTimelockControlMock
- GovernorVoteMocks
- GovernorVotesSuperQuorumFractionMock
- GovernorWithParamsMock
GovernorCountingOverridableMock
Inherits: GovernorSettings, GovernorVotesQuorumFraction, GovernorCountingOverridable
Functions
proposalThreshold
function proposalThreshold() public view override(Governor, GovernorSettings) returns (uint256);
GovernorFractionalMock
Inherits: GovernorSettings, GovernorVotesQuorumFraction, GovernorCountingFractional
Functions
proposalThreshold
function proposalThreshold() public view override(Governor, GovernorSettings) returns (uint256);
GovernorMock
Inherits: GovernorSettings, GovernorVotesQuorumFraction, GovernorCountingSimple
Functions
proposalThreshold
function proposalThreshold() public view override(Governor, GovernorSettings) returns (uint256);
GovernorNoncesKeyedMock
Inherits: GovernorSettings, GovernorVotesQuorumFraction, GovernorCountingSimple, GovernorNoncesKeyed
Functions
proposalThreshold
function proposalThreshold() public view override(Governor, GovernorSettings) returns (uint256);
_validateVoteSig
function _validateVoteSig(uint256 proposalId, uint8 support, address voter, bytes memory signature)
internal
virtual
override(Governor, GovernorNoncesKeyed)
returns (bool);
_validateExtendedVoteSig
function _validateExtendedVoteSig(
uint256 proposalId,
uint8 support,
address voter,
string memory reason,
bytes memory params,
bytes memory signature
) internal virtual override(Governor, GovernorNoncesKeyed) returns (bool);
_useCheckedNonce
function _useCheckedNonce(address owner, uint256 nonce) internal virtual override(Nonces, GovernorNoncesKeyed);
GovernorPreventLateQuorumMock
Inherits: GovernorSettings, GovernorVotes, GovernorCountingSimple, GovernorPreventLateQuorum
State Variables
_quorum
uint256 private _quorum;
Functions
constructor
constructor(uint256 quorum_);
quorum
function quorum(uint256) public view override returns (uint256);
proposalDeadline
function proposalDeadline(uint256 proposalId)
public
view
override(Governor, GovernorPreventLateQuorum)
returns (uint256);
proposalThreshold
function proposalThreshold() public view override(Governor, GovernorSettings) returns (uint256);
_tallyUpdated
function _tallyUpdated(uint256 proposalId) internal override(Governor, GovernorPreventLateQuorum);
GovernorProposalGuardianMock
Inherits: GovernorSettings, GovernorVotesQuorumFraction, GovernorCountingSimple, GovernorProposalGuardian
Functions
proposalThreshold
function proposalThreshold() public view override(Governor, GovernorSettings) returns (uint256);
_validateCancel
function _validateCancel(uint256 proposalId, address caller)
internal
view
override(Governor, GovernorProposalGuardian)
returns (bool);
GovernorSequentialProposalIdMock
Inherits: GovernorSettings, GovernorVotesQuorumFraction, GovernorCountingSimple, GovernorSequentialProposalId
Functions
proposalThreshold
function proposalThreshold() public view override(Governor, GovernorSettings) returns (uint256);
getProposalId
function getProposalId(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) public view virtual override(Governor, GovernorSequentialProposalId) returns (uint256);
_propose
function _propose(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
string memory description,
address proposer
) internal virtual override(Governor, GovernorSequentialProposalId) returns (uint256 proposalId);
GovernorStorageMock
Inherits: GovernorSettings, GovernorTimelockControl, GovernorVotesQuorumFraction, GovernorCountingSimple, GovernorStorage
Functions
quorum
function quorum(uint256 blockNumber) public view override(Governor, GovernorVotesQuorumFraction) returns (uint256);
state
function state(uint256 proposalId) public view override(Governor, GovernorTimelockControl) returns (ProposalState);
proposalThreshold
function proposalThreshold() public view override(Governor, GovernorSettings) returns (uint256);
proposalNeedsQueuing
function proposalNeedsQueuing(uint256 proposalId)
public
view
virtual
override(Governor, GovernorTimelockControl)
returns (bool);
_propose
function _propose(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
string memory description,
address proposer
) internal virtual override(Governor, GovernorStorage) returns (uint256);
_queueOperations
function _queueOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(Governor, GovernorTimelockControl) returns (uint48);
_executeOperations
function _executeOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(Governor, GovernorTimelockControl);
_cancel
function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
internal
override(Governor, GovernorTimelockControl)
returns (uint256);
_executor
function _executor() internal view override(Governor, GovernorTimelockControl) returns (address);
GovernorSuperQuorumMock
Inherits: GovernorSettings, GovernorVotes, GovernorTimelockControl, GovernorSuperQuorum, GovernorCountingSimple
State Variables
_quorum
uint256 private _quorum;
_superQuorum
uint256 private _superQuorum;
Functions
constructor
constructor(uint256 quorum_, uint256 superQuorum_);
quorum
function quorum(uint256) public view override returns (uint256);
superQuorum
function superQuorum(uint256) public view override returns (uint256);
state
function state(uint256 proposalId)
public
view
override(Governor, GovernorSuperQuorum, GovernorTimelockControl)
returns (ProposalState);
proposalThreshold
function proposalThreshold() public view override(Governor, GovernorSettings) returns (uint256);
proposalVotes
function proposalVotes(uint256 proposalId)
public
view
virtual
override(GovernorCountingSimple, GovernorSuperQuorum)
returns (uint256 againstVotes, uint256 forVotes, uint256 abstainVotes);
_cancel
function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
internal
override(Governor, GovernorTimelockControl)
returns (uint256);
_executeOperations
function _executeOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(Governor, GovernorTimelockControl);
_executor
function _executor() internal view override(Governor, GovernorTimelockControl) returns (address);
_queueOperations
function _queueOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(Governor, GovernorTimelockControl) returns (uint48);
proposalNeedsQueuing
function proposalNeedsQueuing(uint256 proposalId)
public
view
override(Governor, GovernorTimelockControl)
returns (bool);
GovernorTimelockAccessMock
Inherits: GovernorSettings, GovernorTimelockAccess, GovernorVotesQuorumFraction, GovernorCountingSimple
Functions
nonGovernanceFunction
function nonGovernanceFunction() external;
quorum
function quorum(uint256 blockNumber) public view override(Governor, GovernorVotesQuorumFraction) returns (uint256);
proposalThreshold
function proposalThreshold() public view override(Governor, GovernorSettings) returns (uint256);
proposalNeedsQueuing
function proposalNeedsQueuing(uint256 proposalId)
public
view
virtual
override(Governor, GovernorTimelockAccess)
returns (bool);
propose
function propose(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, string memory description)
public
override(Governor, GovernorTimelockAccess)
returns (uint256);
_queueOperations
function _queueOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(Governor, GovernorTimelockAccess) returns (uint48);
_executeOperations
function _executeOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(Governor, GovernorTimelockAccess);
_cancel
function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
internal
override(Governor, GovernorTimelockAccess)
returns (uint256);
GovernorTimelockCompoundMock
Inherits: GovernorSettings, GovernorTimelockCompound, GovernorVotesQuorumFraction, GovernorCountingSimple
Functions
quorum
function quorum(uint256 blockNumber) public view override(Governor, GovernorVotesQuorumFraction) returns (uint256);
state
function state(uint256 proposalId) public view override(Governor, GovernorTimelockCompound) returns (ProposalState);
proposalThreshold
function proposalThreshold() public view override(Governor, GovernorSettings) returns (uint256);
proposalNeedsQueuing
function proposalNeedsQueuing(uint256 proposalId)
public
view
virtual
override(Governor, GovernorTimelockCompound)
returns (bool);
_queueOperations
function _queueOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(Governor, GovernorTimelockCompound) returns (uint48);
_executeOperations
function _executeOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(Governor, GovernorTimelockCompound);
_cancel
function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
internal
override(Governor, GovernorTimelockCompound)
returns (uint256);
_executor
function _executor() internal view override(Governor, GovernorTimelockCompound) returns (address);
GovernorTimelockControlMock
Inherits: GovernorSettings, GovernorTimelockControl, GovernorVotesQuorumFraction, GovernorCountingSimple
Functions
quorum
function quorum(uint256 blockNumber) public view override(Governor, GovernorVotesQuorumFraction) returns (uint256);
state
function state(uint256 proposalId) public view override(Governor, GovernorTimelockControl) returns (ProposalState);
proposalThreshold
function proposalThreshold() public view override(Governor, GovernorSettings) returns (uint256);
proposalNeedsQueuing
function proposalNeedsQueuing(uint256 proposalId)
public
view
virtual
override(Governor, GovernorTimelockControl)
returns (bool);
_queueOperations
function _queueOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(Governor, GovernorTimelockControl) returns (uint48);
_executeOperations
function _executeOperations(
uint256 proposalId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) internal override(Governor, GovernorTimelockControl);
_cancel
function _cancel(address[] memory targets, uint256[] memory values, bytes[] memory calldatas, bytes32 descriptionHash)
internal
override(Governor, GovernorTimelockControl)
returns (uint256);
_executor
function _executor() internal view override(Governor, GovernorTimelockControl) returns (address);
nonGovernanceFunction
function nonGovernanceFunction() external;
GovernorVoteMocks
Inherits: GovernorVotes, GovernorCountingSimple
Functions
quorum
function quorum(uint256) public pure override returns (uint256);
votingDelay
function votingDelay() public pure override returns (uint256);
votingPeriod
function votingPeriod() public pure override returns (uint256);
GovernorVotesSuperQuorumFractionMock
Inherits: GovernorSettings, GovernorVotesSuperQuorumFraction, GovernorCountingSimple
Functions
proposalThreshold
function proposalThreshold() public view override(Governor, GovernorSettings) returns (uint256);
proposalVotes
function proposalVotes(uint256 proposalId)
public
view
virtual
override(GovernorCountingSimple, GovernorSuperQuorum)
returns (uint256 againstVotes, uint256 forVotes, uint256 abstainVotes);
state
function state(uint256 proposalId)
public
view
override(Governor, GovernorVotesSuperQuorumFraction)
returns (ProposalState);
GovernorWithParamsMock
Inherits: GovernorVotes, GovernorCountingSimple
Functions
quorum
function quorum(uint256) public pure override returns (uint256);
votingDelay
function votingDelay() public pure override returns (uint256);
votingPeriod
function votingPeriod() public pure override returns (uint256);
_getVotes
function _getVotes(address account, uint256 blockNumber, bytes memory params)
internal
view
override(Governor, GovernorVotes)
returns (uint256);
_countVote
function _countVote(uint256 proposalId, address account, uint8 support, uint256 weight, bytes memory params)
internal
override(Governor, GovernorCountingSimple)
returns (uint256);
Events
CountParams
event CountParams(uint256 uintParam, string strParam);
Contents
- BadBeaconNoImpl
- BadBeaconNotContract
- ClashingImplementation
- NonUpgradeableMock
- UUPSUpgradeableMock
- UUPSUpgradeableUnsafeMock
- UUPSUnsupportedProxiableUUID
BadBeaconNoImpl
BadBeaconNotContract
Functions
implementation
function implementation() external pure returns (address);
ClashingImplementation
Implementation contract with a payable changeAdmin(address) function made to clash with TransparentUpgradeableProxy's to test correct functioning of the Transparent Proxy feature.
Functions
upgradeToAndCall
function upgradeToAndCall(address, bytes calldata) external payable;
delegatedFunction
function delegatedFunction() external pure returns (bool);
Events
ClashingImplementationCall
event ClashingImplementationCall();
NonUpgradeableMock
State Variables
_counter
uint256 internal _counter;
Functions
current
function current() external view returns (uint256);
increment
function increment() external;
UUPSUpgradeableMock
Inherits: NonUpgradeableMock, UUPSUpgradeable
Functions
_authorizeUpgrade
function _authorizeUpgrade(address) internal override;
UUPSUpgradeableUnsafeMock
Inherits: UUPSUpgradeableMock
Functions
upgradeToAndCall
function upgradeToAndCall(address newImplementation, bytes memory data) public payable override;
UUPSUnsupportedProxiableUUID
Inherits: UUPSUpgradeableMock
Functions
proxiableUUID
function proxiableUUID() external pure override returns (bytes32);
Contents
- ERC1155ReceiverMock
- ERC1363ForceApproveMock
- ERC1363NoReturnMock
- ERC1363ReceiverMock
- ERC1363ReturnFalseOnERC20Mock
- ERC1363ReturnFalseMock
- ERC1363SpenderMock
- ERC20ApprovalMock
- ERC20BridgeableMock
- ERC20DecimalsMock
- ERC20ExcessDecimalsMock
- ERC20FlashMintMock
- ERC20ForceApproveMock
- ERC20GetterHelper
- ERC20Mock
- ERC20MulticallMock
- ERC20NoReturnMock
- ERC20Reentrant
- ERC20ReturnFalseMock
- ERC20VotesExtendedMock
- ERC20VotesExtendedTimestampMock
- ERC20VotesLegacyMock
- ERC20VotesTimestampMock
- ERC721VotesTimestampMock
- ERC4626LimitsMock
- ERC4626Mock
- ERC4626OffsetMock
- ERC4626FeesMock
- ERC721ConsecutiveEnumerableMock
- ERC721ConsecutiveMock
- ERC721ConsecutiveNoConstructorMintMock
- ERC721ReceiverMock
- ERC721URIStorageMock
ERC1155ReceiverMock
Inherits: ERC165, IERC1155Receiver
State Variables
_recRetval
bytes4 private immutable _recRetval;
_batRetval
bytes4 private immutable _batRetval;
_error
RevertType private immutable _error;
Functions
constructor
constructor(bytes4 recRetval, bytes4 batRetval, RevertType error);
onERC1155Received
function onERC1155Received(address operator, address from, uint256 id, uint256 value, bytes calldata data)
external
returns (bytes4);
onERC1155BatchReceived
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
Events
Received
event Received(address operator, address from, uint256 id, uint256 value, bytes data, uint256 gas);
BatchReceived
event BatchReceived(address operator, address from, uint256[] ids, uint256[] values, bytes data, uint256 gas);
Errors
CustomError
error CustomError(bytes4);
Enums
RevertType
enum RevertType {
None,
RevertWithoutMessage,
RevertWithMessage,
RevertWithCustomError,
Panic
}
ERC1363ForceApproveMock
Inherits: ERC1363
Functions
approveAndCall
function approveAndCall(address spender, uint256 amount, bytes memory data) public virtual override returns (bool);
ERC1363NoReturnMock
Inherits: ERC1363
Functions
transferAndCall
function transferAndCall(address to, uint256 value, bytes memory data) public override returns (bool);
transferFromAndCall
function transferFromAndCall(address from, address to, uint256 value, bytes memory data)
public
override
returns (bool);
approveAndCall
function approveAndCall(address spender, uint256 value, bytes memory data) public override returns (bool);
ERC1363ReceiverMock
Inherits: IERC1363Receiver
State Variables
_retval
bytes4 private _retval;
_error
RevertType private _error;
Functions
constructor
constructor();
setUp
function setUp(bytes4 retval, RevertType error) public;
onTransferReceived
function onTransferReceived(address operator, address from, uint256 value, bytes calldata data)
external
override
returns (bytes4);
Events
Received
event Received(address operator, address from, uint256 value, bytes data);
Errors
CustomError
error CustomError(bytes4);
Enums
RevertType
enum RevertType {
None,
RevertWithoutMessage,
RevertWithMessage,
RevertWithCustomError,
Panic
}
ERC1363ReturnFalseOnERC20Mock
Inherits: ERC1363
Functions
transfer
function transfer(address, uint256) public pure override(IERC20, ERC20) returns (bool);
transferFrom
function transferFrom(address, address, uint256) public pure override(IERC20, ERC20) returns (bool);
approve
function approve(address, uint256) public pure override(IERC20, ERC20) returns (bool);
ERC1363ReturnFalseMock
Inherits: ERC1363
Functions
transferAndCall
function transferAndCall(address, uint256, bytes memory) public pure override returns (bool);
transferFromAndCall
function transferFromAndCall(address, address, uint256, bytes memory) public pure override returns (bool);
approveAndCall
function approveAndCall(address, uint256, bytes memory) public pure override returns (bool);
ERC1363SpenderMock
Inherits: IERC1363Spender
State Variables
_retval
bytes4 private _retval;
_error
RevertType private _error;
Functions
constructor
constructor();
setUp
function setUp(bytes4 retval, RevertType error) public;
onApprovalReceived
function onApprovalReceived(address owner, uint256 value, bytes calldata data) external override returns (bytes4);
Events
Approved
event Approved(address owner, uint256 value, bytes data);
Errors
CustomError
error CustomError(bytes4);
Enums
RevertType
enum RevertType {
None,
RevertWithoutMessage,
RevertWithMessage,
RevertWithCustomError,
Panic
}
ERC20ApprovalMock
Inherits: ERC20
Functions
_approve
function _approve(address owner, address spender, uint256 amount, bool) internal virtual override;
ERC20BridgeableMock
Inherits: ERC20Bridgeable
State Variables
_bridge
address private _bridge;
Functions
constructor
constructor(address bridge);
onlyTokenBridgeFn
function onlyTokenBridgeFn() external onlyTokenBridge;
_checkTokenBridge
function _checkTokenBridge(address sender) internal view override;
Events
OnlyTokenBridgeFnCalled
event OnlyTokenBridgeFnCalled(address caller);
Errors
OnlyTokenBridge
error OnlyTokenBridge();
ERC20DecimalsMock
Inherits: ERC20
State Variables
_decimals
uint8 private immutable _decimals;
Functions
constructor
constructor(uint8 decimals_);
decimals
function decimals() public view override returns (uint8);
ERC20ExcessDecimalsMock
Functions
decimals
function decimals() public pure returns (uint256);
ERC20FlashMintMock
Inherits: ERC20FlashMint
State Variables
_flashFeeAmount
uint256 _flashFeeAmount;
_flashFeeReceiverAddress
address _flashFeeReceiverAddress;
Functions
setFlashFee
function setFlashFee(uint256 amount) public;
_flashFee
function _flashFee(address, uint256) internal view override returns (uint256);
setFlashFeeReceiver
function setFlashFeeReceiver(address receiver) public;
_flashFeeReceiver
function _flashFeeReceiver() internal view override returns (address);
ERC20ForceApproveMock
Inherits: ERC20
Functions
approve
function approve(address spender, uint256 amount) public virtual override returns (bool);
ERC20GetterHelper
Functions
totalSupply
function totalSupply(IERC20 token) external;
balanceOf
function balanceOf(IERC20 token, address account) external;
allowance
function allowance(IERC20 token, address owner, address spender) external;
name
function name(IERC20Metadata token) external;
symbol
function symbol(IERC20Metadata token) external;
decimals
function decimals(IERC20Metadata token) external;
Events
ERC20TotalSupply
event ERC20TotalSupply(IERC20 token, uint256 totalSupply);
ERC20BalanceOf
event ERC20BalanceOf(IERC20 token, address account, uint256 balanceOf);
ERC20Allowance
event ERC20Allowance(IERC20 token, address owner, address spender, uint256 allowance);
ERC20Name
event ERC20Name(IERC20Metadata token, string name);
ERC20Symbol
event ERC20Symbol(IERC20Metadata token, string symbol);
ERC20Decimals
event ERC20Decimals(IERC20Metadata token, uint8 decimals);
ERC20Mock
Inherits: ERC20
Functions
constructor
constructor() ERC20("ERC20Mock", "E20M");
mint
function mint(address account, uint256 amount) external;
burn
function burn(address account, uint256 amount) external;
ERC20MulticallMock
ERC20NoReturnMock
Inherits: ERC20
Functions
transfer
function transfer(address to, uint256 amount) public override returns (bool);
transferFrom
function transferFrom(address from, address to, uint256 amount) public override returns (bool);
approve
function approve(address spender, uint256 amount) public override returns (bool);
ERC20Reentrant
Inherits: ERC20
State Variables
_reenterType
Type private _reenterType;
_reenterTarget
address private _reenterTarget;
_reenterData
bytes private _reenterData;
Functions
scheduleReenter
function scheduleReenter(Type when, address target, bytes calldata data) external;
functionCall
function functionCall(address target, bytes memory data) public returns (bytes memory);
_update
function _update(address from, address to, uint256 amount) internal override;
Enums
Type
enum Type {
No,
Before,
After
}
ERC20ReturnFalseMock
Inherits: ERC20
Functions
transfer
function transfer(address, uint256) public pure override returns (bool);
transferFrom
function transferFrom(address, address, uint256) public pure override returns (bool);
approve
function approve(address, uint256) public pure override returns (bool);
ERC20VotesExtendedMock
Inherits: ERC20Votes, VotesExtended
Functions
_delegate
function _delegate(address account, address delegatee) internal virtual override(Votes, VotesExtended);
_transferVotingUnits
function _transferVotingUnits(address from, address to, uint256 amount)
internal
virtual
override(Votes, VotesExtended);
ERC20VotesExtendedTimestampMock
Inherits: ERC20VotesExtendedMock
Functions
clock
function clock() public view virtual override returns (uint48);
CLOCK_MODE
function CLOCK_MODE() public view virtual override returns (string memory);
ERC20VotesLegacyMock
Inherits: IVotes, ERC20Permit
Copied from the master branch at commit 86de1e8b6c3fa6b4efa4a5435869d2521be0f5f5
State Variables
_DELEGATION_TYPEHASH
bytes32 private constant _DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
_delegatee
mapping(address account => address) private _delegatee;
_checkpoints
mapping(address delegatee => Checkpoint[]) private _checkpoints;
_totalSupplyCheckpoints
Checkpoint[] private _totalSupplyCheckpoints;
Functions
checkpoints
Get the pos-th checkpoint for account.
function checkpoints(address account, uint32 pos) public view virtual returns (Checkpoint memory);
numCheckpoints
Get number of checkpoints for account.
function numCheckpoints(address account) public view virtual returns (uint32);
delegates
Get the address account is currently delegating to.
function delegates(address account) public view virtual returns (address);
getVotes
Gets the current votes balance for account
function getVotes(address account) public view virtual returns (uint256);
getPastVotes
*Retrieve the number of votes for account at the end of blockNumber.
Requirements:
blockNumbermust have been already mined*
function getPastVotes(address account, uint256 blockNumber) public view virtual returns (uint256);
getPastTotalSupply
*Retrieve the totalSupply at the end of blockNumber. Note, this value is the sum of all balances.
It is NOT the sum of all the delegated votes!
Requirements:
blockNumbermust have been already mined*
function getPastTotalSupply(uint256 blockNumber) public view virtual returns (uint256);
_checkpointsLookup
Lookup a value in a list of (sorted) checkpoints.
function _checkpointsLookup(Checkpoint[] storage ckpts, uint256 blockNumber) private view returns (uint256);
delegate
Delegate votes from the sender to delegatee.
function delegate(address delegatee) public virtual;
delegateBySig
Delegates votes from signer to delegatee
function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s)
public
virtual;
_maxSupply
Maximum token supply. Defaults to type(uint224).max (2^224^ - 1).
function _maxSupply() internal view virtual returns (uint224);
_update
Move voting power when tokens are transferred. Emits a {IVotes-DelegateVotesChanged} event.
function _update(address from, address to, uint256 amount) internal virtual override;
_delegate
Change delegation for delegator to delegatee.
Emits events {IVotes-DelegateChanged} and {IVotes-DelegateVotesChanged}.
function _delegate(address delegator, address delegatee) internal virtual;
_moveVotingPower
function _moveVotingPower(address src, address dst, uint256 amount) private;
_writeCheckpoint
function _writeCheckpoint(
Checkpoint[] storage ckpts,
function(uint256, uint256) view returns (uint256) op,
uint256 delta
) private returns (uint256 oldWeight, uint256 newWeight);
_add
function _add(uint256 a, uint256 b) private pure returns (uint256);
_subtract
function _subtract(uint256 a, uint256 b) private pure returns (uint256);
_unsafeAccess
Access an element of the array without performing bounds check. The position is assumed to be within bounds.
function _unsafeAccess(Checkpoint[] storage ckpts, uint256 pos) private pure returns (Checkpoint storage result);
Structs
Checkpoint
struct Checkpoint {
uint32 fromBlock;
uint224 votes;
}
ERC20VotesTimestampMock
Inherits: ERC20Votes
Functions
clock
function clock() public view virtual override returns (uint48);
CLOCK_MODE
function CLOCK_MODE() public view virtual override returns (string memory);
ERC721VotesTimestampMock
Inherits: ERC721Votes
Functions
clock
function clock() public view virtual override returns (uint48);
CLOCK_MODE
function CLOCK_MODE() public view virtual override returns (string memory);
ERC4626LimitsMock
Inherits: ERC4626
State Variables
_maxDeposit
uint256 _maxDeposit;
_maxMint
uint256 _maxMint;
Functions
constructor
constructor();
maxDeposit
function maxDeposit(address) public view override returns (uint256);
maxMint
function maxMint(address) public view override returns (uint256);
ERC4626Mock
Inherits: ERC4626
Functions
constructor
constructor(address underlying) ERC20("ERC4626Mock", "E4626M") ERC4626(IERC20(underlying));
mint
function mint(address account, uint256 amount) external;
burn
function burn(address account, uint256 amount) external;
ERC4626OffsetMock
Inherits: ERC4626
State Variables
_offset
uint8 private immutable _offset;
Functions
constructor
constructor(uint8 offset_);
_decimalsOffset
function _decimalsOffset() internal view virtual override returns (uint8);
ERC4626FeesMock
Inherits: ERC4626Fees
State Variables
_entryFeeBasisPointValue
uint256 private immutable _entryFeeBasisPointValue;
_entryFeeRecipientValue
address private immutable _entryFeeRecipientValue;
_exitFeeBasisPointValue
uint256 private immutable _exitFeeBasisPointValue;
_exitFeeRecipientValue
address private immutable _exitFeeRecipientValue;
Functions
constructor
constructor(
uint256 entryFeeBasisPoints,
address entryFeeRecipient,
uint256 exitFeeBasisPoints,
address exitFeeRecipient
);
_entryFeeBasisPoints
function _entryFeeBasisPoints() internal view virtual override returns (uint256);
_entryFeeRecipient
function _entryFeeRecipient() internal view virtual override returns (address);
_exitFeeBasisPoints
function _exitFeeBasisPoints() internal view virtual override returns (uint256);
_exitFeeRecipient
function _exitFeeRecipient() internal view virtual override returns (address);
ERC721ConsecutiveEnumerableMock
Inherits: ERC721Consecutive, ERC721Enumerable
Functions
constructor
constructor(string memory name, string memory symbol, address[] memory receivers, uint96[] memory amounts)
ERC721(name, symbol);
supportsInterface
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC721Enumerable) returns (bool);
_ownerOf
function _ownerOf(uint256 tokenId) internal view virtual override(ERC721, ERC721Consecutive) returns (address);
_update
function _update(address to, uint256 tokenId, address auth)
internal
virtual
override(ERC721Consecutive, ERC721Enumerable)
returns (address);
_increaseBalance
function _increaseBalance(address account, uint128 amount) internal virtual override(ERC721, ERC721Enumerable);
ERC721ConsecutiveMock
Inherits: ERC721Consecutive, ERC721Pausable, ERC721Votes
State Variables
_offset
uint96 private immutable _offset;
Functions
constructor
constructor(
string memory name,
string memory symbol,
uint96 offset,
address[] memory delegates,
address[] memory receivers,
uint96[] memory amounts
) ERC721(name, symbol) EIP712(name, "1");
_firstConsecutiveId
function _firstConsecutiveId() internal view virtual override returns (uint96);
_ownerOf
function _ownerOf(uint256 tokenId) internal view virtual override(ERC721, ERC721Consecutive) returns (address);
_update
function _update(address to, uint256 tokenId, address auth)
internal
virtual
override(ERC721Consecutive, ERC721Pausable, ERC721Votes)
returns (address);
_increaseBalance
function _increaseBalance(address account, uint128 amount) internal virtual override(ERC721, ERC721Votes);
ERC721ConsecutiveNoConstructorMintMock
Inherits: ERC721Consecutive
Functions
constructor
constructor(string memory name, string memory symbol) ERC721(name, symbol);
ERC721ReceiverMock
Inherits: IERC721Receiver
State Variables
_retval
bytes4 private immutable _retval;
_error
RevertType private immutable _error;
Functions
constructor
constructor(bytes4 retval, RevertType error);
onERC721Received
function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data) public returns (bytes4);
Events
Received
event Received(address operator, address from, uint256 tokenId, bytes data, uint256 gas);
Errors
CustomError
error CustomError(bytes4);
Enums
RevertType
enum RevertType {
None,
RevertWithoutMessage,
RevertWithMessage,
RevertWithCustomError,
Panic
}
ERC721URIStorageMock
Inherits: ERC721URIStorage
State Variables
_baseTokenURI
string private _baseTokenURI;
Functions
_baseURI
function _baseURI() internal view virtual override returns (string memory);
setBaseURI
function setBaseURI(string calldata newBaseTokenURI) public;
Contents
Contents
ERC7739ECDSAMock
Inherits: ERC7739, SignerECDSA
ERC7739P256Mock
Inherits: ERC7739, SignerP256
ERC7739RSAMock
AccessManagedTarget
Inherits: AccessManaged
Functions
fnRestricted
function fnRestricted() public restricted;
fnUnrestricted
function fnUnrestricted() public;
setIsConsumingScheduledOp
function setIsConsumingScheduledOp(bool isConsuming, bytes32 slot) external;
fallback
fallback() external;
Events
CalledRestricted
event CalledRestricted(address caller);
CalledUnrestricted
event CalledUnrestricted(address caller);
CalledFallback
event CalledFallback(address caller);
AccessManagerMock
Inherits: AccessManager
Functions
constructor
constructor(address initialAdmin) AccessManager(initialAdmin);
fnRestricted
function fnRestricted() public onlyAuthorized;
fnUnrestricted
function fnUnrestricted() public;
Events
CalledRestricted
event CalledRestricted(address caller);
CalledUnrestricted
event CalledUnrestricted(address caller);
Uint256ArraysMock
State Variables
_array
uint256[] private _array;
Functions
constructor
constructor(uint256[] memory array);
findUpperBound
function findUpperBound(uint256 value) external view returns (uint256);
lowerBound
function lowerBound(uint256 value) external view returns (uint256);
upperBound
function upperBound(uint256 value) external view returns (uint256);
lowerBoundMemory
function lowerBoundMemory(uint256[] memory array, uint256 value) external pure returns (uint256);
upperBoundMemory
function upperBoundMemory(uint256[] memory array, uint256 value) external pure returns (uint256);
unsafeAccess
function unsafeAccess(uint256 pos) external view returns (uint256);
sort
function sort(uint256[] memory array) external pure returns (uint256[] memory);
sortReverse
function sortReverse(uint256[] memory array) external pure returns (uint256[] memory);
_reverse
function _reverse(uint256 a, uint256 b) private pure returns (bool);
unsafeSetLength
function unsafeSetLength(uint256 newLength) external;
length
function length() external view returns (uint256);
AddressArraysMock
State Variables
_array
address[] private _array;
Functions
constructor
constructor(address[] memory array);
unsafeAccess
function unsafeAccess(uint256 pos) external view returns (address);
sort
function sort(address[] memory array) external pure returns (address[] memory);
sortReverse
function sortReverse(address[] memory array) external pure returns (address[] memory);
_reverse
function _reverse(address a, address b) private pure returns (bool);
unsafeSetLength
function unsafeSetLength(uint256 newLength) external;
length
function length() external view returns (uint256);
Bytes32ArraysMock
State Variables
_array
bytes32[] private _array;
Functions
constructor
constructor(bytes32[] memory array);
unsafeAccess
function unsafeAccess(uint256 pos) external view returns (bytes32);
sort
function sort(bytes32[] memory array) external pure returns (bytes32[] memory);
sortReverse
function sortReverse(bytes32[] memory array) external pure returns (bytes32[] memory);
_reverse
function _reverse(bytes32 a, bytes32 b) private pure returns (bool);
unsafeSetLength
function unsafeSetLength(uint256 newLength) external;
length
function length() external view returns (uint256);
BytesArraysMock
State Variables
_array
bytes[] private _array;
Functions
constructor
constructor(bytes[] memory array);
unsafeAccess
function unsafeAccess(uint256 pos) external view returns (bytes memory);
unsafeSetLength
function unsafeSetLength(uint256 newLength) external;
length
function length() external view returns (uint256);
StringArraysMock
State Variables
_array
string[] private _array;
Functions
constructor
constructor(string[] memory array);
unsafeAccess
function unsafeAccess(uint256 pos) external view returns (string memory);
unsafeSetLength
function unsafeSetLength(uint256 newLength) external;
length
function length() external view returns (uint256);
NotAuthorityMock
Inherits: IAuthority
Functions
canCall
function canCall(address, address, bytes4) external pure returns (bool);
AuthorityNoDelayMock
Inherits: IAuthority
State Variables
_immediate
bool private _immediate;
Functions
canCall
function canCall(address, address, bytes4) external view returns (bool immediate);
_setImmediate
function _setImmediate(bool immediate) external;
AuthorityDelayMock
State Variables
_immediate
bool private _immediate;
_delay
uint256 private _delay;
Functions
canCall
function canCall(address, address, bytes4) external view returns (bool immediate, uint256 delay);
_setImmediate
function _setImmediate(bool immediate) external;
_setDelay
function _setDelay(uint256 delay) external;
AuthorityNoResponse
Functions
canCall
function canCall(address, address, bytes4) external view;
AuthorityObserveIsConsuming
Functions
canCall
function canCall(address, address, bytes4) external pure returns (bool immediate, uint32 delay);
consumeScheduledOp
function consumeScheduledOp(address caller, bytes memory data) public;
Events
ConsumeScheduledOpCalled
event ConsumeScheduledOpCalled(address caller, bytes data, bytes4 isConsuming);
Base64Dirty
Functions
encode
function encode(bytes memory input) public pure returns (string memory);
Structs
A
struct A {
uint256 value;
}
BatchCaller
Functions
execute
function execute(Call[] calldata calls) external returns (bytes[] memory);
Structs
Call
struct Call {
address target;
uint256 value;
bytes data;
}
CallReceiverMock
State Variables
_array
uint256[] private _array;
Functions
mockFunction
function mockFunction() public payable returns (string memory);
mockFunctionEmptyReturn
function mockFunctionEmptyReturn() public payable;
mockFunctionWithArgs
function mockFunctionWithArgs(uint256 a, uint256 b) public payable returns (string memory);
mockFunctionNonPayable
function mockFunctionNonPayable() public returns (string memory);
mockStaticFunction
function mockStaticFunction() public pure returns (string memory);
mockFunctionRevertsNoReason
function mockFunctionRevertsNoReason() public payable;
mockFunctionRevertsReason
function mockFunctionRevertsReason() public payable;
mockFunctionThrows
function mockFunctionThrows() public payable;
mockFunctionOutOfGas
function mockFunctionOutOfGas() public payable;
mockFunctionWritesStorage
function mockFunctionWritesStorage(bytes32 slot, bytes32 value) public returns (string memory);
mockFunctionExtra
function mockFunctionExtra() public payable;
Events
MockFunctionCalled
event MockFunctionCalled();
MockFunctionCalledWithArgs
event MockFunctionCalledWithArgs(uint256 a, uint256 b);
MockFunctionCalledExtra
event MockFunctionCalledExtra(address caller, uint256 value);
CallReceiverMockTrustingForwarder
Inherits: CallReceiverMock
State Variables
_trustedForwarder
address private _trustedForwarder;
Functions
constructor
constructor(address trustedForwarder_);
isTrustedForwarder
function isTrustedForwarder(address forwarder) public view virtual returns (bool);
ConstructorMock
State Variables
foo
bool foo;
Functions
constructor
constructor(RevertType error);
Errors
CustomError
error CustomError();
Enums
RevertType
enum RevertType {
None,
RevertWithoutMessage,
RevertWithMessage,
RevertWithCustomError,
Panic
}
ContextMock
Inherits: Context
Functions
msgSender
function msgSender() public;
msgData
function msgData(uint256 integerValue, string memory stringValue) public;
msgDataShort
function msgDataShort() public;
Events
Sender
event Sender(address sender);
Data
event Data(bytes data, uint256 integerValue, string stringValue);
DataShort
event DataShort(bytes data);
ContextMockCaller
Functions
callSender
function callSender(ContextMock context) public;
callData
function callData(ContextMock context, uint256 integerValue, string memory stringValue) public;
Impl
Functions
version
function version() public pure virtual returns (string memory);
DummyImplementation
State Variables
value
uint256 public value;
text
string public text;
values
uint256[] public values;
Functions
initializeNonPayable
function initializeNonPayable() public;
initializePayable
function initializePayable() public payable;
initializeNonPayableWithValue
function initializeNonPayableWithValue(uint256 _value) public;
initializePayableWithValue
function initializePayableWithValue(uint256 _value) public payable;
initialize
function initialize(uint256 _value, string memory _text, uint256[] memory _values) public;
get
function get() public pure returns (bool);
version
function version() public pure virtual returns (string memory);
reverts
function reverts() public pure;
unsafeOverrideAdmin
function unsafeOverrideAdmin(address newAdmin) public;
DummyImplementationV2
Inherits: DummyImplementation
Functions
migrate
function migrate(uint256 newVal) public payable;
version
function version() public pure override returns (string memory);
EIP712Verifier
Inherits: EIP712
Functions
verify
function verify(bytes memory signature, address signer, address mailTo, string memory mailContents) external view;
ERC1271WalletMock
Functions
constructor
constructor(address originalOwner) Ownable(originalOwner);
isValidSignature
function isValidSignature(bytes32 hash, bytes memory signature) public view returns (bytes4 magicValue);
ERC1271MaliciousMock
Inherits: IERC1271
Functions
isValidSignature
function isValidSignature(bytes32, bytes memory) public pure returns (bytes4);
ERC2771ContextMock
Inherits: ContextMock, ERC2771Context, Multicall
Functions
constructor
Note: oz-upgrades-unsafe-allow: constructor
constructor(address trustedForwarder) ERC2771Context(trustedForwarder);
_msgSender
function _msgSender() internal view override(Context, ERC2771Context) returns (address);
_msgData
function _msgData() internal view override(Context, ERC2771Context) returns (bytes calldata);
_contextSuffixLength
function _contextSuffixLength() internal view override(Context, ERC2771Context) returns (uint256);
ERC3156FlashBorrowerMock
Inherits: IERC3156FlashBorrower
WARNING: this IERC3156FlashBorrower mock implementation is for testing purposes ONLY. Writing a secure flash lock borrower is not an easy task, and should be done with the utmost care. This is not an example of how it should be done, and no pattern present in this mock should be considered secure. Following best practices, always have your contract properly audited before using them to manipulate important funds on live networks.
State Variables
_RETURN_VALUE
bytes32 internal constant _RETURN_VALUE = keccak256("ERC3156FlashBorrower.onFlashLoan");
_enableApprove
bool immutable _enableApprove;
_enableReturn
bool immutable _enableReturn;
Functions
constructor
constructor(bool enableReturn, bool enableApprove);
onFlashLoan
function onFlashLoan(address, address token, uint256 amount, uint256 fee, bytes calldata data)
public
returns (bytes32);
Events
BalanceOf
event BalanceOf(address token, address account, uint256 value);
TotalSupply
event TotalSupply(address token, uint256 value);
EtherReceiverMock
State Variables
_acceptEther
bool private _acceptEther;
Functions
setAcceptEther
function setAcceptEther(bool acceptEther) public;
receive
receive() external payable;
InitializableMock
Inherits: Initializable
This contract is a mock to test initializable functionality
State Variables
initializerRan
bool public initializerRan;
onlyInitializingRan
bool public onlyInitializingRan;
x
uint256 public x;
Functions
isInitializing
function isInitializing() public view returns (bool);
initialize
function initialize() public initializer;
initializeOnlyInitializing
function initializeOnlyInitializing() public onlyInitializing;
initializerNested
function initializerNested() public initializer;
onlyInitializingNested
function onlyInitializingNested() public initializer;
initializeWithX
function initializeWithX(uint256 _x) public payable initializer;
nonInitializable
function nonInitializable(uint256 _x) public payable;
fail
function fail() public pure;
ConstructorInitializableMock
Inherits: Initializable
State Variables
initializerRan
bool public initializerRan;
onlyInitializingRan
bool public onlyInitializingRan;
Functions
constructor
constructor() initializer;
initialize
function initialize() public initializer;
initializeOnlyInitializing
function initializeOnlyInitializing() public onlyInitializing;
ChildConstructorInitializableMock
Inherits: ConstructorInitializableMock
State Variables
childInitializerRan
bool public childInitializerRan;
Functions
constructor
constructor() initializer;
childInitialize
function childInitialize() public initializer;
ReinitializerMock
Inherits: Initializable
State Variables
counter
uint256 public counter;
Functions
getInitializedVersion
function getInitializedVersion() public view returns (uint64);
initialize
function initialize() public initializer;
reinitialize
function reinitialize(uint64 i) public reinitializer(i);
nestedReinitialize
function nestedReinitialize(uint64 i, uint64 j) public reinitializer(i);
chainReinitialize
function chainReinitialize(uint64 i, uint64 j) public;
disableInitializers
function disableInitializers() public;
doStuff
function doStuff() public onlyInitializing;
DisableNew
Inherits: Initializable
Functions
constructor
constructor();
DisableOld
Inherits: Initializable
Functions
constructor
constructor() initializer;
DisableBad1
Inherits: DisableNew, DisableOld
DisableBad2
Inherits: Initializable
Functions
constructor
constructor() initializer;
DisableOk
Inherits: DisableOld, DisableNew
MerkleProofCustomHashMock
Functions
customHash
function customHash(bytes32 a, bytes32 b) internal pure returns (bytes32);
verify
function verify(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal view returns (bool);
processProof
function processProof(bytes32[] calldata proof, bytes32 leaf) internal view returns (bytes32);
verifyCalldata
function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal view returns (bool);
processProofCalldata
function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal view returns (bytes32);
multiProofVerify
function multiProofVerify(bytes32[] calldata proof, bool[] calldata proofFlags, bytes32 root, bytes32[] calldata leaves)
internal
view
returns (bool);
processMultiProof
function processMultiProof(bytes32[] calldata proof, bool[] calldata proofFlags, bytes32[] calldata leaves)
internal
view
returns (bytes32);
multiProofVerifyCalldata
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] calldata leaves
) internal view returns (bool);
processMultiProofCalldata
function processMultiProofCalldata(bytes32[] calldata proof, bool[] calldata proofFlags, bytes32[] calldata leaves)
internal
view
returns (bytes32);
MerkleTreeMock
State Variables
_tree
MerkleTree.Bytes32PushTree private _tree;
root
bytes32 public root;
Functions
setup
function setup(uint8 _depth, bytes32 _zero) public;
push
function push(bytes32 leaf) public;
update
function update(uint256 index, bytes32 oldValue, bytes32 newValue, bytes32[] memory proof) public;
depth
function depth() public view returns (uint256);
nextLeafIndex
function nextLeafIndex() public view returns (uint256);
sides
function sides(uint256 i) public view returns (bytes32);
zeros
function zeros(uint256 i) public view returns (bytes32);
Events
LeafInserted
event LeafInserted(bytes32 leaf, uint256 index, bytes32 root);
LeafUpdated
event LeafUpdated(bytes32 oldLeaf, bytes32 newLeaf, uint256 index, bytes32 root);
MulticallHelper
Functions
checkReturnValues
function checkReturnValues(ERC20MulticallMock multicallToken, address[] calldata recipients, uint256[] calldata amounts)
external;
SampleHuman
Inherits: Initializable
Sample base initializable contract that is a human
State Variables
isHuman
bool public isHuman;
Functions
initialize
function initialize() public initializer;
__SampleHuman_init
function __SampleHuman_init() internal onlyInitializing;
__SampleHuman_init_unchained
function __SampleHuman_init_unchained() internal onlyInitializing;
SampleMother
Inherits: Initializable, SampleHuman
Sample base initializable contract that defines a field mother
State Variables
mother
uint256 public mother;
Functions
initialize
function initialize(uint256 value) public initializer;
__SampleMother_init
function __SampleMother_init(uint256 value) internal onlyInitializing;
__SampleMother_init_unchained
function __SampleMother_init_unchained(uint256 value) internal onlyInitializing;
SampleGramps
Inherits: Initializable, SampleHuman
Sample base initializable contract that defines a field gramps
State Variables
gramps
string public gramps;
Functions
initialize
function initialize(string memory value) public initializer;
__SampleGramps_init
function __SampleGramps_init(string memory value) internal onlyInitializing;
__SampleGramps_init_unchained
function __SampleGramps_init_unchained(string memory value) internal onlyInitializing;
SampleFather
Inherits: Initializable, SampleGramps
Sample base initializable contract that defines a field father and extends from gramps
State Variables
father
uint256 public father;
Functions
initialize
function initialize(string memory _gramps, uint256 _father) public initializer;
__SampleFather_init
function __SampleFather_init(string memory _gramps, uint256 _father) internal onlyInitializing;
__SampleFather_init_unchained
function __SampleFather_init_unchained(uint256 _father) internal onlyInitializing;
SampleChild
Inherits: Initializable, SampleMother, SampleFather
Child extends from mother, father (gramps)
State Variables
child
uint256 public child;
Functions
initialize
function initialize(uint256 _mother, string memory _gramps, uint256 _father, uint256 _child) public initializer;
__SampleChild_init
function __SampleChild_init(uint256 _mother, string memory _gramps, uint256 _father, uint256 _child)
internal
onlyInitializing;
__SampleChild_init_unchained
function __SampleChild_init_unchained(uint256 _child) internal onlyInitializing;
PausableMock
Inherits: Pausable
State Variables
drasticMeasureTaken
bool public drasticMeasureTaken;
count
uint256 public count;
Functions
constructor
constructor();
normalProcess
function normalProcess() external whenNotPaused;
drasticMeasure
function drasticMeasure() external whenPaused;
pause
function pause() external;
unpause
function unpause() external;
ReentrancyAttack
Inherits: Context
Functions
callSender
function callSender(bytes calldata data) public;
ReentrancyMock
Inherits: ReentrancyGuard
State Variables
counter
uint256 public counter;
Functions
constructor
constructor();
callback
function callback() external nonReentrant;
countLocalRecursive
function countLocalRecursive(uint256 n) public nonReentrant;
countThisRecursive
function countThisRecursive(uint256 n) public nonReentrant;
countAndCall
function countAndCall(ReentrancyAttack attacker) public nonReentrant;
_count
function _count() private;
guardedCheckEntered
function guardedCheckEntered() public nonReentrant;
unguardedCheckNotEntered
function unguardedCheckNotEntered() public view;
ReentrancyTransientMock
Inherits: ReentrancyGuardTransient
State Variables
counter
uint256 public counter;
Functions
constructor
constructor();
callback
function callback() external nonReentrant;
countLocalRecursive
function countLocalRecursive(uint256 n) public nonReentrant;
countThisRecursive
function countThisRecursive(uint256 n) public nonReentrant;
countAndCall
function countAndCall(ReentrancyAttack attacker) public nonReentrant;
_count
function _count() private;
guardedCheckEntered
function guardedCheckEntered() public nonReentrant;
unguardedCheckNotEntered
function unguardedCheckNotEntered() public view;
Implementation1
Inherits: Initializable
State Variables
_value
uint256 internal _value;
Functions
initialize
function initialize() public initializer;
setValue
function setValue(uint256 _number) public;
Implementation2
Inherits: Initializable
State Variables
_value
uint256 internal _value;
Functions
initialize
function initialize() public initializer;
setValue
function setValue(uint256 _number) public;
getValue
function getValue() public view returns (uint256);
Implementation3
Inherits: Initializable
State Variables
_value
uint256 internal _value;
Functions
initialize
function initialize() public initializer;
setValue
function setValue(uint256 _number) public;
getValue
function getValue(uint256 _number) public view returns (uint256);
Implementation4
Inherits: Initializable
State Variables
_value
uint256 internal _value;
Functions
initialize
function initialize() public initializer;
setValue
function setValue(uint256 _number) public;
getValue
function getValue() public view returns (uint256);
fallback
fallback() external;
MigratableMockV1
Inherits: Initializable
This contract is a mock to test initializable functionality through migrations
State Variables
x
uint256 public x;
Functions
initialize
function initialize(uint256 value) public payable initializer;
MigratableMockV2
Inherits: MigratableMockV1
This contract is a mock to test migratable functionality with params
State Variables
_migratedV2
bool internal _migratedV2;
y
uint256 public y;
Functions
migrate
function migrate(uint256 value, uint256 anotherValue) public payable;
MigratableMockV3
Inherits: MigratableMockV2
This contract is a mock to test migratable functionality without params
State Variables
_migratedV3
bool internal _migratedV3;
Functions
migrate
function migrate() public payable;
Dummy1234
StorageSlotMock
Inherits: Multicall
State Variables
stringMap
mapping(uint256 key => string) public stringMap;
bytesMap
mapping(uint256 key => bytes) public bytesMap;
Functions
setAddressSlot
function setAddressSlot(bytes32 slot, address value) public;
setBooleanSlot
function setBooleanSlot(bytes32 slot, bool value) public;
setBytes32Slot
function setBytes32Slot(bytes32 slot, bytes32 value) public;
setUint256Slot
function setUint256Slot(bytes32 slot, uint256 value) public;
setInt256Slot
function setInt256Slot(bytes32 slot, int256 value) public;
getAddressSlot
function getAddressSlot(bytes32 slot) public view returns (address);
getBooleanSlot
function getBooleanSlot(bytes32 slot) public view returns (bool);
getBytes32Slot
function getBytes32Slot(bytes32 slot) public view returns (bytes32);
getUint256Slot
function getUint256Slot(bytes32 slot) public view returns (uint256);
getInt256Slot
function getInt256Slot(bytes32 slot) public view returns (int256);
setStringSlot
function setStringSlot(bytes32 slot, string calldata value) public;
setStringStorage
function setStringStorage(uint256 key, string calldata value) public;
getStringSlot
function getStringSlot(bytes32 slot) public view returns (string memory);
getStringStorage
function getStringStorage(uint256 key) public view returns (string memory);
setBytesSlot
function setBytesSlot(bytes32 slot, bytes calldata value) public;
setBytesStorage
function setBytesStorage(uint256 key, bytes calldata value) public;
getBytesSlot
function getBytesSlot(bytes32 slot) public view returns (bytes memory);
getBytesStorage
function getBytesStorage(uint256 key) public view returns (bytes memory);
TimelockReentrant
State Variables
_reenterTarget
address private _reenterTarget;
_reenterData
bytes private _reenterData;
_reentered
bool _reentered;
Functions
disableReentrancy
function disableReentrancy() external;
enableRentrancy
function enableRentrancy(address target, bytes calldata data) external;
reenter
function reenter() external;
TransientSlotMock
Inherits: Multicall
Functions
tloadAddress
function tloadAddress(bytes32 slot) public;
tstore
function tstore(bytes32 slot, address value) public;
tloadBoolean
function tloadBoolean(bytes32 slot) public;
tstore
function tstore(bytes32 slot, bool value) public;
tloadBytes32
function tloadBytes32(bytes32 slot) public;
tstore
function tstore(bytes32 slot, bytes32 value) public;
tloadUint256
function tloadUint256(bytes32 slot) public;
tstore
function tstore(bytes32 slot, uint256 value) public;
tloadInt256
function tloadInt256(bytes32 slot) public;
tstore
function tstore(bytes32 slot, int256 value) public;
Events
AddressValue
event AddressValue(bytes32 slot, address value);
BooleanValue
event BooleanValue(bytes32 slot, bool value);
Bytes32Value
event Bytes32Value(bytes32 slot, bytes32 value);
Uint256Value
event Uint256Value(bytes32 slot, uint256 value);
Int256Value
event Int256Value(bytes32 slot, int256 value);
UpgradeableBeaconMock
Inherits: IBeacon
State Variables
implementation
address public implementation;
Functions
constructor
constructor(address impl);
IProxyExposed
Functions
$getBeacon
function $getBeacon() external view returns (address);
UpgradeableBeaconReentrantMock
Inherits: IBeacon
Functions
implementation
function implementation() external view override returns (address);
Errors
BeaconProxyBeaconSlotAddress
error BeaconProxyBeaconSlotAddress(address beacon);
VotesExtendedMock
Inherits: VotesExtended
State Variables
_votingUnits
mapping(address voter => uint256) private _votingUnits;
Functions
getTotalSupply
function getTotalSupply() public view returns (uint256);
delegate
function delegate(address account, address newDelegation) public;
_getVotingUnits
function _getVotingUnits(address account) internal view override returns (uint256);
_mint
function _mint(address account, uint256 votes) internal;
_burn
function _burn(address account, uint256 votes) internal;
VotesExtendedTimestampMock
Inherits: VotesExtendedMock
Functions
clock
function clock() public view override returns (uint48);
CLOCK_MODE
function CLOCK_MODE() public view virtual override returns (string memory);
VotesMock
Inherits: Votes
State Variables
_votingUnits
mapping(address voter => uint256) private _votingUnits;
Functions
getTotalSupply
function getTotalSupply() public view returns (uint256);
delegate
function delegate(address account, address newDelegation) public;
_getVotingUnits
function _getVotingUnits(address account) internal view override returns (uint256);
_mint
function _mint(address account, uint256 votes) internal;
_burn
function _burn(address account, uint256 votes) internal;
VotesTimestampMock
Inherits: VotesMock
Functions
clock
function clock() public view override returns (uint48);
CLOCK_MODE
function CLOCK_MODE() public view virtual override returns (string memory);
Contents
Contents
ERC1967Proxy
Inherits: Proxy
This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an implementation address that can be changed. This address is stored in storage in the location specified by https://eips.ethereum.org/EIPS/eip-1967[ERC-1967], so that it doesn't conflict with the storage layout of the implementation behind the proxy.
Functions
constructor
*Initializes the upgradeable proxy with an initial implementation specified by implementation.
If _data is nonempty, it's used as data in a delegate call to implementation. This will typically be an
encoded function call, and allows initializing the storage of the proxy like a Solidity constructor.
Requirements:
- If
datais empty,msg.valuemust be zero.*
constructor(address implementation, bytes memory _data) payable;
_implementation
Returns the current implementation address.
TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using
the https://eth.wiki/json-rpc/API#eth_getstorageat[eth_getStorageAt] RPC call.
0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc
function _implementation() internal view virtual override returns (address);
ERC1967Utils
This library provides getters and event emitting update functions for https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots.
State Variables
IMPLEMENTATION_SLOT
Storage slot with the address of the current implementation. This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
ADMIN_SLOT
Storage slot with the admin of the contract. This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
BEACON_SLOT
The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
Functions
getImplementation
Returns the current implementation address.
function getImplementation() internal view returns (address);
_setImplementation
Stores a new address in the ERC-1967 implementation slot.
function _setImplementation(address newImplementation) private;
upgradeToAndCall
Performs implementation upgrade with additional setup call if data is nonempty.
This function is payable only if the setup call is performed, otherwise msg.value is rejected
to avoid stuck value in the contract.
Emits an {IERC1967-Upgraded} event.
function upgradeToAndCall(address newImplementation, bytes memory data) internal;
getAdmin
Returns the current admin.
TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using
the https://eth.wiki/json-rpc/API#eth_getstorageat[eth_getStorageAt] RPC call.
0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103
function getAdmin() internal view returns (address);
_setAdmin
Stores a new address in the ERC-1967 admin slot.
function _setAdmin(address newAdmin) private;
changeAdmin
Changes the admin of the proxy. Emits an {IERC1967-AdminChanged} event.
function changeAdmin(address newAdmin) internal;
getBeacon
Returns the current beacon.
function getBeacon() internal view returns (address);
_setBeacon
Stores a new beacon in the ERC-1967 beacon slot.
function _setBeacon(address newBeacon) private;
upgradeBeaconToAndCall
Change the beacon and trigger a setup call if data is nonempty.
This function is payable only if the setup call is performed, otherwise msg.value is rejected
to avoid stuck value in the contract.
Emits an {IERC1967-BeaconUpgraded} event.
CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
efficiency.
function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal;
_checkNonPayable
Reverts if msg.value is not zero. It can be used to avoid msg.value stuck in the contract
if an upgrade doesn't perform an initialization call.
function _checkNonPayable() private;
Errors
ERC1967InvalidImplementation
The implementation of the proxy is invalid.
error ERC1967InvalidImplementation(address implementation);
ERC1967InvalidAdmin
The admin of the proxy is invalid.
error ERC1967InvalidAdmin(address admin);
ERC1967InvalidBeacon
The beacon of the proxy is invalid.
error ERC1967InvalidBeacon(address beacon);
ERC1967NonPayable
An upgrade function sees msg.value > 0 that may be lost.
error ERC1967NonPayable();
Contents
BeaconProxy
Inherits: Proxy
This contract implements a proxy that gets the implementation address for each call from an {UpgradeableBeacon}. The beacon address can only be set once during construction, and cannot be changed afterwards. It is stored in an immutable variable to avoid unnecessary storage reads, and also in the beacon storage slot specified by https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] so that it can be accessed externally. CAUTION: Since the beacon address can never be changed, you must ensure that you either control the beacon, or trust the beacon to not upgrade the implementation maliciously. IMPORTANT: Do not use the implementation logic to modify the beacon storage slot. Doing so would leave the proxy in an inconsistent state where the beacon storage slot does not match the beacon address.
State Variables
_beacon
address private immutable _beacon;
Functions
constructor
*Initializes the proxy with beacon.
If data is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This
will typically be an encoded function call, and allows initializing the storage of the proxy like a Solidity
constructor.
Requirements:
beaconmust be a contract with the interface {IBeacon}.- If
datais empty,msg.valuemust be zero.*
constructor(address beacon, bytes memory data) payable;
_implementation
Returns the current implementation address of the associated beacon.
function _implementation() internal view virtual override returns (address);
_getBeacon
Returns the beacon.
function _getBeacon() internal view virtual returns (address);
IBeacon
This is the interface that {BeaconProxy} expects of its beacon.
Functions
implementation
Must return an address that can be used as a delegate call target. {UpgradeableBeacon} will check that this address is a contract.
function implementation() external view returns (address);
UpgradeableBeacon
This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their implementation contract, which is where they will delegate all function calls. An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.
State Variables
_implementation
address private _implementation;
Functions
constructor
Sets the address of the initial implementation, and the initial owner who can upgrade the beacon.
constructor(address implementation_, address initialOwner) Ownable(initialOwner);
implementation
Returns the current implementation address.
function implementation() public view virtual returns (address);
upgradeTo
*Upgrades the beacon to a new implementation. Emits an Upgraded event. Requirements:
- msg.sender must be the owner of the contract.
newImplementationmust be a contract.*
function upgradeTo(address newImplementation) public virtual onlyOwner;
_setImplementation
*Sets the implementation contract address for this beacon Requirements:
newImplementationmust be a contract.*
function _setImplementation(address newImplementation) private;
Events
Upgraded
Emitted when the implementation returned by the beacon is changed.
event Upgraded(address indexed implementation);
Errors
BeaconInvalidImplementation
The implementation of the beacon is invalid.
error BeaconInvalidImplementation(address implementation);
Contents
ProxyAdmin
Inherits: Ownable
This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.
State Variables
UPGRADE_INTERFACE_VERSION
The version of the upgrade interface of the contract. If this getter is missing, both upgrade(address,address)
and upgradeAndCall(address,address,bytes) are present, and upgrade must be used if no function should be called,
while upgradeAndCall will invoke the receive function if the third argument is the empty byte string.
If the getter returns "5.0.0", only upgradeAndCall(address,address,bytes) is present, and the third argument must
be the empty byte string if no function should be called, making it impossible to invoke the receive function
during an upgrade.
string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";
Functions
constructor
Sets the initial owner who can perform upgrades.
constructor(address initialOwner) Ownable(initialOwner);
upgradeAndCall
*Upgrades proxy to implementation and calls a function on the new implementation.
See TransparentUpgradeableProxy-_dispatchUpgradeToAndCall.
Requirements:
- This contract must be the admin of
proxy. - If
datais empty,msg.valuemust be zero.*
function upgradeAndCall(ITransparentUpgradeableProxy proxy, address implementation, bytes memory data)
public
payable
virtual
onlyOwner;
ITransparentUpgradeableProxy
Inherits: IERC1967
Interface for {TransparentUpgradeableProxy}. In order to implement transparency, {TransparentUpgradeableProxy} does not implement this interface directly, and its upgradeability mechanism is implemented by an internal dispatch mechanism. The compiler is unaware that these functions are implemented by {TransparentUpgradeableProxy} and will not include them in the ABI so this interface must be used to interact with it.
Functions
upgradeToAndCall
See UUPSUpgradeable-upgradeToAndCall
function upgradeToAndCall(address newImplementation, bytes calldata data) external payable;
TransparentUpgradeableProxy
Inherits: ERC1967Proxy
*This contract implements a proxy that is upgradeable through an associated {ProxyAdmin} instance. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand:
- If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches the {ITransparentUpgradeableProxy-upgradeToAndCall} function exposed by the proxy itself.
- If the admin calls the proxy, it can call the
upgradeToAndCallfunction but any other call won't be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error indicating the proxy admin cannot fallback to the target implementation. These properties mean that the admin account can only be used for upgrading the proxy, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. For this reason, the proxy deploys an instance of {ProxyAdmin} and allows upgrades only if they come through it. You should think of theProxyAdmininstance as the administrative interface of the proxy, including the ability to change who can trigger upgrades by transferring ownership. NOTE: The real interface of this proxy is that defined inITransparentUpgradeableProxy. This contract does not inherit from that interface, and insteadupgradeToAndCallis implicitly implemented using a custom dispatch mechanism in_fallback. Consequently, the compiler will not produce an ABI for this contract. This is necessary to fully implement transparency without decoding reverts caused by selector clashes between the proxy and the implementation. NOTE: This proxy does not inherit from {Context} deliberately. The {ProxyAdmin} of this contract won't send a meta-transaction in any way, and any other meta-transaction setup should be made in the implementation contract. IMPORTANT: This contract avoids unnecessary storage reads by setting the admin only during construction as an immutable variable, preventing any changes thereafter. However, the admin slot defined in ERC-1967 can still be overwritten by the implementation logic pointed to by this proxy. In such cases, the contract may end up in an undesirable state where the admin slot is different from the actual admin. Relying on the value of the admin slot is generally fine if the implementation is trusted. WARNING: It is not recommended to extend this contract to add additional external functions. If you do so, the compiler will not check that there are no selector conflicts, due to the note above. A selector clash between any new function and the functions declared in {ITransparentUpgradeableProxy} will be resolved in favor of the new one. This could render theupgradeToAndCallfunction inaccessible, preventing upgradeability and compromising transparency.*
State Variables
_admin
address private immutable _admin;
Functions
constructor
Initializes an upgradeable proxy managed by an instance of a {ProxyAdmin} with an initialOwner,
backed by the implementation at _logic, and optionally initialized with _data as explained in
{ERC1967Proxy-constructor}.
constructor(address _logic, address initialOwner, bytes memory _data) payable ERC1967Proxy(_logic, _data);
_proxyAdmin
Returns the admin of this proxy.
function _proxyAdmin() internal view virtual returns (address);
_fallback
If caller is the admin process the call internally, otherwise transparently fallback to the proxy behavior.
function _fallback() internal virtual override;
_dispatchUpgradeToAndCall
*Upgrade the implementation of the proxy. See ERC1967Utils-upgradeToAndCall. Requirements:
- If
datais empty,msg.valuemust be zero.*
function _dispatchUpgradeToAndCall() private;
Errors
ProxyDeniedAdminAccess
The proxy caller is the current admin, and can't fallback to the proxy target.
error ProxyDeniedAdminAccess();
Contents
Initializable
*This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
external initializer function, usually called initialize. It then becomes necessary to protect this initializer
function so it can only be called once. The initializer modifier provided by this contract will have this effect.
The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
case an upgrade adds a module that needs to be initialized.
For example:
[.hljs-theme-light.nopadding]
contract MyToken is ERC20Upgradeable {
function initialize() initializer public {
__ERC20_init("MyToken", "MTK");
}
}
contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
function initializeV2() reinitializer(2) public {
__ERC20Permit_init("MyToken");
}
}
TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
possible by providing the encoded function call as the _data argument to {ERC1967Proxy-constructor}.
CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
[CAUTION]
Avoid leaving a contract uninitialized. An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: [.hljs-theme-light.nopadding]
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
====*
State Variables
INITIALIZABLE_STORAGE
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
Functions
initializer
A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
onlyInitializing functions can be used to initialize parent contracts.
Similar to reinitializer(1), except that in the context of a constructor an initializer may be invoked any
number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
production.
Emits an Initialized event.
modifier initializer();
reinitializer
A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
contract hasn't been initialized to a greater version before. In its scope, onlyInitializing functions can be
used to initialize parent contracts.
A reinitializer may be used after the original initialization step. This is essential to configure modules that
are added through upgrades and that require initialization.
When version is 1, this modifier is similar to initializer, except that functions marked with reinitializer
cannot be nested. If one is invoked in the context of another, execution will revert.
Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
a contract, executing them in the right order is up to the developer or operator.
WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
Emits an Initialized event.
modifier reinitializer(uint64 version);
onlyInitializing
Modifier to protect an initialization function so that it can only be invoked by functions with the initializer and {reinitializer} modifiers, directly or indirectly.
modifier onlyInitializing();
_checkInitializing
Reverts if the contract is not in an initializing state. See onlyInitializing.
function _checkInitializing() internal view virtual;
_disableInitializers
Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized to any version. It is recommended to use this to lock implementation contracts that are designed to be called through proxies. Emits an Initialized event the first time it is successfully executed.
function _disableInitializers() internal virtual;
_getInitializedVersion
Returns the highest version that has been initialized. See reinitializer.
function _getInitializedVersion() internal view returns (uint64);
_isInitializing
Returns true if the contract is currently initializing. See onlyInitializing.
function _isInitializing() internal view returns (bool);
_initializableStorageSlot
Pointer to storage slot. Allows integrators to override it with a custom storage location. NOTE: Consider following the ERC-7201 formula to derive storage locations.
function _initializableStorageSlot() internal pure virtual returns (bytes32);
_getInitializableStorage
Returns a pointer to the storage namespace.
function _getInitializableStorage() private pure returns (InitializableStorage storage $);
Events
Initialized
Triggered when the contract has been initialized or reinitialized.
event Initialized(uint64 version);
Errors
InvalidInitialization
The contract is already initialized.
error InvalidInitialization();
NotInitializing
The contract is not initializing.
error NotInitializing();
Structs
InitializableStorage
Storage of the initializable contract. It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions when using with upgradeable contracts.
Note: storage-location: erc7201:openzeppelin.storage.Initializable
struct InitializableStorage {
uint64 _initialized;
bool _initializing;
}
UUPSUpgradeable
Inherits: IERC1822Proxiable
An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
{ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
UUPSUpgradeable with a custom implementation of upgrades.
The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
State Variables
__self
Note: oz-upgrades-unsafe-allow: state-variable-immutable
address private immutable __self = address(this);
UPGRADE_INTERFACE_VERSION
The version of the upgrade interface of the contract. If this getter is missing, both upgradeTo(address)
and upgradeToAndCall(address,bytes) are present, and upgradeTo must be used if no function should be called,
while upgradeToAndCall will invoke the receive function if the second argument is the empty byte string.
If the getter returns "5.0.0", only upgradeToAndCall(address,bytes) is present, and the second argument must
be the empty byte string if no function should be called, making it impossible to invoke the receive function
during an upgrade.
string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";
Functions
onlyProxy
Check that the execution is being performed through a delegatecall call and that the execution context is a proxy contract with an implementation (as defined in ERC-1967) pointing to self. This should only be the case for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a function through ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to fail.
modifier onlyProxy();
notDelegated
Check that the execution is not being performed through a delegate call. This allows a function to be callable on the implementing contract but not through proxies.
modifier notDelegated();
proxiableUUID
Implementation of the ERC-1822 proxiableUUID function. This returns the storage slot used by the
implementation. It is used to validate the implementation's compatibility when performing an upgrade.
IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
function revert if invoked through a proxy. This is guaranteed by the notDelegated modifier.
function proxiableUUID() external view virtual notDelegated returns (bytes32);
upgradeToAndCall
Upgrade the implementation of the proxy to newImplementation, and subsequently execute the function call
encoded in data.
Calls _authorizeUpgrade.
Emits an {Upgraded} event.
Note: oz-upgrades-unsafe-allow-reachable: delegatecall
function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy;
_checkProxy
Reverts if the execution is not performed via delegatecall or the execution context is not of a proxy with an ERC-1967 compliant implementation pointing to self.
function _checkProxy() internal view virtual;
_checkNotDelegated
Reverts if the execution is performed via delegatecall. See notDelegated.
function _checkNotDelegated() internal view virtual;
_authorizeUpgrade
*Function that should revert when msg.sender is not authorized to upgrade the contract. Called by
upgradeToAndCall.
Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
function _authorizeUpgrade(address) internal onlyOwner {}
```*
```solidity
function _authorizeUpgrade(address newImplementation) internal virtual;
_upgradeToAndCallUUPS
Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call. As a security check, proxiableUUID is invoked in the new implementation, and the return value is expected to be the implementation slot in ERC-1967. Emits an {IERC1967-Upgraded} event.
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private;
Errors
UUPSUnauthorizedCallContext
The call is from an unauthorized context.
error UUPSUnauthorizedCallContext();
UUPSUnsupportedProxiableUUID
The storage slot is unsupported as a UUID.
error UUPSUnsupportedProxiableUUID(bytes32 slot);
Clones
*https://eips.ethereum.org/EIPS/eip-1167[ERC-1167] is a standard for deploying minimal proxy contracts, also known as "clones".
To simply and cheaply clone contract functionality in an immutable way, this standard specifies a minimal bytecode implementation that delegates all calls to a known, fixed address. The library includes functions to deploy a proxy using either
create(traditional deployment) orcreate2(salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the deterministic method.*
Functions
clone
Deploys and returns the address of a clone that mimics the behavior of implementation.
This function uses the create opcode, which should never revert.
WARNING: This function does not check if implementation has code. A clone that points to an address
without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
function clone(address implementation) internal returns (address instance);
clone
Same as {xref-Clones-clone-address-}[clone], but with a value parameter to send native currency
to the new contract.
WARNING: This function does not check if implementation has code. A clone that points to an address
without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
NOTE: Using a non-zero value at creation will require the contract using this function (e.g. a factory)
to always have enough balance for new deployments. Consider exposing this function under a payable method.
function clone(address implementation, uint256 value) internal returns (address instance);
cloneDeterministic
Deploys and returns the address of a clone that mimics the behavior of implementation.
This function uses the create2 opcode and a salt to deterministically deploy
the clone. Using the same implementation and salt multiple times will revert, since
the clones cannot be deployed twice at the same address.
WARNING: This function does not check if implementation has code. A clone that points to an address
without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance);
cloneDeterministic
Same as {xref-Clones-cloneDeterministic-address-bytes32-}[cloneDeterministic], but with
a value parameter to send native currency to the new contract.
WARNING: This function does not check if implementation has code. A clone that points to an address
without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
NOTE: Using a non-zero value at creation will require the contract using this function (e.g. a factory)
to always have enough balance for new deployments. Consider exposing this function under a payable method.
function cloneDeterministic(address implementation, bytes32 salt, uint256 value) internal returns (address instance);
predictDeterministicAddress
Computes the address of a clone deployed using {Clones-cloneDeterministic}.
function predictDeterministicAddress(address implementation, bytes32 salt, address deployer)
internal
pure
returns (address predicted);
predictDeterministicAddress
Computes the address of a clone deployed using {Clones-cloneDeterministic}.
function predictDeterministicAddress(address implementation, bytes32 salt) internal view returns (address predicted);
cloneWithImmutableArgs
Deploys and returns the address of a clone that mimics the behavior of implementation with custom
immutable arguments. These are provided through args and cannot be changed after deployment. To
access the arguments within the implementation, use fetchCloneArgs.
This function uses the create opcode, which should never revert.
WARNING: This function does not check if implementation has code. A clone that points to an address
without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
function cloneWithImmutableArgs(address implementation, bytes memory args) internal returns (address instance);
cloneWithImmutableArgs
Same as {xref-Clones-cloneWithImmutableArgs-address-bytes-}[cloneWithImmutableArgs], but with a value
parameter to send native currency to the new contract.
WARNING: This function does not check if implementation has code. A clone that points to an address
without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
NOTE: Using a non-zero value at creation will require the contract using this function (e.g. a factory)
to always have enough balance for new deployments. Consider exposing this function under a payable method.
function cloneWithImmutableArgs(address implementation, bytes memory args, uint256 value)
internal
returns (address instance);
cloneDeterministicWithImmutableArgs
Deploys and returns the address of a clone that mimics the behavior of implementation with custom
immutable arguments. These are provided through args and cannot be changed after deployment. To
access the arguments within the implementation, use fetchCloneArgs.
This function uses the create2 opcode and a salt to deterministically deploy the clone. Using the same
implementation, args and salt multiple times will revert, since the clones cannot be deployed twice
at the same address.
WARNING: This function does not check if implementation has code. A clone that points to an address
without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
function cloneDeterministicWithImmutableArgs(address implementation, bytes memory args, bytes32 salt)
internal
returns (address instance);
cloneDeterministicWithImmutableArgs
Same as {xref-Clones-cloneDeterministicWithImmutableArgs-address-bytes-bytes32-}[cloneDeterministicWithImmutableArgs],
but with a value parameter to send native currency to the new contract.
WARNING: This function does not check if implementation has code. A clone that points to an address
without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
NOTE: Using a non-zero value at creation will require the contract using this function (e.g. a factory)
to always have enough balance for new deployments. Consider exposing this function under a payable method.
function cloneDeterministicWithImmutableArgs(address implementation, bytes memory args, bytes32 salt, uint256 value)
internal
returns (address instance);
predictDeterministicAddressWithImmutableArgs
Computes the address of a clone deployed using {Clones-cloneDeterministicWithImmutableArgs}.
function predictDeterministicAddressWithImmutableArgs(
address implementation,
bytes memory args,
bytes32 salt,
address deployer
) internal pure returns (address predicted);
predictDeterministicAddressWithImmutableArgs
Computes the address of a clone deployed using {Clones-cloneDeterministicWithImmutableArgs}.
function predictDeterministicAddressWithImmutableArgs(address implementation, bytes memory args, bytes32 salt)
internal
view
returns (address predicted);
fetchCloneArgs
*Get the immutable args attached to a clone.
- If
instanceis a clone that was deployed usingcloneorcloneDeterministic, this function will return an empty array. - If
instanceis a clone that was deployed usingcloneWithImmutableArgsorcloneDeterministicWithImmutableArgs, this function will return the args array used at creation. - If
instanceis NOT a clone deployed using this library, the behavior is undefined. This function should only be used to check addresses that are known to be clones.*
function fetchCloneArgs(address instance) internal view returns (bytes memory);
_cloneCodeWithImmutableArgs
Helper that prepares the initcode of the proxy with immutable args.
An assembly variant of this function requires copying the args array, which can be efficiently done using
mcopy. Unfortunately, that opcode is not available before cancun. A pure solidity implementation using
abi.encodePacked is more expensive but also more portable and easier to review.
NOTE: https://eips.ethereum.org/EIPS/eip-170[EIP-170] limits the length of the contract code to 24576 bytes.
With the proxy code taking 45 bytes, that limits the length of the immutable args to 24531 bytes.
function _cloneCodeWithImmutableArgs(address implementation, bytes memory args) private pure returns (bytes memory);
Errors
CloneArgumentsTooLong
error CloneArgumentsTooLong();
Proxy
This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
instruction delegatecall. We refer to the second contract as the implementation behind the proxy, and it has to
be specified by overriding the virtual _implementation function.
Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
different contract through the {_delegate} function.
The success and return data of the delegated call will be returned back to the caller of the proxy.
Functions
_delegate
Delegates the current call to implementation.
This function does not return to its internal call site, it will return directly to the external caller.
function _delegate(address implementation) internal virtual;
_implementation
This is a virtual function that should be overridden so it returns the address to which the fallback function and _fallback should delegate.
function _implementation() internal view virtual returns (address);
_fallback
Delegates the current call to the address returned by _implementation().
This function does not return to its internal call site, it will return directly to the external caller.
function _fallback() internal virtual;
fallback
Fallback function that delegates calls to the address returned by _implementation(). Will run if no other
function in the contract matches the call data.
fallback() external payable virtual;
Contents
Contents
Contents
ERC1155Burnable
Inherits: ERC1155
Extension of {ERC1155} that allows token holders to destroy both their own tokens and those that they have been approved to use.
Functions
burn
function burn(address account, uint256 id, uint256 value) public virtual;
burnBatch
function burnBatch(address account, uint256[] memory ids, uint256[] memory values) public virtual;
ERC1155Pausable
ERC-1155 token with pausable token transfers, minting and burning. Useful for scenarios such as preventing trades until the end of an evaluation period, or having an emergency switch for freezing all token transfers in the event of a large bug. IMPORTANT: This contract does not include public pause and unpause functions. In addition to inheriting this contract, you must define both functions, invoking the {Pausable-_pause} and {Pausable-_unpause} internal functions, with appropriate access control, e.g. using {AccessControl} or {Ownable}. Not doing so will make the contract pause mechanism of the contract unreachable, and thus unusable.
Functions
_update
*See ERC1155-_update. Requirements:
- the contract must not be paused.*
function _update(address from, address to, uint256[] memory ids, uint256[] memory values)
internal
virtual
override
whenNotPaused;
ERC1155Supply
Inherits: ERC1155
Extension of ERC-1155 that adds tracking of total supply per id. Useful for scenarios where Fungible and Non-fungible tokens have to be clearly identified. Note: While a totalSupply of 1 might mean the corresponding is an NFT, there is no guarantees that no other token with the same id are not going to be minted. NOTE: This contract implies a global limit of 2**256 - 1 to the number of tokens that can be minted. CAUTION: This extension should not be added in an upgrade to an already deployed contract.
State Variables
_totalSupply
mapping(uint256 id => uint256) private _totalSupply;
_totalSupplyAll
uint256 private _totalSupplyAll;
Functions
totalSupply
Total value of tokens in with a given id.
function totalSupply(uint256 id) public view virtual returns (uint256);
totalSupply
Total value of tokens.
function totalSupply() public view virtual returns (uint256);
exists
Indicates whether any token exist with a given id, or not.
function exists(uint256 id) public view virtual returns (bool);
_update
*Transfers a value amount of tokens of type id from from to to. Will mint (or burn) if from
(or to) is the zero address.
Emits a {TransferSingle} event if the arrays contain one element, and {TransferBatch} otherwise.
Requirements:
- If
torefers to a smart contract, it must implement either {IERC1155Receiver-onERC1155Received} or {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value. idsandvaluesmust have the same length. NOTE: The ERC-1155 acceptance check is not performed in this function. See {_updateWithAcceptanceCheck} instead.*
function _update(address from, address to, uint256[] memory ids, uint256[] memory values) internal virtual override;
ERC1155URIStorage
Inherits: ERC1155
ERC-1155 token with storage based token URI management. Inspired by the {ERC721URIStorage} extension
State Variables
_baseURI
string private _baseURI = "";
_tokenURIs
mapping(uint256 tokenId => string) private _tokenURIs;
Functions
uri
*See {IERC1155MetadataURI-uri}.
This implementation returns the concatenation of the _baseURI
and the token-specific uri if the latter is set
This enables the following behaviors:
- if
_tokenURIs[tokenId]is set, then the result is the concatenation of_baseURIand_tokenURIs[tokenId](keep in mind that_baseURIis empty per default); - if
_tokenURIs[tokenId]is NOT set then we fallback tosuper.uri()which in most cases will containERC1155._uri; - if
_tokenURIs[tokenId]is NOT set, and if the parents do not have a uri value set, then the result is empty.*
function uri(uint256 tokenId) public view virtual override returns (string memory);
_setURI
Sets tokenURI as the tokenURI of tokenId.
function _setURI(uint256 tokenId, string memory tokenURI) internal virtual;
_setBaseURI
Sets baseURI as the _baseURI for all tokens
function _setBaseURI(string memory baseURI) internal virtual;
IERC1155MetadataURI
Inherits: IERC1155
Interface of the optional ERC1155MetadataExtension interface, as defined in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[ERC].
Functions
uri
Returns the URI for token type id.
If the \{id\} substring is present in the URI, it must be replaced by
clients with the actual token type ID.
function uri(uint256 id) external view returns (string memory);
Contents
ERC1155Holder
Inherits: ERC165, IERC1155Receiver
Simple implementation of IERC1155Receiver that will allow a contract to hold ERC-1155 tokens.
IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be
stuck.
Functions
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
onERC1155Received
function onERC1155Received(address, address, uint256, uint256, bytes memory) public virtual override returns (bytes4);
onERC1155BatchReceived
function onERC1155BatchReceived(address, address, uint256[] memory, uint256[] memory, bytes memory)
public
virtual
override
returns (bytes4);
ERC1155Utils
Library that provide common ERC-1155 utility functions. See https://eips.ethereum.org/EIPS/eip-1155[ERC-1155]. Available since v5.1.
Functions
checkOnERC1155Received
Performs an acceptance check for the provided operator by calling IERC1155Receiver-onERC1155Received
on the to address. The operator is generally the address that initiated the token transfer (i.e. msg.sender).
The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA).
Otherwise, the recipient must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value to accept
the transfer.
function checkOnERC1155Received(
address operator,
address from,
address to,
uint256 id,
uint256 value,
bytes memory data
) internal;
checkOnERC1155BatchReceived
Performs a batch acceptance check for the provided operator by calling IERC1155Receiver-onERC1155BatchReceived
on the to address. The operator is generally the address that initiated the token transfer (i.e. msg.sender).
The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA).
Otherwise, the recipient must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value to accept
the transfer.
function checkOnERC1155BatchReceived(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
) internal;
ERC1155
Inherits: Context, ERC165, IERC1155, IERC1155MetadataURI, IERC1155Errors
Implementation of the basic standard multi-token. See https://eips.ethereum.org/EIPS/eip-1155 Originally based on code by Enjin: https://github.com/enjin/erc-1155
State Variables
_balances
mapping(uint256 id => mapping(address account => uint256)) private _balances;
_operatorApprovals
mapping(address account => mapping(address operator => bool)) private _operatorApprovals;
_uri
string private _uri;
Functions
constructor
See _setURI.
constructor(string memory uri_);
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
uri
See IERC1155MetadataURI-uri.
This implementation returns the same URI for all token types. It relies
on the token type ID substitution mechanism
https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the ERC].
Clients calling this function must replace the \{id\} substring with the
actual token type ID.
function uri(uint256) public view virtual returns (string memory);
balanceOf
Get the balance of an account's tokens.
function balanceOf(address account, uint256 id) public view virtual returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
account | address | |
id | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The _owner's balance of the token type requested |
balanceOfBatch
*See IERC1155-balanceOfBatch. Requirements:
accountsandidsmust have the same length.*
function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
public
view
virtual
returns (uint256[] memory);
setApprovalForAll
Enable or disable approval for a third party ("operator") to manage all of the caller's tokens.
MUST emit the ApprovalForAll event on success.
function setApprovalForAll(address operator, bool approved) public virtual;
Parameters
| Name | Type | Description |
|---|---|---|
operator | address | |
approved | bool |
isApprovedForAll
Queries the approval status of an operator for a given owner.
function isApprovedForAll(address account, address operator) public view virtual returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
account | address | |
operator | address |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the operator is approved, false if not |
safeTransferFrom
Transfers _value amount of an _id from the _from address to the _to address specified (with safety call).
*Caller must be approved to manage the tokens being transferred out of the _from account (see "Approval" section of the standard).
- MUST revert if
_tois the zero address. - MUST revert if balance of holder for token
_idis lower than the_valuesent. - MUST revert on any other error.
- MUST emit the
TransferSingleevent to reflect the balance change (see "Safe Transfer Rules" section of the standard). - After the above conditions are met, this function MUST check if
_tois a smart contract (e.g. code size > 0). If so, it MUST callonERC1155Receivedon_toand act appropriately (see "Safe Transfer Rules" section of the standard).*
function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) public virtual;
Parameters
| Name | Type | Description |
|---|---|---|
from | address | |
to | address | |
id | uint256 | |
value | uint256 | |
data | bytes |
safeBatchTransferFrom
Transfers _values amount(s) of _ids from the _from address to the _to address specified (with safety call).
*Caller must be approved to manage the tokens being transferred out of the _from account (see "Approval" section of the standard).
- MUST revert if
_tois the zero address. - MUST revert if length of
_idsis not the same as length of_values. - MUST revert if any of the balance(s) of the holder(s) for token(s) in
_idsis lower than the respective amount(s) in_valuessent to the recipient. - MUST revert on any other error.
- MUST emit
TransferSingleorTransferBatchevent(s) such that all the balance changes are reflected (see "Safe Transfer Rules" section of the standard). - Balance changes and events MUST follow the ordering of the arrays (_ids[0]/_values[0] before _ids[1]/_values[1], etc).
- After the above conditions for the transfer(s) in the batch are met, this function MUST check if
_tois a smart contract (e.g. code size > 0). If so, it MUST call the relevantERC1155TokenReceiverhook(s) on_toand act appropriately (see "Safe Transfer Rules" section of the standard).*
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
) public virtual;
Parameters
| Name | Type | Description |
|---|---|---|
from | address | |
to | address | |
ids | uint256[] | |
values | uint256[] | |
data | bytes |
_update
*Transfers a value amount of tokens of type id from from to to. Will mint (or burn) if from
(or to) is the zero address.
Emits a {TransferSingle} event if the arrays contain one element, and {TransferBatch} otherwise.
Requirements:
- If
torefers to a smart contract, it must implement either {IERC1155Receiver-onERC1155Received} or {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value. idsandvaluesmust have the same length. NOTE: The ERC-1155 acceptance check is not performed in this function. See {_updateWithAcceptanceCheck} instead.*
function _update(address from, address to, uint256[] memory ids, uint256[] memory values) internal virtual;
_updateWithAcceptanceCheck
Version of _update that performs the token acceptance check by calling {IERC1155Receiver-onERC1155Received} or {IERC1155Receiver-onERC1155BatchReceived} on the receiver address if it contains code (eg. is a smart contract at the moment of execution). IMPORTANT: Overriding this function is discouraged because it poses a reentrancy risk from the receiver. So any update to the contract state after this function would break the check-effect-interaction pattern. Consider overriding {_update} instead.
function _updateWithAcceptanceCheck(
address from,
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
) internal virtual;
_safeTransferFrom
*Transfers a value tokens of token type id from from to to.
Emits a {TransferSingle} event.
Requirements:
tocannot be the zero address.frommust have a balance of tokens of typeidof at leastvalueamount.- If
torefers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value.*
function _safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) internal;
_safeBatchTransferFrom
*xref:ROOT:erc1155.adoc#batch-operations[Batched] version of _safeTransferFrom. Emits a {TransferBatch} event. Requirements:
- If
torefers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value. idsandvaluesmust have the same length.*
function _safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
) internal;
_setURI
Sets a new URI for all token types, by relying on the token type ID
substitution mechanism
https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the ERC].
By this mechanism, any occurrence of the \{id\} substring in either the
URI or any of the values in the JSON file at said URI will be replaced by
clients with the token type ID.
For example, the https://token-cdn-domain/\{id\}.json URI would be
interpreted by clients as
https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json
for token type ID 0x4cce0.
See uri.
Because these URIs cannot be meaningfully represented by the {URI} event,
this function emits no events.
function _setURI(string memory newuri) internal virtual;
_mint
*Creates a value amount of tokens of type id, and assigns them to to.
Emits a {TransferSingle} event.
Requirements:
tocannot be the zero address.- If
torefers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value.*
function _mint(address to, uint256 id, uint256 value, bytes memory data) internal;
_mintBatch
*xref:ROOT:erc1155.adoc#batch-operations[Batched] version of _mint. Emits a {TransferBatch} event. Requirements:
idsandvaluesmust have the same length.tocannot be the zero address.- If
torefers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value.*
function _mintBatch(address to, uint256[] memory ids, uint256[] memory values, bytes memory data) internal;
_burn
*Destroys a value amount of tokens of type id from from
Emits a {TransferSingle} event.
Requirements:
fromcannot be the zero address.frommust have at leastvalueamount of tokens of typeid.*
function _burn(address from, uint256 id, uint256 value) internal;
_burnBatch
*xref:ROOT:erc1155.adoc#batch-operations[Batched] version of _burn. Emits a {TransferBatch} event. Requirements:
fromcannot be the zero address.frommust have at leastvalueamount of tokens of typeid.idsandvaluesmust have the same length.*
function _burnBatch(address from, uint256[] memory ids, uint256[] memory values) internal;
_setApprovalForAll
*Approve operator to operate on all of owner tokens
Emits an {ApprovalForAll} event.
Requirements:
operatorcannot be the zero address.*
function _setApprovalForAll(address owner, address operator, bool approved) internal virtual;
_asSingletonArrays
Creates an array in memory with only one value for each of the elements provided.
function _asSingletonArrays(uint256 element1, uint256 element2)
private
pure
returns (uint256[] memory array1, uint256[] memory array2);
IERC1155
Inherits: IERC165
Required interface of an ERC-1155 compliant contract, as defined in the https://eips.ethereum.org/EIPS/eip-1155[ERC].
Functions
balanceOf
Returns the value of tokens of token type id owned by account.
function balanceOf(address account, uint256 id) external view returns (uint256);
balanceOfBatch
*xref:ROOT:erc1155.adoc#batch-operations[Batched] version of balanceOf. Requirements:
accountsandidsmust have the same length.*
function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory);
setApprovalForAll
*Grants or revokes permission to operator to transfer the caller's tokens, according to approved,
Emits an ApprovalForAll event.
Requirements:
operatorcannot be the zero address.*
function setApprovalForAll(address operator, bool approved) external;
isApprovedForAll
Returns true if operator is approved to transfer account's tokens.
See setApprovalForAll.
function isApprovedForAll(address account, address operator) external view returns (bool);
safeTransferFrom
*Transfers a value amount of tokens of type id from from to to.
WARNING: This function can potentially allow a reentrancy attack when transferring tokens
to an untrusted contract, when invoking IERC1155Receiver-onERC1155Received on the receiver.
Ensure to follow the checks-effects-interactions pattern and consider employing
reentrancy guards when interacting with untrusted contracts.
Emits a {TransferSingle} event.
Requirements:
tocannot be the zero address.- If the caller is not
from, it must have been approved to spendfrom's tokens via {setApprovalForAll}. frommust have a balance of tokens of typeidof at leastvalueamount.- If
torefers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value.*
function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external;
safeBatchTransferFrom
*xref:ROOT:erc1155.adoc#batch-operations[Batched] version of safeTransferFrom. WARNING: This function can potentially allow a reentrancy attack when transferring tokens to an untrusted contract, when invoking {IERC1155Receiver-onERC1155BatchReceived} on the receiver. Ensure to follow the checks-effects-interactions pattern and consider employing reentrancy guards when interacting with untrusted contracts. Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments. Requirements:
idsandvaluesmust have the same length.- If
torefers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value.*
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external;
Events
TransferSingle
Emitted when value amount of tokens of type id are transferred from from to to by operator.
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
TransferBatch
Equivalent to multiple TransferSingle events, where operator, from and to are the same for all
transfers.
event TransferBatch(
address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values
);
ApprovalForAll
Emitted when account grants or revokes permission to operator to transfer their tokens, according to
approved.
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
URI
Emitted when the URI for token type id changes to value, if it is a non-programmatic URI.
If an URI event was emitted for id, the standard
https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that value will equal the value
returned by {IERC1155MetadataURI-uri}.
event URI(string value, uint256 indexed id);
IERC1155Receiver
Inherits: IERC165
Interface that must be implemented by smart contracts in order to receive ERC-1155 token transfers.
Functions
onERC1155Received
Handles the receipt of a single ERC-1155 token type. This function is
called at the end of a safeTransferFrom after the balance has been updated.
NOTE: To accept the transfer, this must return
bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))
(i.e. 0xf23a6e61, or its own function selector).
function onERC1155Received(address operator, address from, uint256 id, uint256 value, bytes calldata data)
external
returns (bytes4);
Parameters
| Name | Type | Description |
|---|---|---|
operator | address | The address which initiated the transfer (i.e. msg.sender) |
from | address | The address which previously owned the token |
id | uint256 | The ID of the token being transferred |
value | uint256 | The amount of tokens being transferred |
data | bytes | Additional data with no specified format |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes4 | bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)")) if transfer is allowed |
onERC1155BatchReceived
Handles the receipt of a multiple ERC-1155 token types. This function
is called at the end of a safeBatchTransferFrom after the balances have
been updated.
NOTE: To accept the transfer(s), this must return
bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))
(i.e. 0xbc197c81, or its own function selector).
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
Parameters
| Name | Type | Description |
|---|---|---|
operator | address | The address which initiated the batch transfer (i.e. msg.sender) |
from | address | The address which previously owned the token |
ids | uint256[] | An array containing ids of each token being transferred (order and length must match values array) |
values | uint256[] | An array containing amounts of each token being transferred (order and length must match ids array) |
data | bytes | Additional data with no specified format |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes4 | bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)")) if transfer is allowed |
Contents
Contents
- ERC1363
- ERC20Burnable
- ERC20Capped
- ERC20FlashMint
- ERC20Pausable
- ERC20Permit
- ERC20Votes
- ERC20Wrapper
- ERC4626
- IERC20Metadata
- IERC20Permit
- ERC20Bridgeable
- ERC20TemporaryApproval
ERC1363
Inherits: ERC20, ERC165, IERC1363
Extension of {ERC20} tokens that adds support for code execution after transfers and approvals on recipient contracts. Calls after transfers are enabled through the {ERC1363-transferAndCall} and {ERC1363-transferFromAndCall} methods while calls after approvals can be made with {ERC1363-approveAndCall} Available since v5.1.
Functions
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
transferAndCall
*Moves a value amount of tokens from the caller's account to to
and then calls {IERC1363Receiver-onTransferReceived} on to. Returns a flag that indicates
if the call succeeded.
Requirements:
- The target has code (i.e. is a contract).
- The target
tomust implement the {IERC1363Receiver} interface. - The target must return the {IERC1363Receiver-onTransferReceived} selector to accept the transfer.
- The internal {transfer} must succeed (returned
true).*
function transferAndCall(address to, uint256 value) public returns (bool);
transferAndCall
Variant of transferAndCall that accepts an additional data parameter with
no specified format.
function transferAndCall(address to, uint256 value, bytes memory data) public virtual returns (bool);
transferFromAndCall
*Moves a value amount of tokens from from to to using the allowance mechanism
and then calls {IERC1363Receiver-onTransferReceived} on to. Returns a flag that indicates
if the call succeeded.
Requirements:
- The target has code (i.e. is a contract).
- The target
tomust implement the {IERC1363Receiver} interface. - The target must return the {IERC1363Receiver-onTransferReceived} selector to accept the transfer.
- The internal {transferFrom} must succeed (returned
true).*
function transferFromAndCall(address from, address to, uint256 value) public returns (bool);
transferFromAndCall
Variant of transferFromAndCall that accepts an additional data parameter with
no specified format.
function transferFromAndCall(address from, address to, uint256 value, bytes memory data)
public
virtual
returns (bool);
approveAndCall
*Sets a value amount of tokens as the allowance of spender over the
caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on spender.
Returns a flag that indicates if the call succeeded.
Requirements:
- The target has code (i.e. is a contract).
- The target
spendermust implement the {IERC1363Spender} interface. - The target must return the {IERC1363Spender-onApprovalReceived} selector to accept the approval.
- The internal {approve} must succeed (returned
true).*
function approveAndCall(address spender, uint256 value) public returns (bool);
approveAndCall
Variant of approveAndCall that accepts an additional data parameter with
no specified format.
function approveAndCall(address spender, uint256 value, bytes memory data) public virtual returns (bool);
Errors
ERC1363TransferFailed
Indicates a failure within the {transfer} part of a transferAndCall operation.
error ERC1363TransferFailed(address receiver, uint256 value);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | Address to which tokens are being transferred. |
value | uint256 | Amount of tokens to be transferred. |
ERC1363TransferFromFailed
Indicates a failure within the {transferFrom} part of a transferFromAndCall operation.
error ERC1363TransferFromFailed(address sender, address receiver, uint256 value);
Parameters
| Name | Type | Description |
|---|---|---|
sender | address | Address from which to send tokens. |
receiver | address | Address to which tokens are being transferred. |
value | uint256 | Amount of tokens to be transferred. |
ERC1363ApproveFailed
Indicates a failure within the {approve} part of a approveAndCall operation.
error ERC1363ApproveFailed(address spender, uint256 value);
Parameters
| Name | Type | Description |
|---|---|---|
spender | address | Address which will spend the funds. |
value | uint256 | Amount of tokens to be spent. |
ERC20Burnable
Extension of {ERC20} that allows token holders to destroy both their own tokens and those that they have an allowance for, in a way that can be recognized off-chain (via event analysis).
Functions
burn
Destroys a value amount of tokens from the caller.
See ERC20-_burn.
function burn(uint256 value) public virtual;
burnFrom
*Destroys a value amount of tokens from account, deducting from
the caller's allowance.
See ERC20-_burn and {ERC20-allowance}.
Requirements:
- the caller must have allowance for
accounts's tokens of at leastvalue.*
function burnFrom(address account, uint256 value) public virtual;
ERC20Capped
Inherits: ERC20
Extension of {ERC20} that adds a cap to the supply of tokens.
State Variables
_cap
uint256 private immutable _cap;
Functions
constructor
Sets the value of the cap. This value is immutable, it can only be
set once during construction.
constructor(uint256 cap_);
cap
Returns the cap on the token's total supply.
function cap() public view virtual returns (uint256);
_update
Transfers a value amount of tokens from from to to, or alternatively mints (or burns) if from
(or to) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
this function.
Emits a {Transfer} event.
function _update(address from, address to, uint256 value) internal virtual override;
Errors
ERC20ExceededCap
Total supply cap has been exceeded.
error ERC20ExceededCap(uint256 increasedSupply, uint256 cap);
ERC20InvalidCap
The supplied cap is not a valid cap.
error ERC20InvalidCap(uint256 cap);
ERC20FlashMint
Inherits: ERC20, IERC3156FlashLender
Implementation of the ERC-3156 Flash loans extension, as defined in https://eips.ethereum.org/EIPS/eip-3156[ERC-3156]. Adds the flashLoan method, which provides flash loan support at the token level. By default there is no fee, but this can be changed by overriding {flashFee}. NOTE: When this extension is used along with the {ERC20Capped} or {ERC20Votes} extensions, {maxFlashLoan} will not correctly reflect the maximum that can be flash minted. We recommend overriding {maxFlashLoan} so that it correctly reflects the supply cap.
State Variables
RETURN_VALUE
bytes32 private constant RETURN_VALUE = keccak256("ERC3156FlashBorrower.onFlashLoan");
Functions
maxFlashLoan
Returns the maximum amount of tokens available for loan.
function maxFlashLoan(address token) public view virtual returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | The address of the token that is requested. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The amount of token that can be loaned. NOTE: This function does not consider any form of supply cap, so in case it's used in a token with a cap like {ERC20Capped}, make sure to override this function to integrate the cap instead of type(uint256).max. |
flashFee
Returns the fee applied when doing flash loans. This function calls the _flashFee function which returns the fee applied when doing flash loans.
function flashFee(address token, uint256 value) public view virtual returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | The token to be flash loaned. |
value | uint256 | The amount of tokens to be loaned. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The fees applied to the corresponding flash loan. |
_flashFee
Returns the fee applied when doing flash loans. By default this implementation has 0 fees. This function can be overloaded to make the flash loan mechanism deflationary.
function _flashFee(address token, uint256 value) internal view virtual returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | The token to be flash loaned. |
value | uint256 | The amount of tokens to be loaned. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The fees applied to the corresponding flash loan. |
_flashFeeReceiver
Returns the receiver address of the flash fee. By default this implementation returns the address(0) which means the fee amount will be burnt. This function can be overloaded to change the fee receiver.
function _flashFeeReceiver() internal view virtual returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The address for which the flash fee will be sent to. |
flashLoan
Performs a flash loan. New tokens are minted and sent to the
receiver, who is required to implement the {IERC3156FlashBorrower}
interface. By the end of the flash loan, the receiver is expected to own
value + fee tokens and have them approved back to the token contract itself so
they can be burned.
function flashLoan(IERC3156FlashBorrower receiver, address token, uint256 value, bytes calldata data)
public
virtual
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | IERC3156FlashBorrower | The receiver of the flash loan. Should implement the IERC3156FlashBorrower-onFlashLoan interface. |
token | address | The token to be flash loaned. Only address(this) is supported. |
value | uint256 | The amount of tokens to be loaned. |
data | bytes | An arbitrary datafield that is passed to the receiver. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the flash loan was successful. |
Errors
ERC3156UnsupportedToken
The loan token is not valid.
error ERC3156UnsupportedToken(address token);
ERC3156ExceededMaxLoan
The requested loan exceeds the max loan value for token.
error ERC3156ExceededMaxLoan(uint256 maxLoan);
ERC3156InvalidReceiver
The receiver of a flashloan is not a valid IERC3156FlashBorrower-onFlashLoan implementer.
error ERC3156InvalidReceiver(address receiver);
ERC20Pausable
ERC-20 token with pausable token transfers, minting and burning. Useful for scenarios such as preventing trades until the end of an evaluation period, or having an emergency switch for freezing all token transfers in the event of a large bug. IMPORTANT: This contract does not include public pause and unpause functions. In addition to inheriting this contract, you must define both functions, invoking the {Pausable-_pause} and {Pausable-_unpause} internal functions, with appropriate access control, e.g. using {AccessControl} or {Ownable}. Not doing so will make the contract pause mechanism of the contract unreachable, and thus unusable.
Functions
_update
*See ERC20-_update. Requirements:
- the contract must not be paused.*
function _update(address from, address to, uint256 value) internal virtual override whenNotPaused;
ERC20Permit
Inherits: ERC20, IERC20Permit, EIP712, Nonces
Implementation of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in
https://eips.ethereum.org/EIPS/eip-2612[ERC-2612].
Adds the permit method, which can be used to change an account's ERC-20 allowance (see {IERC20-allowance}) by
presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
need to send a transaction, and thus is not required to hold Ether at all.
State Variables
PERMIT_TYPEHASH
bytes32 private constant PERMIT_TYPEHASH =
keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
Functions
constructor
Initializes the {EIP712} domain separator using the name parameter, and setting version to "1".
It's a good idea to use the same name that is defined as the ERC-20 token name.
constructor(string memory name) EIP712(name, "1");
permit
*Sets value as the allowance of spender over owner's tokens,
given owner's signed approval.
IMPORTANT: The same issues {IERC20-approve} has related to transaction
ordering also apply here.
Emits an {Approval} event.
Requirements:
spendercannot be the zero address.deadlinemust be a timestamp in the future.v,randsmust be a validsecp256k1signature fromownerover the EIP712-formatted function arguments.- the signature must use
owner's current nonce (see {nonces}). For more information on the signature format, see the https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP section]. CAUTION: See Security Considerations above.*
function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
public
virtual;
nonces
Returns the current nonce for owner. This value must be
included whenever a signature is generated for {permit}.
Every successful call to {permit} increases owner's nonce by one. This
prevents a signature from being used multiple times.
function nonces(address owner) public view virtual override(IERC20Permit, Nonces) returns (uint256);
DOMAIN_SEPARATOR
Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
function DOMAIN_SEPARATOR() external view virtual returns (bytes32);
Errors
ERC2612ExpiredSignature
Permit deadline has expired.
error ERC2612ExpiredSignature(uint256 deadline);
ERC2612InvalidSigner
Mismatched signature.
error ERC2612InvalidSigner(address signer, address owner);
ERC20Votes
Extension of ERC-20 to support Compound-like voting and delegation. This version is more generic than Compound's, and supports token supply up to 2^208^ - 1, while COMP is limited to 2^96^ - 1. NOTE: This contract does not provide interface compatibility with Compound's COMP token. This extension keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either by calling the {Votes-delegate} function directly, or by providing a signature to be used with {Votes-delegateBySig}. Voting power can be queried through the public accessors {Votes-getVotes} and {Votes-getPastVotes}. By default, token balance does not account for voting power. This makes transfers cheaper. The downside is that it requires users to delegate to themselves in order to activate checkpoints and have their voting power tracked.
Functions
_maxSupply
Maximum token supply. Defaults to type(uint208).max (2^208^ - 1).
This maximum is enforced in _update. It limits the total supply of the token, which is otherwise a uint256,
so that checkpoints can be stored in the Trace208 structure used by {Votes}. Increasing this value will not
remove the underlying limitation, and will cause {_update} to fail because of a math overflow in
{Votes-_transferVotingUnits}. An override could be used to further restrict the total supply (to a lower value) if
additional logic requires it. When resolving override conflicts on this function, the minimum should be
returned.
function _maxSupply() internal view virtual returns (uint256);
_update
Move voting power when tokens are transferred. Emits a {IVotes-DelegateVotesChanged} event.
function _update(address from, address to, uint256 value) internal virtual override;
_getVotingUnits
Returns the voting units of an account.
WARNING: Overriding this function may compromise the internal vote accounting.
ERC20Votes assumes tokens map to voting units 1:1 and this is not easy to change.
function _getVotingUnits(address account) internal view virtual override returns (uint256);
numCheckpoints
Get number of checkpoints for account.
function numCheckpoints(address account) public view virtual returns (uint32);
checkpoints
Get the pos-th checkpoint for account.
function checkpoints(address account, uint32 pos) public view virtual returns (Checkpoints.Checkpoint208 memory);
Errors
ERC20ExceededSafeSupply
Total supply cap has been exceeded, introducing a risk of votes overflowing.
error ERC20ExceededSafeSupply(uint256 increasedSupply, uint256 cap);
ERC20Wrapper
Inherits: ERC20
Extension of the ERC-20 token contract to support token wrapping. Users can deposit and withdraw "underlying tokens" and receive a matching number of "wrapped tokens". This is useful in conjunction with other modules. For example, combining this wrapping mechanism with {ERC20Votes} will allow the wrapping of an existing "basic" ERC-20 into a governance token. WARNING: Any mechanism in which the underlying token changes the {balanceOf} of an account without an explicit transfer may desynchronize this contract's supply and its underlying balance. Please exercise caution when wrapping tokens that may undercollateralize the wrapper (i.e. wrapper's total supply is higher than its underlying balance). See {_recover} for recovering value accrued to the wrapper.
State Variables
_underlying
IERC20 private immutable _underlying;
Functions
constructor
constructor(IERC20 underlyingToken);
decimals
Returns the decimals places of the token.
function decimals() public view virtual override returns (uint8);
underlying
Returns the address of the underlying ERC-20 token that is being wrapped.
function underlying() public view returns (IERC20);
depositFor
Allow a user to deposit underlying tokens and mint the corresponding number of wrapped tokens.
function depositFor(address account, uint256 value) public virtual returns (bool);
withdrawTo
Allow a user to burn a number of wrapped tokens and withdraw the corresponding number of underlying tokens.
function withdrawTo(address account, uint256 value) public virtual returns (bool);
_recover
Mint wrapped token to cover any underlyingTokens that would have been transferred by mistake or acquired from rebasing mechanisms. Internal function that can be exposed with access control if desired.
function _recover(address account) internal virtual returns (uint256);
Errors
ERC20InvalidUnderlying
The underlying token couldn't be wrapped.
error ERC20InvalidUnderlying(address token);
ERC4626
*Implementation of the ERC-4626 "Tokenized Vault Standard" as defined in https://eips.ethereum.org/EIPS/eip-4626[ERC-4626]. This extension allows the minting and burning of "shares" (represented using the ERC-20 inheritance) in exchange for underlying "assets" through standardized deposit, {mint}, {redeem} and {burn} workflows. This contract extends the ERC-20 standard. Any additional extensions included along it would affect the "shares" token represented by this contract and not the "assets" token which is an independent contract. [CAUTION]
In empty (or nearly empty) ERC-4626 vaults, deposits are at high risk of being stolen through frontrunning
with a "donation" to the vault that inflates the price of a share. This is variously known as a donation or inflation
attack and is essentially a problem of slippage. Vault deployers can protect against this attack by making an initial
deposit of a non-trivial amount of the asset, such that price manipulation becomes infeasible. Withdrawals may
similarly be affected by slippage. Users can protect against this attack as well as unexpected slippage in general by
verifying the amount received is as expected, using a wrapper that performs these checks such as
https://github.com/fei-protocol/ERC4626#erc4626router-and-base[ERC4626Router].
Since v4.9, this implementation introduces configurable virtual assets and shares to help developers mitigate that risk.
The _decimalsOffset() corresponds to an offset in the decimal representation between the underlying asset's decimals
and the vault decimals. This offset also determines the rate of virtual shares to virtual assets in the vault, which
itself determines the initial exchange rate. While not fully preventing the attack, analysis shows that the default
offset (0) makes it non-profitable even if an attacker is able to capture value from multiple user deposits, as a result
of the value being captured by the virtual shares (out of the attacker's donation) matching the attacker's expected gains.
With a larger offset, the attack becomes orders of magnitude more expensive than it is profitable. More details about the
underlying math can be found xref:ROOT:erc4626.adoc#inflation-attack[here].
The drawback of this approach is that the virtual shares do capture (a very small) part of the value being accrued
to the vault. Also, if the vault experiences losses, the users try to exit the vault, the virtual shares and assets
will cause the first user to exit to experience reduced losses in detriment to the last users that will experience
bigger losses. Developers willing to revert back to the pre-v4.9 behavior just need to override the
_convertToShares and _convertToAssets functions.
To learn more, check out our xref:ROOT:erc4626.adoc[ERC-4626 guide].
====*
State Variables
_asset
IERC20 private immutable _asset;
_underlyingDecimals
uint8 private immutable _underlyingDecimals;
Functions
constructor
Set the underlying asset contract. This must be an ERC20-compatible contract (ERC-20 or ERC-777).
constructor(IERC20 asset_);
_tryGetAssetDecimals
Attempts to fetch the asset decimals. A return value of false indicates that the attempt failed in some way.
function _tryGetAssetDecimals(IERC20 asset_) private view returns (bool ok, uint8 assetDecimals);
decimals
Decimals are computed by adding the decimal offset on top of the underlying asset's decimals. This "original" value is cached during construction of the vault contract. If this read operation fails (e.g., the asset has not been created yet), a default of 18 is used to represent the underlying asset's decimals. See IERC20Metadata-decimals.
function decimals() public view virtual override(IERC20Metadata, ERC20) returns (uint8);
asset
function asset() public view virtual returns (address);
totalAssets
function totalAssets() public view virtual returns (uint256);
convertToShares
function convertToShares(uint256 assets) public view virtual returns (uint256);
convertToAssets
function convertToAssets(uint256 shares) public view virtual returns (uint256);
maxDeposit
function maxDeposit(address) public view virtual returns (uint256);
maxMint
function maxMint(address) public view virtual returns (uint256);
maxWithdraw
function maxWithdraw(address owner) public view virtual returns (uint256);
maxRedeem
function maxRedeem(address owner) public view virtual returns (uint256);
previewDeposit
function previewDeposit(uint256 assets) public view virtual returns (uint256);
previewMint
function previewMint(uint256 shares) public view virtual returns (uint256);
previewWithdraw
function previewWithdraw(uint256 assets) public view virtual returns (uint256);
previewRedeem
function previewRedeem(uint256 shares) public view virtual returns (uint256);
deposit
function deposit(uint256 assets, address receiver) public virtual returns (uint256);
mint
function mint(uint256 shares, address receiver) public virtual returns (uint256);
withdraw
function withdraw(uint256 assets, address receiver, address owner) public virtual returns (uint256);
redeem
function redeem(uint256 shares, address receiver, address owner) public virtual returns (uint256);
_convertToShares
Internal conversion function (from assets to shares) with support for rounding direction.
function _convertToShares(uint256 assets, Math.Rounding rounding) internal view virtual returns (uint256);
_convertToAssets
Internal conversion function (from shares to assets) with support for rounding direction.
function _convertToAssets(uint256 shares, Math.Rounding rounding) internal view virtual returns (uint256);
_deposit
Deposit/mint common workflow.
function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual;
_withdraw
Withdraw/redeem common workflow.
function _withdraw(address caller, address receiver, address owner, uint256 assets, uint256 shares) internal virtual;
_decimalsOffset
function _decimalsOffset() internal view virtual returns (uint8);
Errors
ERC4626ExceededMaxDeposit
Attempted to deposit more assets than the max amount for receiver.
error ERC4626ExceededMaxDeposit(address receiver, uint256 assets, uint256 max);
ERC4626ExceededMaxMint
Attempted to mint more shares than the max amount for receiver.
error ERC4626ExceededMaxMint(address receiver, uint256 shares, uint256 max);
ERC4626ExceededMaxWithdraw
Attempted to withdraw more assets than the max amount for receiver.
error ERC4626ExceededMaxWithdraw(address owner, uint256 assets, uint256 max);
ERC4626ExceededMaxRedeem
Attempted to redeem more shares than the max amount for receiver.
error ERC4626ExceededMaxRedeem(address owner, uint256 shares, uint256 max);
IERC20Metadata
Inherits: IERC20
Interface for the optional metadata functions from the ERC-20 standard.
Functions
name
Returns the name of the token.
function name() external view returns (string memory);
symbol
Returns the symbol of the token.
function symbol() external view returns (string memory);
decimals
Returns the decimals places of the token.
function decimals() external view returns (uint8);
IERC20Permit
*Interface of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in
https://eips.ethereum.org/EIPS/eip-2612[ERC-2612].
Adds the permit method, which can be used to change an account's ERC-20 allowance (see {IERC20-allowance}) by
presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
need to send a transaction, and thus is not required to hold Ether at all.
==== Security Considerations
There are two important considerations concerning the use of permit. The first is that a valid permit signature
expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
considered as an intention to spend the allowance in any specific way. The second is that because permits have
built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
take this into consideration and allow a permit call to fail. Combining these two aspects, a pattern that may be
generally recommended is:
function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
doThing(..., value);
}
function doThing(..., uint256 value) public {
token.safeTransferFrom(msg.sender, address(this), value);
...
}
Observe that: 1) msg.sender is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
try/catch allows the permit to fail and makes the code tolerant to frontrunning. (See also
{SafeERC20-safeTransferFrom}).
Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
contracts should have entry points that don't rely on permit.*
Functions
permit
*Sets value as the allowance of spender over owner's tokens,
given owner's signed approval.
IMPORTANT: The same issues IERC20-approve has related to transaction
ordering also apply here.
Emits an {Approval} event.
Requirements:
spendercannot be the zero address.deadlinemust be a timestamp in the future.v,randsmust be a validsecp256k1signature fromownerover the EIP712-formatted function arguments.- the signature must use
owner's current nonce (see {nonces}). For more information on the signature format, see the https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP section]. CAUTION: See Security Considerations above.*
function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
external;
nonces
Returns the current nonce for owner. This value must be
included whenever a signature is generated for permit.
Every successful call to {permit} increases owner's nonce by one. This
prevents a signature from being used multiple times.
function nonces(address owner) external view returns (uint256);
DOMAIN_SEPARATOR
Returns the domain separator used in the encoding of the signature for permit, as defined by {EIP712}.
function DOMAIN_SEPARATOR() external view returns (bytes32);
ERC20Bridgeable
Inherits: ERC20, ERC165, IERC7802
ERC20 extension that implements the standard token interface according to https://eips.ethereum.org/EIPS/eip-7802[ERC-7802].
Functions
onlyTokenBridge
Modifier to restrict access to the token bridge.
modifier onlyTokenBridge();
supportsInterface
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool);
crosschainMint
See {IERC7802-crosschainMint}. Emits a {IERC7802-CrosschainMint} event.
function crosschainMint(address to, uint256 value) public virtual override onlyTokenBridge;
crosschainBurn
See {IERC7802-crosschainBurn}. Emits a {IERC7802-CrosschainBurn} event.
function crosschainBurn(address from, uint256 value) public virtual override onlyTokenBridge;
_checkTokenBridge
Checks if the caller is a trusted token bridge. MUST revert otherwise. Developers should implement this function using an access control mechanism that allows customizing the list of allowed senders. Consider using {AccessControl} or {AccessManaged}.
function _checkTokenBridge(address caller) internal virtual;
ERC20TemporaryApproval
Extension of {ERC20} that adds support for temporary allowances following ERC-7674. WARNING: This is a draft contract. The corresponding ERC is still subject to changes. Available since v5.1.
State Variables
ERC20_TEMPORARY_APPROVAL_STORAGE
bytes32 private constant ERC20_TEMPORARY_APPROVAL_STORAGE =
0xea2d0e77a01400d0111492b1321103eed560d8fe44b9a7c2410407714583c400;
Functions
allowance
allowance override that includes the temporary allowance when looking up the current allowance. If adding up the persistent and the temporary allowances result in an overflow, type(uint256).max is returned.
function allowance(address owner, address spender) public view virtual override(IERC20, ERC20) returns (uint256);
_temporaryAllowance
Internal getter for the current temporary allowance that spender has over owner tokens.
function _temporaryAllowance(address owner, address spender) internal view virtual returns (uint256);
temporaryApprove
*Alternative to {approve} that sets a value amount of tokens as the temporary allowance of spender over
the caller's tokens.
Returns a boolean value indicating whether the operation succeeded.
Requirements:
spendercannot be the zero address. Does NOT emit an {Approval} event.*
function temporaryApprove(address spender, uint256 value) public virtual returns (bool);
_temporaryApprove
*Sets value as the temporary allowance of spender over the owner's tokens.
This internal function is equivalent to temporaryApprove, and can be used to e.g. set automatic allowances
for certain subsystems, etc.
Requirements:
ownercannot be the zero address.spendercannot be the zero address. Does NOT emit an {Approval} event.*
function _temporaryApprove(address owner, address spender, uint256 value) internal virtual;
_spendAllowance
_spendAllowance override that consumes the temporary allowance (if any) before eventually falling back
to consuming the persistent allowance.
NOTE: This function skips calling super._spendAllowance if the temporary allowance
is enough to cover the spending.
function _spendAllowance(address owner, address spender, uint256 value) internal virtual override;
_temporaryAllowanceSlot
function _temporaryAllowanceSlot(address owner, address spender) private pure returns (TransientSlot.Uint256Slot);
Contents
ERC1363Utils
Library that provides common ERC-1363 utility functions. See https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
Functions
checkOnERC1363TransferReceived
*Performs a call to {IERC1363Receiver-onTransferReceived} on a target address. Requirements:
- The target has code (i.e. is a contract).
- The target
tomust implement the {IERC1363Receiver} interface. - The target must return the {IERC1363Receiver-onTransferReceived} selector to accept the transfer.*
function checkOnERC1363TransferReceived(address operator, address from, address to, uint256 value, bytes memory data)
internal;
checkOnERC1363ApprovalReceived
*Performs a call to {IERC1363Spender-onApprovalReceived} on a target address. Requirements:
- The target has code (i.e. is a contract).
- The target
spendermust implement the {IERC1363Spender} interface. - The target must return the {IERC1363Spender-onApprovalReceived} selector to accept the approval.*
function checkOnERC1363ApprovalReceived(address operator, address spender, uint256 value, bytes memory data) internal;
Errors
ERC1363InvalidReceiver
Indicates a failure with the token receiver. Used in transfers.
error ERC1363InvalidReceiver(address receiver);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | Address to which tokens are being transferred. |
ERC1363InvalidSpender
Indicates a failure with the token spender. Used in approvals.
error ERC1363InvalidSpender(address spender);
Parameters
| Name | Type | Description |
|---|---|---|
spender | address | Address that may be allowed to operate on tokens without being their owner. |
SafeERC20
Wrappers around ERC-20 operations that throw on failure (when the token
contract returns false). Tokens that return no value (and instead revert or
throw on failure) are also supported, non-reverting calls are assumed to be
successful.
To use this library you can add a using SafeERC20 for IERC20; statement to your contract,
which allows you to call the safe operations as token.safeTransfer(...), etc.
Functions
safeTransfer
Transfer value amount of token from the calling contract to to. If token returns no value,
non-reverting calls are assumed to be successful.
function safeTransfer(IERC20 token, address to, uint256 value) internal;
safeTransferFrom
Transfer value amount of token from from to to, spending the approval given by from to the
calling contract. If token returns no value, non-reverting calls are assumed to be successful.
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal;
trySafeTransfer
Variant of safeTransfer that returns a bool instead of reverting if the operation is not successful.
function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool);
trySafeTransferFrom
Variant of safeTransferFrom that returns a bool instead of reverting if the operation is not successful.
function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool);
safeIncreaseAllowance
Increase the calling contract's allowance toward spender by value. If token returns no value,
non-reverting calls are assumed to be successful.
IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
this function. Performing a safeIncreaseAllowance or {safeDecreaseAllowance} operation on a token contract
that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal;
safeDecreaseAllowance
Decrease the calling contract's allowance toward spender by requestedDecrease. If token returns no
value, non-reverting calls are assumed to be successful.
IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
this function. Performing a safeIncreaseAllowance or {safeDecreaseAllowance} operation on a token contract
that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal;
forceApprove
Set the calling contract's allowance toward spender to value. If token returns no value,
non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
to be set to zero before setting it to a non-zero value, such as USDT.
NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
set here.
function forceApprove(IERC20 token, address spender, uint256 value) internal;
transferAndCallRelaxed
Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
targeting contracts.
Reverts if the returned value is other than true.
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal;
transferFromAndCallRelaxed
Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
targeting contracts.
Reverts if the returned value is other than true.
function transferFromAndCallRelaxed(IERC1363 token, address from, address to, uint256 value, bytes memory data)
internal;
approveAndCallRelaxed
Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
targeting contracts.
NOTE: When the recipient address (to) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
Opposedly, when the recipient address (to) has code, this function only attempts to call {ERC1363-approveAndCall}
once without retrying, and relies on the returned value to be true.
Reverts if the returned value is other than true.
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal;
_callOptionalReturn
Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement on the return value: the return value is optional (but if data is returned, it must not be false).
function _callOptionalReturn(IERC20 token, bytes memory data) private;
Parameters
| Name | Type | Description |
|---|---|---|
token | IERC20 | The token targeted by the call. |
data | bytes | The call data (encoded using abi.encode or one of its variants). This is a variant of _callOptionalReturnBool that reverts if call fails to meet the requirements. |
_callOptionalReturnBool
Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement on the return value: the return value is optional (but if data is returned, it must not be false).
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
token | IERC20 | The token targeted by the call. |
data | bytes | The call data (encoded using abi.encode or one of its variants). This is a variant of _callOptionalReturn that silently catches all reverts and returns a bool instead. |
Errors
SafeERC20FailedOperation
An operation with an ERC-20 token failed.
error SafeERC20FailedOperation(address token);
SafeERC20FailedDecreaseAllowance
Indicates a failed decreaseAllowance request.
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
ERC20
Inherits: Context, IERC20, IERC20Metadata, IERC20Errors
Implementation of the {IERC20} interface.
This implementation is agnostic to the way tokens are created. This means
that a supply mechanism has to be added in a derived contract using {_mint}.
TIP: For a detailed writeup see our guide
https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
to implement supply mechanisms].
The default value of {decimals} is 18. To change this, you should override
this function so it returns a different value.
We have followed general OpenZeppelin Contracts guidelines: functions revert
instead returning false on failure. This behavior is nonetheless
conventional and does not conflict with the expectations of ERC-20
applications.
State Variables
_balances
mapping(address account => uint256) private _balances;
_allowances
mapping(address account => mapping(address spender => uint256)) private _allowances;
_totalSupply
uint256 private _totalSupply;
_name
string private _name;
_symbol
string private _symbol;
Functions
constructor
Sets the values for name and {symbol}. Both values are immutable: they can only be set once during construction.
constructor(string memory name_, string memory symbol_);
name
Returns the name of the token.
function name() public view virtual returns (string memory);
symbol
Returns the symbol of the token, usually a shorter version of the name.
function symbol() public view virtual returns (string memory);
decimals
Returns the number of decimals used to get its user representation.
For example, if decimals equals 2, a balance of 505 tokens should
be displayed to a user as 5.05 (505 / 10 ** 2).
Tokens usually opt for a value of 18, imitating the relationship between
Ether and Wei. This is the default value returned by this function, unless
it's overridden.
NOTE: This information is only used for display purposes: it in
no way affects any of the arithmetic of the contract, including
IERC20-balanceOf and {IERC20-transfer}.
function decimals() public view virtual returns (uint8);
totalSupply
function totalSupply() public view virtual returns (uint256);
balanceOf
function balanceOf(address account) public view virtual returns (uint256);
transfer
*See IERC20-transfer. Requirements:
tocannot be the zero address.- the caller must have a balance of at least
value.*
function transfer(address to, uint256 value) public virtual returns (bool);
allowance
function allowance(address owner, address spender) public view virtual returns (uint256);
approve
*See IERC20-approve.
NOTE: If value is the maximum uint256, the allowance is not updated on
transferFrom. This is semantically equivalent to an infinite approval.
Requirements:
spendercannot be the zero address.*
function approve(address spender, uint256 value) public virtual returns (bool);
transferFrom
*See IERC20-transferFrom.
Skips emitting an {Approval} event indicating an allowance update. This is not
required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].
NOTE: Does not update the allowance if the current allowance
is the maximum uint256.
Requirements:
fromandtocannot be the zero address.frommust have a balance of at leastvalue.- the caller must have allowance for
from's tokens of at leastvalue.*
function transferFrom(address from, address to, uint256 value) public virtual returns (bool);
_transfer
Moves a value amount of tokens from from to to.
This internal function is equivalent to transfer, and can be used to
e.g. implement automatic token fees, slashing mechanisms, etc.
Emits a {Transfer} event.
NOTE: This function is not virtual, {_update} should be overridden instead.
function _transfer(address from, address to, uint256 value) internal;
_update
Transfers a value amount of tokens from from to to, or alternatively mints (or burns) if from
(or to) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
this function.
Emits a {Transfer} event.
function _update(address from, address to, uint256 value) internal virtual;
_mint
Creates a value amount of tokens and assigns them to account, by transferring it from address(0).
Relies on the _update mechanism
Emits a {Transfer} event with from set to the zero address.
NOTE: This function is not virtual, {_update} should be overridden instead.
function _mint(address account, uint256 value) internal;
_burn
Destroys a value amount of tokens from account, lowering the total supply.
Relies on the _update mechanism.
Emits a {Transfer} event with to set to the zero address.
NOTE: This function is not virtual, {_update} should be overridden instead
function _burn(address account, uint256 value) internal;
_approve
*Sets value as the allowance of spender over the owner's tokens.
This internal function is equivalent to approve, and can be used to
e.g. set automatic allowances for certain subsystems, etc.
Emits an {Approval} event.
Requirements:
ownercannot be the zero address.spendercannot be the zero address. Overrides to this logic should be done to the variant with an additionalbool emitEventargument.*
function _approve(address owner, address spender, uint256 value) internal;
_approve
*Variant of _approve with an optional flag to enable or disable the {Approval} event.
By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
_spendAllowance during the transferFrom operation set the flag to false. This saves gas by not emitting any
Approval event during transferFrom operations.
Anyone who wishes to continue emitting Approval events on thetransferFrom operation can force the flag to
true using the following override:
function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
super._approve(owner, spender, value, true);
}
Requirements are the same as {_approve}.*
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual;
_spendAllowance
Updates owner's allowance for spender based on spent value.
Does not update the allowance value in case of infinite allowance.
Revert if not enough allowance is available.
Does not emit an {Approval} event.
function _spendAllowance(address owner, address spender, uint256 value) internal virtual;
IERC20
Interface of the ERC-20 standard as defined in the ERC.
Functions
totalSupply
Returns the value of tokens in existence.
function totalSupply() external view returns (uint256);
balanceOf
Returns the value of tokens owned by account.
function balanceOf(address account) external view returns (uint256);
transfer
Moves a value amount of tokens from the caller's account to to.
Returns a boolean value indicating whether the operation succeeded.
Emits a Transfer event.
function transfer(address to, uint256 value) external returns (bool);
allowance
Returns the remaining number of tokens that spender will be
allowed to spend on behalf of owner through transferFrom. This is
zero by default.
This value changes when {approve} or {transferFrom} are called.
function allowance(address owner, address spender) external view returns (uint256);
approve
Sets a value amount of tokens as the allowance of spender over the
caller's tokens.
Returns a boolean value indicating whether the operation succeeded.
IMPORTANT: Beware that changing an allowance with this method brings the risk
that someone may use both the old and the new allowance by unfortunate
transaction ordering. One possible solution to mitigate this race
condition is to first reduce the spender's allowance to 0 and set the
desired value afterwards:
https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
Emits an Approval event.
function approve(address spender, uint256 value) external returns (bool);
transferFrom
Moves a value amount of tokens from from to to using the
allowance mechanism. value is then deducted from the caller's
allowance.
Returns a boolean value indicating whether the operation succeeded.
Emits a Transfer event.
function transferFrom(address from, address to, uint256 value) external returns (bool);
Events
Transfer
Emitted when value tokens are moved from one account (from) to
another (to).
Note that value may be zero.
event Transfer(address indexed from, address indexed to, uint256 value);
Approval
Emitted when the allowance of a spender for an owner is set by
a call to approve. value is the new allowance.
event Approval(address indexed owner, address indexed spender, uint256 value);
Contents
Contents
ERC6909ContentURI
Inherits: ERC6909, IERC6909ContentURI
Implementation of the Content URI extension defined in ERC6909.
State Variables
_contractURI
string private _contractURI;
_tokenURIs
mapping(uint256 id => string) private _tokenURIs;
Functions
contractURI
Returns URI for the contract.
function contractURI() public view virtual override returns (string memory);
tokenURI
Returns the URI for the token of type id.
function tokenURI(uint256 id) public view virtual override returns (string memory);
_setContractURI
Sets the contractURI for the contract. Emits a {ContractURIUpdated} event.
function _setContractURI(string memory newContractURI) internal virtual;
_setTokenURI
Sets the tokenURI for a given token of type id.
Emits a {URI} event.
function _setTokenURI(uint256 id, string memory newTokenURI) internal virtual;
Events
ContractURIUpdated
Event emitted when the contract URI is changed. See https://eips.ethereum.org/EIPS/eip-7572[ERC-7572] for details.
event ContractURIUpdated();
URI
See IERC1155-URI
event URI(string value, uint256 indexed id);
ERC6909Metadata
Inherits: ERC6909, IERC6909Metadata
Implementation of the Metadata extension defined in ERC6909. Exposes the name, symbol, and decimals of each token id.
State Variables
_tokenMetadata
mapping(uint256 id => TokenMetadata) private _tokenMetadata;
Functions
name
Returns the name of the token of type id.
function name(uint256 id) public view virtual override returns (string memory);
symbol
Returns the ticker symbol of the token of type id.
function symbol(uint256 id) public view virtual override returns (string memory);
decimals
Returns the number of decimals for the token of type id.
function decimals(uint256 id) public view virtual override returns (uint8);
_setName
Sets the name for a given token of type id.
Emits an ERC6909NameUpdated event.
function _setName(uint256 id, string memory newName) internal virtual;
_setSymbol
Sets the symbol for a given token of type id.
Emits an ERC6909SymbolUpdated event.
function _setSymbol(uint256 id, string memory newSymbol) internal virtual;
_setDecimals
Sets the decimals for a given token of type id.
Emits an ERC6909DecimalsUpdated event.
function _setDecimals(uint256 id, uint8 newDecimals) internal virtual;
Events
ERC6909NameUpdated
The name of the token of type id was updated to newName.
event ERC6909NameUpdated(uint256 indexed id, string newName);
ERC6909SymbolUpdated
The symbol for the token of type id was updated to newSymbol.
event ERC6909SymbolUpdated(uint256 indexed id, string newSymbol);
ERC6909DecimalsUpdated
The decimals value for token of type id was updated to newDecimals.
event ERC6909DecimalsUpdated(uint256 indexed id, uint8 newDecimals);
Structs
TokenMetadata
struct TokenMetadata {
string name;
string symbol;
uint8 decimals;
}
ERC6909TokenSupply
Inherits: ERC6909, IERC6909TokenSupply
Implementation of the Token Supply extension defined in ERC6909. Tracks the total supply of each token id individually.
State Variables
_totalSupplies
mapping(uint256 id => uint256) private _totalSupplies;
Functions
totalSupply
Returns the total supply of the token of type id.
function totalSupply(uint256 id) public view virtual override returns (uint256);
_update
Override the _update function to update the total supply of each token id as necessary.
function _update(address from, address to, uint256 id, uint256 amount) internal virtual override;
ERC6909
Inherits: Context, ERC165, IERC6909
Implementation of ERC-6909. See https://eips.ethereum.org/EIPS/eip-6909
State Variables
_balances
mapping(address owner => mapping(uint256 id => uint256)) private _balances;
_operatorApprovals
mapping(address owner => mapping(address operator => bool)) private _operatorApprovals;
_allowances
mapping(address owner => mapping(address spender => mapping(uint256 id => uint256))) private _allowances;
Functions
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
balanceOf
Returns the amount of tokens of type id owned by owner.
function balanceOf(address owner, uint256 id) public view virtual override returns (uint256);
allowance
Returns the amount of tokens of type id that spender is allowed to spend on behalf of owner.
NOTE: Does not include operator allowances.
function allowance(address owner, address spender, uint256 id) public view virtual override returns (uint256);
isOperator
Returns true if spender is set as an operator for owner.
function isOperator(address owner, address spender) public view virtual override returns (bool);
approve
Sets an approval to spender for amount of tokens of type id from the caller's tokens. An amount of
type(uint256).max signifies an unlimited approval.
Must return true.
function approve(address spender, uint256 id, uint256 amount) public virtual override returns (bool);
setOperator
Grants or revokes unlimited transfer permission of any token id to spender for the caller's tokens.
Must return true.
function setOperator(address spender, bool approved) public virtual override returns (bool);
transfer
Transfers amount of token type id from the caller's account to receiver.
Must return true.
function transfer(address receiver, uint256 id, uint256 amount) public virtual override returns (bool);
transferFrom
Transfers amount of token type id from sender to receiver.
Must return true.
function transferFrom(address sender, address receiver, uint256 id, uint256 amount)
public
virtual
override
returns (bool);
_mint
Creates amount of token id and assigns them to account, by transferring it from address(0).
Relies on the _update mechanism.
Emits a {Transfer} event with from set to the zero address.
NOTE: This function is not virtual, {_update} should be overridden instead.
function _mint(address to, uint256 id, uint256 amount) internal;
_transfer
Moves amount of token id from from to to without checking for approvals. This function verifies
that neither the sender nor the receiver are address(0), which means it cannot mint or burn tokens.
Relies on the _update mechanism.
Emits a {Transfer} event.
NOTE: This function is not virtual, {_update} should be overridden instead.
function _transfer(address from, address to, uint256 id, uint256 amount) internal;
_burn
Destroys a amount of token id from account.
Relies on the _update mechanism.
Emits a {Transfer} event with to set to the zero address.
NOTE: This function is not virtual, {_update} should be overridden instead
function _burn(address from, uint256 id, uint256 amount) internal;
_update
Transfers amount of token id from from to to, or alternatively mints (or burns) if from
(or to) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
this function.
Emits a {Transfer} event.
function _update(address from, address to, uint256 id, uint256 amount) internal virtual;
_approve
*Sets amount as the allowance of spender over the owner's id tokens.
This internal function is equivalent to approve, and can be used to e.g. set automatic allowances for certain
subsystems, etc.
Emits an {Approval} event.
Requirements:
ownercannot be the zero address.spendercannot be the zero address.*
function _approve(address owner, address spender, uint256 id, uint256 amount) internal virtual;
_setOperator
*Approve spender to operate on all of owner's tokens
This internal function is equivalent to setOperator, and can be used to e.g. set automatic allowances for
certain subsystems, etc.
Emits an {OperatorSet} event.
Requirements:
ownercannot be the zero address.spendercannot be the zero address.*
function _setOperator(address owner, address spender, bool approved) internal virtual;
_spendAllowance
Updates owner's allowance for spender based on spent amount.
Does not update the allowance value in case of infinite allowance.
Revert if not enough allowance is available.
Does not emit an {Approval} event.
function _spendAllowance(address owner, address spender, uint256 id, uint256 amount) internal virtual;
Errors
ERC6909InsufficientBalance
error ERC6909InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 id);
ERC6909InsufficientAllowance
error ERC6909InsufficientAllowance(address spender, uint256 allowance, uint256 needed, uint256 id);
ERC6909InvalidApprover
error ERC6909InvalidApprover(address approver);
ERC6909InvalidReceiver
error ERC6909InvalidReceiver(address receiver);
ERC6909InvalidSender
error ERC6909InvalidSender(address sender);
ERC6909InvalidSpender
error ERC6909InvalidSpender(address spender);
Contents
Contents
- ERC721Burnable
- ERC721Consecutive
- ERC721Enumerable
- ERC721Pausable
- ERC721Royalty
- ERC721URIStorage
- ERC721Votes
- ERC721Wrapper
- IERC721Enumerable
- IERC721Metadata
ERC721Burnable
ERC-721 Token that can be burned (destroyed).
Functions
burn
*Burns tokenId. See ERC721-_burn.
Requirements:
- The caller must own
tokenIdor be an approved operator.*
function burn(uint256 tokenId) public virtual;
ERC721Consecutive
Implementation of the ERC-2309 "Consecutive Transfer Extension" as defined in https://eips.ethereum.org/EIPS/eip-2309[ERC-2309]. This extension allows the minting of large batches of tokens, during contract construction only. For upgradeable contracts this implies that batch minting is only available during proxy deployment, and not in subsequent upgrades. These batches are limited to 5000 tokens at a time by default to accommodate off-chain indexers. Using this extension removes the ability to mint single tokens during contract construction. This ability is regained after construction. During construction, only batch minting is allowed. IMPORTANT: This extension does not call the _update function for tokens minted in batch. Any logic added to this function through overrides will not be triggered when token are minted in batch. You may want to also override {_increaseBalance} or {_mintConsecutive} to account for these mints. IMPORTANT: When overriding {_mintConsecutive}, be careful about call ordering. {ownerOf} may return invalid values during the {_mintConsecutive} execution if the super call is not called first. To be safe, execute the super call before your custom logic.
State Variables
_sequentialOwnership
Checkpoints.Trace160 private _sequentialOwnership;
_sequentialBurn
BitMaps.BitMap private _sequentialBurn;
Functions
_maxBatchSize
Maximum size of a batch of consecutive tokens. This is designed to limit stress on off-chain indexing services that have to record one entry per token, and have protections against "unreasonably large" batches of tokens. NOTE: Overriding the default value of 5000 will not cause on-chain issues, but may result in the asset not being correctly supported by off-chain indexing services (including marketplaces).
function _maxBatchSize() internal view virtual returns (uint96);
_ownerOf
See ERC721-_ownerOf. Override that checks the sequential ownership structure for tokens that have been minted as part of a batch, and not yet transferred.
function _ownerOf(uint256 tokenId) internal view virtual override returns (address);
_mintConsecutive
*Mint a batch of tokens of length batchSize for to. Returns the token id of the first token minted in the
batch; if batchSize is 0, returns the number of consecutive ids minted so far.
Requirements:
batchSizemust not be greater than _maxBatchSize.- The function is called in the constructor of the contract (directly or indirectly).
CAUTION: Does not emit a
Transferevent. This is ERC-721 compliant as long as it is done inside of the constructor, which is enforced by this function. CAUTION: Does not invokeonERC721Receivedon the receiver. Emits a {IERC2309-ConsecutiveTransfer} event.*
function _mintConsecutive(address to, uint96 batchSize) internal virtual returns (uint96);
_update
See ERC721-_update. Override version that restricts normal minting to after construction. WARNING: Using {ERC721Consecutive} prevents minting during construction in favor of {_mintConsecutive}. After construction, {_mintConsecutive} is no longer available and minting through {_update} becomes available.
function _update(address to, uint256 tokenId, address auth) internal virtual override returns (address);
_firstConsecutiveId
Used to offset the first token id in _nextConsecutiveId
function _firstConsecutiveId() internal view virtual returns (uint96);
_nextConsecutiveId
Returns the next tokenId to mint using _mintConsecutive. It will return {_firstConsecutiveId} if no consecutive tokenId has been minted before.
function _nextConsecutiveId() private view returns (uint96);
Errors
ERC721ForbiddenBatchMint
Batch mint is restricted to the constructor. Any batch mint not emitting the IERC721-Transfer event outside of the constructor is non ERC-721 compliant.
error ERC721ForbiddenBatchMint();
ERC721ExceededMaxBatchMint
Exceeds the max amount of mints per batch.
error ERC721ExceededMaxBatchMint(uint256 batchSize, uint256 maxBatch);
ERC721ForbiddenMint
Individual minting is not allowed.
error ERC721ForbiddenMint();
ERC721ForbiddenBatchBurn
Batch burn is not supported.
error ERC721ForbiddenBatchBurn();
ERC721Enumerable
Inherits: ERC721, IERC721Enumerable
This implements an optional extension of {ERC721} defined in the ERC that adds enumerability
of all the token ids in the contract as well as all token ids owned by each account.
CAUTION: {ERC721} extensions that implement custom balanceOf logic, such as {ERC721Consecutive},
interfere with enumerability and should not be used together with {ERC721Enumerable}.
State Variables
_ownedTokens
mapping(address owner => mapping(uint256 index => uint256)) private _ownedTokens;
_ownedTokensIndex
mapping(uint256 tokenId => uint256) private _ownedTokensIndex;
_allTokens
uint256[] private _allTokens;
_allTokensIndex
mapping(uint256 tokenId => uint256) private _allTokensIndex;
Functions
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
tokenOfOwnerByIndex
Enumerate NFTs assigned to an owner
Throws if _index >= balanceOf(_owner) or if
_owner is the zero address, representing invalid NFTs.
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
owner | address | |
index | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The token identifier for the _indexth NFT assigned to _owner, (sort order not specified) |
totalSupply
Count NFTs tracked by this contract
function totalSupply() public view virtual returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | A count of valid NFTs tracked by this contract, where each one of them has an assigned and queryable owner not equal to the zero address |
tokenByIndex
Enumerate valid NFTs
Throws if _index >= totalSupply().
function tokenByIndex(uint256 index) public view virtual returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The token identifier for the _indexth NFT, (sort order not specified) |
_update
Transfers tokenId from its current owner to to, or alternatively mints (or burns) if the current owner
(or to) is the zero address. Returns the owner of the tokenId before the update.
The auth argument is optional. If the value passed is non 0, then this function will check that
auth is either the owner of the token, or approved to operate on the token (by the owner).
Emits a {Transfer} event.
NOTE: If overriding this function in a way that tracks balances, see also {_increaseBalance}.
function _update(address to, uint256 tokenId, address auth) internal virtual override returns (address);
_addTokenToOwnerEnumeration
Private function to add a token to this extension's ownership-tracking data structures.
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private;
Parameters
| Name | Type | Description |
|---|---|---|
to | address | address representing the new owner of the given token ID |
tokenId | uint256 | uint256 ID of the token to be added to the tokens list of the given address |
_addTokenToAllTokensEnumeration
Private function to add a token to this extension's token tracking data structures.
function _addTokenToAllTokensEnumeration(uint256 tokenId) private;
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | uint256 ID of the token to be added to the tokens list |
_removeTokenFromOwnerEnumeration
Private function to remove a token from this extension's ownership-tracking data structures. Note that
while the token is not assigned a new owner, the _ownedTokensIndex mapping is not updated: this allows for
gas optimizations e.g. when performing a transfer operation (avoiding double writes).
This has O(1) time complexity, but alters the order of the _ownedTokens array.
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private;
Parameters
| Name | Type | Description |
|---|---|---|
from | address | address representing the previous owner of the given token ID |
tokenId | uint256 | uint256 ID of the token to be removed from the tokens list of the given address |
_removeTokenFromAllTokensEnumeration
Private function to remove a token from this extension's token tracking data structures. This has O(1) time complexity, but alters the order of the _allTokens array.
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private;
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | uint256 ID of the token to be removed from the tokens list |
_increaseBalance
See ERC721-_increaseBalance. We need that to account tokens that were minted in batch
function _increaseBalance(address account, uint128 amount) internal virtual override;
Errors
ERC721OutOfBoundsIndex
An owner's token query was out of bounds for index.
NOTE: The owner being address(0) indicates a global out of bounds index.
error ERC721OutOfBoundsIndex(address owner, uint256 index);
ERC721EnumerableForbiddenBatchMint
Batch mint is not allowed.
error ERC721EnumerableForbiddenBatchMint();
ERC721Pausable
ERC-721 token with pausable token transfers, minting and burning. Useful for scenarios such as preventing trades until the end of an evaluation period, or having an emergency switch for freezing all token transfers in the event of a large bug. IMPORTANT: This contract does not include public pause and unpause functions. In addition to inheriting this contract, you must define both functions, invoking the {Pausable-_pause} and {Pausable-_unpause} internal functions, with appropriate access control, e.g. using {AccessControl} or {Ownable}. Not doing so will make the contract pause mechanism of the contract unreachable, and thus unusable.
Functions
_update
*See ERC721-_update. Requirements:
- the contract must not be paused.*
function _update(address to, uint256 tokenId, address auth) internal virtual override whenNotPaused returns (address);
ERC721Royalty
Extension of ERC-721 with the ERC-2981 NFT Royalty Standard, a standardized way to retrieve royalty payment information. Royalty information can be specified globally for all token ids via {ERC2981-_setDefaultRoyalty}, and/or individually for specific token ids via {ERC2981-_setTokenRoyalty}. The latter takes precedence over the first. IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the ERC. Marketplaces are expected to voluntarily pay royalties together with sales, but note that this standard is not yet widely supported.
Functions
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC2981) returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
ERC721URIStorage
ERC-721 token with storage based token URI management.
State Variables
ERC4906_INTERFACE_ID
bytes4 private constant ERC4906_INTERFACE_ID = bytes4(0x49064906);
_tokenURIs
mapping(uint256 tokenId => string) private _tokenURIs;
Functions
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, IERC165) returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
tokenURI
A distinct Uniform Resource Identifier (URI) for a given asset.
Throws if _tokenId is not a valid NFT. URIs are defined in RFC
3986. The URI may point to a JSON file that conforms to the "ERC721
Metadata JSON Schema".
function tokenURI(uint256 tokenId) public view virtual override returns (string memory);
_setTokenURI
Sets _tokenURI as the tokenURI of tokenId.
Emits {IERC4906-MetadataUpdate}.
function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual;
ERC721Votes
Extension of ERC-721 to support voting and delegation as implemented by {Votes}, where each individual NFT counts as 1 vote unit. Tokens do not count as votes until they are delegated, because votes must be tracked which incurs an additional cost on every transfer. Token holders can either delegate to a trusted representative who will decide how to make use of the votes in governance decisions, or they can delegate to themselves to be their own representative.
Functions
_update
See ERC721-_update. Adjusts votes when tokens are transferred. Emits a {IVotes-DelegateVotesChanged} event.
function _update(address to, uint256 tokenId, address auth) internal virtual override returns (address);
_getVotingUnits
Returns the balance of account.
WARNING: Overriding this function will likely result in incorrect vote tracking.
function _getVotingUnits(address account) internal view virtual override returns (uint256);
_increaseBalance
See ERC721-_increaseBalance. We need that to account tokens that were minted in batch.
function _increaseBalance(address account, uint128 amount) internal virtual override;
ERC721Wrapper
Inherits: ERC721, IERC721Receiver
Extension of the ERC-721 token contract to support token wrapping. Users can deposit and withdraw an "underlying token" and receive a "wrapped token" with a matching tokenId. This is useful in conjunction with other modules. For example, combining this wrapping mechanism with {ERC721Votes} will allow the wrapping of an existing "basic" ERC-721 into a governance token.
State Variables
_underlying
IERC721 private immutable _underlying;
Functions
constructor
constructor(IERC721 underlyingToken);
depositFor
Allow a user to deposit underlying tokens and mint the corresponding tokenIds.
function depositFor(address account, uint256[] memory tokenIds) public virtual returns (bool);
withdrawTo
Allow a user to burn wrapped tokens and withdraw the corresponding tokenIds of the underlying tokens.
function withdrawTo(address account, uint256[] memory tokenIds) public virtual returns (bool);
onERC721Received
Overrides IERC721Receiver-onERC721Received to allow minting on direct ERC-721 transfers to this contract. In case there's data attached, it validates that the operator is this contract, so only trusted data is accepted from {depositFor}. WARNING: Doesn't work with unsafe transfers (eg. {IERC721-transferFrom}). Use {ERC721Wrapper-_recover} for recovering in that scenario.
function onERC721Received(address, address from, uint256 tokenId, bytes memory) public virtual returns (bytes4);
_recover
Mint a wrapped token to cover any underlyingToken that would have been transferred by mistake. Internal function that can be exposed with access control if desired.
function _recover(address account, uint256 tokenId) internal virtual returns (uint256);
underlying
Returns the underlying token.
function underlying() public view virtual returns (IERC721);
Errors
ERC721UnsupportedToken
The received ERC-721 token couldn't be wrapped.
error ERC721UnsupportedToken(address token);
IERC721Enumerable
Inherits: IERC721
See https://eips.ethereum.org/EIPS/eip-721
Functions
totalSupply
Returns the total amount of tokens stored by the contract.
function totalSupply() external view returns (uint256);
tokenOfOwnerByIndex
Returns a token ID owned by owner at a given index of its token list.
Use along with {balanceOf} to enumerate all of owner's tokens.
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
tokenByIndex
Returns a token ID at a given index of all the tokens stored by the contract.
Use along with totalSupply to enumerate all tokens.
function tokenByIndex(uint256 index) external view returns (uint256);
IERC721Metadata
Inherits: IERC721
See https://eips.ethereum.org/EIPS/eip-721
Functions
name
Returns the token collection name.
function name() external view returns (string memory);
symbol
Returns the token collection symbol.
function symbol() external view returns (string memory);
tokenURI
Returns the Uniform Resource Identifier (URI) for tokenId token.
function tokenURI(uint256 tokenId) external view returns (string memory);
Contents
ERC721Holder
Inherits: IERC721Receiver
Implementation of the {IERC721Receiver} interface. Accepts all token transfers. Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.
Functions
onERC721Received
See IERC721Receiver-onERC721Received.
Always returns IERC721Receiver.onERC721Received.selector.
function onERC721Received(address, address, uint256, bytes memory) public virtual returns (bytes4);
ERC721Utils
Library that provide common ERC-721 utility functions. See https://eips.ethereum.org/EIPS/eip-721[ERC-721]. Available since v5.1.
Functions
checkOnERC721Received
Performs an acceptance check for the provided operator by calling IERC721Receiver-onERC721Received
on the to address. The operator is generally the address that initiated the token transfer (i.e. msg.sender).
The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA).
Otherwise, the recipient must implement {IERC721Receiver-onERC721Received} and return the acceptance magic value to accept
the transfer.
function checkOnERC721Received(address operator, address from, address to, uint256 tokenId, bytes memory data)
internal;
ERC721
Inherits: Context, ERC165, IERC721, IERC721Metadata, IERC721Errors
Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC-721] Non-Fungible Token Standard, including the Metadata extension, but not including the Enumerable extension, which is available separately as {ERC721Enumerable}.
State Variables
_name
string private _name;
_symbol
string private _symbol;
_owners
mapping(uint256 tokenId => address) private _owners;
_balances
mapping(address owner => uint256) private _balances;
_tokenApprovals
mapping(uint256 tokenId => address) private _tokenApprovals;
_operatorApprovals
mapping(address owner => mapping(address operator => bool)) private _operatorApprovals;
Functions
constructor
Initializes the contract by setting a name and a symbol to the token collection.
constructor(string memory name_, string memory symbol_);
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
balanceOf
Count all NFTs assigned to an owner
NFTs assigned to the zero address are considered invalid, and this function throws for queries about the zero address.
function balanceOf(address owner) public view virtual returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
owner | address |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The number of NFTs owned by _owner, possibly zero |
ownerOf
Find the owner of an NFT
NFTs assigned to zero address are considered invalid, and queries about them do throw.
function ownerOf(uint256 tokenId) public view virtual returns (address);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The address of the owner of the NFT |
name
A descriptive name for a collection of NFTs in this contract
function name() public view virtual returns (string memory);
symbol
An abbreviated name for NFTs in this contract
function symbol() public view virtual returns (string memory);
tokenURI
A distinct Uniform Resource Identifier (URI) for a given asset.
Throws if _tokenId is not a valid NFT. URIs are defined in RFC
3986. The URI may point to a JSON file that conforms to the "ERC721
Metadata JSON Schema".
function tokenURI(uint256 tokenId) public view virtual returns (string memory);
_baseURI
Base URI for computing tokenURI. If set, the resulting URI for each
token will be the concatenation of the baseURI and the tokenId. Empty
by default, can be overridden in child contracts.
function _baseURI() internal view virtual returns (string memory);
approve
Change or reaffirm the approved address for an NFT
The zero address indicates there is no approved address.
Throws unless msg.sender is the current NFT owner, or an authorized
operator of the current owner.
function approve(address to, uint256 tokenId) public virtual;
Parameters
| Name | Type | Description |
|---|---|---|
to | address | |
tokenId | uint256 |
getApproved
Get the approved address for a single NFT
Throws if _tokenId is not a valid NFT.
function getApproved(uint256 tokenId) public view virtual returns (address);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The approved address for this NFT, or the zero address if there is none |
setApprovalForAll
Enable or disable approval for a third party ("operator") to manage
all of msg.sender's assets
Emits the ApprovalForAll event. The contract MUST allow multiple operators per owner.
function setApprovalForAll(address operator, bool approved) public virtual;
Parameters
| Name | Type | Description |
|---|---|---|
operator | address | |
approved | bool |
isApprovedForAll
Query if an address is an authorized operator for another address
function isApprovedForAll(address owner, address operator) public view virtual returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
owner | address | |
operator | address |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if _operator is an approved operator for _owner, false otherwise |
transferFrom
Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE
TO CONFIRM THAT _to IS CAPABLE OF RECEIVING NFTS OR ELSE
THEY MAY BE PERMANENTLY LOST
Throws unless msg.sender is the current owner, an authorized
operator, or the approved address for this NFT. Throws if _from is
not the current owner. Throws if _to is the zero address. Throws if
_tokenId is not a valid NFT.
function transferFrom(address from, address to, uint256 tokenId) public virtual;
Parameters
| Name | Type | Description |
|---|---|---|
from | address | |
to | address | |
tokenId | uint256 |
safeTransferFrom
Transfers the ownership of an NFT from one address to another address
Throws unless msg.sender is the current owner, an authorized
operator, or the approved address for this NFT. Throws if _from is
not the current owner. Throws if _to is the zero address. Throws if
_tokenId is not a valid NFT. When transfer is complete, this function
checks if _to is a smart contract (code size > 0). If so, it calls
onERC721Received on _to and throws if the return value is not
bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")).
function safeTransferFrom(address from, address to, uint256 tokenId) public;
Parameters
| Name | Type | Description |
|---|---|---|
from | address | |
to | address | |
tokenId | uint256 |
safeTransferFrom
Transfers the ownership of an NFT from one address to another address
Throws unless msg.sender is the current owner, an authorized
operator, or the approved address for this NFT. Throws if _from is
not the current owner. Throws if _to is the zero address. Throws if
_tokenId is not a valid NFT. When transfer is complete, this function
checks if _to is a smart contract (code size > 0). If so, it calls
onERC721Received on _to and throws if the return value is not
bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")).
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual;
Parameters
| Name | Type | Description |
|---|---|---|
from | address | |
to | address | |
tokenId | uint256 | |
data | bytes | Additional data with no specified format, sent in call to _to |
_ownerOf
Returns the owner of the tokenId. Does NOT revert if token doesn't exist
IMPORTANT: Any overrides to this function that add ownership of tokens not tracked by the
core ERC-721 logic MUST be matched with the use of _increaseBalance to keep balances
consistent with ownership. The invariant to preserve is that for any address a the value returned by
balanceOf(a) must be equal to the number of tokens such that _ownerOf(tokenId) is a.
function _ownerOf(uint256 tokenId) internal view virtual returns (address);
_getApproved
Returns the approved address for tokenId. Returns 0 if tokenId is not minted.
function _getApproved(uint256 tokenId) internal view virtual returns (address);
_isAuthorized
Returns whether spender is allowed to manage owner's tokens, or tokenId in
particular (ignoring whether it is owned by owner).
WARNING: This function assumes that owner is the actual owner of tokenId and does not verify this
assumption.
function _isAuthorized(address owner, address spender, uint256 tokenId) internal view virtual returns (bool);
_checkAuthorized
*Checks if spender can operate on tokenId, assuming the provided owner is the actual owner.
Reverts if:
spenderdoes not have approval fromownerfortokenId.spenderdoes not have approval to manage all ofowner's assets. WARNING: This function assumes thatowneris the actual owner oftokenIdand does not verify this assumption.*
function _checkAuthorized(address owner, address spender, uint256 tokenId) internal view virtual;
_increaseBalance
Unsafe write access to the balances, used by extensions that "mint" tokens using an ownerOf override. NOTE: the value is limited to type(uint128).max. This protect against _balance overflow. It is unrealistic that a uint256 would ever overflow from increments when these increments are bounded to uint128 values. WARNING: Increasing an account's balance using this function tends to be paired with an override of the {_ownerOf} function to resolve the ownership of the corresponding tokens so that balances and ownership remain consistent with one another.
function _increaseBalance(address account, uint128 value) internal virtual;
_update
Transfers tokenId from its current owner to to, or alternatively mints (or burns) if the current owner
(or to) is the zero address. Returns the owner of the tokenId before the update.
The auth argument is optional. If the value passed is non 0, then this function will check that
auth is either the owner of the token, or approved to operate on the token (by the owner).
Emits a {Transfer} event.
NOTE: If overriding this function in a way that tracks balances, see also {_increaseBalance}.
function _update(address to, uint256 tokenId, address auth) internal virtual returns (address);
_mint
*Mints tokenId and transfers it to to.
WARNING: Usage of this method is discouraged, use _safeMint whenever possible
Requirements:
tokenIdmust not exist.tocannot be the zero address. Emits a {Transfer} event.*
function _mint(address to, uint256 tokenId) internal;
_safeMint
*Mints tokenId, transfers it to to and checks for to acceptance.
Requirements:
tokenIdmust not exist.- If
torefers to a smart contract, it must implement IERC721Receiver-onERC721Received, which is called upon a safe transfer. Emits a {Transfer} event.*
function _safeMint(address to, uint256 tokenId) internal;
_safeMint
Same as _safeMint, with an additional data parameter which is
forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual;
_burn
*Destroys tokenId.
The approval is cleared when the token is burned.
This is an internal function that does not check if the sender is authorized to operate on the token.
Requirements:
tokenIdmust exist. Emits a {Transfer} event.*
function _burn(uint256 tokenId) internal;
_transfer
*Transfers tokenId from from to to.
As opposed to transferFrom, this imposes no restrictions on msg.sender.
Requirements:
tocannot be the zero address.tokenIdtoken must be owned byfrom. Emits a {Transfer} event.*
function _transfer(address from, address to, uint256 tokenId) internal;
_safeTransfer
*Safely transfers tokenId token from from to to, checking that contract recipients
are aware of the ERC-721 standard to prevent tokens from being forever locked.
data is additional data, it has no specified format and it is sent in call to to.
This internal function is like safeTransferFrom in the sense that it invokes
{IERC721Receiver-onERC721Received} on the receiver, and can be used to e.g.
implement alternative mechanisms to perform token transfer, such as signature-based.
Requirements:
tokenIdtoken must exist and be owned byfrom.tocannot be the zero address.fromcannot be the zero address.- If
torefers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. Emits a {Transfer} event.*
function _safeTransfer(address from, address to, uint256 tokenId) internal;
_safeTransfer
Same as {xref-ERC721-_safeTransfer-address-address-uint256-}[_safeTransfer], with an additional data parameter which is
forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual;
_approve
Approve to to operate on tokenId
The auth argument is optional. If the value passed is non 0, then this function will check that auth is
either the owner of the token, or approved to operate on all tokens held by this owner.
Emits an {Approval} event.
Overrides to this logic should be done to the variant with an additional bool emitEvent argument.
function _approve(address to, uint256 tokenId, address auth) internal;
_approve
Variant of _approve with an optional flag to enable or disable the {Approval} event. The event is not
emitted in the context of transfers.
function _approve(address to, uint256 tokenId, address auth, bool emitEvent) internal virtual;
_setApprovalForAll
*Approve operator to operate on all of owner tokens
Requirements:
- operator can't be the address zero. Emits an {ApprovalForAll} event.*
function _setApprovalForAll(address owner, address operator, bool approved) internal virtual;
_requireOwned
Reverts if the tokenId doesn't have a current owner (it hasn't been minted, or it has been burned).
Returns the owner.
Overrides to ownership logic should be done to _ownerOf.
function _requireOwned(uint256 tokenId) internal view returns (address);
IERC721
Inherits: IERC165
Required interface of an ERC-721 compliant contract.
Functions
balanceOf
Returns the number of tokens in owner's account.
function balanceOf(address owner) external view returns (uint256 balance);
ownerOf
*Returns the owner of the tokenId token.
Requirements:
tokenIdmust exist.*
function ownerOf(uint256 tokenId) external view returns (address owner);
safeTransferFrom
*Safely transfers tokenId token from from to to.
Requirements:
fromcannot be the zero address.tocannot be the zero address.tokenIdtoken must exist and be owned byfrom.- If the caller is not
from, it must be approved to move this token by either approve or {setApprovalForAll}. - If
torefers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. Emits a {Transfer} event.*
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
safeTransferFrom
*Safely transfers tokenId token from from to to, checking first that contract recipients
are aware of the ERC-721 protocol to prevent tokens from being forever locked.
Requirements:
fromcannot be the zero address.tocannot be the zero address.tokenIdtoken must exist and be owned byfrom.- If the caller is not
from, it must have been allowed to move this token by either approve or {setApprovalForAll}. - If
torefers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. Emits a {Transfer} event.*
function safeTransferFrom(address from, address to, uint256 tokenId) external;
transferFrom
*Transfers tokenId token from from to to.
WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC-721
or else they may be permanently lost. Usage of safeTransferFrom prevents loss, though the caller must
understand this adds an external call which potentially creates a reentrancy vulnerability.
Requirements:
fromcannot be the zero address.tocannot be the zero address.tokenIdtoken must be owned byfrom.- If the caller is not
from, it must be approved to move this token by either {approve} or {setApprovalForAll}. Emits a {Transfer} event.*
function transferFrom(address from, address to, uint256 tokenId) external;
approve
*Gives permission to to to transfer tokenId token to another account.
The approval is cleared when the token is transferred.
Only a single account can be approved at a time, so approving the zero address clears previous approvals.
Requirements:
- The caller must own the token or be an approved operator.
tokenIdmust exist. Emits an Approval event.*
function approve(address to, uint256 tokenId) external;
setApprovalForAll
*Approve or remove operator as an operator for the caller.
Operators can call transferFrom or {safeTransferFrom} for any token owned by the caller.
Requirements:
- The
operatorcannot be the address zero. Emits an {ApprovalForAll} event.*
function setApprovalForAll(address operator, bool approved) external;
getApproved
*Returns the account approved for tokenId token.
Requirements:
tokenIdmust exist.*
function getApproved(uint256 tokenId) external view returns (address operator);
isApprovedForAll
Returns if the operator is allowed to manage all of the assets of owner.
See setApprovalForAll
function isApprovedForAll(address owner, address operator) external view returns (bool);
Events
Transfer
Emitted when tokenId token is transferred from from to to.
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
Approval
Emitted when owner enables approved to manage the tokenId token.
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
ApprovalForAll
Emitted when owner enables or disables (approved) operator to manage all of its assets.
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
IERC721Receiver
Interface for any contract that wants to support safeTransfers from ERC-721 asset contracts.
Functions
onERC721Received
Whenever an {IERC721} tokenId token is transferred to this contract via {IERC721-safeTransferFrom}
by operator from from, this function is called.
It must return its Solidity selector to confirm the token transfer.
If any other value is returned or the interface is not implemented by the recipient, the transfer will be
reverted.
The selector can be obtained in Solidity with IERC721Receiver.onERC721Received.selector.
function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data)
external
returns (bytes4);
Contents
ERC2981
Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information. Royalty information can be specified globally for all token ids via _setDefaultRoyalty, and/or individually for specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first. Royalty is specified as a fraction of sale price. {_feeDenominator} is overridable but defaults to 10000, meaning the fee is specified in basis points by default. IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the ERC. Marketplaces are expected to voluntarily pay royalties together with sales, but note that this standard is not yet widely supported.
State Variables
_defaultRoyaltyInfo
RoyaltyInfo private _defaultRoyaltyInfo;
_tokenRoyaltyInfo
mapping(uint256 tokenId => RoyaltyInfo) private _tokenRoyaltyInfo;
Functions
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165) returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
royaltyInfo
Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of exchange. The royalty amount is denominated and should be paid in that same unit of exchange. NOTE: ERC-2981 allows setting the royalty to 100% of the price. In that case all the price would be sent to the royalty receiver and 0 tokens to the seller. Contracts dealing with royalty should consider empty transfers.
function royaltyInfo(uint256 tokenId, uint256 salePrice)
public
view
virtual
returns (address receiver, uint256 amount);
_feeDenominator
The denominator with which to interpret the fee set in _setTokenRoyalty and {_setDefaultRoyalty} as a fraction of the sale price. Defaults to 10000 so fees are expressed in basis points, but may be customized by an override.
function _feeDenominator() internal pure virtual returns (uint96);
_setDefaultRoyalty
*Sets the royalty information that all ids in this contract will default to. Requirements:
receivercannot be the zero address.feeNumeratorcannot be greater than the fee denominator.*
function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual;
_deleteDefaultRoyalty
Removes default royalty information.
function _deleteDefaultRoyalty() internal virtual;
_setTokenRoyalty
*Sets the royalty information for a specific token id, overriding the global default. Requirements:
receivercannot be the zero address.feeNumeratorcannot be greater than the fee denominator.*
function _setTokenRoyalty(uint256 tokenId, address receiver, uint96 feeNumerator) internal virtual;
_resetTokenRoyalty
Resets royalty information for the token id back to the global default.
function _resetTokenRoyalty(uint256 tokenId) internal virtual;
Errors
ERC2981InvalidDefaultRoyalty
The default royalty set is invalid (eg. (numerator / denominator) >= 1).
error ERC2981InvalidDefaultRoyalty(uint256 numerator, uint256 denominator);
ERC2981InvalidDefaultRoyaltyReceiver
The default royalty receiver is invalid.
error ERC2981InvalidDefaultRoyaltyReceiver(address receiver);
ERC2981InvalidTokenRoyalty
The royalty set for a specific tokenId is invalid (eg. (numerator / denominator) >= 1).
error ERC2981InvalidTokenRoyalty(uint256 tokenId, uint256 numerator, uint256 denominator);
ERC2981InvalidTokenRoyaltyReceiver
The royalty receiver for tokenId is invalid.
error ERC2981InvalidTokenRoyaltyReceiver(uint256 tokenId, address receiver);
Structs
RoyaltyInfo
struct RoyaltyInfo {
address receiver;
uint96 royaltyFraction;
}
Contents
- cryptography
- introspection
- math
- structs
- types
- Address
- Arrays
- Base64
- Blockhash
- Bytes
- CAIP10
- CAIP2
- Calldata
- Comparators
- Context
- Create2
- Errors
- Multicall
- Nonces
- NoncesKeyed
- Packing
- Panic
- Pausable
- ReentrancyGuard
- ReentrancyGuardTransient
- ShortString
- ShortStrings
- SlotDerivation
- StorageSlot
- Strings
- TransientSlot
Contents
- signers
- verifiers
- ECDSA
- EIP712
- Hashes
- MerkleProof
- MessageHashUtils
- P256
- RSA
- SignatureChecker
- ERC7739Utils
Contents
- AbstractSigner
- MultiSignerERC7913
- MultiSignerERC7913Weighted
- SignerECDSA
- SignerERC7702
- SignerERC7913
- SignerP256
- SignerRSA
- ERC7739
AbstractSigner
Abstract contract for signature validation. Developers must implement _rawSignatureValidation and use it as the lowest-level signature validation mechanism.
Note: stateless:
Functions
_rawSignatureValidation
Signature validation algorithm. WARNING: Implementing a signature validation algorithm is a security-sensitive operation as it involves cryptographic verification. It is important to review and test thoroughly before deployment. Consider using one of the signature verification libraries (xref:api:utils/cryptography#ECDSA[ECDSA], xref:api:utils/cryptography#P256[P256] or xref:api:utils/cryptography#RSA[RSA]).
function _rawSignatureValidation(bytes32 hash, bytes calldata signature) internal view virtual returns (bool);
MultiSignerERC7913
Inherits: AbstractSigner
*Implementation of {AbstractSigner} using multiple ERC-7913 signers with a threshold-based signature verification system. This contract allows managing a set of authorized signers and requires a minimum number of signatures (threshold) to approve operations. It uses ERC-7913 formatted signers, which makes it natively compatible with ECDSA and ERC-1271 signers. Example of usage:
contract MyMultiSignerAccount is Account, MultiSignerERC7913, Initializable {
function initialize(bytes[] memory signers, uint64 threshold) public initializer {
_addSigners(signers);
_setThreshold(threshold);
}
function addSigners(bytes[] memory signers) public onlyEntryPointOrSelf {
_addSigners(signers);
}
function removeSigners(bytes[] memory signers) public onlyEntryPointOrSelf {
_removeSigners(signers);
}
function setThreshold(uint64 threshold) public onlyEntryPointOrSelf {
_setThreshold(threshold);
}
}
IMPORTANT: Failing to properly initialize the signers and threshold either during construction (if used standalone) or during initialization (if used as a clone) may leave the contract either front-runnable or unusable.*
State Variables
_signers
EnumerableSet.BytesSet private _signers;
_threshold
uint64 private _threshold;
Functions
constructor
constructor(bytes[] memory signers_, uint64 threshold_);
getSigners
Returns a slice of the set of authorized signers.
Using start = 0 and end = type(uint64).max will return the entire set of signers.
WARNING: Depending on the start and end, this operation can copy a large amount of data to memory, which
can be expensive. This is designed for view accessors queried without gas fees. Using it in state-changing
functions may become uncallable if the slice grows too large.
function getSigners(uint64 start, uint64 end) public view virtual returns (bytes[] memory);
getSignerCount
Returns the number of authorized signers
function getSignerCount() public view virtual returns (uint256);
isSigner
Returns whether the signer is an authorized signer.
function isSigner(bytes memory signer) public view virtual returns (bool);
threshold
Returns the minimum number of signers required to approve a multisignature operation.
function threshold() public view virtual returns (uint64);
_addSigners
Adds the newSigners to those allowed to sign on behalf of this contract.
Internal version without access control.
Requirements:
Each of newSigners must be at least 20 bytes long. Reverts with MultiSignerERC7913InvalidSigner if not.
Each of newSigners must not be authorized. See {isSigner}. Reverts with {MultiSignerERC7913AlreadyExists} if so.
function _addSigners(bytes[] memory newSigners) internal virtual;
_removeSigners
Removes the oldSigners from the authorized signers. Internal version without access control.
Requirements:
Each of oldSigners must be authorized. See isSigner. Otherwise {MultiSignerERC7913NonexistentSigner} is thrown.
See {_validateReachableThreshold} for the threshold validation.
function _removeSigners(bytes[] memory oldSigners) internal virtual;
_setThreshold
Sets the signatures threshold required to approve a multisignature operation.
Internal version without access control.
Requirements:
See _validateReachableThreshold for the threshold validation.
function _setThreshold(uint64 newThreshold) internal virtual;
_validateReachableThreshold
Validates the current threshold is reachable. Requirements: The getSignerCount must be greater or equal than to the {threshold}. Throws {MultiSignerERC7913UnreachableThreshold} if not.
function _validateReachableThreshold() internal view virtual;
_rawSignatureValidation
*Decodes, validates the signature and checks the signers are authorized. See _validateSignatures and {_validateThreshold} for more details. Example of signature encoding:
// Encode signers (verifier || key)
bytes memory signer1 = abi.encodePacked(verifier1, key1);
bytes memory signer2 = abi.encodePacked(verifier2, key2);
// Order signers by their id
if (keccak256(signer1) > keccak256(signer2)) {
(signer1, signer2) = (signer2, signer1);
(signature1, signature2) = (signature2, signature1);
}
// Assign ordered signers and signatures
bytes[] memory signers = new bytes[](2);
bytes[] memory signatures = new bytes[](2);
signers[0] = signer1;
signatures[0] = signature1;
signers[1] = signer2;
signatures[1] = signature2;
// Encode the multi signature
bytes memory signature = abi.encode(signers, signatures);
Requirements:
The signature must be encoded as abi.encode(signers, signatures).*
function _rawSignatureValidation(bytes32 hash, bytes calldata signature)
internal
view
virtual
override
returns (bool);
_validateSignatures
Validates the signatures using the signers and their corresponding signatures.
Returns whether the signers are authorized and the signatures are valid for the given hash.
IMPORTANT: Sorting the signers by their keccak256 hash will improve the gas efficiency of this function.
See {SignatureChecker-areValidSignaturesNow-bytes32-bytes[]-bytes[]} for more details.
Requirements:
The signatures and signers arrays must be equal in length. Returns false otherwise.
function _validateSignatures(bytes32 hash, bytes[] memory signers, bytes[] memory signatures)
internal
view
virtual
returns (bool valid);
_validateThreshold
Validates that the number of signers meets the threshold requirement. Assumes the signers were already validated. See {_validateSignatures} for more details.
function _validateThreshold(bytes[] memory validatingSigners) internal view virtual returns (bool);
Events
ERC7913SignerAdded
Emitted when a signer is added.
event ERC7913SignerAdded(bytes indexed signers);
ERC7913SignerRemoved
Emitted when a signers is removed.
event ERC7913SignerRemoved(bytes indexed signers);
ERC7913ThresholdSet
Emitted when the threshold is updated.
event ERC7913ThresholdSet(uint64 threshold);
Errors
MultiSignerERC7913AlreadyExists
The signer already exists.
error MultiSignerERC7913AlreadyExists(bytes signer);
MultiSignerERC7913NonexistentSigner
The signer does not exist.
error MultiSignerERC7913NonexistentSigner(bytes signer);
MultiSignerERC7913InvalidSigner
The signer is less than 20 bytes long.
error MultiSignerERC7913InvalidSigner(bytes signer);
MultiSignerERC7913ZeroThreshold
The threshold is zero.
error MultiSignerERC7913ZeroThreshold();
MultiSignerERC7913UnreachableThreshold
The threshold is unreachable given the number of signers.
error MultiSignerERC7913UnreachableThreshold(uint64 signers, uint64 threshold);
MultiSignerERC7913Weighted
Inherits: MultiSignerERC7913
*Extension of {MultiSignerERC7913} that supports weighted signatures. This contract allows assigning different weights to each signer, enabling more flexible governance schemes. For example, some signers could have higher weight than others, allowing for weighted voting or prioritized authorization. Example of usage:
contract MyWeightedMultiSignerAccount is Account, MultiSignerERC7913Weighted, Initializable {
function initialize(bytes[] memory signers, uint64[] memory weights, uint64 threshold) public initializer {
_addSigners(signers);
_setSignerWeights(signers, weights);
_setThreshold(threshold);
}
function addSigners(bytes[] memory signers) public onlyEntryPointOrSelf {
_addSigners(signers);
}
function removeSigners(bytes[] memory signers) public onlyEntryPointOrSelf {
_removeSigners(signers);
}
function setThreshold(uint64 threshold) public onlyEntryPointOrSelf {
_setThreshold(threshold);
}
function setSignerWeights(bytes[] memory signers, uint64[] memory weights) public onlyEntryPointOrSelf {
_setSignerWeights(signers, weights);
}
}
IMPORTANT: When setting a threshold value, ensure it matches the scale used for signer weights. For example, if signers have weights like 1, 2, or 3, then a threshold of 4 would require at least two signers (e.g., one with weight 1 and one with weight 3). See {signerWeight}.*
State Variables
_totalExtraWeight
uint64 private _totalExtraWeight;
_extraWeights
mapping(bytes signer => uint64) private _extraWeights;
Functions
constructor
constructor(bytes[] memory signers_, uint64[] memory weights_, uint64 threshold_) MultiSignerERC7913(signers_, 1);
signerWeight
Gets the weight of a signer. Returns 0 if the signer is not authorized.
function signerWeight(bytes memory signer) public view virtual returns (uint64);
totalWeight
Gets the total weight of all signers.
function totalWeight() public view virtual returns (uint64);
_setSignerWeights
Sets weights for multiple signers at once. Internal version without access control.
Requirements:
signers and weights arrays must have the same length. Reverts with MultiSignerERC7913WeightedMismatchedLength on mismatch.
Each signer must exist in the set of authorized signers. Otherwise reverts with {MultiSignerERC7913NonexistentSigner}
Each weight must be greater than 0. Otherwise reverts with {MultiSignerERC7913WeightedInvalidWeight}
See {_validateReachableThreshold} for the threshold validation.
Emits {ERC7913SignerWeightChanged} for each signer.
function _setSignerWeights(bytes[] memory signers, uint64[] memory weights) internal virtual;
_addSigners
See MultiSignerERC7913-_addSigners.
In cases where {totalWeight} is almost type(uint64).max (due to a large _totalExtraWeight), adding new
signers could cause the {totalWeight} computation to overflow. Adding a {totalWeight} calls after the new
signers are added ensures no such overflow happens.
function _addSigners(bytes[] memory newSigners) internal virtual override;
_removeSigners
See MultiSignerERC7913-_removeSigners. Just like {_addSigners}, this function does not emit {ERC7913SignerWeightChanged} events. The {ERC7913SignerRemoved} event emitted by {MultiSignerERC7913-_removeSigners} is enough to track weights here.
function _removeSigners(bytes[] memory signers) internal virtual override;
_validateReachableThreshold
Sets the threshold for the multisignature operation. Internal version without access control.
Requirements:
The totalWeight must be >= the {threshold}. Otherwise reverts with {MultiSignerERC7913UnreachableThreshold}
NOTE: This function intentionally does not call super._validateReachableThreshold because the base implementation
assumes each signer has a weight of 1, which is a subset of this weighted implementation. Consider that multiple
implementations of this function may exist in the contract, so important side effects may be missed
depending on the linearization order.
function _validateReachableThreshold() internal view virtual override;
_validateThreshold
Validates that the total weight of signers meets the threshold requirement.
NOTE: This function intentionally does not call super._validateThreshold because the base implementation
assumes each signer has a weight of 1, which is a subset of this weighted implementation. Consider that multiple
implementations of this function may exist in the contract, so important side effects may be missed
depending on the linearization order.
function _validateThreshold(bytes[] memory signers) internal view virtual override returns (bool);
Events
ERC7913SignerWeightChanged
Emitted when a signer's weight is changed. NOTE: Not emitted in _addSigners or {_removeSigners}. Indexers must rely on {ERC7913SignerAdded} and {ERC7913SignerRemoved} to index a default weight of 1. See {signerWeight}.
event ERC7913SignerWeightChanged(bytes indexed signer, uint64 weight);
Errors
MultiSignerERC7913WeightedInvalidWeight
Thrown when a signer's weight is invalid.
error MultiSignerERC7913WeightedInvalidWeight(bytes signer, uint64 weight);
MultiSignerERC7913WeightedMismatchedLength
Thrown when the arrays lengths don't match. See _setSignerWeights.
error MultiSignerERC7913WeightedMismatchedLength();
SignerECDSA
Inherits: AbstractSigner
*Implementation of {AbstractSigner} using xref:api:utils/cryptography#ECDSA[ECDSA] signatures. For {Account} usage, a {_setSigner} function is provided to set the {signer} address. Doing so is easier for a factory, who is likely to use initializable clones of this contract. Example of usage:
contract MyAccountECDSA is Account, SignerECDSA, Initializable {
function initialize(address signerAddr) public initializer {
_setSigner(signerAddr);
}
}
IMPORTANT: Failing to call {_setSigner} either during construction (if used standalone) or during initialization (if used as a clone) may leave the signer either front-runnable or unusable.*
State Variables
_signer
address private _signer;
Functions
constructor
constructor(address signerAddr);
_setSigner
Sets the signer with the address of the native signer. This function should be called during construction or through an initializer.
function _setSigner(address signerAddr) internal;
signer
Return the signer's address.
function signer() public view virtual returns (address);
_rawSignatureValidation
Signature validation algorithm. WARNING: Implementing a signature validation algorithm is a security-sensitive operation as it involves cryptographic verification. It is important to review and test thoroughly before deployment. Consider using one of the signature verification libraries (xref:api:utils/cryptography#ECDSA[ECDSA], xref:api:utils/cryptography#P256[P256] or xref:api:utils/cryptography#RSA[RSA]).
function _rawSignatureValidation(bytes32 hash, bytes calldata signature)
internal
view
virtual
override
returns (bool);
SignerERC7702
Inherits: AbstractSigner
Implementation of {AbstractSigner} for implementation for an EOA. Useful for ERC-7702 accounts.
Note: stateless:
Functions
_rawSignatureValidation
Validates the signature using the EOA's address (i.e. address(this)).
function _rawSignatureValidation(bytes32 hash, bytes calldata signature)
internal
view
virtual
override
returns (bool);
SignerERC7913
Inherits: AbstractSigner
*Implementation of {AbstractSigner} using
https://eips.ethereum.org/EIPS/eip-7913[ERC-7913] signature verification.
For {Account} usage, a {_setSigner} function is provided to set the ERC-7913 formatted {signer}.
Doing so is easier for a factory, who is likely to use initializable clones of this contract.
The signer is a bytes object that concatenates a verifier address and a key: verifier || key.
Example of usage:
contract MyAccountERC7913 is Account, SignerERC7913, Initializable {
function initialize(bytes memory signer_) public initializer {
_setSigner(signer_);
}
function setSigner(bytes memory signer_) public onlyEntryPointOrSelf {
_setSigner(signer_);
}
}
IMPORTANT: Failing to call {_setSigner} either during construction (if used standalone) or during initialization (if used as a clone) may leave the signer either front-runnable or unusable.*
State Variables
_signer
bytes private _signer;
Functions
constructor
constructor(bytes memory signer_);
signer
Return the ERC-7913 signer (i.e. verifier || key).
function signer() public view virtual returns (bytes memory);
_setSigner
Sets the signer (i.e. verifier || key) with an ERC-7913 formatted signer.
function _setSigner(bytes memory signer_) internal;
_rawSignatureValidation
Verifies a signature using {SignatureChecker-isValidSignatureNow-bytes-bytes32-bytes-}
with {signer}, hash and signature.
function _rawSignatureValidation(bytes32 hash, bytes calldata signature)
internal
view
virtual
override
returns (bool);
SignerP256
Inherits: AbstractSigner
*Implementation of {AbstractSigner} using xref:api:utils/cryptography#P256[P256] signatures. For {Account} usage, a {_setSigner} function is provided to set the {signer} public key. Doing so is easier for a factory, who is likely to use initializable clones of this contract. Example of usage:
contract MyAccountP256 is Account, SignerP256, Initializable {
function initialize(bytes32 qx, bytes32 qy) public initializer {
_setSigner(qx, qy);
}
}
IMPORTANT: Failing to call {_setSigner} either during construction (if used standalone) or during initialization (if used as a clone) may leave the signer either front-runnable or unusable.*
State Variables
_qx
bytes32 private _qx;
_qy
bytes32 private _qy;
Functions
constructor
constructor(bytes32 qx, bytes32 qy);
_setSigner
Sets the signer with a P256 public key. This function should be called during construction or through an initializer.
function _setSigner(bytes32 qx, bytes32 qy) internal;
signer
Return the signer's P256 public key.
function signer() public view virtual returns (bytes32 qx, bytes32 qy);
_rawSignatureValidation
Signature validation algorithm. WARNING: Implementing a signature validation algorithm is a security-sensitive operation as it involves cryptographic verification. It is important to review and test thoroughly before deployment. Consider using one of the signature verification libraries (xref:api:utils/cryptography#ECDSA[ECDSA], xref:api:utils/cryptography#P256[P256] or xref:api:utils/cryptography#RSA[RSA]).
function _rawSignatureValidation(bytes32 hash, bytes calldata signature)
internal
view
virtual
override
returns (bool);
Errors
SignerP256InvalidPublicKey
error SignerP256InvalidPublicKey(bytes32 qx, bytes32 qy);
SignerRSA
Inherits: AbstractSigner
*Implementation of {AbstractSigner} using xref:api:utils/cryptography#RSA[RSA] signatures. For {Account} usage, a {_setSigner} function is provided to set the {signer} public key. Doing so is easier for a factory, who is likely to use initializable clones of this contract. Example of usage:
contract MyAccountRSA is Account, SignerRSA, Initializable {
function initialize(bytes memory e, bytes memory n) public initializer {
_setSigner(e, n);
}
}
IMPORTANT: Failing to call {_setSigner} either during construction (if used standalone) or during initialization (if used as a clone) may leave the signer either front-runnable or unusable.*
State Variables
_e
bytes private _e;
_n
bytes private _n;
Functions
constructor
constructor(bytes memory e, bytes memory n);
_setSigner
Sets the signer with a RSA public key. This function should be called during construction or through an initializer.
function _setSigner(bytes memory e, bytes memory n) internal;
signer
Return the signer's RSA public key.
function signer() public view virtual returns (bytes memory e, bytes memory n);
_rawSignatureValidation
See AbstractSigner-_rawSignatureValidation. Verifies a PKCSv1.5 signature by calling
xref:api:utils/cryptography.adoc#RSA-pkcs1Sha256-bytes-bytes-bytes-bytes-[RSA.pkcs1Sha256].
IMPORTANT: Following the RSASSA-PKCS1-V1_5-VERIFY procedure outlined in RFC8017 (section 8.2.2), the
provided hash is used as the M (message) and rehashed using SHA256 according to EMSA-PKCS1-v1_5
encoding as per section 9.2 (step 1) of the RFC.
function _rawSignatureValidation(bytes32 hash, bytes calldata signature)
internal
view
virtual
override
returns (bool);
ERC7739
Inherits: AbstractSigner, EIP712, IERC1271
Validates signatures wrapping the message hash in a nested EIP712 type. See {ERC7739Utils}. Linking the signature to the EIP-712 domain separator is a security measure to prevent signature replay across different EIP-712 domains (e.g. a single offchain owner of multiple contracts). This contract requires implementing the {_rawSignatureValidation} function, which passes the wrapped message hash, which may be either an typed data or a personal sign nested type. NOTE: xref:api:utils/cryptography#EIP712[EIP-712] uses xref:api:utils/cryptography#ShortStrings[ShortStrings] to optimize gas costs for short strings (up to 31 characters). Consider that strings longer than that will use storage, which may limit the ability of the signer to be used within the ERC-4337 validation phase (due to https://eips.ethereum.org/EIPS/eip-7562#storage-rules[ERC-7562 storage access rules]).
Functions
isValidSignature
*Attempts validating the signature in a nested EIP-712 type. A nested EIP-712 type might be presented in 2 different ways:
- As a nested EIP-712 typed data
- As a personal signature (an EIP-712 mimic of the
eth_personalSignfor a smart contract)*
function isValidSignature(bytes32 hash, bytes calldata signature) public view virtual returns (bytes4 result);
_isValidNestedPersonalSignSignature
Nested personal signature verification.
function _isValidNestedPersonalSignSignature(bytes32 hash, bytes calldata signature) private view returns (bool);
_isValidNestedTypedDataSignature
Nested EIP-712 typed data verification.
function _isValidNestedTypedDataSignature(bytes32 hash, bytes calldata encodedSignature) private view returns (bool);
Contents
ERC7913P256Verifier
Inherits: IERC7913SignatureVerifier
ERC-7913 signature verifier that support P256 (secp256r1) keys.
Note: stateless:
Functions
verify
Verifies signature as a valid signature of hash by key.
MUST return the bytes4 magic value IERC7913SignatureVerifier.verify.selector if the signature is valid.
SHOULD return 0xffffffff or revert if the signature is not valid.
SHOULD return 0xffffffff or revert if the key is empty
function verify(bytes calldata key, bytes32 hash, bytes calldata signature) public view virtual returns (bytes4);
ERC7913RSAVerifier
Inherits: IERC7913SignatureVerifier
ERC-7913 signature verifier that support RSA keys.
Note: stateless:
Functions
verify
Verifies signature as a valid signature of hash by key.
MUST return the bytes4 magic value IERC7913SignatureVerifier.verify.selector if the signature is valid.
SHOULD return 0xffffffff or revert if the signature is not valid.
SHOULD return 0xffffffff or revert if the key is empty
function verify(bytes calldata key, bytes32 hash, bytes calldata signature) public view virtual returns (bytes4);
ECDSA
Elliptic Curve Digital Signature Algorithm (ECDSA) operations. These functions can be used to verify that a message was signed by the holder of the private keys of a given address.
Functions
tryRecover
*Returns the address that signed a hashed message (hash) with signature or an error. This will not
return address(0) without also returning an error description. Errors are documented using an enum (error type)
and a bytes32 providing additional information about the error.
If no error is returned, then the address can be used for verification purposes.
The ecrecover EVM precompile allows for malleable (non-unique) signatures:
this function rejects them by requiring the s value to be in the lower
half order, and the v value to be either 27 or 28.
IMPORTANT: hash must be the result of a hash operation for the
verification to be secure: it is possible to craft signatures that
recover to arbitrary addresses for non-hashed data. A safe way to ensure
this is by receiving a hash of the original message (which may otherwise
be too long), and then calling MessageHashUtils-toEthSignedMessageHash on it.
Documentation for signature generation:
- with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
- with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]*
function tryRecover(bytes32 hash, bytes memory signature)
internal
pure
returns (address recovered, RecoverError err, bytes32 errArg);
recover
Returns the address that signed a hashed message (hash) with
signature. This address can then be used for verification purposes.
The ecrecover EVM precompile allows for malleable (non-unique) signatures:
this function rejects them by requiring the s value to be in the lower
half order, and the v value to be either 27 or 28.
IMPORTANT: hash must be the result of a hash operation for the
verification to be secure: it is possible to craft signatures that
recover to arbitrary addresses for non-hashed data. A safe way to ensure
this is by receiving a hash of the original message (which may otherwise
be too long), and then calling MessageHashUtils-toEthSignedMessageHash on it.
function recover(bytes32 hash, bytes memory signature) internal pure returns (address);
tryRecover
Overload of {ECDSA-tryRecover} that receives the r and vs short-signature fields separately.
See https://eips.ethereum.org/EIPS/eip-2098[ERC-2098 short signatures]
function tryRecover(bytes32 hash, bytes32 r, bytes32 vs)
internal
pure
returns (address recovered, RecoverError err, bytes32 errArg);
recover
Overload of ECDSA-recover that receives the r and vs` short-signature fields separately.
function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address);
tryRecover
Overload of {ECDSA-tryRecover} that receives the v,
r and s signature fields separately.
function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s)
internal
pure
returns (address recovered, RecoverError err, bytes32 errArg);
recover
Overload of ECDSA-recover that receives the v,
r and s signature fields separately.
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address);
_throwError
Optionally reverts with the corresponding custom error according to the error argument provided.
function _throwError(RecoverError error, bytes32 errorArg) private pure;
Errors
ECDSAInvalidSignature
The signature derives the address(0).
error ECDSAInvalidSignature();
ECDSAInvalidSignatureLength
The signature has an invalid length.
error ECDSAInvalidSignatureLength(uint256 length);
ECDSAInvalidSignatureS
The signature has an S value that is in the upper half order.
error ECDSAInvalidSignatureS(bytes32 s);
Enums
RecoverError
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS
}
EIP712
Inherits: IERC5267
https://eips.ethereum.org/EIPS/eip-712[EIP-712] is a standard for hashing and signing of typed structured data.
The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose
encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract
does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to
produce the hash of their typed data using a combination of abi.encode and keccak256.
This contract implements the EIP-712 domain separator (_domainSeparatorV4) that is used as part of the encoding
scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
({_hashTypedDataV4}).
The implementation of the domain separator was designed to be as efficient as possible while still properly updating
the chain id to protect against replay attacks on an eventual fork of the chain.
NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
https://docs.metamask.io/guide/signing-data.html[eth_signTypedDataV4 in MetaMask].
NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain
separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the
separator from the immutable values, which is cheaper than accessing a cached version in cold storage.
Note: oz-upgrades-unsafe-allow: state-variable-immutable
State Variables
TYPE_HASH
bytes32 private constant TYPE_HASH =
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
_cachedDomainSeparator
bytes32 private immutable _cachedDomainSeparator;
_cachedChainId
uint256 private immutable _cachedChainId;
_cachedThis
address private immutable _cachedThis;
_hashedName
bytes32 private immutable _hashedName;
_hashedVersion
bytes32 private immutable _hashedVersion;
_name
ShortString private immutable _name;
_version
ShortString private immutable _version;
_nameFallback
string private _nameFallback;
_versionFallback
string private _versionFallback;
Functions
constructor
*Initializes the domain separator and parameter caches.
The meaning of name and version is specified in
https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP-712]:
name: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.version: the current major version of the signing domain. NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart contract upgrade].*
constructor(string memory name, string memory version);
_domainSeparatorV4
Returns the domain separator for the current chain.
function _domainSeparatorV4() internal view returns (bytes32);
_buildDomainSeparator
function _buildDomainSeparator() private view returns (bytes32);
_hashTypedDataV4
*Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this function returns the hash of the fully encoded EIP712 message for this domain. This hash can be used together with ECDSA-recover to obtain the signer of a message. For example:
bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
keccak256("Mail(address to,string contents)"),
mailTo,
keccak256(bytes(mailContents))
)));
address signer = ECDSA.recover(digest, signature);
```*
```solidity
function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32);
eip712Domain
returns the fields and values that describe the domain separator used by this contract for EIP-712 signature.
function eip712Domain()
public
view
virtual
returns (
bytes1 fields,
string memory name,
string memory version,
uint256 chainId,
address verifyingContract,
bytes32 salt,
uint256[] memory extensions
);
_EIP712Name
The name parameter for the EIP712 domain. NOTE: By default this function reads _name which is an immutable value. It only reads from storage if necessary (in case the value is too large to fit in a ShortString).
function _EIP712Name() internal view returns (string memory);
_EIP712Version
The version parameter for the EIP712 domain. NOTE: By default this function reads _version which is an immutable value. It only reads from storage if necessary (in case the value is too large to fit in a ShortString).
function _EIP712Version() internal view returns (string memory);
Hashes
Library of standard hash functions. Available since v5.1.
Functions
commutativeKeccak256
Commutative Keccak256 hash of a sorted pair of bytes32. Frequently used when working with merkle proofs.
NOTE: Equivalent to the standardNodeHash in our https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
function commutativeKeccak256(bytes32 a, bytes32 b) internal pure returns (bytes32);
efficientKeccak256
Implementation of keccak256(abi.encode(a, b)) that doesn't allocate or expand memory.
function efficientKeccak256(bytes32 a, bytes32 b) internal pure returns (bytes32 value);
MerkleProof
These functions deal with verification of Merkle Tree proofs.
The tree and the proofs can be generated using our
https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
You will find a quickstart guide in the readme.
WARNING: You should avoid using leaf values that are 64 bytes long prior to
hashing, or use a hash function other than keccak256 for hashing leaves.
This is because the concatenation of a sorted pair of internal nodes in
the Merkle tree could be reinterpreted as a leaf value.
OpenZeppelin's JavaScript library generates Merkle trees that are safe
against this attack out of the box.
IMPORTANT: Consider memory side-effects when using custom hashing functions
that access memory in an unsafe way.
NOTE: This library supports proof verification for merkle trees built using
custom commutative hashing functions (i.e. H(a, b) == H(b, a)). Proving
leaf inclusion in trees built using non-commutative hashing functions requires
additional logic that is not supported by this library.
Functions
verify
Returns true if a leaf can be proved to be a part of a Merkle tree
defined by root. For this, a proof must be provided, containing
sibling hashes on the branch from the leaf to the root of the tree. Each
pair of leaves and each pair of pre-images are assumed to be sorted.
This version handles proofs in memory with the default hashing function.
function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool);
processProof
Returns the rebuilt hash obtained by traversing a Merkle tree up
from leaf using proof. A proof is valid if and only if the rebuilt
hash matches the root of the tree. When processing the proof, the pairs
of leaves & pre-images are assumed to be sorted.
This version handles proofs in memory with the default hashing function.
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32);
verify
Returns true if a leaf can be proved to be a part of a Merkle tree
defined by root. For this, a proof must be provided, containing
sibling hashes on the branch from the leaf to the root of the tree. Each
pair of leaves and each pair of pre-images are assumed to be sorted.
This version handles proofs in memory with a custom hashing function.
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bool);
processProof
Returns the rebuilt hash obtained by traversing a Merkle tree up
from leaf using proof. A proof is valid if and only if the rebuilt
hash matches the root of the tree. When processing the proof, the pairs
of leaves & pre-images are assumed to be sorted.
This version handles proofs in memory with a custom hashing function.
function processProof(bytes32[] memory proof, bytes32 leaf, function(bytes32, bytes32) view returns (bytes32) hasher)
internal
view
returns (bytes32);
verifyCalldata
Returns true if a leaf can be proved to be a part of a Merkle tree
defined by root. For this, a proof must be provided, containing
sibling hashes on the branch from the leaf to the root of the tree. Each
pair of leaves and each pair of pre-images are assumed to be sorted.
This version handles proofs in calldata with the default hashing function.
function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool);
processProofCalldata
Returns the rebuilt hash obtained by traversing a Merkle tree up
from leaf using proof. A proof is valid if and only if the rebuilt
hash matches the root of the tree. When processing the proof, the pairs
of leaves & pre-images are assumed to be sorted.
This version handles proofs in calldata with the default hashing function.
function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32);
verifyCalldata
Returns true if a leaf can be proved to be a part of a Merkle tree
defined by root. For this, a proof must be provided, containing
sibling hashes on the branch from the leaf to the root of the tree. Each
pair of leaves and each pair of pre-images are assumed to be sorted.
This version handles proofs in calldata with a custom hashing function.
function verifyCalldata(
bytes32[] calldata proof,
bytes32 root,
bytes32 leaf,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bool);
processProofCalldata
Returns the rebuilt hash obtained by traversing a Merkle tree up
from leaf using proof. A proof is valid if and only if the rebuilt
hash matches the root of the tree. When processing the proof, the pairs
of leaves & pre-images are assumed to be sorted.
This version handles proofs in calldata with a custom hashing function.
function processProofCalldata(
bytes32[] calldata proof,
bytes32 leaf,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bytes32);
multiProofVerify
Returns true if the leaves can be simultaneously proven to be a part of a Merkle tree defined by
root, according to proof and proofFlags as described in processMultiProof.
This version handles multiproofs in memory with the default hashing function.
CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
NOTE: Consider the case where root == proof[0] && leaves.length == 0 as it will return true.
The leaves must be validated independently. See {processMultiProof}.
function multiProofVerify(bytes32[] memory proof, bool[] memory proofFlags, bytes32 root, bytes32[] memory leaves)
internal
pure
returns (bool);
processMultiProof
Returns the root of a tree reconstructed from leaves and sibling nodes in proof. The reconstruction
proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
leaf/inner node or a proof sibling node, depending on whether each proofFlags item is true or false
respectively.
This version handles multiproofs in memory with the default hashing function.
CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
NOTE: The empty set (i.e. the case where proof.length == 1 && leaves.length == 0) is considered a no-op,
and therefore a valid multiproof (i.e. it returns proof[0]). Consider disallowing this case if you're not
validating the leaves elsewhere.
function processMultiProof(bytes32[] memory proof, bool[] memory proofFlags, bytes32[] memory leaves)
internal
pure
returns (bytes32 merkleRoot);
multiProofVerify
Returns true if the leaves can be simultaneously proven to be a part of a Merkle tree defined by
root, according to proof and proofFlags as described in processMultiProof.
This version handles multiproofs in memory with a custom hashing function.
CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
NOTE: Consider the case where root == proof[0] && leaves.length == 0 as it will return true.
The leaves must be validated independently. See {processMultiProof}.
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bool);
processMultiProof
Returns the root of a tree reconstructed from leaves and sibling nodes in proof. The reconstruction
proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
leaf/inner node or a proof sibling node, depending on whether each proofFlags item is true or false
respectively.
This version handles multiproofs in memory with a custom hashing function.
CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
NOTE: The empty set (i.e. the case where proof.length == 1 && leaves.length == 0) is considered a no-op,
and therefore a valid multiproof (i.e. it returns proof[0]). Consider disallowing this case if you're not
validating the leaves elsewhere.
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bytes32 merkleRoot);
multiProofVerifyCalldata
Returns true if the leaves can be simultaneously proven to be a part of a Merkle tree defined by
root, according to proof and proofFlags as described in processMultiProof.
This version handles multiproofs in calldata with the default hashing function.
CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
NOTE: Consider the case where root == proof[0] && leaves.length == 0 as it will return true.
The leaves must be validated independently. See {processMultiProofCalldata}.
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool);
processMultiProofCalldata
Returns the root of a tree reconstructed from leaves and sibling nodes in proof. The reconstruction
proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
leaf/inner node or a proof sibling node, depending on whether each proofFlags item is true or false
respectively.
This version handles multiproofs in calldata with the default hashing function.
CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
NOTE: The empty set (i.e. the case where proof.length == 1 && leaves.length == 0) is considered a no-op,
and therefore a valid multiproof (i.e. it returns proof[0]). Consider disallowing this case if you're not
validating the leaves elsewhere.
function processMultiProofCalldata(bytes32[] calldata proof, bool[] calldata proofFlags, bytes32[] memory leaves)
internal
pure
returns (bytes32 merkleRoot);
multiProofVerifyCalldata
Returns true if the leaves can be simultaneously proven to be a part of a Merkle tree defined by
root, according to proof and proofFlags as described in processMultiProof.
This version handles multiproofs in calldata with a custom hashing function.
CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
NOTE: Consider the case where root == proof[0] && leaves.length == 0 as it will return true.
The leaves must be validated independently. See {processMultiProofCalldata}.
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bool);
processMultiProofCalldata
Returns the root of a tree reconstructed from leaves and sibling nodes in proof. The reconstruction
proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
leaf/inner node or a proof sibling node, depending on whether each proofFlags item is true or false
respectively.
This version handles multiproofs in calldata with a custom hashing function.
CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
NOTE: The empty set (i.e. the case where proof.length == 1 && leaves.length == 0) is considered a no-op,
and therefore a valid multiproof (i.e. it returns proof[0]). Consider disallowing this case if you're not
validating the leaves elsewhere.
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bytes32 merkleRoot);
Errors
MerkleProofInvalidMultiproof
The multiproof provided is not valid.
error MerkleProofInvalidMultiproof();
MessageHashUtils
Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing. The library provides methods for generating a hash of a message that conforms to the https://eips.ethereum.org/EIPS/eip-191[ERC-191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712] specifications.
Functions
toEthSignedMessageHash
Returns the keccak256 digest of an ERC-191 signed data with version
0x45 (personal_sign messages).
The digest is calculated by prefixing a bytes32 messageHash with
"\x19Ethereum Signed Message:\n32" and hashing the result. It corresponds with the
hash signed when using the https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sign[eth_sign] JSON-RPC method.
NOTE: The messageHash parameter is intended to be the result of hashing a raw message with
keccak256, although any bytes32 value can be safely used because the final digest will
be re-hashed.
See ECDSA-recover.
function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest);
toEthSignedMessageHash
Returns the keccak256 digest of an ERC-191 signed data with version
0x45 (personal_sign messages).
The digest is calculated by prefixing an arbitrary message with
"\x19Ethereum Signed Message:\n" + len(message) and hashing the result. It corresponds with the
hash signed when using the https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sign[eth_sign] JSON-RPC method.
See ECDSA-recover.
function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32);
toDataWithIntendedValidatorHash
Returns the keccak256 digest of an ERC-191 signed data with version
0x00 (data with intended validator).
The digest is calculated by prefixing an arbitrary data with "\x19\x00" and the intended
validator address. Then hashing the result.
See ECDSA-recover.
function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32);
toDataWithIntendedValidatorHash
Variant of {toDataWithIntendedValidatorHash-address-bytes} optimized for cases where data is a bytes32.
function toDataWithIntendedValidatorHash(address validator, bytes32 messageHash)
internal
pure
returns (bytes32 digest);
toTypedDataHash
Returns the keccak256 digest of an EIP-712 typed data (ERC-191 version 0x01).
The digest is calculated from a domainSeparator and a structHash, by prefixing them with
\x19\x01 and hashing the result. It corresponds to the hash signed by the
https://eips.ethereum.org/EIPS/eip-712[eth_signTypedData] JSON-RPC method as part of EIP-712.
See ECDSA-recover.
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest);
P256
Implementation of secp256r1 verification and recovery functions. The secp256r1 curve (also known as P256) is a NIST standard curve with wide support in modern devices and cryptographic standards. Some notable examples include Apple's Secure Enclave and Android's Keystore as well as authentication protocols like FIDO2. Based on the original https://github.com/itsobvioustech/aa-passkeys-wallet/blob/d3d423f28a4d8dfcb203c7fa0c47f42592a7378e/src/Secp256r1.sol[implementation of itsobvioustech] (GNU General Public License v3.0). Heavily inspired in https://github.com/maxrobot/elliptic-solidity/blob/c4bb1b6e8ae89534d8db3a6b3a6b52219100520f/contracts/Secp256r1.sol[maxrobot] and https://github.com/tdrerup/elliptic-curve-solidity/blob/59a9c25957d4d190eff53b6610731d81a077a15e/contracts/curves/EllipticCurve.sol[tdrerup] implementations. Available since v5.1.
State Variables
GX
Generator (x component)
uint256 internal constant GX = 0x6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296;
GY
Generator (y component)
uint256 internal constant GY = 0x4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5;
P
P (size of the field)
uint256 internal constant P = 0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF;
N
N (order of G)
uint256 internal constant N = 0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551;
A
A parameter of the weierstrass equation
uint256 internal constant A = 0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC;
B
B parameter of the weierstrass equation
uint256 internal constant B = 0x5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B;
P1DIV4
(P + 1) / 4. Useful to compute sqrt
uint256 private constant P1DIV4 = 0x3fffffffc0000000400000000000000000000000400000000000000000000000;
HALF_N
N/2 for excluding higher order s values
uint256 private constant HALF_N = 0x7fffffff800000007fffffffffffffffde737d56d38bcf4279dce5617e3192a8;
Functions
verify
Verifies a secp256r1 signature using the RIP-7212 precompile and falls back to the Solidity implementation if the precompile is not available. This version should work on all chains, but requires the deployment of more bytecode.
function verify(bytes32 h, bytes32 r, bytes32 s, bytes32 qx, bytes32 qy) internal view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
h | bytes32 | - hashed message |
r | bytes32 | - signature half R |
s | bytes32 | - signature half S |
qx | bytes32 | - public key coordinate X |
qy | bytes32 | - public key coordinate Y IMPORTANT: This function disallows signatures where the s value is above N/2 to prevent malleability. To flip the s value, compute s = N - s. |
verifyNative
Same as verify, but it will revert if the required precompile is not available. Make sure any logic (code or precompile) deployed at that address is the expected one, otherwise the returned value may be misinterpreted as a positive boolean.
function verifyNative(bytes32 h, bytes32 r, bytes32 s, bytes32 qx, bytes32 qy) internal view returns (bool);
_tryVerifyNative
Same as verify, but it will return false if the required precompile is not available.
function _tryVerifyNative(bytes32 h, bytes32 r, bytes32 s, bytes32 qx, bytes32 qy)
private
view
returns (bool valid, bool supported);
_rip7212
Low level helper for _tryVerifyNative. Calls the precompile and checks if there is a return value.
function _rip7212(bytes32 h, bytes32 r, bytes32 s, bytes32 qx, bytes32 qy) private view returns (bool isValid);
verifySolidity
Same as verify, but only the Solidity implementation is used.
function verifySolidity(bytes32 h, bytes32 r, bytes32 s, bytes32 qx, bytes32 qy) internal view returns (bool);
recovery
Public key recovery
function recovery(bytes32 h, uint8 v, bytes32 r, bytes32 s) internal view returns (bytes32 x, bytes32 y);
Parameters
| Name | Type | Description |
|---|---|---|
h | bytes32 | - hashed message |
v | uint8 | - signature recovery param |
r | bytes32 | - signature half R |
s | bytes32 | - signature half S IMPORTANT: This function disallows signatures where the s value is above N/2 to prevent malleability. To flip the s value, compute s = N - s and v = 1 - v if (`v = 0 |
isValidPublicKey
Checks if (x, y) are valid coordinates of a point on the curve. In particular this function checks that x < P and y < P.
function isValidPublicKey(bytes32 x, bytes32 y) internal pure returns (bool result);
_isProperSignature
Checks if (r, s) is a proper signature.
In particular, this checks that s is in the "lower-range", making the signature non-malleable.
function _isProperSignature(bytes32 r, bytes32 s) private pure returns (bool);
_affineFromJacobian
Reduce from jacobian to affine coordinates
function _affineFromJacobian(uint256 jx, uint256 jy, uint256 jz) private view returns (uint256 ax, uint256 ay);
Parameters
| Name | Type | Description |
|---|---|---|
jx | uint256 | - jacobian coordinate x |
jy | uint256 | - jacobian coordinate y |
jz | uint256 | - jacobian coordinate z |
Returns
| Name | Type | Description |
|---|---|---|
ax | uint256 | - affine coordinate x |
ay | uint256 | - affine coordinate y |
_jAdd
*Point addition on the jacobian coordinates Reference: https://www.hyperelliptic.org/EFD/g1p/auto-shortw-jacobian.html#addition-add-1998-cmo-2 Note that:
addition-add-1998-cmo-2doesn't support identical input points. This version is modified to use thehandrvalues computed byaddition-add-1998-cmo-2to detect identical inputs, and fallback todoubling-dbl-1998-cmo-2if needed.- if one of the points is at infinity (i.e.
z=0), the result is undefined.*
function _jAdd(JPoint memory p1, uint256 x2, uint256 y2, uint256 z2)
private
pure
returns (uint256 rx, uint256 ry, uint256 rz);
_jDouble
Point doubling on the jacobian coordinates Reference: https://www.hyperelliptic.org/EFD/g1p/auto-shortw-jacobian.html#doubling-dbl-1998-cmo-2
function _jDouble(uint256 x, uint256 y, uint256 z) private pure returns (uint256 rx, uint256 ry, uint256 rz);
_jMultShamir
Compute G·u1 + P·u2 using the precomputed points for G and P (see _preComputeJacobianPoints). Uses Strauss Shamir trick for EC multiplication https://stackoverflow.com/questions/50993471/ec-scalar-multiplication-with-strauss-shamir-method We optimize this for 2 bits at a time rather than a single bit. The individual points for a single pass are precomputed. Overall this reduces the number of additions while keeping the same number of doublings
function _jMultShamir(JPoint[16] memory points, uint256 u1, uint256 u2) private view returns (uint256 rx, uint256 ry);
_preComputeJacobianPoints
Precompute a matrice of useful jacobian points associated with a given P. This can be seen as a 4x4 matrix
that contains combination of P and G (generator) up to 3 times each. See the table below:
┌────┬─────────────────────┐
│ i │ 0 1 2 3 │
├────┼─────────────────────┤
│ 0 │ 0 p 2p 3p │
│ 4 │ g g+p g+2p g+3p │
│ 8 │ 2g 2g+p 2g+2p 2g+3p │
│ 12 │ 3g 3g+p 3g+2p 3g+3p │
└────┴─────────────────────┘
Note that _jAdd (and thus _jAddPoint) does not handle the case where one of the inputs is a point at
infinity (z = 0). However, we know that since N ≡ 1 mod 2 and N ≡ 1 mod 3, there is no point P such that
2P = 0 or 3P = 0. This guarantees that g, 2g, 3g, p, 2p, 3p are all non-zero, and that all _jAddPoint calls
have valid inputs.
function _preComputeJacobianPoints(uint256 px, uint256 py) private pure returns (JPoint[16] memory points);
_jAddPoint
function _jAddPoint(JPoint memory p1, JPoint memory p2) private pure returns (JPoint memory);
_jDoublePoint
function _jDoublePoint(JPoint memory p) private pure returns (JPoint memory);
Structs
JPoint
struct JPoint {
uint256 x;
uint256 y;
uint256 z;
}
RSA
RSA PKCS#1 v1.5 signature verification implementation according to https://datatracker.ietf.org/doc/html/rfc8017[RFC8017]. This library supports PKCS#1 v1.5 padding to avoid malleability via chosen plaintext attacks in practical implementations. The padding follows the EMSA-PKCS1-v1_5-ENCODE encoding definition as per section 9.2 of the RFC. This padding makes RSA semantically secure for signing messages. Inspired by https://github.com/adria0/SolRsaVerify/blob/79c6182cabb9102ea69d4a2e996816091d5f1cd1[Adrià Massanet's work] (GNU General Public License v3.0). Available since v5.1.
Functions
pkcs1Sha256
Same as pkcs1Sha256 but using SHA256 to calculate the digest of data.
function pkcs1Sha256(bytes memory data, bytes memory s, bytes memory e, bytes memory n) internal view returns (bool);
pkcs1Sha256
Verifies a PKCSv1.5 signature given a digest according to the verification
method described in https://datatracker.ietf.org/doc/html/rfc8017#section-8.2.2[section 8.2.2 of RFC8017] with
support for explicit or implicit NULL parameters in the DigestInfo (no other optional parameters are supported).
IMPORTANT: For security reason, this function requires the signature and modulus to have a length of at least
2048 bits. If you use a smaller key, consider replacing it with a larger, more secure, one.
WARNING: This verification algorithm doesn't prevent replayability. If called multiple times with the same
digest, public key and (valid signature), it will return true every time. Consider including an onchain nonce
or unique identifier in the message to prevent replay attacks.
WARNING: This verification algorithm supports any exponent. NIST recommends using 65537 (or higher).
That is the default value many libraries use, such as OpenSSL. Developers may choose to reject public keys
using a low exponent out of security concerns.
function pkcs1Sha256(bytes32 digest, bytes memory s, bytes memory e, bytes memory n) internal view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
digest | bytes32 | the digest to verify |
s | bytes | is a buffer containing the signature |
e | bytes | is the exponent of the public key |
n | bytes | is the modulus of the public key |
_unsafeReadBytes32
Reads a bytes32 from a bytes array without bounds checking.
function _unsafeReadBytes32(bytes memory array, uint256 offset) private pure returns (bytes32 result);
SignatureChecker
Signature verification helper that can be used instead of ECDSA.recover to seamlessly support:
ECDSA signatures from externally owned accounts (EOAs)
ERC-1271 signatures from smart contract wallets like Argent and Safe Wallet (previously Gnosis Safe)
ERC-7913 signatures from keys that do not have an Ethereum address of their own
See https://eips.ethereum.org/EIPS/eip-1271[ERC-1271] and https://eips.ethereum.org/EIPS/eip-7913[ERC-7913].
Functions
isValidSignatureNow
Checks if a signature is valid for a given signer and data hash. If the signer has code, the
signature is validated against it using ERC-1271, otherwise it's validated using ECDSA.recover.
NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus
change through time. It could return true at block N and false at block N+1 (or the opposite).
NOTE: For an extended version of this function that supports ERC-7913 signatures, see {isValidSignatureNow-bytes-bytes32-bytes-}.
function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool);
isValidERC1271SignatureNow
Checks if a signature is valid for a given signer and data hash. The signature is validated against the signer smart contract using ERC-1271. NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus change through time. It could return true at block N and false at block N+1 (or the opposite).
function isValidERC1271SignatureNow(address signer, bytes32 hash, bytes memory signature)
internal
view
returns (bool);
isValidSignatureNow
Verifies a signature for a given ERC-7913 signer and hash.
The signer is a bytes object that is the concatenation of an address and optionally a key:
verifier || key. A signer must be at least 20 bytes long.
Verification is done as follows:
If signer.length < 20: verification fails
If signer.length == 20: verification is done using isValidSignatureNow
Otherwise: verification is done using {IERC7913SignatureVerifier}
NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus
change through time. It could return true at block N and false at block N+1 (or the opposite).
function isValidSignatureNow(bytes memory signer, bytes32 hash, bytes memory signature) internal view returns (bool);
areValidSignaturesNow
Verifies multiple ERC-7913 signatures for a given hash using a set of signers.
Returns false if the number of signers and signatures is not the same.
The signers should be ordered by their keccak256 hash to ensure efficient duplication check. Unordered
signers are supported, but the uniqueness check will be more expensive.
NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus
change through time. It could return true at block N and false at block N+1 (or the opposite).
function areValidSignaturesNow(bytes32 hash, bytes[] memory signers, bytes[] memory signatures)
internal
view
returns (bool);
ERC7739Utils
*Utilities to process https://ercs.ethereum.org/ERCS/erc-7739[ERC-7739] typed data signatures that are specific to an EIP-712 domain. This library provides methods to wrap, unwrap and operate over typed data signatures with a defensive rehashing mechanism that includes the app's xref:api:utils/cryptography#EIP712-_domainSeparatorV4[EIP-712] and preserves readability of the signed content using an EIP-712 nested approach. A smart contract domain can validate a signature for a typed data structure in two ways:
- As an application validating a typed data signature. See typedDataSignStructHash.
- As a smart contract validating a raw message signature. See {personalSignStructHash}.
NOTE: A provider for a smart contract wallet would need to return this signature as the
result of a call to
personal_signoreth_signTypedData, and this may be unsupported by API clients that expect a return value of 129 bytes, or specifically ther,s,vparameters of an xref:api:utils/cryptography#ECDSA[ECDSA] signature, as is for example specified for xref:api:utils/cryptography#EIP712[EIP-712].*
State Variables
PERSONAL_SIGN_TYPEHASH
An EIP-712 type to represent "personal" signatures
(i.e. mimic of personal_sign for smart contracts).
bytes32 private constant PERSONAL_SIGN_TYPEHASH = keccak256("PersonalSign(bytes prefixed)");
Functions
encodeTypedDataSig
Nest a signature for a given EIP-712 type into a nested signature for the domain of the app. Counterpart of decodeTypedDataSig to extract the original signature and the nested components.
function encodeTypedDataSig(
bytes memory signature,
bytes32 appSeparator,
bytes32 contentsHash,
string memory contentsDescr
) internal pure returns (bytes memory);
decodeTypedDataSig
*Parses a nested signature into its components.
Constructed as follows:
signature ‖ APP_DOMAIN_SEPARATOR ‖ contentsHash ‖ contentsDescr ‖ uint16(contentsDescr.length)
signatureis the signature for the (ERC-7739) nested struct hash. This signature indirectly signs over the original "contents" hash (from the app) and the account's domain separator.APP_DOMAIN_SEPARATORis the EIP-712 EIP712-_domainSeparatorV4 of the application smart contract that is requesting the signature verification (though ERC-1271).contentsHashis the hash of the underlying data structure or message.contentsDescris a descriptor of the "contents" part of the the EIP-712 type of the nested signature. NOTE: This function returns empty if the input format is invalid instead of reverting. data instead.*
function decodeTypedDataSig(bytes calldata encodedSignature)
internal
pure
returns (bytes calldata signature, bytes32 appSeparator, bytes32 contentsHash, string calldata contentsDescr);
personalSignStructHash
Nests an ERC-191 digest into a PersonalSign EIP-712 struct, and returns the corresponding struct hash.
This struct hash must be combined with a domain separator, using MessageHashUtils-toTypedDataHash before
being verified/recovered.
This is used to simulates the personal_sign RPC method in the context of smart contracts.
function personalSignStructHash(bytes32 contents) internal pure returns (bytes32);
typedDataSignStructHash
Nests an EIP-712 hash (contents) into a TypedDataSign EIP-712 struct, and returns the corresponding
struct hash. This struct hash must be combined with a domain separator, using MessageHashUtils-toTypedDataHash
before being verified/recovered.
function typedDataSignStructHash(
string calldata contentsName,
string calldata contentsType,
bytes32 contentsHash,
bytes memory domainBytes
) internal pure returns (bytes32 result);
typedDataSignStructHash
Variant of {typedDataSignStructHash-string-string-bytes32-bytes} that takes a content descriptor
and decodes the contentsName and contentsType out of it.
function typedDataSignStructHash(string calldata contentsDescr, bytes32 contentsHash, bytes memory domainBytes)
internal
pure
returns (bytes32 result);
typedDataSignTypehash
Compute the EIP-712 typehash of the TypedDataSign structure for a given type (and typename).
function typedDataSignTypehash(string calldata contentsName, string calldata contentsType)
internal
pure
returns (bytes32);
decodeContentsDescr
Parse the type name out of the ERC-7739 contents type description. Supports both the implicit and explicit
modes.
Following ERC-7739 specifications, a contentsName is considered invalid if it's empty or it contains
any of the following bytes , )\x00
If the contentsType is invalid, this returns an empty string. Otherwise, the return string has non-zero
length.
function decodeContentsDescr(string calldata contentsDescr)
internal
pure
returns (string calldata contentsName, string calldata contentsType);
_isForbiddenChar
function _isForbiddenChar(bytes1 char) private pure returns (bool);
Contents
ERC165
Inherits: IERC165
*Implementation of the {IERC165} interface. Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check for the additional interface id that will be supported. For example:
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
}
```*
## Functions
### supportsInterface
Query if a contract implements an interface
*Interface identification is specified in ERC-165. This function
uses less than 30,000 gas.*
```solidity
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceId | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
ERC165Checker
Library used to query support of an interface declared via {IERC165}.
Note that these functions return the actual result of the query: they do not
revert if an interface is not supported. It is up to the caller to decide
what to do in these cases.
State Variables
INTERFACE_ID_INVALID
bytes4 private constant INTERFACE_ID_INVALID = 0xffffffff;
Functions
supportsERC165
Returns true if account supports the {IERC165} interface.
function supportsERC165(address account) internal view returns (bool);
supportsInterface
Returns true if account supports the interface defined by
interfaceId. Support for {IERC165} itself is queried automatically.
See {IERC165-supportsInterface}.
function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool);
getSupportedInterfaces
Returns a boolean array where each value corresponds to the interfaces passed in and whether they're supported or not. This allows you to batch check interfaces for a contract where your expectation is that some interfaces may not be supported. See IERC165-supportsInterface.
function getSupportedInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool[] memory);
supportsAllInterfaces
Returns true if account supports all the interfaces defined in
interfaceIds. Support for {IERC165} itself is queried automatically.
Batch-querying can lead to gas savings by skipping repeated checks for
{IERC165} support.
See {IERC165-supportsInterface}.
function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool);
supportsERC165InterfaceUnchecked
Query if a contract implements an interface, does not check ERC-165 support
Assumes that account contains a contract that supports ERC-165, otherwise the behavior of this method is undefined. This precondition can be checked with supportsERC165. Some precompiled contracts will falsely indicate support for a given interface, so caution should be exercised when using this function. Interface identification is specified in ERC-165.
function supportsERC165InterfaceUnchecked(address account, bytes4 interfaceId) internal view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
account | address | The address of the contract to query for support of an interface |
interfaceId | bytes4 | The interface identifier, as specified in ERC-165 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract at account indicates support of the interface with identifier interfaceId, false otherwise |
IERC165
Interface of the ERC-165 standard, as defined in the https://eips.ethereum.org/EIPS/eip-165[ERC]. Implementers can declare support of contract interfaces, which can then be queried by others ({ERC165Checker}). For an implementation, see {ERC165}.
Functions
supportsInterface
Returns true if this contract implements the interface defined by
interfaceId. See the corresponding
https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
to learn more about how these ids are created.
This function call must use less than 30 000 gas.
function supportsInterface(bytes4 interfaceId) external view returns (bool);
Contents
Math
Standard math utilities missing in the Solidity language.
Functions
add512
Return the 512-bit addition of two uint256. The result is stored in two 256 variables such that sum = high * 2²⁵⁶ + low.
function add512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low);
mul512
Return the 512-bit multiplication of two uint256. The result is stored in two 256 variables such that product = high * 2²⁵⁶ + low.
function mul512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low);
tryAdd
Returns the addition of two unsigned integers, with a success flag (no overflow).
function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result);
trySub
Returns the subtraction of two unsigned integers, with a success flag (no overflow).
function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result);
tryMul
Returns the multiplication of two unsigned integers, with a success flag (no overflow).
function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result);
tryDiv
Returns the division of two unsigned integers, with a success flag (no division by zero).
function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result);
tryMod
Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result);
saturatingAdd
Unsigned saturating addition, bounds to 2²⁵⁶ - 1 instead of overflowing.
function saturatingAdd(uint256 a, uint256 b) internal pure returns (uint256);
saturatingSub
Unsigned saturating subtraction, bounds to zero instead of overflowing.
function saturatingSub(uint256 a, uint256 b) internal pure returns (uint256);
saturatingMul
Unsigned saturating multiplication, bounds to 2²⁵⁶ - 1 instead of overflowing.
function saturatingMul(uint256 a, uint256 b) internal pure returns (uint256);
ternary
Branchless ternary evaluation for a ? b : c. Gas costs are constant.
IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
However, the compiler may optimize Solidity ternary operations (i.e. a ? b : c) to only compute
one branch when needed, making this function more expensive.
function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256);
max
Returns the largest of two numbers.
function max(uint256 a, uint256 b) internal pure returns (uint256);
min
Returns the smallest of two numbers.
function min(uint256 a, uint256 b) internal pure returns (uint256);
average
Returns the average of two numbers. The result is rounded towards zero.
function average(uint256 a, uint256 b) internal pure returns (uint256);
ceilDiv
Returns the ceiling of the division of two numbers.
This differs from standard division with / in that it rounds towards infinity instead
of rounding towards zero.
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256);
mulDiv
Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0. Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by Uniswap Labs also under MIT license.
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result);
mulDiv
Calculates x * y / denominator with full precision, following the selected rounding direction.
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256);
mulShr
Calculates floor(x * y >> n) with full precision. Throws if result overflows a uint256.
function mulShr(uint256 x, uint256 y, uint8 n) internal pure returns (uint256 result);
mulShr
Calculates x * y >> n with full precision, following the selected rounding direction.
function mulShr(uint256 x, uint256 y, uint8 n, Rounding rounding) internal pure returns (uint256);
invMod
Calculate the modular multiplicative inverse of a number in Z/nZ.
If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.
If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
If the input value is not inversible, 0 is returned.
NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the
inverse using Math.modExp(a, n - 2, n). See invModPrime.
function invMod(uint256 a, uint256 n) internal pure returns (uint256);
invModPrime
Variant of invMod. More efficient, but only works if p is known to be a prime greater than 2.
From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is
prime, then a**(p-1) ≡ 1 mod p. As a consequence, we have a * a**(p-2) ≡ 1 mod p, which means that
a**(p-2) is the modular multiplicative inverse of a in Fp.
NOTE: this function does NOT check that p is a prime greater than 2.
function invModPrime(uint256 a, uint256 p) internal view returns (uint256);
modExp
*Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m) Requirements:
- modulus can't be zero
- underlying staticcall to precompile must succeed IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make sure the chain you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack of a revert, but the result may be incorrectly interpreted as 0.*
function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256);
tryModExp
Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m). It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying to operate modulo 0 or if the underlying precompile reverted. IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack of a revert, but the result may be incorrectly interpreted as 0.
function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result);
modExp
Variant of modExp that supports inputs of arbitrary length.
function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory);
tryModExp
Variant of tryModExp that supports inputs of arbitrary length.
function tryModExp(bytes memory b, bytes memory e, bytes memory m)
internal
view
returns (bool success, bytes memory result);
_zeroBytes
Returns whether the provided byte array is zero.
function _zeroBytes(bytes memory byteArray) private pure returns (bool);
sqrt
Returns the square root of a number. If the number is not a perfect square, the value is rounded towards zero. This method is based on Newton's method for computing square roots; the algorithm is restricted to only using integer operations.
function sqrt(uint256 a) internal pure returns (uint256);
sqrt
Calculates sqrt(a), following the selected rounding direction.
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256);
log2
Return the log in base 2 of a positive value rounded towards zero. Returns 0 if given 0.
function log2(uint256 x) internal pure returns (uint256 r);
log2
Return the log in base 2, following the selected rounding direction, of a positive value. Returns 0 if given 0.
function log2(uint256 value, Rounding rounding) internal pure returns (uint256);
log10
Return the log in base 10 of a positive value rounded towards zero. Returns 0 if given 0.
function log10(uint256 value) internal pure returns (uint256);
log10
Return the log in base 10, following the selected rounding direction, of a positive value. Returns 0 if given 0.
function log10(uint256 value, Rounding rounding) internal pure returns (uint256);
log256
Return the log in base 256 of a positive value rounded towards zero.
Returns 0 if given 0.
Adding one to the result gives the number of pairs of hex symbols needed to represent value as a hex string.
function log256(uint256 x) internal pure returns (uint256 r);
log256
Return the log in base 256, following the selected rounding direction, of a positive value. Returns 0 if given 0.
function log256(uint256 value, Rounding rounding) internal pure returns (uint256);
unsignedRoundsUp
Returns whether a provided rounding mode is considered rounding up for unsigned integers.
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool);
Enums
Rounding
enum Rounding {
Floor,
Ceil,
Trunc,
Expand
}
SafeCast
Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow
checks.
Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
easily result in undesired exploitation or bugs, since developers usually
assume that overflows raise errors. SafeCast restores this intuition by
reverting the transaction when such an operation overflows.
Using this library instead of the unchecked operations eliminates an entire
class of bugs, so it's recommended to use it always.
Functions
toUint248
*Returns the downcasted uint248 from uint256, reverting on
overflow (when the input is greater than largest uint248).
Counterpart to Solidity's uint248 operator.
Requirements:
- input must fit into 248 bits*
function toUint248(uint256 value) internal pure returns (uint248);
toUint240
*Returns the downcasted uint240 from uint256, reverting on
overflow (when the input is greater than largest uint240).
Counterpart to Solidity's uint240 operator.
Requirements:
- input must fit into 240 bits*
function toUint240(uint256 value) internal pure returns (uint240);
toUint232
*Returns the downcasted uint232 from uint256, reverting on
overflow (when the input is greater than largest uint232).
Counterpart to Solidity's uint232 operator.
Requirements:
- input must fit into 232 bits*
function toUint232(uint256 value) internal pure returns (uint232);
toUint224
*Returns the downcasted uint224 from uint256, reverting on
overflow (when the input is greater than largest uint224).
Counterpart to Solidity's uint224 operator.
Requirements:
- input must fit into 224 bits*
function toUint224(uint256 value) internal pure returns (uint224);
toUint216
*Returns the downcasted uint216 from uint256, reverting on
overflow (when the input is greater than largest uint216).
Counterpart to Solidity's uint216 operator.
Requirements:
- input must fit into 216 bits*
function toUint216(uint256 value) internal pure returns (uint216);
toUint208
*Returns the downcasted uint208 from uint256, reverting on
overflow (when the input is greater than largest uint208).
Counterpart to Solidity's uint208 operator.
Requirements:
- input must fit into 208 bits*
function toUint208(uint256 value) internal pure returns (uint208);
toUint200
*Returns the downcasted uint200 from uint256, reverting on
overflow (when the input is greater than largest uint200).
Counterpart to Solidity's uint200 operator.
Requirements:
- input must fit into 200 bits*
function toUint200(uint256 value) internal pure returns (uint200);
toUint192
*Returns the downcasted uint192 from uint256, reverting on
overflow (when the input is greater than largest uint192).
Counterpart to Solidity's uint192 operator.
Requirements:
- input must fit into 192 bits*
function toUint192(uint256 value) internal pure returns (uint192);
toUint184
*Returns the downcasted uint184 from uint256, reverting on
overflow (when the input is greater than largest uint184).
Counterpart to Solidity's uint184 operator.
Requirements:
- input must fit into 184 bits*
function toUint184(uint256 value) internal pure returns (uint184);
toUint176
*Returns the downcasted uint176 from uint256, reverting on
overflow (when the input is greater than largest uint176).
Counterpart to Solidity's uint176 operator.
Requirements:
- input must fit into 176 bits*
function toUint176(uint256 value) internal pure returns (uint176);
toUint168
*Returns the downcasted uint168 from uint256, reverting on
overflow (when the input is greater than largest uint168).
Counterpart to Solidity's uint168 operator.
Requirements:
- input must fit into 168 bits*
function toUint168(uint256 value) internal pure returns (uint168);
toUint160
*Returns the downcasted uint160 from uint256, reverting on
overflow (when the input is greater than largest uint160).
Counterpart to Solidity's uint160 operator.
Requirements:
- input must fit into 160 bits*
function toUint160(uint256 value) internal pure returns (uint160);
toUint152
*Returns the downcasted uint152 from uint256, reverting on
overflow (when the input is greater than largest uint152).
Counterpart to Solidity's uint152 operator.
Requirements:
- input must fit into 152 bits*
function toUint152(uint256 value) internal pure returns (uint152);
toUint144
*Returns the downcasted uint144 from uint256, reverting on
overflow (when the input is greater than largest uint144).
Counterpart to Solidity's uint144 operator.
Requirements:
- input must fit into 144 bits*
function toUint144(uint256 value) internal pure returns (uint144);
toUint136
*Returns the downcasted uint136 from uint256, reverting on
overflow (when the input is greater than largest uint136).
Counterpart to Solidity's uint136 operator.
Requirements:
- input must fit into 136 bits*
function toUint136(uint256 value) internal pure returns (uint136);
toUint128
*Returns the downcasted uint128 from uint256, reverting on
overflow (when the input is greater than largest uint128).
Counterpart to Solidity's uint128 operator.
Requirements:
- input must fit into 128 bits*
function toUint128(uint256 value) internal pure returns (uint128);
toUint120
*Returns the downcasted uint120 from uint256, reverting on
overflow (when the input is greater than largest uint120).
Counterpart to Solidity's uint120 operator.
Requirements:
- input must fit into 120 bits*
function toUint120(uint256 value) internal pure returns (uint120);
toUint112
*Returns the downcasted uint112 from uint256, reverting on
overflow (when the input is greater than largest uint112).
Counterpart to Solidity's uint112 operator.
Requirements:
- input must fit into 112 bits*
function toUint112(uint256 value) internal pure returns (uint112);
toUint104
*Returns the downcasted uint104 from uint256, reverting on
overflow (when the input is greater than largest uint104).
Counterpart to Solidity's uint104 operator.
Requirements:
- input must fit into 104 bits*
function toUint104(uint256 value) internal pure returns (uint104);
toUint96
*Returns the downcasted uint96 from uint256, reverting on
overflow (when the input is greater than largest uint96).
Counterpart to Solidity's uint96 operator.
Requirements:
- input must fit into 96 bits*
function toUint96(uint256 value) internal pure returns (uint96);
toUint88
*Returns the downcasted uint88 from uint256, reverting on
overflow (when the input is greater than largest uint88).
Counterpart to Solidity's uint88 operator.
Requirements:
- input must fit into 88 bits*
function toUint88(uint256 value) internal pure returns (uint88);
toUint80
*Returns the downcasted uint80 from uint256, reverting on
overflow (when the input is greater than largest uint80).
Counterpart to Solidity's uint80 operator.
Requirements:
- input must fit into 80 bits*
function toUint80(uint256 value) internal pure returns (uint80);
toUint72
*Returns the downcasted uint72 from uint256, reverting on
overflow (when the input is greater than largest uint72).
Counterpart to Solidity's uint72 operator.
Requirements:
- input must fit into 72 bits*
function toUint72(uint256 value) internal pure returns (uint72);
toUint64
*Returns the downcasted uint64 from uint256, reverting on
overflow (when the input is greater than largest uint64).
Counterpart to Solidity's uint64 operator.
Requirements:
- input must fit into 64 bits*
function toUint64(uint256 value) internal pure returns (uint64);
toUint56
*Returns the downcasted uint56 from uint256, reverting on
overflow (when the input is greater than largest uint56).
Counterpart to Solidity's uint56 operator.
Requirements:
- input must fit into 56 bits*
function toUint56(uint256 value) internal pure returns (uint56);
toUint48
*Returns the downcasted uint48 from uint256, reverting on
overflow (when the input is greater than largest uint48).
Counterpart to Solidity's uint48 operator.
Requirements:
- input must fit into 48 bits*
function toUint48(uint256 value) internal pure returns (uint48);
toUint40
*Returns the downcasted uint40 from uint256, reverting on
overflow (when the input is greater than largest uint40).
Counterpart to Solidity's uint40 operator.
Requirements:
- input must fit into 40 bits*
function toUint40(uint256 value) internal pure returns (uint40);
toUint32
*Returns the downcasted uint32 from uint256, reverting on
overflow (when the input is greater than largest uint32).
Counterpart to Solidity's uint32 operator.
Requirements:
- input must fit into 32 bits*
function toUint32(uint256 value) internal pure returns (uint32);
toUint24
*Returns the downcasted uint24 from uint256, reverting on
overflow (when the input is greater than largest uint24).
Counterpart to Solidity's uint24 operator.
Requirements:
- input must fit into 24 bits*
function toUint24(uint256 value) internal pure returns (uint24);
toUint16
*Returns the downcasted uint16 from uint256, reverting on
overflow (when the input is greater than largest uint16).
Counterpart to Solidity's uint16 operator.
Requirements:
- input must fit into 16 bits*
function toUint16(uint256 value) internal pure returns (uint16);
toUint8
*Returns the downcasted uint8 from uint256, reverting on
overflow (when the input is greater than largest uint8).
Counterpart to Solidity's uint8 operator.
Requirements:
- input must fit into 8 bits*
function toUint8(uint256 value) internal pure returns (uint8);
toUint256
*Converts a signed int256 into an unsigned uint256. Requirements:
- input must be greater than or equal to 0.*
function toUint256(int256 value) internal pure returns (uint256);
toInt248
*Returns the downcasted int248 from int256, reverting on
overflow (when the input is less than smallest int248 or
greater than largest int248).
Counterpart to Solidity's int248 operator.
Requirements:
- input must fit into 248 bits*
function toInt248(int256 value) internal pure returns (int248 downcasted);
toInt240
*Returns the downcasted int240 from int256, reverting on
overflow (when the input is less than smallest int240 or
greater than largest int240).
Counterpart to Solidity's int240 operator.
Requirements:
- input must fit into 240 bits*
function toInt240(int256 value) internal pure returns (int240 downcasted);
toInt232
*Returns the downcasted int232 from int256, reverting on
overflow (when the input is less than smallest int232 or
greater than largest int232).
Counterpart to Solidity's int232 operator.
Requirements:
- input must fit into 232 bits*
function toInt232(int256 value) internal pure returns (int232 downcasted);
toInt224
*Returns the downcasted int224 from int256, reverting on
overflow (when the input is less than smallest int224 or
greater than largest int224).
Counterpart to Solidity's int224 operator.
Requirements:
- input must fit into 224 bits*
function toInt224(int256 value) internal pure returns (int224 downcasted);
toInt216
*Returns the downcasted int216 from int256, reverting on
overflow (when the input is less than smallest int216 or
greater than largest int216).
Counterpart to Solidity's int216 operator.
Requirements:
- input must fit into 216 bits*
function toInt216(int256 value) internal pure returns (int216 downcasted);
toInt208
*Returns the downcasted int208 from int256, reverting on
overflow (when the input is less than smallest int208 or
greater than largest int208).
Counterpart to Solidity's int208 operator.
Requirements:
- input must fit into 208 bits*
function toInt208(int256 value) internal pure returns (int208 downcasted);
toInt200
*Returns the downcasted int200 from int256, reverting on
overflow (when the input is less than smallest int200 or
greater than largest int200).
Counterpart to Solidity's int200 operator.
Requirements:
- input must fit into 200 bits*
function toInt200(int256 value) internal pure returns (int200 downcasted);
toInt192
*Returns the downcasted int192 from int256, reverting on
overflow (when the input is less than smallest int192 or
greater than largest int192).
Counterpart to Solidity's int192 operator.
Requirements:
- input must fit into 192 bits*
function toInt192(int256 value) internal pure returns (int192 downcasted);
toInt184
*Returns the downcasted int184 from int256, reverting on
overflow (when the input is less than smallest int184 or
greater than largest int184).
Counterpart to Solidity's int184 operator.
Requirements:
- input must fit into 184 bits*
function toInt184(int256 value) internal pure returns (int184 downcasted);
toInt176
*Returns the downcasted int176 from int256, reverting on
overflow (when the input is less than smallest int176 or
greater than largest int176).
Counterpart to Solidity's int176 operator.
Requirements:
- input must fit into 176 bits*
function toInt176(int256 value) internal pure returns (int176 downcasted);
toInt168
*Returns the downcasted int168 from int256, reverting on
overflow (when the input is less than smallest int168 or
greater than largest int168).
Counterpart to Solidity's int168 operator.
Requirements:
- input must fit into 168 bits*
function toInt168(int256 value) internal pure returns (int168 downcasted);
toInt160
*Returns the downcasted int160 from int256, reverting on
overflow (when the input is less than smallest int160 or
greater than largest int160).
Counterpart to Solidity's int160 operator.
Requirements:
- input must fit into 160 bits*
function toInt160(int256 value) internal pure returns (int160 downcasted);
toInt152
*Returns the downcasted int152 from int256, reverting on
overflow (when the input is less than smallest int152 or
greater than largest int152).
Counterpart to Solidity's int152 operator.
Requirements:
- input must fit into 152 bits*
function toInt152(int256 value) internal pure returns (int152 downcasted);
toInt144
*Returns the downcasted int144 from int256, reverting on
overflow (when the input is less than smallest int144 or
greater than largest int144).
Counterpart to Solidity's int144 operator.
Requirements:
- input must fit into 144 bits*
function toInt144(int256 value) internal pure returns (int144 downcasted);
toInt136
*Returns the downcasted int136 from int256, reverting on
overflow (when the input is less than smallest int136 or
greater than largest int136).
Counterpart to Solidity's int136 operator.
Requirements:
- input must fit into 136 bits*
function toInt136(int256 value) internal pure returns (int136 downcasted);
toInt128
*Returns the downcasted int128 from int256, reverting on
overflow (when the input is less than smallest int128 or
greater than largest int128).
Counterpart to Solidity's int128 operator.
Requirements:
- input must fit into 128 bits*
function toInt128(int256 value) internal pure returns (int128 downcasted);
toInt120
*Returns the downcasted int120 from int256, reverting on
overflow (when the input is less than smallest int120 or
greater than largest int120).
Counterpart to Solidity's int120 operator.
Requirements:
- input must fit into 120 bits*
function toInt120(int256 value) internal pure returns (int120 downcasted);
toInt112
*Returns the downcasted int112 from int256, reverting on
overflow (when the input is less than smallest int112 or
greater than largest int112).
Counterpart to Solidity's int112 operator.
Requirements:
- input must fit into 112 bits*
function toInt112(int256 value) internal pure returns (int112 downcasted);
toInt104
*Returns the downcasted int104 from int256, reverting on
overflow (when the input is less than smallest int104 or
greater than largest int104).
Counterpart to Solidity's int104 operator.
Requirements:
- input must fit into 104 bits*
function toInt104(int256 value) internal pure returns (int104 downcasted);
toInt96
*Returns the downcasted int96 from int256, reverting on
overflow (when the input is less than smallest int96 or
greater than largest int96).
Counterpart to Solidity's int96 operator.
Requirements:
- input must fit into 96 bits*
function toInt96(int256 value) internal pure returns (int96 downcasted);
toInt88
*Returns the downcasted int88 from int256, reverting on
overflow (when the input is less than smallest int88 or
greater than largest int88).
Counterpart to Solidity's int88 operator.
Requirements:
- input must fit into 88 bits*
function toInt88(int256 value) internal pure returns (int88 downcasted);
toInt80
*Returns the downcasted int80 from int256, reverting on
overflow (when the input is less than smallest int80 or
greater than largest int80).
Counterpart to Solidity's int80 operator.
Requirements:
- input must fit into 80 bits*
function toInt80(int256 value) internal pure returns (int80 downcasted);
toInt72
*Returns the downcasted int72 from int256, reverting on
overflow (when the input is less than smallest int72 or
greater than largest int72).
Counterpart to Solidity's int72 operator.
Requirements:
- input must fit into 72 bits*
function toInt72(int256 value) internal pure returns (int72 downcasted);
toInt64
*Returns the downcasted int64 from int256, reverting on
overflow (when the input is less than smallest int64 or
greater than largest int64).
Counterpart to Solidity's int64 operator.
Requirements:
- input must fit into 64 bits*
function toInt64(int256 value) internal pure returns (int64 downcasted);
toInt56
*Returns the downcasted int56 from int256, reverting on
overflow (when the input is less than smallest int56 or
greater than largest int56).
Counterpart to Solidity's int56 operator.
Requirements:
- input must fit into 56 bits*
function toInt56(int256 value) internal pure returns (int56 downcasted);
toInt48
*Returns the downcasted int48 from int256, reverting on
overflow (when the input is less than smallest int48 or
greater than largest int48).
Counterpart to Solidity's int48 operator.
Requirements:
- input must fit into 48 bits*
function toInt48(int256 value) internal pure returns (int48 downcasted);
toInt40
*Returns the downcasted int40 from int256, reverting on
overflow (when the input is less than smallest int40 or
greater than largest int40).
Counterpart to Solidity's int40 operator.
Requirements:
- input must fit into 40 bits*
function toInt40(int256 value) internal pure returns (int40 downcasted);
toInt32
*Returns the downcasted int32 from int256, reverting on
overflow (when the input is less than smallest int32 or
greater than largest int32).
Counterpart to Solidity's int32 operator.
Requirements:
- input must fit into 32 bits*
function toInt32(int256 value) internal pure returns (int32 downcasted);
toInt24
*Returns the downcasted int24 from int256, reverting on
overflow (when the input is less than smallest int24 or
greater than largest int24).
Counterpart to Solidity's int24 operator.
Requirements:
- input must fit into 24 bits*
function toInt24(int256 value) internal pure returns (int24 downcasted);
toInt16
*Returns the downcasted int16 from int256, reverting on
overflow (when the input is less than smallest int16 or
greater than largest int16).
Counterpart to Solidity's int16 operator.
Requirements:
- input must fit into 16 bits*
function toInt16(int256 value) internal pure returns (int16 downcasted);
toInt8
*Returns the downcasted int8 from int256, reverting on
overflow (when the input is less than smallest int8 or
greater than largest int8).
Counterpart to Solidity's int8 operator.
Requirements:
- input must fit into 8 bits*
function toInt8(int256 value) internal pure returns (int8 downcasted);
toInt256
*Converts an unsigned uint256 into a signed int256. Requirements:
- input must be less than or equal to maxInt256.*
function toInt256(uint256 value) internal pure returns (int256);
toUint
Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
function toUint(bool b) internal pure returns (uint256 u);
Errors
SafeCastOverflowedUintDowncast
Value doesn't fit in an uint of bits size.
error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);
SafeCastOverflowedIntToUint
An int value doesn't fit in an uint of bits size.
error SafeCastOverflowedIntToUint(int256 value);
SafeCastOverflowedIntDowncast
Value doesn't fit in an int of bits size.
error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);
SafeCastOverflowedUintToInt
An uint value doesn't fit in an int of bits size.
error SafeCastOverflowedUintToInt(uint256 value);
SignedMath
Standard signed math utilities missing in the Solidity language.
Functions
ternary
Branchless ternary evaluation for a ? b : c. Gas costs are constant.
IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
However, the compiler may optimize Solidity ternary operations (i.e. a ? b : c) to only compute
one branch when needed, making this function more expensive.
function ternary(bool condition, int256 a, int256 b) internal pure returns (int256);
max
Returns the largest of two signed numbers.
function max(int256 a, int256 b) internal pure returns (int256);
min
Returns the smallest of two signed numbers.
function min(int256 a, int256 b) internal pure returns (int256);
average
Returns the average of two signed numbers without overflow. The result is rounded towards zero.
function average(int256 a, int256 b) internal pure returns (int256);
abs
Returns the absolute unsigned value of a signed value.
function abs(int256 n) internal pure returns (uint256);
Contents
BitMaps
*Library for managing uint256 to bool mapping in a compact and efficient way, provided the keys are sequential.
Largely inspired by Uniswap's https://github.com/Uniswap/merkle-distributor/blob/master/contracts/MerkleDistributor.sol[merkle-distributor].
BitMaps pack 256 booleans across each bit of a single 256-bit slot of uint256 type.
Hence booleans corresponding to 256 sequential indices would only consume a single slot,
unlike the regular bool which would consume an entire slot for a single value.
This results in gas savings in two ways:
- Setting a zero value to non-zero only once every 256 times
- Accessing the same warm slot for every 256 sequential indices*
Functions
get
Returns whether the bit at index is set.
function get(BitMap storage bitmap, uint256 index) internal view returns (bool);
setTo
Sets the bit at index to the boolean value.
function setTo(BitMap storage bitmap, uint256 index, bool value) internal;
set
Sets the bit at index.
function set(BitMap storage bitmap, uint256 index) internal;
unset
Unsets the bit at index.
function unset(BitMap storage bitmap, uint256 index) internal;
Structs
BitMap
struct BitMap {
mapping(uint256 bucket => uint256) _data;
}
Checkpoints
This library defines the Trace* struct, for checkpointing values as they change at different points in
time, and later looking up past values by block number. See {Votes} as an example.
To create a history of checkpoints define a variable type Checkpoints.Trace* in your contract, and store a new
checkpoint for the current transaction block using the {push} function.
Functions
push
Pushes a (key, value) pair into a Trace224 so that it is stored as the checkpoint.
Returns previous value and new value.
IMPORTANT: Never accept key as a user input, since an arbitrary type(uint32).max key set will disable the
library.
function push(Trace224 storage self, uint32 key, uint224 value) internal returns (uint224 oldValue, uint224 newValue);
lowerLookup
Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if there is none.
function lowerLookup(Trace224 storage self, uint32 key) internal view returns (uint224);
upperLookup
Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero if there is none.
function upperLookup(Trace224 storage self, uint32 key) internal view returns (uint224);
upperLookupRecent
Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero if there is none. NOTE: This is a variant of upperLookup that is optimized to find "recent" checkpoint (checkpoints with high keys).
function upperLookupRecent(Trace224 storage self, uint32 key) internal view returns (uint224);
latest
Returns the value in the most recent checkpoint, or zero if there are no checkpoints.
function latest(Trace224 storage self) internal view returns (uint224);
latestCheckpoint
Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value in the most recent checkpoint.
function latestCheckpoint(Trace224 storage self) internal view returns (bool exists, uint32 _key, uint224 _value);
length
Returns the number of checkpoints.
function length(Trace224 storage self) internal view returns (uint256);
at
Returns checkpoint at given position.
function at(Trace224 storage self, uint32 pos) internal view returns (Checkpoint224 memory);
_insert
Pushes a (key, value) pair into an ordered list of checkpoints, either by inserting a new checkpoint,
or by updating the last one.
function _insert(Checkpoint224[] storage self, uint32 key, uint224 value)
private
returns (uint224 oldValue, uint224 newValue);
_upperBinaryLookup
Return the index of the first (oldest) checkpoint with key strictly bigger than the search key, or high
if there is none. low and high define a section where to do the search, with inclusive low and exclusive
high.
WARNING: high should not be greater than the array's length.
function _upperBinaryLookup(Checkpoint224[] storage self, uint32 key, uint256 low, uint256 high)
private
view
returns (uint256);
_lowerBinaryLookup
Return the index of the first (oldest) checkpoint with key greater or equal than the search key, or high
if there is none. low and high define a section where to do the search, with inclusive low and exclusive
high.
WARNING: high should not be greater than the array's length.
function _lowerBinaryLookup(Checkpoint224[] storage self, uint32 key, uint256 low, uint256 high)
private
view
returns (uint256);
_unsafeAccess
Access an element of the array without performing bounds check. The position is assumed to be within bounds.
function _unsafeAccess(Checkpoint224[] storage self, uint256 pos) private pure returns (Checkpoint224 storage result);
push
Pushes a (key, value) pair into a Trace208 so that it is stored as the checkpoint.
Returns previous value and new value.
IMPORTANT: Never accept key as a user input, since an arbitrary type(uint48).max key set will disable the
library.
function push(Trace208 storage self, uint48 key, uint208 value) internal returns (uint208 oldValue, uint208 newValue);
lowerLookup
Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if there is none.
function lowerLookup(Trace208 storage self, uint48 key) internal view returns (uint208);
upperLookup
Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero if there is none.
function upperLookup(Trace208 storage self, uint48 key) internal view returns (uint208);
upperLookupRecent
Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero if there is none. NOTE: This is a variant of upperLookup that is optimized to find "recent" checkpoint (checkpoints with high keys).
function upperLookupRecent(Trace208 storage self, uint48 key) internal view returns (uint208);
latest
Returns the value in the most recent checkpoint, or zero if there are no checkpoints.
function latest(Trace208 storage self) internal view returns (uint208);
latestCheckpoint
Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value in the most recent checkpoint.
function latestCheckpoint(Trace208 storage self) internal view returns (bool exists, uint48 _key, uint208 _value);
length
Returns the number of checkpoints.
function length(Trace208 storage self) internal view returns (uint256);
at
Returns checkpoint at given position.
function at(Trace208 storage self, uint32 pos) internal view returns (Checkpoint208 memory);
_insert
Pushes a (key, value) pair into an ordered list of checkpoints, either by inserting a new checkpoint,
or by updating the last one.
function _insert(Checkpoint208[] storage self, uint48 key, uint208 value)
private
returns (uint208 oldValue, uint208 newValue);
_upperBinaryLookup
Return the index of the first (oldest) checkpoint with key strictly bigger than the search key, or high
if there is none. low and high define a section where to do the search, with inclusive low and exclusive
high.
WARNING: high should not be greater than the array's length.
function _upperBinaryLookup(Checkpoint208[] storage self, uint48 key, uint256 low, uint256 high)
private
view
returns (uint256);
_lowerBinaryLookup
Return the index of the first (oldest) checkpoint with key greater or equal than the search key, or high
if there is none. low and high define a section where to do the search, with inclusive low and exclusive
high.
WARNING: high should not be greater than the array's length.
function _lowerBinaryLookup(Checkpoint208[] storage self, uint48 key, uint256 low, uint256 high)
private
view
returns (uint256);
_unsafeAccess
Access an element of the array without performing bounds check. The position is assumed to be within bounds.
function _unsafeAccess(Checkpoint208[] storage self, uint256 pos) private pure returns (Checkpoint208 storage result);
push
Pushes a (key, value) pair into a Trace160 so that it is stored as the checkpoint.
Returns previous value and new value.
IMPORTANT: Never accept key as a user input, since an arbitrary type(uint96).max key set will disable the
library.
function push(Trace160 storage self, uint96 key, uint160 value) internal returns (uint160 oldValue, uint160 newValue);
lowerLookup
Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if there is none.
function lowerLookup(Trace160 storage self, uint96 key) internal view returns (uint160);
upperLookup
Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero if there is none.
function upperLookup(Trace160 storage self, uint96 key) internal view returns (uint160);
upperLookupRecent
Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero if there is none. NOTE: This is a variant of upperLookup that is optimized to find "recent" checkpoint (checkpoints with high keys).
function upperLookupRecent(Trace160 storage self, uint96 key) internal view returns (uint160);
latest
Returns the value in the most recent checkpoint, or zero if there are no checkpoints.
function latest(Trace160 storage self) internal view returns (uint160);
latestCheckpoint
Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value in the most recent checkpoint.
function latestCheckpoint(Trace160 storage self) internal view returns (bool exists, uint96 _key, uint160 _value);
length
Returns the number of checkpoints.
function length(Trace160 storage self) internal view returns (uint256);
at
Returns checkpoint at given position.
function at(Trace160 storage self, uint32 pos) internal view returns (Checkpoint160 memory);
_insert
Pushes a (key, value) pair into an ordered list of checkpoints, either by inserting a new checkpoint,
or by updating the last one.
function _insert(Checkpoint160[] storage self, uint96 key, uint160 value)
private
returns (uint160 oldValue, uint160 newValue);
_upperBinaryLookup
Return the index of the first (oldest) checkpoint with key strictly bigger than the search key, or high
if there is none. low and high define a section where to do the search, with inclusive low and exclusive
high.
WARNING: high should not be greater than the array's length.
function _upperBinaryLookup(Checkpoint160[] storage self, uint96 key, uint256 low, uint256 high)
private
view
returns (uint256);
_lowerBinaryLookup
Return the index of the first (oldest) checkpoint with key greater or equal than the search key, or high
if there is none. low and high define a section where to do the search, with inclusive low and exclusive
high.
WARNING: high should not be greater than the array's length.
function _lowerBinaryLookup(Checkpoint160[] storage self, uint96 key, uint256 low, uint256 high)
private
view
returns (uint256);
_unsafeAccess
Access an element of the array without performing bounds check. The position is assumed to be within bounds.
function _unsafeAccess(Checkpoint160[] storage self, uint256 pos) private pure returns (Checkpoint160 storage result);
Errors
CheckpointUnorderedInsertion
A value was attempted to be inserted on a past checkpoint.
error CheckpointUnorderedInsertion();
Structs
Trace224
struct Trace224 {
Checkpoint224[] _checkpoints;
}
Checkpoint224
struct Checkpoint224 {
uint32 _key;
uint224 _value;
}
Trace208
struct Trace208 {
Checkpoint208[] _checkpoints;
}
Checkpoint208
struct Checkpoint208 {
uint48 _key;
uint208 _value;
}
Trace160
struct Trace160 {
Checkpoint160[] _checkpoints;
}
Checkpoint160
struct Checkpoint160 {
uint96 _key;
uint160 _value;
}
CircularBuffer
*A fixed-size buffer for keeping bytes32 items in storage.
This data structure allows for pushing elements to it, and when its length exceeds the specified fixed size,
new items take the place of the oldest element in the buffer, keeping at most N elements in the
structure.
Elements can't be removed but the data structure can be cleared. See clear.
Complexity:
- insertion ({push}): O(1)
- lookup ({last}): O(1)
- inclusion ({includes}): O(N) (worst case)
- reset ({clear}): O(1)
The struct is called
Bytes32CircularBuffer. Other types can be cast to and frombytes32. This data structure can only be used in storage, and not in memory. Example usage:
contract Example {
// Add the library methods
using CircularBuffer for CircularBuffer.Bytes32CircularBuffer;
// Declare a buffer storage variable
CircularBuffer.Bytes32CircularBuffer private myBuffer;
}
Available since v5.1.*
Functions
setup
Initialize a new CircularBuffer of a given size. If the CircularBuffer was already setup and used, calling that function again will reset it to a blank state. NOTE: The size of the buffer will affect the execution of includes function, as it has a complexity of O(N). Consider a large buffer size may render the function unusable.
function setup(Bytes32CircularBuffer storage self, uint256 size) internal;
clear
Clear all data in the buffer without resetting memory, keeping the existing size.
function clear(Bytes32CircularBuffer storage self) internal;
push
Push a new value to the buffer. If the buffer is already full, the new value replaces the oldest value in the buffer.
function push(Bytes32CircularBuffer storage self, bytes32 value) internal;
count
Number of values currently in the buffer. This value is 0 for an empty buffer, and cannot exceed the size of the buffer.
function count(Bytes32CircularBuffer storage self) internal view returns (uint256);
length
Length of the buffer. This is the maximum number of elements kept in the buffer.
function length(Bytes32CircularBuffer storage self) internal view returns (uint256);
last
Getter for the i-th value in the buffer, from the end. Reverts with {Panic-ARRAY_OUT_OF_BOUNDS} if trying to access an element that was not pushed, or that was dropped to make room for newer elements.
function last(Bytes32CircularBuffer storage self, uint256 i) internal view returns (bytes32);
includes
Check if a given value is in the buffer.
function includes(Bytes32CircularBuffer storage self, bytes32 value) internal view returns (bool);
Errors
InvalidBufferSize
Error emitted when trying to setup a buffer with a size of 0.
error InvalidBufferSize();
Structs
Bytes32CircularBuffer
*Counts the number of items that have been pushed to the buffer. The residuo modulo _data.length indicates where the next value should be stored. Struct members have an underscore prefix indicating that they are "private" and should not be read or written to directly. Use the functions provided below instead. Modifying the struct manually may violate assumptions and lead to unexpected behavior. In a full buffer:
- The most recently pushed item (last) is at data[(index - 1) % data.length]
- The oldest item (first) is at data[index % data.length]*
struct Bytes32CircularBuffer {
uint256 _count;
bytes32[] _data;
}
DoubleEndedQueue
*A sequence of items with the ability to efficiently push and pop items (i.e. insert and remove) on both ends of
the sequence (called front and back). Among other access patterns, it can be used to implement efficient LIFO and
FIFO queues. Storage use is optimized, and all operations are O(1) constant time. This includes clear, given that
the existing queue contents are left in storage.
The struct is called Bytes32Deque. Other types can be cast to and from bytes32. This data structure can only be
used in storage, and not in memory.
DoubleEndedQueue.Bytes32Deque queue;
```*
## Functions
### pushBack
*Inserts an item at the end of the queue.
Reverts with {Panic-RESOURCE_ERROR} if the queue is full.*
```solidity
function pushBack(Bytes32Deque storage deque, bytes32 value) internal;
popBack
Removes the item at the end of the queue and returns it. Reverts with {Panic-EMPTY_ARRAY_POP} if the queue is empty.
function popBack(Bytes32Deque storage deque) internal returns (bytes32 value);
pushFront
Inserts an item at the beginning of the queue. Reverts with {Panic-RESOURCE_ERROR} if the queue is full.
function pushFront(Bytes32Deque storage deque, bytes32 value) internal;
popFront
Removes the item at the beginning of the queue and returns it. Reverts with {Panic-EMPTY_ARRAY_POP} if the queue is empty.
function popFront(Bytes32Deque storage deque) internal returns (bytes32 value);
front
Returns the item at the beginning of the queue. Reverts with {Panic-ARRAY_OUT_OF_BOUNDS} if the queue is empty.
function front(Bytes32Deque storage deque) internal view returns (bytes32 value);
back
Returns the item at the end of the queue. Reverts with {Panic-ARRAY_OUT_OF_BOUNDS} if the queue is empty.
function back(Bytes32Deque storage deque) internal view returns (bytes32 value);
at
Return the item at a position in the queue given by index, with the first item at 0 and last item at
length(deque) - 1.
Reverts with {Panic-ARRAY_OUT_OF_BOUNDS} if the index is out of bounds.
function at(Bytes32Deque storage deque, uint256 index) internal view returns (bytes32 value);
clear
Resets the queue back to being empty. NOTE: The current items are left behind in storage. This does not affect the functioning of the queue, but misses out on potential gas refunds.
function clear(Bytes32Deque storage deque) internal;
length
Returns the number of items in the queue.
function length(Bytes32Deque storage deque) internal view returns (uint256);
empty
Returns true if the queue is empty.
function empty(Bytes32Deque storage deque) internal view returns (bool);
Structs
Bytes32Deque
Indices are 128 bits so begin and end are packed in a single storage slot for efficient access. Struct members have an underscore prefix indicating that they are "private" and should not be read or written to directly. Use the functions provided below instead. Modifying the struct manually may violate assumptions and lead to unexpected behavior. The first item is at data[begin] and the last item is at data[end - 1]. This range can wrap around.
struct Bytes32Deque {
uint128 _begin;
uint128 _end;
mapping(uint128 index => bytes32) _data;
}
EnumerableMap
*Library for managing an enumerable variant of Solidity's
https://solidity.readthedocs.io/en/latest/types.html#mapping-types[mapping]
type.
Maps have the following properties:
- Entries are added, removed, and checked for existence in constant time (O(1)).
- Entries are enumerated in O(n). No guarantees are made on the ordering.
- Map can be cleared (all entries removed) in O(n).
contract Example {
// Add the library methods
using EnumerableMap for EnumerableMap.UintToAddressMap;
// Declare a set state variable
EnumerableMap.UintToAddressMap private myMap;
}
The following map types are supported:
uint256 -> address(UintToAddressMap) since v3.0.0address -> uint256(AddressToUintMap) since v4.6.0bytes32 -> bytes32(Bytes32ToBytes32Map) since v4.6.0uint256 -> uint256(UintToUintMap) since v4.7.0bytes32 -> uint256(Bytes32ToUintMap) since v4.7.0uint256 -> bytes32(UintToBytes32Map) since v5.1.0address -> address(AddressToAddressMap) since v5.1.0address -> bytes32(AddressToBytes32Map) since v5.1.0bytes32 -> address(Bytes32ToAddressMap) since v5.1.0bytes -> bytes(BytesToBytesMap) since v5.4.0 [WARNING] ==== Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable. See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. In order to clean an EnumerableMap, you can either remove all elements one by one or create a fresh instance using an array of EnumerableMap. ====*
Functions
set
Adds a key-value pair to a map, or updates the value for an existing key. O(1). Returns true if the key was added to the map, that is if it was not already present.
function set(Bytes32ToBytes32Map storage map, bytes32 key, bytes32 value) internal returns (bool);
remove
Removes a key-value pair from a map. O(1). Returns true if the key was removed from the map, that is if it was present.
function remove(Bytes32ToBytes32Map storage map, bytes32 key) internal returns (bool);
clear
Removes all the entries from a map. O(n). WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the function uncallable if the map grows to the point where clearing it consumes too much gas to fit in a block.
function clear(Bytes32ToBytes32Map storage map) internal;
contains
Returns true if the key is in the map. O(1).
function contains(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool);
length
Returns the number of key-value pairs in the map. O(1).
function length(Bytes32ToBytes32Map storage map) internal view returns (uint256);
at
*Returns the key-value pair stored at position index in the map. O(1).
Note that there are no guarantees on the ordering of entries inside the
array, and it may change when more entries are added or removed.
Requirements:
indexmust be strictly less than length.*
function at(Bytes32ToBytes32Map storage map, uint256 index) internal view returns (bytes32 key, bytes32 value);
tryGet
Tries to return the value associated with key. O(1).
Does not revert if key is not in the map.
function tryGet(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool exists, bytes32 value);
get
*Returns the value associated with key. O(1).
Requirements:
keymust be in the map.*
function get(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bytes32);
keys
Returns an array containing all the keys WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
function keys(Bytes32ToBytes32Map storage map) internal view returns (bytes32[] memory);
keys
Returns an array containing a slice of the keys WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
function keys(Bytes32ToBytes32Map storage map, uint256 start, uint256 end) internal view returns (bytes32[] memory);
set
Adds a key-value pair to a map, or updates the value for an existing key. O(1). Returns true if the key was added to the map, that is if it was not already present.
function set(UintToUintMap storage map, uint256 key, uint256 value) internal returns (bool);
remove
Removes a value from a map. O(1). Returns true if the key was removed from the map, that is if it was present.
function remove(UintToUintMap storage map, uint256 key) internal returns (bool);
clear
Removes all the entries from a map. O(n). WARNING: This function has an unbounded cost that scales with map size. Developers should keep in mind that using it may render the function uncallable if the map grows to the point where clearing it consumes too much gas to fit in a block.
function clear(UintToUintMap storage map) internal;
contains
Returns true if the key is in the map. O(1).
function contains(UintToUintMap storage map, uint256 key) internal view returns (bool);
length
Returns the number of elements in the map. O(1).
function length(UintToUintMap storage map) internal view returns (uint256);
at
*Returns the element stored at position index in the map. O(1).
Note that there are no guarantees on the ordering of values inside the
array, and it may change when more values are added or removed.
Requirements:
indexmust be strictly less than length.*
function at(UintToUintMap storage map, uint256 index) internal view returns (uint256 key, uint256 value);
tryGet
Tries to return the value associated with key. O(1).
Does not revert if key is not in the map.
function tryGet(UintToUintMap storage map, uint256 key) internal view returns (bool exists, uint256 value);
get
*Returns the value associated with key. O(1).
Requirements:
keymust be in the map.*
function get(UintToUintMap storage map, uint256 key) internal view returns (uint256);
keys
Returns an array containing all the keys WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
function keys(UintToUintMap storage map) internal view returns (uint256[] memory);
keys
Returns an array containing a slice of the keys WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
function keys(UintToUintMap storage map, uint256 start, uint256 end) internal view returns (uint256[] memory);
set
Adds a key-value pair to a map, or updates the value for an existing key. O(1). Returns true if the key was added to the map, that is if it was not already present.
function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool);
remove
Removes a value from a map. O(1). Returns true if the key was removed from the map, that is if it was present.
function remove(UintToAddressMap storage map, uint256 key) internal returns (bool);
clear
Removes all the entries from a map. O(n). WARNING: This function has an unbounded cost that scales with map size. Developers should keep in mind that using it may render the function uncallable if the map grows to the point where clearing it consumes too much gas to fit in a block.
function clear(UintToAddressMap storage map) internal;
contains
Returns true if the key is in the map. O(1).
function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool);
length
Returns the number of elements in the map. O(1).
function length(UintToAddressMap storage map) internal view returns (uint256);
at
*Returns the element stored at position index in the map. O(1).
Note that there are no guarantees on the ordering of values inside the
array, and it may change when more values are added or removed.
Requirements:
indexmust be strictly less than length.*
function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256 key, address value);
tryGet
Tries to return the value associated with key. O(1).
Does not revert if key is not in the map.
function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool exists, address value);
get
*Returns the value associated with key. O(1).
Requirements:
keymust be in the map.*
function get(UintToAddressMap storage map, uint256 key) internal view returns (address);
keys
Returns an array containing all the keys WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
function keys(UintToAddressMap storage map) internal view returns (uint256[] memory);
keys
Returns an array containing a slice of the keys WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
function keys(UintToAddressMap storage map, uint256 start, uint256 end) internal view returns (uint256[] memory);
set
Adds a key-value pair to a map, or updates the value for an existing key. O(1). Returns true if the key was added to the map, that is if it was not already present.
function set(UintToBytes32Map storage map, uint256 key, bytes32 value) internal returns (bool);
remove
Removes a value from a map. O(1). Returns true if the key was removed from the map, that is if it was present.
function remove(UintToBytes32Map storage map, uint256 key) internal returns (bool);
clear
Removes all the entries from a map. O(n). WARNING: This function has an unbounded cost that scales with map size. Developers should keep in mind that using it may render the function uncallable if the map grows to the point where clearing it consumes too much gas to fit in a block.
function clear(UintToBytes32Map storage map) internal;
contains
Returns true if the key is in the map. O(1).
function contains(UintToBytes32Map storage map, uint256 key) internal view returns (bool);
length
Returns the number of elements in the map. O(1).
function length(UintToBytes32Map storage map) internal view returns (uint256);
at
*Returns the element stored at position index in the map. O(1).
Note that there are no guarantees on the ordering of values inside the
array, and it may change when more values are added or removed.
Requirements:
indexmust be strictly less than length.*
function at(UintToBytes32Map storage map, uint256 index) internal view returns (uint256 key, bytes32 value);
tryGet
Tries to return the value associated with key. O(1).
Does not revert if key is not in the map.
function tryGet(UintToBytes32Map storage map, uint256 key) internal view returns (bool exists, bytes32 value);
get
*Returns the value associated with key. O(1).
Requirements:
keymust be in the map.*
function get(UintToBytes32Map storage map, uint256 key) internal view returns (bytes32);
keys
Returns an array containing all the keys WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
function keys(UintToBytes32Map storage map) internal view returns (uint256[] memory);
keys
Returns an array containing a slice of the keys WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
function keys(UintToBytes32Map storage map, uint256 start, uint256 end) internal view returns (uint256[] memory);
set
Adds a key-value pair to a map, or updates the value for an existing key. O(1). Returns true if the key was added to the map, that is if it was not already present.
function set(AddressToUintMap storage map, address key, uint256 value) internal returns (bool);
remove
Removes a value from a map. O(1). Returns true if the key was removed from the map, that is if it was present.
function remove(AddressToUintMap storage map, address key) internal returns (bool);
clear
Removes all the entries from a map. O(n). WARNING: This function has an unbounded cost that scales with map size. Developers should keep in mind that using it may render the function uncallable if the map grows to the point where clearing it consumes too much gas to fit in a block.
function clear(AddressToUintMap storage map) internal;
contains
Returns true if the key is in the map. O(1).
function contains(AddressToUintMap storage map, address key) internal view returns (bool);
length
Returns the number of elements in the map. O(1).
function length(AddressToUintMap storage map) internal view returns (uint256);
at
*Returns the element stored at position index in the map. O(1).
Note that there are no guarantees on the ordering of values inside the
array, and it may change when more values are added or removed.
Requirements:
indexmust be strictly less than length.*
function at(AddressToUintMap storage map, uint256 index) internal view returns (address key, uint256 value);
tryGet
Tries to return the value associated with key. O(1).
Does not revert if key is not in the map.
function tryGet(AddressToUintMap storage map, address key) internal view returns (bool exists, uint256 value);
get
*Returns the value associated with key. O(1).
Requirements:
keymust be in the map.*
function get(AddressToUintMap storage map, address key) internal view returns (uint256);
keys
Returns an array containing all the keys WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
function keys(AddressToUintMap storage map) internal view returns (address[] memory);
keys
Returns an array containing a slice of the keys WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
function keys(AddressToUintMap storage map, uint256 start, uint256 end) internal view returns (address[] memory);
set
Adds a key-value pair to a map, or updates the value for an existing key. O(1). Returns true if the key was added to the map, that is if it was not already present.
function set(AddressToAddressMap storage map, address key, address value) internal returns (bool);
remove
Removes a value from a map. O(1). Returns true if the key was removed from the map, that is if it was present.
function remove(AddressToAddressMap storage map, address key) internal returns (bool);
clear
Removes all the entries from a map. O(n). WARNING: This function has an unbounded cost that scales with map size. Developers should keep in mind that using it may render the function uncallable if the map grows to the point where clearing it consumes too much gas to fit in a block.
function clear(AddressToAddressMap storage map) internal;
contains
Returns true if the key is in the map. O(1).
function contains(AddressToAddressMap storage map, address key) internal view returns (bool);
length
Returns the number of elements in the map. O(1).
function length(AddressToAddressMap storage map) internal view returns (uint256);
at
*Returns the element stored at position index in the map. O(1).
Note that there are no guarantees on the ordering of values inside the
array, and it may change when more values are added or removed.
Requirements:
indexmust be strictly less than length.*
function at(AddressToAddressMap storage map, uint256 index) internal view returns (address key, address value);
tryGet
Tries to return the value associated with key. O(1).
Does not revert if key is not in the map.
function tryGet(AddressToAddressMap storage map, address key) internal view returns (bool exists, address value);
get
*Returns the value associated with key. O(1).
Requirements:
keymust be in the map.*
function get(AddressToAddressMap storage map, address key) internal view returns (address);
keys
Returns an array containing all the keys WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
function keys(AddressToAddressMap storage map) internal view returns (address[] memory);
keys
Returns an array containing a slice of the keys WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
function keys(AddressToAddressMap storage map, uint256 start, uint256 end) internal view returns (address[] memory);
set
Adds a key-value pair to a map, or updates the value for an existing key. O(1). Returns true if the key was added to the map, that is if it was not already present.
function set(AddressToBytes32Map storage map, address key, bytes32 value) internal returns (bool);
remove
Removes a value from a map. O(1). Returns true if the key was removed from the map, that is if it was present.
function remove(AddressToBytes32Map storage map, address key) internal returns (bool);
clear
Removes all the entries from a map. O(n). WARNING: This function has an unbounded cost that scales with map size. Developers should keep in mind that using it may render the function uncallable if the map grows to the point where clearing it consumes too much gas to fit in a block.
function clear(AddressToBytes32Map storage map) internal;
contains
Returns true if the key is in the map. O(1).
function contains(AddressToBytes32Map storage map, address key) internal view returns (bool);
length
Returns the number of elements in the map. O(1).
function length(AddressToBytes32Map storage map) internal view returns (uint256);
at
*Returns the element stored at position index in the map. O(1).
Note that there are no guarantees on the ordering of values inside the
array, and it may change when more values are added or removed.
Requirements:
indexmust be strictly less than length.*
function at(AddressToBytes32Map storage map, uint256 index) internal view returns (address key, bytes32 value);
tryGet
Tries to return the value associated with key. O(1).
Does not revert if key is not in the map.
function tryGet(AddressToBytes32Map storage map, address key) internal view returns (bool exists, bytes32 value);
get
*Returns the value associated with key. O(1).
Requirements:
keymust be in the map.*
function get(AddressToBytes32Map storage map, address key) internal view returns (bytes32);
keys
Returns an array containing all the keys WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
function keys(AddressToBytes32Map storage map) internal view returns (address[] memory);
keys
Returns an array containing a slice of the keys WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
function keys(AddressToBytes32Map storage map, uint256 start, uint256 end) internal view returns (address[] memory);
set
Adds a key-value pair to a map, or updates the value for an existing key. O(1). Returns true if the key was added to the map, that is if it was not already present.
function set(Bytes32ToUintMap storage map, bytes32 key, uint256 value) internal returns (bool);
remove
Removes a value from a map. O(1). Returns true if the key was removed from the map, that is if it was present.
function remove(Bytes32ToUintMap storage map, bytes32 key) internal returns (bool);
clear
Removes all the entries from a map. O(n). WARNING: This function has an unbounded cost that scales with map size. Developers should keep in mind that using it may render the function uncallable if the map grows to the point where clearing it consumes too much gas to fit in a block.
function clear(Bytes32ToUintMap storage map) internal;
contains
Returns true if the key is in the map. O(1).
function contains(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool);
length
Returns the number of elements in the map. O(1).
function length(Bytes32ToUintMap storage map) internal view returns (uint256);
at
*Returns the element stored at position index in the map. O(1).
Note that there are no guarantees on the ordering of values inside the
array, and it may change when more values are added or removed.
Requirements:
indexmust be strictly less than length.*
function at(Bytes32ToUintMap storage map, uint256 index) internal view returns (bytes32 key, uint256 value);
tryGet
Tries to return the value associated with key. O(1).
Does not revert if key is not in the map.
function tryGet(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool exists, uint256 value);
get
*Returns the value associated with key. O(1).
Requirements:
keymust be in the map.*
function get(Bytes32ToUintMap storage map, bytes32 key) internal view returns (uint256);
keys
Returns an array containing all the keys WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
function keys(Bytes32ToUintMap storage map) internal view returns (bytes32[] memory);
keys
Returns an array containing a slice of the keys WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
function keys(Bytes32ToUintMap storage map, uint256 start, uint256 end) internal view returns (bytes32[] memory);
set
Adds a key-value pair to a map, or updates the value for an existing key. O(1). Returns true if the key was added to the map, that is if it was not already present.
function set(Bytes32ToAddressMap storage map, bytes32 key, address value) internal returns (bool);
remove
Removes a value from a map. O(1). Returns true if the key was removed from the map, that is if it was present.
function remove(Bytes32ToAddressMap storage map, bytes32 key) internal returns (bool);
clear
Removes all the entries from a map. O(n). WARNING: This function has an unbounded cost that scales with map size. Developers should keep in mind that using it may render the function uncallable if the map grows to the point where clearing it consumes too much gas to fit in a block.
function clear(Bytes32ToAddressMap storage map) internal;
contains
Returns true if the key is in the map. O(1).
function contains(Bytes32ToAddressMap storage map, bytes32 key) internal view returns (bool);
length
Returns the number of elements in the map. O(1).
function length(Bytes32ToAddressMap storage map) internal view returns (uint256);
at
*Returns the element stored at position index in the map. O(1).
Note that there are no guarantees on the ordering of values inside the
array, and it may change when more values are added or removed.
Requirements:
indexmust be strictly less than length.*
function at(Bytes32ToAddressMap storage map, uint256 index) internal view returns (bytes32 key, address value);
tryGet
Tries to return the value associated with key. O(1).
Does not revert if key is not in the map.
function tryGet(Bytes32ToAddressMap storage map, bytes32 key) internal view returns (bool exists, address value);
get
*Returns the value associated with key. O(1).
Requirements:
keymust be in the map.*
function get(Bytes32ToAddressMap storage map, bytes32 key) internal view returns (address);
keys
Returns an array containing all the keys WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
function keys(Bytes32ToAddressMap storage map) internal view returns (bytes32[] memory);
keys
Returns an array containing a slice of the keys WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
function keys(Bytes32ToAddressMap storage map, uint256 start, uint256 end) internal view returns (bytes32[] memory);
set
Adds a key-value pair to a map, or updates the value for an existing key. O(1). Returns true if the key was added to the map, that is if it was not already present.
function set(BytesToBytesMap storage map, bytes memory key, bytes memory value) internal returns (bool);
remove
Removes a key-value pair from a map. O(1). Returns true if the key was removed from the map, that is if it was present.
function remove(BytesToBytesMap storage map, bytes memory key) internal returns (bool);
clear
Removes all the entries from a map. O(n). WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the function uncallable if the map grows to the point where clearing it consumes too much gas to fit in a block.
function clear(BytesToBytesMap storage map) internal;
contains
Returns true if the key is in the map. O(1).
function contains(BytesToBytesMap storage map, bytes memory key) internal view returns (bool);
length
Returns the number of key-value pairs in the map. O(1).
function length(BytesToBytesMap storage map) internal view returns (uint256);
at
*Returns the key-value pair stored at position index in the map. O(1).
Note that there are no guarantees on the ordering of entries inside the
array, and it may change when more entries are added or removed.
Requirements:
indexmust be strictly less than length.*
function at(BytesToBytesMap storage map, uint256 index) internal view returns (bytes memory key, bytes memory value);
tryGet
Tries to return the value associated with key. O(1).
Does not revert if key is not in the map.
function tryGet(BytesToBytesMap storage map, bytes memory key)
internal
view
returns (bool exists, bytes memory value);
get
*Returns the value associated with key. O(1).
Requirements:
keymust be in the map.*
function get(BytesToBytesMap storage map, bytes memory key) internal view returns (bytes memory value);
keys
Returns an array containing all the keys WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
function keys(BytesToBytesMap storage map) internal view returns (bytes[] memory);
keys
Returns an array containing a slice of the keys WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
function keys(BytesToBytesMap storage map, uint256 start, uint256 end) internal view returns (bytes[] memory);
Errors
EnumerableMapNonexistentKey
Query for a nonexistent map key.
error EnumerableMapNonexistentKey(bytes32 key);
EnumerableMapNonexistentBytesKey
Query for a nonexistent map key.
error EnumerableMapNonexistentBytesKey(bytes key);
Structs
Bytes32ToBytes32Map
struct Bytes32ToBytes32Map {
EnumerableSet.Bytes32Set _keys;
mapping(bytes32 key => bytes32) _values;
}
UintToUintMap
struct UintToUintMap {
Bytes32ToBytes32Map _inner;
}
UintToAddressMap
struct UintToAddressMap {
Bytes32ToBytes32Map _inner;
}
UintToBytes32Map
struct UintToBytes32Map {
Bytes32ToBytes32Map _inner;
}
AddressToUintMap
struct AddressToUintMap {
Bytes32ToBytes32Map _inner;
}
AddressToAddressMap
struct AddressToAddressMap {
Bytes32ToBytes32Map _inner;
}
AddressToBytes32Map
struct AddressToBytes32Map {
Bytes32ToBytes32Map _inner;
}
Bytes32ToUintMap
struct Bytes32ToUintMap {
Bytes32ToBytes32Map _inner;
}
Bytes32ToAddressMap
struct Bytes32ToAddressMap {
Bytes32ToBytes32Map _inner;
}
BytesToBytesMap
struct BytesToBytesMap {
EnumerableSet.BytesSet _keys;
mapping(bytes key => bytes) _values;
}
EnumerableSet
*Library for managing https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive types. Sets have the following properties:
- Elements are added, removed, and checked for existence in constant time (O(1)).
- Elements are enumerated in O(n). No guarantees are made on the ordering.
- Set can be cleared (all elements removed) in O(n).
contract Example {
// Add the library methods
using EnumerableSet for EnumerableSet.AddressSet;
// Declare a set state variable
EnumerableSet.AddressSet private mySet;
}
The following types are supported:
bytes32(Bytes32Set) since v3.3.0address(AddressSet) since v3.3.0uint256(UintSet) since v3.3.0string(StringSet) since v5.4.0bytes(BytesSet) since v5.4.0 [WARNING] ==== Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable. See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet. ====*
Functions
_add
Add a value to a set. O(1). Returns true if the value was added to the set, that is if it was not already present.
function _add(Set storage set, bytes32 value) private returns (bool);
_remove
Removes a value from a set. O(1). Returns true if the value was removed from the set, that is if it was present.
function _remove(Set storage set, bytes32 value) private returns (bool);
_clear
Removes all the values from a set. O(n). WARNING: This function has an unbounded cost that scales with set size. Developers should keep in mind that using it may render the function uncallable if the set grows to the point where clearing it consumes too much gas to fit in a block.
function _clear(Set storage set) private;
_contains
Returns true if the value is in the set. O(1).
function _contains(Set storage set, bytes32 value) private view returns (bool);
_length
Returns the number of values on the set. O(1).
function _length(Set storage set) private view returns (uint256);
_at
*Returns the value stored at position index in the set. O(1).
Note that there are no guarantees on the ordering of values inside the
array, and it may change when more values are added or removed.
Requirements:
indexmust be strictly less than length.*
function _at(Set storage set, uint256 index) private view returns (bytes32);
_values
Return the entire set in an array WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
function _values(Set storage set) private view returns (bytes32[] memory);
_values
Return a slice of the set in an array WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
function _values(Set storage set, uint256 start, uint256 end) private view returns (bytes32[] memory);
add
Add a value to a set. O(1). Returns true if the value was added to the set, that is if it was not already present.
function add(Bytes32Set storage set, bytes32 value) internal returns (bool);
remove
Removes a value from a set. O(1). Returns true if the value was removed from the set, that is if it was present.
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool);
clear
Removes all the values from a set. O(n). WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the function uncallable if the set grows to the point where clearing it consumes too much gas to fit in a block.
function clear(Bytes32Set storage set) internal;
contains
Returns true if the value is in the set. O(1).
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool);
length
Returns the number of values in the set. O(1).
function length(Bytes32Set storage set) internal view returns (uint256);
at
*Returns the value stored at position index in the set. O(1).
Note that there are no guarantees on the ordering of values inside the
array, and it may change when more values are added or removed.
Requirements:
indexmust be strictly less than length.*
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32);
values
Return the entire set in an array WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
function values(Bytes32Set storage set) internal view returns (bytes32[] memory);
values
Return a slice of the set in an array WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
function values(Bytes32Set storage set, uint256 start, uint256 end) internal view returns (bytes32[] memory);
add
Add a value to a set. O(1). Returns true if the value was added to the set, that is if it was not already present.
function add(AddressSet storage set, address value) internal returns (bool);
remove
Removes a value from a set. O(1). Returns true if the value was removed from the set, that is if it was present.
function remove(AddressSet storage set, address value) internal returns (bool);
clear
Removes all the values from a set. O(n). WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the function uncallable if the set grows to the point where clearing it consumes too much gas to fit in a block.
function clear(AddressSet storage set) internal;
contains
Returns true if the value is in the set. O(1).
function contains(AddressSet storage set, address value) internal view returns (bool);
length
Returns the number of values in the set. O(1).
function length(AddressSet storage set) internal view returns (uint256);
at
*Returns the value stored at position index in the set. O(1).
Note that there are no guarantees on the ordering of values inside the
array, and it may change when more values are added or removed.
Requirements:
indexmust be strictly less than length.*
function at(AddressSet storage set, uint256 index) internal view returns (address);
values
Return the entire set in an array WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
function values(AddressSet storage set) internal view returns (address[] memory);
values
Return a slice of the set in an array WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
function values(AddressSet storage set, uint256 start, uint256 end) internal view returns (address[] memory);
add
Add a value to a set. O(1). Returns true if the value was added to the set, that is if it was not already present.
function add(UintSet storage set, uint256 value) internal returns (bool);
remove
Removes a value from a set. O(1). Returns true if the value was removed from the set, that is if it was present.
function remove(UintSet storage set, uint256 value) internal returns (bool);
clear
Removes all the values from a set. O(n). WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the function uncallable if the set grows to the point where clearing it consumes too much gas to fit in a block.
function clear(UintSet storage set) internal;
contains
Returns true if the value is in the set. O(1).
function contains(UintSet storage set, uint256 value) internal view returns (bool);
length
Returns the number of values in the set. O(1).
function length(UintSet storage set) internal view returns (uint256);
at
*Returns the value stored at position index in the set. O(1).
Note that there are no guarantees on the ordering of values inside the
array, and it may change when more values are added or removed.
Requirements:
indexmust be strictly less than length.*
function at(UintSet storage set, uint256 index) internal view returns (uint256);
values
Return the entire set in an array WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
function values(UintSet storage set) internal view returns (uint256[] memory);
values
Return a slice of the set in an array WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
function values(UintSet storage set, uint256 start, uint256 end) internal view returns (uint256[] memory);
add
Add a value to a set. O(1). Returns true if the value was added to the set, that is if it was not already present.
function add(StringSet storage set, string memory value) internal returns (bool);
remove
Removes a value from a set. O(1). Returns true if the value was removed from the set, that is if it was present.
function remove(StringSet storage set, string memory value) internal returns (bool);
clear
Removes all the values from a set. O(n). WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the function uncallable if the set grows to the point where clearing it consumes too much gas to fit in a block.
function clear(StringSet storage set) internal;
contains
Returns true if the value is in the set. O(1).
function contains(StringSet storage set, string memory value) internal view returns (bool);
length
Returns the number of values on the set. O(1).
function length(StringSet storage set) internal view returns (uint256);
at
*Returns the value stored at position index in the set. O(1).
Note that there are no guarantees on the ordering of values inside the
array, and it may change when more values are added or removed.
Requirements:
indexmust be strictly less than length.*
function at(StringSet storage set, uint256 index) internal view returns (string memory);
values
Return the entire set in an array WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
function values(StringSet storage set) internal view returns (string[] memory);
values
Return a slice of the set in an array WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
function values(StringSet storage set, uint256 start, uint256 end) internal view returns (string[] memory);
add
Add a value to a set. O(1). Returns true if the value was added to the set, that is if it was not already present.
function add(BytesSet storage set, bytes memory value) internal returns (bool);
remove
Removes a value from a set. O(1). Returns true if the value was removed from the set, that is if it was present.
function remove(BytesSet storage set, bytes memory value) internal returns (bool);
clear
Removes all the values from a set. O(n). WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the function uncallable if the set grows to the point where clearing it consumes too much gas to fit in a block.
function clear(BytesSet storage set) internal;
contains
Returns true if the value is in the set. O(1).
function contains(BytesSet storage set, bytes memory value) internal view returns (bool);
length
Returns the number of values on the set. O(1).
function length(BytesSet storage set) internal view returns (uint256);
at
*Returns the value stored at position index in the set. O(1).
Note that there are no guarantees on the ordering of values inside the
array, and it may change when more values are added or removed.
Requirements:
indexmust be strictly less than length.*
function at(BytesSet storage set, uint256 index) internal view returns (bytes memory);
values
Return the entire set in an array WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
function values(BytesSet storage set) internal view returns (bytes[] memory);
values
Return a slice of the set in an array WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that this function has an unbounded cost, and using it as part of a state-changing function may render the function uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
function values(BytesSet storage set, uint256 start, uint256 end) internal view returns (bytes[] memory);
Structs
Set
struct Set {
bytes32[] _values;
mapping(bytes32 value => uint256) _positions;
}
Bytes32Set
struct Bytes32Set {
Set _inner;
}
AddressSet
struct AddressSet {
Set _inner;
}
UintSet
struct UintSet {
Set _inner;
}
StringSet
struct StringSet {
string[] _values;
mapping(string value => uint256) _positions;
}
BytesSet
struct BytesSet {
bytes[] _values;
mapping(bytes value => uint256) _positions;
}
Heap
Library for managing https://en.wikipedia.org/wiki/Binary_heap[binary heap] that can be used as
https://en.wikipedia.org/wiki/Priority_queue[priority queue].
Heaps are represented as a tree of values where the first element (index 0) is the root, and where the node at
index i is the child of the node at index (i-1)/2 and the parent of nodes at index 2i+1 and 2i+2. Each node
stores an element of the heap.
The structure is ordered so that each node is bigger than its parent. An immediate consequence is that the
highest priority value is the one at the root. This value can be looked up in constant time (O(1)) at
heap.tree[0]
The structure is designed to perform the following operations with the corresponding complexities:
peek (get the highest priority value): O(1)
insert (insert a value): O(log(n))
pop (remove the highest priority value): O(log(n))
replace (replace the highest priority value with a new value): O(log(n))
length (get the number of elements): O(1)
clear (remove all elements): O(1)
IMPORTANT: This library allows for the use of custom comparator functions. Given that manipulating
memory can lead to unexpected behavior. Consider verifying that the comparator does not manipulate
the Heap's state directly and that it follows the Solidity memory safety rules.
Available since v5.1.
Functions
peek
Lookup the root element of the heap.
function peek(Uint256Heap storage self) internal view returns (uint256);
pop
Remove (and return) the root element for the heap using the default comparator. NOTE: All inserting and removal from a heap should always be done using the same comparator. Mixing comparator during the lifecycle of a heap will result in undefined behavior.
function pop(Uint256Heap storage self) internal returns (uint256);
pop
Remove (and return) the root element for the heap using the provided comparator. NOTE: All inserting and removal from a heap should always be done using the same comparator. Mixing comparator during the lifecycle of a heap will result in undefined behavior.
function pop(Uint256Heap storage self, function(uint256, uint256) view returns (bool) comp)
internal
returns (uint256);
insert
Insert a new element in the heap using the default comparator. NOTE: All inserting and removal from a heap should always be done using the same comparator. Mixing comparator during the lifecycle of a heap will result in undefined behavior.
function insert(Uint256Heap storage self, uint256 value) internal;
insert
Insert a new element in the heap using the provided comparator. NOTE: All inserting and removal from a heap should always be done using the same comparator. Mixing comparator during the lifecycle of a heap will result in undefined behavior.
function insert(Uint256Heap storage self, uint256 value, function(uint256, uint256) view returns (bool) comp)
internal;
replace
Return the root element for the heap, and replace it with a new value, using the default comparator. This is equivalent to using pop and {insert}, but requires only one rebalancing operation. NOTE: All inserting and removal from a heap should always be done using the same comparator. Mixing comparator during the lifecycle of a heap will result in undefined behavior.
function replace(Uint256Heap storage self, uint256 newValue) internal returns (uint256);
replace
Return the root element for the heap, and replace it with a new value, using the provided comparator. This is equivalent to using pop and {insert}, but requires only one rebalancing operation. NOTE: All inserting and removal from a heap should always be done using the same comparator. Mixing comparator during the lifecycle of a heap will result in undefined behavior.
function replace(Uint256Heap storage self, uint256 newValue, function(uint256, uint256) view returns (bool) comp)
internal
returns (uint256);
length
Returns the number of elements in the heap.
function length(Uint256Heap storage self) internal view returns (uint256);
clear
Removes all elements in the heap.
function clear(Uint256Heap storage self) internal;
_swap
Swap node i and j in the tree.
function _swap(Uint256Heap storage self, uint256 i, uint256 j) private;
_siftDown
Perform heap maintenance on self, starting at index (with the value), using comp as a
comparator, and moving toward the leaves of the underlying tree.
NOTE: This is a private function that is called in a trusted context with already cached parameters. size
and value could be extracted from self and index, but that would require redundant storage read. These
parameters are not verified. It is the caller role to make sure the parameters are correct.
function _siftDown(
Uint256Heap storage self,
uint256 size,
uint256 index,
uint256 value,
function(uint256, uint256) view returns (bool) comp
) private;
_siftUp
Perform heap maintenance on self, starting at index (with the value), using comp as a
comparator, and moving toward the root of the underlying tree.
NOTE: This is a private function that is called in a trusted context with already cached parameters. value
could be extracted from self and index, but that would require redundant storage read. These parameters are not
verified. It is the caller role to make sure the parameters are correct.
function _siftUp(
Uint256Heap storage self,
uint256 index,
uint256 value,
function(uint256, uint256) view returns (bool) comp
) private;
Structs
Uint256Heap
Binary heap that supports values of type uint256. Each element of that structure uses one storage slot.
struct Uint256Heap {
uint256[] tree;
}
MerkleTree
Library for managing https://wikipedia.org/wiki/Merkle_Tree[Merkle Tree] data structures.
Each tree is a complete binary tree with the ability to sequentially insert leaves, changing them from a zero to a
non-zero value and updating its root. This structure allows inserting commitments (or other entries) that are not
stored, but can be proven to be part of the tree at a later time if the root is kept. See {MerkleProof}.
A tree is defined by the following parameters:
Depth: The number of levels in the tree, it also defines the maximum number of leaves as 2**depth.
Zero value: The value that represents an empty leaf. Used to avoid regular zero values to be part of the tree.
Hashing function: A cryptographic hash function used to produce internal nodes. Defaults to {Hashes-commutativeKeccak256}.
NOTE: Building trees using non-commutative hashing functions (i.e. H(a, b) != H(b, a)) is supported. However,
proving the inclusion of a leaf in such trees is not possible with the {MerkleProof} library since it only supports
commutative hashing functions.
Available since v5.1.
Functions
setup
Initialize a Bytes32PushTree using {Hashes-commutativeKeccak256} to hash internal nodes.
The capacity of the tree (i.e. number of leaves) is set to 2**treeDepth.
Calling this function on MerkleTree that was already setup and used will reset it to a blank state.
Once a tree is setup, any push to it must use the same hashing function. This means that values
should be pushed to it using the default {xref-MerkleTree-push-struct-MerkleTree-Bytes32PushTree-bytes32-}[push] function.
IMPORTANT: The zero value should be carefully chosen since it will be stored in the tree representing
empty leaves. It should be a value that is not expected to be part of the tree.
function setup(Bytes32PushTree storage self, uint8 treeDepth, bytes32 zero) internal returns (bytes32 initialRoot);
setup
Same as setup, but allows to specify a custom hashing function. Once a tree is setup, any push to it must use the same hashing function. This means that values should be pushed to it using the custom push function, which should be the same one as used during the setup. IMPORTANT: Providing a custom hashing function is a security-sensitive operation since it may compromise the soundness of the tree. NOTE: Consider verifying that the hashing function does not manipulate the memory state directly and that it follows the Solidity memory safety rules. Otherwise, it may lead to unexpected behavior.
function setup(
Bytes32PushTree storage self,
uint8 treeDepth,
bytes32 zero,
function(bytes32, bytes32) view returns (bytes32) fnHash
) internal returns (bytes32 initialRoot);
push
Insert a new leaf in the tree, and compute the new root. Returns the position of the inserted leaf in the tree, and the resulting root. Hashing the leaf before calling this function is recommended as a protection against second pre-image attacks. This variant uses {Hashes-commutativeKeccak256} to hash internal nodes. It should only be used on merkle trees that were setup using the same (default) hashing function (i.e. by calling {xref-MerkleTree-setup-struct-MerkleTree-Bytes32PushTree-uint8-bytes32-}[the default setup] function).
function push(Bytes32PushTree storage self, bytes32 leaf) internal returns (uint256 index, bytes32 newRoot);
push
Insert a new leaf in the tree, and compute the new root. Returns the position of the inserted leaf in the tree, and the resulting root. Hashing the leaf before calling this function is recommended as a protection against second pre-image attacks. This variant uses a custom hashing function to hash internal nodes. It should only be called with the same function as the one used during the initial setup of the merkle tree.
function push(Bytes32PushTree storage self, bytes32 leaf, function(bytes32, bytes32) view returns (bytes32) fnHash)
internal
returns (uint256 index, bytes32 newRoot);
update
Change the value of the leaf at position index from oldValue to newValue. Returns the recomputed "old"
root (before the update) and "new" root (after the update). The caller must verify that the reconstructed old
root is the last known one.
The proof must be an up-to-date inclusion proof for the leaf being updated. This means that this function is
vulnerable to front-running. Any push or {update} operation (that changes the root of the tree) would render
all "in flight" updates invalid.
This variant uses {Hashes-commutativeKeccak256} to hash internal nodes. It should only be used on merkle trees
that were setup using the same (default) hashing function (i.e. by calling
{xref-MerkleTree-setup-struct-MerkleTree-Bytes32PushTree-uint8-bytes32-}[the default setup] function).
function update(Bytes32PushTree storage self, uint256 index, bytes32 oldValue, bytes32 newValue, bytes32[] memory proof)
internal
returns (bytes32 oldRoot, bytes32 newRoot);
update
Change the value of the leaf at position index from oldValue to newValue. Returns the recomputed "old"
root (before the update) and "new" root (after the update). The caller must verify that the reconstructed old
root is the last known one.
The proof must be an up-to-date inclusion proof for the leaf being update. This means that this function is
vulnerable to front-running. Any push or {update} operation (that changes the root of the tree) would render
all "in flight" updates invalid.
This variant uses a custom hashing function to hash internal nodes. It should only be called with the same
function as the one used during the initial setup of the merkle tree.
function update(
Bytes32PushTree storage self,
uint256 index,
bytes32 oldValue,
bytes32 newValue,
bytes32[] memory proof,
function(bytes32, bytes32) view returns (bytes32) fnHash
) internal returns (bytes32 oldRoot, bytes32 newRoot);
depth
Tree's depth (set at initialization)
function depth(Bytes32PushTree storage self) internal view returns (uint256);
Errors
MerkleTreeUpdateInvalidIndex
Error emitted when trying to update a leaf that was not previously pushed.
error MerkleTreeUpdateInvalidIndex(uint256 index, uint256 length);
MerkleTreeUpdateInvalidProof
Error emitted when the proof used during an update is invalid (could not reproduce the side).
error MerkleTreeUpdateInvalidProof();
Structs
Bytes32PushTree
A complete bytes32 Merkle tree.
The sides and zero arrays are set to have a length equal to the depth of the tree during setup.
Struct members have an underscore prefix indicating that they are "private" and should not be read or written to
directly. Use the functions provided below instead. Modifying the struct manually may violate assumptions and
lead to unexpected behavior.
NOTE: The root and the updates history is not stored within the tree. Consider using a secondary structure to
store a list of historical roots from the values returned from setup and {push} (e.g. a mapping, {BitMaps} or
{Checkpoints}).
WARNING: Updating any of the tree's parameters after the first insertion will result in a corrupted tree.
struct Bytes32PushTree {
uint256 _nextLeafIndex;
bytes32[] _sides;
bytes32[] _zeros;
}
Contents
Time
*This library provides helpers for manipulating time-related objects. It uses the following types:
uint48for timepointsuint32for durations While the library doesn't provide specific types for timepoints and duration, it does provide:- a
Delaytype to represent duration that can be programmed to change value automatically at a given point - additional helper functions*
Functions
timestamp
Get the block timestamp as a Timepoint.
function timestamp() internal view returns (uint48);
blockNumber
Get the block number as a Timepoint.
function blockNumber() internal view returns (uint48);
toDelay
Wrap a duration into a Delay to add the one-step "update in the future" feature
function toDelay(uint32 duration) internal pure returns (Delay);
_getFullAt
Get the value at a given timepoint plus the pending value and effect timepoint if there is a scheduled change after this timepoint. If the effect timepoint is 0, then the pending value should not be considered.
function _getFullAt(Delay self, uint48 timepoint)
private
pure
returns (uint32 valueBefore, uint32 valueAfter, uint48 effect);
getFull
Get the current value plus the pending value and effect timepoint if there is a scheduled change. If the effect timepoint is 0, then the pending value should not be considered.
function getFull(Delay self) internal view returns (uint32 valueBefore, uint32 valueAfter, uint48 effect);
get
Get the current value.
function get(Delay self) internal view returns (uint32);
withUpdate
Update a Delay object so that it takes a new duration after a timepoint that is automatically computed to enforce the old delay at the moment of the update. Returns the updated Delay object and the timestamp when the new delay becomes effective.
function withUpdate(Delay self, uint32 newValue, uint32 minSetback)
internal
view
returns (Delay updatedDelay, uint48 effect);
unpack
Split a delay into its components: valueBefore, valueAfter and effect (transition timepoint).
function unpack(Delay self) internal pure returns (uint32 valueBefore, uint32 valueAfter, uint48 effect);
pack
pack the components into a Delay object.
function pack(uint32 valueBefore, uint32 valueAfter, uint48 effect) internal pure returns (Delay);
Address
Collection of functions related to the address type
Functions
sendValue
Replacement for Solidity's transfer: sends amount wei to
recipient, forwarding all available gas and reverting on errors.
https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
of certain opcodes, possibly making contracts go over the 2300 gas limit
imposed by transfer, making them unable to receive funds via
transfer. sendValue removes this limitation.
https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
IMPORTANT: because control is transferred to recipient, care must be
taken to not create reentrancy vulnerabilities. Consider using
{ReentrancyGuard} or the
https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
function sendValue(address payable recipient, uint256 amount) internal;
functionCall
*Performs a Solidity function call using a low level call. A
plain call is an unsafe replacement for a function call: use this
function instead.
If target reverts with a revert reason or custom error, it is bubbled
up by this function (like regular Solidity function calls). However, if
the call reverted with no returned reason, this function reverts with a
{Errors.FailedCall} error.
Returns the raw returned data. To convert to the expected return value,
use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[abi.decode].
Requirements:
targetmust be a contract.- calling
targetwithdatamust not revert.*
function functionCall(address target, bytes memory data) internal returns (bytes memory);
functionCallWithValue
*Same as functionCall,
but also transferring value wei to target.
Requirements:
- the calling contract must have an ETH balance of at least
value. - the called Solidity function must be
payable.*
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory);
functionStaticCall
Same as functionCall,
but performing a static call.
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory);
functionDelegateCall
Same as functionCall,
but performing a delegate call.
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory);
verifyCallResultFromTarget
Tool to verify that a low level call to smart-contract was successful, and reverts if the target was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case of an unsuccessful call.
function verifyCallResultFromTarget(address target, bool success, bytes memory returndata)
internal
view
returns (bytes memory);
verifyCallResult
Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the revert reason or with a default {Errors.FailedCall} error.
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory);
_revert
Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.
function _revert(bytes memory returndata) private pure;
Errors
AddressEmptyCode
There's no code at target (it is not a contract).
error AddressEmptyCode(address target);
Arrays
Collection of functions related to array types.
Functions
sort
Sort an array of uint256 (in memory) following the provided comparator function.
This function does the sorting "in place", meaning that it overrides the input. The object is returned for
convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array.
NOTE: this function's cost is O(n · log(n)) in average and O(n²) in the worst case, with n the length of the
array. Using it in view functions that are executed through eth_call is safe, but one should be very careful
when executing this as part of a transaction. If the array being sorted is too large, the sort operation may
consume more gas than is available in a block, leading to potential DoS.
IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way.
function sort(uint256[] memory array, function(uint256, uint256) pure returns (bool) comp)
internal
pure
returns (uint256[] memory);
sort
Variant of sort that sorts an array of uint256 in increasing order.
function sort(uint256[] memory array) internal pure returns (uint256[] memory);
sort
Sort an array of address (in memory) following the provided comparator function.
This function does the sorting "in place", meaning that it overrides the input. The object is returned for
convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array.
NOTE: this function's cost is O(n · log(n)) in average and O(n²) in the worst case, with n the length of the
array. Using it in view functions that are executed through eth_call is safe, but one should be very careful
when executing this as part of a transaction. If the array being sorted is too large, the sort operation may
consume more gas than is available in a block, leading to potential DoS.
IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way.
function sort(address[] memory array, function(address, address) pure returns (bool) comp)
internal
pure
returns (address[] memory);
sort
Variant of sort that sorts an array of address in increasing order.
function sort(address[] memory array) internal pure returns (address[] memory);
sort
Sort an array of bytes32 (in memory) following the provided comparator function.
This function does the sorting "in place", meaning that it overrides the input. The object is returned for
convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array.
NOTE: this function's cost is O(n · log(n)) in average and O(n²) in the worst case, with n the length of the
array. Using it in view functions that are executed through eth_call is safe, but one should be very careful
when executing this as part of a transaction. If the array being sorted is too large, the sort operation may
consume more gas than is available in a block, leading to potential DoS.
IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way.
function sort(bytes32[] memory array, function(bytes32, bytes32) pure returns (bool) comp)
internal
pure
returns (bytes32[] memory);
sort
Variant of sort that sorts an array of bytes32 in increasing order.
function sort(bytes32[] memory array) internal pure returns (bytes32[] memory);
_quickSort
Performs a quick sort of a segment of memory. The segment sorted starts at begin (inclusive), and stops
at end (exclusive). Sorting follows the comp comparator.
Invariant: begin <= end. This is the case when initially called by sort and is preserved in subcalls.
IMPORTANT: Memory locations between begin and end are not validated/zeroed. This function should
be used only if the limits are within a memory array.
function _quickSort(uint256 begin, uint256 end, function(uint256, uint256) pure returns (bool) comp) private pure;
_begin
Pointer to the memory location of the first element of array.
function _begin(uint256[] memory array) private pure returns (uint256 ptr);
_end
Pointer to the memory location of the first memory word (32bytes) after array. This is the memory word
that comes just after the last element of the array.
function _end(uint256[] memory array) private pure returns (uint256 ptr);
_mload
Load memory word (as a uint256) at location ptr.
function _mload(uint256 ptr) private pure returns (uint256 value);
_swap
Swaps the elements memory location ptr1 and ptr2.
function _swap(uint256 ptr1, uint256 ptr2) private pure;
_castToUint256Array
Helper: low level cast address memory array to uint256 memory array
function _castToUint256Array(address[] memory input) private pure returns (uint256[] memory output);
_castToUint256Array
Helper: low level cast bytes32 memory array to uint256 memory array
function _castToUint256Array(bytes32[] memory input) private pure returns (uint256[] memory output);
_castToUint256Comp
Helper: low level cast address comp function to uint256 comp function
function _castToUint256Comp(function(address, address) pure returns (bool) input)
private
pure
returns (function(uint256, uint256) pure returns (bool) output);
_castToUint256Comp
Helper: low level cast bytes32 comp function to uint256 comp function
function _castToUint256Comp(function(bytes32, bytes32) pure returns (bool) input)
private
pure
returns (function(uint256, uint256) pure returns (bool) output);
findUpperBound
Searches a sorted array and returns the first index that contains
a value greater or equal to element. If no such index exists (i.e. all
values in the array are strictly less than element), the array length is
returned. Time complexity O(log n).
NOTE: The array is expected to be sorted in ascending order, and to
contain no repeated elements.
IMPORTANT: Deprecated. This implementation behaves as lowerBound but lacks
support for repeated elements in the array. The {lowerBound} function should
be used instead.
function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256);
lowerBound
Searches an array sorted in ascending order and returns the first
index that contains a value greater or equal than element. If no such index
exists (i.e. all values in the array are strictly less than element), the array
length is returned. Time complexity O(log n).
See C++'s https://en.cppreference.com/w/cpp/algorithm/lower_bound[lower_bound].
function lowerBound(uint256[] storage array, uint256 element) internal view returns (uint256);
upperBound
Searches an array sorted in ascending order and returns the first
index that contains a value strictly greater than element. If no such index
exists (i.e. all values in the array are strictly less than element), the array
length is returned. Time complexity O(log n).
See C++'s https://en.cppreference.com/w/cpp/algorithm/upper_bound[upper_bound].
function upperBound(uint256[] storage array, uint256 element) internal view returns (uint256);
lowerBoundMemory
Same as lowerBound, but with an array in memory.
function lowerBoundMemory(uint256[] memory array, uint256 element) internal pure returns (uint256);
upperBoundMemory
Same as upperBound, but with an array in memory.
function upperBoundMemory(uint256[] memory array, uint256 element) internal pure returns (uint256);
unsafeAccess
Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
WARNING: Only use if you are certain pos is lower than the array length.
function unsafeAccess(address[] storage arr, uint256 pos) internal pure returns (StorageSlot.AddressSlot storage);
unsafeAccess
Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
WARNING: Only use if you are certain pos is lower than the array length.
function unsafeAccess(bytes32[] storage arr, uint256 pos) internal pure returns (StorageSlot.Bytes32Slot storage);
unsafeAccess
Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
WARNING: Only use if you are certain pos is lower than the array length.
function unsafeAccess(uint256[] storage arr, uint256 pos) internal pure returns (StorageSlot.Uint256Slot storage);
unsafeAccess
Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
WARNING: Only use if you are certain pos is lower than the array length.
function unsafeAccess(bytes[] storage arr, uint256 pos) internal pure returns (StorageSlot.BytesSlot storage);
unsafeAccess
Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
WARNING: Only use if you are certain pos is lower than the array length.
function unsafeAccess(string[] storage arr, uint256 pos) internal pure returns (StorageSlot.StringSlot storage);
unsafeMemoryAccess
Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
WARNING: Only use if you are certain pos is lower than the array length.
function unsafeMemoryAccess(address[] memory arr, uint256 pos) internal pure returns (address res);
unsafeMemoryAccess
Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
WARNING: Only use if you are certain pos is lower than the array length.
function unsafeMemoryAccess(bytes32[] memory arr, uint256 pos) internal pure returns (bytes32 res);
unsafeMemoryAccess
Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
WARNING: Only use if you are certain pos is lower than the array length.
function unsafeMemoryAccess(uint256[] memory arr, uint256 pos) internal pure returns (uint256 res);
unsafeMemoryAccess
Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
WARNING: Only use if you are certain pos is lower than the array length.
function unsafeMemoryAccess(bytes[] memory arr, uint256 pos) internal pure returns (bytes memory res);
unsafeMemoryAccess
Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
WARNING: Only use if you are certain pos is lower than the array length.
function unsafeMemoryAccess(string[] memory arr, uint256 pos) internal pure returns (string memory res);
unsafeSetLength
Helper to set the length of a dynamic array. Directly writing to .length is forbidden.
WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.
function unsafeSetLength(address[] storage array, uint256 len) internal;
unsafeSetLength
Helper to set the length of a dynamic array. Directly writing to .length is forbidden.
WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.
function unsafeSetLength(bytes32[] storage array, uint256 len) internal;
unsafeSetLength
Helper to set the length of a dynamic array. Directly writing to .length is forbidden.
WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.
function unsafeSetLength(uint256[] storage array, uint256 len) internal;
unsafeSetLength
Helper to set the length of a dynamic array. Directly writing to .length is forbidden.
WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.
function unsafeSetLength(bytes[] storage array, uint256 len) internal;
unsafeSetLength
Helper to set the length of a dynamic array. Directly writing to .length is forbidden.
WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.
function unsafeSetLength(string[] storage array, uint256 len) internal;
Base64
Provides a set of functions to operate with Base64 strings.
State Variables
_TABLE
Base64 Encoding/Decoding Table See sections 4 and 5 of https://datatracker.ietf.org/doc/html/rfc4648
string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
_TABLE_URL
string internal constant _TABLE_URL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
Functions
encode
Converts a bytes to its Bytes64 string representation.
function encode(bytes memory data) internal pure returns (string memory);
encodeURL
Converts a bytes to its Bytes64Url string representation.
Output is not padded with = as specified in https://www.rfc-editor.org/rfc/rfc4648[rfc4648].
function encodeURL(bytes memory data) internal pure returns (string memory);
_encode
Internal table-agnostic conversion
function _encode(bytes memory data, string memory table, bool withPadding) private pure returns (string memory);
Blockhash
Library for accessing historical block hashes beyond the standard 256 block limit.
Uses EIP-2935's history storage contract which maintains a ring buffer of the last
8191 block hashes in state.
For blocks within the last 256 blocks, it uses the native BLOCKHASH opcode.
For blocks between 257 and 8191 blocks ago, it queries the EIP-2935 history storage.
For blocks older than 8191 or future blocks, it returns zero, matching the BLOCKHASH behavior.
NOTE: After EIP-2935 activation, it takes 8191 blocks to completely fill the history.
Before that, only block hashes since the fork block will be available.
State Variables
HISTORY_STORAGE_ADDRESS
Address of the EIP-2935 history storage contract.
address internal constant HISTORY_STORAGE_ADDRESS = 0x0000F90827F1C53a10cb7A02335B175320002935;
Functions
blockHash
Retrieves the block hash for any historical block within the supported range.
NOTE: The function gracefully handles future blocks and blocks beyond the history window
by returning zero, consistent with the EVM's native BLOCKHASH behavior.
function blockHash(uint256 blockNumber) internal view returns (bytes32);
_historyStorageCall
Internal function to query the EIP-2935 history storage contract.
function _historyStorageCall(uint256 blockNumber) private view returns (bytes32 hash);
Bytes
Bytes operations.
Functions
indexOf
Forward search for s in buffer
If s is present in the buffer, returns the index of the first instance
If s is not present in the buffer, returns type(uint256).max
NOTE: replicates the behavior of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf[Javascript's Array.indexOf]
function indexOf(bytes memory buffer, bytes1 s) internal pure returns (uint256);
indexOf
Forward search for s in buffer starting at position pos
If s is present in the buffer (at or after pos), returns the index of the next instance
If s is not present in the buffer (at or after pos), returns type(uint256).max
NOTE: replicates the behavior of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf[Javascript's Array.indexOf]
function indexOf(bytes memory buffer, bytes1 s, uint256 pos) internal pure returns (uint256);
lastIndexOf
Backward search for s in buffer
If s is present in the buffer, returns the index of the last instance
If s is not present in the buffer, returns type(uint256).max
NOTE: replicates the behavior of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf[Javascript's Array.lastIndexOf]
function lastIndexOf(bytes memory buffer, bytes1 s) internal pure returns (uint256);
lastIndexOf
Backward search for s in buffer starting at position pos
If s is present in the buffer (at or before pos), returns the index of the previous instance
If s is not present in the buffer (at or before pos), returns type(uint256).max
NOTE: replicates the behavior of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf[Javascript's Array.lastIndexOf]
function lastIndexOf(bytes memory buffer, bytes1 s, uint256 pos) internal pure returns (uint256);
slice
Copies the content of buffer, from start (included) to the end of buffer into a new bytes object in
memory.
NOTE: replicates the behavior of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice[Javascript's Array.slice]
function slice(bytes memory buffer, uint256 start) internal pure returns (bytes memory);
slice
Copies the content of buffer, from start (included) to end (excluded) into a new bytes object in
memory.
NOTE: replicates the behavior of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice[Javascript's Array.slice]
function slice(bytes memory buffer, uint256 start, uint256 end) internal pure returns (bytes memory);
_unsafeReadBytesOffset
Reads a bytes32 from a bytes array without bounds checking. NOTE: making this function internal would mean it could be used with memory unsafe offset, and marking the assembly block as such would prevent some optimizations.
function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value);
CAIP10
Helper library to format and parse CAIP-10 identifiers https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md[CAIP-10] defines account identifiers as: account_id: chain_id + ":" + account_address chain_id: [-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32} (See {CAIP2}) account_address: [-.%a-zA-Z0-9]{1,128} WARNING: According to CAIP-10's canonicalization section, the implementation remains at the developer's discretion. Please note that case variations may introduce ambiguity. For example, when building hashes to identify accounts or data associated to them, multiple representations of the same account would derive to different hashes. For EVM chains, we recommend using checksummed addresses for the "account_address" part. They can be generated onchain using {Strings-toChecksumHexString}.
Functions
local
Return the CAIP-10 identifier for an account on the current (local) chain.
function local(address account) internal view returns (string memory);
format
Return the CAIP-10 identifier for a given caip2 chain and account. NOTE: This function does not verify that the inputs are properly formatted.
function format(string memory caip2, string memory account) internal pure returns (string memory);
parse
Parse a CAIP-10 identifier into its components.
NOTE: This function does not verify that the CAIP-10 input is properly formatted. The caip2 return can be
parsed using the {CAIP2} library.
function parse(string memory caip10) internal pure returns (string memory caip2, string memory account);
CAIP2
Helper library to format and parse CAIP-2 identifiers
https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-2.md[CAIP-2] defines chain identifiers as:
chain_id: namespace + ":" + reference
namespace: [-a-z0-9]{3,8}
reference: [-_a-zA-Z0-9]{1,32}
WARNING: In some cases, multiple CAIP-2 identifiers may all be valid representation of a single chain.
For EVM chains, it is recommended to use eip155:xxx as the canonical representation (where xxx is
the EIP-155 chain id). Consider the possible ambiguity when processing CAIP-2 identifiers or when using them
in the context of hashes.
Functions
local
Return the CAIP-2 identifier for the current (local) chain.
function local() internal view returns (string memory);
format
Return the CAIP-2 identifier for a given namespace and reference. NOTE: This function does not verify that the inputs are properly formatted.
function format(string memory namespace, string memory ref) internal pure returns (string memory);
parse
Parse a CAIP-2 identifier into its components. NOTE: This function does not verify that the CAIP-2 input is properly formatted.
function parse(string memory caip2) internal pure returns (string memory namespace, string memory ref);
Calldata
Helper library for manipulating objects in calldata.
Functions
emptyBytes
function emptyBytes() internal pure returns (bytes calldata result);
emptyString
function emptyString() internal pure returns (string calldata result);
Comparators
Provides a set of functions to compare values. Available since v5.1.
Functions
lt
function lt(uint256 a, uint256 b) internal pure returns (bool);
gt
function gt(uint256 a, uint256 b) internal pure returns (bool);
Context
Provides information about the current execution context, including the sender of the transaction and its data. While these are generally available via msg.sender and msg.data, they should not be accessed in such a direct manner, since when dealing with meta-transactions the account sending and paying for execution may not be the actual sender (as far as an application is concerned). This contract is only required for intermediate, library-like contracts.
Functions
_msgSender
function _msgSender() internal view virtual returns (address);
_msgData
function _msgData() internal view virtual returns (bytes calldata);
_contextSuffixLength
function _contextSuffixLength() internal view virtual returns (uint256);
Create2
Helper to make usage of the CREATE2 EVM opcode easier and safer.
CREATE2 can be used to compute in advance the address where a smart
contract will be deployed, which allows for interesting new mechanisms known
as 'counterfactual interactions'.
See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more
information.
Functions
deploy
*Deploys a contract using CREATE2. The address where the contract
will be deployed can be known in advance via computeAddress.
The bytecode for a contract can be obtained from Solidity with
type(contractName).creationCode.
Requirements:
bytecodemust not be empty.saltmust have not been used forbytecodealready.- the factory must have a balance of at least
amount. - if
amountis non-zero,bytecodemust have apayableconstructor.*
function deploy(uint256 amount, bytes32 salt, bytes memory bytecode) internal returns (address addr);
computeAddress
Returns the address where a contract will be stored if deployed via deploy. Any change in the
bytecodeHash or salt will result in a new destination address.
function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address);
computeAddress
Returns the address where a contract will be stored if deployed via deploy from a contract located at
deployer. If deployer is this contract's address, returns the same value as {computeAddress}.
function computeAddress(bytes32 salt, bytes32 bytecodeHash, address deployer) internal pure returns (address addr);
Errors
Create2EmptyBytecode
There's no code to deploy.
error Create2EmptyBytecode();
Errors
Collection of common custom errors used in multiple contracts IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library. It is recommended to avoid relying on the error API for critical functionality. Available since v5.1.
Errors
InsufficientBalance
The ETH balance of the account is not enough to perform the operation.
error InsufficientBalance(uint256 balance, uint256 needed);
FailedCall
A call to an address target failed. The target may have reverted.
error FailedCall();
FailedDeployment
The deployment failed.
error FailedDeployment();
MissingPrecompile
A necessary precompile is missing.
error MissingPrecompile(address);
Multicall
Inherits: Context
Provides a function to batch together multiple calls in a single external call.
Consider any assumption about calldata validation performed by the sender may be violated if it's not especially
careful about sending transactions invoking multicall. For example, a relay address that filters function
selectors won't filter calls nested within a {multicall} operation.
NOTE: Since 5.0.1 and 4.9.4, this contract identifies non-canonical contexts (i.e. msg.sender is not {Context-_msgSender}).
If a non-canonical context is identified, the following self delegatecall appends the last bytes of msg.data
to the subcall. This makes it safe to use with {ERC2771Context}. Contexts that don't affect the resolution of
{Context-_msgSender} are not propagated to subcalls.
Functions
multicall
Receives and executes a batch of function calls on this contract.
Note: oz-upgrades-unsafe-allow-reachable: delegatecall
function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results);
Nonces
Provides tracking nonces for addresses. Nonces will only increment.
State Variables
_nonces
mapping(address account => uint256) private _nonces;
Functions
nonces
Returns the next unused nonce for an address.
function nonces(address owner) public view virtual returns (uint256);
_useNonce
Consumes a nonce. Returns the current value and increments nonce.
function _useNonce(address owner) internal virtual returns (uint256);
_useCheckedNonce
Same as _useNonce but checking that nonce is the next valid for owner.
function _useCheckedNonce(address owner, uint256 nonce) internal virtual;
Errors
InvalidAccountNonce
The nonce used for an account is not the expected current nonce.
error InvalidAccountNonce(address account, uint256 currentNonce);
NoncesKeyed
Inherits: Nonces
Alternative to {Nonces}, that supports key-ed nonces.
Follows the https://eips.ethereum.org/EIPS/eip-4337#semi-abstracted-nonce-support[ERC-4337's semi-abstracted nonce system].
NOTE: This contract inherits from {Nonces} and reuses its storage for the first nonce key (i.e. 0). This
makes upgrading from {Nonces} to {NoncesKeyed} safe when using their upgradeable versions (e.g. NoncesKeyedUpgradeable).
Doing so will NOT reset the current state of nonces, avoiding replay attacks where a nonce is reused after the upgrade.
State Variables
_nonces
mapping(address owner => mapping(uint192 key => uint64)) private _nonces;
Functions
nonces
Returns the next unused nonce for an address and key. Result contains the key prefix.
function nonces(address owner, uint192 key) public view virtual returns (uint256);
_useNonce
Consumes the next unused nonce for an address and key. Returns the current value without the key prefix. Consumed nonce is increased, so calling this function twice with the same arguments will return different (sequential) results.
function _useNonce(address owner, uint192 key) internal virtual returns (uint256);
_useCheckedNonce
*Same as _useNonce but checking that nonce is the next valid for owner.
This version takes the key and the nonce in a single uint256 parameter:
- use the first 24 bytes for the key
- use the last 8 bytes for the nonce*
function _useCheckedNonce(address owner, uint256 keyNonce) internal virtual override;
_useCheckedNonce
Same as _useNonce but checking that nonce is the next valid for owner.
This version takes the key and the nonce as two different parameters.
function _useCheckedNonce(address owner, uint192 key, uint64 nonce) internal virtual;
_pack
Pack key and nonce into a keyNonce
function _pack(uint192 key, uint64 nonce) private pure returns (uint256);
_unpack
Unpack a keyNonce into its key and nonce components
function _unpack(uint256 keyNonce) private pure returns (uint192 key, uint64 nonce);
Packing
*Helper library packing and unpacking multiple values into bytesXX. Example usage:
library MyPacker {
type MyType is bytes32;
function _pack(address account, bytes4 selector, uint64 period) external pure returns (MyType) {
bytes12 subpack = Packing.pack_4_8(selector, bytes8(period));
bytes32 pack = Packing.pack_20_12(bytes20(account), subpack);
return MyType.wrap(pack);
}
function _unpack(MyType self) external pure returns (address, bytes4, uint64) {
bytes32 pack = MyType.unwrap(self);
return (
address(Packing.extract_32_20(pack, 0)),
Packing.extract_32_4(pack, 20),
uint64(Packing.extract_32_8(pack, 24))
);
}
}
Available since v5.1.*
Functions
pack_1_1
function pack_1_1(bytes1 left, bytes1 right) internal pure returns (bytes2 result);
pack_2_2
function pack_2_2(bytes2 left, bytes2 right) internal pure returns (bytes4 result);
pack_2_4
function pack_2_4(bytes2 left, bytes4 right) internal pure returns (bytes6 result);
pack_2_6
function pack_2_6(bytes2 left, bytes6 right) internal pure returns (bytes8 result);
pack_2_8
function pack_2_8(bytes2 left, bytes8 right) internal pure returns (bytes10 result);
pack_2_10
function pack_2_10(bytes2 left, bytes10 right) internal pure returns (bytes12 result);
pack_2_20
function pack_2_20(bytes2 left, bytes20 right) internal pure returns (bytes22 result);
pack_2_22
function pack_2_22(bytes2 left, bytes22 right) internal pure returns (bytes24 result);
pack_4_2
function pack_4_2(bytes4 left, bytes2 right) internal pure returns (bytes6 result);
pack_4_4
function pack_4_4(bytes4 left, bytes4 right) internal pure returns (bytes8 result);
pack_4_6
function pack_4_6(bytes4 left, bytes6 right) internal pure returns (bytes10 result);
pack_4_8
function pack_4_8(bytes4 left, bytes8 right) internal pure returns (bytes12 result);
pack_4_12
function pack_4_12(bytes4 left, bytes12 right) internal pure returns (bytes16 result);
pack_4_16
function pack_4_16(bytes4 left, bytes16 right) internal pure returns (bytes20 result);
pack_4_20
function pack_4_20(bytes4 left, bytes20 right) internal pure returns (bytes24 result);
pack_4_24
function pack_4_24(bytes4 left, bytes24 right) internal pure returns (bytes28 result);
pack_4_28
function pack_4_28(bytes4 left, bytes28 right) internal pure returns (bytes32 result);
pack_6_2
function pack_6_2(bytes6 left, bytes2 right) internal pure returns (bytes8 result);
pack_6_4
function pack_6_4(bytes6 left, bytes4 right) internal pure returns (bytes10 result);
pack_6_6
function pack_6_6(bytes6 left, bytes6 right) internal pure returns (bytes12 result);
pack_6_10
function pack_6_10(bytes6 left, bytes10 right) internal pure returns (bytes16 result);
pack_6_16
function pack_6_16(bytes6 left, bytes16 right) internal pure returns (bytes22 result);
pack_6_22
function pack_6_22(bytes6 left, bytes22 right) internal pure returns (bytes28 result);
pack_8_2
function pack_8_2(bytes8 left, bytes2 right) internal pure returns (bytes10 result);
pack_8_4
function pack_8_4(bytes8 left, bytes4 right) internal pure returns (bytes12 result);
pack_8_8
function pack_8_8(bytes8 left, bytes8 right) internal pure returns (bytes16 result);
pack_8_12
function pack_8_12(bytes8 left, bytes12 right) internal pure returns (bytes20 result);
pack_8_16
function pack_8_16(bytes8 left, bytes16 right) internal pure returns (bytes24 result);
pack_8_20
function pack_8_20(bytes8 left, bytes20 right) internal pure returns (bytes28 result);
pack_8_24
function pack_8_24(bytes8 left, bytes24 right) internal pure returns (bytes32 result);
pack_10_2
function pack_10_2(bytes10 left, bytes2 right) internal pure returns (bytes12 result);
pack_10_6
function pack_10_6(bytes10 left, bytes6 right) internal pure returns (bytes16 result);
pack_10_10
function pack_10_10(bytes10 left, bytes10 right) internal pure returns (bytes20 result);
pack_10_12
function pack_10_12(bytes10 left, bytes12 right) internal pure returns (bytes22 result);
pack_10_22
function pack_10_22(bytes10 left, bytes22 right) internal pure returns (bytes32 result);
pack_12_4
function pack_12_4(bytes12 left, bytes4 right) internal pure returns (bytes16 result);
pack_12_8
function pack_12_8(bytes12 left, bytes8 right) internal pure returns (bytes20 result);
pack_12_10
function pack_12_10(bytes12 left, bytes10 right) internal pure returns (bytes22 result);
pack_12_12
function pack_12_12(bytes12 left, bytes12 right) internal pure returns (bytes24 result);
pack_12_16
function pack_12_16(bytes12 left, bytes16 right) internal pure returns (bytes28 result);
pack_12_20
function pack_12_20(bytes12 left, bytes20 right) internal pure returns (bytes32 result);
pack_16_4
function pack_16_4(bytes16 left, bytes4 right) internal pure returns (bytes20 result);
pack_16_6
function pack_16_6(bytes16 left, bytes6 right) internal pure returns (bytes22 result);
pack_16_8
function pack_16_8(bytes16 left, bytes8 right) internal pure returns (bytes24 result);
pack_16_12
function pack_16_12(bytes16 left, bytes12 right) internal pure returns (bytes28 result);
pack_16_16
function pack_16_16(bytes16 left, bytes16 right) internal pure returns (bytes32 result);
pack_20_2
function pack_20_2(bytes20 left, bytes2 right) internal pure returns (bytes22 result);
pack_20_4
function pack_20_4(bytes20 left, bytes4 right) internal pure returns (bytes24 result);
pack_20_8
function pack_20_8(bytes20 left, bytes8 right) internal pure returns (bytes28 result);
pack_20_12
function pack_20_12(bytes20 left, bytes12 right) internal pure returns (bytes32 result);
pack_22_2
function pack_22_2(bytes22 left, bytes2 right) internal pure returns (bytes24 result);
pack_22_6
function pack_22_6(bytes22 left, bytes6 right) internal pure returns (bytes28 result);
pack_22_10
function pack_22_10(bytes22 left, bytes10 right) internal pure returns (bytes32 result);
pack_24_4
function pack_24_4(bytes24 left, bytes4 right) internal pure returns (bytes28 result);
pack_24_8
function pack_24_8(bytes24 left, bytes8 right) internal pure returns (bytes32 result);
pack_28_4
function pack_28_4(bytes28 left, bytes4 right) internal pure returns (bytes32 result);
extract_2_1
function extract_2_1(bytes2 self, uint8 offset) internal pure returns (bytes1 result);
replace_2_1
function replace_2_1(bytes2 self, bytes1 value, uint8 offset) internal pure returns (bytes2 result);
extract_4_1
function extract_4_1(bytes4 self, uint8 offset) internal pure returns (bytes1 result);
replace_4_1
function replace_4_1(bytes4 self, bytes1 value, uint8 offset) internal pure returns (bytes4 result);
extract_4_2
function extract_4_2(bytes4 self, uint8 offset) internal pure returns (bytes2 result);
replace_4_2
function replace_4_2(bytes4 self, bytes2 value, uint8 offset) internal pure returns (bytes4 result);
extract_6_1
function extract_6_1(bytes6 self, uint8 offset) internal pure returns (bytes1 result);
replace_6_1
function replace_6_1(bytes6 self, bytes1 value, uint8 offset) internal pure returns (bytes6 result);
extract_6_2
function extract_6_2(bytes6 self, uint8 offset) internal pure returns (bytes2 result);
replace_6_2
function replace_6_2(bytes6 self, bytes2 value, uint8 offset) internal pure returns (bytes6 result);
extract_6_4
function extract_6_4(bytes6 self, uint8 offset) internal pure returns (bytes4 result);
replace_6_4
function replace_6_4(bytes6 self, bytes4 value, uint8 offset) internal pure returns (bytes6 result);
extract_8_1
function extract_8_1(bytes8 self, uint8 offset) internal pure returns (bytes1 result);
replace_8_1
function replace_8_1(bytes8 self, bytes1 value, uint8 offset) internal pure returns (bytes8 result);
extract_8_2
function extract_8_2(bytes8 self, uint8 offset) internal pure returns (bytes2 result);
replace_8_2
function replace_8_2(bytes8 self, bytes2 value, uint8 offset) internal pure returns (bytes8 result);
extract_8_4
function extract_8_4(bytes8 self, uint8 offset) internal pure returns (bytes4 result);
replace_8_4
function replace_8_4(bytes8 self, bytes4 value, uint8 offset) internal pure returns (bytes8 result);
extract_8_6
function extract_8_6(bytes8 self, uint8 offset) internal pure returns (bytes6 result);
replace_8_6
function replace_8_6(bytes8 self, bytes6 value, uint8 offset) internal pure returns (bytes8 result);
extract_10_1
function extract_10_1(bytes10 self, uint8 offset) internal pure returns (bytes1 result);
replace_10_1
function replace_10_1(bytes10 self, bytes1 value, uint8 offset) internal pure returns (bytes10 result);
extract_10_2
function extract_10_2(bytes10 self, uint8 offset) internal pure returns (bytes2 result);
replace_10_2
function replace_10_2(bytes10 self, bytes2 value, uint8 offset) internal pure returns (bytes10 result);
extract_10_4
function extract_10_4(bytes10 self, uint8 offset) internal pure returns (bytes4 result);
replace_10_4
function replace_10_4(bytes10 self, bytes4 value, uint8 offset) internal pure returns (bytes10 result);
extract_10_6
function extract_10_6(bytes10 self, uint8 offset) internal pure returns (bytes6 result);
replace_10_6
function replace_10_6(bytes10 self, bytes6 value, uint8 offset) internal pure returns (bytes10 result);
extract_10_8
function extract_10_8(bytes10 self, uint8 offset) internal pure returns (bytes8 result);
replace_10_8
function replace_10_8(bytes10 self, bytes8 value, uint8 offset) internal pure returns (bytes10 result);
extract_12_1
function extract_12_1(bytes12 self, uint8 offset) internal pure returns (bytes1 result);
replace_12_1
function replace_12_1(bytes12 self, bytes1 value, uint8 offset) internal pure returns (bytes12 result);
extract_12_2
function extract_12_2(bytes12 self, uint8 offset) internal pure returns (bytes2 result);
replace_12_2
function replace_12_2(bytes12 self, bytes2 value, uint8 offset) internal pure returns (bytes12 result);
extract_12_4
function extract_12_4(bytes12 self, uint8 offset) internal pure returns (bytes4 result);
replace_12_4
function replace_12_4(bytes12 self, bytes4 value, uint8 offset) internal pure returns (bytes12 result);
extract_12_6
function extract_12_6(bytes12 self, uint8 offset) internal pure returns (bytes6 result);
replace_12_6
function replace_12_6(bytes12 self, bytes6 value, uint8 offset) internal pure returns (bytes12 result);
extract_12_8
function extract_12_8(bytes12 self, uint8 offset) internal pure returns (bytes8 result);
replace_12_8
function replace_12_8(bytes12 self, bytes8 value, uint8 offset) internal pure returns (bytes12 result);
extract_12_10
function extract_12_10(bytes12 self, uint8 offset) internal pure returns (bytes10 result);
replace_12_10
function replace_12_10(bytes12 self, bytes10 value, uint8 offset) internal pure returns (bytes12 result);
extract_16_1
function extract_16_1(bytes16 self, uint8 offset) internal pure returns (bytes1 result);
replace_16_1
function replace_16_1(bytes16 self, bytes1 value, uint8 offset) internal pure returns (bytes16 result);
extract_16_2
function extract_16_2(bytes16 self, uint8 offset) internal pure returns (bytes2 result);
replace_16_2
function replace_16_2(bytes16 self, bytes2 value, uint8 offset) internal pure returns (bytes16 result);
extract_16_4
function extract_16_4(bytes16 self, uint8 offset) internal pure returns (bytes4 result);
replace_16_4
function replace_16_4(bytes16 self, bytes4 value, uint8 offset) internal pure returns (bytes16 result);
extract_16_6
function extract_16_6(bytes16 self, uint8 offset) internal pure returns (bytes6 result);
replace_16_6
function replace_16_6(bytes16 self, bytes6 value, uint8 offset) internal pure returns (bytes16 result);
extract_16_8
function extract_16_8(bytes16 self, uint8 offset) internal pure returns (bytes8 result);
replace_16_8
function replace_16_8(bytes16 self, bytes8 value, uint8 offset) internal pure returns (bytes16 result);
extract_16_10
function extract_16_10(bytes16 self, uint8 offset) internal pure returns (bytes10 result);
replace_16_10
function replace_16_10(bytes16 self, bytes10 value, uint8 offset) internal pure returns (bytes16 result);
extract_16_12
function extract_16_12(bytes16 self, uint8 offset) internal pure returns (bytes12 result);
replace_16_12
function replace_16_12(bytes16 self, bytes12 value, uint8 offset) internal pure returns (bytes16 result);
extract_20_1
function extract_20_1(bytes20 self, uint8 offset) internal pure returns (bytes1 result);
replace_20_1
function replace_20_1(bytes20 self, bytes1 value, uint8 offset) internal pure returns (bytes20 result);
extract_20_2
function extract_20_2(bytes20 self, uint8 offset) internal pure returns (bytes2 result);
replace_20_2
function replace_20_2(bytes20 self, bytes2 value, uint8 offset) internal pure returns (bytes20 result);
extract_20_4
function extract_20_4(bytes20 self, uint8 offset) internal pure returns (bytes4 result);
replace_20_4
function replace_20_4(bytes20 self, bytes4 value, uint8 offset) internal pure returns (bytes20 result);
extract_20_6
function extract_20_6(bytes20 self, uint8 offset) internal pure returns (bytes6 result);
replace_20_6
function replace_20_6(bytes20 self, bytes6 value, uint8 offset) internal pure returns (bytes20 result);
extract_20_8
function extract_20_8(bytes20 self, uint8 offset) internal pure returns (bytes8 result);
replace_20_8
function replace_20_8(bytes20 self, bytes8 value, uint8 offset) internal pure returns (bytes20 result);
extract_20_10
function extract_20_10(bytes20 self, uint8 offset) internal pure returns (bytes10 result);
replace_20_10
function replace_20_10(bytes20 self, bytes10 value, uint8 offset) internal pure returns (bytes20 result);
extract_20_12
function extract_20_12(bytes20 self, uint8 offset) internal pure returns (bytes12 result);
replace_20_12
function replace_20_12(bytes20 self, bytes12 value, uint8 offset) internal pure returns (bytes20 result);
extract_20_16
function extract_20_16(bytes20 self, uint8 offset) internal pure returns (bytes16 result);
replace_20_16
function replace_20_16(bytes20 self, bytes16 value, uint8 offset) internal pure returns (bytes20 result);
extract_22_1
function extract_22_1(bytes22 self, uint8 offset) internal pure returns (bytes1 result);
replace_22_1
function replace_22_1(bytes22 self, bytes1 value, uint8 offset) internal pure returns (bytes22 result);
extract_22_2
function extract_22_2(bytes22 self, uint8 offset) internal pure returns (bytes2 result);
replace_22_2
function replace_22_2(bytes22 self, bytes2 value, uint8 offset) internal pure returns (bytes22 result);
extract_22_4
function extract_22_4(bytes22 self, uint8 offset) internal pure returns (bytes4 result);
replace_22_4
function replace_22_4(bytes22 self, bytes4 value, uint8 offset) internal pure returns (bytes22 result);
extract_22_6
function extract_22_6(bytes22 self, uint8 offset) internal pure returns (bytes6 result);
replace_22_6
function replace_22_6(bytes22 self, bytes6 value, uint8 offset) internal pure returns (bytes22 result);
extract_22_8
function extract_22_8(bytes22 self, uint8 offset) internal pure returns (bytes8 result);
replace_22_8
function replace_22_8(bytes22 self, bytes8 value, uint8 offset) internal pure returns (bytes22 result);
extract_22_10
function extract_22_10(bytes22 self, uint8 offset) internal pure returns (bytes10 result);
replace_22_10
function replace_22_10(bytes22 self, bytes10 value, uint8 offset) internal pure returns (bytes22 result);
extract_22_12
function extract_22_12(bytes22 self, uint8 offset) internal pure returns (bytes12 result);
replace_22_12
function replace_22_12(bytes22 self, bytes12 value, uint8 offset) internal pure returns (bytes22 result);
extract_22_16
function extract_22_16(bytes22 self, uint8 offset) internal pure returns (bytes16 result);
replace_22_16
function replace_22_16(bytes22 self, bytes16 value, uint8 offset) internal pure returns (bytes22 result);
extract_22_20
function extract_22_20(bytes22 self, uint8 offset) internal pure returns (bytes20 result);
replace_22_20
function replace_22_20(bytes22 self, bytes20 value, uint8 offset) internal pure returns (bytes22 result);
extract_24_1
function extract_24_1(bytes24 self, uint8 offset) internal pure returns (bytes1 result);
replace_24_1
function replace_24_1(bytes24 self, bytes1 value, uint8 offset) internal pure returns (bytes24 result);
extract_24_2
function extract_24_2(bytes24 self, uint8 offset) internal pure returns (bytes2 result);
replace_24_2
function replace_24_2(bytes24 self, bytes2 value, uint8 offset) internal pure returns (bytes24 result);
extract_24_4
function extract_24_4(bytes24 self, uint8 offset) internal pure returns (bytes4 result);
replace_24_4
function replace_24_4(bytes24 self, bytes4 value, uint8 offset) internal pure returns (bytes24 result);
extract_24_6
function extract_24_6(bytes24 self, uint8 offset) internal pure returns (bytes6 result);
replace_24_6
function replace_24_6(bytes24 self, bytes6 value, uint8 offset) internal pure returns (bytes24 result);
extract_24_8
function extract_24_8(bytes24 self, uint8 offset) internal pure returns (bytes8 result);
replace_24_8
function replace_24_8(bytes24 self, bytes8 value, uint8 offset) internal pure returns (bytes24 result);
extract_24_10
function extract_24_10(bytes24 self, uint8 offset) internal pure returns (bytes10 result);
replace_24_10
function replace_24_10(bytes24 self, bytes10 value, uint8 offset) internal pure returns (bytes24 result);
extract_24_12
function extract_24_12(bytes24 self, uint8 offset) internal pure returns (bytes12 result);
replace_24_12
function replace_24_12(bytes24 self, bytes12 value, uint8 offset) internal pure returns (bytes24 result);
extract_24_16
function extract_24_16(bytes24 self, uint8 offset) internal pure returns (bytes16 result);
replace_24_16
function replace_24_16(bytes24 self, bytes16 value, uint8 offset) internal pure returns (bytes24 result);
extract_24_20
function extract_24_20(bytes24 self, uint8 offset) internal pure returns (bytes20 result);
replace_24_20
function replace_24_20(bytes24 self, bytes20 value, uint8 offset) internal pure returns (bytes24 result);
extract_24_22
function extract_24_22(bytes24 self, uint8 offset) internal pure returns (bytes22 result);
replace_24_22
function replace_24_22(bytes24 self, bytes22 value, uint8 offset) internal pure returns (bytes24 result);
extract_28_1
function extract_28_1(bytes28 self, uint8 offset) internal pure returns (bytes1 result);
replace_28_1
function replace_28_1(bytes28 self, bytes1 value, uint8 offset) internal pure returns (bytes28 result);
extract_28_2
function extract_28_2(bytes28 self, uint8 offset) internal pure returns (bytes2 result);
replace_28_2
function replace_28_2(bytes28 self, bytes2 value, uint8 offset) internal pure returns (bytes28 result);
extract_28_4
function extract_28_4(bytes28 self, uint8 offset) internal pure returns (bytes4 result);
replace_28_4
function replace_28_4(bytes28 self, bytes4 value, uint8 offset) internal pure returns (bytes28 result);
extract_28_6
function extract_28_6(bytes28 self, uint8 offset) internal pure returns (bytes6 result);
replace_28_6
function replace_28_6(bytes28 self, bytes6 value, uint8 offset) internal pure returns (bytes28 result);
extract_28_8
function extract_28_8(bytes28 self, uint8 offset) internal pure returns (bytes8 result);
replace_28_8
function replace_28_8(bytes28 self, bytes8 value, uint8 offset) internal pure returns (bytes28 result);
extract_28_10
function extract_28_10(bytes28 self, uint8 offset) internal pure returns (bytes10 result);
replace_28_10
function replace_28_10(bytes28 self, bytes10 value, uint8 offset) internal pure returns (bytes28 result);
extract_28_12
function extract_28_12(bytes28 self, uint8 offset) internal pure returns (bytes12 result);
replace_28_12
function replace_28_12(bytes28 self, bytes12 value, uint8 offset) internal pure returns (bytes28 result);
extract_28_16
function extract_28_16(bytes28 self, uint8 offset) internal pure returns (bytes16 result);
replace_28_16
function replace_28_16(bytes28 self, bytes16 value, uint8 offset) internal pure returns (bytes28 result);
extract_28_20
function extract_28_20(bytes28 self, uint8 offset) internal pure returns (bytes20 result);
replace_28_20
function replace_28_20(bytes28 self, bytes20 value, uint8 offset) internal pure returns (bytes28 result);
extract_28_22
function extract_28_22(bytes28 self, uint8 offset) internal pure returns (bytes22 result);
replace_28_22
function replace_28_22(bytes28 self, bytes22 value, uint8 offset) internal pure returns (bytes28 result);
extract_28_24
function extract_28_24(bytes28 self, uint8 offset) internal pure returns (bytes24 result);
replace_28_24
function replace_28_24(bytes28 self, bytes24 value, uint8 offset) internal pure returns (bytes28 result);
extract_32_1
function extract_32_1(bytes32 self, uint8 offset) internal pure returns (bytes1 result);
replace_32_1
function replace_32_1(bytes32 self, bytes1 value, uint8 offset) internal pure returns (bytes32 result);
extract_32_2
function extract_32_2(bytes32 self, uint8 offset) internal pure returns (bytes2 result);
replace_32_2
function replace_32_2(bytes32 self, bytes2 value, uint8 offset) internal pure returns (bytes32 result);
extract_32_4
function extract_32_4(bytes32 self, uint8 offset) internal pure returns (bytes4 result);
replace_32_4
function replace_32_4(bytes32 self, bytes4 value, uint8 offset) internal pure returns (bytes32 result);
extract_32_6
function extract_32_6(bytes32 self, uint8 offset) internal pure returns (bytes6 result);
replace_32_6
function replace_32_6(bytes32 self, bytes6 value, uint8 offset) internal pure returns (bytes32 result);
extract_32_8
function extract_32_8(bytes32 self, uint8 offset) internal pure returns (bytes8 result);
replace_32_8
function replace_32_8(bytes32 self, bytes8 value, uint8 offset) internal pure returns (bytes32 result);
extract_32_10
function extract_32_10(bytes32 self, uint8 offset) internal pure returns (bytes10 result);
replace_32_10
function replace_32_10(bytes32 self, bytes10 value, uint8 offset) internal pure returns (bytes32 result);
extract_32_12
function extract_32_12(bytes32 self, uint8 offset) internal pure returns (bytes12 result);
replace_32_12
function replace_32_12(bytes32 self, bytes12 value, uint8 offset) internal pure returns (bytes32 result);
extract_32_16
function extract_32_16(bytes32 self, uint8 offset) internal pure returns (bytes16 result);
replace_32_16
function replace_32_16(bytes32 self, bytes16 value, uint8 offset) internal pure returns (bytes32 result);
extract_32_20
function extract_32_20(bytes32 self, uint8 offset) internal pure returns (bytes20 result);
replace_32_20
function replace_32_20(bytes32 self, bytes20 value, uint8 offset) internal pure returns (bytes32 result);
extract_32_22
function extract_32_22(bytes32 self, uint8 offset) internal pure returns (bytes22 result);
replace_32_22
function replace_32_22(bytes32 self, bytes22 value, uint8 offset) internal pure returns (bytes32 result);
extract_32_24
function extract_32_24(bytes32 self, uint8 offset) internal pure returns (bytes24 result);
replace_32_24
function replace_32_24(bytes32 self, bytes24 value, uint8 offset) internal pure returns (bytes32 result);
extract_32_28
function extract_32_28(bytes32 self, uint8 offset) internal pure returns (bytes28 result);
replace_32_28
function replace_32_28(bytes32 self, bytes28 value, uint8 offset) internal pure returns (bytes32 result);
Errors
OutOfRangeAccess
error OutOfRangeAccess();
Panic
*Helper library for emitting standardized panic codes.
contract Example {
using Panic for uint256;
// Use any of the declared internal constants
function foo() { Panic.GENERIC.panic(); }
// Alternatively
function foo() { Panic.panic(Panic.GENERIC); }
}
Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil]. Available since v5.1.*
State Variables
GENERIC
generic / unspecified error
uint256 internal constant GENERIC = 0x00;
ASSERT
used by the assert() builtin
uint256 internal constant ASSERT = 0x01;
UNDER_OVERFLOW
arithmetic underflow or overflow
uint256 internal constant UNDER_OVERFLOW = 0x11;
DIVISION_BY_ZERO
division or modulo by zero
uint256 internal constant DIVISION_BY_ZERO = 0x12;
ENUM_CONVERSION_ERROR
enum conversion error
uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
STORAGE_ENCODING_ERROR
invalid encoding in storage
uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
EMPTY_ARRAY_POP
empty array pop
uint256 internal constant EMPTY_ARRAY_POP = 0x31;
ARRAY_OUT_OF_BOUNDS
array out of bounds access
uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
RESOURCE_ERROR
resource error (too large allocation or too large array)
uint256 internal constant RESOURCE_ERROR = 0x41;
INVALID_INTERNAL_FUNCTION
calling invalid internal function
uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;
Functions
panic
Reverts with a panic code. Recommended to use with the internal constants with predefined codes.
function panic(uint256 code) internal pure;
Pausable
Inherits: Context
Contract module which allows children to implement an emergency stop
mechanism that can be triggered by an authorized account.
This module is used through inheritance. It will make available the
modifiers whenNotPaused and whenPaused, which can be applied to
the functions of your contract. Note that they will not be pausable by
simply including this module, only once the modifiers are put in place.
State Variables
_paused
bool private _paused;
Functions
whenNotPaused
*Modifier to make a function callable only when the contract is not paused. Requirements:
- The contract must not be paused.*
modifier whenNotPaused();
whenPaused
*Modifier to make a function callable only when the contract is paused. Requirements:
- The contract must be paused.*
modifier whenPaused();
paused
Returns true if the contract is paused, and false otherwise.
function paused() public view virtual returns (bool);
_requireNotPaused
Throws if the contract is paused.
function _requireNotPaused() internal view virtual;
_requirePaused
Throws if the contract is not paused.
function _requirePaused() internal view virtual;
_pause
*Triggers stopped state. Requirements:
- The contract must not be paused.*
function _pause() internal virtual whenNotPaused;
_unpause
*Returns to normal state. Requirements:
- The contract must be paused.*
function _unpause() internal virtual whenPaused;
Events
Paused
Emitted when the pause is triggered by account.
event Paused(address account);
Unpaused
Emitted when the pause is lifted by account.
event Unpaused(address account);
Errors
EnforcedPause
The operation failed because the contract is paused.
error EnforcedPause();
ExpectedPause
The operation failed because the contract is not paused.
error ExpectedPause();
ReentrancyGuard
Contract module that helps prevent reentrant calls to a function.
Inheriting from ReentrancyGuard will make the nonReentrant modifier
available, which can be applied to functions to make sure there are no nested
(reentrant) calls to them.
Note that because there is a single nonReentrant guard, functions marked as
nonReentrant may not call one another. This can be worked around by making
those functions private, and then adding external nonReentrant entry
points to them.
TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
consider using {ReentrancyGuardTransient} instead.
TIP: If you would like to learn more about reentrancy and alternative ways
to protect against it, check out our blog post
https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
State Variables
NOT_ENTERED
uint256 private constant NOT_ENTERED = 1;
ENTERED
uint256 private constant ENTERED = 2;
_status
uint256 private _status;
Functions
constructor
constructor();
nonReentrant
Prevents a contract from calling itself, directly or indirectly.
Calling a nonReentrant function from another nonReentrant
function is not supported. It is possible to prevent this from happening
by making the nonReentrant function external, and making it call a
private function that does the actual work.
modifier nonReentrant();
_nonReentrantBefore
function _nonReentrantBefore() private;
_nonReentrantAfter
function _nonReentrantAfter() private;
_reentrancyGuardEntered
Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
nonReentrant function in the call stack.
function _reentrancyGuardEntered() internal view returns (bool);
Errors
ReentrancyGuardReentrantCall
Unauthorized reentrant call.
error ReentrancyGuardReentrantCall();
ReentrancyGuardTransient
Variant of {ReentrancyGuard} that uses transient storage. NOTE: This variant only works on networks where EIP-1153 is available. Available since v5.1.
State Variables
REENTRANCY_GUARD_STORAGE
bytes32 private constant REENTRANCY_GUARD_STORAGE = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;
Functions
nonReentrant
Prevents a contract from calling itself, directly or indirectly.
Calling a nonReentrant function from another nonReentrant
function is not supported. It is possible to prevent this from happening
by making the nonReentrant function external, and making it call a
private function that does the actual work.
modifier nonReentrant();
_nonReentrantBefore
function _nonReentrantBefore() private;
_nonReentrantAfter
function _nonReentrantAfter() private;
_reentrancyGuardEntered
Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
nonReentrant function in the call stack.
function _reentrancyGuardEntered() internal view returns (bool);
Errors
ReentrancyGuardReentrantCall
Unauthorized reentrant call.
error ReentrancyGuardReentrantCall();
ShortString
type ShortString is bytes32;
ShortStrings
*This library provides functions to convert short memory strings
into a ShortString type that can be used as an immutable variable.
Strings of arbitrary length can be optimized using this library if
they are short enough (up to 31 bytes) by packing them with their
length (1 byte) in a single EVM word (32 bytes). Additionally, a
fallback mechanism can be used for every other case.
Usage example:
contract Named {
using ShortStrings for *;
ShortString private immutable _name;
string private _nameFallback;
constructor(string memory contractName) {
_name = contractName.toShortStringWithFallback(_nameFallback);
}
function name() external view returns (string memory) {
return _name.toStringWithFallback(_nameFallback);
}
}
```*
## State Variables
### FALLBACK_SENTINEL
```solidity
bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;
Functions
toShortString
Encode a string of at most 31 chars into a ShortString.
This will trigger a StringTooLong error is the input string is too long.
function toShortString(string memory str) internal pure returns (ShortString);
toString
Decode a ShortString back to a "normal" string.
function toString(ShortString sstr) internal pure returns (string memory);
byteLength
Return the length of a ShortString.
function byteLength(ShortString sstr) internal pure returns (uint256);
toShortStringWithFallback
Encode a string into a ShortString, or write it to storage if it is too long.
function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString);
toStringWithFallback
Decode a string that was encoded to ShortString or written to storage using toShortStringWithFallback.
function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory);
byteLengthWithFallback
Return the length of a string that was encoded to ShortString or written to storage using
toShortStringWithFallback.
WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of
actual characters as the UTF-8 encoding of a single character can span over multiple bytes.
function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256);
Errors
StringTooLong
error StringTooLong(string str);
InvalidShortString
error InvalidShortString();
SlotDerivation
*Library for computing storage (and transient storage) locations from namespaces and deriving slots corresponding to standard patterns. The derivation method for array and mapping matches the storage layout used by the solidity language / compiler. See https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays[Solidity docs for mappings and dynamic arrays.]. Example usage:
contract Example {
// Add the library methods
using StorageSlot for bytes32;
using SlotDerivation for bytes32;
// Declare a namespace
string private constant _NAMESPACE = "<namespace>"; // eg. OpenZeppelin.Slot
function setValueInNamespace(uint256 key, address newValue) internal {
_NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value = newValue;
}
function getValueInNamespace(uint256 key) internal view returns (address) {
return _NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value;
}
}
TIP: Consider using this library along with {StorageSlot}. NOTE: This library provides a way to manipulate storage locations in a non-standard way. Tooling for checking upgrade safety will ignore the slots accessed through this library. Available since v5.1.*
Functions
erc7201Slot
Derive an ERC-7201 slot from a string (namespace).
function erc7201Slot(string memory namespace) internal pure returns (bytes32 slot);
offset
Add an offset to a slot to get the n-th element of a structure or an array.
function offset(bytes32 slot, uint256 pos) internal pure returns (bytes32 result);
deriveArray
Derive the location of the first element in an array from the slot where the length is stored.
function deriveArray(bytes32 slot) internal pure returns (bytes32 result);
deriveMapping
Derive the location of a mapping element from the key.
function deriveMapping(bytes32 slot, address key) internal pure returns (bytes32 result);
deriveMapping
Derive the location of a mapping element from the key.
function deriveMapping(bytes32 slot, bool key) internal pure returns (bytes32 result);
deriveMapping
Derive the location of a mapping element from the key.
function deriveMapping(bytes32 slot, bytes32 key) internal pure returns (bytes32 result);
deriveMapping
Derive the location of a mapping element from the key.
function deriveMapping(bytes32 slot, uint256 key) internal pure returns (bytes32 result);
deriveMapping
Derive the location of a mapping element from the key.
function deriveMapping(bytes32 slot, int256 key) internal pure returns (bytes32 result);
deriveMapping
Derive the location of a mapping element from the key.
function deriveMapping(bytes32 slot, string memory key) internal pure returns (bytes32 result);
deriveMapping
Derive the location of a mapping element from the key.
function deriveMapping(bytes32 slot, bytes memory key) internal pure returns (bytes32 result);
StorageSlot
*Library for reading and writing primitive types to specific storage slots.
Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
This library helps with reading and writing to such slots without the need for inline assembly.
The functions in this library return Slot structs that contain a value member that can be used to read or write.
Example usage to set ERC-1967 implementation slot:
contract ERC1967 {
// Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
function _getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
function _setImplementation(address newImplementation) internal {
require(newImplementation.code.length > 0);
StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
}
}
TIP: Consider using this library along with {SlotDerivation}.*
Functions
getAddressSlot
Returns an AddressSlot with member value located at slot.
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r);
getBooleanSlot
Returns a BooleanSlot with member value located at slot.
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r);
getBytes32Slot
Returns a Bytes32Slot with member value located at slot.
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r);
getUint256Slot
Returns a Uint256Slot with member value located at slot.
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r);
getInt256Slot
Returns a Int256Slot with member value located at slot.
function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r);
getStringSlot
Returns a StringSlot with member value located at slot.
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r);
getStringSlot
Returns an StringSlot representation of the string storage pointer store.
function getStringSlot(string storage store) internal pure returns (StringSlot storage r);
getBytesSlot
Returns a BytesSlot with member value located at slot.
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r);
getBytesSlot
Returns an BytesSlot representation of the bytes storage pointer store.
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r);
Structs
AddressSlot
struct AddressSlot {
address value;
}
BooleanSlot
struct BooleanSlot {
bool value;
}
Bytes32Slot
struct Bytes32Slot {
bytes32 value;
}
Uint256Slot
struct Uint256Slot {
uint256 value;
}
Int256Slot
struct Int256Slot {
int256 value;
}
StringSlot
struct StringSlot {
string value;
}
BytesSlot
struct BytesSlot {
bytes value;
}
Strings
String operations.
State Variables
HEX_DIGITS
bytes16 private constant HEX_DIGITS = "0123456789abcdef";
ADDRESS_LENGTH
uint8 private constant ADDRESS_LENGTH = 20;
SPECIAL_CHARS_LOOKUP
uint256 private constant SPECIAL_CHARS_LOOKUP =
(1 << 0x08) | (1 << 0x09) | (1 << 0x0a) | (1 << 0x0c) | (1 << 0x0d) | (1 << 0x22) | (1 << 0x5c);
ABS_MIN_INT256
uint256 private constant ABS_MIN_INT256 = 2 ** 255;
Functions
toString
Converts a uint256 to its ASCII string decimal representation.
function toString(uint256 value) internal pure returns (string memory);
toStringSigned
Converts a int256 to its ASCII string decimal representation.
function toStringSigned(int256 value) internal pure returns (string memory);
toHexString
Converts a uint256 to its ASCII string hexadecimal representation.
function toHexString(uint256 value) internal pure returns (string memory);
toHexString
Converts a uint256 to its ASCII string hexadecimal representation with fixed length.
function toHexString(uint256 value, uint256 length) internal pure returns (string memory);
toHexString
Converts an address with fixed length of 20 bytes to its not checksummed ASCII string hexadecimal
representation.
function toHexString(address addr) internal pure returns (string memory);
toChecksumHexString
Converts an address with fixed length of 20 bytes to its checksummed ASCII string hexadecimal
representation, according to EIP-55.
function toChecksumHexString(address addr) internal pure returns (string memory);
equal
Returns true if the two strings are equal.
function equal(string memory a, string memory b) internal pure returns (bool);
parseUint
*Parse a decimal string and returns the value as a uint256.
Requirements:
- The string must be formatted as
[0-9]* - The result must fit into an
uint256type*
function parseUint(string memory input) internal pure returns (uint256);
parseUint
*Variant of {parseUint-string} that parses a substring of input located between position begin (included) and
end (excluded).
Requirements:
- The substring must be formatted as
[0-9]* - The result must fit into an
uint256type*
function parseUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256);
tryParseUint
Variant of {parseUint-string} that returns false if the parsing fails because of an invalid character.
NOTE: This function will revert if the result does not fit in a uint256.
function tryParseUint(string memory input) internal pure returns (bool success, uint256 value);
tryParseUint
Variant of {parseUint-string-uint256-uint256} that returns false if the parsing fails because of an invalid
character.
NOTE: This function will revert if the result does not fit in a uint256.
function tryParseUint(string memory input, uint256 begin, uint256 end)
internal
pure
returns (bool success, uint256 value);
_tryParseUintUncheckedBounds
Implementation of {tryParseUint-string-uint256-uint256} that does not check bounds. Caller should make sure that
begin <= end <= input.length. Other inputs would result in undefined behavior.
function _tryParseUintUncheckedBounds(string memory input, uint256 begin, uint256 end)
private
pure
returns (bool success, uint256 value);
parseInt
*Parse a decimal string and returns the value as a int256.
Requirements:
- The string must be formatted as
[-+]?[0-9]* - The result must fit in an
int256type.*
function parseInt(string memory input) internal pure returns (int256);
parseInt
*Variant of {parseInt-string} that parses a substring of input located between position begin (included) and
end (excluded).
Requirements:
- The substring must be formatted as
[-+]?[0-9]* - The result must fit in an
int256type.*
function parseInt(string memory input, uint256 begin, uint256 end) internal pure returns (int256);
tryParseInt
Variant of {parseInt-string} that returns false if the parsing fails because of an invalid character or if
the result does not fit in a int256.
NOTE: This function will revert if the absolute value of the result does not fit in a uint256.
function tryParseInt(string memory input) internal pure returns (bool success, int256 value);
tryParseInt
Variant of {parseInt-string-uint256-uint256} that returns false if the parsing fails because of an invalid
character or if the result does not fit in a int256.
NOTE: This function will revert if the absolute value of the result does not fit in a uint256.
function tryParseInt(string memory input, uint256 begin, uint256 end)
internal
pure
returns (bool success, int256 value);
_tryParseIntUncheckedBounds
Implementation of {tryParseInt-string-uint256-uint256} that does not check bounds. Caller should make sure that
begin <= end <= input.length. Other inputs would result in undefined behavior.
function _tryParseIntUncheckedBounds(string memory input, uint256 begin, uint256 end)
private
pure
returns (bool success, int256 value);
parseHexUint
*Parse a hexadecimal string (with or without "0x" prefix), and returns the value as a uint256.
Requirements:
- The string must be formatted as
(0x)?[0-9a-fA-F]* - The result must fit in an
uint256type.*
function parseHexUint(string memory input) internal pure returns (uint256);
parseHexUint
*Variant of {parseHexUint-string} that parses a substring of input located between position begin (included) and
end (excluded).
Requirements:
- The substring must be formatted as
(0x)?[0-9a-fA-F]* - The result must fit in an
uint256type.*
function parseHexUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256);
tryParseHexUint
Variant of {parseHexUint-string} that returns false if the parsing fails because of an invalid character.
NOTE: This function will revert if the result does not fit in a uint256.
function tryParseHexUint(string memory input) internal pure returns (bool success, uint256 value);
tryParseHexUint
Variant of {parseHexUint-string-uint256-uint256} that returns false if the parsing fails because of an
invalid character.
NOTE: This function will revert if the result does not fit in a uint256.
function tryParseHexUint(string memory input, uint256 begin, uint256 end)
internal
pure
returns (bool success, uint256 value);
_tryParseHexUintUncheckedBounds
Implementation of {tryParseHexUint-string-uint256-uint256} that does not check bounds. Caller should make sure that
begin <= end <= input.length. Other inputs would result in undefined behavior.
function _tryParseHexUintUncheckedBounds(string memory input, uint256 begin, uint256 end)
private
pure
returns (bool success, uint256 value);
parseAddress
*Parse a hexadecimal string (with or without "0x" prefix), and returns the value as an address.
Requirements:
- The string must be formatted as
(0x)?[0-9a-fA-F]{40}*
function parseAddress(string memory input) internal pure returns (address);
parseAddress
*Variant of {parseAddress-string} that parses a substring of input located between position begin (included) and
end (excluded).
Requirements:
- The substring must be formatted as
(0x)?[0-9a-fA-F]{40}*
function parseAddress(string memory input, uint256 begin, uint256 end) internal pure returns (address);
tryParseAddress
Variant of {parseAddress-string} that returns false if the parsing fails because the input is not a properly formatted address. See {parseAddress-string} requirements.
function tryParseAddress(string memory input) internal pure returns (bool success, address value);
tryParseAddress
Variant of {parseAddress-string-uint256-uint256} that returns false if the parsing fails because input is not a properly formatted address. See {parseAddress-string-uint256-uint256} requirements.
function tryParseAddress(string memory input, uint256 begin, uint256 end)
internal
pure
returns (bool success, address value);
_tryParseChr
function _tryParseChr(bytes1 chr) private pure returns (uint8);
escapeJSON
Escape special characters in JSON strings. This can be useful to prevent JSON injection in NFT metadata.
WARNING: This function should only be used in double quoted JSON strings. Single quotes are not escaped.
NOTE: This function escapes all unicode characters, and not just the ones in ranges defined in section 2.5 of
RFC-4627 (U+0000 to U+001F, U+0022 and U+005C). ECMAScript's JSON.parse does recover escaped unicode
characters that are not in this range, but other tooling may provide different results.
function escapeJSON(string memory input) internal pure returns (string memory);
_unsafeReadBytesOffset
Reads a bytes32 from a bytes array without bounds checking. NOTE: making this function internal would mean it could be used with memory unsafe offset, and marking the assembly block as such would prevent some optimizations.
function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value);
Errors
StringsInsufficientHexLength
The value string doesn't fit in the specified length.
error StringsInsufficientHexLength(uint256 value, uint256 length);
StringsInvalidChar
The string being parsed contains characters that are not in scope of the given base.
error StringsInvalidChar();
StringsInvalidAddressFormat
The string being parsed is not a properly formatted address.
error StringsInvalidAddressFormat();
TransientSlot
*Library for reading and writing value-types to specific transient storage slots. Transient slots are often used to store temporary values that are removed after the current transaction. This library helps with reading and writing to such slots without the need for inline assembly. Example reading and writing values using transient storage:
contract Lock {
using TransientSlot for *;
// Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
bytes32 internal constant _LOCK_SLOT = 0xf4678858b2b588224636b8522b729e7722d32fc491da849ed75b3fdf3c84f542;
modifier locked() {
require(!_LOCK_SLOT.asBoolean().tload());
_LOCK_SLOT.asBoolean().tstore(true);
_;
_LOCK_SLOT.asBoolean().tstore(false);
}
}
TIP: Consider using this library along with {SlotDerivation}.*
Functions
asAddress
Cast an arbitrary slot to a AddressSlot.
function asAddress(bytes32 slot) internal pure returns (AddressSlot);
asBoolean
Cast an arbitrary slot to a BooleanSlot.
function asBoolean(bytes32 slot) internal pure returns (BooleanSlot);
asBytes32
Cast an arbitrary slot to a Bytes32Slot.
function asBytes32(bytes32 slot) internal pure returns (Bytes32Slot);
asUint256
Cast an arbitrary slot to a Uint256Slot.
function asUint256(bytes32 slot) internal pure returns (Uint256Slot);
asInt256
Cast an arbitrary slot to a Int256Slot.
function asInt256(bytes32 slot) internal pure returns (Int256Slot);
tload
Load the value held at location slot in transient storage.
function tload(AddressSlot slot) internal view returns (address value);
tstore
Store value at location slot in transient storage.
function tstore(AddressSlot slot, address value) internal;
tload
Load the value held at location slot in transient storage.
function tload(BooleanSlot slot) internal view returns (bool value);
tstore
Store value at location slot in transient storage.
function tstore(BooleanSlot slot, bool value) internal;
tload
Load the value held at location slot in transient storage.
function tload(Bytes32Slot slot) internal view returns (bytes32 value);
tstore
Store value at location slot in transient storage.
function tstore(Bytes32Slot slot, bytes32 value) internal;
tload
Load the value held at location slot in transient storage.
function tload(Uint256Slot slot) internal view returns (uint256 value);
tstore
Store value at location slot in transient storage.
function tstore(Uint256Slot slot, uint256 value) internal;
tload
Load the value held at location slot in transient storage.
function tload(Int256Slot slot) internal view returns (int256 value);
tstore
Store value at location slot in transient storage.
function tstore(Int256Slot slot, int256 value) internal;
Contents
Contents
ICompoundTimelock
https://github.com/compound-finance/compound-protocol/blob/master/contracts/Timelock.sol[Compound timelock] interface
Functions
receive
receive() external payable;
GRACE_PERIOD
function GRACE_PERIOD() external view returns (uint256);
MINIMUM_DELAY
function MINIMUM_DELAY() external view returns (uint256);
MAXIMUM_DELAY
function MAXIMUM_DELAY() external view returns (uint256);
admin
function admin() external view returns (address);
pendingAdmin
function pendingAdmin() external view returns (address);
delay
function delay() external view returns (uint256);
queuedTransactions
function queuedTransactions(bytes32) external view returns (bool);
setDelay
function setDelay(uint256) external;
acceptAdmin
function acceptAdmin() external;
setPendingAdmin
function setPendingAdmin(address) external;
queueTransaction
function queueTransaction(address target, uint256 value, string memory signature, bytes memory data, uint256 eta)
external
returns (bytes32);
cancelTransaction
function cancelTransaction(address target, uint256 value, string memory signature, bytes memory data, uint256 eta)
external;
executeTransaction
function executeTransaction(address target, uint256 value, string memory signature, bytes memory data, uint256 eta)
external
payable
returns (bytes memory);
Events
NewAdmin
event NewAdmin(address indexed newAdmin);
NewPendingAdmin
event NewPendingAdmin(address indexed newPendingAdmin);
NewDelay
event NewDelay(uint256 indexed newDelay);
CancelTransaction
event CancelTransaction(
bytes32 indexed txHash, address indexed target, uint256 value, string signature, bytes data, uint256 eta
);
ExecuteTransaction
event ExecuteTransaction(
bytes32 indexed txHash, address indexed target, uint256 value, string signature, bytes data, uint256 eta
);
QueueTransaction
event QueueTransaction(
bytes32 indexed txHash, address indexed target, uint256 value, string signature, bytes data, uint256 eta
);
Contents
Contents
IERC20
Functions
totalSupply
function totalSupply() external view returns (uint256);
balanceOf
function balanceOf(address account) external view returns (uint256);
transfer
function transfer(address to, uint256 amount) external returns (bool);
allowance
function allowance(address owner, address spender) external view returns (uint256);
approve
function approve(address spender, uint256 amount) external returns (bool);
transferFrom
function transferFrom(address from, address to, uint256 amount) external returns (bool);
Events
Transfer
event Transfer(address indexed from, address indexed to, uint256 value);
Approval
event Approval(address indexed owner, address indexed spender, uint256 value);
IERC4626
Inherits: IERC20
Functions
asset
function asset() external view returns (address assetTokenAddress);
totalAssets
function totalAssets() external view returns (uint256 totalManagedAssets);
convertToShares
function convertToShares(uint256 assets) external view returns (uint256 shares);
convertToAssets
function convertToAssets(uint256 shares) external view returns (uint256 assets);
maxDeposit
function maxDeposit(address receiver) external view returns (uint256 maxAssets);
previewDeposit
function previewDeposit(uint256 assets) external view returns (uint256 shares);
deposit
function deposit(uint256 assets, address receiver) external returns (uint256 shares);
maxMint
function maxMint(address receiver) external view returns (uint256 maxShares);
previewMint
function previewMint(uint256 shares) external view returns (uint256 assets);
mint
function mint(uint256 shares, address receiver) external returns (uint256 assets);
maxWithdraw
function maxWithdraw(address owner) external view returns (uint256 maxAssets);
previewWithdraw
function previewWithdraw(uint256 assets) external view returns (uint256 shares);
withdraw
function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);
maxRedeem
function maxRedeem(address owner) external view returns (uint256 maxShares);
previewRedeem
function previewRedeem(uint256 shares) external view returns (uint256 assets);
redeem
function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);
Events
Deposit
event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares);
Withdraw
event Withdraw(address indexed caller, address indexed receiver, address indexed owner, uint256 assets, uint256 shares);
ERC4626Prop
Inherits: Test
State Variables
delta
uint256 internal _delta_;
underlying
address internal _underlying_;
vault
address internal _vault_;
_vaultMayBeEmpty
bool internal _vaultMayBeEmpty;
_unlimitedAmount
bool internal _unlimitedAmount;
Functions
prop_asset
function prop_asset(address caller) public;
prop_totalAssets
function prop_totalAssets(address caller) public;
prop_convertToShares
function prop_convertToShares(address caller1, address caller2, uint256 assets) public;
prop_convertToAssets
function prop_convertToAssets(address caller1, address caller2, uint256 shares) public;
prop_maxDeposit
function prop_maxDeposit(address caller, address receiver) public;
prop_previewDeposit
function prop_previewDeposit(address caller, address receiver, address other, uint256 assets) public;
prop_deposit
function prop_deposit(address caller, address receiver, uint256 assets) public;
prop_maxMint
function prop_maxMint(address caller, address receiver) public;
prop_previewMint
function prop_previewMint(address caller, address receiver, address other, uint256 shares) public;
prop_mint
function prop_mint(address caller, address receiver, uint256 shares) public;
prop_maxWithdraw
function prop_maxWithdraw(address caller, address owner) public;
prop_previewWithdraw
function prop_previewWithdraw(address caller, address receiver, address owner, address other, uint256 assets) public;
prop_withdraw
function prop_withdraw(address caller, address receiver, address owner, uint256 assets) public;
prop_maxRedeem
function prop_maxRedeem(address caller, address owner) public;
prop_previewRedeem
function prop_previewRedeem(address caller, address receiver, address owner, address other, uint256 shares) public;
prop_redeem
function prop_redeem(address caller, address receiver, address owner, uint256 shares) public;
prop_RT_deposit_redeem
function prop_RT_deposit_redeem(address caller, uint256 assets) public;
prop_RT_deposit_withdraw
function prop_RT_deposit_withdraw(address caller, uint256 assets) public;
prop_RT_redeem_deposit
function prop_RT_redeem_deposit(address caller, uint256 shares) public;
prop_RT_redeem_mint
function prop_RT_redeem_mint(address caller, uint256 shares) public;
prop_RT_mint_withdraw
function prop_RT_mint_withdraw(address caller, uint256 shares) public;
prop_RT_mint_redeem
function prop_RT_mint_redeem(address caller, uint256 shares) public;
prop_RT_withdraw_mint
function prop_RT_withdraw_mint(address caller, uint256 assets) public;
prop_RT_withdraw_deposit
function prop_RT_withdraw_deposit(address caller, uint256 assets) public;
vault_convertToShares
function vault_convertToShares(uint256 assets) internal returns (uint256);
vault_convertToAssets
function vault_convertToAssets(uint256 shares) internal returns (uint256);
vault_maxDeposit
function vault_maxDeposit(address receiver) internal returns (uint256);
vault_maxMint
function vault_maxMint(address receiver) internal returns (uint256);
vault_maxWithdraw
function vault_maxWithdraw(address owner) internal returns (uint256);
vault_maxRedeem
function vault_maxRedeem(address owner) internal returns (uint256);
vault_previewDeposit
function vault_previewDeposit(uint256 assets) internal returns (uint256);
vault_previewMint
function vault_previewMint(uint256 shares) internal returns (uint256);
vault_previewWithdraw
function vault_previewWithdraw(uint256 assets) internal returns (uint256);
vault_previewRedeem
function vault_previewRedeem(uint256 shares) internal returns (uint256);
vault_deposit
function vault_deposit(uint256 assets, address receiver) internal returns (uint256);
vault_mint
function vault_mint(uint256 shares, address receiver) internal returns (uint256);
vault_withdraw
function vault_withdraw(uint256 assets, address receiver, address owner) internal returns (uint256);
vault_redeem
function vault_redeem(uint256 shares, address receiver, address owner) internal returns (uint256);
_call_vault
function _call_vault(bytes memory data) internal returns (uint256);
assertApproxGeAbs
function assertApproxGeAbs(uint256 a, uint256 b, uint256 maxDelta) internal;
assertApproxLeAbs
function assertApproxLeAbs(uint256 a, uint256 b, uint256 maxDelta) internal;
IMockERC20
Inherits: IERC20
Functions
mint
function mint(address to, uint256 value) external;
burn
function burn(address from, uint256 value) external;
ERC4626Test
Inherits: ERC4626Prop
State Variables
N
uint256 constant N = 4;
Functions
setUp
function setUp() public virtual;
setUpVault
function setUpVault(Init memory init) public virtual;
setUpYield
function setUpYield(Init memory init) public virtual;
test_asset
function test_asset(Init memory init) public virtual;
test_totalAssets
function test_totalAssets(Init memory init) public virtual;
test_convertToShares
function test_convertToShares(Init memory init, uint256 assets) public virtual;
test_convertToAssets
function test_convertToAssets(Init memory init, uint256 shares) public virtual;
test_maxDeposit
function test_maxDeposit(Init memory init) public virtual;
test_previewDeposit
function test_previewDeposit(Init memory init, uint256 assets) public virtual;
test_deposit
function test_deposit(Init memory init, uint256 assets, uint256 allowance) public virtual;
test_maxMint
function test_maxMint(Init memory init) public virtual;
test_previewMint
function test_previewMint(Init memory init, uint256 shares) public virtual;
test_mint
function test_mint(Init memory init, uint256 shares, uint256 allowance) public virtual;
test_maxWithdraw
function test_maxWithdraw(Init memory init) public virtual;
test_previewWithdraw
function test_previewWithdraw(Init memory init, uint256 assets) public virtual;
test_withdraw
function test_withdraw(Init memory init, uint256 assets, uint256 allowance) public virtual;
test_withdraw_zero_allowance
function test_withdraw_zero_allowance(Init memory init, uint256 assets) public virtual;
test_maxRedeem
function test_maxRedeem(Init memory init) public virtual;
test_previewRedeem
function test_previewRedeem(Init memory init, uint256 shares) public virtual;
test_redeem
function test_redeem(Init memory init, uint256 shares, uint256 allowance) public virtual;
test_redeem_zero_allowance
function test_redeem_zero_allowance(Init memory init, uint256 shares) public virtual;
test_RT_deposit_redeem
function test_RT_deposit_redeem(Init memory init, uint256 assets) public virtual;
test_RT_deposit_withdraw
function test_RT_deposit_withdraw(Init memory init, uint256 assets) public virtual;
test_RT_redeem_deposit
function test_RT_redeem_deposit(Init memory init, uint256 shares) public virtual;
test_RT_redeem_mint
function test_RT_redeem_mint(Init memory init, uint256 shares) public virtual;
test_RT_mint_withdraw
function test_RT_mint_withdraw(Init memory init, uint256 shares) public virtual;
test_RT_mint_redeem
function test_RT_mint_redeem(Init memory init, uint256 shares) public virtual;
test_RT_withdraw_mint
function test_RT_withdraw_mint(Init memory init, uint256 assets) public virtual;
test_RT_withdraw_deposit
function test_RT_withdraw_deposit(Init memory init, uint256 assets) public virtual;
_isContract
function _isContract(address account) internal view returns (bool);
_isEOA
function _isEOA(address account) internal view returns (bool);
_approve
function _approve(address token, address owner, address spender, uint256 amount) internal;
_safeApprove
function _safeApprove(address token, address spender, uint256 amount) internal;
_max_deposit
function _max_deposit(address from) internal virtual returns (uint256);
_max_mint
function _max_mint(address from) internal virtual returns (uint256);
_max_withdraw
function _max_withdraw(address from) internal virtual returns (uint256);
_max_redeem
function _max_redeem(address from) internal virtual returns (uint256);
Structs
Init
struct Init {
address[N] user;
uint256[N] share;
uint256[N] asset;
int256 yield;
}
Contents
Contents
- interfaces
- CommonBase
- TestBase
- ScriptBase
- Script
- StdAssertions
- StdChains
- StdCheatsSafe
- StdCheats
- stdError
- StdInvariant
- stdJson
- stdMath
- FindData
- StdStorage
- stdStorageSafe
- stdStorage
- StdStyle
- stdToml
- StdUtils
- Test
- VmSafe
- Vm
- console
- safeconsole
Contents
- IERC1155
- IERC165
- IERC20
- IERC4626
- IERC721
- IERC721TokenReceiver
- IERC721Metadata
- IERC721Enumerable
- IMulticall3
IERC1155
Inherits: IERC165
See https://eips.ethereum.org/EIPS/eip-1155 Note: The ERC-165 identifier for this interface is 0xd9b67a26.
Functions
safeTransferFrom
Transfers _value amount of an _id from the _from address to the _to address specified (with safety call).
*Caller must be approved to manage the tokens being transferred out of the _from account (see "Approval" section of the standard).
- MUST revert if
_tois the zero address. - MUST revert if balance of holder for token
_idis lower than the_valuesent. - MUST revert on any other error.
- MUST emit the
TransferSingleevent to reflect the balance change (see "Safe Transfer Rules" section of the standard). - After the above conditions are met, this function MUST check if
_tois a smart contract (e.g. code size > 0). If so, it MUST callonERC1155Receivedon_toand act appropriately (see "Safe Transfer Rules" section of the standard).*
function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _value, bytes calldata _data) external;
Parameters
| Name | Type | Description |
|---|---|---|
_from | address | Source address |
_to | address | Target address |
_id | uint256 | ID of the token type |
_value | uint256 | Transfer amount |
_data | bytes | Additional data with no specified format, MUST be sent unaltered in call to onERC1155Received on _to |
safeBatchTransferFrom
Transfers _values amount(s) of _ids from the _from address to the _to address specified (with safety call).
*Caller must be approved to manage the tokens being transferred out of the _from account (see "Approval" section of the standard).
- MUST revert if
_tois the zero address. - MUST revert if length of
_idsis not the same as length of_values. - MUST revert if any of the balance(s) of the holder(s) for token(s) in
_idsis lower than the respective amount(s) in_valuessent to the recipient. - MUST revert on any other error.
- MUST emit
TransferSingleorTransferBatchevent(s) such that all the balance changes are reflected (see "Safe Transfer Rules" section of the standard). - Balance changes and events MUST follow the ordering of the arrays (_ids[0]/_values[0] before _ids[1]/_values[1], etc).
- After the above conditions for the transfer(s) in the batch are met, this function MUST check if
_tois a smart contract (e.g. code size > 0). If so, it MUST call the relevantERC1155TokenReceiverhook(s) on_toand act appropriately (see "Safe Transfer Rules" section of the standard).*
function safeBatchTransferFrom(
address _from,
address _to,
uint256[] calldata _ids,
uint256[] calldata _values,
bytes calldata _data
) external;
Parameters
| Name | Type | Description |
|---|---|---|
_from | address | Source address |
_to | address | Target address |
_ids | uint256[] | IDs of each token type (order and length must match _values array) |
_values | uint256[] | Transfer amounts per token type (order and length must match _ids array) |
_data | bytes | Additional data with no specified format, MUST be sent unaltered in call to the ERC1155TokenReceiver hook(s) on _to |
balanceOf
Get the balance of an account's tokens.
function balanceOf(address _owner, uint256 _id) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_owner | address | The address of the token holder |
_id | uint256 | ID of the token |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The _owner's balance of the token type requested |
balanceOfBatch
Get the balance of multiple account/token pairs
function balanceOfBatch(address[] calldata _owners, uint256[] calldata _ids) external view returns (uint256[] memory);
Parameters
| Name | Type | Description |
|---|---|---|
_owners | address[] | The addresses of the token holders |
_ids | uint256[] | ID of the tokens |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256[] | The _owner's balance of the token types requested (i.e. balance for each (owner, id) pair) |
setApprovalForAll
Enable or disable approval for a third party ("operator") to manage all of the caller's tokens.
MUST emit the ApprovalForAll event on success.
function setApprovalForAll(address _operator, bool _approved) external;
Parameters
| Name | Type | Description |
|---|---|---|
_operator | address | Address to add to the set of authorized operators |
_approved | bool | True if the operator is approved, false to revoke approval |
isApprovedForAll
Queries the approval status of an operator for a given owner.
function isApprovedForAll(address _owner, address _operator) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
_owner | address | The owner of the tokens |
_operator | address | Address of authorized operator |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the operator is approved, false if not |
Events
TransferSingle
- Either
TransferSingleorTransferBatchMUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see "Safe Transfer Rules" section of the standard). - The
_operatorargument MUST be the address of an account/contract that is approved to make the transfer (SHOULD be msg.sender). - The
_fromargument MUST be the address of the holder whose balance is decreased. - The
_toargument MUST be the address of the recipient whose balance is increased. - The
_idargument MUST be the token type being transferred. - The
_valueargument MUST be the number of tokens the holder balance is decreased by and match what the recipient balance is increased by. - When minting/creating tokens, the
_fromargument MUST be set to0x0(i.e. zero address). - When burning/destroying tokens, the
_toargument MUST be set to0x0(i.e. zero address).*
event TransferSingle(
address indexed _operator, address indexed _from, address indexed _to, uint256 _id, uint256 _value
);
TransferBatch
- Either
TransferSingleorTransferBatchMUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see "Safe Transfer Rules" section of the standard). - The
_operatorargument MUST be the address of an account/contract that is approved to make the transfer (SHOULD be msg.sender). - The
_fromargument MUST be the address of the holder whose balance is decreased. - The
_toargument MUST be the address of the recipient whose balance is increased. - The
_idsargument MUST be the list of tokens being transferred. - The
_valuesargument MUST be the list of number of tokens (matching the list and order of tokens specified in _ids) the holder balance is decreased by and match what the recipient balance is increased by. - When minting/creating tokens, the
_fromargument MUST be set to0x0(i.e. zero address). - When burning/destroying tokens, the
_toargument MUST be set to0x0(i.e. zero address).*
event TransferBatch(
address indexed _operator, address indexed _from, address indexed _to, uint256[] _ids, uint256[] _values
);
ApprovalForAll
MUST emit when approval for a second party/operator address to manage all tokens for an owner address is enabled or disabled (absence of an event assumes disabled).
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
URI
MUST emit when the URI is updated for a token ID. URIs are defined in RFC 3986. The URI MUST point to a JSON file that conforms to the "ERC-1155 Metadata URI JSON Schema".
event URI(string _value, uint256 indexed _id);
IERC165
Functions
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceID) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
interfaceID | bytes4 | The interface identifier, as specified in ERC-165 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
IERC20
Interface of the ERC20 standard as defined in the EIP.
This includes the optional name, symbol, and decimals metadata.
Functions
totalSupply
Returns the amount of tokens in existence.
function totalSupply() external view returns (uint256);
balanceOf
Returns the amount of tokens owned by account.
function balanceOf(address account) external view returns (uint256);
transfer
Moves amount tokens from the caller's account to to.
function transfer(address to, uint256 amount) external returns (bool);
allowance
Returns the remaining number of tokens that spender is allowed
to spend on behalf of owner
function allowance(address owner, address spender) external view returns (uint256);
approve
Sets amount as the allowance of spender over the caller's tokens.
Be aware of front-running risks: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
function approve(address spender, uint256 amount) external returns (bool);
transferFrom
Moves amount tokens from from to to using the allowance mechanism.
amount is then deducted from the caller's allowance.
function transferFrom(address from, address to, uint256 amount) external returns (bool);
name
Returns the name of the token.
function name() external view returns (string memory);
symbol
Returns the symbol of the token.
function symbol() external view returns (string memory);
decimals
Returns the decimals places of the token.
function decimals() external view returns (uint8);
Events
Transfer
Emitted when value tokens are moved from one account (from) to another (to).
event Transfer(address indexed from, address indexed to, uint256 value);
Approval
Emitted when the allowance of a spender for an owner is set, where value
is the new allowance.
event Approval(address indexed owner, address indexed spender, uint256 value);
IERC4626
Inherits: IERC20
Interface of the ERC4626 "Tokenized Vault Standard", as defined in https://eips.ethereum.org/EIPS/eip-4626
Functions
asset
Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.
- MUST be an ERC-20 token contract.
- MUST NOT revert.*
function asset() external view returns (address assetTokenAddress);
totalAssets
Returns the total amount of the underlying asset that is “managed” by Vault.
- SHOULD include any compounding that occurs from yield.
- MUST be inclusive of any fees that are charged against assets in the Vault.
- MUST NOT revert.*
function totalAssets() external view returns (uint256 totalManagedAssets);
convertToShares
Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal scenario where all the conditions are met.
- MUST NOT be inclusive of any fees that are charged against assets in the Vault.
- MUST NOT show any variations depending on the caller.
- MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
- MUST NOT revert. NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and from.*
function convertToShares(uint256 assets) external view returns (uint256 shares);
convertToAssets
Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal scenario where all the conditions are met.
- MUST NOT be inclusive of any fees that are charged against assets in the Vault.
- MUST NOT show any variations depending on the caller.
- MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
- MUST NOT revert. NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and from.*
function convertToAssets(uint256 shares) external view returns (uint256 assets);
maxDeposit
Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver, through a deposit call.
- MUST return a limited value if receiver is subject to some deposit limit.
- MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.
- MUST NOT revert.*
function maxDeposit(address receiver) external view returns (uint256 maxAssets);
previewDeposit
Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given current on-chain conditions.
- MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called in the same transaction.
- MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the deposit would be accepted, regardless if the user has enough tokens approved, etc.
- MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
- MUST NOT revert. NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by depositing.*
function previewDeposit(uint256 assets) external view returns (uint256 shares);
deposit
Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.
- MUST emit the Deposit event.
- MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the deposit execution, and are accounted for during deposit.
- MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not approving enough underlying tokens to the Vault contract, etc). NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.*
function deposit(uint256 assets, address receiver) external returns (uint256 shares);
maxMint
Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.
- MUST return a limited value if receiver is subject to some mint limit.
- MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.
- MUST NOT revert.*
function maxMint(address receiver) external view returns (uint256 maxShares);
previewMint
Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given current on-chain conditions.
- MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the same transaction.
- MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint would be accepted, regardless if the user has enough tokens approved, etc.
- MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
- MUST NOT revert. NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by minting.*
function previewMint(uint256 shares) external view returns (uint256 assets);
mint
Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.
- MUST emit the Deposit event.
- MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint execution, and are accounted for during mint.
- MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not approving enough underlying tokens to the Vault contract, etc). NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.*
function mint(uint256 shares, address receiver) external returns (uint256 assets);
maxWithdraw
Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the Vault, through a withdrawal call.
- MUST return a limited value if owner is subject to some withdrawal limit or timelock.
- MUST NOT revert.*
function maxWithdraw(address owner) external view returns (uint256 maxAssets);
previewWithdraw
Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block, given current on-chain conditions.
- MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if called in the same transaction.
- MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though the withdrawal would be accepted, regardless if the user has enough shares, etc.
- MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
- MUST NOT revert. NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by depositing.*
function previewWithdraw(uint256 assets) external view returns (uint256 shares);
withdraw
Burns shares from owner and sends exactly assets of underlying tokens to receiver.
- MUST emit the Withdraw event.
- MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the withdraw execution, and are accounted for during withdrawal.
- MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner not having enough shares, etc). Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed. Those methods should be performed separately.*
function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);
maxRedeem
Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, through a redeem call.
- MUST return a limited value if owner is subject to some withdrawal limit or timelock.
- MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.
- MUST NOT revert.*
function maxRedeem(address owner) external view returns (uint256 maxShares);
previewRedeem
Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block, given current on-chain conditions.
- MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the same transaction.
- MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the redemption would be accepted, regardless if the user has enough shares, etc.
- MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
- MUST NOT revert. NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in share price or some other type of condition, meaning the depositor will lose assets by redeeming.*
function previewRedeem(uint256 shares) external view returns (uint256 assets);
redeem
Burns exactly shares from owner and sends assets of underlying tokens to receiver.
- MUST emit the Withdraw event.
- MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the redeem execution, and are accounted for during redeem.
- MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner not having enough shares, etc). NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed. Those methods should be performed separately.*
function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);
Events
Deposit
event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);
Withdraw
event Withdraw(address indexed sender, address indexed receiver, address indexed owner, uint256 assets, uint256 shares);
IERC721
Inherits: IERC165
See https://eips.ethereum.org/EIPS/eip-721 Note: the ERC-165 identifier for this interface is 0x80ac58cd.
Functions
balanceOf
Count all NFTs assigned to an owner
NFTs assigned to the zero address are considered invalid, and this function throws for queries about the zero address.
function balanceOf(address _owner) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_owner | address | An address for whom to query the balance |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The number of NFTs owned by _owner, possibly zero |
ownerOf
Find the owner of an NFT
NFTs assigned to zero address are considered invalid, and queries about them do throw.
function ownerOf(uint256 _tokenId) external view returns (address);
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | The identifier for an NFT |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The address of the owner of the NFT |
safeTransferFrom
Transfers the ownership of an NFT from one address to another address
Throws unless msg.sender is the current owner, an authorized
operator, or the approved address for this NFT. Throws if _from is
not the current owner. Throws if _to is the zero address. Throws if
_tokenId is not a valid NFT. When transfer is complete, this function
checks if _to is a smart contract (code size > 0). If so, it calls
onERC721Received on _to and throws if the return value is not
bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")).
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes calldata data) external payable;
Parameters
| Name | Type | Description |
|---|---|---|
_from | address | The current owner of the NFT |
_to | address | The new owner |
_tokenId | uint256 | The NFT to transfer |
data | bytes | Additional data with no specified format, sent in call to _to |
safeTransferFrom
Transfers the ownership of an NFT from one address to another address
This works identically to the other function with an extra data parameter, except this function just sets data to "".
function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable;
Parameters
| Name | Type | Description |
|---|---|---|
_from | address | The current owner of the NFT |
_to | address | The new owner |
_tokenId | uint256 | The NFT to transfer |
transferFrom
Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE
TO CONFIRM THAT _to IS CAPABLE OF RECEIVING NFTS OR ELSE
THEY MAY BE PERMANENTLY LOST
Throws unless msg.sender is the current owner, an authorized
operator, or the approved address for this NFT. Throws if _from is
not the current owner. Throws if _to is the zero address. Throws if
_tokenId is not a valid NFT.
function transferFrom(address _from, address _to, uint256 _tokenId) external payable;
Parameters
| Name | Type | Description |
|---|---|---|
_from | address | The current owner of the NFT |
_to | address | The new owner |
_tokenId | uint256 | The NFT to transfer |
approve
Change or reaffirm the approved address for an NFT
The zero address indicates there is no approved address.
Throws unless msg.sender is the current NFT owner, or an authorized
operator of the current owner.
function approve(address _approved, uint256 _tokenId) external payable;
Parameters
| Name | Type | Description |
|---|---|---|
_approved | address | The new approved NFT controller |
_tokenId | uint256 | The NFT to approve |
setApprovalForAll
Enable or disable approval for a third party ("operator") to manage
all of msg.sender's assets
Emits the ApprovalForAll event. The contract MUST allow multiple operators per owner.
function setApprovalForAll(address _operator, bool _approved) external;
Parameters
| Name | Type | Description |
|---|---|---|
_operator | address | Address to add to the set of authorized operators |
_approved | bool | True if the operator is approved, false to revoke approval |
getApproved
Get the approved address for a single NFT
Throws if _tokenId is not a valid NFT.
function getApproved(uint256 _tokenId) external view returns (address);
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | The NFT to find the approved address for |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The approved address for this NFT, or the zero address if there is none |
isApprovedForAll
Query if an address is an authorized operator for another address
function isApprovedForAll(address _owner, address _operator) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
_owner | address | The address that owns the NFTs |
_operator | address | The address that acts on behalf of the owner |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if _operator is an approved operator for _owner, false otherwise |
Events
Transfer
This emits when ownership of any NFT changes by any mechanism.
This event emits when NFTs are created (from == 0) and destroyed
(to == 0). Exception: during contract creation, any number of NFTs
may be created and assigned without emitting Transfer. At the time of
any transfer, the approved address for that NFT (if any) is reset to none.
event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);
Approval
This emits when the approved address for an NFT is changed or reaffirmed. The zero address indicates there is no approved address. When a Transfer event emits, this also indicates that the approved address for that NFT (if any) is reset to none.
event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId);
ApprovalForAll
This emits when an operator is enabled or disabled for an owner. The operator can manage all NFTs of the owner.
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
IERC721TokenReceiver
Note: the ERC-165 identifier for this interface is 0x150b7a02.
Functions
onERC721Received
Handle the receipt of an NFT
The ERC721 smart contract calls this function on the recipient
after a transfer. This function MAY throw to revert and reject the
transfer. Return of other than the magic value MUST result in the
transaction being reverted.
Note: the contract address is always the message sender.
function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes calldata _data)
external
returns (bytes4);
Parameters
| Name | Type | Description |
|---|---|---|
_operator | address | The address which called safeTransferFrom function |
_from | address | The address which previously owned the token |
_tokenId | uint256 | The NFT identifier which is being transferred |
_data | bytes | Additional data with no specified format |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes4 | bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")) unless throwing |
IERC721Metadata
Inherits: IERC721
See https://eips.ethereum.org/EIPS/eip-721 Note: the ERC-165 identifier for this interface is 0x5b5e139f.
Functions
name
A descriptive name for a collection of NFTs in this contract
function name() external view returns (string memory _name);
symbol
An abbreviated name for NFTs in this contract
function symbol() external view returns (string memory _symbol);
tokenURI
A distinct Uniform Resource Identifier (URI) for a given asset.
Throws if _tokenId is not a valid NFT. URIs are defined in RFC
3986. The URI may point to a JSON file that conforms to the "ERC721
Metadata JSON Schema".
function tokenURI(uint256 _tokenId) external view returns (string memory);
IERC721Enumerable
Inherits: IERC721
See https://eips.ethereum.org/EIPS/eip-721 Note: the ERC-165 identifier for this interface is 0x780e9d63.
Functions
totalSupply
Count NFTs tracked by this contract
function totalSupply() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | A count of valid NFTs tracked by this contract, where each one of them has an assigned and queryable owner not equal to the zero address |
tokenByIndex
Enumerate valid NFTs
Throws if _index >= totalSupply().
function tokenByIndex(uint256 _index) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_index | uint256 | A counter less than totalSupply() |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The token identifier for the _indexth NFT, (sort order not specified) |
tokenOfOwnerByIndex
Enumerate NFTs assigned to an owner
Throws if _index >= balanceOf(_owner) or if
_owner is the zero address, representing invalid NFTs.
function tokenOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_owner | address | An address where we are interested in NFTs owned by them |
_index | uint256 | A counter less than balanceOf(_owner) |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The token identifier for the _indexth NFT assigned to _owner, (sort order not specified) |
IMulticall3
Functions
aggregate
function aggregate(Call[] calldata calls) external payable returns (uint256 blockNumber, bytes[] memory returnData);
aggregate3
function aggregate3(Call3[] calldata calls) external payable returns (Result[] memory returnData);
aggregate3Value
function aggregate3Value(Call3Value[] calldata calls) external payable returns (Result[] memory returnData);
blockAndAggregate
function blockAndAggregate(Call[] calldata calls)
external
payable
returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData);
getBasefee
function getBasefee() external view returns (uint256 basefee);
getBlockHash
function getBlockHash(uint256 blockNumber) external view returns (bytes32 blockHash);
getBlockNumber
function getBlockNumber() external view returns (uint256 blockNumber);
getChainId
function getChainId() external view returns (uint256 chainid);
getCurrentBlockCoinbase
function getCurrentBlockCoinbase() external view returns (address coinbase);
getCurrentBlockDifficulty
function getCurrentBlockDifficulty() external view returns (uint256 difficulty);
getCurrentBlockGasLimit
function getCurrentBlockGasLimit() external view returns (uint256 gaslimit);
getCurrentBlockTimestamp
function getCurrentBlockTimestamp() external view returns (uint256 timestamp);
getEthBalance
function getEthBalance(address addr) external view returns (uint256 balance);
getLastBlockHash
function getLastBlockHash() external view returns (bytes32 blockHash);
tryAggregate
function tryAggregate(bool requireSuccess, Call[] calldata calls)
external
payable
returns (Result[] memory returnData);
tryBlockAndAggregate
function tryBlockAndAggregate(bool requireSuccess, Call[] calldata calls)
external
payable
returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData);
Structs
Call
struct Call {
address target;
bytes callData;
}
Call3
struct Call3 {
address target;
bool allowFailure;
bytes callData;
}
Call3Value
struct Call3Value {
address target;
bool allowFailure;
uint256 value;
bytes callData;
}
Result
struct Result {
bool success;
bytes returnData;
}
CommonBase
State Variables
VM_ADDRESS
address internal constant VM_ADDRESS = address(uint160(uint256(keccak256("hevm cheat code"))));
CONSOLE
address internal constant CONSOLE = 0x000000000000000000636F6e736F6c652e6c6f67;
CREATE2_FACTORY
address internal constant CREATE2_FACTORY = 0x4e59b44847b379578588920cA78FbF26c0B4956C;
DEFAULT_SENDER
address internal constant DEFAULT_SENDER = address(uint160(uint256(keccak256("foundry default caller"))));
DEFAULT_TEST_CONTRACT
address internal constant DEFAULT_TEST_CONTRACT = 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f;
MULTICALL3_ADDRESS
address internal constant MULTICALL3_ADDRESS = 0xcA11bde05977b3631167028862bE2a173976CA11;
SECP256K1_ORDER
uint256 internal constant SECP256K1_ORDER =
115792089237316195423570985008687907852837564279074904382605163141518161494337;
UINT256_MAX
uint256 internal constant UINT256_MAX = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
vm
Vm internal constant vm = Vm(VM_ADDRESS);
stdstore
StdStorage internal stdstore;
TestBase
Inherits: CommonBase
ScriptBase
Inherits: CommonBase
State Variables
vmSafe
VmSafe internal constant vmSafe = VmSafe(VM_ADDRESS);
Script
Inherits: ScriptBase, StdChains, StdCheatsSafe, StdUtils
State Variables
IS_SCRIPT
bool public IS_SCRIPT = true;
StdAssertions
State Variables
vm
Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));
_failed
bool private _failed;
Functions
failed
function failed() public view returns (bool);
fail
function fail() internal virtual;
assertTrue
function assertTrue(bool data) internal pure virtual;
assertTrue
function assertTrue(bool data, string memory err) internal pure virtual;
assertFalse
function assertFalse(bool data) internal pure virtual;
assertFalse
function assertFalse(bool data, string memory err) internal pure virtual;
assertEq
function assertEq(bool left, bool right) internal pure virtual;
assertEq
function assertEq(bool left, bool right, string memory err) internal pure virtual;
assertEq
function assertEq(uint256 left, uint256 right) internal pure virtual;
assertEq
function assertEq(uint256 left, uint256 right, string memory err) internal pure virtual;
assertEqDecimal
function assertEqDecimal(uint256 left, uint256 right, uint256 decimals) internal pure virtual;
assertEqDecimal
function assertEqDecimal(uint256 left, uint256 right, uint256 decimals, string memory err) internal pure virtual;
assertEq
function assertEq(int256 left, int256 right) internal pure virtual;
assertEq
function assertEq(int256 left, int256 right, string memory err) internal pure virtual;
assertEqDecimal
function assertEqDecimal(int256 left, int256 right, uint256 decimals) internal pure virtual;
assertEqDecimal
function assertEqDecimal(int256 left, int256 right, uint256 decimals, string memory err) internal pure virtual;
assertEq
function assertEq(address left, address right) internal pure virtual;
assertEq
function assertEq(address left, address right, string memory err) internal pure virtual;
assertEq
function assertEq(bytes32 left, bytes32 right) internal pure virtual;
assertEq
function assertEq(bytes32 left, bytes32 right, string memory err) internal pure virtual;
assertEq32
function assertEq32(bytes32 left, bytes32 right) internal pure virtual;
assertEq32
function assertEq32(bytes32 left, bytes32 right, string memory err) internal pure virtual;
assertEq
function assertEq(string memory left, string memory right) internal pure virtual;
assertEq
function assertEq(string memory left, string memory right, string memory err) internal pure virtual;
assertEq
function assertEq(bytes memory left, bytes memory right) internal pure virtual;
assertEq
function assertEq(bytes memory left, bytes memory right, string memory err) internal pure virtual;
assertEq
function assertEq(bool[] memory left, bool[] memory right) internal pure virtual;
assertEq
function assertEq(bool[] memory left, bool[] memory right, string memory err) internal pure virtual;
assertEq
function assertEq(uint256[] memory left, uint256[] memory right) internal pure virtual;
assertEq
function assertEq(uint256[] memory left, uint256[] memory right, string memory err) internal pure virtual;
assertEq
function assertEq(int256[] memory left, int256[] memory right) internal pure virtual;
assertEq
function assertEq(int256[] memory left, int256[] memory right, string memory err) internal pure virtual;
assertEq
function assertEq(address[] memory left, address[] memory right) internal pure virtual;
assertEq
function assertEq(address[] memory left, address[] memory right, string memory err) internal pure virtual;
assertEq
function assertEq(bytes32[] memory left, bytes32[] memory right) internal pure virtual;
assertEq
function assertEq(bytes32[] memory left, bytes32[] memory right, string memory err) internal pure virtual;
assertEq
function assertEq(string[] memory left, string[] memory right) internal pure virtual;
assertEq
function assertEq(string[] memory left, string[] memory right, string memory err) internal pure virtual;
assertEq
function assertEq(bytes[] memory left, bytes[] memory right) internal pure virtual;
assertEq
function assertEq(bytes[] memory left, bytes[] memory right, string memory err) internal pure virtual;
assertEqUint
function assertEqUint(uint256 left, uint256 right) internal pure virtual;
assertNotEq
function assertNotEq(bool left, bool right) internal pure virtual;
assertNotEq
function assertNotEq(bool left, bool right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(uint256 left, uint256 right) internal pure virtual;
assertNotEq
function assertNotEq(uint256 left, uint256 right, string memory err) internal pure virtual;
assertNotEqDecimal
function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals) internal pure virtual;
assertNotEqDecimal
function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(int256 left, int256 right) internal pure virtual;
assertNotEq
function assertNotEq(int256 left, int256 right, string memory err) internal pure virtual;
assertNotEqDecimal
function assertNotEqDecimal(int256 left, int256 right, uint256 decimals) internal pure virtual;
assertNotEqDecimal
function assertNotEqDecimal(int256 left, int256 right, uint256 decimals, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(address left, address right) internal pure virtual;
assertNotEq
function assertNotEq(address left, address right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(bytes32 left, bytes32 right) internal pure virtual;
assertNotEq
function assertNotEq(bytes32 left, bytes32 right, string memory err) internal pure virtual;
assertNotEq32
function assertNotEq32(bytes32 left, bytes32 right) internal pure virtual;
assertNotEq32
function assertNotEq32(bytes32 left, bytes32 right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(string memory left, string memory right) internal pure virtual;
assertNotEq
function assertNotEq(string memory left, string memory right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(bytes memory left, bytes memory right) internal pure virtual;
assertNotEq
function assertNotEq(bytes memory left, bytes memory right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(bool[] memory left, bool[] memory right) internal pure virtual;
assertNotEq
function assertNotEq(bool[] memory left, bool[] memory right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(uint256[] memory left, uint256[] memory right) internal pure virtual;
assertNotEq
function assertNotEq(uint256[] memory left, uint256[] memory right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(int256[] memory left, int256[] memory right) internal pure virtual;
assertNotEq
function assertNotEq(int256[] memory left, int256[] memory right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(address[] memory left, address[] memory right) internal pure virtual;
assertNotEq
function assertNotEq(address[] memory left, address[] memory right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(bytes32[] memory left, bytes32[] memory right) internal pure virtual;
assertNotEq
function assertNotEq(bytes32[] memory left, bytes32[] memory right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(string[] memory left, string[] memory right) internal pure virtual;
assertNotEq
function assertNotEq(string[] memory left, string[] memory right, string memory err) internal pure virtual;
assertNotEq
function assertNotEq(bytes[] memory left, bytes[] memory right) internal pure virtual;
assertNotEq
function assertNotEq(bytes[] memory left, bytes[] memory right, string memory err) internal pure virtual;
assertLt
function assertLt(uint256 left, uint256 right) internal pure virtual;
assertLt
function assertLt(uint256 left, uint256 right, string memory err) internal pure virtual;
assertLtDecimal
function assertLtDecimal(uint256 left, uint256 right, uint256 decimals) internal pure virtual;
assertLtDecimal
function assertLtDecimal(uint256 left, uint256 right, uint256 decimals, string memory err) internal pure virtual;
assertLt
function assertLt(int256 left, int256 right) internal pure virtual;
assertLt
function assertLt(int256 left, int256 right, string memory err) internal pure virtual;
assertLtDecimal
function assertLtDecimal(int256 left, int256 right, uint256 decimals) internal pure virtual;
assertLtDecimal
function assertLtDecimal(int256 left, int256 right, uint256 decimals, string memory err) internal pure virtual;
assertGt
function assertGt(uint256 left, uint256 right) internal pure virtual;
assertGt
function assertGt(uint256 left, uint256 right, string memory err) internal pure virtual;
assertGtDecimal
function assertGtDecimal(uint256 left, uint256 right, uint256 decimals) internal pure virtual;
assertGtDecimal
function assertGtDecimal(uint256 left, uint256 right, uint256 decimals, string memory err) internal pure virtual;
assertGt
function assertGt(int256 left, int256 right) internal pure virtual;
assertGt
function assertGt(int256 left, int256 right, string memory err) internal pure virtual;
assertGtDecimal
function assertGtDecimal(int256 left, int256 right, uint256 decimals) internal pure virtual;
assertGtDecimal
function assertGtDecimal(int256 left, int256 right, uint256 decimals, string memory err) internal pure virtual;
assertLe
function assertLe(uint256 left, uint256 right) internal pure virtual;
assertLe
function assertLe(uint256 left, uint256 right, string memory err) internal pure virtual;
assertLeDecimal
function assertLeDecimal(uint256 left, uint256 right, uint256 decimals) internal pure virtual;
assertLeDecimal
function assertLeDecimal(uint256 left, uint256 right, uint256 decimals, string memory err) internal pure virtual;
assertLe
function assertLe(int256 left, int256 right) internal pure virtual;
assertLe
function assertLe(int256 left, int256 right, string memory err) internal pure virtual;
assertLeDecimal
function assertLeDecimal(int256 left, int256 right, uint256 decimals) internal pure virtual;
assertLeDecimal
function assertLeDecimal(int256 left, int256 right, uint256 decimals, string memory err) internal pure virtual;
assertGe
function assertGe(uint256 left, uint256 right) internal pure virtual;
assertGe
function assertGe(uint256 left, uint256 right, string memory err) internal pure virtual;
assertGeDecimal
function assertGeDecimal(uint256 left, uint256 right, uint256 decimals) internal pure virtual;
assertGeDecimal
function assertGeDecimal(uint256 left, uint256 right, uint256 decimals, string memory err) internal pure virtual;
assertGe
function assertGe(int256 left, int256 right) internal pure virtual;
assertGe
function assertGe(int256 left, int256 right, string memory err) internal pure virtual;
assertGeDecimal
function assertGeDecimal(int256 left, int256 right, uint256 decimals) internal pure virtual;
assertGeDecimal
function assertGeDecimal(int256 left, int256 right, uint256 decimals, string memory err) internal pure virtual;
assertApproxEqAbs
function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta) internal pure virtual;
assertApproxEqAbs
function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta, string memory err) internal pure virtual;
assertApproxEqAbsDecimal
function assertApproxEqAbsDecimal(uint256 left, uint256 right, uint256 maxDelta, uint256 decimals)
internal
pure
virtual;
assertApproxEqAbsDecimal
function assertApproxEqAbsDecimal(uint256 left, uint256 right, uint256 maxDelta, uint256 decimals, string memory err)
internal
pure
virtual;
assertApproxEqAbs
function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta) internal pure virtual;
assertApproxEqAbs
function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta, string memory err) internal pure virtual;
assertApproxEqAbsDecimal
function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals)
internal
pure
virtual;
assertApproxEqAbsDecimal
function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals, string memory err)
internal
pure
virtual;
assertApproxEqRel
function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta) internal pure virtual;
assertApproxEqRel
function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta, string memory err)
internal
pure
virtual;
assertApproxEqRelDecimal
function assertApproxEqRelDecimal(uint256 left, uint256 right, uint256 maxPercentDelta, uint256 decimals)
internal
pure
virtual;
assertApproxEqRelDecimal
function assertApproxEqRelDecimal(
uint256 left,
uint256 right,
uint256 maxPercentDelta,
uint256 decimals,
string memory err
) internal pure virtual;
assertApproxEqRel
function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta) internal pure virtual;
assertApproxEqRel
function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta, string memory err)
internal
pure
virtual;
assertApproxEqRelDecimal
function assertApproxEqRelDecimal(int256 left, int256 right, uint256 maxPercentDelta, uint256 decimals)
internal
pure
virtual;
assertApproxEqRelDecimal
function assertApproxEqRelDecimal(
int256 left,
int256 right,
uint256 maxPercentDelta,
uint256 decimals,
string memory err
) internal pure virtual;
checkEq0
function checkEq0(bytes memory left, bytes memory right) internal pure returns (bool);
assertEq0
function assertEq0(bytes memory left, bytes memory right) internal pure virtual;
assertEq0
function assertEq0(bytes memory left, bytes memory right, string memory err) internal pure virtual;
assertNotEq0
function assertNotEq0(bytes memory left, bytes memory right) internal pure virtual;
assertNotEq0
function assertNotEq0(bytes memory left, bytes memory right, string memory err) internal pure virtual;
assertEqCall
function assertEqCall(address target, bytes memory callDataA, bytes memory callDataB) internal virtual;
assertEqCall
function assertEqCall(address targetA, bytes memory callDataA, address targetB, bytes memory callDataB)
internal
virtual;
assertEqCall
function assertEqCall(address target, bytes memory callDataA, bytes memory callDataB, bool strictRevertData)
internal
virtual;
assertEqCall
function assertEqCall(
address targetA,
bytes memory callDataA,
address targetB,
bytes memory callDataB,
bool strictRevertData
) internal virtual;
Events
log
event log(string);
logs
event logs(bytes);
log_address
event log_address(address);
log_bytes32
event log_bytes32(bytes32);
log_int
event log_int(int256);
log_uint
event log_uint(uint256);
log_bytes
event log_bytes(bytes);
log_string
event log_string(string);
log_named_address
event log_named_address(string key, address val);
log_named_bytes32
event log_named_bytes32(string key, bytes32 val);
log_named_decimal_int
event log_named_decimal_int(string key, int256 val, uint256 decimals);
log_named_decimal_uint
event log_named_decimal_uint(string key, uint256 val, uint256 decimals);
log_named_int
event log_named_int(string key, int256 val);
log_named_uint
event log_named_uint(string key, uint256 val);
log_named_bytes
event log_named_bytes(string key, bytes val);
log_named_string
event log_named_string(string key, string val);
log_array
event log_array(uint256[] val);
log_array
event log_array(int256[] val);
log_array
event log_array(address[] val);
log_named_array
event log_named_array(string key, uint256[] val);
log_named_array
event log_named_array(string key, int256[] val);
log_named_array
event log_named_array(string key, address[] val);
StdChains
StdChains provides information about EVM compatible chains that can be used in scripts/tests.
For each chain, the chain's name, chain ID, and a default RPC URL are provided. Chains are
identified by their alias, which is the same as the alias in the [rpc_endpoints] section of
the foundry.toml file. For best UX, ensure the alias in the foundry.toml file match the
alias used in this contract, which can be found as the first argument to the
setChainWithDefaultRpcUrl call in the initializeStdChains function.
There are two main ways to use this contract:
- Set a chain with
setChain(string memory chainAlias, ChainData memory chain)orsetChain(string memory chainAlias, Chain memory chain) - Get a chain with
getChain(string memory chainAlias)orgetChain(uint256 chainId). The first time either of those are used, chains are initialized with the default set of RPC URLs. This is done ininitializeStdChains, which usessetChainWithDefaultRpcUrl. Defaults are recorded indefaultRpcUrls. ThesetChainfunction is straightforward, and it simply saves off the given chain data. ThegetChainmethods usegetChainWithUpdatedRpcUrlto return a chain. For example, let's say we want to retrieve the RPC URL formainnet:
- If you have specified data with
setChain, it will return that. - If you have configured a mainnet RPC URL in
foundry.toml, it will return the URL, provided it is valid (e.g. a URL is specified, or an environment variable is given and exists). - If neither of the above conditions is met, the default data is returned.
Summarizing the above, the prioritization hierarchy is
setChain->foundry.toml-> environment variable -> defaults.
State Variables
vm
VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));
stdChainsInitialized
bool private stdChainsInitialized;
chains
mapping(string => Chain) private chains;
defaultRpcUrls
mapping(string => string) private defaultRpcUrls;
idToAlias
mapping(uint256 => string) private idToAlias;
fallbackToDefaultRpcUrls
bool private fallbackToDefaultRpcUrls = true;
Functions
getChain
function getChain(string memory chainAlias) internal virtual returns (Chain memory chain);
getChain
function getChain(uint256 chainId) internal virtual returns (Chain memory chain);
setChain
function setChain(string memory chainAlias, ChainData memory chain) internal virtual;
setChain
function setChain(string memory chainAlias, Chain memory chain) internal virtual;
_toUpper
function _toUpper(string memory str) private pure returns (string memory);
getChainWithUpdatedRpcUrl
function getChainWithUpdatedRpcUrl(string memory chainAlias, Chain memory chain) private view returns (Chain memory);
setFallbackToDefaultRpcUrls
function setFallbackToDefaultRpcUrls(bool useDefault) internal;
initializeStdChains
function initializeStdChains() private;
setChainWithDefaultRpcUrl
function setChainWithDefaultRpcUrl(string memory chainAlias, ChainData memory chain) private;
Structs
ChainData
struct ChainData {
string name;
uint256 chainId;
string rpcUrl;
}
Chain
struct Chain {
string name;
uint256 chainId;
string chainAlias;
string rpcUrl;
}
StdCheatsSafe
State Variables
vm
Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));
UINT256_MAX
uint256 private constant UINT256_MAX = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
gasMeteringOff
bool private gasMeteringOff;
Functions
assumeNotBlacklisted
function assumeNotBlacklisted(address token, address addr) internal view virtual;
assumeNoBlacklisted
function assumeNoBlacklisted(address token, address addr) internal view virtual;
assumeAddressIsNot
function assumeAddressIsNot(address addr, AddressType addressType) internal virtual;
assumeAddressIsNot
function assumeAddressIsNot(address addr, AddressType addressType1, AddressType addressType2) internal virtual;
assumeAddressIsNot
function assumeAddressIsNot(address addr, AddressType addressType1, AddressType addressType2, AddressType addressType3)
internal
virtual;
assumeAddressIsNot
function assumeAddressIsNot(
address addr,
AddressType addressType1,
AddressType addressType2,
AddressType addressType3,
AddressType addressType4
) internal virtual;
_isPayable
function _isPayable(address addr) private returns (bool);
assumePayable
function assumePayable(address addr) internal virtual;
assumeNotPayable
function assumeNotPayable(address addr) internal virtual;
assumeNotZeroAddress
function assumeNotZeroAddress(address addr) internal pure virtual;
assumeNotPrecompile
function assumeNotPrecompile(address addr) internal pure virtual;
assumeNotPrecompile
function assumeNotPrecompile(address addr, uint256 chainId) internal pure virtual;
assumeNotForgeAddress
function assumeNotForgeAddress(address addr) internal pure virtual;
assumeUnusedAddress
function assumeUnusedAddress(address addr) internal view virtual;
readEIP1559ScriptArtifact
function readEIP1559ScriptArtifact(string memory path) internal view virtual returns (EIP1559ScriptArtifact memory);
rawToConvertedEIPTx1559s
function rawToConvertedEIPTx1559s(RawTx1559[] memory rawTxs) internal pure virtual returns (Tx1559[] memory);
rawToConvertedEIPTx1559
function rawToConvertedEIPTx1559(RawTx1559 memory rawTx) internal pure virtual returns (Tx1559 memory);
rawToConvertedEIP1559Detail
function rawToConvertedEIP1559Detail(RawTx1559Detail memory rawDetail)
internal
pure
virtual
returns (Tx1559Detail memory);
readTx1559s
function readTx1559s(string memory path) internal view virtual returns (Tx1559[] memory);
readTx1559
function readTx1559(string memory path, uint256 index) internal view virtual returns (Tx1559 memory);
readReceipts
function readReceipts(string memory path) internal view virtual returns (Receipt[] memory);
readReceipt
function readReceipt(string memory path, uint256 index) internal view virtual returns (Receipt memory);
rawToConvertedReceipts
function rawToConvertedReceipts(RawReceipt[] memory rawReceipts) internal pure virtual returns (Receipt[] memory);
rawToConvertedReceipt
function rawToConvertedReceipt(RawReceipt memory rawReceipt) internal pure virtual returns (Receipt memory);
rawToConvertedReceiptLogs
function rawToConvertedReceiptLogs(RawReceiptLog[] memory rawLogs)
internal
pure
virtual
returns (ReceiptLog[] memory);
deployCode
function deployCode(string memory what, bytes memory args) internal virtual returns (address addr);
deployCode
function deployCode(string memory what) internal virtual returns (address addr);
deployCode
deploy contract with value on construction
function deployCode(string memory what, bytes memory args, uint256 val) internal virtual returns (address addr);
deployCode
function deployCode(string memory what, uint256 val) internal virtual returns (address addr);
makeAddrAndKey
function makeAddrAndKey(string memory name) internal virtual returns (address addr, uint256 privateKey);
makeAddr
function makeAddr(string memory name) internal virtual returns (address addr);
destroyAccount
function destroyAccount(address who, address beneficiary) internal virtual;
makeAccount
function makeAccount(string memory name) internal virtual returns (Account memory account);
deriveRememberKey
function deriveRememberKey(string memory mnemonic, uint32 index)
internal
virtual
returns (address who, uint256 privateKey);
_bytesToUint
function _bytesToUint(bytes memory b) private pure returns (uint256);
isFork
function isFork() internal view virtual returns (bool status);
skipWhenForking
modifier skipWhenForking();
skipWhenNotForking
modifier skipWhenNotForking();
noGasMetering
modifier noGasMetering();
_viewChainId
function _viewChainId() private view returns (uint256 chainId);
_pureChainId
function _pureChainId() private pure returns (uint256 chainId);
Structs
RawTx1559
struct RawTx1559 {
string[] arguments;
address contractAddress;
string contractName;
string functionSig;
bytes32 hash;
RawTx1559Detail txDetail;
string opcode;
}
RawTx1559Detail
struct RawTx1559Detail {
AccessList[] accessList;
bytes data;
address from;
bytes gas;
bytes nonce;
address to;
bytes txType;
bytes value;
}
Tx1559
struct Tx1559 {
string[] arguments;
address contractAddress;
string contractName;
string functionSig;
bytes32 hash;
Tx1559Detail txDetail;
string opcode;
}
Tx1559Detail
struct Tx1559Detail {
AccessList[] accessList;
bytes data;
address from;
uint256 gas;
uint256 nonce;
address to;
uint256 txType;
uint256 value;
}
TxLegacy
struct TxLegacy {
string[] arguments;
address contractAddress;
string contractName;
string functionSig;
string hash;
string opcode;
TxDetailLegacy transaction;
}
TxDetailLegacy
struct TxDetailLegacy {
AccessList[] accessList;
uint256 chainId;
bytes data;
address from;
uint256 gas;
uint256 gasPrice;
bytes32 hash;
uint256 nonce;
bytes1 opcode;
bytes32 r;
bytes32 s;
uint256 txType;
address to;
uint8 v;
uint256 value;
}
AccessList
struct AccessList {
address accessAddress;
bytes32[] storageKeys;
}
RawReceipt
struct RawReceipt {
bytes32 blockHash;
bytes blockNumber;
address contractAddress;
bytes cumulativeGasUsed;
bytes effectiveGasPrice;
address from;
bytes gasUsed;
RawReceiptLog[] logs;
bytes logsBloom;
bytes status;
address to;
bytes32 transactionHash;
bytes transactionIndex;
}
Receipt
struct Receipt {
bytes32 blockHash;
uint256 blockNumber;
address contractAddress;
uint256 cumulativeGasUsed;
uint256 effectiveGasPrice;
address from;
uint256 gasUsed;
ReceiptLog[] logs;
bytes logsBloom;
uint256 status;
address to;
bytes32 transactionHash;
uint256 transactionIndex;
}
EIP1559ScriptArtifact
struct EIP1559ScriptArtifact {
string[] libraries;
string path;
string[] pending;
Receipt[] receipts;
uint256 timestamp;
Tx1559[] transactions;
TxReturn[] txReturns;
}
RawEIP1559ScriptArtifact
struct RawEIP1559ScriptArtifact {
string[] libraries;
string path;
string[] pending;
RawReceipt[] receipts;
TxReturn[] txReturns;
uint256 timestamp;
RawTx1559[] transactions;
}
RawReceiptLog
struct RawReceiptLog {
address logAddress;
bytes32 blockHash;
bytes blockNumber;
bytes data;
bytes logIndex;
bool removed;
bytes32[] topics;
bytes32 transactionHash;
bytes transactionIndex;
bytes transactionLogIndex;
}
ReceiptLog
struct ReceiptLog {
address logAddress;
bytes32 blockHash;
uint256 blockNumber;
bytes data;
uint256 logIndex;
bytes32[] topics;
uint256 transactionIndex;
uint256 transactionLogIndex;
bool removed;
}
TxReturn
struct TxReturn {
string internalType;
string value;
}
Account
struct Account {
address addr;
uint256 key;
}
Enums
AddressType
enum AddressType {
Payable,
NonPayable,
ZeroAddress,
Precompile,
ForgeAddress
}
StdCheats
Inherits: StdCheatsSafe
State Variables
stdstore
StdStorage private stdstore;
vm
Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));
CONSOLE2_ADDRESS
address private constant CONSOLE2_ADDRESS = 0x000000000000000000636F6e736F6c652e6c6f67;
Functions
skip
function skip(uint256 time) internal virtual;
rewind
function rewind(uint256 time) internal virtual;
hoax
function hoax(address msgSender) internal virtual;
hoax
function hoax(address msgSender, uint256 give) internal virtual;
hoax
function hoax(address msgSender, address origin) internal virtual;
hoax
function hoax(address msgSender, address origin, uint256 give) internal virtual;
startHoax
function startHoax(address msgSender) internal virtual;
startHoax
function startHoax(address msgSender, uint256 give) internal virtual;
startHoax
function startHoax(address msgSender, address origin) internal virtual;
startHoax
function startHoax(address msgSender, address origin, uint256 give) internal virtual;
changePrank
function changePrank(address msgSender) internal virtual;
changePrank
function changePrank(address msgSender, address txOrigin) internal virtual;
deal
function deal(address to, uint256 give) internal virtual;
deal
function deal(address token, address to, uint256 give) internal virtual;
dealERC1155
function dealERC1155(address token, address to, uint256 id, uint256 give) internal virtual;
deal
function deal(address token, address to, uint256 give, bool adjust) internal virtual;
dealERC1155
function dealERC1155(address token, address to, uint256 id, uint256 give, bool adjust) internal virtual;
dealERC721
function dealERC721(address token, address to, uint256 id) internal virtual;
deployCodeTo
function deployCodeTo(string memory what, address where) internal virtual;
deployCodeTo
function deployCodeTo(string memory what, bytes memory args, address where) internal virtual;
deployCodeTo
function deployCodeTo(string memory what, bytes memory args, uint256 value, address where) internal virtual;
console2_log_StdCheats
function console2_log_StdCheats(string memory p0) private view;
stdError
State Variables
assertionError
bytes public constant assertionError = abi.encodeWithSignature("Panic(uint256)", 0x01);
arithmeticError
bytes public constant arithmeticError = abi.encodeWithSignature("Panic(uint256)", 0x11);
divisionError
bytes public constant divisionError = abi.encodeWithSignature("Panic(uint256)", 0x12);
enumConversionError
bytes public constant enumConversionError = abi.encodeWithSignature("Panic(uint256)", 0x21);
encodeStorageError
bytes public constant encodeStorageError = abi.encodeWithSignature("Panic(uint256)", 0x22);
popError
bytes public constant popError = abi.encodeWithSignature("Panic(uint256)", 0x31);
indexOOBError
bytes public constant indexOOBError = abi.encodeWithSignature("Panic(uint256)", 0x32);
memOverflowError
bytes public constant memOverflowError = abi.encodeWithSignature("Panic(uint256)", 0x41);
zeroVarError
bytes public constant zeroVarError = abi.encodeWithSignature("Panic(uint256)", 0x51);
StdInvariant
State Variables
_excludedContracts
address[] private _excludedContracts;
_excludedSenders
address[] private _excludedSenders;
_targetedContracts
address[] private _targetedContracts;
_targetedSenders
address[] private _targetedSenders;
_excludedArtifacts
string[] private _excludedArtifacts;
_targetedArtifacts
string[] private _targetedArtifacts;
_targetedArtifactSelectors
FuzzArtifactSelector[] private _targetedArtifactSelectors;
_excludedSelectors
FuzzSelector[] private _excludedSelectors;
_targetedSelectors
FuzzSelector[] private _targetedSelectors;
_targetedInterfaces
FuzzInterface[] private _targetedInterfaces;
Functions
excludeContract
function excludeContract(address newExcludedContract_) internal;
excludeSelector
function excludeSelector(FuzzSelector memory newExcludedSelector_) internal;
excludeSender
function excludeSender(address newExcludedSender_) internal;
excludeArtifact
function excludeArtifact(string memory newExcludedArtifact_) internal;
targetArtifact
function targetArtifact(string memory newTargetedArtifact_) internal;
targetArtifactSelector
function targetArtifactSelector(FuzzArtifactSelector memory newTargetedArtifactSelector_) internal;
targetContract
function targetContract(address newTargetedContract_) internal;
targetSelector
function targetSelector(FuzzSelector memory newTargetedSelector_) internal;
targetSender
function targetSender(address newTargetedSender_) internal;
targetInterface
function targetInterface(FuzzInterface memory newTargetedInterface_) internal;
excludeArtifacts
function excludeArtifacts() public view returns (string[] memory excludedArtifacts_);
excludeContracts
function excludeContracts() public view returns (address[] memory excludedContracts_);
excludeSelectors
function excludeSelectors() public view returns (FuzzSelector[] memory excludedSelectors_);
excludeSenders
function excludeSenders() public view returns (address[] memory excludedSenders_);
targetArtifacts
function targetArtifacts() public view returns (string[] memory targetedArtifacts_);
targetArtifactSelectors
function targetArtifactSelectors() public view returns (FuzzArtifactSelector[] memory targetedArtifactSelectors_);
targetContracts
function targetContracts() public view returns (address[] memory targetedContracts_);
targetSelectors
function targetSelectors() public view returns (FuzzSelector[] memory targetedSelectors_);
targetSenders
function targetSenders() public view returns (address[] memory targetedSenders_);
targetInterfaces
function targetInterfaces() public view returns (FuzzInterface[] memory targetedInterfaces_);
Structs
FuzzSelector
struct FuzzSelector {
address addr;
bytes4[] selectors;
}
FuzzArtifactSelector
struct FuzzArtifactSelector {
string artifact;
bytes4[] selectors;
}
FuzzInterface
struct FuzzInterface {
address addr;
string[] artifacts;
}
stdJson
State Variables
vm
VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));
Functions
keyExists
function keyExists(string memory json, string memory key) internal view returns (bool);
parseRaw
function parseRaw(string memory json, string memory key) internal pure returns (bytes memory);
readUint
function readUint(string memory json, string memory key) internal pure returns (uint256);
readUintArray
function readUintArray(string memory json, string memory key) internal pure returns (uint256[] memory);
readInt
function readInt(string memory json, string memory key) internal pure returns (int256);
readIntArray
function readIntArray(string memory json, string memory key) internal pure returns (int256[] memory);
readBytes32
function readBytes32(string memory json, string memory key) internal pure returns (bytes32);
readBytes32Array
function readBytes32Array(string memory json, string memory key) internal pure returns (bytes32[] memory);
readString
function readString(string memory json, string memory key) internal pure returns (string memory);
readStringArray
function readStringArray(string memory json, string memory key) internal pure returns (string[] memory);
readAddress
function readAddress(string memory json, string memory key) internal pure returns (address);
readAddressArray
function readAddressArray(string memory json, string memory key) internal pure returns (address[] memory);
readBool
function readBool(string memory json, string memory key) internal pure returns (bool);
readBoolArray
function readBoolArray(string memory json, string memory key) internal pure returns (bool[] memory);
readBytes
function readBytes(string memory json, string memory key) internal pure returns (bytes memory);
readBytesArray
function readBytesArray(string memory json, string memory key) internal pure returns (bytes[] memory);
readUintOr
function readUintOr(string memory json, string memory key, uint256 defaultValue) internal view returns (uint256);
readUintArrayOr
function readUintArrayOr(string memory json, string memory key, uint256[] memory defaultValue)
internal
view
returns (uint256[] memory);
readIntOr
function readIntOr(string memory json, string memory key, int256 defaultValue) internal view returns (int256);
readIntArrayOr
function readIntArrayOr(string memory json, string memory key, int256[] memory defaultValue)
internal
view
returns (int256[] memory);
readBytes32Or
function readBytes32Or(string memory json, string memory key, bytes32 defaultValue) internal view returns (bytes32);
readBytes32ArrayOr
function readBytes32ArrayOr(string memory json, string memory key, bytes32[] memory defaultValue)
internal
view
returns (bytes32[] memory);
readStringOr
function readStringOr(string memory json, string memory key, string memory defaultValue)
internal
view
returns (string memory);
readStringArrayOr
function readStringArrayOr(string memory json, string memory key, string[] memory defaultValue)
internal
view
returns (string[] memory);
readAddressOr
function readAddressOr(string memory json, string memory key, address defaultValue) internal view returns (address);
readAddressArrayOr
function readAddressArrayOr(string memory json, string memory key, address[] memory defaultValue)
internal
view
returns (address[] memory);
readBoolOr
function readBoolOr(string memory json, string memory key, bool defaultValue) internal view returns (bool);
readBoolArrayOr
function readBoolArrayOr(string memory json, string memory key, bool[] memory defaultValue)
internal
view
returns (bool[] memory);
readBytesOr
function readBytesOr(string memory json, string memory key, bytes memory defaultValue)
internal
view
returns (bytes memory);
readBytesArrayOr
function readBytesArrayOr(string memory json, string memory key, bytes[] memory defaultValue)
internal
view
returns (bytes[] memory);
serialize
function serialize(string memory jsonKey, string memory rootObject) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bool value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bool[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, uint256 value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, uint256[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, int256 value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, int256[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, address value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, address[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bytes32 value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bytes32[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bytes memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bytes[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, string memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, string[] memory value) internal returns (string memory);
write
function write(string memory jsonKey, string memory path) internal;
write
function write(string memory jsonKey, string memory path, string memory valueKey) internal;
stdMath
State Variables
INT256_MIN
int256 private constant INT256_MIN = -57896044618658097711785492504343953926634992332820282019728792003956564819968;
Functions
abs
function abs(int256 a) internal pure returns (uint256);
delta
function delta(uint256 a, uint256 b) internal pure returns (uint256);
delta
function delta(int256 a, int256 b) internal pure returns (uint256);
percentDelta
function percentDelta(uint256 a, uint256 b) internal pure returns (uint256);
percentDelta
function percentDelta(int256 a, int256 b) internal pure returns (uint256);
FindData
struct FindData {
uint256 slot;
uint256 offsetLeft;
uint256 offsetRight;
bool found;
}
StdStorage
struct StdStorage {
mapping(address => mapping(bytes4 => mapping(bytes32 => FindData))) finds;
bytes32[] _keys;
bytes4 _sig;
uint256 _depth;
address _target;
bytes32 _set;
bool _enable_packed_slots;
bytes _calldata;
}
stdStorageSafe
State Variables
vm
Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));
UINT256_MAX
uint256 constant UINT256_MAX = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
Functions
sigs
function sigs(string memory sigStr) internal pure returns (bytes4);
getCallParams
function getCallParams(StdStorage storage self) internal view returns (bytes memory);
callTarget
function callTarget(StdStorage storage self) internal view returns (bool, bytes32);
checkSlotMutatesCall
function checkSlotMutatesCall(StdStorage storage self, bytes32 slot) internal returns (bool);
findOffset
function findOffset(StdStorage storage self, bytes32 slot, bool left) internal returns (bool, uint256);
findOffsets
function findOffsets(StdStorage storage self, bytes32 slot) internal returns (bool, uint256, uint256);
find
function find(StdStorage storage self) internal returns (FindData storage);
find
find an arbitrary storage slot given a function sig, input data, address of the contract and a value to check against
function find(StdStorage storage self, bool _clear) internal returns (FindData storage);
target
function target(StdStorage storage self, address _target) internal returns (StdStorage storage);
sig
function sig(StdStorage storage self, bytes4 _sig) internal returns (StdStorage storage);
sig
function sig(StdStorage storage self, string memory _sig) internal returns (StdStorage storage);
with_calldata
function with_calldata(StdStorage storage self, bytes memory _calldata) internal returns (StdStorage storage);
with_key
function with_key(StdStorage storage self, address who) internal returns (StdStorage storage);
with_key
function with_key(StdStorage storage self, uint256 amt) internal returns (StdStorage storage);
with_key
function with_key(StdStorage storage self, bytes32 key) internal returns (StdStorage storage);
enable_packed_slots
function enable_packed_slots(StdStorage storage self) internal returns (StdStorage storage);
depth
function depth(StdStorage storage self, uint256 _depth) internal returns (StdStorage storage);
read
function read(StdStorage storage self) private returns (bytes memory);
read_bytes32
function read_bytes32(StdStorage storage self) internal returns (bytes32);
read_bool
function read_bool(StdStorage storage self) internal returns (bool);
read_address
function read_address(StdStorage storage self) internal returns (address);
read_uint
function read_uint(StdStorage storage self) internal returns (uint256);
read_int
function read_int(StdStorage storage self) internal returns (int256);
parent
function parent(StdStorage storage self) internal returns (uint256, bytes32);
root
function root(StdStorage storage self) internal returns (uint256);
bytesToBytes32
function bytesToBytes32(bytes memory b, uint256 offset) private pure returns (bytes32);
flatten
function flatten(bytes32[] memory b) private pure returns (bytes memory);
clear
function clear(StdStorage storage self) internal;
getMaskByOffsets
function getMaskByOffsets(uint256 offsetLeft, uint256 offsetRight) internal pure returns (uint256 mask);
getUpdatedSlotValue
function getUpdatedSlotValue(bytes32 curValue, uint256 varValue, uint256 offsetLeft, uint256 offsetRight)
internal
pure
returns (bytes32 newValue);
Events
SlotFound
event SlotFound(address who, bytes4 fsig, bytes32 keysHash, uint256 slot);
WARNING_UninitedSlot
event WARNING_UninitedSlot(address who, uint256 slot);
stdStorage
State Variables
vm
Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));
Functions
sigs
function sigs(string memory sigStr) internal pure returns (bytes4);
find
function find(StdStorage storage self) internal returns (uint256);
find
function find(StdStorage storage self, bool _clear) internal returns (uint256);
target
function target(StdStorage storage self, address _target) internal returns (StdStorage storage);
sig
function sig(StdStorage storage self, bytes4 _sig) internal returns (StdStorage storage);
sig
function sig(StdStorage storage self, string memory _sig) internal returns (StdStorage storage);
with_key
function with_key(StdStorage storage self, address who) internal returns (StdStorage storage);
with_key
function with_key(StdStorage storage self, uint256 amt) internal returns (StdStorage storage);
with_key
function with_key(StdStorage storage self, bytes32 key) internal returns (StdStorage storage);
with_calldata
function with_calldata(StdStorage storage self, bytes memory _calldata) internal returns (StdStorage storage);
enable_packed_slots
function enable_packed_slots(StdStorage storage self) internal returns (StdStorage storage);
depth
function depth(StdStorage storage self, uint256 _depth) internal returns (StdStorage storage);
clear
function clear(StdStorage storage self) internal;
checked_write
function checked_write(StdStorage storage self, address who) internal;
checked_write
function checked_write(StdStorage storage self, uint256 amt) internal;
checked_write_int
function checked_write_int(StdStorage storage self, int256 val) internal;
checked_write
function checked_write(StdStorage storage self, bool write) internal;
checked_write
function checked_write(StdStorage storage self, bytes32 set) internal;
read_bytes32
function read_bytes32(StdStorage storage self) internal returns (bytes32);
read_bool
function read_bool(StdStorage storage self) internal returns (bool);
read_address
function read_address(StdStorage storage self) internal returns (address);
read_uint
function read_uint(StdStorage storage self) internal returns (uint256);
read_int
function read_int(StdStorage storage self) internal returns (int256);
parent
function parent(StdStorage storage self) internal returns (uint256, bytes32);
root
function root(StdStorage storage self) internal returns (uint256);
StdStyle
State Variables
vm
VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));
RED
string constant RED = "\u001b[91m";
GREEN
string constant GREEN = "\u001b[92m";
YELLOW
string constant YELLOW = "\u001b[93m";
BLUE
string constant BLUE = "\u001b[94m";
MAGENTA
string constant MAGENTA = "\u001b[95m";
CYAN
string constant CYAN = "\u001b[96m";
BOLD
string constant BOLD = "\u001b[1m";
DIM
string constant DIM = "\u001b[2m";
ITALIC
string constant ITALIC = "\u001b[3m";
UNDERLINE
string constant UNDERLINE = "\u001b[4m";
INVERSE
string constant INVERSE = "\u001b[7m";
RESET
string constant RESET = "\u001b[0m";
Functions
styleConcat
function styleConcat(string memory style, string memory self) private pure returns (string memory);
red
function red(string memory self) internal pure returns (string memory);
red
function red(uint256 self) internal pure returns (string memory);
red
function red(int256 self) internal pure returns (string memory);
red
function red(address self) internal pure returns (string memory);
red
function red(bool self) internal pure returns (string memory);
redBytes
function redBytes(bytes memory self) internal pure returns (string memory);
redBytes32
function redBytes32(bytes32 self) internal pure returns (string memory);
green
function green(string memory self) internal pure returns (string memory);
green
function green(uint256 self) internal pure returns (string memory);
green
function green(int256 self) internal pure returns (string memory);
green
function green(address self) internal pure returns (string memory);
green
function green(bool self) internal pure returns (string memory);
greenBytes
function greenBytes(bytes memory self) internal pure returns (string memory);
greenBytes32
function greenBytes32(bytes32 self) internal pure returns (string memory);
yellow
function yellow(string memory self) internal pure returns (string memory);
yellow
function yellow(uint256 self) internal pure returns (string memory);
yellow
function yellow(int256 self) internal pure returns (string memory);
yellow
function yellow(address self) internal pure returns (string memory);
yellow
function yellow(bool self) internal pure returns (string memory);
yellowBytes
function yellowBytes(bytes memory self) internal pure returns (string memory);
yellowBytes32
function yellowBytes32(bytes32 self) internal pure returns (string memory);
blue
function blue(string memory self) internal pure returns (string memory);
blue
function blue(uint256 self) internal pure returns (string memory);
blue
function blue(int256 self) internal pure returns (string memory);
blue
function blue(address self) internal pure returns (string memory);
blue
function blue(bool self) internal pure returns (string memory);
blueBytes
function blueBytes(bytes memory self) internal pure returns (string memory);
blueBytes32
function blueBytes32(bytes32 self) internal pure returns (string memory);
magenta
function magenta(string memory self) internal pure returns (string memory);
magenta
function magenta(uint256 self) internal pure returns (string memory);
magenta
function magenta(int256 self) internal pure returns (string memory);
magenta
function magenta(address self) internal pure returns (string memory);
magenta
function magenta(bool self) internal pure returns (string memory);
magentaBytes
function magentaBytes(bytes memory self) internal pure returns (string memory);
magentaBytes32
function magentaBytes32(bytes32 self) internal pure returns (string memory);
cyan
function cyan(string memory self) internal pure returns (string memory);
cyan
function cyan(uint256 self) internal pure returns (string memory);
cyan
function cyan(int256 self) internal pure returns (string memory);
cyan
function cyan(address self) internal pure returns (string memory);
cyan
function cyan(bool self) internal pure returns (string memory);
cyanBytes
function cyanBytes(bytes memory self) internal pure returns (string memory);
cyanBytes32
function cyanBytes32(bytes32 self) internal pure returns (string memory);
bold
function bold(string memory self) internal pure returns (string memory);
bold
function bold(uint256 self) internal pure returns (string memory);
bold
function bold(int256 self) internal pure returns (string memory);
bold
function bold(address self) internal pure returns (string memory);
bold
function bold(bool self) internal pure returns (string memory);
boldBytes
function boldBytes(bytes memory self) internal pure returns (string memory);
boldBytes32
function boldBytes32(bytes32 self) internal pure returns (string memory);
dim
function dim(string memory self) internal pure returns (string memory);
dim
function dim(uint256 self) internal pure returns (string memory);
dim
function dim(int256 self) internal pure returns (string memory);
dim
function dim(address self) internal pure returns (string memory);
dim
function dim(bool self) internal pure returns (string memory);
dimBytes
function dimBytes(bytes memory self) internal pure returns (string memory);
dimBytes32
function dimBytes32(bytes32 self) internal pure returns (string memory);
italic
function italic(string memory self) internal pure returns (string memory);
italic
function italic(uint256 self) internal pure returns (string memory);
italic
function italic(int256 self) internal pure returns (string memory);
italic
function italic(address self) internal pure returns (string memory);
italic
function italic(bool self) internal pure returns (string memory);
italicBytes
function italicBytes(bytes memory self) internal pure returns (string memory);
italicBytes32
function italicBytes32(bytes32 self) internal pure returns (string memory);
underline
function underline(string memory self) internal pure returns (string memory);
underline
function underline(uint256 self) internal pure returns (string memory);
underline
function underline(int256 self) internal pure returns (string memory);
underline
function underline(address self) internal pure returns (string memory);
underline
function underline(bool self) internal pure returns (string memory);
underlineBytes
function underlineBytes(bytes memory self) internal pure returns (string memory);
underlineBytes32
function underlineBytes32(bytes32 self) internal pure returns (string memory);
inverse
function inverse(string memory self) internal pure returns (string memory);
inverse
function inverse(uint256 self) internal pure returns (string memory);
inverse
function inverse(int256 self) internal pure returns (string memory);
inverse
function inverse(address self) internal pure returns (string memory);
inverse
function inverse(bool self) internal pure returns (string memory);
inverseBytes
function inverseBytes(bytes memory self) internal pure returns (string memory);
inverseBytes32
function inverseBytes32(bytes32 self) internal pure returns (string memory);
stdToml
State Variables
vm
VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));
Functions
keyExists
function keyExists(string memory toml, string memory key) internal view returns (bool);
parseRaw
function parseRaw(string memory toml, string memory key) internal pure returns (bytes memory);
readUint
function readUint(string memory toml, string memory key) internal pure returns (uint256);
readUintArray
function readUintArray(string memory toml, string memory key) internal pure returns (uint256[] memory);
readInt
function readInt(string memory toml, string memory key) internal pure returns (int256);
readIntArray
function readIntArray(string memory toml, string memory key) internal pure returns (int256[] memory);
readBytes32
function readBytes32(string memory toml, string memory key) internal pure returns (bytes32);
readBytes32Array
function readBytes32Array(string memory toml, string memory key) internal pure returns (bytes32[] memory);
readString
function readString(string memory toml, string memory key) internal pure returns (string memory);
readStringArray
function readStringArray(string memory toml, string memory key) internal pure returns (string[] memory);
readAddress
function readAddress(string memory toml, string memory key) internal pure returns (address);
readAddressArray
function readAddressArray(string memory toml, string memory key) internal pure returns (address[] memory);
readBool
function readBool(string memory toml, string memory key) internal pure returns (bool);
readBoolArray
function readBoolArray(string memory toml, string memory key) internal pure returns (bool[] memory);
readBytes
function readBytes(string memory toml, string memory key) internal pure returns (bytes memory);
readBytesArray
function readBytesArray(string memory toml, string memory key) internal pure returns (bytes[] memory);
readUintOr
function readUintOr(string memory toml, string memory key, uint256 defaultValue) internal view returns (uint256);
readUintArrayOr
function readUintArrayOr(string memory toml, string memory key, uint256[] memory defaultValue)
internal
view
returns (uint256[] memory);
readIntOr
function readIntOr(string memory toml, string memory key, int256 defaultValue) internal view returns (int256);
readIntArrayOr
function readIntArrayOr(string memory toml, string memory key, int256[] memory defaultValue)
internal
view
returns (int256[] memory);
readBytes32Or
function readBytes32Or(string memory toml, string memory key, bytes32 defaultValue) internal view returns (bytes32);
readBytes32ArrayOr
function readBytes32ArrayOr(string memory toml, string memory key, bytes32[] memory defaultValue)
internal
view
returns (bytes32[] memory);
readStringOr
function readStringOr(string memory toml, string memory key, string memory defaultValue)
internal
view
returns (string memory);
readStringArrayOr
function readStringArrayOr(string memory toml, string memory key, string[] memory defaultValue)
internal
view
returns (string[] memory);
readAddressOr
function readAddressOr(string memory toml, string memory key, address defaultValue) internal view returns (address);
readAddressArrayOr
function readAddressArrayOr(string memory toml, string memory key, address[] memory defaultValue)
internal
view
returns (address[] memory);
readBoolOr
function readBoolOr(string memory toml, string memory key, bool defaultValue) internal view returns (bool);
readBoolArrayOr
function readBoolArrayOr(string memory toml, string memory key, bool[] memory defaultValue)
internal
view
returns (bool[] memory);
readBytesOr
function readBytesOr(string memory toml, string memory key, bytes memory defaultValue)
internal
view
returns (bytes memory);
readBytesArrayOr
function readBytesArrayOr(string memory toml, string memory key, bytes[] memory defaultValue)
internal
view
returns (bytes[] memory);
serialize
function serialize(string memory jsonKey, string memory rootObject) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bool value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bool[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, uint256 value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, uint256[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, int256 value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, int256[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, address value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, address[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bytes32 value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bytes32[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bytes memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, bytes[] memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, string memory value) internal returns (string memory);
serialize
function serialize(string memory jsonKey, string memory key, string[] memory value) internal returns (string memory);
write
function write(string memory jsonKey, string memory path) internal;
write
function write(string memory jsonKey, string memory path, string memory valueKey) internal;
StdUtils
State Variables
multicall
IMulticall3 private constant multicall = IMulticall3(0xcA11bde05977b3631167028862bE2a173976CA11);
vm
VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));
CONSOLE2_ADDRESS
address private constant CONSOLE2_ADDRESS = 0x000000000000000000636F6e736F6c652e6c6f67;
INT256_MIN_ABS
uint256 private constant INT256_MIN_ABS = 57896044618658097711785492504343953926634992332820282019728792003956564819968;
SECP256K1_ORDER
uint256 private constant SECP256K1_ORDER =
115792089237316195423570985008687907852837564279074904382605163141518161494337;
UINT256_MAX
uint256 private constant UINT256_MAX = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
CREATE2_FACTORY
address private constant CREATE2_FACTORY = 0x4e59b44847b379578588920cA78FbF26c0B4956C;
Functions
_bound
function _bound(uint256 x, uint256 min, uint256 max) internal pure virtual returns (uint256 result);
bound
function bound(uint256 x, uint256 min, uint256 max) internal pure virtual returns (uint256 result);
_bound
function _bound(int256 x, int256 min, int256 max) internal pure virtual returns (int256 result);
bound
function bound(int256 x, int256 min, int256 max) internal pure virtual returns (int256 result);
boundPrivateKey
function boundPrivateKey(uint256 privateKey) internal pure virtual returns (uint256 result);
bytesToUint
function bytesToUint(bytes memory b) internal pure virtual returns (uint256);
computeCreateAddress
adapted from Solmate implementation (https://github.com/Rari-Capital/solmate/blob/main/src/utils/LibRLP.sol)
Compute the address a contract will be deployed at for a given deployer address and nonce
function computeCreateAddress(address deployer, uint256 nonce) internal pure virtual returns (address);
computeCreate2Address
function computeCreate2Address(bytes32 salt, bytes32 initcodeHash, address deployer)
internal
pure
virtual
returns (address);
computeCreate2Address
returns the address of a contract created with CREATE2 using the default CREATE2 deployer
function computeCreate2Address(bytes32 salt, bytes32 initCodeHash) internal pure returns (address);
hashInitCode
returns the hash of the init code (creation code + no args) used in CREATE2 with no constructor arguments
function hashInitCode(bytes memory creationCode) internal pure returns (bytes32);
Parameters
| Name | Type | Description |
|---|---|---|
creationCode | bytes | the creation code of a contract C, as returned by type(C).creationCode |
hashInitCode
returns the hash of the init code (creation code + ABI-encoded args) used in CREATE2
function hashInitCode(bytes memory creationCode, bytes memory args) internal pure returns (bytes32);
Parameters
| Name | Type | Description |
|---|---|---|
creationCode | bytes | the creation code of a contract C, as returned by type(C).creationCode |
args | bytes | the ABI-encoded arguments to the constructor of C |
getTokenBalances
function getTokenBalances(address token, address[] memory addresses)
internal
virtual
returns (uint256[] memory balances);
addressFromLast20Bytes
function addressFromLast20Bytes(bytes32 bytesValue) private pure returns (address);
_castLogPayloadViewToPure
function _castLogPayloadViewToPure(function(bytes memory) internal view fnIn)
internal
pure
returns (function(bytes memory) internal pure fnOut);
_sendLogPayload
function _sendLogPayload(bytes memory payload) internal pure;
_sendLogPayloadView
function _sendLogPayloadView(bytes memory payload) private view;
console2_log_StdUtils
function console2_log_StdUtils(string memory p0) private pure;
console2_log_StdUtils
function console2_log_StdUtils(string memory p0, uint256 p1) private pure;
console2_log_StdUtils
function console2_log_StdUtils(string memory p0, string memory p1) private pure;
Test
Inherits: TestBase, StdAssertions, StdChains, StdCheats, StdInvariant, StdUtils
State Variables
IS_TEST
bool public IS_TEST = true;
VmSafe
The VmSafe interface does not allow manipulation of the EVM state or other actions that may
result in Script simulations differing from on-chain execution. It is recommended to only use
these cheats in scripts.
Functions
createWallet
Derives a private key from the name, labels the account with that name, and returns the wallet.
function createWallet(string calldata walletLabel) external returns (Wallet memory wallet);
createWallet
Generates a wallet from the private key and returns the wallet.
function createWallet(uint256 privateKey) external returns (Wallet memory wallet);
createWallet
Generates a wallet from the private key, labels the account with that name, and returns the wallet.
function createWallet(uint256 privateKey, string calldata walletLabel) external returns (Wallet memory wallet);
deriveKey
Derive a private key from a provided mnenomic string (or mnenomic file path)
at the derivation path m/44'/60'/0'/0/{index}.
function deriveKey(string calldata mnemonic, uint32 index) external pure returns (uint256 privateKey);
deriveKey
Derive a private key from a provided mnenomic string (or mnenomic file path)
at {derivationPath}{index}.
function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index)
external
pure
returns (uint256 privateKey);
deriveKey
Derive a private key from a provided mnenomic string (or mnenomic file path) in the specified language
at the derivation path m/44'/60'/0'/0/{index}.
function deriveKey(string calldata mnemonic, uint32 index, string calldata language)
external
pure
returns (uint256 privateKey);
deriveKey
Derive a private key from a provided mnenomic string (or mnenomic file path) in the specified language
at {derivationPath}{index}.
function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index, string calldata language)
external
pure
returns (uint256 privateKey);
publicKeyP256
Derives secp256r1 public key from the provided privateKey.
function publicKeyP256(uint256 privateKey) external pure returns (uint256 publicKeyX, uint256 publicKeyY);
rememberKey
Adds a private key to the local forge wallet and returns the address.
function rememberKey(uint256 privateKey) external returns (address keyAddr);
rememberKeys
Derive a set number of wallets from a mnemonic at the derivation path m/44'/60'/0'/0/{0..count}.
The respective private keys are saved to the local forge wallet for later use and their addresses are returned.
function rememberKeys(string calldata mnemonic, string calldata derivationPath, uint32 count)
external
returns (address[] memory keyAddrs);
rememberKeys
Derive a set number of wallets from a mnemonic in the specified language at the derivation path m/44'/60'/0'/0/{0..count}.
The respective private keys are saved to the local forge wallet for later use and their addresses are returned.
function rememberKeys(string calldata mnemonic, string calldata derivationPath, string calldata language, uint32 count)
external
returns (address[] memory keyAddrs);
signCompact
Signs data with a Wallet.
Returns a compact signature (r, vs) as per EIP-2098, where vs encodes both the
signature's s value, and the recovery id v in a single bytes32.
This format reduces the signature size from 65 to 64 bytes.
function signCompact(Wallet calldata wallet, bytes32 digest) external returns (bytes32 r, bytes32 vs);
signCompact
Signs digest with privateKey using the secp256k1 curve.
Returns a compact signature (r, vs) as per EIP-2098, where vs encodes both the
signature's s value, and the recovery id v in a single bytes32.
This format reduces the signature size from 65 to 64 bytes.
function signCompact(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
signCompact
Signs digest with signer provided to script using the secp256k1 curve.
Returns a compact signature (r, vs) as per EIP-2098, where vs encodes both the
signature's s value, and the recovery id v in a single bytes32.
This format reduces the signature size from 65 to 64 bytes.
If --sender is provided, the signer with provided address is used, otherwise,
if exactly one signer is provided to the script, that signer is used.
Raises error if signer passed through --sender does not match any unlocked signers or
if --sender is not provided and not exactly one signer is passed to the script.
function signCompact(bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
signCompact
Signs digest with signer provided to script using the secp256k1 curve.
Returns a compact signature (r, vs) as per EIP-2098, where vs encodes both the
signature's s value, and the recovery id v in a single bytes32.
This format reduces the signature size from 65 to 64 bytes.
Raises error if none of the signers passed into the script have provided address.
function signCompact(address signer, bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
signP256
Signs digest with privateKey using the secp256r1 curve.
function signP256(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 s);
sign
Signs data with a Wallet.
function sign(Wallet calldata wallet, bytes32 digest) external returns (uint8 v, bytes32 r, bytes32 s);
sign
Signs digest with privateKey using the secp256k1 curve.
function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
sign
Signs digest with signer provided to script using the secp256k1 curve.
If --sender is provided, the signer with provided address is used, otherwise,
if exactly one signer is provided to the script, that signer is used.
Raises error if signer passed through --sender does not match any unlocked signers or
if --sender is not provided and not exactly one signer is passed to the script.
function sign(bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
sign
Signs digest with signer provided to script using the secp256k1 curve.
Raises error if none of the signers passed into the script have provided address.
function sign(address signer, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
envAddress
Gets the environment variable name and parses it as address.
Reverts if the variable was not found or could not be parsed.
function envAddress(string calldata name) external view returns (address value);
envAddress
Gets the environment variable name and parses it as an array of address, delimited by delim.
Reverts if the variable was not found or could not be parsed.
function envAddress(string calldata name, string calldata delim) external view returns (address[] memory value);
envBool
Gets the environment variable name and parses it as bool.
Reverts if the variable was not found or could not be parsed.
function envBool(string calldata name) external view returns (bool value);
envBool
Gets the environment variable name and parses it as an array of bool, delimited by delim.
Reverts if the variable was not found or could not be parsed.
function envBool(string calldata name, string calldata delim) external view returns (bool[] memory value);
envBytes32
Gets the environment variable name and parses it as bytes32.
Reverts if the variable was not found or could not be parsed.
function envBytes32(string calldata name) external view returns (bytes32 value);
envBytes32
Gets the environment variable name and parses it as an array of bytes32, delimited by delim.
Reverts if the variable was not found or could not be parsed.
function envBytes32(string calldata name, string calldata delim) external view returns (bytes32[] memory value);
envBytes
Gets the environment variable name and parses it as bytes.
Reverts if the variable was not found or could not be parsed.
function envBytes(string calldata name) external view returns (bytes memory value);
envBytes
Gets the environment variable name and parses it as an array of bytes, delimited by delim.
Reverts if the variable was not found or could not be parsed.
function envBytes(string calldata name, string calldata delim) external view returns (bytes[] memory value);
envExists
Gets the environment variable name and returns true if it exists, else returns false.
function envExists(string calldata name) external view returns (bool result);
envInt
Gets the environment variable name and parses it as int256.
Reverts if the variable was not found or could not be parsed.
function envInt(string calldata name) external view returns (int256 value);
envInt
Gets the environment variable name and parses it as an array of int256, delimited by delim.
Reverts if the variable was not found or could not be parsed.
function envInt(string calldata name, string calldata delim) external view returns (int256[] memory value);
envOr
Gets the environment variable name and parses it as bool.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, bool defaultValue) external view returns (bool value);
envOr
Gets the environment variable name and parses it as uint256.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, uint256 defaultValue) external view returns (uint256 value);
envOr
Gets the environment variable name and parses it as an array of address, delimited by delim.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, string calldata delim, address[] calldata defaultValue)
external
view
returns (address[] memory value);
envOr
Gets the environment variable name and parses it as an array of bytes32, delimited by delim.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, string calldata delim, bytes32[] calldata defaultValue)
external
view
returns (bytes32[] memory value);
envOr
Gets the environment variable name and parses it as an array of string, delimited by delim.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, string calldata delim, string[] calldata defaultValue)
external
view
returns (string[] memory value);
envOr
Gets the environment variable name and parses it as an array of bytes, delimited by delim.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, string calldata delim, bytes[] calldata defaultValue)
external
view
returns (bytes[] memory value);
envOr
Gets the environment variable name and parses it as int256.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, int256 defaultValue) external view returns (int256 value);
envOr
Gets the environment variable name and parses it as address.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, address defaultValue) external view returns (address value);
envOr
Gets the environment variable name and parses it as bytes32.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, bytes32 defaultValue) external view returns (bytes32 value);
envOr
Gets the environment variable name and parses it as string.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, string calldata defaultValue) external view returns (string memory value);
envOr
Gets the environment variable name and parses it as bytes.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, bytes calldata defaultValue) external view returns (bytes memory value);
envOr
Gets the environment variable name and parses it as an array of bool, delimited by delim.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, string calldata delim, bool[] calldata defaultValue)
external
view
returns (bool[] memory value);
envOr
Gets the environment variable name and parses it as an array of uint256, delimited by delim.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, string calldata delim, uint256[] calldata defaultValue)
external
view
returns (uint256[] memory value);
envOr
Gets the environment variable name and parses it as an array of int256, delimited by delim.
Reverts if the variable could not be parsed.
Returns defaultValue if the variable was not found.
function envOr(string calldata name, string calldata delim, int256[] calldata defaultValue)
external
view
returns (int256[] memory value);
envString
Gets the environment variable name and parses it as string.
Reverts if the variable was not found or could not be parsed.
function envString(string calldata name) external view returns (string memory value);
envString
Gets the environment variable name and parses it as an array of string, delimited by delim.
Reverts if the variable was not found or could not be parsed.
function envString(string calldata name, string calldata delim) external view returns (string[] memory value);
envUint
Gets the environment variable name and parses it as uint256.
Reverts if the variable was not found or could not be parsed.
function envUint(string calldata name) external view returns (uint256 value);
envUint
Gets the environment variable name and parses it as an array of uint256, delimited by delim.
Reverts if the variable was not found or could not be parsed.
function envUint(string calldata name, string calldata delim) external view returns (uint256[] memory value);
isContext
Returns true if forge command was executed in given context.
function isContext(ForgeContext context) external view returns (bool result);
setEnv
Sets environment variables.
function setEnv(string calldata name, string calldata value) external;
accesses
Gets all accessed reads and write slot from a vm.record session, for a given address.
function accesses(address target) external returns (bytes32[] memory readSlots, bytes32[] memory writeSlots);
addr
Gets the address for a given private key.
function addr(uint256 privateKey) external pure returns (address keyAddr);
eth_getLogs
Gets all the logs according to specified filter.
function eth_getLogs(uint256 fromBlock, uint256 toBlock, address target, bytes32[] calldata topics)
external
returns (EthGetLogs[] memory logs);
getBlobBaseFee
Gets the current block.blobbasefee.
You should use this instead of block.blobbasefee if you use vm.blobBaseFee, as block.blobbasefee is assumed to be constant across a transaction,
and as a result will get optimized out by the compiler.
See https://github.com/foundry-rs/foundry/issues/6180
function getBlobBaseFee() external view returns (uint256 blobBaseFee);
getBlockNumber
Gets the current block.number.
You should use this instead of block.number if you use vm.roll, as block.number is assumed to be constant across a transaction,
and as a result will get optimized out by the compiler.
See https://github.com/foundry-rs/foundry/issues/6180
function getBlockNumber() external view returns (uint256 height);
getBlockTimestamp
Gets the current block.timestamp.
You should use this instead of block.timestamp if you use vm.warp, as block.timestamp is assumed to be constant across a transaction,
and as a result will get optimized out by the compiler.
See https://github.com/foundry-rs/foundry/issues/6180
function getBlockTimestamp() external view returns (uint256 timestamp);
getMappingKeyAndParentOf
Gets the map key and parent of a mapping at a given slot, for a given address.
function getMappingKeyAndParentOf(address target, bytes32 elementSlot)
external
returns (bool found, bytes32 key, bytes32 parent);
getMappingLength
Gets the number of elements in the mapping at the given slot, for a given address.
function getMappingLength(address target, bytes32 mappingSlot) external returns (uint256 length);
getMappingSlotAt
Gets the elements at index idx of the mapping at the given slot, for a given address. The index must be less than the length of the mapping (i.e. the number of keys in the mapping).
function getMappingSlotAt(address target, bytes32 mappingSlot, uint256 idx) external returns (bytes32 value);
getNonce
Gets the nonce of an account.
function getNonce(address account) external view returns (uint64 nonce);
getNonce
Get the nonce of a Wallet.
function getNonce(Wallet calldata wallet) external returns (uint64 nonce);
getRecordedLogs
Gets all the recorded logs.
function getRecordedLogs() external returns (Log[] memory logs);
getStateDiff
Returns state diffs from current vm.startStateDiffRecording session.
function getStateDiff() external view returns (string memory diff);
getStateDiffJson
Returns state diffs from current vm.startStateDiffRecording session, in json format.
function getStateDiffJson() external view returns (string memory diff);
lastCallGas
Gets the gas used in the last call from the callee perspective.
function lastCallGas() external view returns (Gas memory gas);
load
Loads a storage slot from an address.
function load(address target, bytes32 slot) external view returns (bytes32 data);
pauseGasMetering
Pauses gas metering (i.e. gas usage is not counted). Noop if already paused.
function pauseGasMetering() external;
record
Records all storage reads and writes.
function record() external;
recordLogs
Record all the transaction logs.
function recordLogs() external;
resetGasMetering
Reset gas metering (i.e. gas usage is set to gas limit).
function resetGasMetering() external;
resumeGasMetering
Resumes gas metering (i.e. gas usage is counted again). Noop if already on.
function resumeGasMetering() external;
rpc
Performs an Ethereum JSON-RPC request to the current fork URL.
function rpc(string calldata method, string calldata params) external returns (bytes memory data);
rpc
Performs an Ethereum JSON-RPC request to the given endpoint.
function rpc(string calldata urlOrAlias, string calldata method, string calldata params)
external
returns (bytes memory data);
startDebugTraceRecording
Records the debug trace during the run.
function startDebugTraceRecording() external;
startMappingRecording
Starts recording all map SSTOREs for later retrieval.
function startMappingRecording() external;
startStateDiffRecording
Record all account accesses as part of CREATE, CALL or SELFDESTRUCT opcodes in order, along with the context of the calls
function startStateDiffRecording() external;
stopAndReturnDebugTraceRecording
Stop debug trace recording and returns the recorded debug trace.
function stopAndReturnDebugTraceRecording() external returns (DebugStep[] memory step);
stopAndReturnStateDiff
Returns an ordered array of all account accesses from a vm.startStateDiffRecording session.
function stopAndReturnStateDiff() external returns (AccountAccess[] memory accountAccesses);
stopMappingRecording
Stops recording all map SSTOREs for later retrieval and clears the recorded data.
function stopMappingRecording() external;
closeFile
Closes file for reading, resetting the offset and allowing to read it from beginning with readLine.
path is relative to the project root.
function closeFile(string calldata path) external;
copyFile
Copies the contents of one file to another. This function will overwrite the contents of to.
On success, the total number of bytes copied is returned and it is equal to the length of the to file as reported by metadata.
Both from and to are relative to the project root.
function copyFile(string calldata from, string calldata to) external returns (uint64 copied);
createDir
Creates a new, empty directory at the provided path. This cheatcode will revert in the following situations, but is not limited to just these cases:
- User lacks permissions to modify
path. - A parent of the given path doesn't exist and
recursiveis false. pathalready exists andrecursiveis false.pathis relative to the project root.
function createDir(string calldata path, bool recursive) external;
deployCode
Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the
artifact in the form of
function deployCode(string calldata artifactPath) external returns (address deployedAddress);
deployCode
Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the
artifact in the form of
function deployCode(string calldata artifactPath, bytes calldata constructorArgs)
external
returns (address deployedAddress);
exists
Returns true if the given path points to an existing entity, else returns false.
function exists(string calldata path) external view returns (bool result);
ffi
Performs a foreign function call via the terminal.
function ffi(string[] calldata commandInput) external returns (bytes memory result);
fsMetadata
Given a path, query the file system to get information about a file, directory, etc.
function fsMetadata(string calldata path) external view returns (FsMetadata memory metadata);
getArtifactPathByCode
Gets the artifact path from code (aka. creation code).
function getArtifactPathByCode(bytes calldata code) external view returns (string memory path);
getArtifactPathByDeployedCode
Gets the artifact path from deployed code (aka. runtime code).
function getArtifactPathByDeployedCode(bytes calldata deployedCode) external view returns (string memory path);
getBroadcast
Returns the most recent broadcast for the given contract on chainId matching txType.
For example:
The most recent deployment can be fetched by passing txType as CREATE or CREATE2.
The most recent call can be fetched by passing txType as CALL.
function getBroadcast(string calldata contractName, uint64 chainId, BroadcastTxType txType)
external
view
returns (BroadcastTxSummary memory);
getBroadcasts
Returns all broadcasts for the given contract on chainId with the specified txType.
Sorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber.
function getBroadcasts(string calldata contractName, uint64 chainId, BroadcastTxType txType)
external
view
returns (BroadcastTxSummary[] memory);
getBroadcasts
Returns all broadcasts for the given contract on chainId.
Sorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber.
function getBroadcasts(string calldata contractName, uint64 chainId)
external
view
returns (BroadcastTxSummary[] memory);
getCode
Gets the creation bytecode from an artifact file. Takes in the relative path to the json file or the path to the
artifact in the form of
function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode);
getDeployedCode
Gets the deployed bytecode from an artifact file. Takes in the relative path to the json file or the path to the
artifact in the form of
function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode);
getDeployment
Returns the most recent deployment for the current chainId.
function getDeployment(string calldata contractName) external view returns (address deployedAddress);
getDeployment
Returns the most recent deployment for the given contract on chainId
function getDeployment(string calldata contractName, uint64 chainId) external view returns (address deployedAddress);
getDeployments
Returns all deployments for the given contract on chainId
Sorted in descending order of deployment time i.e descending order of BroadcastTxSummary.blockNumber.
The most recent deployment is the first element, and the oldest is the last.
function getDeployments(string calldata contractName, uint64 chainId)
external
view
returns (address[] memory deployedAddresses);
isDir
Returns true if the path exists on disk and is pointing at a directory, else returns false.
function isDir(string calldata path) external view returns (bool result);
isFile
Returns true if the path exists on disk and is pointing at a regular file, else returns false.
function isFile(string calldata path) external view returns (bool result);
projectRoot
Get the path of the current project root.
function projectRoot() external view returns (string memory path);
prompt
Prompts the user for a string value in the terminal.
function prompt(string calldata promptText) external returns (string memory input);
promptAddress
Prompts the user for an address in the terminal.
function promptAddress(string calldata promptText) external returns (address);
promptSecret
Prompts the user for a hidden string value in the terminal.
function promptSecret(string calldata promptText) external returns (string memory input);
promptSecretUint
Prompts the user for hidden uint256 in the terminal (usually pk).
function promptSecretUint(string calldata promptText) external returns (uint256);
promptUint
Prompts the user for uint256 in the terminal.
function promptUint(string calldata promptText) external returns (uint256);
readDir
Reads the directory at the given path recursively, up to maxDepth.
maxDepth defaults to 1, meaning only the direct children of the given directory will be returned.
Follows symbolic links if followLinks is true.
function readDir(string calldata path) external view returns (DirEntry[] memory entries);
readDir
See readDir(string).
function readDir(string calldata path, uint64 maxDepth) external view returns (DirEntry[] memory entries);
readDir
See readDir(string).
function readDir(string calldata path, uint64 maxDepth, bool followLinks)
external
view
returns (DirEntry[] memory entries);
readFile
Reads the entire content of file to string. path is relative to the project root.
function readFile(string calldata path) external view returns (string memory data);
readFileBinary
Reads the entire content of file as binary. path is relative to the project root.
function readFileBinary(string calldata path) external view returns (bytes memory data);
readLine
Reads next line of file to string.
function readLine(string calldata path) external view returns (string memory line);
readLink
Reads a symbolic link, returning the path that the link points to. This cheatcode will revert in the following situations, but is not limited to just these cases:
pathis not a symbolic link.pathdoes not exist.
function readLink(string calldata linkPath) external view returns (string memory targetPath);
removeDir
Removes a directory at the provided path. This cheatcode will revert in the following situations, but is not limited to just these cases:
pathdoesn't exist.pathisn't a directory.- User lacks permissions to modify
path. - The directory is not empty and
recursiveis false.pathis relative to the project root.
function removeDir(string calldata path, bool recursive) external;
removeFile
Removes a file from the filesystem. This cheatcode will revert in the following situations, but is not limited to just these cases:
pathpoints to a directory.- The file doesn't exist.
- The user lacks permissions to remove the file.
pathis relative to the project root.
function removeFile(string calldata path) external;
tryFfi
Performs a foreign function call via terminal and returns the exit code, stdout, and stderr.
function tryFfi(string[] calldata commandInput) external returns (FfiResult memory result);
unixTime
Returns the time since unix epoch in milliseconds.
function unixTime() external view returns (uint256 milliseconds);
writeFile
Writes data to file, creating a file if it does not exist, and entirely replacing its contents if it does.
path is relative to the project root.
function writeFile(string calldata path, string calldata data) external;
writeFileBinary
Writes binary data to a file, creating a file if it does not exist, and entirely replacing its contents if it does.
path is relative to the project root.
function writeFileBinary(string calldata path, bytes calldata data) external;
writeLine
Writes line to file, creating a file if it does not exist.
path is relative to the project root.
function writeLine(string calldata path, string calldata data) external;
keyExistsJson
Checks if key exists in a JSON object.
function keyExistsJson(string calldata json, string calldata key) external view returns (bool);
parseJsonAddress
Parses a string of JSON data at key and coerces it to address.
function parseJsonAddress(string calldata json, string calldata key) external pure returns (address);
parseJsonAddressArray
Parses a string of JSON data at key and coerces it to address[].
function parseJsonAddressArray(string calldata json, string calldata key) external pure returns (address[] memory);
parseJsonBool
Parses a string of JSON data at key and coerces it to bool.
function parseJsonBool(string calldata json, string calldata key) external pure returns (bool);
parseJsonBoolArray
Parses a string of JSON data at key and coerces it to bool[].
function parseJsonBoolArray(string calldata json, string calldata key) external pure returns (bool[] memory);
parseJsonBytes
Parses a string of JSON data at key and coerces it to bytes.
function parseJsonBytes(string calldata json, string calldata key) external pure returns (bytes memory);
parseJsonBytes32
Parses a string of JSON data at key and coerces it to bytes32.
function parseJsonBytes32(string calldata json, string calldata key) external pure returns (bytes32);
parseJsonBytes32Array
Parses a string of JSON data at key and coerces it to bytes32[].
function parseJsonBytes32Array(string calldata json, string calldata key) external pure returns (bytes32[] memory);
parseJsonBytesArray
Parses a string of JSON data at key and coerces it to bytes[].
function parseJsonBytesArray(string calldata json, string calldata key) external pure returns (bytes[] memory);
parseJsonInt
Parses a string of JSON data at key and coerces it to int256.
function parseJsonInt(string calldata json, string calldata key) external pure returns (int256);
parseJsonIntArray
Parses a string of JSON data at key and coerces it to int256[].
function parseJsonIntArray(string calldata json, string calldata key) external pure returns (int256[] memory);
parseJsonKeys
Returns an array of all the keys in a JSON object.
function parseJsonKeys(string calldata json, string calldata key) external pure returns (string[] memory keys);
parseJsonString
Parses a string of JSON data at key and coerces it to string.
function parseJsonString(string calldata json, string calldata key) external pure returns (string memory);
parseJsonStringArray
Parses a string of JSON data at key and coerces it to string[].
function parseJsonStringArray(string calldata json, string calldata key) external pure returns (string[] memory);
parseJsonTypeArray
Parses a string of JSON data at key and coerces it to type array corresponding to typeDescription.
function parseJsonTypeArray(string calldata json, string calldata key, string calldata typeDescription)
external
pure
returns (bytes memory);
parseJsonType
Parses a string of JSON data and coerces it to type corresponding to typeDescription.
function parseJsonType(string calldata json, string calldata typeDescription) external pure returns (bytes memory);
parseJsonType
Parses a string of JSON data at key and coerces it to type corresponding to typeDescription.
function parseJsonType(string calldata json, string calldata key, string calldata typeDescription)
external
pure
returns (bytes memory);
parseJsonUint
Parses a string of JSON data at key and coerces it to uint256.
function parseJsonUint(string calldata json, string calldata key) external pure returns (uint256);
parseJsonUintArray
Parses a string of JSON data at key and coerces it to uint256[].
function parseJsonUintArray(string calldata json, string calldata key) external pure returns (uint256[] memory);
parseJson
ABI-encodes a JSON object.
function parseJson(string calldata json) external pure returns (bytes memory abiEncodedData);
parseJson
ABI-encodes a JSON object at key.
function parseJson(string calldata json, string calldata key) external pure returns (bytes memory abiEncodedData);
serializeAddress
See serializeJson.
function serializeAddress(string calldata objectKey, string calldata valueKey, address value)
external
returns (string memory json);
serializeAddress
See serializeJson.
function serializeAddress(string calldata objectKey, string calldata valueKey, address[] calldata values)
external
returns (string memory json);
serializeBool
See serializeJson.
function serializeBool(string calldata objectKey, string calldata valueKey, bool value)
external
returns (string memory json);
serializeBool
See serializeJson.
function serializeBool(string calldata objectKey, string calldata valueKey, bool[] calldata values)
external
returns (string memory json);
serializeBytes32
See serializeJson.
function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32 value)
external
returns (string memory json);
serializeBytes32
See serializeJson.
function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32[] calldata values)
external
returns (string memory json);
serializeBytes
See serializeJson.
function serializeBytes(string calldata objectKey, string calldata valueKey, bytes calldata value)
external
returns (string memory json);
serializeBytes
See serializeJson.
function serializeBytes(string calldata objectKey, string calldata valueKey, bytes[] calldata values)
external
returns (string memory json);
serializeInt
See serializeJson.
function serializeInt(string calldata objectKey, string calldata valueKey, int256 value)
external
returns (string memory json);
serializeInt
See serializeJson.
function serializeInt(string calldata objectKey, string calldata valueKey, int256[] calldata values)
external
returns (string memory json);
serializeJson
Serializes a key and value to a JSON object stored in-memory that can be later written to a file. Returns the stringified version of the specific JSON file up to that moment.
function serializeJson(string calldata objectKey, string calldata value) external returns (string memory json);
serializeJsonType
See serializeJson.
function serializeJsonType(string calldata typeDescription, bytes calldata value)
external
pure
returns (string memory json);
serializeJsonType
See serializeJson.
function serializeJsonType(
string calldata objectKey,
string calldata valueKey,
string calldata typeDescription,
bytes calldata value
) external returns (string memory json);
serializeString
See serializeJson.
function serializeString(string calldata objectKey, string calldata valueKey, string calldata value)
external
returns (string memory json);
serializeString
See serializeJson.
function serializeString(string calldata objectKey, string calldata valueKey, string[] calldata values)
external
returns (string memory json);
serializeUintToHex
See serializeJson.
function serializeUintToHex(string calldata objectKey, string calldata valueKey, uint256 value)
external
returns (string memory json);
serializeUint
See serializeJson.
function serializeUint(string calldata objectKey, string calldata valueKey, uint256 value)
external
returns (string memory json);
serializeUint
See serializeJson.
function serializeUint(string calldata objectKey, string calldata valueKey, uint256[] calldata values)
external
returns (string memory json);
writeJson
Write a serialized JSON object to a file. If the file exists, it will be overwritten.
function writeJson(string calldata json, string calldata path) external;
writeJson
Write a serialized JSON object to an existing JSON file, replacing a value with key = <value_key.> This is useful to replace a specific value of a JSON file, without having to parse the entire thing.
function writeJson(string calldata json, string calldata path, string calldata valueKey) external;
keyExists
Checks if key exists in a JSON object
keyExists is being deprecated in favor of keyExistsJson. It will be removed in future versions.
function keyExists(string calldata json, string calldata key) external view returns (bool);
attachDelegation
Designate the next call as an EIP-7702 transaction
function attachDelegation(SignedDelegation calldata signedDelegation) external;
broadcastRawTransaction
Takes a signed transaction and broadcasts it to the network.
function broadcastRawTransaction(bytes calldata data) external;
broadcast
Has the next call (at this call depth only) create transactions that can later be signed and sent onchain. Broadcasting address is determined by checking the following in order:
- If
--senderargument was provided, that address is used. - If exactly one signer (e.g. private key, hw wallet, keystore) is set when
forge broadcastis invoked, that signer is used. - Otherwise, default foundry sender (1804c8AB1F12E6bbf3894d4083f33e07309d1f38) is used.
function broadcast() external;
broadcast
Has the next call (at this call depth only) create a transaction with the address provided as the sender that can later be signed and sent onchain.
function broadcast(address signer) external;
broadcast
Has the next call (at this call depth only) create a transaction with the private key provided as the sender that can later be signed and sent onchain.
function broadcast(uint256 privateKey) external;
getWallets
Returns addresses of available unlocked wallets in the script environment.
function getWallets() external returns (address[] memory wallets);
signAndAttachDelegation
Sign an EIP-7702 authorization and designate the next call as an EIP-7702 transaction
function signAndAttachDelegation(address implementation, uint256 privateKey)
external
returns (SignedDelegation memory signedDelegation);
signDelegation
Sign an EIP-7702 authorization for delegation
function signDelegation(address implementation, uint256 privateKey)
external
returns (SignedDelegation memory signedDelegation);
startBroadcast
Has all subsequent calls (at this call depth only) create transactions that can later be signed and sent onchain. Broadcasting address is determined by checking the following in order:
- If
--senderargument was provided, that address is used. - If exactly one signer (e.g. private key, hw wallet, keystore) is set when
forge broadcastis invoked, that signer is used. - Otherwise, default foundry sender (1804c8AB1F12E6bbf3894d4083f33e07309d1f38) is used.
function startBroadcast() external;
startBroadcast
Has all subsequent calls (at this call depth only) create transactions with the address provided that can later be signed and sent onchain.
function startBroadcast(address signer) external;
startBroadcast
Has all subsequent calls (at this call depth only) create transactions with the private key provided that can later be signed and sent onchain.
function startBroadcast(uint256 privateKey) external;
stopBroadcast
Stops collecting onchain transactions.
function stopBroadcast() external;
contains
Returns true if search is found in subject, false otherwise.
function contains(string calldata subject, string calldata search) external returns (bool result);
indexOf
Returns the index of the first occurrence of a key in an input string.
Returns NOT_FOUND (i.e. type(uint256).max) if the key is not found.
Returns 0 in case of an empty key.
function indexOf(string calldata input, string calldata key) external pure returns (uint256);
parseAddress
Parses the given string into an address.
function parseAddress(string calldata stringifiedValue) external pure returns (address parsedValue);
parseBool
Parses the given string into a bool.
function parseBool(string calldata stringifiedValue) external pure returns (bool parsedValue);
parseBytes
Parses the given string into bytes.
function parseBytes(string calldata stringifiedValue) external pure returns (bytes memory parsedValue);
parseBytes32
Parses the given string into a bytes32.
function parseBytes32(string calldata stringifiedValue) external pure returns (bytes32 parsedValue);
parseInt
Parses the given string into a int256.
function parseInt(string calldata stringifiedValue) external pure returns (int256 parsedValue);
parseUint
Parses the given string into a uint256.
function parseUint(string calldata stringifiedValue) external pure returns (uint256 parsedValue);
replace
Replaces occurrences of from in the given string with to.
function replace(string calldata input, string calldata from, string calldata to)
external
pure
returns (string memory output);
split
Splits the given string into an array of strings divided by the delimiter.
function split(string calldata input, string calldata delimiter) external pure returns (string[] memory outputs);
toLowercase
Converts the given string value to Lowercase.
function toLowercase(string calldata input) external pure returns (string memory output);
toString
Converts the given value to a string.
function toString(address value) external pure returns (string memory stringifiedValue);
toString
Converts the given value to a string.
function toString(bytes calldata value) external pure returns (string memory stringifiedValue);
toString
Converts the given value to a string.
function toString(bytes32 value) external pure returns (string memory stringifiedValue);
toString
Converts the given value to a string.
function toString(bool value) external pure returns (string memory stringifiedValue);
toString
Converts the given value to a string.
function toString(uint256 value) external pure returns (string memory stringifiedValue);
toString
Converts the given value to a string.
function toString(int256 value) external pure returns (string memory stringifiedValue);
toUppercase
Converts the given string value to Uppercase.
function toUppercase(string calldata input) external pure returns (string memory output);
trim
Trims leading and trailing whitespace from the given string value.
function trim(string calldata input) external pure returns (string memory output);
assertApproxEqAbsDecimal
Compares two uint256 values. Expects difference to be less than or equal to maxDelta.
Formats values with decimals in failure message.
function assertApproxEqAbsDecimal(uint256 left, uint256 right, uint256 maxDelta, uint256 decimals) external pure;
assertApproxEqAbsDecimal
Compares two uint256 values. Expects difference to be less than or equal to maxDelta.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertApproxEqAbsDecimal(
uint256 left,
uint256 right,
uint256 maxDelta,
uint256 decimals,
string calldata error
) external pure;
assertApproxEqAbsDecimal
Compares two int256 values. Expects difference to be less than or equal to maxDelta.
Formats values with decimals in failure message.
function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals) external pure;
assertApproxEqAbsDecimal
Compares two int256 values. Expects difference to be less than or equal to maxDelta.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals, string calldata error)
external
pure;
assertApproxEqAbs
Compares two uint256 values. Expects difference to be less than or equal to maxDelta.
function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta) external pure;
assertApproxEqAbs
Compares two uint256 values. Expects difference to be less than or equal to maxDelta.
Includes error message into revert string on failure.
function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta, string calldata error) external pure;
assertApproxEqAbs
Compares two int256 values. Expects difference to be less than or equal to maxDelta.
function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta) external pure;
assertApproxEqAbs
Compares two int256 values. Expects difference to be less than or equal to maxDelta.
Includes error message into revert string on failure.
function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta, string calldata error) external pure;
assertApproxEqRelDecimal
Compares two uint256 values. Expects relative difference in percents to be less than or equal to maxPercentDelta.
maxPercentDelta is an 18 decimal fixed point number, where 1e18 == 100%
Formats values with decimals in failure message.
function assertApproxEqRelDecimal(uint256 left, uint256 right, uint256 maxPercentDelta, uint256 decimals)
external
pure;
assertApproxEqRelDecimal
Compares two uint256 values. Expects relative difference in percents to be less than or equal to maxPercentDelta.
maxPercentDelta is an 18 decimal fixed point number, where 1e18 == 100%
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertApproxEqRelDecimal(
uint256 left,
uint256 right,
uint256 maxPercentDelta,
uint256 decimals,
string calldata error
) external pure;
assertApproxEqRelDecimal
Compares two int256 values. Expects relative difference in percents to be less than or equal to maxPercentDelta.
maxPercentDelta is an 18 decimal fixed point number, where 1e18 == 100%
Formats values with decimals in failure message.
function assertApproxEqRelDecimal(int256 left, int256 right, uint256 maxPercentDelta, uint256 decimals) external pure;
assertApproxEqRelDecimal
Compares two int256 values. Expects relative difference in percents to be less than or equal to maxPercentDelta.
maxPercentDelta is an 18 decimal fixed point number, where 1e18 == 100%
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertApproxEqRelDecimal(
int256 left,
int256 right,
uint256 maxPercentDelta,
uint256 decimals,
string calldata error
) external pure;
assertApproxEqRel
Compares two uint256 values. Expects relative difference in percents to be less than or equal to maxPercentDelta.
maxPercentDelta is an 18 decimal fixed point number, where 1e18 == 100%
function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta) external pure;
assertApproxEqRel
Compares two uint256 values. Expects relative difference in percents to be less than or equal to maxPercentDelta.
maxPercentDelta is an 18 decimal fixed point number, where 1e18 == 100%
Includes error message into revert string on failure.
function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta, string calldata error) external pure;
assertApproxEqRel
Compares two int256 values. Expects relative difference in percents to be less than or equal to maxPercentDelta.
maxPercentDelta is an 18 decimal fixed point number, where 1e18 == 100%
function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta) external pure;
assertApproxEqRel
Compares two int256 values. Expects relative difference in percents to be less than or equal to maxPercentDelta.
maxPercentDelta is an 18 decimal fixed point number, where 1e18 == 100%
Includes error message into revert string on failure.
function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta, string calldata error) external pure;
assertEqDecimal
Asserts that two uint256 values are equal, formatting them with decimals in failure message.
function assertEqDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
assertEqDecimal
Asserts that two uint256 values are equal, formatting them with decimals in failure message.
Includes error message into revert string on failure.
function assertEqDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
assertEqDecimal
Asserts that two int256 values are equal, formatting them with decimals in failure message.
function assertEqDecimal(int256 left, int256 right, uint256 decimals) external pure;
assertEqDecimal
Asserts that two int256 values are equal, formatting them with decimals in failure message.
Includes error message into revert string on failure.
function assertEqDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
assertEq
Asserts that two bool values are equal.
function assertEq(bool left, bool right) external pure;
assertEq
Asserts that two bool values are equal and includes error message into revert string on failure.
function assertEq(bool left, bool right, string calldata error) external pure;
assertEq
Asserts that two string values are equal.
function assertEq(string calldata left, string calldata right) external pure;
assertEq
Asserts that two string values are equal and includes error message into revert string on failure.
function assertEq(string calldata left, string calldata right, string calldata error) external pure;
assertEq
Asserts that two bytes values are equal.
function assertEq(bytes calldata left, bytes calldata right) external pure;
assertEq
Asserts that two bytes values are equal and includes error message into revert string on failure.
function assertEq(bytes calldata left, bytes calldata right, string calldata error) external pure;
assertEq
Asserts that two arrays of bool values are equal.
function assertEq(bool[] calldata left, bool[] calldata right) external pure;
assertEq
Asserts that two arrays of bool values are equal and includes error message into revert string on failure.
function assertEq(bool[] calldata left, bool[] calldata right, string calldata error) external pure;
assertEq
Asserts that two arrays of `uint256 values are equal.
function assertEq(uint256[] calldata left, uint256[] calldata right) external pure;
assertEq
Asserts that two arrays of uint256 values are equal and includes error message into revert string on failure.
function assertEq(uint256[] calldata left, uint256[] calldata right, string calldata error) external pure;
assertEq
Asserts that two arrays of int256 values are equal.
function assertEq(int256[] calldata left, int256[] calldata right) external pure;
assertEq
Asserts that two arrays of int256 values are equal and includes error message into revert string on failure.
function assertEq(int256[] calldata left, int256[] calldata right, string calldata error) external pure;
assertEq
Asserts that two uint256 values are equal.
function assertEq(uint256 left, uint256 right) external pure;
assertEq
Asserts that two arrays of address values are equal.
function assertEq(address[] calldata left, address[] calldata right) external pure;
assertEq
Asserts that two arrays of address values are equal and includes error message into revert string on failure.
function assertEq(address[] calldata left, address[] calldata right, string calldata error) external pure;
assertEq
Asserts that two arrays of bytes32 values are equal.
function assertEq(bytes32[] calldata left, bytes32[] calldata right) external pure;
assertEq
Asserts that two arrays of bytes32 values are equal and includes error message into revert string on failure.
function assertEq(bytes32[] calldata left, bytes32[] calldata right, string calldata error) external pure;
assertEq
Asserts that two arrays of string values are equal.
function assertEq(string[] calldata left, string[] calldata right) external pure;
assertEq
Asserts that two arrays of string values are equal and includes error message into revert string on failure.
function assertEq(string[] calldata left, string[] calldata right, string calldata error) external pure;
assertEq
Asserts that two arrays of bytes values are equal.
function assertEq(bytes[] calldata left, bytes[] calldata right) external pure;
assertEq
Asserts that two arrays of bytes values are equal and includes error message into revert string on failure.
function assertEq(bytes[] calldata left, bytes[] calldata right, string calldata error) external pure;
assertEq
Asserts that two uint256 values are equal and includes error message into revert string on failure.
function assertEq(uint256 left, uint256 right, string calldata error) external pure;
assertEq
Asserts that two int256 values are equal.
function assertEq(int256 left, int256 right) external pure;
assertEq
Asserts that two int256 values are equal and includes error message into revert string on failure.
function assertEq(int256 left, int256 right, string calldata error) external pure;
assertEq
Asserts that two address values are equal.
function assertEq(address left, address right) external pure;
assertEq
Asserts that two address values are equal and includes error message into revert string on failure.
function assertEq(address left, address right, string calldata error) external pure;
assertEq
Asserts that two bytes32 values are equal.
function assertEq(bytes32 left, bytes32 right) external pure;
assertEq
Asserts that two bytes32 values are equal and includes error message into revert string on failure.
function assertEq(bytes32 left, bytes32 right, string calldata error) external pure;
assertFalse
Asserts that the given condition is false.
function assertFalse(bool condition) external pure;
assertFalse
Asserts that the given condition is false and includes error message into revert string on failure.
function assertFalse(bool condition, string calldata error) external pure;
assertGeDecimal
Compares two uint256 values. Expects first value to be greater than or equal to second.
Formats values with decimals in failure message.
function assertGeDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
assertGeDecimal
Compares two uint256 values. Expects first value to be greater than or equal to second.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertGeDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
assertGeDecimal
Compares two int256 values. Expects first value to be greater than or equal to second.
Formats values with decimals in failure message.
function assertGeDecimal(int256 left, int256 right, uint256 decimals) external pure;
assertGeDecimal
Compares two int256 values. Expects first value to be greater than or equal to second.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertGeDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
assertGe
Compares two uint256 values. Expects first value to be greater than or equal to second.
function assertGe(uint256 left, uint256 right) external pure;
assertGe
Compares two uint256 values. Expects first value to be greater than or equal to second.
Includes error message into revert string on failure.
function assertGe(uint256 left, uint256 right, string calldata error) external pure;
assertGe
Compares two int256 values. Expects first value to be greater than or equal to second.
function assertGe(int256 left, int256 right) external pure;
assertGe
Compares two int256 values. Expects first value to be greater than or equal to second.
Includes error message into revert string on failure.
function assertGe(int256 left, int256 right, string calldata error) external pure;
assertGtDecimal
Compares two uint256 values. Expects first value to be greater than second.
Formats values with decimals in failure message.
function assertGtDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
assertGtDecimal
Compares two uint256 values. Expects first value to be greater than second.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertGtDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
assertGtDecimal
Compares two int256 values. Expects first value to be greater than second.
Formats values with decimals in failure message.
function assertGtDecimal(int256 left, int256 right, uint256 decimals) external pure;
assertGtDecimal
Compares two int256 values. Expects first value to be greater than second.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertGtDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
assertGt
Compares two uint256 values. Expects first value to be greater than second.
function assertGt(uint256 left, uint256 right) external pure;
assertGt
Compares two uint256 values. Expects first value to be greater than second.
Includes error message into revert string on failure.
function assertGt(uint256 left, uint256 right, string calldata error) external pure;
assertGt
Compares two int256 values. Expects first value to be greater than second.
function assertGt(int256 left, int256 right) external pure;
assertGt
Compares two int256 values. Expects first value to be greater than second.
Includes error message into revert string on failure.
function assertGt(int256 left, int256 right, string calldata error) external pure;
assertLeDecimal
Compares two uint256 values. Expects first value to be less than or equal to second.
Formats values with decimals in failure message.
function assertLeDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
assertLeDecimal
Compares two uint256 values. Expects first value to be less than or equal to second.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertLeDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
assertLeDecimal
Compares two int256 values. Expects first value to be less than or equal to second.
Formats values with decimals in failure message.
function assertLeDecimal(int256 left, int256 right, uint256 decimals) external pure;
assertLeDecimal
Compares two int256 values. Expects first value to be less than or equal to second.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertLeDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
assertLe
Compares two uint256 values. Expects first value to be less than or equal to second.
function assertLe(uint256 left, uint256 right) external pure;
assertLe
Compares two uint256 values. Expects first value to be less than or equal to second.
Includes error message into revert string on failure.
function assertLe(uint256 left, uint256 right, string calldata error) external pure;
assertLe
Compares two int256 values. Expects first value to be less than or equal to second.
function assertLe(int256 left, int256 right) external pure;
assertLe
Compares two int256 values. Expects first value to be less than or equal to second.
Includes error message into revert string on failure.
function assertLe(int256 left, int256 right, string calldata error) external pure;
assertLtDecimal
Compares two uint256 values. Expects first value to be less than second.
Formats values with decimals in failure message.
function assertLtDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
assertLtDecimal
Compares two uint256 values. Expects first value to be less than second.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertLtDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
assertLtDecimal
Compares two int256 values. Expects first value to be less than second.
Formats values with decimals in failure message.
function assertLtDecimal(int256 left, int256 right, uint256 decimals) external pure;
assertLtDecimal
Compares two int256 values. Expects first value to be less than second.
Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertLtDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
assertLt
Compares two uint256 values. Expects first value to be less than second.
function assertLt(uint256 left, uint256 right) external pure;
assertLt
Compares two uint256 values. Expects first value to be less than second.
Includes error message into revert string on failure.
function assertLt(uint256 left, uint256 right, string calldata error) external pure;
assertLt
Compares two int256 values. Expects first value to be less than second.
function assertLt(int256 left, int256 right) external pure;
assertLt
Compares two int256 values. Expects first value to be less than second.
Includes error message into revert string on failure.
function assertLt(int256 left, int256 right, string calldata error) external pure;
assertNotEqDecimal
Asserts that two uint256 values are not equal, formatting them with decimals in failure message.
function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
assertNotEqDecimal
Asserts that two uint256 values are not equal, formatting them with decimals in failure message.
Includes error message into revert string on failure.
function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
assertNotEqDecimal
Asserts that two int256 values are not equal, formatting them with decimals in failure message.
function assertNotEqDecimal(int256 left, int256 right, uint256 decimals) external pure;
assertNotEqDecimal
Asserts that two int256 values are not equal, formatting them with decimals in failure message.
Includes error message into revert string on failure.
function assertNotEqDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
assertNotEq
Asserts that two bool values are not equal.
function assertNotEq(bool left, bool right) external pure;
assertNotEq
Asserts that two bool values are not equal and includes error message into revert string on failure.
function assertNotEq(bool left, bool right, string calldata error) external pure;
assertNotEq
Asserts that two string values are not equal.
function assertNotEq(string calldata left, string calldata right) external pure;
assertNotEq
Asserts that two string values are not equal and includes error message into revert string on failure.
function assertNotEq(string calldata left, string calldata right, string calldata error) external pure;
assertNotEq
Asserts that two bytes values are not equal.
function assertNotEq(bytes calldata left, bytes calldata right) external pure;
assertNotEq
Asserts that two bytes values are not equal and includes error message into revert string on failure.
function assertNotEq(bytes calldata left, bytes calldata right, string calldata error) external pure;
assertNotEq
Asserts that two arrays of bool values are not equal.
function assertNotEq(bool[] calldata left, bool[] calldata right) external pure;
assertNotEq
Asserts that two arrays of bool values are not equal and includes error message into revert string on failure.
function assertNotEq(bool[] calldata left, bool[] calldata right, string calldata error) external pure;
assertNotEq
Asserts that two arrays of uint256 values are not equal.
function assertNotEq(uint256[] calldata left, uint256[] calldata right) external pure;
assertNotEq
Asserts that two arrays of uint256 values are not equal and includes error message into revert string on failure.
function assertNotEq(uint256[] calldata left, uint256[] calldata right, string calldata error) external pure;
assertNotEq
Asserts that two arrays of int256 values are not equal.
function assertNotEq(int256[] calldata left, int256[] calldata right) external pure;
assertNotEq
Asserts that two arrays of int256 values are not equal and includes error message into revert string on failure.
function assertNotEq(int256[] calldata left, int256[] calldata right, string calldata error) external pure;
assertNotEq
Asserts that two uint256 values are not equal.
function assertNotEq(uint256 left, uint256 right) external pure;
assertNotEq
Asserts that two arrays of address values are not equal.
function assertNotEq(address[] calldata left, address[] calldata right) external pure;
assertNotEq
Asserts that two arrays of address values are not equal and includes error message into revert string on failure.
function assertNotEq(address[] calldata left, address[] calldata right, string calldata error) external pure;
assertNotEq
Asserts that two arrays of bytes32 values are not equal.
function assertNotEq(bytes32[] calldata left, bytes32[] calldata right) external pure;
assertNotEq
Asserts that two arrays of bytes32 values are not equal and includes error message into revert string on failure.
function assertNotEq(bytes32[] calldata left, bytes32[] calldata right, string calldata error) external pure;
assertNotEq
Asserts that two arrays of string values are not equal.
function assertNotEq(string[] calldata left, string[] calldata right) external pure;
assertNotEq
Asserts that two arrays of string values are not equal and includes error message into revert string on failure.
function assertNotEq(string[] calldata left, string[] calldata right, string calldata error) external pure;
assertNotEq
Asserts that two arrays of bytes values are not equal.
function assertNotEq(bytes[] calldata left, bytes[] calldata right) external pure;
assertNotEq
Asserts that two arrays of bytes values are not equal and includes error message into revert string on failure.
function assertNotEq(bytes[] calldata left, bytes[] calldata right, string calldata error) external pure;
assertNotEq
Asserts that two uint256 values are not equal and includes error message into revert string on failure.
function assertNotEq(uint256 left, uint256 right, string calldata error) external pure;
assertNotEq
Asserts that two int256 values are not equal.
function assertNotEq(int256 left, int256 right) external pure;
assertNotEq
Asserts that two int256 values are not equal and includes error message into revert string on failure.
function assertNotEq(int256 left, int256 right, string calldata error) external pure;
assertNotEq
Asserts that two address values are not equal.
function assertNotEq(address left, address right) external pure;
assertNotEq
Asserts that two address values are not equal and includes error message into revert string on failure.
function assertNotEq(address left, address right, string calldata error) external pure;
assertNotEq
Asserts that two bytes32 values are not equal.
function assertNotEq(bytes32 left, bytes32 right) external pure;
assertNotEq
Asserts that two bytes32 values are not equal and includes error message into revert string on failure.
function assertNotEq(bytes32 left, bytes32 right, string calldata error) external pure;
assertTrue
Asserts that the given condition is true.
function assertTrue(bool condition) external pure;
assertTrue
Asserts that the given condition is true and includes error message into revert string on failure.
function assertTrue(bool condition, string calldata error) external pure;
assume
If the condition is false, discard this run's fuzz inputs and generate new ones.
function assume(bool condition) external pure;
assumeNoRevert
Discard this run's fuzz inputs and generate new ones if next call reverted.
function assumeNoRevert() external pure;
assumeNoRevert
Discard this run's fuzz inputs and generate new ones if next call reverts with the potential revert parameters.
function assumeNoRevert(PotentialRevert calldata potentialRevert) external pure;
assumeNoRevert
Discard this run's fuzz inputs and generate new ones if next call reverts with the any of the potential revert parameters.
function assumeNoRevert(PotentialRevert[] calldata potentialReverts) external pure;
breakpoint
Writes a breakpoint to jump to in the debugger.
function breakpoint(string calldata char) external pure;
breakpoint
Writes a conditional breakpoint to jump to in the debugger.
function breakpoint(string calldata char, bool value) external pure;
getFoundryVersion
Returns the Foundry version.
Format: <cargo_version>-
function getFoundryVersion() external view returns (string memory version);
rpcUrl
Returns the RPC url for the given alias.
function rpcUrl(string calldata rpcAlias) external view returns (string memory json);
rpcUrlStructs
Returns all rpc urls and their aliases as structs.
function rpcUrlStructs() external view returns (Rpc[] memory urls);
rpcUrls
Returns all rpc urls and their aliases [alias, url][].
function rpcUrls() external view returns (string[2][] memory urls);
sleep
Suspends execution of the main thread for duration milliseconds.
function sleep(uint256 duration) external;
keyExistsToml
Checks if key exists in a TOML table.
function keyExistsToml(string calldata toml, string calldata key) external view returns (bool);
parseTomlAddress
Parses a string of TOML data at key and coerces it to address.
function parseTomlAddress(string calldata toml, string calldata key) external pure returns (address);
parseTomlAddressArray
Parses a string of TOML data at key and coerces it to address[].
function parseTomlAddressArray(string calldata toml, string calldata key) external pure returns (address[] memory);
parseTomlBool
Parses a string of TOML data at key and coerces it to bool.
function parseTomlBool(string calldata toml, string calldata key) external pure returns (bool);
parseTomlBoolArray
Parses a string of TOML data at key and coerces it to bool[].
function parseTomlBoolArray(string calldata toml, string calldata key) external pure returns (bool[] memory);
parseTomlBytes
Parses a string of TOML data at key and coerces it to bytes.
function parseTomlBytes(string calldata toml, string calldata key) external pure returns (bytes memory);
parseTomlBytes32
Parses a string of TOML data at key and coerces it to bytes32.
function parseTomlBytes32(string calldata toml, string calldata key) external pure returns (bytes32);
parseTomlBytes32Array
Parses a string of TOML data at key and coerces it to bytes32[].
function parseTomlBytes32Array(string calldata toml, string calldata key) external pure returns (bytes32[] memory);
parseTomlBytesArray
Parses a string of TOML data at key and coerces it to bytes[].
function parseTomlBytesArray(string calldata toml, string calldata key) external pure returns (bytes[] memory);
parseTomlInt
Parses a string of TOML data at key and coerces it to int256.
function parseTomlInt(string calldata toml, string calldata key) external pure returns (int256);
parseTomlIntArray
Parses a string of TOML data at key and coerces it to int256[].
function parseTomlIntArray(string calldata toml, string calldata key) external pure returns (int256[] memory);
parseTomlKeys
Returns an array of all the keys in a TOML table.
function parseTomlKeys(string calldata toml, string calldata key) external pure returns (string[] memory keys);
parseTomlString
Parses a string of TOML data at key and coerces it to string.
function parseTomlString(string calldata toml, string calldata key) external pure returns (string memory);
parseTomlStringArray
Parses a string of TOML data at key and coerces it to string[].
function parseTomlStringArray(string calldata toml, string calldata key) external pure returns (string[] memory);
parseTomlTypeArray
Parses a string of TOML data at key and coerces it to type array corresponding to typeDescription.
function parseTomlTypeArray(string calldata toml, string calldata key, string calldata typeDescription)
external
pure
returns (bytes memory);
parseTomlType
Parses a string of TOML data and coerces it to type corresponding to typeDescription.
function parseTomlType(string calldata toml, string calldata typeDescription) external pure returns (bytes memory);
parseTomlType
Parses a string of TOML data at key and coerces it to type corresponding to typeDescription.
function parseTomlType(string calldata toml, string calldata key, string calldata typeDescription)
external
pure
returns (bytes memory);
parseTomlUint
Parses a string of TOML data at key and coerces it to uint256.
function parseTomlUint(string calldata toml, string calldata key) external pure returns (uint256);
parseTomlUintArray
Parses a string of TOML data at key and coerces it to uint256[].
function parseTomlUintArray(string calldata toml, string calldata key) external pure returns (uint256[] memory);
parseToml
ABI-encodes a TOML table.
function parseToml(string calldata toml) external pure returns (bytes memory abiEncodedData);
parseToml
ABI-encodes a TOML table at key.
function parseToml(string calldata toml, string calldata key) external pure returns (bytes memory abiEncodedData);
writeToml
Takes serialized JSON, converts to TOML and write a serialized TOML to a file.
function writeToml(string calldata json, string calldata path) external;
writeToml
Takes serialized JSON, converts to TOML and write a serialized TOML table to an existing TOML file, replacing a value with key = <value_key.> This is useful to replace a specific value of a TOML file, without having to parse the entire thing.
function writeToml(string calldata json, string calldata path, string calldata valueKey) external;
computeCreate2Address
Compute the address of a contract created with CREATE2 using the given CREATE2 deployer.
function computeCreate2Address(bytes32 salt, bytes32 initCodeHash, address deployer) external pure returns (address);
computeCreate2Address
Compute the address of a contract created with CREATE2 using the default CREATE2 deployer.
function computeCreate2Address(bytes32 salt, bytes32 initCodeHash) external pure returns (address);
computeCreateAddress
Compute the address a contract will be deployed at for a given deployer address and nonce.
function computeCreateAddress(address deployer, uint256 nonce) external pure returns (address);
copyStorage
Utility cheatcode to copy storage of from contract to another to contract.
function copyStorage(address from, address to) external;
ensNamehash
Returns ENS namehash for provided string.
function ensNamehash(string calldata name) external pure returns (bytes32);
getLabel
Gets the label for the specified address.
function getLabel(address account) external view returns (string memory currentLabel);
label
Labels an address in call traces.
function label(address account, string calldata newLabel) external;
pauseTracing
Pauses collection of call traces. Useful in cases when you want to skip tracing of complex calls which are not useful for debugging.
function pauseTracing() external view;
randomAddress
Returns a random address.
function randomAddress() external returns (address);
randomBool
Returns a random bool.
function randomBool() external view returns (bool);
randomBytes
Returns a random byte array value of the given length.
function randomBytes(uint256 len) external view returns (bytes memory);
randomBytes4
Returns a random fixed-size byte array of length 4.
function randomBytes4() external view returns (bytes4);
randomBytes8
Returns a random fixed-size byte array of length 8.
function randomBytes8() external view returns (bytes8);
randomInt
Returns a random int256 value.
function randomInt() external view returns (int256);
randomInt
Returns a random int256 value of given bits.
function randomInt(uint256 bits) external view returns (int256);
randomUint
Returns a random uint256 value.
function randomUint() external returns (uint256);
randomUint
Returns random uint256 value between the provided range (=min..=max).
function randomUint(uint256 min, uint256 max) external returns (uint256);
randomUint
Returns a random uint256 value of given bits.
function randomUint(uint256 bits) external view returns (uint256);
resumeTracing
Unpauses collection of call traces.
function resumeTracing() external view;
setArbitraryStorage
Utility cheatcode to set arbitrary storage for given target address.
function setArbitraryStorage(address target) external;
toBase64URL
Encodes a bytes value to a base64url string.
function toBase64URL(bytes calldata data) external pure returns (string memory);
toBase64URL
Encodes a string value to a base64url string.
function toBase64URL(string calldata data) external pure returns (string memory);
toBase64
Encodes a bytes value to a base64 string.
function toBase64(bytes calldata data) external pure returns (string memory);
toBase64
Encodes a string value to a base64 string.
function toBase64(string calldata data) external pure returns (string memory);
Structs
Log
An Ethereum log. Returned by getRecordedLogs.
struct Log {
bytes32[] topics;
bytes data;
address emitter;
}
Rpc
An RPC URL and its alias. Returned by rpcUrlStructs.
struct Rpc {
string key;
string url;
}
EthGetLogs
An RPC log object. Returned by eth_getLogs.
struct EthGetLogs {
address emitter;
bytes32[] topics;
bytes data;
bytes32 blockHash;
uint64 blockNumber;
bytes32 transactionHash;
uint64 transactionIndex;
uint256 logIndex;
bool removed;
}
DirEntry
A single entry in a directory listing. Returned by readDir.
struct DirEntry {
string errorMessage;
string path;
uint64 depth;
bool isDir;
bool isSymlink;
}
FsMetadata
Metadata information about a file.
This structure is returned from the fsMetadata function and represents known
metadata about a file such as its permissions, size, modification
times, etc.
struct FsMetadata {
bool isDir;
bool isSymlink;
uint256 length;
bool readOnly;
uint256 modified;
uint256 accessed;
uint256 created;
}
Wallet
A wallet with a public and private key.
struct Wallet {
address addr;
uint256 publicKeyX;
uint256 publicKeyY;
uint256 privateKey;
}
FfiResult
The result of a tryFfi call.
struct FfiResult {
int32 exitCode;
bytes stdout;
bytes stderr;
}
ChainInfo
Information on the chain and fork.
struct ChainInfo {
uint256 forkId;
uint256 chainId;
}
AccountAccess
The result of a stopAndReturnStateDiff call.
struct AccountAccess {
ChainInfo chainInfo;
AccountAccessKind kind;
address account;
address accessor;
bool initialized;
uint256 oldBalance;
uint256 newBalance;
bytes deployedCode;
uint256 value;
bytes data;
bool reverted;
StorageAccess[] storageAccesses;
uint64 depth;
}
StorageAccess
The storage accessed during an AccountAccess.
struct StorageAccess {
address account;
bytes32 slot;
bool isWrite;
bytes32 previousValue;
bytes32 newValue;
bool reverted;
}
Gas
Gas used. Returned by lastCallGas.
struct Gas {
uint64 gasLimit;
uint64 gasTotalUsed;
uint64 gasMemoryUsed;
int64 gasRefunded;
uint64 gasRemaining;
}
DebugStep
The result of the stopDebugTraceRecording call
struct DebugStep {
uint256[] stack;
bytes memoryInput;
uint8 opcode;
uint64 depth;
bool isOutOfGas;
address contractAddr;
}
BroadcastTxSummary
Represents a transaction's broadcast details.
struct BroadcastTxSummary {
bytes32 txHash;
BroadcastTxType txType;
address contractAddress;
uint64 blockNumber;
bool success;
}
SignedDelegation
Holds a signed EIP-7702 authorization for an authority account to delegate to an implementation.
struct SignedDelegation {
uint8 v;
bytes32 r;
bytes32 s;
uint64 nonce;
address implementation;
}
PotentialRevert
Represents a "potential" revert reason from a single subsequent call when using vm.assumeNoReverts.
Reverts that match will result in a FOUNDRY::ASSUME rejection, whereas unmatched reverts will be surfaced
as normal.
struct PotentialRevert {
address reverter;
bool partialMatch;
bytes revertData;
}
Enums
CallerMode
A modification applied to either msg.sender or tx.origin. Returned by readCallers.
enum CallerMode {
None,
Broadcast,
RecurrentBroadcast,
Prank,
RecurrentPrank
}
AccountAccessKind
The kind of account access that occurred.
enum AccountAccessKind {
Call,
DelegateCall,
CallCode,
StaticCall,
Create,
SelfDestruct,
Resume,
Balance,
Extcodesize,
Extcodehash,
Extcodecopy
}
ForgeContext
Forge execution contexts.
enum ForgeContext {
TestGroup,
Test,
Coverage,
Snapshot,
ScriptGroup,
ScriptDryRun,
ScriptBroadcast,
ScriptResume,
Unknown
}
BroadcastTxType
The transaction type (txType) of the broadcast.
enum BroadcastTxType {
Call,
Create,
Create2
}
Vm
Inherits: VmSafe
The Vm interface does allow manipulation of the EVM state. These are all intended to be used
in tests, but it is not recommended to use these cheats in scripts.
Functions
activeFork
Returns the identifier of the currently active fork. Reverts if no fork is currently active.
function activeFork() external view returns (uint256 forkId);
allowCheatcodes
In forking mode, explicitly grant the given address cheatcode access.
function allowCheatcodes(address account) external;
blobBaseFee
Sets block.blobbasefee
function blobBaseFee(uint256 newBlobBaseFee) external;
blobhashes
Sets the blobhashes in the transaction. Not available on EVM versions before Cancun. If used on unsupported EVM versions it will revert.
function blobhashes(bytes32[] calldata hashes) external;
chainId
Sets block.chainid.
function chainId(uint256 newChainId) external;
clearMockedCalls
Clears all mocked calls.
function clearMockedCalls() external;
cloneAccount
Clones a source account code, state, balance and nonce to a target account and updates in-memory EVM state.
function cloneAccount(address source, address target) external;
coinbase
Sets block.coinbase.
function coinbase(address newCoinbase) external;
createFork
Creates a new fork with the given endpoint and the latest block and returns the identifier of the fork.
function createFork(string calldata urlOrAlias) external returns (uint256 forkId);
createFork
Creates a new fork with the given endpoint and block and returns the identifier of the fork.
function createFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);
createFork
Creates a new fork with the given endpoint and at the block the given transaction was mined in, replays all transaction mined in the block before the transaction, and returns the identifier of the fork.
function createFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);
createSelectFork
Creates and also selects a new fork with the given endpoint and the latest block and returns the identifier of the fork.
function createSelectFork(string calldata urlOrAlias) external returns (uint256 forkId);
createSelectFork
Creates and also selects a new fork with the given endpoint and block and returns the identifier of the fork.
function createSelectFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);
createSelectFork
Creates and also selects new fork with the given endpoint and at the block the given transaction was mined in, replays all transaction mined in the block before the transaction, returns the identifier of the fork.
function createSelectFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);
deal
Sets an address' balance.
function deal(address account, uint256 newBalance) external;
deleteStateSnapshot
Removes the snapshot with the given ID created by snapshot.
Takes the snapshot ID to delete.
Returns true if the snapshot was successfully deleted.
Returns false if the snapshot does not exist.
function deleteStateSnapshot(uint256 snapshotId) external returns (bool success);
deleteStateSnapshots
Removes all snapshots previously created by snapshot.
function deleteStateSnapshots() external;
difficulty
Sets block.difficulty.
Not available on EVM versions from Paris onwards. Use prevrandao instead.
Reverts if used on unsupported EVM versions.
function difficulty(uint256 newDifficulty) external;
dumpState
Dump a genesis JSON file's allocs to disk.
function dumpState(string calldata pathToStateJson) external;
etch
Sets an address' code.
function etch(address target, bytes calldata newRuntimeBytecode) external;
fee
Sets block.basefee.
function fee(uint256 newBasefee) external;
getBlobhashes
Gets the blockhashes from the current transaction. Not available on EVM versions before Cancun. If used on unsupported EVM versions it will revert.
function getBlobhashes() external view returns (bytes32[] memory hashes);
isPersistent
Returns true if the account is marked as persistent.
function isPersistent(address account) external view returns (bool persistent);
loadAllocs
Load a genesis JSON file's allocs into the in-memory EVM state.
function loadAllocs(string calldata pathToAllocsJson) external;
makePersistent
Marks that the account(s) should use persistent storage across fork swaps in a multifork setup Meaning, changes made to the state of this account will be kept when switching forks.
function makePersistent(address account) external;
makePersistent
See makePersistent(address).
function makePersistent(address account0, address account1) external;
makePersistent
See makePersistent(address).
function makePersistent(address account0, address account1, address account2) external;
makePersistent
See makePersistent(address).
function makePersistent(address[] calldata accounts) external;
mockCallRevert
Reverts a call to an address with specified revert data.
function mockCallRevert(address callee, bytes calldata data, bytes calldata revertData) external;
mockCallRevert
Reverts a call to an address with a specific msg.value, with specified revert data.
function mockCallRevert(address callee, uint256 msgValue, bytes calldata data, bytes calldata revertData) external;
mockCallRevert
Reverts a call to an address with specified revert data.
Overload to pass the function selector directly token.approve.selector instead of abi.encodeWithSelector(token.approve.selector).
function mockCallRevert(address callee, bytes4 data, bytes calldata revertData) external;
mockCallRevert
Reverts a call to an address with a specific msg.value, with specified revert data.
Overload to pass the function selector directly token.approve.selector instead of abi.encodeWithSelector(token.approve.selector).
function mockCallRevert(address callee, uint256 msgValue, bytes4 data, bytes calldata revertData) external;
mockCall
Mocks a call to an address, returning specified data. Calldata can either be strict or a partial match, e.g. if you only pass a Solidity selector to the expected calldata, then the entire Solidity function will be mocked.
function mockCall(address callee, bytes calldata data, bytes calldata returnData) external;
mockCall
Mocks a call to an address with a specific msg.value, returning specified data.
Calldata match takes precedence over msg.value in case of ambiguity.
function mockCall(address callee, uint256 msgValue, bytes calldata data, bytes calldata returnData) external;
mockCall
Mocks a call to an address, returning specified data.
Calldata can either be strict or a partial match, e.g. if you only
pass a Solidity selector to the expected calldata, then the entire Solidity
function will be mocked.
Overload to pass the function selector directly token.approve.selector instead of abi.encodeWithSelector(token.approve.selector).
function mockCall(address callee, bytes4 data, bytes calldata returnData) external;
mockCall
Mocks a call to an address with a specific msg.value, returning specified data.
Calldata match takes precedence over msg.value in case of ambiguity.
Overload to pass the function selector directly token.approve.selector instead of abi.encodeWithSelector(token.approve.selector).
function mockCall(address callee, uint256 msgValue, bytes4 data, bytes calldata returnData) external;
mockCalls
Mocks multiple calls to an address, returning specified data for each call.
function mockCalls(address callee, bytes calldata data, bytes[] calldata returnData) external;
mockCalls
Mocks multiple calls to an address with a specific msg.value, returning specified data for each call.
function mockCalls(address callee, uint256 msgValue, bytes calldata data, bytes[] calldata returnData) external;
mockFunction
Whenever a call is made to callee with calldata data, this cheatcode instead calls
target with the same calldata. This functionality is similar to a delegate call made to
target contract from callee.
Can be used to substitute a call to a function with another implementation that captures
the primary logic of the original function but is easier to reason about.
If calldata is not a strict match then partial match by selector is attempted.
function mockFunction(address callee, address target, bytes calldata data) external;
prank
Sets the next call's msg.sender to be the input address.
function prank(address msgSender) external;
prank
Sets the next call's msg.sender to be the input address, and the tx.origin to be the second input.
function prank(address msgSender, address txOrigin) external;
prank
Sets the next delegate call's msg.sender to be the input address.
function prank(address msgSender, bool delegateCall) external;
prank
Sets the next delegate call's msg.sender to be the input address, and the tx.origin to be the second input.
function prank(address msgSender, address txOrigin, bool delegateCall) external;
prevrandao
Sets block.prevrandao.
Not available on EVM versions before Paris. Use difficulty instead.
If used on unsupported EVM versions it will revert.
function prevrandao(bytes32 newPrevrandao) external;
prevrandao
Sets block.prevrandao.
Not available on EVM versions before Paris. Use difficulty instead.
If used on unsupported EVM versions it will revert.
function prevrandao(uint256 newPrevrandao) external;
readCallers
Reads the current msg.sender and tx.origin from state and reports if there is any active caller modification.
function readCallers() external returns (CallerMode callerMode, address msgSender, address txOrigin);
resetNonce
Resets the nonce of an account to 0 for EOAs and 1 for contract accounts.
function resetNonce(address account) external;
revertToState
Revert the state of the EVM to a previous snapshot
Takes the snapshot ID to revert to.
Returns true if the snapshot was successfully reverted.
Returns false if the snapshot does not exist.
Note: This does not automatically delete the snapshot. To delete the snapshot use deleteStateSnapshot.
function revertToState(uint256 snapshotId) external returns (bool success);
revertToStateAndDelete
Revert the state of the EVM to a previous snapshot and automatically deletes the snapshots
Takes the snapshot ID to revert to.
Returns true if the snapshot was successfully reverted and deleted.
Returns false if the snapshot does not exist.
function revertToStateAndDelete(uint256 snapshotId) external returns (bool success);
revokePersistent
Revokes persistent status from the address, previously added via makePersistent.
function revokePersistent(address account) external;
revokePersistent
See revokePersistent(address).
function revokePersistent(address[] calldata accounts) external;
roll
Sets block.height.
function roll(uint256 newHeight) external;
rollFork
Updates the currently active fork to given block number
This is similar to roll but for the currently active fork.
function rollFork(uint256 blockNumber) external;
rollFork
Updates the currently active fork to given transaction. This will rollFork with the number
of the block the transaction was mined in and replays all transaction mined before it in the block.
function rollFork(bytes32 txHash) external;
rollFork
Updates the given fork to given block number.
function rollFork(uint256 forkId, uint256 blockNumber) external;
rollFork
Updates the given fork to block number of the given transaction and replays all transaction mined before it in the block.
function rollFork(uint256 forkId, bytes32 txHash) external;
selectFork
Takes a fork identifier created by createFork and sets the corresponding forked state as active.
function selectFork(uint256 forkId) external;
setBlockhash
Set blockhash for the current block.
It only sets the blockhash for blocks where block.number - 256 <= number < block.number.
function setBlockhash(uint256 blockNumber, bytes32 blockHash) external;
setNonce
Sets the nonce of an account. Must be higher than the current nonce of the account.
function setNonce(address account, uint64 newNonce) external;
setNonceUnsafe
Sets the nonce of an account to an arbitrary value.
function setNonceUnsafe(address account, uint64 newNonce) external;
snapshotGasLastCall
Snapshot capture the gas usage of the last call by name from the callee perspective.
function snapshotGasLastCall(string calldata name) external returns (uint256 gasUsed);
snapshotGasLastCall
Snapshot capture the gas usage of the last call by name in a group from the callee perspective.
function snapshotGasLastCall(string calldata group, string calldata name) external returns (uint256 gasUsed);
snapshotState
Snapshot the current state of the evm.
Returns the ID of the snapshot that was created.
To revert a snapshot use revertToState.
function snapshotState() external returns (uint256 snapshotId);
snapshotValue
Snapshot capture an arbitrary numerical value by name. The group name is derived from the contract name.
function snapshotValue(string calldata name, uint256 value) external;
snapshotValue
Snapshot capture an arbitrary numerical value by name in a group.
function snapshotValue(string calldata group, string calldata name, uint256 value) external;
startPrank
Sets all subsequent calls' msg.sender to be the input address until stopPrank is called.
function startPrank(address msgSender) external;
startPrank
Sets all subsequent calls' msg.sender to be the input address until stopPrank is called, and the tx.origin to be the second input.
function startPrank(address msgSender, address txOrigin) external;
startPrank
Sets all subsequent delegate calls' msg.sender to be the input address until stopPrank is called.
function startPrank(address msgSender, bool delegateCall) external;
startPrank
Sets all subsequent delegate calls' msg.sender to be the input address until stopPrank is called, and the tx.origin to be the second input.
function startPrank(address msgSender, address txOrigin, bool delegateCall) external;
startSnapshotGas
Start a snapshot capture of the current gas usage by name. The group name is derived from the contract name.
function startSnapshotGas(string calldata name) external;
startSnapshotGas
Start a snapshot capture of the current gas usage by name in a group.
function startSnapshotGas(string calldata group, string calldata name) external;
stopPrank
Resets subsequent calls' msg.sender to be address(this).
function stopPrank() external;
stopSnapshotGas
Stop the snapshot capture of the current gas by latest snapshot name, capturing the gas used since the start.
function stopSnapshotGas() external returns (uint256 gasUsed);
stopSnapshotGas
Stop the snapshot capture of the current gas usage by name, capturing the gas used since the start. The group name is derived from the contract name.
function stopSnapshotGas(string calldata name) external returns (uint256 gasUsed);
stopSnapshotGas
Stop the snapshot capture of the current gas usage by name in a group, capturing the gas used since the start.
function stopSnapshotGas(string calldata group, string calldata name) external returns (uint256 gasUsed);
store
Stores a value to an address' storage slot.
function store(address target, bytes32 slot, bytes32 value) external;
transact
Fetches the given transaction from the active fork and executes it on the current state.
function transact(bytes32 txHash) external;
transact
Fetches the given transaction from the given fork and executes it on the current state.
function transact(uint256 forkId, bytes32 txHash) external;
txGasPrice
Sets tx.gasprice.
function txGasPrice(uint256 newGasPrice) external;
warp
Sets block.timestamp.
function warp(uint256 newTimestamp) external;
deleteSnapshot
deleteSnapshot is being deprecated in favor of deleteStateSnapshot. It will be removed in future versions.
function deleteSnapshot(uint256 snapshotId) external returns (bool success);
deleteSnapshots
deleteSnapshots is being deprecated in favor of deleteStateSnapshots. It will be removed in future versions.
function deleteSnapshots() external;
revertToAndDelete
revertToAndDelete is being deprecated in favor of revertToStateAndDelete. It will be removed in future versions.
function revertToAndDelete(uint256 snapshotId) external returns (bool success);
revertTo
revertTo is being deprecated in favor of revertToState. It will be removed in future versions.
function revertTo(uint256 snapshotId) external returns (bool success);
snapshot
snapshot is being deprecated in favor of snapshotState. It will be removed in future versions.
function snapshot() external returns (uint256 snapshotId);
expectCallMinGas
Expect a call to an address with the specified msg.value and calldata, and a minimum amount of gas.
function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data) external;
expectCallMinGas
Expect given number of calls to an address with the specified msg.value and calldata, and a minimum amount of gas.
function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data, uint64 count)
external;
expectCall
Expects a call to an address with the specified calldata. Calldata can either be a strict or a partial match.
function expectCall(address callee, bytes calldata data) external;
expectCall
Expects given number of calls to an address with the specified calldata.
function expectCall(address callee, bytes calldata data, uint64 count) external;
expectCall
Expects a call to an address with the specified msg.value and calldata.
function expectCall(address callee, uint256 msgValue, bytes calldata data) external;
expectCall
Expects given number of calls to an address with the specified msg.value and calldata.
function expectCall(address callee, uint256 msgValue, bytes calldata data, uint64 count) external;
expectCall
Expect a call to an address with the specified msg.value, gas, and calldata.
function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data) external;
expectCall
Expects given number of calls to an address with the specified msg.value, gas, and calldata.
function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data, uint64 count) external;
expectEmitAnonymous
Prepare an expected anonymous log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData.). Call this function, then emit an anonymous event, then call a function. Internally after the call, we check if logs were emitted in the expected order with the expected topics and data (as specified by the booleans).
function expectEmitAnonymous(bool checkTopic0, bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData)
external;
expectEmitAnonymous
Same as the previous method, but also checks supplied address against emitting contract.
function expectEmitAnonymous(
bool checkTopic0,
bool checkTopic1,
bool checkTopic2,
bool checkTopic3,
bool checkData,
address emitter
) external;
expectEmitAnonymous
Prepare an expected anonymous log with all topic and data checks enabled. Call this function, then emit an anonymous event, then call a function. Internally after the call, we check if logs were emitted in the expected order with the expected topics and data.
function expectEmitAnonymous() external;
expectEmitAnonymous
Same as the previous method, but also checks supplied address against emitting contract.
function expectEmitAnonymous(address emitter) external;
expectEmit
Prepare an expected log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData.). Call this function, then emit an event, then call a function. Internally after the call, we check if logs were emitted in the expected order with the expected topics and data (as specified by the booleans).
function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external;
expectEmit
Same as the previous method, but also checks supplied address against emitting contract.
function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter) external;
expectEmit
Prepare an expected log with all topic and data checks enabled. Call this function, then emit an event, then call a function. Internally after the call, we check if logs were emitted in the expected order with the expected topics and data.
function expectEmit() external;
expectEmit
Same as the previous method, but also checks supplied address against emitting contract.
function expectEmit(address emitter) external;
expectEmit
Expect a given number of logs with the provided topics.
function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, uint64 count) external;
expectEmit
Expect a given number of logs from a specific emitter with the provided topics.
function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter, uint64 count)
external;
expectEmit
Expect a given number of logs with all topic and data checks enabled.
function expectEmit(uint64 count) external;
expectEmit
Expect a given number of logs from a specific emitter with all topic and data checks enabled.
function expectEmit(address emitter, uint64 count) external;
expectPartialRevert
Expects an error on next call that starts with the revert data.
function expectPartialRevert(bytes4 revertData) external;
expectPartialRevert
Expects an error on next call to reverter address, that starts with the revert data.
function expectPartialRevert(bytes4 revertData, address reverter) external;
expectRevert
Expects an error on next call with any revert data.
function expectRevert() external;
expectRevert
Expects an error on next call that exactly matches the revert data.
function expectRevert(bytes4 revertData) external;
expectRevert
Expects a count number of reverts from the upcoming calls from the reverter address that match the revert data.
function expectRevert(bytes4 revertData, address reverter, uint64 count) external;
expectRevert
Expects a count number of reverts from the upcoming calls from the reverter address that exactly match the revert data.
function expectRevert(bytes calldata revertData, address reverter, uint64 count) external;
expectRevert
Expects an error on next call that exactly matches the revert data.
function expectRevert(bytes calldata revertData) external;
expectRevert
Expects an error with any revert data on next call to reverter address.
function expectRevert(address reverter) external;
expectRevert
Expects an error from reverter address on next call, with any revert data.
function expectRevert(bytes4 revertData, address reverter) external;
expectRevert
Expects an error from reverter address on next call, that exactly matches the revert data.
function expectRevert(bytes calldata revertData, address reverter) external;
expectRevert
Expects a count number of reverts from the upcoming calls with any revert data or reverter.
function expectRevert(uint64 count) external;
expectRevert
Expects a count number of reverts from the upcoming calls that match the revert data.
function expectRevert(bytes4 revertData, uint64 count) external;
expectRevert
Expects a count number of reverts from the upcoming calls that exactly match the revert data.
function expectRevert(bytes calldata revertData, uint64 count) external;
expectRevert
Expects a count number of reverts from the upcoming calls from the reverter address.
function expectRevert(address reverter, uint64 count) external;
expectSafeMemory
Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the current subcontext. If any other memory is written to, the test will fail. Can be called multiple times to add more ranges to the set.
function expectSafeMemory(uint64 min, uint64 max) external;
expectSafeMemoryCall
Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the next created subcontext. If any other memory is written to, the test will fail. Can be called multiple times to add more ranges to the set.
function expectSafeMemoryCall(uint64 min, uint64 max) external;
skip
Marks a test as skipped. Must be called at the top level of a test.
function skip(bool skipTest) external;
skip
Marks a test as skipped with a reason. Must be called at the top level of a test.
function skip(bool skipTest, string calldata reason) external;
stopExpectSafeMemory
Stops all safe memory expectation in the current subcontext.
function stopExpectSafeMemory() external;
console
State Variables
CONSOLE_ADDRESS
address constant CONSOLE_ADDRESS = 0x000000000000000000636F6e736F6c652e6c6f67;
Functions
_sendLogPayloadImplementation
function _sendLogPayloadImplementation(bytes memory payload) internal view;
_castToPure
function _castToPure(function(bytes memory) internal view fnIn)
internal
pure
returns (function(bytes memory) pure fnOut);
_sendLogPayload
function _sendLogPayload(bytes memory payload) internal pure;
log
function log() internal pure;
logInt
function logInt(int256 p0) internal pure;
logUint
function logUint(uint256 p0) internal pure;
logString
function logString(string memory p0) internal pure;
logBool
function logBool(bool p0) internal pure;
logAddress
function logAddress(address p0) internal pure;
logBytes
function logBytes(bytes memory p0) internal pure;
logBytes1
function logBytes1(bytes1 p0) internal pure;
logBytes2
function logBytes2(bytes2 p0) internal pure;
logBytes3
function logBytes3(bytes3 p0) internal pure;
logBytes4
function logBytes4(bytes4 p0) internal pure;
logBytes5
function logBytes5(bytes5 p0) internal pure;
logBytes6
function logBytes6(bytes6 p0) internal pure;
logBytes7
function logBytes7(bytes7 p0) internal pure;
logBytes8
function logBytes8(bytes8 p0) internal pure;
logBytes9
function logBytes9(bytes9 p0) internal pure;
logBytes10
function logBytes10(bytes10 p0) internal pure;
logBytes11
function logBytes11(bytes11 p0) internal pure;
logBytes12
function logBytes12(bytes12 p0) internal pure;
logBytes13
function logBytes13(bytes13 p0) internal pure;
logBytes14
function logBytes14(bytes14 p0) internal pure;
logBytes15
function logBytes15(bytes15 p0) internal pure;
logBytes16
function logBytes16(bytes16 p0) internal pure;
logBytes17
function logBytes17(bytes17 p0) internal pure;
logBytes18
function logBytes18(bytes18 p0) internal pure;
logBytes19
function logBytes19(bytes19 p0) internal pure;
logBytes20
function logBytes20(bytes20 p0) internal pure;
logBytes21
function logBytes21(bytes21 p0) internal pure;
logBytes22
function logBytes22(bytes22 p0) internal pure;
logBytes23
function logBytes23(bytes23 p0) internal pure;
logBytes24
function logBytes24(bytes24 p0) internal pure;
logBytes25
function logBytes25(bytes25 p0) internal pure;
logBytes26
function logBytes26(bytes26 p0) internal pure;
logBytes27
function logBytes27(bytes27 p0) internal pure;
logBytes28
function logBytes28(bytes28 p0) internal pure;
logBytes29
function logBytes29(bytes29 p0) internal pure;
logBytes30
function logBytes30(bytes30 p0) internal pure;
logBytes31
function logBytes31(bytes31 p0) internal pure;
logBytes32
function logBytes32(bytes32 p0) internal pure;
log
function log(uint256 p0) internal pure;
log
function log(int256 p0) internal pure;
log
function log(string memory p0) internal pure;
log
function log(bool p0) internal pure;
log
function log(address p0) internal pure;
log
function log(uint256 p0, uint256 p1) internal pure;
log
function log(uint256 p0, string memory p1) internal pure;
log
function log(uint256 p0, bool p1) internal pure;
log
function log(uint256 p0, address p1) internal pure;
log
function log(string memory p0, uint256 p1) internal pure;
log
function log(string memory p0, int256 p1) internal pure;
log
function log(string memory p0, string memory p1) internal pure;
log
function log(string memory p0, bool p1) internal pure;
log
function log(string memory p0, address p1) internal pure;
log
function log(bool p0, uint256 p1) internal pure;
log
function log(bool p0, string memory p1) internal pure;
log
function log(bool p0, bool p1) internal pure;
log
function log(bool p0, address p1) internal pure;
log
function log(address p0, uint256 p1) internal pure;
log
function log(address p0, string memory p1) internal pure;
log
function log(address p0, bool p1) internal pure;
log
function log(address p0, address p1) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2) internal pure;
log
function log(uint256 p0, uint256 p1, string memory p2) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2) internal pure;
log
function log(uint256 p0, uint256 p1, address p2) internal pure;
log
function log(uint256 p0, string memory p1, uint256 p2) internal pure;
log
function log(uint256 p0, string memory p1, string memory p2) internal pure;
log
function log(uint256 p0, string memory p1, bool p2) internal pure;
log
function log(uint256 p0, string memory p1, address p2) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2) internal pure;
log
function log(uint256 p0, bool p1, string memory p2) internal pure;
log
function log(uint256 p0, bool p1, bool p2) internal pure;
log
function log(uint256 p0, bool p1, address p2) internal pure;
log
function log(uint256 p0, address p1, uint256 p2) internal pure;
log
function log(uint256 p0, address p1, string memory p2) internal pure;
log
function log(uint256 p0, address p1, bool p2) internal pure;
log
function log(uint256 p0, address p1, address p2) internal pure;
log
function log(string memory p0, uint256 p1, uint256 p2) internal pure;
log
function log(string memory p0, uint256 p1, string memory p2) internal pure;
log
function log(string memory p0, uint256 p1, bool p2) internal pure;
log
function log(string memory p0, uint256 p1, address p2) internal pure;
log
function log(string memory p0, string memory p1, uint256 p2) internal pure;
log
function log(string memory p0, string memory p1, string memory p2) internal pure;
log
function log(string memory p0, string memory p1, bool p2) internal pure;
log
function log(string memory p0, string memory p1, address p2) internal pure;
log
function log(string memory p0, bool p1, uint256 p2) internal pure;
log
function log(string memory p0, bool p1, string memory p2) internal pure;
log
function log(string memory p0, bool p1, bool p2) internal pure;
log
function log(string memory p0, bool p1, address p2) internal pure;
log
function log(string memory p0, address p1, uint256 p2) internal pure;
log
function log(string memory p0, address p1, string memory p2) internal pure;
log
function log(string memory p0, address p1, bool p2) internal pure;
log
function log(string memory p0, address p1, address p2) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2) internal pure;
log
function log(bool p0, uint256 p1, string memory p2) internal pure;
log
function log(bool p0, uint256 p1, bool p2) internal pure;
log
function log(bool p0, uint256 p1, address p2) internal pure;
log
function log(bool p0, string memory p1, uint256 p2) internal pure;
log
function log(bool p0, string memory p1, string memory p2) internal pure;
log
function log(bool p0, string memory p1, bool p2) internal pure;
log
function log(bool p0, string memory p1, address p2) internal pure;
log
function log(bool p0, bool p1, uint256 p2) internal pure;
log
function log(bool p0, bool p1, string memory p2) internal pure;
log
function log(bool p0, bool p1, bool p2) internal pure;
log
function log(bool p0, bool p1, address p2) internal pure;
log
function log(bool p0, address p1, uint256 p2) internal pure;
log
function log(bool p0, address p1, string memory p2) internal pure;
log
function log(bool p0, address p1, bool p2) internal pure;
log
function log(bool p0, address p1, address p2) internal pure;
log
function log(address p0, uint256 p1, uint256 p2) internal pure;
log
function log(address p0, uint256 p1, string memory p2) internal pure;
log
function log(address p0, uint256 p1, bool p2) internal pure;
log
function log(address p0, uint256 p1, address p2) internal pure;
log
function log(address p0, string memory p1, uint256 p2) internal pure;
log
function log(address p0, string memory p1, string memory p2) internal pure;
log
function log(address p0, string memory p1, bool p2) internal pure;
log
function log(address p0, string memory p1, address p2) internal pure;
log
function log(address p0, bool p1, uint256 p2) internal pure;
log
function log(address p0, bool p1, string memory p2) internal pure;
log
function log(address p0, bool p1, bool p2) internal pure;
log
function log(address p0, bool p1, address p2) internal pure;
log
function log(address p0, address p1, uint256 p2) internal pure;
log
function log(address p0, address p1, string memory p2) internal pure;
log
function log(address p0, address p1, bool p2) internal pure;
log
function log(address p0, address p1, address p2) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2, uint256 p3) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2, string memory p3) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2, bool p3) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2, address p3) internal pure;
log
function log(uint256 p0, uint256 p1, string memory p2, uint256 p3) internal pure;
log
function log(uint256 p0, uint256 p1, string memory p2, string memory p3) internal pure;
log
function log(uint256 p0, uint256 p1, string memory p2, bool p3) internal pure;
log
function log(uint256 p0, uint256 p1, string memory p2, address p3) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2, uint256 p3) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2, string memory p3) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2, bool p3) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2, address p3) internal pure;
log
function log(uint256 p0, uint256 p1, address p2, uint256 p3) internal pure;
log
function log(uint256 p0, uint256 p1, address p2, string memory p3) internal pure;
log
function log(uint256 p0, uint256 p1, address p2, bool p3) internal pure;
log
function log(uint256 p0, uint256 p1, address p2, address p3) internal pure;
log
function log(uint256 p0, string memory p1, uint256 p2, uint256 p3) internal pure;
log
function log(uint256 p0, string memory p1, uint256 p2, string memory p3) internal pure;
log
function log(uint256 p0, string memory p1, uint256 p2, bool p3) internal pure;
log
function log(uint256 p0, string memory p1, uint256 p2, address p3) internal pure;
log
function log(uint256 p0, string memory p1, string memory p2, uint256 p3) internal pure;
log
function log(uint256 p0, string memory p1, string memory p2, string memory p3) internal pure;
log
function log(uint256 p0, string memory p1, string memory p2, bool p3) internal pure;
log
function log(uint256 p0, string memory p1, string memory p2, address p3) internal pure;
log
function log(uint256 p0, string memory p1, bool p2, uint256 p3) internal pure;
log
function log(uint256 p0, string memory p1, bool p2, string memory p3) internal pure;
log
function log(uint256 p0, string memory p1, bool p2, bool p3) internal pure;
log
function log(uint256 p0, string memory p1, bool p2, address p3) internal pure;
log
function log(uint256 p0, string memory p1, address p2, uint256 p3) internal pure;
log
function log(uint256 p0, string memory p1, address p2, string memory p3) internal pure;
log
function log(uint256 p0, string memory p1, address p2, bool p3) internal pure;
log
function log(uint256 p0, string memory p1, address p2, address p3) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2, uint256 p3) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2, string memory p3) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2, bool p3) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2, address p3) internal pure;
log
function log(uint256 p0, bool p1, string memory p2, uint256 p3) internal pure;
log
function log(uint256 p0, bool p1, string memory p2, string memory p3) internal pure;
log
function log(uint256 p0, bool p1, string memory p2, bool p3) internal pure;
log
function log(uint256 p0, bool p1, string memory p2, address p3) internal pure;
log
function log(uint256 p0, bool p1, bool p2, uint256 p3) internal pure;
log
function log(uint256 p0, bool p1, bool p2, string memory p3) internal pure;
log
function log(uint256 p0, bool p1, bool p2, bool p3) internal pure;
log
function log(uint256 p0, bool p1, bool p2, address p3) internal pure;
log
function log(uint256 p0, bool p1, address p2, uint256 p3) internal pure;
log
function log(uint256 p0, bool p1, address p2, string memory p3) internal pure;
log
function log(uint256 p0, bool p1, address p2, bool p3) internal pure;
log
function log(uint256 p0, bool p1, address p2, address p3) internal pure;
log
function log(uint256 p0, address p1, uint256 p2, uint256 p3) internal pure;
log
function log(uint256 p0, address p1, uint256 p2, string memory p3) internal pure;
log
function log(uint256 p0, address p1, uint256 p2, bool p3) internal pure;
log
function log(uint256 p0, address p1, uint256 p2, address p3) internal pure;
log
function log(uint256 p0, address p1, string memory p2, uint256 p3) internal pure;
log
function log(uint256 p0, address p1, string memory p2, string memory p3) internal pure;
log
function log(uint256 p0, address p1, string memory p2, bool p3) internal pure;
log
function log(uint256 p0, address p1, string memory p2, address p3) internal pure;
log
function log(uint256 p0, address p1, bool p2, uint256 p3) internal pure;
log
function log(uint256 p0, address p1, bool p2, string memory p3) internal pure;
log
function log(uint256 p0, address p1, bool p2, bool p3) internal pure;
log
function log(uint256 p0, address p1, bool p2, address p3) internal pure;
log
function log(uint256 p0, address p1, address p2, uint256 p3) internal pure;
log
function log(uint256 p0, address p1, address p2, string memory p3) internal pure;
log
function log(uint256 p0, address p1, address p2, bool p3) internal pure;
log
function log(uint256 p0, address p1, address p2, address p3) internal pure;
log
function log(string memory p0, uint256 p1, uint256 p2, uint256 p3) internal pure;
log
function log(string memory p0, uint256 p1, uint256 p2, string memory p3) internal pure;
log
function log(string memory p0, uint256 p1, uint256 p2, bool p3) internal pure;
log
function log(string memory p0, uint256 p1, uint256 p2, address p3) internal pure;
log
function log(string memory p0, uint256 p1, string memory p2, uint256 p3) internal pure;
log
function log(string memory p0, uint256 p1, string memory p2, string memory p3) internal pure;
log
function log(string memory p0, uint256 p1, string memory p2, bool p3) internal pure;
log
function log(string memory p0, uint256 p1, string memory p2, address p3) internal pure;
log
function log(string memory p0, uint256 p1, bool p2, uint256 p3) internal pure;
log
function log(string memory p0, uint256 p1, bool p2, string memory p3) internal pure;
log
function log(string memory p0, uint256 p1, bool p2, bool p3) internal pure;
log
function log(string memory p0, uint256 p1, bool p2, address p3) internal pure;
log
function log(string memory p0, uint256 p1, address p2, uint256 p3) internal pure;
log
function log(string memory p0, uint256 p1, address p2, string memory p3) internal pure;
log
function log(string memory p0, uint256 p1, address p2, bool p3) internal pure;
log
function log(string memory p0, uint256 p1, address p2, address p3) internal pure;
log
function log(string memory p0, string memory p1, uint256 p2, uint256 p3) internal pure;
log
function log(string memory p0, string memory p1, uint256 p2, string memory p3) internal pure;
log
function log(string memory p0, string memory p1, uint256 p2, bool p3) internal pure;
log
function log(string memory p0, string memory p1, uint256 p2, address p3) internal pure;
log
function log(string memory p0, string memory p1, string memory p2, uint256 p3) internal pure;
log
function log(string memory p0, string memory p1, string memory p2, string memory p3) internal pure;
log
function log(string memory p0, string memory p1, string memory p2, bool p3) internal pure;
log
function log(string memory p0, string memory p1, string memory p2, address p3) internal pure;
log
function log(string memory p0, string memory p1, bool p2, uint256 p3) internal pure;
log
function log(string memory p0, string memory p1, bool p2, string memory p3) internal pure;
log
function log(string memory p0, string memory p1, bool p2, bool p3) internal pure;
log
function log(string memory p0, string memory p1, bool p2, address p3) internal pure;
log
function log(string memory p0, string memory p1, address p2, uint256 p3) internal pure;
log
function log(string memory p0, string memory p1, address p2, string memory p3) internal pure;
log
function log(string memory p0, string memory p1, address p2, bool p3) internal pure;
log
function log(string memory p0, string memory p1, address p2, address p3) internal pure;
log
function log(string memory p0, bool p1, uint256 p2, uint256 p3) internal pure;
log
function log(string memory p0, bool p1, uint256 p2, string memory p3) internal pure;
log
function log(string memory p0, bool p1, uint256 p2, bool p3) internal pure;
log
function log(string memory p0, bool p1, uint256 p2, address p3) internal pure;
log
function log(string memory p0, bool p1, string memory p2, uint256 p3) internal pure;
log
function log(string memory p0, bool p1, string memory p2, string memory p3) internal pure;
log
function log(string memory p0, bool p1, string memory p2, bool p3) internal pure;
log
function log(string memory p0, bool p1, string memory p2, address p3) internal pure;
log
function log(string memory p0, bool p1, bool p2, uint256 p3) internal pure;
log
function log(string memory p0, bool p1, bool p2, string memory p3) internal pure;
log
function log(string memory p0, bool p1, bool p2, bool p3) internal pure;
log
function log(string memory p0, bool p1, bool p2, address p3) internal pure;
log
function log(string memory p0, bool p1, address p2, uint256 p3) internal pure;
log
function log(string memory p0, bool p1, address p2, string memory p3) internal pure;
log
function log(string memory p0, bool p1, address p2, bool p3) internal pure;
log
function log(string memory p0, bool p1, address p2, address p3) internal pure;
log
function log(string memory p0, address p1, uint256 p2, uint256 p3) internal pure;
log
function log(string memory p0, address p1, uint256 p2, string memory p3) internal pure;
log
function log(string memory p0, address p1, uint256 p2, bool p3) internal pure;
log
function log(string memory p0, address p1, uint256 p2, address p3) internal pure;
log
function log(string memory p0, address p1, string memory p2, uint256 p3) internal pure;
log
function log(string memory p0, address p1, string memory p2, string memory p3) internal pure;
log
function log(string memory p0, address p1, string memory p2, bool p3) internal pure;
log
function log(string memory p0, address p1, string memory p2, address p3) internal pure;
log
function log(string memory p0, address p1, bool p2, uint256 p3) internal pure;
log
function log(string memory p0, address p1, bool p2, string memory p3) internal pure;
log
function log(string memory p0, address p1, bool p2, bool p3) internal pure;
log
function log(string memory p0, address p1, bool p2, address p3) internal pure;
log
function log(string memory p0, address p1, address p2, uint256 p3) internal pure;
log
function log(string memory p0, address p1, address p2, string memory p3) internal pure;
log
function log(string memory p0, address p1, address p2, bool p3) internal pure;
log
function log(string memory p0, address p1, address p2, address p3) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2, uint256 p3) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2, string memory p3) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2, bool p3) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2, address p3) internal pure;
log
function log(bool p0, uint256 p1, string memory p2, uint256 p3) internal pure;
log
function log(bool p0, uint256 p1, string memory p2, string memory p3) internal pure;
log
function log(bool p0, uint256 p1, string memory p2, bool p3) internal pure;
log
function log(bool p0, uint256 p1, string memory p2, address p3) internal pure;
log
function log(bool p0, uint256 p1, bool p2, uint256 p3) internal pure;
log
function log(bool p0, uint256 p1, bool p2, string memory p3) internal pure;
log
function log(bool p0, uint256 p1, bool p2, bool p3) internal pure;
log
function log(bool p0, uint256 p1, bool p2, address p3) internal pure;
log
function log(bool p0, uint256 p1, address p2, uint256 p3) internal pure;
log
function log(bool p0, uint256 p1, address p2, string memory p3) internal pure;
log
function log(bool p0, uint256 p1, address p2, bool p3) internal pure;
log
function log(bool p0, uint256 p1, address p2, address p3) internal pure;
log
function log(bool p0, string memory p1, uint256 p2, uint256 p3) internal pure;
log
function log(bool p0, string memory p1, uint256 p2, string memory p3) internal pure;
log
function log(bool p0, string memory p1, uint256 p2, bool p3) internal pure;
log
function log(bool p0, string memory p1, uint256 p2, address p3) internal pure;
log
function log(bool p0, string memory p1, string memory p2, uint256 p3) internal pure;
log
function log(bool p0, string memory p1, string memory p2, string memory p3) internal pure;
log
function log(bool p0, string memory p1, string memory p2, bool p3) internal pure;
log
function log(bool p0, string memory p1, string memory p2, address p3) internal pure;
log
function log(bool p0, string memory p1, bool p2, uint256 p3) internal pure;
log
function log(bool p0, string memory p1, bool p2, string memory p3) internal pure;
log
function log(bool p0, string memory p1, bool p2, bool p3) internal pure;
log
function log(bool p0, string memory p1, bool p2, address p3) internal pure;
log
function log(bool p0, string memory p1, address p2, uint256 p3) internal pure;
log
function log(bool p0, string memory p1, address p2, string memory p3) internal pure;
log
function log(bool p0, string memory p1, address p2, bool p3) internal pure;
log
function log(bool p0, string memory p1, address p2, address p3) internal pure;
log
function log(bool p0, bool p1, uint256 p2, uint256 p3) internal pure;
log
function log(bool p0, bool p1, uint256 p2, string memory p3) internal pure;
log
function log(bool p0, bool p1, uint256 p2, bool p3) internal pure;
log
function log(bool p0, bool p1, uint256 p2, address p3) internal pure;
log
function log(bool p0, bool p1, string memory p2, uint256 p3) internal pure;
log
function log(bool p0, bool p1, string memory p2, string memory p3) internal pure;
log
function log(bool p0, bool p1, string memory p2, bool p3) internal pure;
log
function log(bool p0, bool p1, string memory p2, address p3) internal pure;
log
function log(bool p0, bool p1, bool p2, uint256 p3) internal pure;
log
function log(bool p0, bool p1, bool p2, string memory p3) internal pure;
log
function log(bool p0, bool p1, bool p2, bool p3) internal pure;
log
function log(bool p0, bool p1, bool p2, address p3) internal pure;
log
function log(bool p0, bool p1, address p2, uint256 p3) internal pure;
log
function log(bool p0, bool p1, address p2, string memory p3) internal pure;
log
function log(bool p0, bool p1, address p2, bool p3) internal pure;
log
function log(bool p0, bool p1, address p2, address p3) internal pure;
log
function log(bool p0, address p1, uint256 p2, uint256 p3) internal pure;
log
function log(bool p0, address p1, uint256 p2, string memory p3) internal pure;
log
function log(bool p0, address p1, uint256 p2, bool p3) internal pure;
log
function log(bool p0, address p1, uint256 p2, address p3) internal pure;
log
function log(bool p0, address p1, string memory p2, uint256 p3) internal pure;
log
function log(bool p0, address p1, string memory p2, string memory p3) internal pure;
log
function log(bool p0, address p1, string memory p2, bool p3) internal pure;
log
function log(bool p0, address p1, string memory p2, address p3) internal pure;
log
function log(bool p0, address p1, bool p2, uint256 p3) internal pure;
log
function log(bool p0, address p1, bool p2, string memory p3) internal pure;
log
function log(bool p0, address p1, bool p2, bool p3) internal pure;
log
function log(bool p0, address p1, bool p2, address p3) internal pure;
log
function log(bool p0, address p1, address p2, uint256 p3) internal pure;
log
function log(bool p0, address p1, address p2, string memory p3) internal pure;
log
function log(bool p0, address p1, address p2, bool p3) internal pure;
log
function log(bool p0, address p1, address p2, address p3) internal pure;
log
function log(address p0, uint256 p1, uint256 p2, uint256 p3) internal pure;
log
function log(address p0, uint256 p1, uint256 p2, string memory p3) internal pure;
log
function log(address p0, uint256 p1, uint256 p2, bool p3) internal pure;
log
function log(address p0, uint256 p1, uint256 p2, address p3) internal pure;
log
function log(address p0, uint256 p1, string memory p2, uint256 p3) internal pure;
log
function log(address p0, uint256 p1, string memory p2, string memory p3) internal pure;
log
function log(address p0, uint256 p1, string memory p2, bool p3) internal pure;
log
function log(address p0, uint256 p1, string memory p2, address p3) internal pure;
log
function log(address p0, uint256 p1, bool p2, uint256 p3) internal pure;
log
function log(address p0, uint256 p1, bool p2, string memory p3) internal pure;
log
function log(address p0, uint256 p1, bool p2, bool p3) internal pure;
log
function log(address p0, uint256 p1, bool p2, address p3) internal pure;
log
function log(address p0, uint256 p1, address p2, uint256 p3) internal pure;
log
function log(address p0, uint256 p1, address p2, string memory p3) internal pure;
log
function log(address p0, uint256 p1, address p2, bool p3) internal pure;
log
function log(address p0, uint256 p1, address p2, address p3) internal pure;
log
function log(address p0, string memory p1, uint256 p2, uint256 p3) internal pure;
log
function log(address p0, string memory p1, uint256 p2, string memory p3) internal pure;
log
function log(address p0, string memory p1, uint256 p2, bool p3) internal pure;
log
function log(address p0, string memory p1, uint256 p2, address p3) internal pure;
log
function log(address p0, string memory p1, string memory p2, uint256 p3) internal pure;
log
function log(address p0, string memory p1, string memory p2, string memory p3) internal pure;
log
function log(address p0, string memory p1, string memory p2, bool p3) internal pure;
log
function log(address p0, string memory p1, string memory p2, address p3) internal pure;
log
function log(address p0, string memory p1, bool p2, uint256 p3) internal pure;
log
function log(address p0, string memory p1, bool p2, string memory p3) internal pure;
log
function log(address p0, string memory p1, bool p2, bool p3) internal pure;
log
function log(address p0, string memory p1, bool p2, address p3) internal pure;
log
function log(address p0, string memory p1, address p2, uint256 p3) internal pure;
log
function log(address p0, string memory p1, address p2, string memory p3) internal pure;
log
function log(address p0, string memory p1, address p2, bool p3) internal pure;
log
function log(address p0, string memory p1, address p2, address p3) internal pure;
log
function log(address p0, bool p1, uint256 p2, uint256 p3) internal pure;
log
function log(address p0, bool p1, uint256 p2, string memory p3) internal pure;
log
function log(address p0, bool p1, uint256 p2, bool p3) internal pure;
log
function log(address p0, bool p1, uint256 p2, address p3) internal pure;
log
function log(address p0, bool p1, string memory p2, uint256 p3) internal pure;
log
function log(address p0, bool p1, string memory p2, string memory p3) internal pure;
log
function log(address p0, bool p1, string memory p2, bool p3) internal pure;
log
function log(address p0, bool p1, string memory p2, address p3) internal pure;
log
function log(address p0, bool p1, bool p2, uint256 p3) internal pure;
log
function log(address p0, bool p1, bool p2, string memory p3) internal pure;
log
function log(address p0, bool p1, bool p2, bool p3) internal pure;
log
function log(address p0, bool p1, bool p2, address p3) internal pure;
log
function log(address p0, bool p1, address p2, uint256 p3) internal pure;
log
function log(address p0, bool p1, address p2, string memory p3) internal pure;
log
function log(address p0, bool p1, address p2, bool p3) internal pure;
log
function log(address p0, bool p1, address p2, address p3) internal pure;
log
function log(address p0, address p1, uint256 p2, uint256 p3) internal pure;
log
function log(address p0, address p1, uint256 p2, string memory p3) internal pure;
log
function log(address p0, address p1, uint256 p2, bool p3) internal pure;
log
function log(address p0, address p1, uint256 p2, address p3) internal pure;
log
function log(address p0, address p1, string memory p2, uint256 p3) internal pure;
log
function log(address p0, address p1, string memory p2, string memory p3) internal pure;
log
function log(address p0, address p1, string memory p2, bool p3) internal pure;
log
function log(address p0, address p1, string memory p2, address p3) internal pure;
log
function log(address p0, address p1, bool p2, uint256 p3) internal pure;
log
function log(address p0, address p1, bool p2, string memory p3) internal pure;
log
function log(address p0, address p1, bool p2, bool p3) internal pure;
log
function log(address p0, address p1, bool p2, address p3) internal pure;
log
function log(address p0, address p1, address p2, uint256 p3) internal pure;
log
function log(address p0, address p1, address p2, string memory p3) internal pure;
log
function log(address p0, address p1, address p2, bool p3) internal pure;
log
function log(address p0, address p1, address p2, address p3) internal pure;
safeconsole
Author: philogy https://github.com/philogy
Code generated automatically by script.
State Variables
CONSOLE_ADDR
uint256 constant CONSOLE_ADDR = 0x000000000000000000000000000000000000000000636F6e736F6c652e6c6f67;
Functions
_sendLogPayload
function _sendLogPayload(uint256 offset, uint256 size) private pure;
_sendLogPayloadView
function _sendLogPayloadView(uint256 offset, uint256 size) private view;
_memcopy
function _memcopy(uint256 fromOffset, uint256 toOffset, uint256 length) private pure;
_memcopyView
function _memcopyView(uint256 fromOffset, uint256 toOffset, uint256 length) private view;
logMemory
function logMemory(uint256 offset, uint256 length) internal pure;
log
function log(address p0) internal pure;
log
function log(bool p0) internal pure;
log
function log(uint256 p0) internal pure;
log
function log(bytes32 p0) internal pure;
log
function log(address p0, address p1) internal pure;
log
function log(address p0, bool p1) internal pure;
log
function log(address p0, uint256 p1) internal pure;
log
function log(address p0, bytes32 p1) internal pure;
log
function log(bool p0, address p1) internal pure;
log
function log(bool p0, bool p1) internal pure;
log
function log(bool p0, uint256 p1) internal pure;
log
function log(bool p0, bytes32 p1) internal pure;
log
function log(uint256 p0, address p1) internal pure;
log
function log(uint256 p0, bool p1) internal pure;
log
function log(uint256 p0, uint256 p1) internal pure;
log
function log(uint256 p0, bytes32 p1) internal pure;
log
function log(bytes32 p0, address p1) internal pure;
log
function log(bytes32 p0, bool p1) internal pure;
log
function log(bytes32 p0, uint256 p1) internal pure;
log
function log(bytes32 p0, bytes32 p1) internal pure;
log
function log(address p0, address p1, address p2) internal pure;
log
function log(address p0, address p1, bool p2) internal pure;
log
function log(address p0, address p1, uint256 p2) internal pure;
log
function log(address p0, address p1, bytes32 p2) internal pure;
log
function log(address p0, bool p1, address p2) internal pure;
log
function log(address p0, bool p1, bool p2) internal pure;
log
function log(address p0, bool p1, uint256 p2) internal pure;
log
function log(address p0, bool p1, bytes32 p2) internal pure;
log
function log(address p0, uint256 p1, address p2) internal pure;
log
function log(address p0, uint256 p1, bool p2) internal pure;
log
function log(address p0, uint256 p1, uint256 p2) internal pure;
log
function log(address p0, uint256 p1, bytes32 p2) internal pure;
log
function log(address p0, bytes32 p1, address p2) internal pure;
log
function log(address p0, bytes32 p1, bool p2) internal pure;
log
function log(address p0, bytes32 p1, uint256 p2) internal pure;
log
function log(address p0, bytes32 p1, bytes32 p2) internal pure;
log
function log(bool p0, address p1, address p2) internal pure;
log
function log(bool p0, address p1, bool p2) internal pure;
log
function log(bool p0, address p1, uint256 p2) internal pure;
log
function log(bool p0, address p1, bytes32 p2) internal pure;
log
function log(bool p0, bool p1, address p2) internal pure;
log
function log(bool p0, bool p1, bool p2) internal pure;
log
function log(bool p0, bool p1, uint256 p2) internal pure;
log
function log(bool p0, bool p1, bytes32 p2) internal pure;
log
function log(bool p0, uint256 p1, address p2) internal pure;
log
function log(bool p0, uint256 p1, bool p2) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2) internal pure;
log
function log(bool p0, uint256 p1, bytes32 p2) internal pure;
log
function log(bool p0, bytes32 p1, address p2) internal pure;
log
function log(bool p0, bytes32 p1, bool p2) internal pure;
log
function log(bool p0, bytes32 p1, uint256 p2) internal pure;
log
function log(bool p0, bytes32 p1, bytes32 p2) internal pure;
log
function log(uint256 p0, address p1, address p2) internal pure;
log
function log(uint256 p0, address p1, bool p2) internal pure;
log
function log(uint256 p0, address p1, uint256 p2) internal pure;
log
function log(uint256 p0, address p1, bytes32 p2) internal pure;
log
function log(uint256 p0, bool p1, address p2) internal pure;
log
function log(uint256 p0, bool p1, bool p2) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2) internal pure;
log
function log(uint256 p0, bool p1, bytes32 p2) internal pure;
log
function log(uint256 p0, uint256 p1, address p2) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2) internal pure;
log
function log(uint256 p0, uint256 p1, bytes32 p2) internal pure;
log
function log(uint256 p0, bytes32 p1, address p2) internal pure;
log
function log(uint256 p0, bytes32 p1, bool p2) internal pure;
log
function log(uint256 p0, bytes32 p1, uint256 p2) internal pure;
log
function log(uint256 p0, bytes32 p1, bytes32 p2) internal pure;
log
function log(bytes32 p0, address p1, address p2) internal pure;
log
function log(bytes32 p0, address p1, bool p2) internal pure;
log
function log(bytes32 p0, address p1, uint256 p2) internal pure;
log
function log(bytes32 p0, address p1, bytes32 p2) internal pure;
log
function log(bytes32 p0, bool p1, address p2) internal pure;
log
function log(bytes32 p0, bool p1, bool p2) internal pure;
log
function log(bytes32 p0, bool p1, uint256 p2) internal pure;
log
function log(bytes32 p0, bool p1, bytes32 p2) internal pure;
log
function log(bytes32 p0, uint256 p1, address p2) internal pure;
log
function log(bytes32 p0, uint256 p1, bool p2) internal pure;
log
function log(bytes32 p0, uint256 p1, uint256 p2) internal pure;
log
function log(bytes32 p0, uint256 p1, bytes32 p2) internal pure;
log
function log(bytes32 p0, bytes32 p1, address p2) internal pure;
log
function log(bytes32 p0, bytes32 p1, bool p2) internal pure;
log
function log(bytes32 p0, bytes32 p1, uint256 p2) internal pure;
log
function log(bytes32 p0, bytes32 p1, bytes32 p2) internal pure;
log
function log(address p0, address p1, address p2, address p3) internal pure;
log
function log(address p0, address p1, address p2, bool p3) internal pure;
log
function log(address p0, address p1, address p2, uint256 p3) internal pure;
log
function log(address p0, address p1, address p2, bytes32 p3) internal pure;
log
function log(address p0, address p1, bool p2, address p3) internal pure;
log
function log(address p0, address p1, bool p2, bool p3) internal pure;
log
function log(address p0, address p1, bool p2, uint256 p3) internal pure;
log
function log(address p0, address p1, bool p2, bytes32 p3) internal pure;
log
function log(address p0, address p1, uint256 p2, address p3) internal pure;
log
function log(address p0, address p1, uint256 p2, bool p3) internal pure;
log
function log(address p0, address p1, uint256 p2, uint256 p3) internal pure;
log
function log(address p0, address p1, uint256 p2, bytes32 p3) internal pure;
log
function log(address p0, address p1, bytes32 p2, address p3) internal pure;
log
function log(address p0, address p1, bytes32 p2, bool p3) internal pure;
log
function log(address p0, address p1, bytes32 p2, uint256 p3) internal pure;
log
function log(address p0, address p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(address p0, bool p1, address p2, address p3) internal pure;
log
function log(address p0, bool p1, address p2, bool p3) internal pure;
log
function log(address p0, bool p1, address p2, uint256 p3) internal pure;
log
function log(address p0, bool p1, address p2, bytes32 p3) internal pure;
log
function log(address p0, bool p1, bool p2, address p3) internal pure;
log
function log(address p0, bool p1, bool p2, bool p3) internal pure;
log
function log(address p0, bool p1, bool p2, uint256 p3) internal pure;
log
function log(address p0, bool p1, bool p2, bytes32 p3) internal pure;
log
function log(address p0, bool p1, uint256 p2, address p3) internal pure;
log
function log(address p0, bool p1, uint256 p2, bool p3) internal pure;
log
function log(address p0, bool p1, uint256 p2, uint256 p3) internal pure;
log
function log(address p0, bool p1, uint256 p2, bytes32 p3) internal pure;
log
function log(address p0, bool p1, bytes32 p2, address p3) internal pure;
log
function log(address p0, bool p1, bytes32 p2, bool p3) internal pure;
log
function log(address p0, bool p1, bytes32 p2, uint256 p3) internal pure;
log
function log(address p0, bool p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(address p0, uint256 p1, address p2, address p3) internal pure;
log
function log(address p0, uint256 p1, address p2, bool p3) internal pure;
log
function log(address p0, uint256 p1, address p2, uint256 p3) internal pure;
log
function log(address p0, uint256 p1, address p2, bytes32 p3) internal pure;
log
function log(address p0, uint256 p1, bool p2, address p3) internal pure;
log
function log(address p0, uint256 p1, bool p2, bool p3) internal pure;
log
function log(address p0, uint256 p1, bool p2, uint256 p3) internal pure;
log
function log(address p0, uint256 p1, bool p2, bytes32 p3) internal pure;
log
function log(address p0, uint256 p1, uint256 p2, address p3) internal pure;
log
function log(address p0, uint256 p1, uint256 p2, bool p3) internal pure;
log
function log(address p0, uint256 p1, uint256 p2, uint256 p3) internal pure;
log
function log(address p0, uint256 p1, uint256 p2, bytes32 p3) internal pure;
log
function log(address p0, uint256 p1, bytes32 p2, address p3) internal pure;
log
function log(address p0, uint256 p1, bytes32 p2, bool p3) internal pure;
log
function log(address p0, uint256 p1, bytes32 p2, uint256 p3) internal pure;
log
function log(address p0, uint256 p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(address p0, bytes32 p1, address p2, address p3) internal pure;
log
function log(address p0, bytes32 p1, address p2, bool p3) internal pure;
log
function log(address p0, bytes32 p1, address p2, uint256 p3) internal pure;
log
function log(address p0, bytes32 p1, address p2, bytes32 p3) internal pure;
log
function log(address p0, bytes32 p1, bool p2, address p3) internal pure;
log
function log(address p0, bytes32 p1, bool p2, bool p3) internal pure;
log
function log(address p0, bytes32 p1, bool p2, uint256 p3) internal pure;
log
function log(address p0, bytes32 p1, bool p2, bytes32 p3) internal pure;
log
function log(address p0, bytes32 p1, uint256 p2, address p3) internal pure;
log
function log(address p0, bytes32 p1, uint256 p2, bool p3) internal pure;
log
function log(address p0, bytes32 p1, uint256 p2, uint256 p3) internal pure;
log
function log(address p0, bytes32 p1, uint256 p2, bytes32 p3) internal pure;
log
function log(address p0, bytes32 p1, bytes32 p2, address p3) internal pure;
log
function log(address p0, bytes32 p1, bytes32 p2, bool p3) internal pure;
log
function log(address p0, bytes32 p1, bytes32 p2, uint256 p3) internal pure;
log
function log(address p0, bytes32 p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(bool p0, address p1, address p2, address p3) internal pure;
log
function log(bool p0, address p1, address p2, bool p3) internal pure;
log
function log(bool p0, address p1, address p2, uint256 p3) internal pure;
log
function log(bool p0, address p1, address p2, bytes32 p3) internal pure;
log
function log(bool p0, address p1, bool p2, address p3) internal pure;
log
function log(bool p0, address p1, bool p2, bool p3) internal pure;
log
function log(bool p0, address p1, bool p2, uint256 p3) internal pure;
log
function log(bool p0, address p1, bool p2, bytes32 p3) internal pure;
log
function log(bool p0, address p1, uint256 p2, address p3) internal pure;
log
function log(bool p0, address p1, uint256 p2, bool p3) internal pure;
log
function log(bool p0, address p1, uint256 p2, uint256 p3) internal pure;
log
function log(bool p0, address p1, uint256 p2, bytes32 p3) internal pure;
log
function log(bool p0, address p1, bytes32 p2, address p3) internal pure;
log
function log(bool p0, address p1, bytes32 p2, bool p3) internal pure;
log
function log(bool p0, address p1, bytes32 p2, uint256 p3) internal pure;
log
function log(bool p0, address p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(bool p0, bool p1, address p2, address p3) internal pure;
log
function log(bool p0, bool p1, address p2, bool p3) internal pure;
log
function log(bool p0, bool p1, address p2, uint256 p3) internal pure;
log
function log(bool p0, bool p1, address p2, bytes32 p3) internal pure;
log
function log(bool p0, bool p1, bool p2, address p3) internal pure;
log
function log(bool p0, bool p1, bool p2, bool p3) internal pure;
log
function log(bool p0, bool p1, bool p2, uint256 p3) internal pure;
log
function log(bool p0, bool p1, bool p2, bytes32 p3) internal pure;
log
function log(bool p0, bool p1, uint256 p2, address p3) internal pure;
log
function log(bool p0, bool p1, uint256 p2, bool p3) internal pure;
log
function log(bool p0, bool p1, uint256 p2, uint256 p3) internal pure;
log
function log(bool p0, bool p1, uint256 p2, bytes32 p3) internal pure;
log
function log(bool p0, bool p1, bytes32 p2, address p3) internal pure;
log
function log(bool p0, bool p1, bytes32 p2, bool p3) internal pure;
log
function log(bool p0, bool p1, bytes32 p2, uint256 p3) internal pure;
log
function log(bool p0, bool p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(bool p0, uint256 p1, address p2, address p3) internal pure;
log
function log(bool p0, uint256 p1, address p2, bool p3) internal pure;
log
function log(bool p0, uint256 p1, address p2, uint256 p3) internal pure;
log
function log(bool p0, uint256 p1, address p2, bytes32 p3) internal pure;
log
function log(bool p0, uint256 p1, bool p2, address p3) internal pure;
log
function log(bool p0, uint256 p1, bool p2, bool p3) internal pure;
log
function log(bool p0, uint256 p1, bool p2, uint256 p3) internal pure;
log
function log(bool p0, uint256 p1, bool p2, bytes32 p3) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2, address p3) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2, bool p3) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2, uint256 p3) internal pure;
log
function log(bool p0, uint256 p1, uint256 p2, bytes32 p3) internal pure;
log
function log(bool p0, uint256 p1, bytes32 p2, address p3) internal pure;
log
function log(bool p0, uint256 p1, bytes32 p2, bool p3) internal pure;
log
function log(bool p0, uint256 p1, bytes32 p2, uint256 p3) internal pure;
log
function log(bool p0, uint256 p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(bool p0, bytes32 p1, address p2, address p3) internal pure;
log
function log(bool p0, bytes32 p1, address p2, bool p3) internal pure;
log
function log(bool p0, bytes32 p1, address p2, uint256 p3) internal pure;
log
function log(bool p0, bytes32 p1, address p2, bytes32 p3) internal pure;
log
function log(bool p0, bytes32 p1, bool p2, address p3) internal pure;
log
function log(bool p0, bytes32 p1, bool p2, bool p3) internal pure;
log
function log(bool p0, bytes32 p1, bool p2, uint256 p3) internal pure;
log
function log(bool p0, bytes32 p1, bool p2, bytes32 p3) internal pure;
log
function log(bool p0, bytes32 p1, uint256 p2, address p3) internal pure;
log
function log(bool p0, bytes32 p1, uint256 p2, bool p3) internal pure;
log
function log(bool p0, bytes32 p1, uint256 p2, uint256 p3) internal pure;
log
function log(bool p0, bytes32 p1, uint256 p2, bytes32 p3) internal pure;
log
function log(bool p0, bytes32 p1, bytes32 p2, address p3) internal pure;
log
function log(bool p0, bytes32 p1, bytes32 p2, bool p3) internal pure;
log
function log(bool p0, bytes32 p1, bytes32 p2, uint256 p3) internal pure;
log
function log(bool p0, bytes32 p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(uint256 p0, address p1, address p2, address p3) internal pure;
log
function log(uint256 p0, address p1, address p2, bool p3) internal pure;
log
function log(uint256 p0, address p1, address p2, uint256 p3) internal pure;
log
function log(uint256 p0, address p1, address p2, bytes32 p3) internal pure;
log
function log(uint256 p0, address p1, bool p2, address p3) internal pure;
log
function log(uint256 p0, address p1, bool p2, bool p3) internal pure;
log
function log(uint256 p0, address p1, bool p2, uint256 p3) internal pure;
log
function log(uint256 p0, address p1, bool p2, bytes32 p3) internal pure;
log
function log(uint256 p0, address p1, uint256 p2, address p3) internal pure;
log
function log(uint256 p0, address p1, uint256 p2, bool p3) internal pure;
log
function log(uint256 p0, address p1, uint256 p2, uint256 p3) internal pure;
log
function log(uint256 p0, address p1, uint256 p2, bytes32 p3) internal pure;
log
function log(uint256 p0, address p1, bytes32 p2, address p3) internal pure;
log
function log(uint256 p0, address p1, bytes32 p2, bool p3) internal pure;
log
function log(uint256 p0, address p1, bytes32 p2, uint256 p3) internal pure;
log
function log(uint256 p0, address p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(uint256 p0, bool p1, address p2, address p3) internal pure;
log
function log(uint256 p0, bool p1, address p2, bool p3) internal pure;
log
function log(uint256 p0, bool p1, address p2, uint256 p3) internal pure;
log
function log(uint256 p0, bool p1, address p2, bytes32 p3) internal pure;
log
function log(uint256 p0, bool p1, bool p2, address p3) internal pure;
log
function log(uint256 p0, bool p1, bool p2, bool p3) internal pure;
log
function log(uint256 p0, bool p1, bool p2, uint256 p3) internal pure;
log
function log(uint256 p0, bool p1, bool p2, bytes32 p3) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2, address p3) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2, bool p3) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2, uint256 p3) internal pure;
log
function log(uint256 p0, bool p1, uint256 p2, bytes32 p3) internal pure;
log
function log(uint256 p0, bool p1, bytes32 p2, address p3) internal pure;
log
function log(uint256 p0, bool p1, bytes32 p2, bool p3) internal pure;
log
function log(uint256 p0, bool p1, bytes32 p2, uint256 p3) internal pure;
log
function log(uint256 p0, bool p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(uint256 p0, uint256 p1, address p2, address p3) internal pure;
log
function log(uint256 p0, uint256 p1, address p2, bool p3) internal pure;
log
function log(uint256 p0, uint256 p1, address p2, uint256 p3) internal pure;
log
function log(uint256 p0, uint256 p1, address p2, bytes32 p3) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2, address p3) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2, bool p3) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2, uint256 p3) internal pure;
log
function log(uint256 p0, uint256 p1, bool p2, bytes32 p3) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2, address p3) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2, bool p3) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2, uint256 p3) internal pure;
log
function log(uint256 p0, uint256 p1, uint256 p2, bytes32 p3) internal pure;
log
function log(uint256 p0, uint256 p1, bytes32 p2, address p3) internal pure;
log
function log(uint256 p0, uint256 p1, bytes32 p2, bool p3) internal pure;
log
function log(uint256 p0, uint256 p1, bytes32 p2, uint256 p3) internal pure;
log
function log(uint256 p0, uint256 p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(uint256 p0, bytes32 p1, address p2, address p3) internal pure;
log
function log(uint256 p0, bytes32 p1, address p2, bool p3) internal pure;
log
function log(uint256 p0, bytes32 p1, address p2, uint256 p3) internal pure;
log
function log(uint256 p0, bytes32 p1, address p2, bytes32 p3) internal pure;
log
function log(uint256 p0, bytes32 p1, bool p2, address p3) internal pure;
log
function log(uint256 p0, bytes32 p1, bool p2, bool p3) internal pure;
log
function log(uint256 p0, bytes32 p1, bool p2, uint256 p3) internal pure;
log
function log(uint256 p0, bytes32 p1, bool p2, bytes32 p3) internal pure;
log
function log(uint256 p0, bytes32 p1, uint256 p2, address p3) internal pure;
log
function log(uint256 p0, bytes32 p1, uint256 p2, bool p3) internal pure;
log
function log(uint256 p0, bytes32 p1, uint256 p2, uint256 p3) internal pure;
log
function log(uint256 p0, bytes32 p1, uint256 p2, bytes32 p3) internal pure;
log
function log(uint256 p0, bytes32 p1, bytes32 p2, address p3) internal pure;
log
function log(uint256 p0, bytes32 p1, bytes32 p2, bool p3) internal pure;
log
function log(uint256 p0, bytes32 p1, bytes32 p2, uint256 p3) internal pure;
log
function log(uint256 p0, bytes32 p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, address p1, address p2, address p3) internal pure;
log
function log(bytes32 p0, address p1, address p2, bool p3) internal pure;
log
function log(bytes32 p0, address p1, address p2, uint256 p3) internal pure;
log
function log(bytes32 p0, address p1, address p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, address p1, bool p2, address p3) internal pure;
log
function log(bytes32 p0, address p1, bool p2, bool p3) internal pure;
log
function log(bytes32 p0, address p1, bool p2, uint256 p3) internal pure;
log
function log(bytes32 p0, address p1, bool p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, address p1, uint256 p2, address p3) internal pure;
log
function log(bytes32 p0, address p1, uint256 p2, bool p3) internal pure;
log
function log(bytes32 p0, address p1, uint256 p2, uint256 p3) internal pure;
log
function log(bytes32 p0, address p1, uint256 p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, address p1, bytes32 p2, address p3) internal pure;
log
function log(bytes32 p0, address p1, bytes32 p2, bool p3) internal pure;
log
function log(bytes32 p0, address p1, bytes32 p2, uint256 p3) internal pure;
log
function log(bytes32 p0, address p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, bool p1, address p2, address p3) internal pure;
log
function log(bytes32 p0, bool p1, address p2, bool p3) internal pure;
log
function log(bytes32 p0, bool p1, address p2, uint256 p3) internal pure;
log
function log(bytes32 p0, bool p1, address p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, bool p1, bool p2, address p3) internal pure;
log
function log(bytes32 p0, bool p1, bool p2, bool p3) internal pure;
log
function log(bytes32 p0, bool p1, bool p2, uint256 p3) internal pure;
log
function log(bytes32 p0, bool p1, bool p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, bool p1, uint256 p2, address p3) internal pure;
log
function log(bytes32 p0, bool p1, uint256 p2, bool p3) internal pure;
log
function log(bytes32 p0, bool p1, uint256 p2, uint256 p3) internal pure;
log
function log(bytes32 p0, bool p1, uint256 p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, bool p1, bytes32 p2, address p3) internal pure;
log
function log(bytes32 p0, bool p1, bytes32 p2, bool p3) internal pure;
log
function log(bytes32 p0, bool p1, bytes32 p2, uint256 p3) internal pure;
log
function log(bytes32 p0, bool p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, uint256 p1, address p2, address p3) internal pure;
log
function log(bytes32 p0, uint256 p1, address p2, bool p3) internal pure;
log
function log(bytes32 p0, uint256 p1, address p2, uint256 p3) internal pure;
log
function log(bytes32 p0, uint256 p1, address p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, uint256 p1, bool p2, address p3) internal pure;
log
function log(bytes32 p0, uint256 p1, bool p2, bool p3) internal pure;
log
function log(bytes32 p0, uint256 p1, bool p2, uint256 p3) internal pure;
log
function log(bytes32 p0, uint256 p1, bool p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, uint256 p1, uint256 p2, address p3) internal pure;
log
function log(bytes32 p0, uint256 p1, uint256 p2, bool p3) internal pure;
log
function log(bytes32 p0, uint256 p1, uint256 p2, uint256 p3) internal pure;
log
function log(bytes32 p0, uint256 p1, uint256 p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, uint256 p1, bytes32 p2, address p3) internal pure;
log
function log(bytes32 p0, uint256 p1, bytes32 p2, bool p3) internal pure;
log
function log(bytes32 p0, uint256 p1, bytes32 p2, uint256 p3) internal pure;
log
function log(bytes32 p0, uint256 p1, bytes32 p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, address p2, address p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, address p2, bool p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, address p2, uint256 p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, address p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, bool p2, address p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, bool p2, bool p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, bool p2, uint256 p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, bool p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, uint256 p2, address p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, uint256 p2, bool p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, uint256 p2, uint256 p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, uint256 p2, bytes32 p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, bytes32 p2, address p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, bytes32 p2, bool p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, bytes32 p2, uint256 p3) internal pure;
log
function log(bytes32 p0, bytes32 p1, bytes32 p2, bytes32 p3) internal pure;
Contents
- compilation
- VmInternal
- StdAssertionsTest
- TestMockCall
- StdChainsMock
- StdChainsTest
- StdCheatsTest
- StdCheatsMock
- StdCheatsForkTest
- Bar
- BarERC1155
- BarERC721
- USDCLike
- USDTLike
- RevertingContract
- MockContractWithConstructorArgs
- MockContractPayable
- StdErrorsTest
- ErrorsTest
- StdJsonTest
- StdMathMock
- StdMathTest
- StdStorageTest
- StorageTestTarget
- StorageTest
- StdStyleTest
- StdTomlTest
- StdUtilsMock
- StdUtilsTest
- StdUtilsForkTest
- VmTest
Contents
CompilationScript
Inherits: Script
CompilationScriptBase
Inherits: ScriptBase
CompilationTest
Inherits: Test
CompilationTestBase
Inherits: TestBase
VmInternal
Inherits: Vm
Functions
_expectCheatcodeRevert
function _expectCheatcodeRevert(bytes memory message) external;
StdAssertionsTest
Inherits: StdAssertions
State Variables
errorMessage
string constant errorMessage = "User provided message";
maxDecimals
uint256 constant maxDecimals = 77;
SHOULD_REVERT
bool constant SHOULD_REVERT = true;
SHOULD_RETURN
bool constant SHOULD_RETURN = false;
STRICT_REVERT_DATA
bool constant STRICT_REVERT_DATA = true;
NON_STRICT_REVERT_DATA
bool constant NON_STRICT_REVERT_DATA = false;
vm
VmInternal constant vm = VmInternal(address(uint160(uint256(keccak256("hevm cheat code")))));
Functions
testFuzz_AssertEqCall_Return_Pass
function testFuzz_AssertEqCall_Return_Pass(
bytes memory callDataA,
bytes memory callDataB,
bytes memory returnData,
bool strictRevertData
) external;
testFuzz_RevertWhenCalled_AssertEqCall_Return_Fail
function testFuzz_RevertWhenCalled_AssertEqCall_Return_Fail(
bytes memory callDataA,
bytes memory callDataB,
bytes memory returnDataA,
bytes memory returnDataB,
bool strictRevertData
) external;
testFuzz_AssertEqCall_Revert_Pass
function testFuzz_AssertEqCall_Revert_Pass(
bytes memory callDataA,
bytes memory callDataB,
bytes memory revertDataA,
bytes memory revertDataB
) external;
testFuzz_RevertWhenCalled_AssertEqCall_Revert_Fail
function testFuzz_RevertWhenCalled_AssertEqCall_Revert_Fail(
bytes memory callDataA,
bytes memory callDataB,
bytes memory revertDataA,
bytes memory revertDataB
) external;
testFuzz_RevertWhenCalled_AssertEqCall_Fail
function testFuzz_RevertWhenCalled_AssertEqCall_Fail(
bytes memory callDataA,
bytes memory callDataB,
bytes memory returnDataA,
bytes memory returnDataB,
bool strictRevertData
) external;
assertEqCallExternal
function assertEqCallExternal(
address targetA,
bytes memory callDataA,
address targetB,
bytes memory callDataB,
bool strictRevertData
) public;
TestMockCall
State Variables
returnData
bytes returnData;
shouldRevert
bool shouldRevert;
Functions
constructor
constructor(bytes memory returnData_, bool shouldRevert_);
fallback
fallback() external payable;
StdChainsMock
Inherits: Test
Functions
exposed_getChain
function exposed_getChain(string memory chainAlias) public returns (Chain memory);
exposed_getChain
function exposed_getChain(uint256 chainId) public returns (Chain memory);
exposed_setChain
function exposed_setChain(string memory chainAlias, ChainData memory chainData) public;
exposed_setFallbackToDefaultRpcUrls
function exposed_setFallbackToDefaultRpcUrls(bool useDefault) public;
StdChainsTest
Inherits: Test
Functions
test_ChainRpcInitialization
function test_ChainRpcInitialization() public;
_testRpc
function _testRpc(string memory rpcAlias) internal;
test_RevertIf_ChainNotFound
function test_RevertIf_ChainNotFound() public;
test_RevertIf_SetChain_ChainIdExist_FirstTest
function test_RevertIf_SetChain_ChainIdExist_FirstTest() public;
test_RevertIf_ChainBubbleUp
function test_RevertIf_ChainBubbleUp() public;
test_RevertIf_SetChain_ChainIdExists_SecondTest
function test_RevertIf_SetChain_ChainIdExists_SecondTest() public;
test_SetChain
function test_SetChain() public;
test_RevertIf_SetEmptyAlias
function test_RevertIf_SetEmptyAlias() public;
test_RevertIf_SetNoChainId0
function test_RevertIf_SetNoChainId0() public;
test_RevertIf_GetNoChainId0
function test_RevertIf_GetNoChainId0() public;
test_RevertIf_GetNoEmptyAlias
function test_RevertIf_GetNoEmptyAlias() public;
test_RevertIf_ChainIdNotFound
function test_RevertIf_ChainIdNotFound() public;
test_RevertIf_ChainAliasNotFound
function test_RevertIf_ChainAliasNotFound() public;
test_SetChain_ExistingOne
function test_SetChain_ExistingOne() public;
test_RevertIf_DontUseDefaultRpcUrl
function test_RevertIf_DontUseDefaultRpcUrl() public;
StdCheatsTest
Inherits: Test
State Variables
test
Bar test;
Functions
setUp
function setUp() public;
test_Skip
function test_Skip() public;
test_Rewind
function test_Rewind() public;
test_Hoax
function test_Hoax() public;
test_HoaxOrigin
function test_HoaxOrigin() public;
test_HoaxDifferentAddresses
function test_HoaxDifferentAddresses() public;
test_StartHoax
function test_StartHoax() public;
test_StartHoaxOrigin
function test_StartHoaxOrigin() public;
test_ChangePrankMsgSender
function test_ChangePrankMsgSender() public;
test_ChangePrankMsgSenderAndTxOrigin
function test_ChangePrankMsgSenderAndTxOrigin() public;
test_MakeAccountEquivalence
function test_MakeAccountEquivalence() public;
test_MakeAddrEquivalence
function test_MakeAddrEquivalence() public;
test_MakeAddrSigning
function test_MakeAddrSigning() public;
test_Deal
function test_Deal() public;
test_DealToken
function test_DealToken() public;
test_DealTokenAdjustTotalSupply
function test_DealTokenAdjustTotalSupply() public;
test_DealERC1155Token
function test_DealERC1155Token() public;
test_DealERC1155TokenAdjustTotalSupply
function test_DealERC1155TokenAdjustTotalSupply() public;
test_DealERC721Token
function test_DealERC721Token() public;
test_DeployCode
function test_DeployCode() public;
test_DestroyAccount
function test_DestroyAccount() public;
test_DeployCodeNoArgs
function test_DeployCodeNoArgs() public;
test_DeployCodeVal
function test_DeployCodeVal() public;
test_DeployCodeValNoArgs
function test_DeployCodeValNoArgs() public;
deployCodeHelper
function deployCodeHelper(string memory what) external;
test_RevertIf_DeployCodeFail
function test_RevertIf_DeployCodeFail() public;
getCode
function getCode(address who) internal view returns (bytes memory o_code);
test_DeriveRememberKey
function test_DeriveRememberKey() public;
test_BytesToUint
function test_BytesToUint() public pure;
test_ParseJsonTxDetail
function test_ParseJsonTxDetail() public view;
test_ReadEIP1559Transaction
function test_ReadEIP1559Transaction() public view;
test_ReadEIP1559Transactions
function test_ReadEIP1559Transactions() public view;
test_ReadReceipt
function test_ReadReceipt() public view;
test_ReadReceipts
function test_ReadReceipts() public view;
test_GasMeteringModifier
function test_GasMeteringModifier() public;
addInLoop
function addInLoop() internal pure returns (uint256);
addInLoopNoGas
function addInLoopNoGas() internal noGasMetering returns (uint256);
addInLoopNoGasNoGas
function addInLoopNoGasNoGas() internal noGasMetering returns (uint256);
bytesToUint_test
function bytesToUint_test(bytes memory b) private pure returns (uint256);
testFuzz_AssumeAddressIsNot
function testFuzz_AssumeAddressIsNot(address addr) external;
test_AssumePayable
function test_AssumePayable() external;
test_AssumeNotPayable
function test_AssumeNotPayable() external;
testFuzz_AssumeNotPrecompile
function testFuzz_AssumeNotPrecompile(address addr) external;
testFuzz_AssumeNotForgeAddress
function testFuzz_AssumeNotForgeAddress(address addr) external pure;
test_RevertIf_CannotDeployCodeTo
function test_RevertIf_CannotDeployCodeTo() external;
_revertDeployCodeTo
function _revertDeployCodeTo() external;
test_DeployCodeTo
function test_DeployCodeTo() external;
StdCheatsMock
Inherits: StdCheats
Functions
exposed_assumePayable
function exposed_assumePayable(address addr) external;
exposed_assumeNotPayable
function exposed_assumeNotPayable(address addr) external;
exposed_assumeNotBlacklisted
function exposed_assumeNotBlacklisted(address token, address addr) external view;
StdCheatsForkTest
Inherits: Test
State Variables
SHIB
address internal constant SHIB = 0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE;
USDC
address internal constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
USDC_BLACKLISTED_USER
address internal constant USDC_BLACKLISTED_USER = 0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD;
USDT
address internal constant USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
USDT_BLACKLISTED_USER
address internal constant USDT_BLACKLISTED_USER = 0x8f8a8F4B54a2aAC7799d7bc81368aC27b852822A;
Functions
setUp
function setUp() public;
test_RevertIf_CannotAssumeNoBlacklisted_EOA
function test_RevertIf_CannotAssumeNoBlacklisted_EOA() external;
testFuzz_AssumeNotBlacklisted_TokenWithoutBlacklist
function testFuzz_AssumeNotBlacklisted_TokenWithoutBlacklist(address addr) external view;
test_RevertIf_AssumeNoBlacklisted_USDC
function test_RevertIf_AssumeNoBlacklisted_USDC() external;
testFuzz_AssumeNotBlacklisted_USDC
function testFuzz_AssumeNotBlacklisted_USDC(address addr) external view;
test_RevertIf_AssumeNoBlacklisted_USDT
function test_RevertIf_AssumeNoBlacklisted_USDT() external;
testFuzz_AssumeNotBlacklisted_USDT
function testFuzz_AssumeNotBlacklisted_USDT(address addr) external view;
test_dealUSDC
function test_dealUSDC() external;
Bar
State Variables
balanceOf
DEAL STDCHEAT
mapping(address => uint256) public balanceOf;
totalSupply
uint256 public totalSupply;
Functions
constructor
constructor() payable;
bar
HOAX and CHANGEPRANK STDCHEATS
function bar(address expectedSender) public payable;
origin
function origin(address expectedSender) public payable;
origin
function origin(address expectedSender, address expectedOrigin) public payable;
BarERC1155
State Variables
_balances
DEALERC1155 STDCHEAT
mapping(uint256 => mapping(address => uint256)) private _balances;
_totalSupply
mapping(uint256 => uint256) private _totalSupply;
Functions
constructor
constructor() payable;
balanceOf
function balanceOf(address account, uint256 id) public view virtual returns (uint256);
totalSupply
function totalSupply(uint256 id) public view virtual returns (uint256);
BarERC721
State Variables
_owners
mapping(uint256 => address) private _owners;
_balances
mapping(address => uint256) private _balances;
Functions
constructor
constructor() payable;
balanceOf
function balanceOf(address owner) public view virtual returns (uint256);
ownerOf
function ownerOf(uint256 tokenId) public view virtual returns (address);
USDCLike
Functions
isBlacklisted
function isBlacklisted(address) external view returns (bool);
USDTLike
Functions
isBlackListed
function isBlackListed(address) external view returns (bool);
RevertingContract
Functions
constructor
constructor();
MockContractWithConstructorArgs
State Variables
x
uint256 public immutable x;
y
bool public y;
z
bytes20 public z;
Functions
constructor
constructor(uint256 _x, bool _y, bytes20 _z) payable;
MockContractPayable
Functions
receive
receive() external payable;
StdErrorsTest
Inherits: Test
State Variables
test
ErrorsTest test;
Functions
setUp
function setUp() public;
test_RevertIf_AssertionError
function test_RevertIf_AssertionError() public;
test_RevertIf_ArithmeticError
function test_RevertIf_ArithmeticError() public;
test_RevertIf_DivisionError
function test_RevertIf_DivisionError() public;
test_RevertIf_ModError
function test_RevertIf_ModError() public;
test_RevertIf_EnumConversionError
function test_RevertIf_EnumConversionError() public;
test_RevertIf_EncodeStgError
function test_RevertIf_EncodeStgError() public;
test_RevertIf_PopError
function test_RevertIf_PopError() public;
test_RevertIf_IndexOOBError
function test_RevertIf_IndexOOBError() public;
test_RevertIf_MemOverflowError
function test_RevertIf_MemOverflowError() public;
test_RevertIf_InternError
function test_RevertIf_InternError() public;
ErrorsTest
State Variables
someArr
uint256[] public someArr;
someBytes
bytes someBytes;
Functions
assertionError
function assertionError() public pure;
arithmeticError
function arithmeticError(uint256 a) public pure;
divError
function divError(uint256 a) public pure;
modError
function modError(uint256 a) public pure;
enumConversion
function enumConversion(uint256 a) public pure;
encodeStgError
function encodeStgError() public;
pop
function pop() public;
indexOOBError
function indexOOBError(uint256 a) public pure;
mem
function mem() public pure;
intern
function intern() public returns (uint256);
Enums
T
enum T {
T1
}
StdJsonTest
Inherits: Test
State Variables
root
string root;
path
string path;
Functions
setUp
function setUp() public;
test_readJson
function test_readJson() public view;
test_writeJson
function test_writeJson() public;
Structs
SimpleJson
struct SimpleJson {
uint256 a;
string b;
}
NestedJson
struct NestedJson {
uint256 a;
string b;
SimpleJson c;
}
StdMathMock
Inherits: Test
Functions
exposed_percentDelta
function exposed_percentDelta(uint256 a, uint256 b) public pure returns (uint256);
exposed_percentDelta
function exposed_percentDelta(int256 a, int256 b) public pure returns (uint256);
StdMathTest
Inherits: Test
Functions
test_GetAbs
function test_GetAbs() external pure;
testFuzz_GetAbs
function testFuzz_GetAbs(int256 a) external pure;
test_GetDelta_Uint
function test_GetDelta_Uint() external pure;
testFuzz_GetDelta_Uint
function testFuzz_GetDelta_Uint(uint256 a, uint256 b) external pure;
test_GetDelta_Int
function test_GetDelta_Int() external pure;
testFuzz_GetDelta_Int
function testFuzz_GetDelta_Int(int256 a, int256 b) external pure;
test_GetPercentDelta_Uint
function test_GetPercentDelta_Uint() external;
testFuzz_GetPercentDelta_Uint
function testFuzz_GetPercentDelta_Uint(uint192 a, uint192 b) external pure;
test_GetPercentDelta_Int
function test_GetPercentDelta_Int() external;
testFuzz_GetPercentDelta_Int
function testFuzz_GetPercentDelta_Int(int192 a, int192 b) external pure;
getAbs
function getAbs(int256 a) private pure returns (uint256);
StdStorageTest
Inherits: Test
State Variables
test
StorageTest internal test;
Functions
setUp
function setUp() public;
test_StorageHidden
function test_StorageHidden() public;
test_StorageObvious
function test_StorageObvious() public;
test_StorageExtraSload
function test_StorageExtraSload() public;
test_StorageCheckedWriteHidden
function test_StorageCheckedWriteHidden() public;
test_StorageCheckedWriteObvious
function test_StorageCheckedWriteObvious() public;
test_StorageCheckedWriteSignedIntegerHidden
function test_StorageCheckedWriteSignedIntegerHidden() public;
test_StorageCheckedWriteSignedIntegerObvious
function test_StorageCheckedWriteSignedIntegerObvious() public;
test_StorageMapStructA
function test_StorageMapStructA() public;
test_StorageMapStructB
function test_StorageMapStructB() public;
test_StorageDeepMap
function test_StorageDeepMap() public;
test_StorageCheckedWriteDeepMap
function test_StorageCheckedWriteDeepMap() public;
test_StorageDeepMapStructA
function test_StorageDeepMapStructA() public;
test_StorageDeepMapStructB
function test_StorageDeepMapStructB() public;
test_StorageCheckedWriteDeepMapStructA
function test_StorageCheckedWriteDeepMapStructA() public;
test_StorageCheckedWriteDeepMapStructB
function test_StorageCheckedWriteDeepMapStructB() public;
test_StorageCheckedWriteMapStructA
function test_StorageCheckedWriteMapStructA() public;
test_StorageCheckedWriteMapStructB
function test_StorageCheckedWriteMapStructB() public;
test_StorageStructA
function test_StorageStructA() public;
test_StorageStructB
function test_StorageStructB() public;
test_StorageCheckedWriteStructA
function test_StorageCheckedWriteStructA() public;
test_StorageCheckedWriteStructB
function test_StorageCheckedWriteStructB() public;
test_StorageMapAddrFound
function test_StorageMapAddrFound() public;
test_StorageMapAddrRoot
function test_StorageMapAddrRoot() public;
test_StorageMapUintFound
function test_StorageMapUintFound() public;
test_StorageCheckedWriteMapUint
function test_StorageCheckedWriteMapUint() public;
test_StorageCheckedWriteMapAddr
function test_StorageCheckedWriteMapAddr() public;
test_StorageCheckedWriteMapBool
function test_StorageCheckedWriteMapBool() public;
testFuzz_StorageCheckedWriteMapPacked
function testFuzz_StorageCheckedWriteMapPacked(address addr, uint128 value) public;
test_StorageCheckedWriteMapPackedFullSuccess
function test_StorageCheckedWriteMapPackedFullSuccess() public;
test_RevertStorageConst
function test_RevertStorageConst() public;
testFuzz_StorageNativePack
function testFuzz_StorageNativePack(uint248 val1, uint248 val2, bool boolVal1, bool boolVal2) public;
test_StorageReadBytes32
function test_StorageReadBytes32() public;
test_StorageReadBool_False
function test_StorageReadBool_False() public;
test_StorageReadBool_True
function test_StorageReadBool_True() public;
test_RevertIf_ReadingNonBoolValue
function test_RevertIf_ReadingNonBoolValue() public;
readNonBoolValue
function readNonBoolValue() public;
test_StorageReadAddress
function test_StorageReadAddress() public;
test_StorageReadUint
function test_StorageReadUint() public;
test_StorageReadInt
function test_StorageReadInt() public;
testFuzz_Packed
function testFuzz_Packed(uint256 val, uint8 elemToGet) public;
testFuzz_Packed2
function testFuzz_Packed2(uint256 nvars, uint256 seed) public;
testEdgeCaseArray
function testEdgeCaseArray() public;
StorageTestTarget
State Variables
stdstore
StdStorage internal stdstore;
test
StorageTest internal test;
Functions
constructor
constructor(StorageTest test_);
expectRevertStorageConst
function expectRevertStorageConst() public;
StorageTest
State Variables
exists
uint256 public exists = 1;
map_addr
mapping(address => uint256) public map_addr;
map_uint
mapping(uint256 => uint256) public map_uint;
map_packed
mapping(address => uint256) public map_packed;
map_struct
mapping(address => UnpackedStruct) public map_struct;
deep_map
mapping(address => mapping(address => uint256)) public deep_map;
deep_map_struct
mapping(address => mapping(address => UnpackedStruct)) public deep_map_struct;
basic
UnpackedStruct public basic;
tA
uint248 public tA;
tB
bool public tB;
tC
bool public tC = false;
tD
uint248 public tD = 1;
map_bool
mapping(address => bool) public map_bool;
tE
bytes32 public tE = hex"1337";
tF
address public tF = address(1337);
tG
int256 public tG = type(int256).min;
tH
bool public tH = true;
tI
bytes32 private tI = ~bytes32(hex"1337");
randomPacking
uint256 randomPacking;
edgeCaseArray
uint256[] public edgeCaseArray = [3, 3, 3];
Functions
constructor
constructor();
read_struct_upper
function read_struct_upper(address who) public view returns (uint256);
read_struct_lower
function read_struct_lower(address who) public view returns (uint256);
hidden
function hidden() public view returns (bytes32 t);
const
function const() public pure returns (bytes32 t);
extra_sload
function extra_sload() public view returns (bytes32 t);
setRandomPacking
function setRandomPacking(uint256 val) public;
_getMask
function _getMask(uint256 size) internal pure returns (uint256 mask);
setRandomPacking
function setRandomPacking(uint256 val, uint256 size, uint256 offset) public;
getRandomPacked
function getRandomPacked(uint256 size, uint256 offset) public view returns (uint256);
getRandomPacked
function getRandomPacked(uint8 shifts, uint8[] memory shiftSizes, uint8 elem) public view returns (uint256);
Structs
UnpackedStruct
struct UnpackedStruct {
uint256 a;
uint256 b;
}
StdStyleTest
Inherits: Test
Functions
test_StyleColor
function test_StyleColor() public pure;
test_StyleFontWeight
function test_StyleFontWeight() public pure;
test_StyleCombined
function test_StyleCombined() public pure;
test_StyleCustom
function test_StyleCustom() public pure;
h1
function h1(string memory a) private pure returns (string memory);
h2
function h2(string memory a) private pure returns (string memory);
StdTomlTest
Inherits: Test
State Variables
root
string root;
path
string path;
Functions
setUp
function setUp() public;
test_readToml
function test_readToml() public view;
test_writeToml
function test_writeToml() public;
Structs
SimpleToml
struct SimpleToml {
uint256 a;
string b;
}
NestedToml
struct NestedToml {
uint256 a;
string b;
SimpleToml c;
}
StdUtilsMock
Inherits: StdUtils
Functions
exposed_getTokenBalances
function exposed_getTokenBalances(address token, address[] memory addresses)
external
returns (uint256[] memory balances);
exposed_bound
function exposed_bound(int256 num, int256 min, int256 max) external pure returns (int256);
exposed_bound
function exposed_bound(uint256 num, uint256 min, uint256 max) external pure returns (uint256);
exposed_bytesToUint
function exposed_bytesToUint(bytes memory b) external pure returns (uint256);
StdUtilsTest
Inherits: Test
Functions
test_Bound
function test_Bound() public pure;
test_Bound_WithinRange
function test_Bound_WithinRange() public pure;
test_Bound_EdgeCoverage
function test_Bound_EdgeCoverage() public pure;
testFuzz_Bound_DistributionIsEven
function testFuzz_Bound_DistributionIsEven(uint256 min, uint256 size) public pure;
testFuzz_Bound
function testFuzz_Bound(uint256 num, uint256 min, uint256 max) public pure;
test_BoundUint256Max
function test_BoundUint256Max() public pure;
test_RevertIf_BoundMaxLessThanMin
function test_RevertIf_BoundMaxLessThanMin() public;
testFuzz_RevertIf_BoundMaxLessThanMin
function testFuzz_RevertIf_BoundMaxLessThanMin(uint256 num, uint256 min, uint256 max) public;
test_BoundInt
function test_BoundInt() public pure;
test_BoundInt_WithinRange
function test_BoundInt_WithinRange() public pure;
test_BoundInt_EdgeCoverage
function test_BoundInt_EdgeCoverage() public pure;
testFuzz_BoundInt_DistributionIsEven
function testFuzz_BoundInt_DistributionIsEven(int256 min, uint256 size) public pure;
testFuzz_BoundInt
function testFuzz_BoundInt(int256 num, int256 min, int256 max) public pure;
test_BoundIntInt256Max
function test_BoundIntInt256Max() public pure;
test_BoundIntInt256Min
function test_BoundIntInt256Min() public pure;
test_RevertIf_BoundIntMaxLessThanMin
function test_RevertIf_BoundIntMaxLessThanMin() public;
testFuzz_RevertIf_BoundIntMaxLessThanMin
function testFuzz_RevertIf_BoundIntMaxLessThanMin(int256 num, int256 min, int256 max) public;
test_BoundPrivateKey
function test_BoundPrivateKey() public pure;
test_BytesToUint
function test_BytesToUint() external pure;
test_RevertIf_BytesLengthExceeds32
function test_RevertIf_BytesLengthExceeds32() external;
test_ComputeCreateAddress
function test_ComputeCreateAddress() external pure;
test_ComputeCreate2Address
function test_ComputeCreate2Address() external pure;
test_ComputeCreate2AddressWithDefaultDeployer
function test_ComputeCreate2AddressWithDefaultDeployer() external pure;
StdUtilsForkTest
Inherits: Test
State Variables
SHIB
address internal SHIB = 0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE;
SHIB_HOLDER_0
address internal SHIB_HOLDER_0 = 0x855F5981e831D83e6A4b4EBFCAdAa68D92333170;
SHIB_HOLDER_1
address internal SHIB_HOLDER_1 = 0x8F509A90c2e47779cA408Fe00d7A72e359229AdA;
SHIB_HOLDER_2
address internal SHIB_HOLDER_2 = 0x0e3bbc0D04fF62211F71f3e4C45d82ad76224385;
USDC
address internal USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
USDC_HOLDER_0
address internal USDC_HOLDER_0 = 0xDa9CE944a37d218c3302F6B82a094844C6ECEb17;
USDC_HOLDER_1
address internal USDC_HOLDER_1 = 0x3e67F4721E6d1c41a015f645eFa37BEd854fcf52;
Functions
setUp
function setUp() public;
test_RevertIf_CannotGetTokenBalances_NonTokenContract
function test_RevertIf_CannotGetTokenBalances_NonTokenContract() external;
test_RevertIf_CannotGetTokenBalances_EOA
function test_RevertIf_CannotGetTokenBalances_EOA() external;
test_GetTokenBalances_Empty
function test_GetTokenBalances_Empty() external;
test_GetTokenBalances_USDC
function test_GetTokenBalances_USDC() external;
test_GetTokenBalances_SHIB
function test_GetTokenBalances_SHIB() external;
VmTest
Inherits: Test
Functions
test_VmInterfaceId
function test_VmInterfaceId() public pure;
test_VmSafeInterfaceId
function test_VmSafeInterfaceId() public pure;
Contents
Contents
SVM
Symbolic Virtual Machine
Functions
createUint
function createUint(uint256 bitSize, string memory name) external pure returns (uint256 value);
createUint256
function createUint256(string memory name) external pure returns (uint256 value);
createInt
function createInt(uint256 bitSize, string memory name) external pure returns (int256 value);
createInt256
function createInt256(string memory name) external pure returns (int256 value);
createBytes
function createBytes(uint256 byteSize, string memory name) external pure returns (bytes memory value);
createString
function createString(uint256 byteSize, string memory name) external pure returns (string memory value);
createBytes32
function createBytes32(string memory name) external pure returns (bytes32 value);
createBytes4
function createBytes4(string memory name) external pure returns (bytes4 value);
createAddress
function createAddress(string memory name) external pure returns (address value);
createBool
function createBool(string memory name) external pure returns (bool value);
createCalldata
function createCalldata(string memory contractOrInterfaceName) external pure returns (bytes memory data);
createCalldata
function createCalldata(string memory contractOrInterfaceName, bool includeViewAndPureFunctions)
external
pure
returns (bytes memory data);
createCalldata
function createCalldata(string memory filename, string memory contractOrInterfaceName)
external
pure
returns (bytes memory data);
createCalldata
function createCalldata(string memory filename, string memory contractOrInterfaceName, bool includeViewAndPureFunctions)
external
pure
returns (bytes memory data);
enableSymbolicStorage
function enableSymbolicStorage(address) external;
snapshotStorage
function snapshotStorage(address) external returns (uint256 id);
SymTest
State Variables
SVM_ADDRESS
address internal constant SVM_ADDRESS = address(uint160(uint256(keccak256("svm cheat code"))));
svm
SVM internal constant svm = SVM(SVM_ADDRESS);
Contents
Contents
Contents
SampleAccount
Functions
constructor
constructor(address initialOwner) Ownable(initialOwner);
validateUserOp
function validateUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash, uint256 missingAccountFunds)
external
override
returns (uint256 validationData);
execute
function execute(Mode mode, bytes calldata executionCalldata) external payable;
Events
Log
event Log(bool duringValidation, Execution[] calls);
Errors
UnsupportedCallType
error UnsupportedCallType(CallType callType);
ERC7579UtilsTest
Inherits: Test
State Variables
_owner
address private _owner;
_ownerKey
uint256 private _ownerKey;
_account
address private _account;
_beneficiary
address private _beneficiary;
_recipient1
address private _recipient1;
_recipient2
address private _recipient2;
Functions
constructor
constructor();
testExecuteBatchDecodeCorrectly
function testExecuteBatchDecodeCorrectly() public;
testExecuteBatchDecodeEmpty
function testExecuteBatchDecodeEmpty() public;
testExecuteBatchDecodeDifferent
function testExecuteBatchDecodeDifferent() public;
testDecodeBatch
function testDecodeBatch() public;
callDecodeBatch
function callDecodeBatch(bytes calldata executionCalldata) public pure;
callDecodeBatchAndGetFirst
function callDecodeBatchAndGetFirst(bytes calldata executionCalldata) public pure;
callDecodeBatchAndGetFirstBytes
function callDecodeBatchAndGetFirstBytes(bytes calldata executionCalldata) public pure returns (bytes calldata);
hashUserOperation
function hashUserOperation(PackedUserOperation calldata useroperation) public view returns (bytes32);
_collectAndPrintLogs
function _collectAndPrintLogs(bool includeTotalValue) internal;
_printDecodedCalls
function _printDecodedCalls(bytes memory logData, bool includeTotalValue) internal pure;
_packGas
function _packGas(uint256 upper, uint256 lower) internal pure returns (bytes32);
AccountERC7702MockConstructor
Inherits: AccountERC7702Mock
Functions
constructor
constructor() EIP712("MyAccount", "1");
AccountERC7702Test
Inherits: Test
State Variables
MAX_ETH
uint256 private constant MAX_ETH = type(uint128).max;
_target
CallReceiverMock private _target;
_signerPrivateKey
uint256 private _signerPrivateKey;
_signer
AccountERC7702MockConstructor private _signer;
Functions
setUp
function setUp() public;
testExecuteBatch
function testExecuteBatch(uint256 argA, uint256 argB) public;
Contents
Contents
TokenMock
Inherits: ERC20VotesExtendedTimestampMock
Functions
constructor
constructor() ERC20("Mock Token", "MTK") EIP712("Mock Token", "1");
GovernorHandler
Inherits: GovernorVotesSuperQuorumFractionMock
Main responsibility: expose the functions that are relevant to the simulation
Functions
constructor
constructor(
string memory name_,
uint48 votingDelay_,
uint32 votingPeriod_,
uint256 proposalThreshold_,
IVotes token_,
uint256 quorumNumerator_,
uint256 superQuorumNumerator_
)
Governor(name_)
GovernorSettings(votingDelay_, votingPeriod_, proposalThreshold_)
GovernorVotes(token_)
GovernorVotesQuorumFraction(quorumNumerator_)
GovernorVotesSuperQuorumFraction(superQuorumNumerator_);
$_updateSuperQuorumNumerator
function $_updateSuperQuorumNumerator(uint256 newSuperQuorumNumerator) public;
$_updateQuorumNumerator
function $_updateQuorumNumerator(uint256 newQuorumNumerator) public;
GovernorSuperQuorumGreaterThanQuorum
Inherits: Test
State Variables
_governorHandler
GovernorHandler private _governorHandler;
Functions
setUp
function setUp() external;
invariant_superQuorumGreaterThanQuorum
function invariant_superQuorumGreaterThanQuorum() external view;
GovernorInternalTest
Functions
constructor
constructor() Governor("");
testValidDescriptionForProposer
function testValidDescriptionForProposer(string memory description, address proposer, bool includeProposer)
public
view;
testInvalidDescriptionForProposer
function testInvalidDescriptionForProposer(string memory description, address commitProposer, address actualProposer)
public
view;
clock
function clock() public pure override returns (uint48);
CLOCK_MODE
function CLOCK_MODE() public pure override returns (string memory);
COUNTING_MODE
function COUNTING_MODE() public pure virtual override returns (string memory);
votingDelay
function votingDelay() public pure virtual override returns (uint256);
votingPeriod
function votingPeriod() public pure virtual override returns (uint256);
quorum
function quorum(uint256) public pure virtual override returns (uint256);
hasVoted
function hasVoted(uint256, address) public pure virtual override returns (bool);
_quorumReached
function _quorumReached(uint256) internal pure virtual override returns (bool);
_voteSucceeded
function _voteSucceeded(uint256) internal pure virtual override returns (bool);
_getVotes
function _getVotes(address, uint256, bytes memory) internal pure virtual override returns (uint256);
_countVote
function _countVote(uint256, address, uint8, uint256, bytes memory) internal virtual override returns (uint256);
Contents
TamperType
enum TamperType {
FROM,
TO,
VALUE,
DATA,
SIGNATURE
}
ERC2771ForwarderMock
Inherits: ERC2771Forwarder
Functions
constructor
constructor(string memory name) ERC2771Forwarder(name);
forwardRequestStructHash
function forwardRequestStructHash(ERC2771Forwarder.ForwardRequestData calldata request, uint256 nonce)
external
view
returns (bytes32);
ERC2771ForwarderTest
Inherits: Test
State Variables
_erc2771Forwarder
ERC2771ForwarderMock internal _erc2771Forwarder;
_receiver
CallReceiverMockTrustingForwarder internal _receiver;
_signerPrivateKey
uint256 internal _signerPrivateKey = 0xA11CE;
_signer
address internal _signer = vm.addr(_signerPrivateKey);
_MAX_ETHER
uint256 internal constant _MAX_ETHER = 10_000_000;
Functions
setUp
function setUp() public;
_forgeRequestData
function _forgeRequestData() private view returns (ERC2771Forwarder.ForwardRequestData memory);
_forgeRequestData
function _forgeRequestData(uint256 value, uint48 deadline, bytes memory data)
private
view
returns (ERC2771Forwarder.ForwardRequestData memory);
_signRequestData
function _signRequestData(ERC2771Forwarder.ForwardRequestData memory request, uint256 nonce)
private
view
returns (ERC2771Forwarder.ForwardRequestData memory);
_tamperRequestData
function _tamperRequestData(ERC2771Forwarder.ForwardRequestData memory request, TamperType tamper)
private
returns (ERC2771Forwarder.ForwardRequestData memory);
_tamperedExpectRevert
function _tamperedExpectRevert(ERC2771Forwarder.ForwardRequestData memory request, TamperType tamper, uint256 nonce)
private
returns (ERC2771Forwarder.ForwardRequestData memory);
testExecuteAvoidsETHStuck
function testExecuteAvoidsETHStuck(uint256 initialBalance, uint256 value, bool targetReverts) public;
testExecuteBatchAvoidsETHStuck
function testExecuteBatchAvoidsETHStuck(uint256 initialBalance, uint256 batchSize, uint256 value) public;
testVerifyTamperedValues
function testVerifyTamperedValues(uint8 _tamper) public;
testExecuteTamperedValues
function testExecuteTamperedValues(uint8 _tamper) public;
testExecuteBatchTamperedValuesZeroReceiver
function testExecuteBatchTamperedValuesZeroReceiver(uint8 _tamper) public;
testExecuteBatchTamperedValues
function testExecuteBatchTamperedValues(uint8 _tamper) public;
_asTamper
function _asTamper(uint8 _tamper) private pure returns (TamperType);
Contents
ClonesTest
Inherits: Test
Functions
getNumber
function getNumber() external pure returns (uint256);
testSymbolicPredictDeterministicAddressSpillage
function testSymbolicPredictDeterministicAddressSpillage(address implementation, bytes32 salt) public view;
testSymbolicPredictDeterministicAddressWithImmutableArgsSpillage
function testSymbolicPredictDeterministicAddressWithImmutableArgsSpillage(
address implementation,
bytes32 salt,
bytes memory args
) public view;
testCloneDirty
function testCloneDirty() external;
testCloneDeterministicDirty
function testCloneDeterministicDirty(bytes32 salt) external;
testPredictDeterministicAddressDirty
function testPredictDeterministicAddressDirty(bytes32 salt) external view;
testFetchCloneArgs
function testFetchCloneArgs(bytes memory args, bytes32 salt) external;
_dirty
function _dirty(address input) private pure returns (address output);
Contents
Contents
Contents
ERC4626VaultOffsetMock
Inherits: ERC4626OffsetMock
Functions
constructor
constructor(ERC20 underlying_, uint8 offset_)
ERC20("My Token Vault", "MTKNV")
ERC4626(underlying_)
ERC4626OffsetMock(offset_);
ERC4626StdTest
Inherits: ERC4626Test
State Variables
_underlying
ERC20 private _underlying = new ERC20Mock();
Functions
setUp
function setUp() public override;
testFuzzDecimalsOverflow
Check the case where calculated decimals value overflows the uint8 type.
function testFuzzDecimalsOverflow(uint8 offset) public;
Contents
Contents
ERC721ConsecutiveTarget
Inherits: StdUtils, ERC721Consecutive
State Variables
_offset
uint96 private immutable _offset;
totalMinted
uint256 public totalMinted = 0;
Functions
constructor
constructor(address[] memory receivers, uint256[] memory batches, uint256 startingId) ERC721("", "");
burn
function burn(uint256 tokenId) public;
_firstConsecutiveId
function _firstConsecutiveId() internal view virtual override returns (uint96);
ERC721ConsecutiveTest
Inherits: Test
Functions
test_balance
function test_balance(address receiver, uint256[] calldata batches, uint96 startingId) public;
test_ownership
function test_ownership(
address receiver,
uint256[] calldata batches,
uint256[2] calldata unboundedTokenId,
uint96 startingId
) public;
test_burn
function test_burn(address receiver, uint256[] calldata batches, uint256 unboundedTokenId, uint96 startingId) public;
test_transfer
function test_transfer(
address[2] calldata accounts,
uint256[2] calldata unboundedBatches,
uint256[2] calldata unboundedTokenId,
uint96 startingId
) public;
test_start_consecutive_id
function test_start_consecutive_id(
address receiver,
uint256[2] calldata unboundedBatches,
uint256[2] calldata unboundedTokenId,
uint96 startingId
) public;
toSingleton
function toSingleton(address account) pure returns (address[] memory);
Contents
- cryptography
- math
- structs
- ArraysTest
- Base64Test
- BlockhashTest
- BytesTest
- Create2Test
- PackingTest
- ShortStringsTest
- SlotDerivationTest
- StringsTest
Contents
MessageHashUtilsTest
Inherits: Test
Functions
testToDataWithIntendedValidatorHash
function testToDataWithIntendedValidatorHash(address validator, bytes memory data) external pure;
testToDataWithIntendedValidatorHash
function testToDataWithIntendedValidatorHash(address validator, bytes32 messageHash) external pure;
_dirty
function _dirty(address input) private pure returns (address output);
P256Test
Inherits: Test
Functions
testVerify
forge-config: default.fuzz.runs = 512
function testVerify(bytes32 digest, uint256 seed) public view;
testRecover
forge-config: default.fuzz.runs = 512
function testRecover(bytes32 digest, uint256 seed) public view;
testVerifyNativeUnsupportedRIP7212
function testVerifyNativeUnsupportedRIP7212(bytes32 digest, uint256 seed) public;
_asPrivateKey
function _asPrivateKey(uint256 seed) private pure returns (uint256);
_ensureLowerS
function _ensureLowerS(bytes32 s) private pure returns (bytes32);
verifyNative
function verifyNative(bytes32 digest, bytes32 r, bytes32 s, bytes32 x, bytes32 y) external view;
Contents
MathTest
Inherits: Test
Functions
testSymbolicTernary
function testSymbolicTernary(bool f, uint256 a, uint256 b) public pure;
testAdd512
function testAdd512(uint256 a, uint256 b) public pure;
testMul512
function testMul512(uint256 a, uint256 b) public pure;
testSymbolicMinMax
function testSymbolicMinMax(uint256 a, uint256 b) public pure;
testCeilDiv
function testCeilDiv(uint256 a, uint256 b) public pure;
testSqrt
function testSqrt(uint256 input, uint8 r) public pure;
_squareBigger
function _squareBigger(uint256 value, uint256 ref) private pure returns (bool);
_squareSmaller
function _squareSmaller(uint256 value, uint256 ref) private pure returns (bool);
testInvMod
function testInvMod(uint256 value, uint256 p) public pure;
testInvMod2
function testInvMod2(uint256 seed) public pure;
testInvMod17
function testInvMod17(uint256 seed) public pure;
testInvMod65537
function testInvMod65537(uint256 seed) public pure;
testInvModP256
function testInvModP256(uint256 seed) public pure;
_testInvMod
function _testInvMod(uint256 value, uint256 p, bool allowZero) private pure;
testLog2
function testLog2(uint256 input, uint8 r) public pure;
_powerOf2Bigger
function _powerOf2Bigger(uint256 value, uint256 ref) private pure returns (bool);
_powerOf2Smaller
function _powerOf2Smaller(uint256 value, uint256 ref) private pure returns (bool);
testLog10
function testLog10(uint256 input, uint8 r) public pure;
_powerOf10Bigger
function _powerOf10Bigger(uint256 value, uint256 ref) private pure returns (bool);
_powerOf10Smaller
function _powerOf10Smaller(uint256 value, uint256 ref) private pure returns (bool);
testLog256
function testLog256(uint256 input, uint8 r) public pure;
_powerOf256Bigger
function _powerOf256Bigger(uint256 value, uint256 ref) private pure returns (bool);
_powerOf256Smaller
function _powerOf256Smaller(uint256 value, uint256 ref) private pure returns (bool);
testMulDiv
function testMulDiv(uint256 x, uint256 y, uint256 d) public pure;
testMulDivDomain
forge-config: default.allow_internal_expect_revert = true
function testMulDivDomain(uint256 x, uint256 y, uint256 d) public;
testModExp
forge-config: default.allow_internal_expect_revert = true
function testModExp(uint256 b, uint256 e, uint256 m) public;
testTryModExp
function testTryModExp(uint256 b, uint256 e, uint256 m) public view;
testModExpMemory
forge-config: default.allow_internal_expect_revert = true
function testModExpMemory(uint256 b, uint256 e, uint256 m) public;
testTryModExpMemory
function testTryModExpMemory(uint256 b, uint256 e, uint256 m) public view;
_asRounding
function _asRounding(uint8 r) private pure returns (Math.Rounding);
_mulKaratsuba
function _mulKaratsuba(uint256 x, uint256 y) private pure returns (uint256 high, uint256 low);
_nativeModExp
function _nativeModExp(uint256 b, uint256 e, uint256 m) private pure returns (uint256);
SignedMathTest
Inherits: Test
Functions
testSymbolicTernary
function testSymbolicTernary(bool f, int256 a, int256 b) public pure;
testSymbolicMinMax
function testSymbolicMinMax(int256 a, int256 b) public pure;
testSymbolicMin
function testSymbolicMin(int256 a, int256 b) public pure;
testSymbolicMax
function testSymbolicMax(int256 a, int256 b) public pure;
testAverage1
function testAverage1(int256 a, int256 b) public pure;
testAverage2
function testAverage2(int256 a, int256 b) public pure;
testSymbolicAbs
function testSymbolicAbs(int256 a) public pure;
Contents
CheckpointsTrace224Test
Inherits: Test
State Variables
_KEY_MAX_GAP
uint8 internal constant _KEY_MAX_GAP = 64;
_ckpts
Checkpoints.Trace224 internal _ckpts;
Functions
_boundUint32
function _boundUint32(uint32 x, uint32 min, uint32 max) internal pure returns (uint32);
_prepareKeys
function _prepareKeys(uint32[] memory keys, uint32 maxSpread) internal pure;
_assertLatestCheckpoint
function _assertLatestCheckpoint(bool exist, uint32 key, uint224 value) internal view;
testPush
function testPush(uint32[] memory keys, uint224[] memory values, uint32 pastKey) public;
push
function push(uint32 key, uint224 value) external;
testLookup
function testLookup(uint32[] memory keys, uint224[] memory values, uint32 lookup) public;
CheckpointsTrace208Test
Inherits: Test
State Variables
_KEY_MAX_GAP
uint8 internal constant _KEY_MAX_GAP = 64;
_ckpts
Checkpoints.Trace208 internal _ckpts;
Functions
_boundUint48
function _boundUint48(uint48 x, uint48 min, uint48 max) internal pure returns (uint48);
_prepareKeys
function _prepareKeys(uint48[] memory keys, uint48 maxSpread) internal pure;
_assertLatestCheckpoint
function _assertLatestCheckpoint(bool exist, uint48 key, uint208 value) internal view;
testPush
function testPush(uint48[] memory keys, uint208[] memory values, uint48 pastKey) public;
push
function push(uint48 key, uint208 value) external;
testLookup
function testLookup(uint48[] memory keys, uint208[] memory values, uint48 lookup) public;
CheckpointsTrace160Test
Inherits: Test
State Variables
_KEY_MAX_GAP
uint8 internal constant _KEY_MAX_GAP = 64;
_ckpts
Checkpoints.Trace160 internal _ckpts;
Functions
_boundUint96
function _boundUint96(uint96 x, uint96 min, uint96 max) internal pure returns (uint96);
_prepareKeys
function _prepareKeys(uint96[] memory keys, uint96 maxSpread) internal pure;
_assertLatestCheckpoint
function _assertLatestCheckpoint(bool exist, uint96 key, uint160 value) internal view;
testPush
function testPush(uint96[] memory keys, uint160[] memory values, uint96 pastKey) public;
push
function push(uint96 key, uint160 value) external;
testLookup
function testLookup(uint96[] memory keys, uint160[] memory values, uint96 lookup) public;
Uint256HeapTest
Inherits: Test
State Variables
heap
Heap.Uint256Heap internal heap;
Functions
_validateHeap
function _validateHeap(function(uint256, uint256) view returns (bool) comp) internal view;
testFuzz
function testFuzz(uint256[] calldata input) public;
testFuzzGt
function testFuzzGt(uint256[] calldata input) public;
ArraysTest
Functions
testSort
function testSort(uint256[] memory values) public pure;
symbolicSort
function symbolicSort() public pure;
_assertSort
Asserts
function _assertSort(uint256[] memory values) internal pure;
Base64Test
Inherits: Test
Functions
testEncode
function testEncode(bytes memory input) external pure;
testEncodeURL
function testEncodeURL(bytes memory input) external pure;
_removePadding
function _removePadding(string memory inputStr) internal pure returns (string memory);
BlockhashTest
Inherits: Test
State Variables
startingBlock
uint256 internal startingBlock;
SYSTEM_ADDRESS
address internal constant SYSTEM_ADDRESS = 0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE;
HISTORY_STORAGE_BYTECODE
bytes private constant HISTORY_STORAGE_BYTECODE =
hex"3373fffffffffffffffffffffffffffffffffffffffe14604657602036036042575f35600143038111604257611fff81430311604257611fff9006545f5260205ff35b5f5ffd5b5f35611fff60014303065500";
Functions
setUp
function setUp() public;
testFuzzRecentBlocks
function testFuzzRecentBlocks(uint8 offset, uint64 currentBlock, bytes32 expectedHash) public;
testFuzzHistoryBlocks
function testFuzzHistoryBlocks(uint16 offset, uint256 currentBlock, bytes32 expectedHash) public;
testFuzzVeryOldBlocks
function testFuzzVeryOldBlocks(uint256 offset, uint256 currentBlock) public;
testFuzzFutureBlocks
function testFuzzFutureBlocks(uint256 offset, uint256 currentBlock) public;
testUnsupportedChainsReturnZeroWhenOutOfRange
function testUnsupportedChainsReturnZeroWhenOutOfRange() public;
_setHistoryBlockhash
function _setHistoryBlockhash(bytes32 blockHash) internal;
_setHistoryBlockhash
function _setHistoryBlockhash(uint256 blockNumber, bytes32 blockHash) internal;
BytesTest
Inherits: Test
Functions
testIndexOf
function testIndexOf(bytes memory buffer, bytes1 s) public pure;
testIndexOf
function testIndexOf(bytes memory buffer, bytes1 s, uint256 pos) public pure;
testLastIndexOf
function testLastIndexOf(bytes memory buffer, bytes1 s) public pure;
testLastIndexOf
function testLastIndexOf(bytes memory buffer, bytes1 s, uint256 pos) public pure;
testSliceWithStartOnly
function testSliceWithStartOnly(bytes memory buffer, uint256 start) public pure;
testSlice
function testSlice(bytes memory buffer, uint256 start, uint256 end) public pure;
Create2Test
Inherits: Test
Functions
testSymbolicComputeAddressSpillage
function testSymbolicComputeAddressSpillage(bytes32 salt, bytes32 bytecodeHash, address deployer) public pure;
PackingTest
Inherits: Test
Functions
testPack
function testPack(bytes1 left, bytes1 right) external pure;
testPack
function testPack(bytes2 left, bytes2 right) external pure;
testPack
function testPack(bytes2 left, bytes4 right) external pure;
testPack
function testPack(bytes2 left, bytes6 right) external pure;
testPack
function testPack(bytes2 left, bytes8 right) external pure;
testPack
function testPack(bytes2 left, bytes10 right) external pure;
testPack
function testPack(bytes2 left, bytes20 right) external pure;
testPack
function testPack(bytes2 left, bytes22 right) external pure;
testPack
fu