From 124946fe1edc139a61d699f67bd73360a6820d23 Mon Sep 17 00:00:00 2001 From: stevep0z <255929980+stevep0z@users.noreply.github.com> Date: Thu, 2 Apr 2026 10:22:05 -0500 Subject: [PATCH 01/11] fix: update docgen templates with strict reference matching and output fixes - Remove fuzzy reference matching that caused cross-standard contamination (e.g., ERC20 constructor referencing Governor.name, IERC6909Metadata.symbol) - Add same-page preference so {name} on an ERC20 page resolves to ERC20.name - Use absolute paths for cross-page links via API_DOCS_PATH - Fix multi-line callout handling (NOTE: blocks spanning multiple lines) - Escape bare < in natspec (e.g., < 0x80) to prevent MDX parse errors - Convert Antora xref patterns to markdown links - Convert AsciiDoc headings (====) to markdown (####) - Clean up orphaned block delimiters - Strip /index from links for Fumadocs compatibility --- docgen/templates-md/helpers.js | 155 +++++++++++++++++++++------------ 1 file changed, 98 insertions(+), 57 deletions(-) diff --git a/docgen/templates-md/helpers.js b/docgen/templates-md/helpers.js index 21468281..30f94abc 100644 --- a/docgen/templates-md/helpers.js +++ b/docgen/templates-md/helpers.js @@ -56,7 +56,7 @@ module.exports['process-natspec'] = function (natspec, opts) { const currentPage = opts.data.root.__item_context?.page || opts.data.root.id; const links = getAllLinks(opts.data.site.items, currentPage); - const processed = processReferences(natspec, links); + const processed = processReferences(natspec, links, currentPage); return processCallouts(processed); // Add callout processing at the end }; @@ -89,6 +89,8 @@ function getAllLinks(items, currentPage) { } const res = {}; + // Track which page each link key belongs to for same-page preference + const linkPages = {}; const currentPagePath = currentPage ? currentPage.replace(/\.mdx$/, '') : ''; for (const item of items) { @@ -97,6 +99,7 @@ function getAllLinks(items, currentPage) { // Generate xref keys for legacy compatibility res[`xref-${item.anchor}`] = linkPath; + linkPages[`xref-${item.anchor}`] = pagePath; // Generate original case xref keys if (item.__item_context && item.__item_context.contract) { @@ -106,11 +109,18 @@ function getAllLinks(items, currentPage) { originalAnchor += slug('(' + signature + ')'); } res[`xref-${originalAnchor}`] = linkPath; + linkPages[`xref-${originalAnchor}`] = pagePath; } - res[slug(item.fullName)] = `[\`${item.fullName}\`](${linkPath})`; + const key = slug(item.fullName); + res[key] = `[\`${item.fullName}\`](${linkPath})`; + linkPages[key] = pagePath; } + // Attach page info for same-page preference in findBestMatch + res.__linkPages = linkPages; + res.__currentPagePath = currentPagePath; + if (currentPage) { let cache = linksCache.get(items); if (!cache) { @@ -124,6 +134,7 @@ function getAllLinks(items, currentPage) { } function generateLinkPath(pagePath, currentPagePath, anchor) { + // Same page: use fragment-only link if ( currentPagePath && (pagePath === currentPagePath || pagePath.split('/').pop() === currentPagePath.split('/').pop()) @@ -131,30 +142,8 @@ function generateLinkPath(pagePath, currentPagePath, anchor) { return `#${anchor}`; } - if (currentPagePath) { - const currentParts = currentPagePath.split('/'); - const targetParts = pagePath.split('/'); - - // Find common base - let i = 0; - while (i < currentParts.length && i < targetParts.length && currentParts[i] === targetParts[i]) { - i++; - } - - const upLevels = Math.max(0, currentParts.length - 1 - i); - const downPath = targetParts.slice(i); - - if (upLevels === 0 && downPath.length === 1) { - return `${downPath[0]}#${anchor}`; - } else if (upLevels === 0) { - return `${downPath.join('/')}#${anchor}`; - } else { - const relativePath = '../'.repeat(upLevels) + downPath.join('/'); - return `${relativePath}#${anchor}`; - } - } - - return `${pagePath}#${anchor}`; + // Cross-page: use absolute path with API_DOCS_PATH prefix + return `/${API_DOCS_PATH}/${pagePath}#${anchor}`; } // Process {REF} and other references @@ -219,7 +208,13 @@ function processReferences(content, links) { return replacement || `\`${key}\``; }); - return cleanupContent(result); + result = cleanupContent(result); + + // Escape bare < that aren't HTML/JSX tags (e.g., "< 0x80", "< 128") + // Must run after cleanupContent (which decodes < to <) and before processCallouts + result = result.replace(/(<)(\s+\w)/g, '<$2'); + + return result; } function resolveReference(refId, links) { @@ -249,39 +244,43 @@ function resolveReference(refId, links) { } function findBestMatch(key, links) { - let replacement = links[key]; + // Exact match first + if (links[key]) { + return links[key]; + } - if (!replacement) { - // Strategy 1: Look for keys that end with this key - let matchingKeys = Object.keys(links).filter(linkKey => { - const parts = linkKey.split('-'); - return parts.length >= 2 && parts[parts.length - 1] === key; - }); + const linkPages = links.__linkPages || {}; + const currentPagePath = links.__currentPagePath || ''; - // Strategy 2: Try with different separators - if (matchingKeys.length === 0) { - const keyWithDashes = key.replace(/\./g, '-'); - matchingKeys = Object.keys(links).filter(linkKey => linkKey.includes(keyWithDashes)); - } + // Match by contract function name (e.g., {transfer} matches ERC20-transfer) + // Only match if the key is the final segment after the last hyphen + const matchingKeys = Object.keys(links).filter(linkKey => { + if (linkKey.startsWith('__')) return false; // skip metadata keys + const parts = linkKey.split('-'); + return parts.length >= 2 && parts[parts.length - 1] === key; + }); - // Strategy 3: Try partial matches - if (matchingKeys.length === 0) { - matchingKeys = Object.keys(links).filter(linkKey => { - return linkKey === key || linkKey.endsWith('-' + key) || linkKey.includes(key); - }); + if (matchingKeys.length > 0) { + const nonXrefMatches = matchingKeys.filter(k => !k.startsWith('xref-')); + const candidates = nonXrefMatches.length > 0 ? nonXrefMatches : matchingKeys; + + // Prefer matches from the same page (e.g., ERC20.name over Governor.name on the ERC20 page) + if (currentPagePath && candidates.length > 1) { + const samePageMatch = candidates.find(k => linkPages[k] === currentPagePath); + if (samePageMatch) { + return links[samePageMatch]; + } } - if (matchingKeys.length > 0) { - const nonXrefMatches = matchingKeys.filter(k => !k.startsWith('xref-')); - const bestMatch = nonXrefMatches.length > 0 ? nonXrefMatches[0] : matchingKeys[0]; - replacement = links[bestMatch]; - } + return links[candidates[0]]; } - return replacement; + return undefined; } function cleanupContent(content) { + const apiDocsBase = '/' + API_DOCS_PATH; + const docsBase = apiDocsBase.replace(/\/api$/, ''); return content .replace(/</g, '<') .replace(/>/g, '>') @@ -295,7 +294,26 @@ function cleanupContent(content) { .replace(/https?:\/\/[^\s[]+\[[^\]]+\]/g, match => { const urlMatch = match.match(/^(https?:\/\/[^[]+)\[([^\]]+)\]$/); return urlMatch ? `[${urlMatch[2]}](${urlMatch[1]})` : match; - }); + }) + // Convert remaining Antora xref patterns in natspec + // xref:ROOT:filename.adoc#anchor[text] -> [text](docsBase/filename#anchor) + .replace(/xref:ROOT:([^[]+)\.adoc(?:#([^[]*))?\[([^\]]*)\]/g, (_, file, anchor, text) => + `[${text}](${docsBase}/${file}${anchor ? '#' + anchor : ''})`) + // xref:api:filename.adoc#anchor[text] -> [text](apiDocsBase/filename#anchor) + .replace(/xref:api:([^[]+)\.adoc(?:#([^[]*))?\[([^\]]*)\]/g, (_, file, anchor, text) => + `[${text}](${apiDocsBase}/${file}${anchor ? '#' + anchor : ''})`) + // xref:module::filename.adoc[text] -> [text](docsBase/module/filename) + // Modules like "learn" are relative to the product docs base, not site root + .replace(/xref:([a-z-]+)::([^[]+)\.adoc(?:#([^[]*))?\[([^\]]*)\]/g, (_, mod, file, anchor, text) => { + // upgrades-plugins is a separate product at site root + const base = mod === 'upgrades-plugins' ? '' : docsBase; + return `[${text}](${base}/${mod}/${file}${anchor ? '#' + anchor : ''})`; + }) + // xref:filename.adoc#anchor[text] -> [text](apiDocsBase/filename#anchor) (bare, within API context) + .replace(/xref:([^:[\s]+)\.adoc(?:#([^[]*))?\[([^\]]*)\]/g, (_, file, anchor, text) => + `[${text}](${apiDocsBase}/${file}${anchor ? '#' + anchor : ''})`) + // Strip /index from links + .replace(/\/index([#)])/g, '$1'); } function processAdocContent(content) { @@ -325,8 +343,22 @@ function processAdocContent(content) { let mdContent = fs.readFileSync(tempMdFile, 'utf8'); // Clean up and transform markdown, then process callouts once at the end + // Convert Antora xref patterns that downdoc turns into markdown links + const apiDocsBase = '/' + API_DOCS_PATH; + const docsBase = apiDocsBase.replace(/\/api$/, ''); mdContent = cleanupContent(mdContent) - .replace(/\(api:([^)]+)\.adoc([^)]*)\)/g, `(${API_DOCS_PATH}/$1.mdx$2)`) + // api:filename.adoc#anchor -> /contracts/5.x/api/filename#anchor + .replace(/\(api:([^)]+)\.adoc([^)]*)\)/g, `(${apiDocsBase}/$1$2)`) + // ROOT:filename.adoc -> docs base (non-API pages like guides) + .replace(/\(ROOT:([^)]+)\.adoc([^)]*)\)/g, `(${docsBase}/$1$2)`) + // upgrades-plugins::filename.adoc -> /upgrades-plugins/filename + .replace(/\(upgrades-plugins::([^)]+)\.adoc([^)]*)\)/g, '(/upgrades-plugins/$1$2)') + // Strip /index from links (Fumadocs routes index.mdx as the directory root) + .replace(/\/index([#)])/g, '$1') + // governance.adoc#anchor -> /contracts/5.x/api/governance#anchor (within API context) + .replace(/\(([a-z0-9-]+)\.adoc(#[^)]*)\)/g, `(${apiDocsBase}/$1$2)`) + // Clean up any remaining bare .adoc references + .replace(/([a-z0-9-]+)\.adoc/g, '$1') .replace(/!\[([^\]]*)\]\(([^/)][^)]*\.(png|jpg|jpeg|gif|svg|webp))\)/g, '![$1](/$2)') .replace(/^#+\s+.+$/m, '') .replace(/^\n+/, ''); @@ -351,8 +383,14 @@ function processAdocContent(content) { } function processCallouts(content) { - // First, normalize whitespace around block delimiters to make patterns more consistent - let result = content.replace(/\s*\n====\s*\n/g, '\n====\n').replace(/\n====\s*\n/g, '\n====\n'); + // Convert AsciiDoc headings in natspec (==== heading -> #### heading) + // Must come BEFORE block delimiter normalization + let result = content.replace(/^={4}\s+(.+)$/gm, '#### $1'); + result = result.replace(/^={3}\s+(.+)$/gm, '### $1'); + result = result.replace(/^={2}\s+(.+)$/gm, '## $1'); + + // Normalize whitespace around block delimiters to make patterns more consistent + result = result.replace(/\s*\n====\s*\n/g, '\n====\n').replace(/\n====\s*\n/g, '\n====\n'); // Handle AsciiDoc block admonitions (with ====) result = result.replace(/^\[(NOTE|TIP)\]\s*\n====\s*\n([\s\S]*?)\n====$/gm, '\n$2\n'); @@ -361,9 +399,9 @@ function processCallouts(content) { '\n$2\n', ); - // Handle simple single-line admonitions - result = result.replace(/^(NOTE|TIP):\s*(.+)$/gm, '\n$2\n'); - result = result.replace(/^(IMPORTANT|WARNING):\s*(.+)$/gm, '\n$2\n'); + // Handle single/multi-line admonitions (NOTE: content until blank line) + result = result.replace(/^(NOTE|TIP):\s*([\s\S]*?)(?=\n\n|$)/gm, '\n$2\n'); + result = result.replace(/^(IMPORTANT|WARNING|CAUTION):\s*([\s\S]*?)(?=\n\n|$)/gm, '\n$2\n'); // Handle markdown-style bold admonitions (the ones you're seeing) result = result.replace( @@ -407,6 +445,9 @@ function processCallouts(content) { // Remove callouts that only contain whitespace/newlines result = result.replace(/]*>\s*\n\s*<\/Callout>/g, ''); + // Remove any remaining standalone ==== block delimiters (orphaned from callout processing) + result = result.replace(/^====\s*$/gm, ''); + return result; } From 34b09b738903cabfcfaf6695e3fa84f90692ba8a Mon Sep 17 00:00:00 2001 From: stevep0z <255929980+stevep0z@users.noreply.github.com> Date: Thu, 2 Apr 2026 10:22:17 -0500 Subject: [PATCH 02/11] docs: regenerate API reference for contracts 5.x and community-contracts Regenerated from openzeppelin-contracts (master) and openzeppelin-community-contracts (master) using updated docgen templates. - All cross-page links use absolute paths - No cross-standard contamination in reference resolution - No legacy AsciiDoc patterns in output - 0 link validation errors --- content/community-contracts/api/access.mdx | 5 +- content/community-contracts/api/account.mdx | 127 +- .../community-contracts/api/crosschain.mdx | 203 +- .../community-contracts/api/governance.mdx | 472 ++ content/community-contracts/api/index.mdx | 23 +- .../community-contracts/api/interfaces.mdx | 493 ++- content/community-contracts/api/proxy.mdx | 9 +- content/community-contracts/api/token.mdx | 279 +- content/community-contracts/api/utils.mdx | 47 +- .../api/utils/cryptography.mdx | 304 +- content/contracts/5.x/api/access.mdx | 390 +- content/contracts/5.x/api/account.mdx | 155 +- content/contracts/5.x/api/crosschain.mdx | 1880 +++++++- content/contracts/5.x/api/finance.mdx | 9 +- content/contracts/5.x/api/governance.mdx | 389 +- content/contracts/5.x/api/interfaces.mdx | 3876 +++++++++-------- content/contracts/5.x/api/metatx.mdx | 49 +- content/contracts/5.x/api/proxy.mdx | 1054 ++--- content/contracts/5.x/api/token/ERC1155.mdx | 325 +- content/contracts/5.x/api/token/ERC20.mdx | 3443 ++++++++------- content/contracts/5.x/api/token/ERC6909.mdx | 123 +- content/contracts/5.x/api/token/ERC721.mdx | 386 +- content/contracts/5.x/api/token/common.mdx | 5 +- content/contracts/5.x/api/utils.mdx | 2742 ++++++++---- .../contracts/5.x/api/utils/cryptography.mdx | 460 +- 25 files changed, 10774 insertions(+), 6474 deletions(-) create mode 100644 content/community-contracts/api/governance.mdx diff --git a/content/community-contracts/api/access.mdx b/content/community-contracts/api/access.mdx index 6f9659b3..6023bc9c 100644 --- a/content/community-contracts/api/access.mdx +++ b/content/community-contracts/api/access.mdx @@ -5,7 +5,7 @@ description: "Smart contract access utilities and implementations" This directory contains utility contracts to restrict access control in smart contracts. These include: -* [`AccessManagerLight`](#AccessManagerLight): A simpler version of an AccessManager that uses `bytes8` roles to allow function calls identified by their 4-bytes selector. +- [`AccessManagerLight`](#AccessManagerLight): A simpler version of an AccessManager that uses `bytes8` roles to allow function calls identified by their 4-bytes selector. ## AccessManager @@ -24,7 +24,7 @@ This directory contains utility contracts to restrict access control in smart co ```solidity -import "@openzeppelin/community-contracts/access/manager/AccessManagerLight.sol"; +import "@openzeppelin/community-contracts/contracts/access/manager/AccessManagerLight.sol"; ``` Light version of an AccessManager contract that defines `bytes8` roles @@ -461,3 +461,4 @@ Internal version of [`AccessManagerLight._setRequirements`](#AccessManagerLight- + diff --git a/content/community-contracts/api/account.mdx b/content/community-contracts/api/account.mdx index 6fe89546..ae6ac946 100644 --- a/content/community-contracts/api/account.mdx +++ b/content/community-contracts/api/account.mdx @@ -5,20 +5,20 @@ description: "Smart contract account utilities and implementations" This directory includes contracts to build accounts for ERC-4337. These include: -* [`ERC7579Executor`](#ERC7579Executor): An executor module that enables executing calls from accounts where the it’s installed. -* [`ERC7579DelayedExecutor`](#ERC7579DelayedExecutor): An executor module that adds a delay before executing an account operation. -* [`ERC7579SelectorExecutor`](#ERC7579SelectorExecutor): An executor module that restricts execution to specific function selectors. -* [`ERC7579Validator`](#ERC7579Validator): Abstract validator module for ERC-7579 accounts that provides base implementation for signature validation. -* [`ERC7579Signature`](#ERC7579Signature): Implementation of [`ERC7579Validator`](#ERC7579Validator) using ERC-7913 signature verification for address-less cryptographic keys and account signatures. -* [`ERC7579Multisig`](#ERC7579Multisig): An extension of [`ERC7579Validator`](#ERC7579Validator) that enables validation using ERC-7913 signer keys. -* [`ERC7579MultisigWeighted`](#ERC7579MultisigWeighted): An extension of [`ERC7579Multisig`](#ERC7579Multisig) that allows different weights to be assigned to signers. -* [`ERC7579MultisigConfirmation`](#ERC7579MultisigConfirmation): An extension of [`ERC7579Multisig`](#ERC7579Multisig) that requires each signer to provide a confirmation signature. -* [`ERC7579MultisigStorage`](#ERC7579MultisigStorage): An extension of [`ERC7579Multisig`](#ERC7579Multisig) that allows storing presigned approvals in storage. -* [`PaymasterCore`](#PaymasterCore): An ERC-4337 paymaster implementation that includes the core logic to validate and pay for user operations. -* [`PaymasterERC20`](#PaymasterERC20): A paymaster that allows users to pay for user operations using ERC-20 tokens. -* [`PaymasterERC20Guarantor`](#PaymasterERC20Guarantor): A paymaster that enables third parties to guarantee user operations by pre-funding gas costs, with the option for users to repay or for guarantors to absorb the cost. -* [`PaymasterERC721Owner`](#PaymasterERC721Owner): A paymaster that allows users to pay for user operations based on ERC-721 ownership. -* [`PaymasterSigner`](#PaymasterSigner): A paymaster that allows users to pay for user operations using an authorized signature. +- [`ERC7579Executor`](#ERC7579Executor): An executor module that enables executing calls from accounts where the it's installed. +- [`ERC7579DelayedExecutor`](#ERC7579DelayedExecutor): An executor module that adds a delay before executing an account operation. +- [`ERC7579SelectorExecutor`](#ERC7579SelectorExecutor): An executor module that restricts execution to specific function selectors. +- [`ERC7579Validator`](#ERC7579Validator): Abstract validator module for ERC-7579 accounts that provides base implementation for signature validation. +- [`ERC7579Signature`](#ERC7579Signature): Implementation of [`ERC7579Validator`](#ERC7579Validator) using ERC-7913 signature verification for address-less cryptographic keys and account signatures. +- [`ERC7579Multisig`](#ERC7579Multisig): An extension of [`ERC7579Validator`](#ERC7579Validator) that enables validation using ERC-7913 signer keys. +- [`ERC7579MultisigWeighted`](#ERC7579MultisigWeighted): An extension of [`ERC7579Multisig`](#ERC7579Multisig) that allows different weights to be assigned to signers. +- [`ERC7579MultisigConfirmation`](#ERC7579MultisigConfirmation): An extension of [`ERC7579Multisig`](#ERC7579Multisig) that requires each signer to provide a confirmation signature. +- [`ERC7579MultisigStorage`](#ERC7579MultisigStorage): An extension of [`ERC7579Multisig`](#ERC7579Multisig) that allows storing presigned approvals in storage. +- [`PaymasterCore`](#PaymasterCore): An ERC-4337 paymaster implementation that includes the core logic to validate and pay for user operations. +- [`PaymasterERC20`](#PaymasterERC20): A paymaster that allows users to pay for user operations using ERC-20 tokens. +- [`PaymasterERC20Guarantor`](#PaymasterERC20Guarantor): A paymaster that enables third parties to guarantee user operations by pre-funding gas costs, with the option for users to repay or for guarantors to absorb the cost. +- [`PaymasterERC721Owner`](#PaymasterERC721Owner): A paymaster that allows users to pay for user operations based on ERC-721 ownership. +- [`PaymasterSigner`](#PaymasterSigner): A paymaster that allows users to pay for user operations using an authorized signature. ## Modules @@ -69,13 +69,13 @@ This directory includes contracts to build accounts for ERC-4337. These include: ```solidity -import "@openzeppelin/community-contracts/account/modules/ERC7579DelayedExecutor.sol"; +import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579DelayedExecutor.sol"; ``` Extension of [`ERC7579Executor`](#ERC7579Executor) that allows scheduling and executing delayed operations with expiration. This module enables time-delayed execution patterns for smart accounts. -==== Operation Lifecycle +#### Operation Lifecycle 1. Scheduling: Operations are scheduled via [`ERC7579DelayedExecutor.schedule`](#ERC7579DelayedExecutor-schedule-address-bytes32-bytes32-bytes-) with a specified delay period. The delay period is set during [`ERC7579DelayedExecutor.onInstall`](#ERC7579DelayedExecutor-onInstall-bytes-) and can be customized via [`ERC7579DelayedExecutor.setDelay`](#ERC7579DelayedExecutor-setDelay-uint32-). Each @@ -90,7 +90,7 @@ Operations can be executed via [`ERC7579Executor.execute`](#ERC7579Executor-exec executable. If an operation is not executed within the expiration period, it becomes `Expired` and can't be executed. Expired operations must be rescheduled with a different salt. -==== Delay Management +#### Delay Management Accounts can set their own delay periods during installation or via [`ERC7579DelayedExecutor.setDelay`](#ERC7579DelayedExecutor-setDelay-uint32-). The delay period is enforced even between installas and uninstalls to prevent @@ -98,7 +98,7 @@ immediate downgrades. When setting a new delay period, the new delay takes effec after a transition period defined by the current delay or [`ERC7579DelayedExecutor.minSetback`](#ERC7579DelayedExecutor-minSetback--), whichever is longer. -==== Authorization +#### Authorization Authorization for scheduling and canceling operations is controlled through the [`ERC7579DelayedExecutor._validateSchedule`](#ERC7579DelayedExecutor-_validateSchedule-address-bytes32-bytes32-bytes-) and [`ERC7579DelayedExecutor._validateCancel`](#ERC7579DelayedExecutor-_validateCancel-address-bytes32-bytes32-bytes-) functions. These functions can be overridden to implement custom @@ -106,8 +106,8 @@ authorization logic, such as requiring specific signers or roles. Use [`ERC7579DelayedExecutor._scheduleAt`](#ERC7579DelayedExecutor-_scheduleAt-address-bytes32-bytes32-bytes-uint48-uint32-) to schedule operations at a specific points in time. This is -useful to pre-schedule operations for non-deployed accounts (e.g. subscriptions). +useful to pre-schedule operations for non-deployed accounts (e.g. subscriptions).

Functions

@@ -442,16 +442,16 @@ and respecting the previous delay and expiration values. This function does not clean up scheduled operations. This means operations + could potentially be re-executed if the module is reinstalled later. This is a deliberate design choice for efficiency, but module implementations may want to override this behavior to clear scheduled operations during uninstallation for their specific use cases. - Calling this function directly will remove the expiration ([`ERC7579DelayedExecutor.getExpiration`](#ERC7579DelayedExecutor-getExpiration-address-)) value and + will schedule a reset of the delay ([`ERC7579DelayedExecutor.getDelay`](#ERC7579DelayedExecutor-getDelay-address-)) to `0` for the account. Reinstalling the module will not immediately reset the delay if the delay reset hasn't taken effect yet. -
@@ -472,9 +472,9 @@ Returns `data` as the execution calldata. See [`ERC7579Executor._execute`](#ERC7 This function relies on the operation state validation in [`ERC7579DelayedExecutor._execute`](#ERC7579DelayedExecutor-_execute-address-bytes32-bytes32-bytes-) for + authorization. Extensions of this module should override this function to implement additional validation logic if needed. - @@ -804,7 +804,7 @@ The module is not installed on the account. ```solidity -import "@openzeppelin/community-contracts/account/modules/ERC7579Executor.sol"; +import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579Executor.sol"; ``` Basic implementation for ERC-7579 executor modules that provides execution functionality @@ -817,9 +817,9 @@ derived contracts. This is a simplified executor that directly executes operations without delay or expiration + mechanisms. For a more advanced implementation with time-delayed execution patterns and security features, see [`ERC7579DelayedExecutor`](#ERC7579DelayedExecutor). -

Functions

@@ -908,9 +908,9 @@ Example extension: Pack extra data in the `data` arguments (e.g. a signature) to be used in the + validation process. Calldata can be sliced to extract it and return only the execution calldata. -
@@ -967,7 +967,7 @@ Emitted when an operation is executed. ```solidity -import "@openzeppelin/community-contracts/account/modules/ERC7579Multisig.sol"; +import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579Multisig.sol"; ``` Implementation of an [`ERC7579Validator`](#ERC7579Validator) that uses ERC-7913 signers for multisignature @@ -1060,8 +1060,8 @@ disabled until they are added later. An account can only call onInstall once. If called directly by the account, -the signer will be set to the provided data. Future installations will behave as a no-op. +the signer will be set to the provided data. Future installations will behave as a no-op. @@ -1085,8 +1085,8 @@ See [`ERC7579DelayedExecutor.onUninstall`](#ERC7579DelayedExecutor-onUninstall-b This function has unbounded gas costs and may become uncallable if the set grows too large. -See `EnumerableSet-clear`. +See `EnumerableSet-clear`. @@ -1109,9 +1109,9 @@ Using `start = 0` and `end = type(uint64).max` will return the entire set of sig 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. - @@ -1338,7 +1338,7 @@ Requirements:
-Validates the current threshold is reachable with the number of [`ERC7579Multisig._signersSetByAccount`](#ERC7579Multisig-_signersSetByAccount-mapping-address----struct-EnumerableSet-BytesSet-). +Validates the current threshold is reachable with the number of `signers`. Requirements: @@ -1541,7 +1541,7 @@ The `threshold` is unreachable given the number of `signers`.
```solidity -import "@openzeppelin/community-contracts/account/modules/ERC7579MultisigConfirmation.sol"; +import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579MultisigConfirmation.sol"; ``` Extension of [`ERC7579Multisig`](#ERC7579Multisig) that requires explicit confirmation signatures @@ -1553,8 +1553,8 @@ consent to be added. Each signer must sign an EIP-712 message to confirm their a Use this module to ensure that all guardians in a social recovery or multisig setup have -explicitly agreed to their roles. +explicitly agreed to their roles.

Functions

@@ -1720,7 +1720,7 @@ Error thrown when a confirmation signature has expired
```solidity -import "@openzeppelin/community-contracts/account/modules/ERC7579MultisigStorage.sol"; +import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579MultisigStorage.sol"; ``` Extension of [`ERC7579Multisig`](#ERC7579Multisig) that allows storing presigned approvals in storage. @@ -1830,8 +1830,8 @@ signed, otherwise acts as a no-op. Does not check if the signer is authorized for the account. Valid signatures from -invalid signers won't be executable. See [`ERC7579Multisig._validateSignatures`](#ERC7579Multisig-_validateSignatures-address-bytes32-bytes---bytes---) for more details. +invalid signers won't be executable. See [`ERC7579Multisig._validateSignatures`](#ERC7579Multisig-_validateSignatures-address-bytes32-bytes---bytes---) for more details. @@ -1851,7 +1851,7 @@ invalid signers won't be executable. See [`ERC7579Multisig._validateSignatures`] See [`ERC7579Multisig._validateSignatures`](#ERC7579Multisig-_validateSignatures-address-bytes32-bytes---bytes---). If a signature is empty, it indicates a presignature and the validation will check the storage mapping -instead of cryptographic verification. See [`ERC7579Multisig._signersSetByAccount`](#ERC7579Multisig-_signersSetByAccount-mapping-address----struct-EnumerableSet-BytesSet-) for more details. +instead of cryptographic verification. See `sign` for more details. @@ -1887,7 +1887,7 @@ Emitted when a signer signs a hash ```solidity -import "@openzeppelin/community-contracts/account/modules/ERC7579MultisigWeighted.sol"; +import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579MultisigWeighted.sol"; ``` Extension of [`ERC7579Multisig`](#ERC7579Multisig) that supports weighted signatures. @@ -1905,9 +1905,9 @@ after the time delay has passed. 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 signatures with a total weight of at least 4 (e.g., one with weight 1 and one with weight 3). -

Functions

@@ -1996,8 +1996,8 @@ If weights are not provided but signers are, all signers default to weight 1. An account can only call onInstall once. If called directly by the account, -the signer will be set to the provided data. Future installations will behave as a no-op. +the signer will be set to the provided data. Future installations will behave as a no-op.
@@ -2158,10 +2158,10 @@ Override to validate threshold against total weight instead of signer count. 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. - @@ -2183,8 +2183,8 @@ Overrides the base implementation to use weights instead of count. This function intentionally does not call `super._validateThreshold` because the base implementation -assumes each signer has a weight of 1, which is incompatible with this weighted implementation. +assumes each signer has a weight of 1, which is incompatible with this weighted implementation. @@ -2206,8 +2206,8 @@ Emitted when a signer's weight is changed. Not emitted in [`ERC7579Multisig._addSigners`](#ERC7579Multisig-_addSigners-address-bytes---) or [`ERC7579Multisig._removeSigners`](#ERC7579Multisig-_removeSigners-address-bytes---). Indexers must rely on [`ERC7579Multisig.ERC7913SignerAdded`](#ERC7579Multisig-ERC7913SignerAdded-address-bytes-) -and [`ERC7579Multisig.ERC7913SignerRemoved`](#ERC7579Multisig-ERC7913SignerRemoved-address-bytes-) to index a default weight of 1. See [`ERC7579MultisigWeighted.signerWeight`](#ERC7579MultisigWeighted-signerWeight-address-bytes-). +and [`ERC7579Multisig.ERC7913SignerRemoved`](#ERC7579Multisig-ERC7913SignerRemoved-address-bytes-) to index a default weight of 1. See [`ERC7579MultisigWeighted.signerWeight`](#ERC7579MultisigWeighted-signerWeight-address-bytes-). @@ -2259,7 +2259,7 @@ Thrown when the arrays lengths don't match. ```solidity -import "@openzeppelin/community-contracts/account/modules/ERC7579SelectorExecutor.sol"; +import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579SelectorExecutor.sol"; ``` Implementation of an [`ERC7579Executor`](#ERC7579Executor) that allows authorizing specific function selectors @@ -2340,8 +2340,8 @@ Returns the set of authorized selectors for the specified account. This operation copies the entire selectors set to memory, which -can be expensive or may result in unbounded computation. +can be expensive or may result in unbounded computation. @@ -2381,8 +2381,8 @@ Clears all selectors. This function has unbounded gas costs and may become uncallable if the set grows too large. -See [`EnumerableSetExtended.clear`](./utils#EnumerableSetExtended-clear-struct-EnumerableSetExtended-Bytes32x2Set-). +See [`EnumerableSetExtended.clear`](/community-contracts/api/utils#EnumerableSetExtended-clear-struct-EnumerableSetExtended-Bytes32x2Set-). @@ -2538,7 +2538,7 @@ Error thrown when attempting to execute a non-authorized selector ```solidity -import "@openzeppelin/community-contracts/account/modules/ERC7579Signature.sol"; +import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579Signature.sol"; ``` Implementation of [`ERC7579Validator`](#ERC7579Validator) module using ERC-7913 signature verification. @@ -2623,8 +2623,8 @@ See `IERC7579Module-onInstall`. An account can only call onInstall once. If called directly by the account, -the signer will be set to the provided data. Future installations will behave as a no-op. +the signer will be set to the provided data. Future installations will behave as a no-op. @@ -2645,9 +2645,9 @@ See `IERC7579Module-onUninstall`. The signer's key will be removed if the account calls this function, potentially + making the account unusable. As an account operator, make sure to uninstall to a predefined path in your account that properly handles side effects of uninstallation. See `AccountERC7579-uninstallModule`. - @@ -2757,7 +2757,7 @@ Thrown when the signer length is less than 20 bytes. ```solidity -import "@openzeppelin/community-contracts/account/modules/ERC7579Validator.sol"; +import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579Validator.sol"; ``` Abstract validator module for ERC-7579 accounts. @@ -2889,8 +2889,8 @@ Validation algorithm. Validation is a critical security function. Implementations must carefully -handle cryptographic verification to prevent unauthorized access. +handle cryptographic verification to prevent unauthorized access. @@ -2908,7 +2908,7 @@ handle cryptographic verification to prevent unauthorized access. ```solidity -import "@openzeppelin/community-contracts/account/paymaster/PaymasterCore.sol"; +import "@openzeppelin/community-contracts/contracts/account/paymaster/PaymasterCore.sol"; ``` A simple ERC4337 paymaster implementation. This base implementation only includes the minimal logic to validate @@ -2925,8 +2925,8 @@ through the internal functions [`PaymasterCore.deposit`](#PaymasterCore-deposit- See [Paymaster's unstaked reputation rules](https://eips.ethereum.org/EIPS/eip-7562#unstaked-paymasters-reputation-rules) - for more details on the paymaster's storage access limitations. + for more details on the paymaster's storage access limitations.

Modifiers

@@ -3094,8 +3094,8 @@ is returned by [`PaymasterCore.validatePaymasterUserOp`](#PaymasterCore-validate The `actualUserOpFeePerGas` is not `tx.gasprice`. A user operation can be bundled with other transactions -making the gas price of the user operation to differ. +making the gas price of the user operation to differ.
@@ -3256,7 +3256,7 @@ Unauthorized call to the paymaster. ```solidity -import "@openzeppelin/community-contracts/account/paymaster/PaymasterERC20.sol"; +import "@openzeppelin/community-contracts/contracts/account/paymaster/PaymasterERC20.sol"; ``` Extension of [`PaymasterCore`](#PaymasterCore) that enables users to pay gas with ERC-20 tokens. @@ -3366,9 +3366,9 @@ Returns a `prefundContext` that's passed to the [`PaymasterCore._postOp`](#Payma Consider not reverting if the prefund fails when overriding this function. This is to avoid reverting + during the validation phase of the user operation, which may penalize the paymaster's reputation according to ERC-7562 validation rules. - @@ -3391,9 +3391,9 @@ Reverts with [`PaymasterERC20.PaymasterERC20FailedRefund`](#PaymasterERC20-Payma This function may revert after the user operation has been executed without + reverting the user operation itself. Consider implementing a mechanism to handle this case gracefully. - @@ -3438,7 +3438,7 @@ The values returned by this internal function are: * `token`: Address of the ERC-20 token used for payment to the paymaster. * `tokenPrice`: Price of the token in native currency, scaled by `_tokenPriceDenominator()`. -==== Calculating the token price +#### Calculating the token price Given gas fees are paid in native currency, developers can use the `ERC20 price unit / native price unit` ratio to calculate the price of an ERC20 token price in native currency. However, the token may have a different number of decimals @@ -3572,7 +3572,7 @@ and the `actualAmount` of `token`. ```solidity -import "@openzeppelin/community-contracts/account/paymaster/PaymasterERC20Guarantor.sol"; +import "@openzeppelin/community-contracts/contracts/account/paymaster/PaymasterERC20Guarantor.sol"; ``` Extension of [`PaymasterERC20`](#PaymasterERC20) that enables third parties to guarantee user operations. @@ -3685,8 +3685,8 @@ Otherwise, fallback to [`PaymasterERC20._refund`](#PaymasterERC20-_refund-contra For guaranteed user operations where the user paid the `actualGasCost` back, this function -doesn't call `super._refund`. Consider whether there are side effects in the parent contract that need to be executed. +doesn't call `super._refund`. Consider whether there are side effects in the parent contract that need to be executed. @@ -3707,8 +3707,8 @@ Fetches the guarantor address and validation data from the user operation. Return `address(0)` to disable the guarantor feature. If supported, ensure -explicit consent (e.g., signature verification) to prevent unauthorized use. +explicit consent (e.g., signature verification) to prevent unauthorized use. @@ -3761,7 +3761,7 @@ Emitted when a user operation identified by `userOpHash` is guaranteed by a `gua ```solidity -import "@openzeppelin/community-contracts/account/paymaster/PaymasterERC721Owner.sol"; +import "@openzeppelin/community-contracts/contracts/account/paymaster/PaymasterERC721Owner.sol"; ``` Extension of [`PaymasterCore`](#PaymasterCore) that supports account based on ownership of an ERC-721 token. @@ -3876,8 +3876,8 @@ Returns the context to be passed to postOp and the validation data. The default `context` is `bytes(0)`. Developers that add a context when overriding this function MUST -also override [`PaymasterCore._postOp`](#PaymasterCore-_postOp-enum-IPaymaster-PostOpMode-bytes-uint256-uint256-) to process the context passed along. +also override [`PaymasterCore._postOp`](#PaymasterCore-_postOp-enum-IPaymaster-PostOpMode-bytes-uint256-uint256-) to process the context passed along. @@ -3913,7 +3913,7 @@ Emitted when the paymaster token is set. ```solidity -import "@openzeppelin/community-contracts/account/paymaster/PaymasterSigner.sol"; +import "@openzeppelin/community-contracts/contracts/account/paymaster/PaymasterSigner.sol"; ``` Extension of [`PaymasterCore`](#PaymasterCore) that adds signature validation. See `SignerECDSA`, `SignerP256` or `SignerRSA`. @@ -4017,8 +4017,8 @@ Returns the context to be passed to postOp and the validation data. The `context` returned is `bytes(0)`. Developers overriding this function MUST -override [`PaymasterCore._postOp`](#PaymasterCore-_postOp-enum-IPaymaster-PostOpMode-bytes-uint256-uint256-) to process the context passed along. +override [`PaymasterCore._postOp`](#PaymasterCore-_postOp-enum-IPaymaster-PostOpMode-bytes-uint256-uint256-) to process the context passed along. @@ -4039,3 +4039,4 @@ Decodes the user operation's data from `paymasterAndData`. + diff --git a/content/community-contracts/api/crosschain.mdx b/content/community-contracts/api/crosschain.mdx index 2ecb1370..1995d1fd 100644 --- a/content/community-contracts/api/crosschain.mdx +++ b/content/community-contracts/api/crosschain.mdx @@ -5,21 +5,16 @@ description: "Smart contract crosschain utilities and implementations" Gateways are contracts that enable cross-chain communication. These can either be a message source or a destination according to ERC-7786. -* [`ERC7786Receiver`](#ERC7786Receiver): ERC-7786 cross-chain message receiver. -* [`ERC7786OpenBridge`](#ERC7786OpenBridge): ERC-7786 "N out of M" gateway. Sends a message through M gateways and executes on the destination if N received it. +- [`ERC7786OpenBridge`](#ERC7786OpenBridge): ERC-7786 "N out of M" gateway. Sends a message through M gateways and executes on the destination if N received it. Developers can access interoperability protocols through gateway adapters. The library includes the following gateway adapters: -* [`AxelarGatewayAdapter`](#AxelarGatewayAdapter): ERC-7786 gateway adapter for Axelar. +- [`AxelarGatewayAdapter`](#AxelarGatewayAdapter): ERC-7786 gateway adapter for Axelar. ## Gateways [`ERC7786OpenBridge`](#ERC7786OpenBridge) -## Clients - -[`ERC7786Receiver`](#ERC7786Receiver) - ## Adapters ### Axelar @@ -39,10 +34,10 @@ Developers can access interoperability protocols through gateway adapters. The l ```solidity -import "@openzeppelin/community-contracts/crosschain/ERC7786OpenBridge.sol"; +import "@openzeppelin/community-contracts/contracts/crosschain/ERC7786OpenBridge.sol"; ``` -N of M gateway: Sends your message through M independent gateways. It will be delivered to the receiver by an +N of M gateway: Sends your message through M independent gateways. It will be delivered to the recipient by an equivalent bridge on the destination chain if N of the M gateways agree.
@@ -79,7 +74,7 @@ equivalent bridge on the destination chain if N of the M gateways agree. - [renounceOwnership()](#Ownable-renounceOwnership--) - [transferOwnership(newOwner)](#Ownable-transferOwnership-address-) - [_transferOwnership(newOwner)](#Ownable-_transferOwnership-address-) -#### IERC7786Receiver [!toc] +#### IERC7786Recipient [!toc] #### IERC7786GatewaySource [!toc]
@@ -100,9 +95,9 @@ equivalent bridge on the destination chain if N of the M gateways agree. - [Unpaused(account)](#Pausable-Unpaused-address-) #### Ownable [!toc] - [OwnershipTransferred(previousOwner, newOwner)](#Ownable-OwnershipTransferred-address-address-) -#### IERC7786Receiver [!toc] +#### IERC7786Recipient [!toc] #### IERC7786GatewaySource [!toc] -- [MessageSent(sendId, sender, receiver, payload, value, attributes)](#IERC7786GatewaySource-MessageSent-bytes32-bytes-bytes-bytes-uint256-bytes---) +- [MessageSent(sendId, sender, recipient, payload, value, attributes)](#IERC7786GatewaySource-MessageSent-bytes32-bytes-bytes-bytes-uint256-bytes---) @@ -124,7 +119,7 @@ equivalent bridge on the destination chain if N of the M gateways agree. #### Ownable [!toc] - [OwnableUnauthorizedAccount(account)](#Ownable-OwnableUnauthorizedAccount-address-) - [OwnableInvalidOwner(owner)](#Ownable-OwnableInvalidOwner-address-) -#### IERC7786Receiver [!toc] +#### IERC7786Recipient [!toc] #### IERC7786GatewaySource [!toc] - [UnsupportedAttribute(selector)](#IERC7786GatewaySource-UnsupportedAttribute-bytes4-) @@ -210,27 +205,27 @@ This function revert if: chain. * someone tries re-execute a message that was already successfully delivered. This includes gateways that call this function a second time with a message that was already executed. -* the execution of the message (on the [`IERC7786Receiver`](./interfaces#IERC7786Receiver) receiver) is successful but fails to return the +* the execution of the message (on the `IERC7786Recipient` recipient) is successful but fails to return the executed value. This function does not revert if: * A known gateway delivers a message for the first time, and that message was already executed. In that case the message is NOT re-executed, and the correct "magic value" is returned. -* The execution of the message (on the [`IERC7786Receiver`](./interfaces#IERC7786Receiver) receiver) reverts. In that case a [`ERC7786OpenBridge.ExecutionFailed`](#ERC7786OpenBridge-ExecutionFailed-bytes32-) +* The execution of the message (on the `IERC7786Recipient` recipient) reverts. In that case a [`ERC7786OpenBridge.ExecutionFailed`](#ERC7786OpenBridge-ExecutionFailed-bytes32-) event is emitted. This function emits: * [`ERC7786OpenBridge.Received`](#ERC7786OpenBridge-Received-bytes32-address-) when a known ERC-7786 gateway delivers a message for the first time. -* [`ERC7786OpenBridge.ExecutionSuccess`](#ERC7786OpenBridge-ExecutionSuccess-bytes32-) when a message is successfully delivered to the receiver. -* [`ERC7786OpenBridge.ExecutionFailed`](#ERC7786OpenBridge-ExecutionFailed-bytes32-) when a message delivery to the receiver reverted (for example because of OOG error). +* [`ERC7786OpenBridge.ExecutionSuccess`](#ERC7786OpenBridge-ExecutionSuccess-bytes32-) when a message is successfully delivered to the recipient. +* [`ERC7786OpenBridge.ExecutionFailed`](#ERC7786OpenBridge-ExecutionFailed-bytes32-) when a message delivery to the recipient reverted (for example because of OOG error). interface requires this function to be payable. Even if we don't expect any value, a gateway may pass + some value for unknown reason. In that case we want to register this gateway having delivered the message and not revert. Any value accrued that way can be recovered by the admin using the [`ERC7786OpenBridge.sweep`](#ERC7786OpenBridge-sweep-address-payable-) function. - @@ -731,21 +726,21 @@ Recovery method in case value is ever received through [`ERC7786OpenBridge.recei ```solidity -import "@openzeppelin/community-contracts/crosschain/axelar/AxelarGatewayAdapter.sol"; +import "@openzeppelin/community-contracts/contracts/crosschain/axelar/AxelarGatewayAdapter.sol"; ``` Implementation of an ERC-7786 gateway destination adapter for the Axelar Network in dual mode. -The contract implements AxelarExecutable's [`ERC7579DelayedExecutor._execute`](./account#ERC7579DelayedExecutor-_execute-address-bytes32-bytes32-bytes-) function to execute the message, converting Axelar's native +The contract implements AxelarExecutable's [`AxelarGatewayAdapter._execute`](#AxelarGatewayAdapter-_execute-bytes32-string-string-bytes-) function to execute the message, converting Axelar's native workflow into the standard ERC-7786. While both ERC-7786 and Axelar do support non-evm chains, this adaptor does not. This limitation comes from + the translation of the ERC-7930 interoperable address (binary objects -- bytes) to strings. This is necessary because Axelar uses string to represent addresses. For EVM network, this adapter uses a checksum hex string representation. Other networks would require a different encoding. Ideally we would have a single encoding for all networks (could be base58, base64, ...) but Axelar doesn't support that. -

Functions

@@ -785,7 +780,7 @@ networks (could be base58, base64, ...) but Axelar doesn't support that. #### Ownable [!toc] - [OwnershipTransferred(previousOwner, newOwner)](#Ownable-OwnershipTransferred-address-address-) #### IERC7786GatewaySource [!toc] -- [MessageSent(sendId, sender, receiver, payload, value, attributes)](#IERC7786GatewaySource-MessageSent-bytes32-bytes-bytes-bytes-uint256-bytes---) +- [MessageSent(sendId, sender, recipient, payload, value, attributes)](#IERC7786GatewaySource-MessageSent-bytes32-bytes-bytes-bytes-uint256-bytes---)
@@ -794,7 +789,7 @@ networks (could be base58, base64, ...) but Axelar doesn't support that.
- [UnsupportedNativeTransfer()](#AxelarGatewayAdapter-UnsupportedNativeTransfer--) - [InvalidOriginGateway(axelarSourceChain, axelarSourceAddress)](#AxelarGatewayAdapter-InvalidOriginGateway-string-string-) -- [ReceiverExecutionFailed()](#AxelarGatewayAdapter-ReceiverExecutionFailed--) +- [RecipientExecutionFailed()](#AxelarGatewayAdapter-RecipientExecutionFailed--) - [UnsupportedChainType(chainType)](#AxelarGatewayAdapter-UnsupportedChainType-bytes2-) - [UnsupportedERC7930Chain(erc7930binary)](#AxelarGatewayAdapter-UnsupportedERC7930Chain-bytes-) - [UnsupportedAxelarChain(axelar)](#AxelarGatewayAdapter-UnsupportedAxelarChain-string-) @@ -962,12 +957,12 @@ Getter to check whether an attribute is supported or not.
Endpoint for creating a new message. If the message requires further (gateway specific) processing before -it can be sent to the destination chain, then a non-zero `outboxId` must be returned. Otherwise, the +it can be sent to the destination chain, then a non-zero `sendId` must be returned. Otherwise, the message MUST be sent and this function must return 0. -* MUST emit a [`IERC7786GatewaySource.MessageSent`](./interfaces#IERC7786GatewaySource-MessageSent-bytes32-bytes-bytes-bytes-uint256-bytes---) event. +* MUST emit a `MessageSent` event. -If any of the `attributes` is not supported, this function SHOULD revert with an [`IERC7786GatewaySource.UnsupportedAttribute`](./interfaces#IERC7786GatewaySource-UnsupportedAttribute-bytes4-) error. +If any of the `attributes` is not supported, this function SHOULD revert with an `UnsupportedAttribute` error. Other errors SHOULD revert with errors not specified in ERC-7786.
@@ -1080,14 +1075,14 @@ A chain equivalence has been registered.
- +
-

ReceiverExecutionFailed()

+

RecipientExecutionFailed()

error

-# +#
@@ -1198,7 +1193,7 @@ A chain equivalence has been registered.
```solidity -import "@openzeppelin/community-contracts/crosschain/utils/ERC7786Attributes.sol"; +import "@openzeppelin/community-contracts/contracts/crosschain/utils/ERC7786Attributes.sol"; ``` Library of helper to parse/process ERC-7786 attributes @@ -1227,135 +1222,6 @@ Parse the `requestRelay(uint256,uint256,address)` (0x4cbb573a) attribute into it
- - -
- -## `ERC7786Receiver` - - - - - -
- -```solidity -import "@openzeppelin/community-contracts/crosschain/utils/ERC7786Receiver.sol"; -``` - -Base implementation of an ERC-7786 compliant cross-chain message receiver. - -This abstract contract exposes the `receiveMessage` function that is used for communication with (one or multiple) -destination gateways. This contract leaves two functions unimplemented: - -[`ERC7786Receiver._isKnownGateway`](#ERC7786Receiver-_isKnownGateway-address-), an internal getter used to verify whether an address is recognised by the contract as a valid -ERC-7786 destination gateway. One or multiple gateway can be supported. Note that any malicious address for which -this function returns true would be able to impersonate any account on any other chain sending any message. - -[`ERC7786Receiver._processMessage`](#ERC7786Receiver-_processMessage-address-bytes32-bytes-bytes-), the internal function that will be called with any message that has been validated. - -
-

Functions

-
-- [receiveMessage(receiveId, sender, payload)](#ERC7786Receiver-receiveMessage-bytes32-bytes-bytes-) -- [_isKnownGateway(instance)](#ERC7786Receiver-_isKnownGateway-address-) -- [_processMessage(gateway, receiveId, sender, payload)](#ERC7786Receiver-_processMessage-address-bytes32-bytes-bytes-) -#### IERC7786Receiver [!toc] -
-
- -
-

Errors

-
-- [ERC7786ReceiverInvalidGateway(gateway)](#ERC7786Receiver-ERC7786ReceiverInvalidGateway-address-) -- [ERC7786ReceivePassiveModeValue()](#ERC7786Receiver-ERC7786ReceivePassiveModeValue--) -#### IERC7786Receiver [!toc] -
-
- - - -
-
-

receiveMessage(bytes32 receiveId, bytes sender, bytes payload) → bytes4

-
-

public

-# -
-
-
- -Endpoint for receiving cross-chain message. - -This function may be called directly by the gateway. - -
-
- - - -
-
-

_isKnownGateway(address instance) → bool

-
-

internal

-# -
-
-
- -Virtual getter that returns whether an address is a valid ERC-7786 gateway. - -
-
- - - -
-
-

_processMessage(address gateway, bytes32 receiveId, bytes sender, bytes payload)

-
-

internal

-# -
-
-
- -Virtual function that should contain the logic to execute when a cross-chain message is received. - -
-
- - - -
-
-

ERC7786ReceiverInvalidGateway(address gateway)

-
-

error

-# -
-
-
- -
-
- - - -
-
-

ERC7786ReceivePassiveModeValue()

-
-

error

-# -
-
-
- -
-
-
@@ -1369,7 +1235,7 @@ Virtual function that should contain the logic to execute when a cross-chain mes
```solidity -import "@openzeppelin/community-contracts/crosschain/wormhole/WormholeGatewayAdapter.sol"; +import "@openzeppelin/community-contracts/contracts/crosschain/wormhole/WormholeGatewayAdapter.sol"; ``` An ERC-7786 compliant adapter to send and receive messages via Wormhole. @@ -1425,7 +1291,7 @@ Note: only EVM chains are currently supported - [OwnershipTransferred(previousOwner, newOwner)](#Ownable-OwnershipTransferred-address-address-) #### IWormholeReceiver [!toc] #### IERC7786GatewaySource [!toc] -- [MessageSent(sendId, sender, receiver, payload, value, attributes)](#IERC7786GatewaySource-MessageSent-bytes32-bytes-bytes-bytes-uint256-bytes---) +- [MessageSent(sendId, sender, recipient, payload, value, attributes)](#IERC7786GatewaySource-MessageSent-bytes32-bytes-bytes-bytes-uint256-bytes---) @@ -1436,7 +1302,7 @@ Note: only EVM chains are currently supported - [DuplicatedAttribute()](#WormholeGatewayAdapter-DuplicatedAttribute--) - [UnauthorizedCaller()](#WormholeGatewayAdapter-UnauthorizedCaller-address-) - [InvalidOriginGateway(wormholeSourceChain, wormholeSourceAddress)](#WormholeGatewayAdapter-InvalidOriginGateway-uint16-bytes32-) -- [ReceiverExecutionFailed()](#WormholeGatewayAdapter-ReceiverExecutionFailed--) +- [RecipientExecutionFailed()](#WormholeGatewayAdapter-RecipientExecutionFailed--) - [UnsupportedChainId(chainId)](#WormholeGatewayAdapter-UnsupportedChainId-uint256-) - [UnsupportedWormholeChain(wormholeId)](#WormholeGatewayAdapter-UnsupportedWormholeChain-uint16-) - [ChainEquivalenceAlreadyRegistered(chainId, wormhole)](#WormholeGatewayAdapter-ChainEquivalenceAlreadyRegistered-uint256-uint16-) @@ -1720,12 +1586,12 @@ Getter to check whether an attribute is supported or not.
Endpoint for creating a new message. If the message requires further (gateway specific) processing before -it can be sent to the destination chain, then a non-zero `outboxId` must be returned. Otherwise, the +it can be sent to the destination chain, then a non-zero `sendId` must be returned. Otherwise, the message MUST be sent and this function must return 0. -* MUST emit a [`IERC7786GatewaySource.MessageSent`](./interfaces#IERC7786GatewaySource-MessageSent-bytes32-bytes-bytes-bytes-uint256-bytes---) event. +* MUST emit a `MessageSent` event. -If any of the `attributes` is not supported, this function SHOULD revert with an [`IERC7786GatewaySource.UnsupportedAttribute`](./interfaces#IERC7786GatewaySource-UnsupportedAttribute-bytes4-) error. +If any of the `attributes` is not supported, this function SHOULD revert with an `UnsupportedAttribute` error. Other errors SHOULD revert with errors not specified in ERC-7786.
@@ -1892,14 +1758,14 @@ A chain equivalence has been registered. - +
-

ReceiverExecutionFailed()

+

RecipientExecutionFailed()

error

-# +#
@@ -2011,3 +1877,4 @@ A chain equivalence has been registered.
+ diff --git a/content/community-contracts/api/governance.mdx b/content/community-contracts/api/governance.mdx new file mode 100644 index 00000000..b0a3ff62 --- /dev/null +++ b/content/community-contracts/api/governance.mdx @@ -0,0 +1,472 @@ +--- +title: "Governance" +description: "Smart contract governance utilities and implementations" +--- + +This directory includes extensions and utilities for on-chain governance. + +* [`TimelockControllerEnumerable`](#TimelockControllerEnumerable): Extension of OpenZeppelin's TimelockController with enumerable operations support. + +## Timelock + +[`TimelockControllerEnumerable`](#TimelockControllerEnumerable) + + + +
+ +## `TimelockControllerEnumerable` + + + + + +
+ +```solidity +import "@openzeppelin/community-contracts/contracts/governance/TimelockControllerEnumerable.sol"; +``` + +Extends the TimelockController to allow for enumerable operations + +
+

Functions

+
+- [schedule(target, value, data, predecessor, salt, delay)](#TimelockControllerEnumerable-schedule-address-uint256-bytes-bytes32-bytes32-uint256-) +- [scheduleBatch(targets, values, payloads, predecessor, salt, delay)](#TimelockControllerEnumerable-scheduleBatch-address---uint256---bytes---bytes32-bytes32-uint256-) +- [cancel(id)](#TimelockControllerEnumerable-cancel-bytes32-) +- [operations()](#TimelockControllerEnumerable-operations--) +- [operations(start, end)](#TimelockControllerEnumerable-operations-uint256-uint256-) +- [operationsCount()](#TimelockControllerEnumerable-operationsCount--) +- [operation(index)](#TimelockControllerEnumerable-operation-uint256-) +- [operation(id)](#TimelockControllerEnumerable-operation-bytes32-) +- [operationsBatch()](#TimelockControllerEnumerable-operationsBatch--) +- [operationsBatch(start, end)](#TimelockControllerEnumerable-operationsBatch-uint256-uint256-) +- [operationsBatchCount()](#TimelockControllerEnumerable-operationsBatchCount--) +- [operationBatch(index)](#TimelockControllerEnumerable-operationBatch-uint256-) +- [operationBatch(id)](#TimelockControllerEnumerable-operationBatch-bytes32-) +#### TimelockController [!toc] +- [receive()](#TimelockController-receive--) +- [supportsInterface(interfaceId)](#TimelockController-supportsInterface-bytes4-) +- [isOperation(id)](#TimelockController-isOperation-bytes32-) +- [isOperationPending(id)](#TimelockController-isOperationPending-bytes32-) +- [isOperationReady(id)](#TimelockController-isOperationReady-bytes32-) +- [isOperationDone(id)](#TimelockController-isOperationDone-bytes32-) +- [getTimestamp(id)](#TimelockController-getTimestamp-bytes32-) +- [getOperationState(id)](#TimelockController-getOperationState-bytes32-) +- [getMinDelay()](#TimelockController-getMinDelay--) +- [hashOperation(target, value, data, predecessor, salt)](#TimelockController-hashOperation-address-uint256-bytes-bytes32-bytes32-) +- [hashOperationBatch(targets, values, payloads, predecessor, salt)](#TimelockController-hashOperationBatch-address---uint256---bytes---bytes32-bytes32-) +- [execute(target, value, payload, predecessor, salt)](#TimelockController-execute-address-uint256-bytes-bytes32-bytes32-) +- [executeBatch(targets, values, payloads, predecessor, salt)](#TimelockController-executeBatch-address---uint256---bytes---bytes32-bytes32-) +- [_execute(target, value, data)](#TimelockController-_execute-address-uint256-bytes-) +- [updateDelay(newDelay)](#TimelockController-updateDelay-uint256-) +- [_encodeStateBitmap(operationState)](#TimelockController-_encodeStateBitmap-enum-TimelockController-OperationState-) +- [PROPOSER_ROLE()](#TimelockController-PROPOSER_ROLE-bytes32) +- [EXECUTOR_ROLE()](#TimelockController-EXECUTOR_ROLE-bytes32) +- [CANCELLER_ROLE()](#TimelockController-CANCELLER_ROLE-bytes32) +#### ERC1155Holder [!toc] +- [onERC1155Received(, , , , )](#ERC1155Holder-onERC1155Received-address-address-uint256-uint256-bytes-) +- [onERC1155BatchReceived(, , , , )](#ERC1155Holder-onERC1155BatchReceived-address-address-uint256---uint256---bytes-) +#### IERC1155Receiver [!toc] +#### ERC721Holder [!toc] +- [onERC721Received(, , , )](#ERC721Holder-onERC721Received-address-address-uint256-bytes-) +#### IERC721Receiver [!toc] +#### AccessControl [!toc] +- [hasRole(role, account)](#AccessControl-hasRole-bytes32-address-) +- [_checkRole(role)](#AccessControl-_checkRole-bytes32-) +- [_checkRole(role, account)](#AccessControl-_checkRole-bytes32-address-) +- [getRoleAdmin(role)](#AccessControl-getRoleAdmin-bytes32-) +- [grantRole(role, account)](#AccessControl-grantRole-bytes32-address-) +- [revokeRole(role, account)](#AccessControl-revokeRole-bytes32-address-) +- [renounceRole(role, callerConfirmation)](#AccessControl-renounceRole-bytes32-address-) +- [_setRoleAdmin(role, adminRole)](#AccessControl-_setRoleAdmin-bytes32-bytes32-) +- [_grantRole(role, account)](#AccessControl-_grantRole-bytes32-address-) +- [_revokeRole(role, account)](#AccessControl-_revokeRole-bytes32-address-) +- [DEFAULT_ADMIN_ROLE()](#AccessControl-DEFAULT_ADMIN_ROLE-bytes32) +#### ERC165 [!toc] +#### IERC165 [!toc] +#### IAccessControl [!toc] +
+
+ +
+

Events

+
+#### TimelockController [!toc] +- [CallScheduled(id, index, target, value, data, predecessor, delay)](#TimelockController-CallScheduled-bytes32-uint256-address-uint256-bytes-bytes32-uint256-) +- [CallExecuted(id, index, target, value, data)](#TimelockController-CallExecuted-bytes32-uint256-address-uint256-bytes-) +- [CallSalt(id, salt)](#TimelockController-CallSalt-bytes32-bytes32-) +- [Cancelled(id)](#TimelockController-Cancelled-bytes32-) +- [MinDelayChange(oldDuration, newDuration)](#TimelockController-MinDelayChange-uint256-uint256-) +#### ERC1155Holder [!toc] +#### IERC1155Receiver [!toc] +#### ERC721Holder [!toc] +#### IERC721Receiver [!toc] +#### AccessControl [!toc] +#### ERC165 [!toc] +#### IERC165 [!toc] +#### IAccessControl [!toc] +- [RoleAdminChanged(role, previousAdminRole, newAdminRole)](#IAccessControl-RoleAdminChanged-bytes32-bytes32-bytes32-) +- [RoleGranted(role, account, sender)](#IAccessControl-RoleGranted-bytes32-address-address-) +- [RoleRevoked(role, account, sender)](#IAccessControl-RoleRevoked-bytes32-address-address-) +
+
+ +
+

Errors

+
+- [OperationIndexNotFound(index)](#TimelockControllerEnumerable-OperationIndexNotFound-uint256-) +- [OperationIdNotFound(id)](#TimelockControllerEnumerable-OperationIdNotFound-bytes32-) +- [OperationBatchIndexNotFound(index)](#TimelockControllerEnumerable-OperationBatchIndexNotFound-uint256-) +- [OperationBatchIdNotFound(id)](#TimelockControllerEnumerable-OperationBatchIdNotFound-bytes32-) +- [InvalidIndexRange(start, end)](#TimelockControllerEnumerable-InvalidIndexRange-uint256-uint256-) +#### TimelockController [!toc] +- [TimelockInvalidOperationLength(targets, payloads, values)](#TimelockController-TimelockInvalidOperationLength-uint256-uint256-uint256-) +- [TimelockInsufficientDelay(delay, minDelay)](#TimelockController-TimelockInsufficientDelay-uint256-uint256-) +- [TimelockUnexpectedOperationState(operationId, expectedStates)](#TimelockController-TimelockUnexpectedOperationState-bytes32-bytes32-) +- [TimelockUnexecutedPredecessor(predecessorId)](#TimelockController-TimelockUnexecutedPredecessor-bytes32-) +- [TimelockUnauthorizedCaller(caller)](#TimelockController-TimelockUnauthorizedCaller-address-) +#### ERC1155Holder [!toc] +#### IERC1155Receiver [!toc] +#### ERC721Holder [!toc] +#### IERC721Receiver [!toc] +#### AccessControl [!toc] +#### ERC165 [!toc] +#### IERC165 [!toc] +#### IAccessControl [!toc] +- [AccessControlUnauthorizedAccount(account, neededRole)](#IAccessControl-AccessControlUnauthorizedAccount-address-bytes32-) +- [AccessControlBadConfirmation()](#IAccessControl-AccessControlBadConfirmation--) +
+
+ + + +
+
+

schedule(address target, uint256 value, bytes data, bytes32 predecessor, bytes32 salt, uint256 delay)

+
+

public

+# +
+
+
+ +Schedule an operation containing a single transaction. + +Emits `CallSalt` if salt is nonzero, and `CallScheduled`. + +Requirements: + +- the caller must have the 'proposer' role. + +
+
+ + + +
+
+

scheduleBatch(address[] targets, uint256[] values, bytes[] payloads, bytes32 predecessor, bytes32 salt, uint256 delay)

+
+

public

+# +
+
+
+ +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. + +
+
+ + + +
+
+

cancel(bytes32 id)

+
+

public

+# +
+
+
+ +Cancel an operation. + +Requirements: + +- the caller must have the 'canceller' role. + +
+
+ + + +
+
+

operations() → struct TimelockControllerEnumerable.Operation[] operations_

+
+

public

+# +
+
+
+ +Return all scheduled operations + +This is designed for view accessors queried without gas fees. Using it in state-changing + +functions may become uncallable if the list grows too large. + +
+
+ + + +
+
+

operations(uint256 start, uint256 end) → struct TimelockControllerEnumerable.Operation[] operations_

+
+

public

+# +
+
+
+ +Return the operations in the given index range + +
+
+ + + +
+
+

operationsCount() → uint256 operationsCount_

+
+

public

+# +
+
+
+ +Return the number of operations from the set + +
+
+ + + +
+
+

operation(uint256 index) → struct TimelockControllerEnumerable.Operation operation_

+
+

public

+# +
+
+
+ +Return the operation at the given index + +
+
+ + + +
+
+

operation(bytes32 id) → struct TimelockControllerEnumerable.Operation operation_

+
+

public

+# +
+
+
+ +Return the operation with the given id + +
+
+ + + +
+
+

operationsBatch() → struct TimelockControllerEnumerable.OperationBatch[] operationsBatch_

+
+

public

+# +
+
+
+ +Return all scheduled operation batches + +This is designed for view accessors queried without gas fees. Using it in state-changing + +functions may become uncallable if the list grows too large. + +
+
+ + + +
+
+

operationsBatch(uint256 start, uint256 end) → struct TimelockControllerEnumerable.OperationBatch[] operationsBatch_

+
+

public

+# +
+
+
+ +Return the operationsBatch in the given index range + +
+
+ + + +
+
+

operationsBatchCount() → uint256 operationsBatchCount_

+
+

public

+# +
+
+
+ +Return the number of operationsBatch from the set + +
+
+ + + +
+
+

operationBatch(uint256 index) → struct TimelockControllerEnumerable.OperationBatch operationBatch_

+
+

public

+# +
+
+
+ +Return the operationsBatch at the given index + +
+
+ + + +
+
+

operationBatch(bytes32 id) → struct TimelockControllerEnumerable.OperationBatch operationBatch_

+
+

public

+# +
+
+
+ +Return the operationsBatch with the given id + +
+
+ + + +
+
+

OperationIndexNotFound(uint256 index)

+
+

error

+# +
+
+
+ +The error when the operation index is not found + +
+
+ + + +
+
+

OperationIdNotFound(bytes32 id)

+
+

error

+# +
+
+
+ +The error when the operation id is not found + +
+
+ + + +
+
+

OperationBatchIndexNotFound(uint256 index)

+
+

error

+# +
+
+
+ +The error when the operation batch index is not found + +
+
+ + + +
+
+

OperationBatchIdNotFound(bytes32 id)

+
+

error

+# +
+
+
+ +The error when the operation batch id is not found + +
+
+ + + +
+
+

InvalidIndexRange(uint256 start, uint256 end)

+
+

error

+# +
+
+
+ +The error when the index range is invalid + +
+
+ diff --git a/content/community-contracts/api/index.mdx b/content/community-contracts/api/index.mdx index 14a2be3d..88b57555 100644 --- a/content/community-contracts/api/index.mdx +++ b/content/community-contracts/api/index.mdx @@ -1,17 +1,18 @@ --- title: API Reference +description: API reference for OpenZeppelin Community Contracts --- -## Core APIs +# API Reference -- **[Access](./api/access)** - Access control and permission management -- **[Account](./api/account)** - Account abstraction and smart account functionality -- **[Crosschain](./api/crosschain)** - Cross-chain communication and bridging utilities -- **[Interfaces](./api/interfaces)** - Standard interfaces and contract definitions -- **[Proxy](./api/proxy)** - Proxy patterns and upgradeable contract utilities -- **[Token](./api/token)** - Token standards and implementations +These pages contain the API reference for the OpenZeppelin Community Contracts library. -## Utilities - -- **[Utils](./api/utils)** - General utility functions and helpers - - **[Cryptography](./api/utils/cryptography)** - Cryptographic functions and primitives +- [Access](/community-contracts/api/access) - Access control utilities +- [Account](/community-contracts/api/account) - ERC-4337 account modules and paymasters +- [Crosschain](/community-contracts/api/crosschain) - Cross-chain communication gateways +- [Governance](/community-contracts/api/governance) - Governance extensions +- [Interfaces](/community-contracts/api/interfaces) - Standardized interfaces +- [Proxy](/community-contracts/api/proxy) - Proxy patterns +- [Token](/community-contracts/api/token) - Token extensions and utilities +- [Utils](/community-contracts/api/utils) - Miscellaneous utilities +- [Cryptography](/community-contracts/api/utils/cryptography) - Cryptographic primitives diff --git a/content/community-contracts/api/interfaces.mdx b/content/community-contracts/api/interfaces.mdx index e0833c3d..3cb609d2 100644 --- a/content/community-contracts/api/interfaces.mdx +++ b/content/community-contracts/api/interfaces.mdx @@ -7,224 +7,257 @@ description: "Smart contract interfaces utilities and implementations" These interfaces are available as `.sol` files. These are useful to interact with third party contracts that implement them. -* [`IERC7786GatewaySource`](#IERC7786GatewaySource), [`IERC7786Receiver`](#IERC7786Receiver) -* [`IERC7802`](#IERC7802) -* [`IERC7821`](#IERC7821) -* `IERC7913SignatureVerifier` -* [`IERC7943`](#IERC7943) +- `IERC7913SignatureVerifier` +- `IERC7943` ## Detailed ABI -[`IERC7786GatewaySource`](#IERC7786GatewaySource) +{`IERC7913SignatureVerifier`} -[`IERC7786Receiver`](#IERC7786Receiver) +{`IERC7943`} -[`IERC7802`](#IERC7802) + -[`IERC7821`](#IERC7821) +
-{`IERC7913SignatureVerifier`} +## `IERC7786Attributes` -[`IERC7943`](#IERC7943) + + + + +
- +```solidity +import "@openzeppelin/community-contracts/contracts/interfaces/IERC7786Attributes.sol"; +``` + +Standard attributes for ERC-7786. These attributes may be standardized in different ERCs. + +
+

Functions

+
+- [requestRelay(value, gasLimit, refundRecipient)](#IERC7786Attributes-requestRelay-uint256-uint256-address-) +
+
+ + + +
+
+

requestRelay(uint256 value, uint256 gasLimit, address refundRecipient)

+
+

external

+# +
+
+
+ +
+
+ +
-## `IERC7786GatewaySource` +## `IERC7943Fungible` - +
```solidity -import "@openzeppelin/community-contracts/interfaces/IERC7786.sol"; +import "@openzeppelin/community-contracts/contracts/interfaces/IERC7943.sol"; ``` -Interface for ERC-7786 source gateways. - -See ERC-7786 for more details -

Functions

-- [supportsAttribute(selector)](#IERC7786GatewaySource-supportsAttribute-bytes4-) -- [sendMessage(recipient, payload, attributes)](#IERC7786GatewaySource-sendMessage-bytes-bytes-bytes---) +- [forcedTransfer(from, to, amount)](#IERC7943Fungible-forcedTransfer-address-address-uint256-) +- [setFrozenTokens(account, amount)](#IERC7943Fungible-setFrozenTokens-address-uint256-) +- [canTransact(account)](#IERC7943Fungible-canTransact-address-) +- [getFrozenTokens(account)](#IERC7943Fungible-getFrozenTokens-address-) +- [canTransfer(from, to, amount)](#IERC7943Fungible-canTransfer-address-address-uint256-) +#### IERC165 [!toc] +- [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-)

Events

-- [MessageSent(sendId, sender, receiver, payload, value, attributes)](#IERC7786GatewaySource-MessageSent-bytes32-bytes-bytes-bytes-uint256-bytes---) +- [ForcedTransfer(from, to, amount)](#IERC7943Fungible-ForcedTransfer-address-address-uint256-) +- [Frozen(account, amount)](#IERC7943Fungible-Frozen-address-uint256-) +#### IERC165 [!toc]

Errors

-- [UnsupportedAttribute(selector)](#IERC7786GatewaySource-UnsupportedAttribute-bytes4-) +- [ERC7943CannotTransact(account)](#IERC7943Fungible-ERC7943CannotTransact-address-) +- [ERC7943CannotTransfer(from, to, amount)](#IERC7943Fungible-ERC7943CannotTransfer-address-address-uint256-) +- [ERC7943InsufficientUnfrozenBalance(account, amount, unfrozen)](#IERC7943Fungible-ERC7943InsufficientUnfrozenBalance-address-uint256-uint256-) +#### IERC165 [!toc]
- +
-

supportsAttribute(bytes4 selector) → bool

+

forcedTransfer(address from, address to, uint256 amount) → bool result

external

-# +#
-Getter to check whether an attribute is supported or not. +Requires specific authorization. Used for regulatory compliance or recovery scenarios.
- +
-

sendMessage(bytes recipient, bytes payload, bytes[] attributes) → bytes32 sendId

+

setFrozenTokens(address account, uint256 amount) → bool result

external

-# +#
-Endpoint for creating a new message. If the message requires further (gateway specific) processing before -it can be sent to the destination chain, then a non-zero `outboxId` must be returned. Otherwise, the -message MUST be sent and this function must return 0. - -* MUST emit a [`IERC7786GatewaySource.MessageSent`](#IERC7786GatewaySource-MessageSent-bytes32-bytes-bytes-bytes-uint256-bytes---) event. - -If any of the `attributes` is not supported, this function SHOULD revert with an [`IERC7786GatewaySource.UnsupportedAttribute`](#IERC7786GatewaySource-UnsupportedAttribute-bytes4-) error. -Other errors SHOULD revert with errors not specified in ERC-7786. +Requires specific authorization. Frozen tokens cannot be transferred by the account.
- +
-

MessageSent(bytes32 indexed sendId, bytes sender, bytes receiver, bytes payload, uint256 value, bytes[] attributes)

+

canTransact(address account) → bool allowed

-

event

-# +

external

+#
-
-Event emitted when a message is created. If `outboxId` is zero, no further processing is necessary. If -`outboxId` is not zero, then further (gateway specific, and non-standardized) action is required. +This is often used for allowlist/KYC/KYB/AML checks.
- +
-

UnsupportedAttribute(bytes4 selector)

+

getFrozenTokens(address account) → uint256 amount

-

error

-# +

external

+#
-This error is thrown when a message creation fails because of an unsupported attribute being specified. +It could return an amount higher than the account's balance.
- - -
- -## `IERC7786Receiver` - - - - + +
+
+

canTransfer(address from, address to, uint256 amount) → bool allowed

+
+

external

+#
+
+
-```solidity -import "@openzeppelin/community-contracts/interfaces/IERC7786.sol"; -``` - -Interface for the ERC-7786 client contract (receiver). - -See ERC-7786 for more details +This can involve checks like allowlists, blocklists, transfer limits and other policy-defined restrictions. -
-

Functions

-
-- [receiveMessage(receiveId, sender, payload)](#IERC7786Receiver-receiveMessage-bytes32-bytes-bytes-)
- +
-

receiveMessage(bytes32 receiveId, bytes sender, bytes payload) → bytes4

+

ForcedTransfer(address indexed from, address indexed to, uint256 amount)

-

external

-# +

event

+#
-
-Endpoint for receiving cross-chain message. +
-This function may be called directly by the gateway. +
+
+ +
+
+

Frozen(address indexed account, uint256 amount)

+
+

event

+#
- +
-
+
+
-## `IERC7786Attributes` + - - - +
+
+

ERC7943CannotTransact(address account)

+
+

error

+# +
+
+
+
-```solidity -import "@openzeppelin/community-contracts/interfaces/IERC7786Attributes.sol"; -``` + -Standard attributes for ERC-7786. These attributes may be standardized in different ERCs. +
+
+

ERC7943CannotTransfer(address from, address to, uint256 amount)

+
+

error

+# +
+
+
-
-

Functions

-
-- [requestRelay(value, gasLimit, refundRecipient)](#IERC7786Attributes-requestRelay-uint256-uint256-address-)
- +
-

requestRelay(uint256 value, uint256 gasLimit, address refundRecipient)

+

ERC7943InsufficientUnfrozenBalance(address account, uint256 amount, uint256 unfrozen)

-

external

-# +

error

+#
@@ -232,27 +265,30 @@ Standard attributes for ERC-7786. These attributes may be standardized in differ
- +
-## `IERC7802` +## `IERC7943NonFungible` - +
```solidity -import "@openzeppelin/community-contracts/interfaces/IERC7802.sol"; +import "@openzeppelin/community-contracts/contracts/interfaces/IERC7943.sol"; ```

Functions

-- [crosschainMint(_to, _amount)](#IERC7802-crosschainMint-address-uint256-) -- [crosschainBurn(_from, _amount)](#IERC7802-crosschainBurn-address-uint256-) +- [forcedTransfer(from, to, tokenId)](#IERC7943NonFungible-forcedTransfer-address-address-uint256-) +- [setFrozenTokens(account, tokenId, frozenStatus)](#IERC7943NonFungible-setFrozenTokens-address-uint256-bool-) +- [canTransact(account)](#IERC7943NonFungible-canTransact-address-) +- [getFrozenTokens(account, tokenId)](#IERC7943NonFungible-getFrozenTokens-address-uint256-) +- [canTransfer(from, to, tokenId)](#IERC7943NonFungible-canTransfer-address-address-uint256-) #### IERC165 [!toc] - [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-)
@@ -261,164 +297,188 @@ import "@openzeppelin/community-contracts/interfaces/IERC7802.sol";

Events

-- [CrosschainMint(to, amount, sender)](#IERC7802-CrosschainMint-address-uint256-address-) -- [CrosschainBurn(from, amount, sender)](#IERC7802-CrosschainBurn-address-uint256-address-) +- [ForcedTransfer(from, to, tokenId)](#IERC7943NonFungible-ForcedTransfer-address-address-uint256-) +- [Frozen(account, tokenId, frozenStatus)](#IERC7943NonFungible-Frozen-address-uint256-bool-) #### IERC165 [!toc]
- +
+

Errors

+
+- [ERC7943CannotTransact(account)](#IERC7943NonFungible-ERC7943CannotTransact-address-) +- [ERC7943CannotTransfer(from, to, tokenId)](#IERC7943NonFungible-ERC7943CannotTransfer-address-address-uint256-) +- [ERC7943InsufficientUnfrozenBalance(account, tokenId)](#IERC7943NonFungible-ERC7943InsufficientUnfrozenBalance-address-uint256-) +#### IERC165 [!toc] +
+
+ +
-

crosschainMint(address _to, uint256 _amount)

+

forcedTransfer(address from, address to, uint256 tokenId) → bool result

external

-# +#
+Requires specific authorization. Used for regulatory compliance or recovery scenarios. +
- +
-

crosschainBurn(address _from, uint256 _amount)

+

setFrozenTokens(address account, uint256 tokenId, bool frozenStatus) → bool result

external

-# +#
+Requires specific authorization. Frozen tokens cannot be transferred by the account. +
- +
-

CrosschainMint(address indexed to, uint256 amount, address indexed sender)

+

canTransact(address account) → bool allowed

-

event

-# +

external

+#
-
+This is often used for allowlist/KYC/KYB/AML checks. +
- + +
-

CrosschainBurn(address indexed from, uint256 amount, address indexed sender)

+

getFrozenTokens(address account, uint256 tokenId) → bool frozenStatus

-

event

-# +

external

+#
-
+It could return true even if account does not hold the token. +
- - -
- -## `IERC7821` - - - - + +
+
+

canTransfer(address from, address to, uint256 tokenId) → bool allowed

+
+

external

+#
+
+
-```solidity -import "@openzeppelin/community-contracts/interfaces/IERC7821.sol"; -``` - -Interface for minimal batch executor. +This can involve checks like allowlists, blocklists, transfer limits and other policy-defined restrictions. -
-

Functions

-
-- [execute(mode, executionData)](#IERC7821-execute-bytes32-bytes-) -- [supportsExecutionMode(mode)](#IERC7821-supportsExecutionMode-bytes32-)
- +
-

execute(bytes32 mode, bytes executionData)

+

ForcedTransfer(address indexed from, address indexed to, uint256 indexed tokenId)

-

external

-# +

event

+#
-
-Executes the calls in `executionData`. -Reverts and bubbles up error if any call fails. - -`executionData` encoding: +
-* If `opData` is empty, `executionData` is simply `abi.encode(calls)`. -* Else, `executionData` is `abi.encode(calls, opData)`. - See: https://eips.ethereum.org/EIPS/eip-7579 +
+
+ -Supported modes: +
+
+

Frozen(address indexed account, uint256 indexed tokenId, bool indexed frozenStatus)

+
+

event

+# +
+
-* `bytes32(0x01000000000000000000...)`: does not support optional `opData`. -* `bytes32(0x01000000000078210001...)`: supports optional `opData`. +
-Authorization checks: +
+
-* If `opData` is empty, the implementation SHOULD require that - `msg.sender == address(this)`. -* If `opData` is not empty, the implementation SHOULD use the signature - encoded in `opData` to determine if the caller can perform the execution. + -`opData` may be used to store additional data for authentication, -paymaster data, gas limits, etc. +
+
+

ERC7943CannotTransact(address account)

+
+

error

+# +
+
+
- +
-

supportsExecutionMode(bytes32 mode) → bool

+

ERC7943CannotTransfer(address from, address to, uint256 tokenId)

-

external

-# +

error

+#
-This function is provided for frontends to detect support. -Only returns true for: +
+
+ + -* `bytes32(0x01000000000000000000...)`: does not support optional `opData`. -* `bytes32(0x01000000000078210001...)`: supports optional `opData`. +
+
+

ERC7943InsufficientUnfrozenBalance(address account, uint256 tokenId)

+
+

error

+# +
+
+
- +
-## `IERC7943` +## `IERC7943MultiToken` @@ -427,17 +487,17 @@ Only returns true for:
```solidity -import "@openzeppelin/community-contracts/interfaces/IERC7943.sol"; +import "@openzeppelin/community-contracts/contracts/interfaces/IERC7943.sol"; ```

Functions

-- [forceTransfer(from, to, tokenId, amount)](#IERC7943-forceTransfer-address-address-uint256-uint256-) -- [setFrozen(user, tokenId, amount)](#IERC7943-setFrozen-address-uint256-uint256-) -- [getFrozen(user, tokenId)](#IERC7943-getFrozen-address-uint256-) -- [isTransferAllowed(from, to, tokenId, amount)](#IERC7943-isTransferAllowed-address-address-uint256-uint256-) -- [isUserAllowed(user)](#IERC7943-isUserAllowed-address-) +- [forcedTransfer(from, to, tokenId, amount)](#IERC7943MultiToken-forcedTransfer-address-address-uint256-uint256-) +- [setFrozenTokens(account, tokenId, amount)](#IERC7943MultiToken-setFrozenTokens-address-uint256-uint256-) +- [canTransact(account)](#IERC7943MultiToken-canTransact-address-) +- [getFrozenTokens(account, tokenId)](#IERC7943MultiToken-getFrozenTokens-address-uint256-) +- [canTransfer(from, to, tokenId, amount)](#IERC7943MultiToken-canTransfer-address-address-uint256-uint256-) #### IERC165 [!toc] - [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-)
@@ -446,8 +506,8 @@ import "@openzeppelin/community-contracts/interfaces/IERC7943.sol";

Events

-- [ForcedTransfer(from, to, tokenId, amount)](#IERC7943-ForcedTransfer-address-address-uint256-uint256-) -- [Frozen(user, tokenId, amount)](#IERC7943-Frozen-address-uint256-uint256-) +- [ForcedTransfer(from, to, tokenId, amount)](#IERC7943MultiToken-ForcedTransfer-address-address-uint256-uint256-) +- [Frozen(account, tokenId, amount)](#IERC7943MultiToken-Frozen-address-uint256-uint256-) #### IERC165 [!toc]
@@ -455,21 +515,21 @@ import "@openzeppelin/community-contracts/interfaces/IERC7943.sol";

Errors

-- [ERC7943NotAllowedUser(account)](#IERC7943-ERC7943NotAllowedUser-address-) -- [ERC7943NotAllowedTransfer(from, to, tokenId, amount)](#IERC7943-ERC7943NotAllowedTransfer-address-address-uint256-uint256-) -- [ERC7943InsufficientUnfrozenBalance(user, tokenId, amount, unfrozen)](#IERC7943-ERC7943InsufficientUnfrozenBalance-address-uint256-uint256-uint256-) +- [ERC7943CannotTransact(account)](#IERC7943MultiToken-ERC7943CannotTransact-address-) +- [ERC7943CannotTransfer(from, to, tokenId, amount)](#IERC7943MultiToken-ERC7943CannotTransfer-address-address-uint256-uint256-) +- [ERC7943InsufficientUnfrozenBalance(account, tokenId, amount, unfrozen)](#IERC7943MultiToken-ERC7943InsufficientUnfrozenBalance-address-uint256-uint256-uint256-) #### IERC165 [!toc]
-
+
-

forceTransfer(address from, address to, uint256 tokenId, uint256 amount)

+

forcedTransfer(address from, address to, uint256 tokenId, uint256 amount) → bool result

external

-# +#
@@ -479,80 +539,82 @@ Requires specific authorization. Used for regulatory compliance or recovery scen
- +
-

setFrozen(address user, uint256 tokenId, uint256 amount)

+

setFrozenTokens(address account, uint256 tokenId, uint256 amount) → bool result

external

-# +#
-Requires specific authorization. Frozen tokens cannot be transferred by the user. +Requires specific authorization. Frozen tokens cannot be transferred by the account.
- +
-

getFrozen(address user, uint256 tokenId) → uint256 amount

+

canTransact(address account) → bool allowed

external

-# +#
+This is often used for allowlist/KYC/KYB/AML checks. +
- +
-

isTransferAllowed(address from, address to, uint256 tokenId, uint256 amount) → bool allowed

+

getFrozenTokens(address account, uint256 tokenId) → uint256 amount

external

-# +#
-This may involve checks like allowlists, blocklists, transfer limits and other policy-defined restrictions. +It could return an amount higher than the account's balance.
- +
-

isUserAllowed(address user) → bool allowed

+

canTransfer(address from, address to, uint256 tokenId, uint256 amount) → bool allowed

external

-# +#
-This is often used for allowlist/KYC/KYB/AML checks. +This can involve checks like allowlists, blocklists, transfer limits and other policy-defined restrictions.
- +
-

ForcedTransfer(address indexed from, address indexed to, uint256 tokenId, uint256 amount)

+

ForcedTransfer(address indexed from, address indexed to, uint256 indexed tokenId, uint256 amount)

event

-# +#
@@ -560,14 +622,14 @@ This is often used for allowlist/KYC/KYB/AML checks.
- +
-

Frozen(address indexed user, uint256 indexed tokenId, uint256 amount)

+

Frozen(address indexed account, uint256 indexed tokenId, uint256 amount)

event

-# +#
@@ -576,14 +638,14 @@ This is often used for allowlist/KYC/KYB/AML checks.
- +
-

ERC7943NotAllowedUser(address account)

+

ERC7943CannotTransact(address account)

error

-# +#
@@ -591,14 +653,14 @@ This is often used for allowlist/KYC/KYB/AML checks.
- +
-

ERC7943NotAllowedTransfer(address from, address to, uint256 tokenId, uint256 amount)

+

ERC7943CannotTransfer(address from, address to, uint256 tokenId, uint256 amount)

error

-# +#
@@ -606,14 +668,14 @@ This is often used for allowlist/KYC/KYB/AML checks.
- +
-

ERC7943InsufficientUnfrozenBalance(address user, uint256 tokenId, uint256 amount, uint256 unfrozen)

+

ERC7943InsufficientUnfrozenBalance(address account, uint256 tokenId, uint256 amount, uint256 unfrozen)

error

-# +#
@@ -634,7 +696,7 @@ This is often used for allowlist/KYC/KYB/AML checks.
```solidity -import "@openzeppelin/community-contracts/interfaces/IERC7969.sol"; +import "@openzeppelin/community-contracts/contracts/interfaces/IERC7969.sol"; ``` This interface provides a standard way to register and validate DKIM public key hashes onchain @@ -711,3 +773,4 @@ Emitted when a DKIM public key hash is revoked for a domain
+ diff --git a/content/community-contracts/api/proxy.mdx b/content/community-contracts/api/proxy.mdx index 3109f979..1292c7fe 100644 --- a/content/community-contracts/api/proxy.mdx +++ b/content/community-contracts/api/proxy.mdx @@ -5,7 +5,7 @@ description: "Smart contract proxy utilities and implementations" Variants of proxy patterns, which are contracts that allow to forward a call to an implementation contract by using `delegatecall`. This contracts include: -* [`HybridProxy`](#HybridProxy): An ERC-1967 proxy that uses the implementation slot as a beacon in a way that a user can upgrade to an implementation of their choice. +- [`HybridProxy`](#HybridProxy): An ERC-1967 proxy that uses the implementation slot as a beacon in a way that a user can upgrade to an implementation of their choice. ## General @@ -24,7 +24,7 @@ Variants of proxy patterns, which are contracts that allow to forward a call to
```solidity -import "@openzeppelin/community-contracts/proxy/HybridProxy.sol"; +import "@openzeppelin/community-contracts/contracts/proxy/HybridProxy.sol"; ``` A version of an ERC-1967 proxy that uses the address stored in the implementation slot as a beacon. @@ -36,9 +36,9 @@ checks that are not compatible with this proxy design. The fallback mechanism relies on the implementation not to define the `IBeacon-implementation` function. + Consider that if your implementation has this function, it'll be assumed as the beacon address, meaning that the returned address will be used as this proxy's implementation. -

Functions

@@ -86,9 +86,10 @@ Returns the current implementation address according to ERC-1967's implementatio The way this function identifies whether the implementation is a beacon, is by checking + if it implements the `IBeacon-implementation` function. Consider that an actual implementation could define this function, mistakenly identifying it as a beacon. -
+ diff --git a/content/community-contracts/api/token.mdx b/content/community-contracts/api/token.mdx index 7ef43718..ab1b9292 100644 --- a/content/community-contracts/api/token.mdx +++ b/content/community-contracts/api/token.mdx @@ -5,12 +5,12 @@ description: "Smart contract token utilities and implementations" Set of extensions and utilities for tokens (e.g ERC-20, ERC-721, ERC-1155) and derivated ERCs (e.g. ERC-4626, ERC-1363). -* [`OnTokenTransferAdapter`](#OnTokenTransferAdapter): Adapter of the ERC-1363 receiver interface to comply with Chainlink’s 667 interface. -* [`ERC20Allowlist`](#ERC20Allowlist): Extension of ERC20 with transfers and approvals that require users to be registered into an allowlist. -* [`ERC20Blocklist`](#ERC20Blocklist): Extension of ERC20 with transfers and approvals that can be disabled by adding users into a blocklist. -* [`ERC20Collateral`](#ERC20Collateral): Oracle-agnostic extension of ERC20 that limits the total supply based on a collateral amount. -* [`ERC20Custodian`](#ERC20Custodian): Extension of ERC20 that implements an access-control agnostic approach to define a custodian that can freeze user’s transfers and approvals. -* [`ERC4626Fees`](#ERC4626Fees): ERC4626 vault with fees on entry (deposit/mint) or exit (withdraw/redeem). +- [`OnTokenTransferAdapter`](#OnTokenTransferAdapter): Adapter of the ERC-1363 receiver interface to comply with Chainlink's 667 interface. +- [`ERC20Allowlist`](#ERC20Allowlist): Extension of ERC20 with transfers and approvals that require users to be registered into an allowlist. +- [`ERC20Blocklist`](#ERC20Blocklist): Extension of ERC20 with transfers and approvals that can be disabled by adding users into a blocklist. +- [`ERC20Collateral`](#ERC20Collateral): Oracle-agnostic extension of ERC20 that limits the total supply based on a collateral amount. +- [`ERC20Custodian`](#ERC20Custodian): Extension of ERC20 that implements an access-control agnostic approach to define a custodian that can freeze user's transfers and approvals. +- [`ERC4626Fees`](#ERC4626Fees): ERC4626 vault with fees on entry (deposit/mint) or exit (withdraw/redeem). ## General @@ -41,10 +41,10 @@ Set of extensions and utilities for tokens (e.g ERC-20, ERC-721, ERC-1155) and d
```solidity -import "@openzeppelin/community-contracts/token/ERC20/extensions/ERC20Allowlist.sol"; +import "@openzeppelin/community-contracts/contracts/token/ERC20/extensions/ERC20Allowlist.sol"; ``` -Extension of [`PaymasterERC20`](./account#PaymasterERC20) that allows to implement an allowlist +Extension of `ERC20` that allows to implement an allowlist mechanism that can be managed by an authorized account with the [`ERC20Allowlist._disallowUser`](#ERC20Allowlist-_disallowUser-address-) and [`ERC20Allowlist._allowUser`](#ERC20Allowlist-_allowUser-address-) functions. @@ -62,7 +62,7 @@ Deprecated. Use [`ERC20Restricted`](#ERC20Restricted) instead.

Functions

-- [allowed(./account)](#ERC20Allowlist-allowed-address-) +- [allowed(account)](#ERC20Allowlist-allowed-address-) - [_allowUser(user)](#ERC20Allowlist-_allowUser-address-) - [_disallowUser(user)](#ERC20Allowlist-_disallowUser-address-) - [_update(from, to, value)](#ERC20Allowlist-_update-address-address-uint256-) @@ -72,14 +72,14 @@ Deprecated. Use [`ERC20Restricted`](#ERC20Restricted) instead. - [symbol()](#ERC20-symbol--) - [decimals()](#ERC20-decimals--) - [totalSupply()](#ERC20-totalSupply--) -- [balanceOf(./account)](#ERC20-balanceOf-address-) +- [balanceOf(account)](#ERC20-balanceOf-address-) - [transfer(to, value)](#ERC20-transfer-address-uint256-) - [allowance(owner, spender)](#ERC20-allowance-address-address-) - [approve(spender, value)](#ERC20-approve-address-uint256-) - [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) - [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) -- [_mint(./account, value)](#ERC20-_mint-address-uint256-) -- [_burn(./account, value)](#ERC20-_burn-address-uint256-) +- [_mint(account, value)](#ERC20-_mint-address-uint256-) +- [_burn(account, value)](#ERC20-_burn-address-uint256-) - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) #### IERC20Errors [!toc] @@ -269,10 +269,10 @@ The operation failed because the user is not allowed.
```solidity -import "@openzeppelin/community-contracts/token/ERC20/extensions/ERC20Blocklist.sol"; +import "@openzeppelin/community-contracts/contracts/token/ERC20/extensions/ERC20Blocklist.sol"; ``` -Extension of [`PaymasterERC20`](./account#PaymasterERC20) that allows to implement a blocklist +Extension of `ERC20` that allows to implement a blocklist mechanism that can be managed by an authorized account with the [`ERC20Blocklist._blockUser`](#ERC20Blocklist-_blockUser-address-) and [`ERC20Blocklist._unblockUser`](#ERC20Blocklist-_unblockUser-address-) functions. @@ -290,7 +290,7 @@ Deprecated. Use [`ERC20Restricted`](#ERC20Restricted) instead.

Functions

-- [blocked(./account)](#ERC20Blocklist-blocked-address-) +- [blocked(account)](#ERC20Blocklist-blocked-address-) - [_blockUser(user)](#ERC20Blocklist-_blockUser-address-) - [_unblockUser(user)](#ERC20Blocklist-_unblockUser-address-) - [_update(from, to, value)](#ERC20Blocklist-_update-address-address-uint256-) @@ -300,14 +300,14 @@ Deprecated. Use [`ERC20Restricted`](#ERC20Restricted) instead. - [symbol()](#ERC20-symbol--) - [decimals()](#ERC20-decimals--) - [totalSupply()](#ERC20-totalSupply--) -- [balanceOf(./account)](#ERC20-balanceOf-address-) +- [balanceOf(account)](#ERC20-balanceOf-address-) - [transfer(to, value)](#ERC20-transfer-address-uint256-) - [allowance(owner, spender)](#ERC20-allowance-address-address-) - [approve(spender, value)](#ERC20-approve-address-uint256-) - [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) - [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) -- [_mint(./account, value)](#ERC20-_mint-address-uint256-) -- [_burn(./account, value)](#ERC20-_burn-address-uint256-) +- [_mint(account, value)](#ERC20-_mint-address-uint256-) +- [_burn(account, value)](#ERC20-_burn-address-uint256-) - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) #### IERC20Errors [!toc] @@ -497,10 +497,10 @@ The operation failed because the user is blocked.
```solidity -import "@openzeppelin/community-contracts/token/ERC20/extensions/ERC20Collateral.sol"; +import "@openzeppelin/community-contracts/contracts/token/ERC20/extensions/ERC20Collateral.sol"; ``` -Extension of [`PaymasterERC20`](./account#PaymasterERC20) that limits the supply of tokens based +Extension of `ERC20` that limits the supply of tokens based on a collateral amount and time-based expiration. The [`ERC20Collateral.collateral`](#ERC20Collateral-collateral--) function must be implemented to return the collateral @@ -521,14 +521,14 @@ data. This function can call external oracles or use any local storage. - [symbol()](#ERC20-symbol--) - [decimals()](#ERC20-decimals--) - [totalSupply()](#ERC20-totalSupply--) -- [balanceOf(./account)](#ERC20-balanceOf-address-) +- [balanceOf(account)](#ERC20-balanceOf-address-) - [transfer(to, value)](#ERC20-transfer-address-uint256-) - [allowance(owner, spender)](#ERC20-allowance-address-address-) - [approve(spender, value)](#ERC20-approve-address-uint256-) - [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) - [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) -- [_mint(./account, value)](#ERC20-_mint-address-uint256-) -- [_burn(./account, value)](#ERC20-_burn-address-uint256-) +- [_mint(account, value)](#ERC20-_mint-address-uint256-) +- [_burn(account, value)](#ERC20-_burn-address-uint256-) - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) @@ -720,10 +720,10 @@ Collateral amount has expired.
```solidity -import "@openzeppelin/community-contracts/token/ERC20/extensions/ERC20Custodian.sol"; +import "@openzeppelin/community-contracts/contracts/token/ERC20/extensions/ERC20Custodian.sol"; ``` -Extension of [`PaymasterERC20`](./account#PaymasterERC20) that allows to implement a custodian +Extension of `ERC20` that allows to implement a custodian mechanism that can be managed by an authorized account with the [`ERC20Custodian.freeze`](#ERC20Custodian-freeze-address-uint256-) function. @@ -751,7 +751,7 @@ Deprecated. Use [`ERC20Freezable`](#ERC20Freezable) instead.
- [frozen(user)](#ERC20Custodian-frozen-address-) - [freeze(user, amount)](#ERC20Custodian-freeze-address-uint256-) -- [availableBalance(./account)](#ERC20Custodian-availableBalance-address-) +- [availableBalance(account)](#ERC20Custodian-availableBalance-address-) - [_isCustodian(user)](#ERC20Custodian-_isCustodian-address-) - [_update(from, to, value)](#ERC20Custodian-_update-address-address-uint256-) #### ERC20 [!toc] @@ -759,14 +759,14 @@ Deprecated. Use [`ERC20Freezable`](#ERC20Freezable) instead. - [symbol()](#ERC20-symbol--) - [decimals()](#ERC20-decimals--) - [totalSupply()](#ERC20-totalSupply--) -- [balanceOf(./account)](#ERC20-balanceOf-address-) +- [balanceOf(account)](#ERC20-balanceOf-address-) - [transfer(to, value)](#ERC20-transfer-address-uint256-) - [allowance(owner, spender)](#ERC20-allowance-address-address-) - [approve(spender, value)](#ERC20-approve-address-uint256-) - [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) - [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) -- [_mint(./account, value)](#ERC20-_mint-address-uint256-) -- [_burn(./account, value)](#ERC20-_burn-address-uint256-) +- [_mint(account, value)](#ERC20-_mint-address-uint256-) +- [_burn(account, value)](#ERC20-_burn-address-uint256-) - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) @@ -911,7 +911,7 @@ Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding this function. -Emits a [`ERC7786OpenBridge.UnsupportedNativeTransfer`](./crosschain#ERC7786OpenBridge-UnsupportedNativeTransfer--) event. +Emits a `Transfer` event.
@@ -1015,38 +1015,38 @@ Error thrown when a non-custodian account attempts to perform a custodian-only o
```solidity -import "@openzeppelin/community-contracts/token/ERC20/extensions/ERC20Freezable.sol"; +import "@openzeppelin/community-contracts/contracts/token/ERC20/extensions/ERC20Freezable.sol"; ``` -Extension of [`PaymasterERC20`](./account#PaymasterERC20) that allows to implement a freezing +Extension of `ERC20` that allows to implement a freezing mechanism that can be managed by an authorized account with the -`_freezeTokens` and `_unfreezeTokens` functions. +[`ERC20Freezable._setFrozen`](#ERC20Freezable-_setFrozen-address-uint256-) function. The freezing mechanism provides the guarantee to the contract owner (e.g. a DAO or a well-configured multisig) that a specific amount -of tokens held by an account won't be transferable until those -tokens are unfrozen using `_unfreezeTokens`. +of tokens held by an account won't be transferable until the frozen amount +is reduced using [`ERC20Freezable._setFrozen`](#ERC20Freezable-_setFrozen-address-uint256-).

Functions

-- [frozen(./account)](#ERC20Freezable-frozen-address-) -- [available(./account)](#ERC20Freezable-available-address-) -- [_setFrozen(user, amount)](#ERC20Freezable-_setFrozen-address-uint256-) +- [frozen(account)](#ERC20Freezable-frozen-address-) +- [available(account)](#ERC20Freezable-available-address-) +- [_setFrozen(account, amount)](#ERC20Freezable-_setFrozen-address-uint256-) - [_update(from, to, value)](#ERC20Freezable-_update-address-address-uint256-) #### ERC20 [!toc] - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) - [decimals()](#ERC20-decimals--) - [totalSupply()](#ERC20-totalSupply--) -- [balanceOf(./account)](#ERC20-balanceOf-address-) +- [balanceOf(account)](#ERC20-balanceOf-address-) - [transfer(to, value)](#ERC20-transfer-address-uint256-) - [allowance(owner, spender)](#ERC20-allowance-address-address-) - [approve(spender, value)](#ERC20-approve-address-uint256-) - [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) - [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) -- [_mint(./account, value)](#ERC20-_mint-address-uint256-) -- [_burn(./account, value)](#ERC20-_burn-address-uint256-) +- [_mint(account, value)](#ERC20-_mint-address-uint256-) +- [_burn(account, value)](#ERC20-_burn-address-uint256-) - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) @@ -1071,7 +1071,7 @@ tokens are unfrozen using `_unfreezeTokens`.

Errors

-- [ERC20InsufficientUnfrozenBalance(user, needed, available)](#ERC20Freezable-ERC20InsufficientUnfrozenBalance-address-uint256-uint256-) +- [ERC20InsufficientUnfrozenBalance(account, needed, available)](#ERC20Freezable-ERC20InsufficientUnfrozenBalance-address-uint256-uint256-) #### ERC20 [!toc] #### IERC20Errors [!toc] - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) @@ -1123,7 +1123,7 @@ Returns the available (unfrozen) balance of an account. Up to `balanceOf`.
-

_setFrozen(address user, uint256 amount)

+

_setFrozen(address account, uint256 amount)

internal

# @@ -1131,7 +1131,7 @@ Returns the available (unfrozen) balance of an account. Up to `balanceOf`.
-Internal function to set the frozen token amount for a user. +Internal function to set the frozen token amount for a account.
@@ -1161,7 +1161,7 @@ Requirements:
-

ERC20InsufficientUnfrozenBalance(address user, uint256 needed, uint256 available)

+

ERC20InsufficientUnfrozenBalance(address account, uint256 needed, uint256 available)

error

# @@ -1169,7 +1169,7 @@ Requirements:
-The operation failed because the user has insufficient unfrozen balance. +The operation failed because the account has insufficient unfrozen balance.
@@ -1187,40 +1187,40 @@ The operation failed because the user has insufficient unfrozen balance.
```solidity -import "@openzeppelin/community-contracts/token/ERC20/extensions/ERC20Restricted.sol"; +import "@openzeppelin/community-contracts/contracts/token/ERC20/extensions/ERC20Restricted.sol"; ``` -Extension of [`PaymasterERC20`](./account#PaymasterERC20) that allows to implement user account transfer restrictions -through the [`IERC7943.isUserAllowed`](./interfaces#IERC7943-isUserAllowed-address-) function. Inspired by [EIP-7943](https://eips.ethereum.org/EIPS/eip-7943). +Extension of `ERC20` that allows to implement user account transfer restrictions +through the [`ERC20Restricted.canTransact`](#ERC20Restricted-canTransact-address-) function. Inspired by [EIP-7943](https://eips.ethereum.org/EIPS/eip-7943). -By default, each account has no explicit restriction. The [`IERC7943.isUserAllowed`](./interfaces#IERC7943-isUserAllowed-address-) function acts as -a blocklist. Developers can override [`IERC7943.isUserAllowed`](./interfaces#IERC7943-isUserAllowed-address-) to check that `restriction == ALLOWED` +By default, each account has no explicit restriction. The [`ERC20Restricted.canTransact`](#ERC20Restricted-canTransact-address-) function acts as +a blocklist. Developers can override [`ERC20Restricted.canTransact`](#ERC20Restricted-canTransact-address-) to check that `restriction == ALLOWED` to implement an allowlist.

Functions

-- [getRestriction(./account)](#ERC20Restricted-getRestriction-address-) -- [isUserAllowed(./account)](#ERC20Restricted-isUserAllowed-address-) +- [getRestriction(account)](#ERC20Restricted-getRestriction-address-) +- [canTransact(account)](#ERC20Restricted-canTransact-address-) - [_update(from, to, value)](#ERC20Restricted-_update-address-address-uint256-) -- [_setRestriction(./account, restriction)](#ERC20Restricted-_setRestriction-address-enum-ERC20Restricted-Restriction-) -- [_blockUser(./account)](#ERC20Restricted-_blockUser-address-) -- [_allowUser(./account)](#ERC20Restricted-_allowUser-address-) -- [_resetUser(./account)](#ERC20Restricted-_resetUser-address-) -- [_checkRestriction(./account)](#ERC20Restricted-_checkRestriction-address-) +- [_setRestriction(account, restriction)](#ERC20Restricted-_setRestriction-address-enum-ERC20Restricted-Restriction-) +- [_blockUser(account)](#ERC20Restricted-_blockUser-address-) +- [_allowUser(account)](#ERC20Restricted-_allowUser-address-) +- [_resetUser(account)](#ERC20Restricted-_resetUser-address-) +- [_checkRestriction(account)](#ERC20Restricted-_checkRestriction-address-) #### ERC20 [!toc] - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) - [decimals()](#ERC20-decimals--) - [totalSupply()](#ERC20-totalSupply--) -- [balanceOf(./account)](#ERC20-balanceOf-address-) +- [balanceOf(account)](#ERC20-balanceOf-address-) - [transfer(to, value)](#ERC20-transfer-address-uint256-) - [allowance(owner, spender)](#ERC20-allowance-address-address-) - [approve(spender, value)](#ERC20-approve-address-uint256-) - [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) - [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) -- [_mint(./account, value)](#ERC20-_mint-address-uint256-) -- [_burn(./account, value)](#ERC20-_burn-address-uint256-) +- [_mint(account, value)](#ERC20-_mint-address-uint256-) +- [_burn(account, value)](#ERC20-_burn-address-uint256-) - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) @@ -1233,7 +1233,7 @@ to implement an allowlist.

Events

-- [UserRestrictionsUpdated(./account, restriction)](#ERC20Restricted-UserRestrictionsUpdated-address-enum-ERC20Restricted-Restriction-) +- [UserRestrictionsUpdated(account, restriction)](#ERC20Restricted-UserRestrictionsUpdated-address-enum-ERC20Restricted-Restriction-) #### ERC20 [!toc] #### IERC20Errors [!toc] #### IERC20Metadata [!toc] @@ -1246,7 +1246,7 @@ to implement an allowlist.

Errors

-- [ERC20UserRestricted(./account)](#ERC20Restricted-ERC20UserRestricted-address-) +- [ERC20UserRestricted(account)](#ERC20Restricted-ERC20UserRestricted-address-) #### ERC20 [!toc] #### IERC20Errors [!toc] - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) @@ -1277,14 +1277,14 @@ Returns the restriction of a user account.
- +
-

isUserAllowed(address account) → bool

+

canTransact(address account) → bool

public

-# +#
@@ -1296,8 +1296,8 @@ Default implementation only disallows explicitly BLOCKED accounts (i.e. a blockl To convert into an allowlist, override as: ```solidity -function isUserAllowed(address account) public view virtual override returns (bool) { - return getRestriction(./account) == Restriction.ALLOWED; +function canTransact(address account) public view virtual override returns (bool) { + return getRestriction(account) == Restriction.ALLOWED; } ``` @@ -1320,8 +1320,8 @@ See `ERC20-_update`. Enforces restriction transfers (excluding minting and burni Requirements: -* `from` must be allowed to transfer tokens (see [`IERC7943.isUserAllowed`](./interfaces#IERC7943-isUserAllowed-address-)). -* `to` must be allowed to receive tokens (see [`IERC7943.isUserAllowed`](./interfaces#IERC7943-isUserAllowed-address-)). +* `from` must be allowed to transfer tokens (see [`ERC20Restricted.canTransact`](#ERC20Restricted-canTransact-address-)). +* `to` must be allowed to receive tokens (see [`ERC20Restricted.canTransact`](#ERC20Restricted-canTransact-address-)).
@@ -1459,38 +1459,40 @@ The operation failed because the user account is restricted.
```solidity -import "@openzeppelin/community-contracts/token/ERC20/extensions/ERC20uRWA.sol"; +import "@openzeppelin/community-contracts/contracts/token/ERC20/extensions/ERC20uRWA.sol"; ``` -Extension of [`PaymasterERC20`](./account#PaymasterERC20) according to [EIP-7943](https://eips.ethereum.org/EIPS/eip-7943). +Extension of `ERC20` according to [EIP-7943](https://eips.ethereum.org/EIPS/eip-7943). -Combines standard ERC-20 functionality with RWA-specific features like user restrictions, -asset freezing, and forced asset transfers. +Combines standard ERC-20 functionality with RWA-specific features like account restrictions, +asset freezing, and forced asset transfers. This contract doesn't expose minting or burning +capabilities; if implemented in derived contracts as needed, they must include 7943-specific +logic.

Functions

-- [isUserAllowed(user)](#ERC20uRWA-isUserAllowed-address-) +- [canTransact(account)](#ERC20uRWA-canTransact-address-) - [supportsInterface(interfaceId)](#ERC20uRWA-supportsInterface-bytes4-) -- [isTransferAllowed(from, to, , amount)](#ERC20uRWA-isTransferAllowed-address-address-uint256-uint256-) -- [getFrozen(user, )](#ERC20uRWA-getFrozen-address-uint256-) -- [setFrozen(user, , amount)](#ERC20uRWA-setFrozen-address-uint256-uint256-) -- [forceTransfer(from, to, , amount)](#ERC20uRWA-forceTransfer-address-address-uint256-uint256-) +- [canTransfer(from, to, amount)](#ERC20uRWA-canTransfer-address-address-uint256-) +- [getFrozenTokens(account)](#ERC20uRWA-getFrozenTokens-address-) +- [setFrozenTokens(account, amount)](#ERC20uRWA-setFrozenTokens-address-uint256-) +- [forcedTransfer(from, to, amount)](#ERC20uRWA-forcedTransfer-address-address-uint256-) - [_update(from, to, amount)](#ERC20uRWA-_update-address-address-uint256-) - [_checkEnforcer(from, to, amount)](#ERC20uRWA-_checkEnforcer-address-address-uint256-) -- [_checkFreezer(user, amount)](#ERC20uRWA-_checkFreezer-address-uint256-) -#### IERC7943 [!toc] +- [_checkFreezer(account, amount)](#ERC20uRWA-_checkFreezer-address-uint256-) +#### IERC7943Fungible [!toc] #### ERC20Restricted [!toc] -- [getRestriction(./account)](#ERC20Restricted-getRestriction-address-) -- [_setRestriction(./account, restriction)](#ERC20Restricted-_setRestriction-address-enum-ERC20Restricted-Restriction-) -- [_blockUser(./account)](#ERC20Restricted-_blockUser-address-) -- [_allowUser(./account)](#ERC20Restricted-_allowUser-address-) -- [_resetUser(./account)](#ERC20Restricted-_resetUser-address-) -- [_checkRestriction(./account)](#ERC20Restricted-_checkRestriction-address-) +- [getRestriction(account)](#ERC20Restricted-getRestriction-address-) +- [_setRestriction(account, restriction)](#ERC20Restricted-_setRestriction-address-enum-ERC20Restricted-Restriction-) +- [_blockUser(account)](#ERC20Restricted-_blockUser-address-) +- [_allowUser(account)](#ERC20Restricted-_allowUser-address-) +- [_resetUser(account)](#ERC20Restricted-_resetUser-address-) +- [_checkRestriction(account)](#ERC20Restricted-_checkRestriction-address-) #### ERC20Freezable [!toc] -- [frozen(./account)](#ERC20Freezable-frozen-address-) -- [available(./account)](#ERC20Freezable-available-address-) -- [_setFrozen(user, amount)](#ERC20Freezable-_setFrozen-address-uint256-) +- [frozen(account)](#ERC20Freezable-frozen-address-) +- [available(account)](#ERC20Freezable-available-address-) +- [_setFrozen(account, amount)](#ERC20Freezable-_setFrozen-address-uint256-) #### ERC165 [!toc] #### IERC165 [!toc] #### ERC20 [!toc] @@ -1498,14 +1500,14 @@ asset freezing, and forced asset transfers. - [symbol()](#ERC20-symbol--) - [decimals()](#ERC20-decimals--) - [totalSupply()](#ERC20-totalSupply--) -- [balanceOf(./account)](#ERC20-balanceOf-address-) +- [balanceOf(account)](#ERC20-balanceOf-address-) - [transfer(to, value)](#ERC20-transfer-address-uint256-) - [allowance(owner, spender)](#ERC20-allowance-address-address-) - [approve(spender, value)](#ERC20-approve-address-uint256-) - [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) - [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) -- [_mint(./account, value)](#ERC20-_mint-address-uint256-) -- [_burn(./account, value)](#ERC20-_burn-address-uint256-) +- [_mint(account, value)](#ERC20-_mint-address-uint256-) +- [_burn(account, value)](#ERC20-_burn-address-uint256-) - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) @@ -1518,11 +1520,11 @@ asset freezing, and forced asset transfers.

Events

-#### IERC7943 [!toc] -- [ForcedTransfer(from, to, tokenId, amount)](#IERC7943-ForcedTransfer-address-address-uint256-uint256-) -- [Frozen(user, tokenId, amount)](#IERC7943-Frozen-address-uint256-uint256-) +#### IERC7943Fungible [!toc] +- [ForcedTransfer(from, to, amount)](#IERC7943Fungible-ForcedTransfer-address-address-uint256-) +- [Frozen(account, amount)](#IERC7943Fungible-Frozen-address-uint256-) #### ERC20Restricted [!toc] -- [UserRestrictionsUpdated(./account, restriction)](#ERC20Restricted-UserRestrictionsUpdated-address-enum-ERC20Restricted-Restriction-) +- [UserRestrictionsUpdated(account, restriction)](#ERC20Restricted-UserRestrictionsUpdated-address-enum-ERC20Restricted-Restriction-) #### ERC20Freezable [!toc] #### ERC165 [!toc] #### IERC165 [!toc] @@ -1538,14 +1540,14 @@ asset freezing, and forced asset transfers.

Errors

-#### IERC7943 [!toc] -- [ERC7943NotAllowedUser(./account)](#IERC7943-ERC7943NotAllowedUser-address-) -- [ERC7943NotAllowedTransfer(from, to, tokenId, amount)](#IERC7943-ERC7943NotAllowedTransfer-address-address-uint256-uint256-) -- [ERC7943InsufficientUnfrozenBalance(user, tokenId, amount, unfrozen)](#IERC7943-ERC7943InsufficientUnfrozenBalance-address-uint256-uint256-uint256-) +#### IERC7943Fungible [!toc] +- [ERC7943CannotTransact(account)](#IERC7943Fungible-ERC7943CannotTransact-address-) +- [ERC7943CannotTransfer(from, to, amount)](#IERC7943Fungible-ERC7943CannotTransfer-address-address-uint256-) +- [ERC7943InsufficientUnfrozenBalance(account, amount, unfrozen)](#IERC7943Fungible-ERC7943InsufficientUnfrozenBalance-address-uint256-uint256-) #### ERC20Restricted [!toc] -- [ERC20UserRestricted(./account)](#ERC20Restricted-ERC20UserRestricted-address-) +- [ERC20UserRestricted(account)](#ERC20Restricted-ERC20UserRestricted-address-) #### ERC20Freezable [!toc] -- [ERC20InsufficientUnfrozenBalance(user, needed, available)](#ERC20Freezable-ERC20InsufficientUnfrozenBalance-address-uint256-uint256-) +- [ERC20InsufficientUnfrozenBalance(account, needed, available)](#ERC20Freezable-ERC20InsufficientUnfrozenBalance-address-uint256-uint256-) #### ERC165 [!toc] #### IERC165 [!toc] #### ERC20 [!toc] @@ -1561,14 +1563,14 @@ asset freezing, and forced asset transfers.
- +
-

isUserAllowed(address user) → bool

+

canTransact(address account) → bool

public

-# +#
@@ -1580,8 +1582,8 @@ Default implementation only disallows explicitly BLOCKED accounts (i.e. a blockl To convert into an allowlist, override as: ```solidity -function isUserAllowed(address account) public view virtual override returns (bool) { - return getRestriction(./account) == Restriction.ALLOWED; +function canTransact(address account) public view virtual override returns (bool) { + return getRestriction(account) == Restriction.ALLOWED; } ``` @@ -1610,86 +1612,90 @@ This function call must use less than 30 000 gas.
- +
-

isTransferAllowed(address from, address to, uint256, uint256 amount) → bool

+

canTransfer(address from, address to, uint256 amount) → bool

external

-# +#
-See [`IERC7943.isTransferAllowed`](./interfaces#IERC7943-isTransferAllowed-address-address-uint256-uint256-). +See [`IERC7943Fungible.canTransfer`](/community-contracts/api/interfaces#IERC7943Fungible-canTransfer-address-address-uint256-). -CAUTION: This function is only meant for external use. Overriding it will not apply the new checks to + +This function is only meant for external use. Overriding it will not apply the new checks to + the internal [`ERC20Allowlist._update`](#ERC20Allowlist-_update-address-address-uint256-) function. Consider overriding [`ERC20Allowlist._update`](#ERC20Allowlist-_update-address-address-uint256-) accordingly to keep both functions in sync.
- +
-

getFrozen(address user, uint256) → uint256 amount

+

getFrozenTokens(address account) → uint256 amount

public

-# +#
+It could return an amount higher than the account's balance. +
- +
-

setFrozen(address user, uint256, uint256 amount)

+

setFrozenTokens(address account, uint256 amount) → bool result

public

-# +#
-See [`IERC7943.setFrozen`](./interfaces#IERC7943-setFrozen-address-uint256-uint256-). +See [`IERC7943Fungible.setFrozenTokens`](/community-contracts/api/interfaces#IERC7943Fungible-setFrozenTokens-address-uint256-). Always returns true if successful. Reverts otherwise. -The `amount` is capped to the balance of the `user` to ensure the [`IERC7943.Frozen`](./interfaces#IERC7943-Frozen-address-uint256-uint256-) event -emits values that consistently reflect the actual amount of tokens that are frozen. +The `amount` is capped to the balance of the `account` to ensure the [`IERC7943Fungible.Frozen`](/community-contracts/api/interfaces#IERC7943Fungible-Frozen-address-uint256-) event +emits values that consistently reflect the actual amount of tokens that are frozen.
- +
-

forceTransfer(address from, address to, uint256, uint256 amount)

+

forcedTransfer(address from, address to, uint256 amount) → bool result

public

-# +#
-See [`IERC7943.forceTransfer`](./interfaces#IERC7943-forceTransfer-address-address-uint256-uint256-). +See [`IERC7943Fungible.forcedTransfer`](/community-contracts/api/interfaces#IERC7943Fungible-forcedTransfer-address-address-uint256-). Always returns true if successful. Reverts otherwise. Bypasses the [`ERC20Restricted`](#ERC20Restricted) restrictions for the `from` address and adjusts the frozen balance to the new balance after the transfer. This function uses [`ERC20Allowlist._update`](#ERC20Allowlist-_update-address-address-uint256-) to perform the transfer, ensuring all standard ERC20 + side effects (such as balance updates and events) are preserved. If you override [`ERC20Allowlist._update`](#ERC20Allowlist-_update-address-address-uint256-) to add additional restrictions or logic, those changes will also apply here. Consider overriding this function to bypass newer restrictions if needed. -
@@ -1710,7 +1716,7 @@ Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding this function. -Emits a [`ERC7786OpenBridge.UnsupportedNativeTransfer`](./crosschain#ERC7786OpenBridge-UnsupportedNativeTransfer--) event. +Emits a `Transfer` event.
@@ -1742,7 +1748,7 @@ function _checkEnforcer(address from, address to, uint256 amount) internal view
-

_checkFreezer(address user, uint256 amount)

+

_checkFreezer(address account, uint256 amount)

internal

# @@ -1755,7 +1761,7 @@ Internal function to check if the `freezer` is allowed to freeze the `amount` of Example usage with `AccessControl-onlyRole`: ```solidity -function _checkFreezer(address user, uint256 amount) internal view override onlyRole(FREEZER_ROLE) {} +function _checkFreezer(address account, uint256 amount) internal view override onlyRole(FREEZER_ROLE) {} ```
@@ -1774,7 +1780,7 @@ function _checkFreezer(address user, uint256 amount) internal view override only
```solidity -import "@openzeppelin/community-contracts/token/ERC20/extensions/ERC4626Fees.sol"; +import "@openzeppelin/community-contracts/contracts/token/ERC20/extensions/ERC4626Fees.sol"; ``` ERC-4626 vault with entry/exit fees expressed in [basis point (bp)](https://en.wikipedia.org/wiki/Basis_point). @@ -1808,21 +1814,23 @@ ERC-4626 vault with entry/exit fees expressed in [basis point (bp)](https://en.w - [redeem(shares, receiver, owner)](#ERC4626-redeem-uint256-address-address-) - [_convertToShares(assets, rounding)](#ERC4626-_convertToShares-uint256-enum-Math-Rounding-) - [_convertToAssets(shares, rounding)](#ERC4626-_convertToAssets-uint256-enum-Math-Rounding-) +- [_transferIn(from, assets)](#ERC4626-_transferIn-address-uint256-) +- [_transferOut(to, assets)](#ERC4626-_transferOut-address-uint256-) - [_decimalsOffset()](#ERC4626-_decimalsOffset--) #### IERC4626 [!toc] #### ERC20 [!toc] - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) - [totalSupply()](#ERC20-totalSupply--) -- [balanceOf(./account)](#ERC20-balanceOf-address-) +- [balanceOf(account)](#ERC20-balanceOf-address-) - [transfer(to, value)](#ERC20-transfer-address-uint256-) - [allowance(owner, spender)](#ERC20-allowance-address-address-) - [approve(spender, value)](#ERC20-approve-address-uint256-) - [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) - [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) - [_update(from, to, value)](#ERC20-_update-address-address-uint256-) -- [_mint(./account, value)](#ERC20-_mint-address-uint256-) -- [_burn(./account, value)](#ERC20-_burn-address-uint256-) +- [_mint(account, value)](#ERC20-_mint-address-uint256-) +- [_burn(account, value)](#ERC20-_burn-address-uint256-) - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) @@ -2045,7 +2053,7 @@ Send exit fee to [`ERC4626Fees._exitFeeRecipient`](#ERC4626Fees-_exitFeeRecipien
```solidity -import "@openzeppelin/community-contracts/token/OnTokenTransferAdapter.sol"; +import "@openzeppelin/community-contracts/contracts/token/OnTokenTransferAdapter.sol"; ``` This contract exposes the 667 `onTokenTransfer` hook on top of `IERC1363Receiver-onTransferReceived`. @@ -2076,3 +2084,4 @@ Chainlink's Link, that implement the 667 interface for transferAndCall.
+ diff --git a/content/community-contracts/api/utils.mdx b/content/community-contracts/api/utils.mdx index 0047856d..7992481d 100644 --- a/content/community-contracts/api/utils.mdx +++ b/content/community-contracts/api/utils.mdx @@ -5,8 +5,8 @@ description: "Smart contract utils utilities and implementations" Miscellaneous contracts and libraries containing utility functions you can use to improve security, work with new data types, or safely use low-level primitives. -* [`EnumerableSetExtended`](#EnumerableSetExtended) and [`EnumerableMapExtended`](#EnumerableMapExtended): Extensions of the `EnumerableSet` and `EnumerableMap` libraries with more types, including non-value types. -* [`Masks`](#Masks): Library to handle `bytes32` masks. +- [`EnumerableSetExtended`](#EnumerableSetExtended) and [`EnumerableMapExtended`](#EnumerableMapExtended): Extensions of the `EnumerableSet` and `EnumerableMap` libraries with more types, including non-value types. +- [`Masks`](#Masks): Library to handle `bytes32` masks. ## Structs @@ -31,7 +31,7 @@ Miscellaneous contracts and libraries containing utility functions you can use t
```solidity -import "@openzeppelin/community-contracts/utils/Masks.sol"; +import "@openzeppelin/community-contracts/contracts/utils/Masks.sol"; ``` Library for handling bit masks @@ -217,7 +217,7 @@ Returns the symmetric difference (∆) of two masks, also known as disjunctive u
```solidity -import "@openzeppelin/community-contracts/utils/structs/EnumerableMapExtended.sol"; +import "@openzeppelin/community-contracts/contracts/utils/structs/EnumerableMapExtended.sol"; ``` Library for managing an enumerable variant of Solidity's @@ -246,17 +246,14 @@ The following map types are supported: - `bytes -> uint256` (`BytesToUintMap`) - `string -> string` (`StringToStringMap`) - -Trying to delete such a structure from storage will likely result in data corruption, rendering the structure +[WARNING] +#### Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable. See [ethereum/solidity#11843](https://github.com/ethereum/solidity/pull/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. - - -Extensions of openzeppelin/contracts/utils/struct/EnumerableMap.sol. - +#### NOTE: Extensions of openzeppelin/contracts/utils/struct/EnumerableMap.sol.

Functions

@@ -348,8 +345,8 @@ Removes all the entries from a map. O(n). 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 uncallable if the map grows to the point where clearing it consumes too much gas to fit in a block.
@@ -467,10 +464,10 @@ Returns an array containing all the keys 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. -
@@ -491,10 +488,10 @@ Returns an array containing a slice of the keys 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. -
@@ -555,8 +552,8 @@ Removes all the entries from a map. O(n). 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 uncallable if the map grows to the point where clearing it consumes too much gas to fit in a block.
@@ -674,10 +671,10 @@ Returns an array containing all the keys 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. -
@@ -698,10 +695,10 @@ Returns an array containing a slice of the keys 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. -
@@ -753,7 +750,7 @@ Query for a nonexistent map key.
```solidity -import "@openzeppelin/community-contracts/utils/structs/EnumerableSetExtended.sol"; +import "@openzeppelin/community-contracts/contracts/utils/structs/EnumerableSetExtended.sol"; ``` Library for managing @@ -780,17 +777,14 @@ contract Example { Sets of type `string` (`StringSet`), `bytes` (`BytesSet`) and `bytes32[2]` (`Bytes32x2Set`) are supported. - -Trying to delete such a structure from storage will likely result in data corruption, rendering the structure +[WARNING] +#### Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable. See [ethereum/solidity#11843](https://github.com/ethereum/solidity/pull/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. - - -This is an extension of openzeppelin/contracts/utils/struct/EnumerableSet.sol. - +#### NOTE: This is an extension of openzeppelin/contracts/utils/struct/EnumerableSet.sol.

Functions

@@ -862,8 +856,8 @@ Removes all the values from a set. O(n). 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 uncallable if the set grows to the point where clearing it consumes too much gas to fit in a block.
@@ -942,10 +936,10 @@ Return the entire set in an array 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. - @@ -966,10 +960,11 @@ Return a slice of the set in an array 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. - + diff --git a/content/community-contracts/api/utils/cryptography.mdx b/content/community-contracts/api/utils/cryptography.mdx index 1e46a40f..742b7569 100644 --- a/content/community-contracts/api/utils/cryptography.mdx +++ b/content/community-contracts/api/utils/cryptography.mdx @@ -5,33 +5,25 @@ description: "Smart contract cryptography utilities and implementations" A collection of contracts and libraries that implement various signature validation schemes and cryptographic primitives. These utilities enable secure authentication, multisignature operations, and advanced cryptographic operations in smart contracts. -* [`ZKEmailUtils`](#ZKEmailUtils): Library for ZKEmail signature validation utilities, enabling email-based authentication through zero-knowledge proofs. -* [`WebAuthn`](#WebAuthn): Library for verifying WebAuthn Authentication Assertions. -* [`DKIMRegistry`](#DKIMRegistry): Implementation of [ERC-7969](https://eips.ethereum.org/EIPS/eip-7969) to enable onchain verification of DomainKeys Identified Mail (DKIM) signatures. -* [`SignerZKEmail`](#SignerZKEmail): Implementation of an [AbstractSigner](https://docs.openzeppelin.com/contracts/5.x/api/utils/cryptography#AbstractSigner) that enables email-based authentication through zero-knowledge proofs. -* [`SignerWebAuthn`](#SignerWebAuthn): Implementation of [SignerP256](https://docs.openzeppelin.com/contracts/5.x/api/utils/cryptography#SignerP256) that supports WebAuthn authentication assertions. -* [`ERC7913ZKEmailVerifier`](#ERC7913ZKEmailVerifier), [`ERC7913WebAuthnVerifier`](#ERC7913WebAuthnVerifier): Ready to use ERC-7913 signature verifiers for ZKEmail and WebAuthn. +- [`ZKEmailUtils`](#ZKEmailUtils): Library for ZKEmail signature validation utilities, enabling email-based authentication through zero-knowledge proofs. +- [`DKIMRegistry`](#DKIMRegistry): Implementation of [ERC-7969](https://eips.ethereum.org/EIPS/eip-7969) to enable onchain verification of DomainKeys Identified Mail (DKIM) signatures. +- [`SignerZKEmail`](#SignerZKEmail): Implementation of an [AbstractSigner](https://docs.openzeppelin.com/contracts/5.x/api/utils/cryptography#AbstractSigner) that enables email-based authentication through zero-knowledge proofs. +- [`ERC7913ZKEmailVerifier`](#ERC7913ZKEmailVerifier): Ready to use ERC-7913 signature verifiers for ZKEmail. ## Utils [`ZKEmailUtils`](#ZKEmailUtils) -[`WebAuthn`](#WebAuthn) - [`DKIMRegistry`](#DKIMRegistry) ## Abstract Signers [`SignerZKEmail`](#SignerZKEmail) -[`SignerWebAuthn`](#SignerWebAuthn) - ## Verifiers [`ERC7913ZKEmailVerifier`](#ERC7913ZKEmailVerifier) -[`ERC7913WebAuthnVerifier`](#ERC7913WebAuthnVerifier) -
@@ -45,7 +37,7 @@ A collection of contracts and libraries that implement various signature validat
```solidity -import "@openzeppelin/community-contracts/utils/cryptography/DKIMRegistry.sol"; +import "@openzeppelin/community-contracts/contracts/utils/cryptography/DKIMRegistry.sol"; ``` Implementation of the [ERC-7969](https://eips.ethereum.org/EIPS/eip-7969) interface for registering @@ -129,12 +121,12 @@ Returns whether a DKIM key hash is valid for a given domain. Sets a DKIM key hash as valid for a domain. Internal version without access control. -Emits a [`IDKIMRegistry.KeyHashRegistered`](../interfaces#IDKIMRegistry-KeyHashRegistered-bytes32-bytes32-) event. +Emits a [`IDKIMRegistry.KeyHashRegistered`](/community-contracts/api/interfaces#IDKIMRegistry-KeyHashRegistered-bytes32-bytes32-) event. This function does not validate that keyHash is non-zero. Consider adding -validation in derived contracts if needed. +validation in derived contracts if needed. @@ -154,12 +146,12 @@ validation in derived contracts if needed. Sets multiple DKIM key hashes as valid for a domain in a single transaction. Internal version without access control. -Emits a [`IDKIMRegistry.KeyHashRegistered`](../interfaces#IDKIMRegistry-KeyHashRegistered-bytes32-bytes32-) event for each key hash. +Emits a [`IDKIMRegistry.KeyHashRegistered`](/community-contracts/api/interfaces#IDKIMRegistry-KeyHashRegistered-bytes32-bytes32-) event for each key hash. This function does not validate that the keyHashes array is non-empty. -Consider adding validation in derived contracts if needed. +Consider adding validation in derived contracts if needed. @@ -179,128 +171,7 @@ Consider adding validation in derived contracts if needed. Revokes a DKIM key hash for a domain, making it invalid. Internal version without access control. -Emits a [`IDKIMRegistry.KeyHashRevoked`](../interfaces#IDKIMRegistry-KeyHashRevoked-bytes32-) event. - - - - - - -
- -## `WebAuthn` - - - - - -
- -```solidity -import "@openzeppelin/community-contracts/utils/cryptography/WebAuthn.sol"; -``` - -Library for verifying WebAuthn Authentication Assertions. - -WebAuthn enables strong authentication for smart contracts using -[P256](https://docs.openzeppelin.com/contracts/5.x/api/utils#P256) -as an alternative to traditional secp256k1 ECDSA signatures. This library verifies -signatures generated during WebAuthn authentication ceremonies as specified in the -[WebAuthn Level 2 standard](https://www.w3.org/TR/webauthn-2/). - -For blockchain use cases, the following WebAuthn validations are intentionally omitted: - -* Origin validation: Origin verification in `clientDataJSON` is omitted as blockchain - contexts rely on authenticator and dapp frontend enforcement. Standard authenticators - implement proper origin validation. -* RP ID hash validation: Verification of `rpIdHash` in authenticatorData against expected - RP ID hash is omitted. This is typically handled by platform-level security measures. - Including an expiry timestamp in signed data is recommended for enhanced security. -* Signature counter: Verification of signature counter increments is omitted. While - useful for detecting credential cloning, on-chain operations typically include nonce - protection, making this check redundant. -* Extension outputs: Extension output value verification is omitted as these are not - essential for core authentication security in blockchain applications. -* Attestation: Attestation object verification is omitted as this implementation - focuses on authentication (`webauthn.get`) rather than registration ceremonies. - -Inspired by: - -* [daimo-eth implementation](https://github.com/daimo-eth/p256-verifier/blob/master/src/WebAuthn.sol) -* [base implementation](https://github.com/base/webauthn-sol/blob/main/src/WebAuthn.sol) - -
-

Functions

-
-- [verify(challenge, auth, qx, qy)](#WebAuthn-verify-bytes-struct-WebAuthn-WebAuthnAuth-bytes32-bytes32-) -- [verify(challenge, auth, qx, qy, requireUV)](#WebAuthn-verify-bytes-struct-WebAuthn-WebAuthnAuth-bytes32-bytes32-bool-) -- [tryDecodeAuth(input)](#WebAuthn-tryDecodeAuth-bytes-) -
-
- - - -
-
-

verify(bytes challenge, struct WebAuthn.WebAuthnAuth auth, bytes32 qx, bytes32 qy) → bool

-
-

internal

-# -
-
-
- -Performs standard verification of a WebAuthn Authentication Assertion. - -
-
- - - -
-
-

verify(bytes challenge, struct WebAuthn.WebAuthnAuth auth, bytes32 qx, bytes32 qy, bool requireUV) → bool

-
-

internal

-# -
-
-
- -Performs verification of a WebAuthn Authentication Assertion. This variants allow the caller to select -whether of not to require the UV flag (step 17). - -Verifies: - -1. Type is "webauthn.get" (see [`WebAuthn._validateExpectedTypeHash`](#WebAuthn-_validateExpectedTypeHash-string-uint256-)) -2. Challenge matches the expected value (see [`WebAuthn._validateChallenge`](#WebAuthn-_validateChallenge-string-uint256-bytes-)) -3. Cryptographic signature is valid for the given public key -4. confirming physical user presence during authentication -5. (if `requireUV` is true) confirming stronger user authentication (biometrics/PIN) -6. Backup Eligibility (`BE`) and Backup State (BS) bits relationship is valid - -
-
- - - -
-
-

tryDecodeAuth(bytes input) → bool success, struct WebAuthn.WebAuthnAuth auth

-
-

internal

-# -
-
-
- -Verifies that calldata bytes (`input`) represents a valid `WebAuthnAuth` object. If encoding is valid, -returns true and the calldata view at the object. Otherwise, returns false and an invalid calldata object. - - -The returned `auth` object should not be accessed if `success` is false. Trying to access the data may -cause revert/panic. - +Emits a [`IDKIMRegistry.KeyHashRevoked`](/community-contracts/api/interfaces#IDKIMRegistry-KeyHashRevoked-bytes32-) event.
@@ -318,7 +189,7 @@ cause revert/panic. ```solidity -import "@openzeppelin/community-contracts/utils/cryptography/ZKEmailUtils.sol"; +import "@openzeppelin/community-contracts/contracts/utils/cryptography/ZKEmailUtils.sol"; ``` Library for [ZKEmail](https://docs.zk.email) Groth16 proof validation utilities. @@ -359,7 +230,7 @@ mechanism to ensure the email was actually sent and received without revealing i
-Variant of [`ZKEmailUtils.isValidZKEmail`](#ZKEmailUtils-isValidZKEmail-struct-EmailProof-contract-IDKIMRegistry-contract-IGroth16Verifier-string---bytes---enum-ZKEmailUtils-Case-) that validates the `["signHash", "../access#AccessManagerLight-ADMIN_ROLE-uint8"]` command template. +Variant of [`ZKEmailUtils.isValidZKEmail`](#ZKEmailUtils-isValidZKEmail-struct-EmailProof-contract-IDKIMRegistry-contract-IGroth16Verifier-string---bytes---enum-ZKEmailUtils-Case-) that validates the `["signHash", "`uint`"]` command template.
@@ -404,7 +275,7 @@ Attempts to validate the command for all possible string [`ZKEmailUtils.Case`](# Variant of [`ZKEmailUtils.isValidZKEmail`](#ZKEmailUtils-isValidZKEmail-struct-EmailProof-contract-IDKIMRegistry-contract-IGroth16Verifier-string---bytes---enum-ZKEmailUtils-Case-) that validates a template with a specific string [`ZKEmailUtils.Case`](#ZKEmailUtils-Case). -Useful for templates with Ethereum address matchers (i.e. ``ethAddr``), which are case-sensitive (e.g., `["someCommand", "../access#AccessManagerLight-_groups-mapping-address----Masks-Mask-"]`). +Useful for templates with Ethereum address matchers (i.e. ``ethAddr``), which are case-sensitive (e.g., `["someCommand", "`address`"]`). @@ -426,8 +297,8 @@ returns true and the calldata view at the object. Otherwise, returns false and a The returned `emailProof` object should not be accessed if `success` is false. Trying to access the data may -cause revert/panic. +cause revert/panic. @@ -452,86 +323,6 @@ into a uint256 array in the order expected by the verifier circuit. - - -
- -## `SignerWebAuthn` - - - - - -
- -```solidity -import "@openzeppelin/community-contracts/utils/cryptography/signers/SignerWebAuthn.sol"; -``` - -Implementation of `SignerP256` that supports WebAuthn authentication assertions. - -This contract enables signature validation using WebAuthn authentication assertions, -leveraging the P256 public key stored in the contract. It allows for both WebAuthn -and raw P256 signature validation, providing compatibility with both signature types. - -The signature is expected to be an abi-encoded [`WebAuthn.WebAuthnAuth`](#WebAuthn-WebAuthnAuth) struct. - -Example usage: - -```solidity -contract MyAccountWebAuthn is Account, SignerWebAuthn, Initializable { - function initialize(bytes32 qx, bytes32 qy) public initializer { - _setSigner(qx, qy); - } -} -``` - - -Failing to call [`ERC7579Signature._setSigner`](../account#ERC7579Signature-_setSigner-address-bytes-) either during construction (if used standalone) -or during initialization (if used as a clone) may leave the signer either front-runnable or unusable. - - -
-

Functions

-
-- [_rawSignatureValidation(hash, signature)](#SignerWebAuthn-_rawSignatureValidation-bytes32-bytes-) -#### SignerP256 [!toc] -- [_setSigner(qx, qy)](#SignerP256-_setSigner-bytes32-bytes32-) -- [signer()](#SignerP256-signer--) -#### AbstractSigner [!toc] -
-
- -
-

Errors

-
-#### SignerP256 [!toc] -- [SignerP256InvalidPublicKey(qx, qy)](#SignerP256-SignerP256InvalidPublicKey-bytes32-bytes32-) -#### AbstractSigner [!toc] -
-
- - - -
-
-

_rawSignatureValidation(bytes32 hash, bytes signature) → bool

-
-

internal

-# -
-
-
- -Validates a raw signature using the WebAuthn authentication assertion. - -In case the signature can't be validated, it falls back to the -`SignerP256-_rawSignatureValidation` method for raw P256 signature validation by passing -the raw `r` and `s` values from the signature. - -
-
-
@@ -545,7 +336,7 @@ the raw `r` and `s` values from the signature.
```solidity -import "@openzeppelin/community-contracts/utils/cryptography/signers/SignerZKEmail.sol"; +import "@openzeppelin/community-contracts/contracts/utils/cryptography/signers/SignerZKEmail.sol"; ``` Implementation of `AbstractSigner` using [ZKEmail](https://docs.zk.email) signatures. @@ -582,9 +373,9 @@ contract MyAccountZKEmail is Account, SignerZKEmail, Initializable { Failing to call [`SignerZKEmail._setAccountSalt`](#SignerZKEmail-_setAccountSalt-bytes32-), [`SignerZKEmail._setDKIMRegistry`](#SignerZKEmail-_setDKIMRegistry-contract-IDKIMRegistry-), and [`SignerZKEmail._setVerifier`](#SignerZKEmail-_setVerifier-contract-IGroth16Verifier-) + either during construction (if used standalone) or during initialization (if used as a clone) may leave the signer either front-runnable or unusable. -

Functions

@@ -763,64 +554,6 @@ Proof verification error.
- - -
- -## `ERC7913WebAuthnVerifier` - - - - - -
- -```solidity -import "@openzeppelin/community-contracts/utils/cryptography/verifiers/ERC7913WebAuthnVerifier.sol"; -``` - -ERC-7913 signature verifier that supports WebAuthn authentication assertions. - -This verifier enables the validation of WebAuthn signatures using P256 public keys. -The key is expected to be a 64-byte concatenation of the P256 public key coordinates (qx || qy). -The signature is expected to be an abi-encoded [`WebAuthn.WebAuthnAuth`](#WebAuthn-WebAuthnAuth) struct. - -Uses `WebAuthn-verifyMinimal` for signature verification, which performs the essential -WebAuthn checks: type validation, challenge matching, and cryptographic signature verification. - - -Wallets that may require default P256 validation may install a P256 verifier separately. - - -
-

Functions

-
-- [verify(key, hash, signature)](#ERC7913WebAuthnVerifier-verify-bytes-bytes32-bytes-) -#### IERC7913SignatureVerifier [!toc] -
-
- - - -
-
-

verify(bytes key, bytes32 hash, bytes signature) → bytes4

-
-

public

-# -
-
-
- -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 - -
-
-
@@ -834,7 +567,7 @@ SHOULD return 0xffffffff or revert if the key is empty
```solidity -import "@openzeppelin/community-contracts/utils/cryptography/verifiers/ERC7913ZKEmailVerifier.sol"; +import "@openzeppelin/community-contracts/contracts/utils/cryptography/verifiers/ERC7913ZKEmailVerifier.sol"; ``` ERC-7913 signature verifier that supports ZKEmail accounts. @@ -893,7 +626,7 @@ The key format is ABI-encoded (IDKIMRegistry, bytes32, IGroth16Verifier) where: See [`ERC7913ZKEmailVerifier._decodeKey`](#ERC7913ZKEmailVerifier-_decodeKey-bytes-) for the key encoding format. -The signature is an ABI-encoded [`ZKEmailUtils.EmailProofError`](#ZKEmailUtils-EmailProofError) struct containing +The signature is an ABI-encoded `EmailProof` struct containing the proof details. Signature encoding: @@ -934,3 +667,4 @@ bytes memory key = abi.encode(registry, accountSalt, verifier); + diff --git a/content/contracts/5.x/api/access.mdx b/content/contracts/5.x/api/access.mdx index b2d6fc6a..949778d4 100644 --- a/content/contracts/5.x/api/access.mdx +++ b/content/contracts/5.x/api/access.mdx @@ -50,7 +50,7 @@ This directory provides ways to restrict who can access the functions of a contr ## `AccessControl` - + @@ -182,6 +182,13 @@ with an [`IAccessControl.AccessControlUnauthorizedAccount`](#IAccessControl-Acce
+Returns true if this contract implements the interface defined by +`interfaceId`. See the corresponding +[ERC section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) +to learn more about how these ids are created. + +This function call must use less than 30 000 gas. +
@@ -421,7 +428,7 @@ May emit a [`IAccessControl.RoleRevoked`](#IAccessControl-RoleRevoked-bytes32-ad ## `IAccessControl` - + @@ -679,7 +686,7 @@ Don't confuse with [`IAccessControl.AccessControlUnauthorizedAccount`](#IAccessC ## `Ownable` - + @@ -912,165 +919,13 @@ The owner is not a valid owner account. (eg. `address(0)`) - - -
- -## `Ownable2Step` - - - - - -
- -```solidity -import "@openzeppelin/contracts/access/Ownable2Step.sol"; -``` - -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`](#Ownable) contract includes a two-step mechanism to transfer -ownership, where the new owner must call [`Ownable2Step.acceptOwnership`](#Ownable2Step-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 [`Ownable.transferOwnership`](#Ownable-transferOwnership-address-) and [`Ownable2Step.acceptOwnership`](#Ownable2Step-acceptOwnership--). - -This module is used through inheritance. It will make available all functions -from parent (Ownable). - -
-

Functions

-
-- [pendingOwner()](#Ownable2Step-pendingOwner--) -- [transferOwnership(newOwner)](#Ownable2Step-transferOwnership-address-) -- [_transferOwnership(newOwner)](#Ownable2Step-_transferOwnership-address-) -- [acceptOwnership()](#Ownable2Step-acceptOwnership--) -#### Ownable [!toc] -- [owner()](#Ownable-owner--) -- [_checkOwner()](#Ownable-_checkOwner--) -- [renounceOwnership()](#Ownable-renounceOwnership--) -
-
- -
-

Events

-
-- [OwnershipTransferStarted(previousOwner, newOwner)](#Ownable2Step-OwnershipTransferStarted-address-address-) -#### Ownable [!toc] -- [OwnershipTransferred(previousOwner, newOwner)](#Ownable-OwnershipTransferred-address-address-) -
-
- -
-

Errors

-
-#### Ownable [!toc] -- [OwnableUnauthorizedAccount(account)](#Ownable-OwnableUnauthorizedAccount-address-) -- [OwnableInvalidOwner(owner)](#Ownable-OwnableInvalidOwner-address-) -
-
- - - -
-
-

pendingOwner() → address

-
-

public

-# -
-
-
- -Returns the address of the pending owner. - -
-
- - - -
-
-

transferOwnership(address newOwner)

-
-

public

-# -
-
-
- -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. - -
-
- - - -
-
-

_transferOwnership(address newOwner)

-
-

internal

-# -
-
-
- -Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner. -Internal function without access restriction. - -
-
- - - -
-
-

acceptOwnership()

-
-

public

-# -
-
-
- -The new owner accepts the ownership transfer. - -
-
- - - -
-
-

OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner)

-
-

event

-# -
-
- -
- -
-
-
## `AccessControlDefaultAdminRules` - + @@ -1503,7 +1358,7 @@ Requirements: - Only can be called by the current [`AccessControlDefaultAdminRules.defaultAdmin`](#AccessControlDefaultAdminRules-defaultAdmin--). -Emits a DefaultAdminRoleChangeStarted event. +Emits a [`IAccessControlDefaultAdminRules.DefaultAdminTransferScheduled`](#IAccessControlDefaultAdminRules-DefaultAdminTransferScheduled-address-uint48-) event.
@@ -1547,7 +1402,7 @@ Requirements: - Only can be called by the current [`AccessControlDefaultAdminRules.defaultAdmin`](#AccessControlDefaultAdminRules-defaultAdmin--). -May emit a DefaultAdminTransferCanceled event. +May emit a [`IAccessControlDefaultAdminRules.DefaultAdminTransferCanceled`](#IAccessControlDefaultAdminRules-DefaultAdminTransferCanceled--) event. @@ -1653,7 +1508,7 @@ Requirements: - Only can be called by the current [`AccessControlDefaultAdminRules.defaultAdmin`](#AccessControlDefaultAdminRules-defaultAdmin--). -Emits a DefaultAdminDelayChangeScheduled event and may emit a DefaultAdminDelayChangeCanceled event. +Emits a [`IAccessControlDefaultAdminRules.DefaultAdminDelayChangeScheduled`](#IAccessControlDefaultAdminRules-DefaultAdminDelayChangeScheduled-uint48-uint48-) event and may emit a [`IAccessControlDefaultAdminRules.DefaultAdminDelayChangeCanceled`](#IAccessControlDefaultAdminRules-DefaultAdminDelayChangeCanceled--) event. @@ -1695,7 +1550,7 @@ Requirements: - Only can be called by the current [`AccessControlDefaultAdminRules.defaultAdmin`](#AccessControlDefaultAdminRules-defaultAdmin--). -May emit a DefaultAdminDelayChangeCanceled event. +May emit a [`IAccessControlDefaultAdminRules.DefaultAdminDelayChangeCanceled`](#IAccessControlDefaultAdminRules-DefaultAdminDelayChangeCanceled--) event. @@ -1748,7 +1603,7 @@ See [`AccessControlDefaultAdminRules.defaultAdminDelayIncreaseWait`](#AccessCont ## `AccessControlEnumerable` - + @@ -1938,7 +1793,7 @@ Overload [`AccessControl._revokeRole`](#AccessControl-_revokeRole-bytes32-addres ## `IAccessControlDefaultAdminRules` - + @@ -2112,7 +1967,7 @@ Requirements: - Only can be called by the current [`AccessControlDefaultAdminRules.defaultAdmin`](#AccessControlDefaultAdminRules-defaultAdmin--). -Emits a DefaultAdminRoleChangeStarted event. +Emits a [`IAccessControlDefaultAdminRules.DefaultAdminTransferScheduled`](#IAccessControlDefaultAdminRules-DefaultAdminTransferScheduled-address-uint48-) event. @@ -2137,7 +1992,7 @@ Requirements: - Only can be called by the current [`AccessControlDefaultAdminRules.defaultAdmin`](#AccessControlDefaultAdminRules-defaultAdmin--). -May emit a DefaultAdminTransferCanceled event. +May emit a [`IAccessControlDefaultAdminRules.DefaultAdminTransferCanceled`](#IAccessControlDefaultAdminRules-DefaultAdminTransferCanceled--) event. @@ -2205,7 +2060,7 @@ Requirements: - Only can be called by the current [`AccessControlDefaultAdminRules.defaultAdmin`](#AccessControlDefaultAdminRules-defaultAdmin--). -Emits a DefaultAdminDelayChangeScheduled event and may emit a DefaultAdminDelayChangeCanceled event. +Emits a [`IAccessControlDefaultAdminRules.DefaultAdminDelayChangeScheduled`](#IAccessControlDefaultAdminRules-DefaultAdminDelayChangeScheduled-uint48-uint48-) event and may emit a [`IAccessControlDefaultAdminRules.DefaultAdminDelayChangeCanceled`](#IAccessControlDefaultAdminRules-DefaultAdminDelayChangeCanceled--) event. @@ -2228,7 +2083,7 @@ Requirements: - Only can be called by the current [`AccessControlDefaultAdminRules.defaultAdmin`](#AccessControlDefaultAdminRules-defaultAdmin--). -May emit a DefaultAdminDelayChangeCanceled event. +May emit a [`IAccessControlDefaultAdminRules.DefaultAdminDelayChangeCanceled`](#IAccessControlDefaultAdminRules-DefaultAdminDelayChangeCanceled--) event. @@ -2400,7 +2255,7 @@ the operation must wait until `schedule`. ## `IAccessControlEnumerable` - + @@ -2497,7 +2352,7 @@ together with [`AccessControlEnumerable.getRoleMember`](#AccessControlEnumerable ## `AccessManaged` - + @@ -2570,22 +2425,20 @@ functions, and ideally only used in `external` functions. See [`AccessManaged.re 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. - -In general, this modifier should only be used on `external` functions. It is okay to use it on `public` +[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. - - -Avoid adding this modifier to the [`receive()`](https://docs.soliditylang.org/en/v0.8.20/contracts.html#receive-ether-function) +#### [WARNING] +#### Avoid adding this modifier to the [`receive()`](https://docs.soliditylang.org/en/v0.8.20/contracts.html#receive-ether-function) function or the [`fallback()`](https://docs.soliditylang.org/en/v0.8.20/contracts.html#fallback-function). 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 [`AccessManaged._checkCanCall`](#AccessManaged-_checkCanCall-address-bytes-)). The `receive()` function will always panic whereas the `fallback()` may panic depending on the calldata length. - @@ -2702,7 +2555,7 @@ is less than 4 bytes long. ## `AccessManager` - + @@ -2850,6 +2703,7 @@ mindful of the danger associated with functions such as [`Ownable.renounceOwners - [AccessManagerNotReady(operationId)](#IAccessManager-AccessManagerNotReady-bytes32-) - [AccessManagerExpired(operationId)](#IAccessManager-AccessManagerExpired-bytes32-) - [AccessManagerLockedRole(roleId)](#IAccessManager-AccessManagerLockedRole-uint64-) +- [AccessManagerLockedFunction(selector)](#IAccessManager-AccessManagerLockedFunction-bytes4-) - [AccessManagerBadConfirmation()](#IAccessManager-AccessManagerBadConfirmation--) - [AccessManagerUnauthorizedAccount(msgsender, roleId)](#IAccessManager-AccessManagerUnauthorizedAccount-address-uint64-) - [AccessManagerUnauthorizedCall(caller, target, selector)](#IAccessManager-AccessManagerUnauthorizedCall-address-address-bytes4-) @@ -3147,6 +3001,7 @@ Give a label to a role, for improved role discoverability by UIs. Requirements: - the caller must be a global admin +- `roleId` must not be the `ADMIN_ROLE` or `PUBLIC_ROLE` Emits a [`IAccessManager.RoleLabel`](#IAccessManager-RoleLabel-uint64-string-) event. @@ -3253,6 +3108,7 @@ Change admin role for a given role. Requirements: - the caller must be a global admin +- `roleId` must not be the `ADMIN_ROLE` or `PUBLIC_ROLE` Emits a [`IAccessControl.RoleAdminChanged`](#IAccessControl-RoleAdminChanged-bytes32-bytes32-bytes32-) event @@ -3276,6 +3132,7 @@ Change guardian role for a given role. Requirements: - the caller must be a global admin +- `roleId` must not be the `ADMIN_ROLE` or `PUBLIC_ROLE` Emits a [`IAccessManager.RoleGuardianChanged`](#IAccessManager-RoleGuardianChanged-uint64-uint64-) event @@ -3299,6 +3156,7 @@ Update the delay for granting a `roleId`. Requirements: - the caller must be a global admin +- `roleId` must not be the `PUBLIC_ROLE` Emits a [`IAccessManager.RoleGrantDelayChanged`](#IAccessManager-RoleGrantDelayChanged-uint64-uint32-uint48-) event. @@ -3774,7 +3632,7 @@ The identifier of the public role. Automatically granted to all addresses with n ## `AuthorityUtils` - + @@ -3816,7 +3674,7 @@ This helper function takes care of invoking `canCall` in a backwards compatible ## `IAccessManaged` - + @@ -3973,7 +3831,7 @@ Authority that manages this contract was updated. ## `IAccessManager` - + @@ -4044,6 +3902,7 @@ import "@openzeppelin/contracts/access/manager/IAccessManager.sol"; - [AccessManagerNotReady(operationId)](#IAccessManager-AccessManagerNotReady-bytes32-) - [AccessManagerExpired(operationId)](#IAccessManager-AccessManagerExpired-bytes32-) - [AccessManagerLockedRole(roleId)](#IAccessManager-AccessManagerLockedRole-uint64-) +- [AccessManagerLockedFunction(selector)](#IAccessManager-AccessManagerLockedFunction-bytes4-) - [AccessManagerBadConfirmation()](#IAccessManager-AccessManagerBadConfirmation--) - [AccessManagerUnauthorizedAccount(msgsender, roleId)](#IAccessManager-AccessManagerUnauthorizedAccount-address-uint64-) - [AccessManagerUnauthorizedCall(caller, target, selector)](#IAccessManager-AccessManagerUnauthorizedCall-address-address-bytes4-) @@ -4306,6 +4165,7 @@ Give a label to a role, for improved role discoverability by UIs. Requirements: - the caller must be a global admin +- `roleId` must not be the `ADMIN_ROLE` or `PUBLIC_ROLE` Emits a [`IAccessManager.RoleLabel`](#IAccessManager-RoleLabel-uint64-string-) event. @@ -4412,6 +4272,7 @@ Change admin role for a given role. Requirements: - the caller must be a global admin +- `roleId` must not be the `ADMIN_ROLE` or `PUBLIC_ROLE` Emits a [`IAccessControl.RoleAdminChanged`](#IAccessControl-RoleAdminChanged-bytes32-bytes32-bytes32-) event @@ -4435,6 +4296,7 @@ Change guardian role for a given role. Requirements: - the caller must be a global admin +- `roleId` must not be the `ADMIN_ROLE` or `PUBLIC_ROLE` Emits a [`IAccessManager.RoleGuardianChanged`](#IAccessManager-RoleGuardianChanged-uint64-uint64-) event @@ -4458,6 +4320,7 @@ Update the delay for granting a `roleId`. Requirements: - the caller must be a global admin +- `roleId` must not be the `PUBLIC_ROLE` Emits a [`IAccessManager.RoleGrantDelayChanged`](#IAccessManager-RoleGrantDelayChanged-uint64-uint32-uint48-) event. @@ -4796,7 +4659,7 @@ Emitted when `account` is granted `roleId`. 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. +otherwise it indicates the timestamp when the execution delay update takes effect for this account and roleId. @@ -4996,6 +4859,21 @@ Admin delay for a given `target` will be updated to `delay` when `since` is reac + + +
+
+

AccessManagerLockedFunction(bytes4 selector)

+
+

error

+# +
+
+
+ +
+
+
@@ -5092,7 +4970,7 @@ Admin delay for a given `target` will be updated to `delay` when `since` is reac ## `IAuthority` - + @@ -5128,3 +5006,155 @@ Returns true if the caller can invoke on a target the function identified by a f
+ + +
+ +## `Ownable2Step` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/access/Ownable2Step.sol"; +``` + +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`](#Ownable) contract includes a two-step mechanism to transfer +ownership, where the new owner must call [`Ownable2Step.acceptOwnership`](#Ownable2Step-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 [`Ownable.transferOwnership`](#Ownable-transferOwnership-address-) and [`Ownable2Step.acceptOwnership`](#Ownable2Step-acceptOwnership--). + +This module is used through inheritance. It will make available all functions +from parent (Ownable). + +
+

Functions

+
+- [pendingOwner()](#Ownable2Step-pendingOwner--) +- [transferOwnership(newOwner)](#Ownable2Step-transferOwnership-address-) +- [_transferOwnership(newOwner)](#Ownable2Step-_transferOwnership-address-) +- [acceptOwnership()](#Ownable2Step-acceptOwnership--) +#### Ownable [!toc] +- [owner()](#Ownable-owner--) +- [_checkOwner()](#Ownable-_checkOwner--) +- [renounceOwnership()](#Ownable-renounceOwnership--) +
+
+ +
+

Events

+
+- [OwnershipTransferStarted(previousOwner, newOwner)](#Ownable2Step-OwnershipTransferStarted-address-address-) +#### Ownable [!toc] +- [OwnershipTransferred(previousOwner, newOwner)](#Ownable-OwnershipTransferred-address-address-) +
+
+ +
+

Errors

+
+#### Ownable [!toc] +- [OwnableUnauthorizedAccount(account)](#Ownable-OwnableUnauthorizedAccount-address-) +- [OwnableInvalidOwner(owner)](#Ownable-OwnableInvalidOwner-address-) +
+
+ + + +
+
+

pendingOwner() → address

+
+

public

+# +
+
+
+ +Returns the address of the pending owner. + +
+
+ + + +
+
+

transferOwnership(address newOwner)

+
+

public

+# +
+
+
+ +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. + +
+
+ + + +
+
+

_transferOwnership(address newOwner)

+
+

internal

+# +
+
+
+ +Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner. +Internal function without access restriction. + +
+
+ + + +
+
+

acceptOwnership()

+
+

public

+# +
+
+
+ +The new owner accepts the ownership transfer. + +
+
+ + + +
+
+

OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner)

+
+

event

+# +
+
+ +
+ +
+
+ diff --git a/content/contracts/5.x/api/account.mdx b/content/contracts/5.x/api/account.mdx index 8d16aab0..7fc1f8c0 100644 --- a/content/contracts/5.x/api/account.mdx +++ b/content/contracts/5.x/api/account.mdx @@ -34,9 +34,9 @@ This directory includes contracts to build accounts for ERC-4337. These include:
-## `Account` +## `Account` - + @@ -353,9 +353,9 @@ Unauthorized call to the account.
-## `AccountERC7579` +## `AccountERC7579` - + @@ -382,8 +382,8 @@ contract MyAccountERC7579 is AccountERC7579, Initializable { } ``` - -* Hook support is not included. See [`AccountERC7579Hooked`](#AccountERC7579Hooked) for a version that hooks to execution. +[NOTE] +#### * Hook support is not included. See [`AccountERC7579Hooked`](#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 [`AccountERC7579._extractUserOpValidator`](#AccountERC7579-_extractUserOpValidator-struct-PackedUserOperation-) and [`AccountERC7579._extractSignatureValidator`](#AccountERC7579-_extractSignatureValidator-bytes-). Both are implemented following common practices. However, this part is not standardized in ERC-7579 (or in any follow-up ERC). Some @@ -391,10 +391,7 @@ contract MyAccountERC7579 is AccountERC7579, Initializable { * When combined with [`ERC7739`](/contracts/5.x/api/utils/cryptography#ERC7739), resolution ordering of [`AccountERC7579.isValidSignature`](#AccountERC7579-isValidSignature-bytes32-bytes-) may have an impact ([`ERC7739`](/contracts/5.x/api/utils/cryptography#ERC7739) does not call super). Manual resolution might be necessary. * Static calls (using callType `0xfe`) are currently NOT supported. - - -Removing all validator modules will render the account inoperable, as no user operations can be validated thereafter. - +#### WARNING: Removing all validator modules will render the account inoperable, as no user operations can be validated thereafter.

Modifiers

@@ -923,7 +920,7 @@ If we had calldata here, we could use calldata slice which are cheaper to manipu 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. +clones/proxy/EIP-7702 delegates and therefore rely on initializers anyway.
@@ -984,9 +981,9 @@ The provided initData/deInitData for a fallback module is too short to extract a
-## `AccountERC7579Hooked` +## `AccountERC7579Hooked` - + @@ -999,7 +996,7 @@ import "@openzeppelin/contracts/account/extensions/draft-AccountERC7579Hooked.so Extension of [`AccountERC7579`](#AccountERC7579) with support for a single hook module (type 4). If installed, this extension will call the hook module's [`IERC7579Hook.preCheck`](/contracts/5.x/api/interfaces#IERC7579Hook-preCheck-address-uint256-bytes-) before executing any operation -with [`AccountERC7579._execute`](#AccountERC7579-_execute-Mode-bytes-) (including [`AccessManager.execute`](/contracts/5.x/api/access#AccessManager-execute-address-bytes-) and [`AccountERC7579.executeFromExecutor`](#AccountERC7579-executeFromExecutor-bytes32-bytes-) by default) and [`IERC7579Hook.postCheck`](/contracts/5.x/api/interfaces#IERC7579Hook-postCheck-bytes-) thereafter. +with [`AccountERC7579._execute`](#AccountERC7579-_execute-Mode-bytes-) (including [`AccountERC7579.execute`](#AccountERC7579-execute-bytes32-bytes-) and [`AccountERC7579.executeFromExecutor`](#AccountERC7579-executeFromExecutor-bytes32-bytes-) by default) and [`IERC7579Hook.postCheck`](/contracts/5.x/api/interfaces#IERC7579Hook-postCheck-bytes-) thereafter. Hook modules break the check-effect-interaction pattern. In particular, the [`IERC7579Hook.preCheck`](/contracts/5.x/api/interfaces#IERC7579Hook-preCheck-address-uint256-bytes-) hook can @@ -1271,9 +1268,9 @@ A hook module is already present. This contract only supports one hook module.
-## `ERC7821` +## `ERC7821` - + @@ -1363,7 +1360,7 @@ Only returns true for:
-Access control mechanism for the [`AccessManager.execute`](/contracts/5.x/api/access#AccessManager-execute-address-bytes-) function. +Access control mechanism for the [`AccountERC7579.execute`](#AccountERC7579-execute-bytes32-bytes-) function. By default, only the contract itself is allowed to execute. Override this function to implement custom access control, for example to allow the @@ -1401,9 +1398,9 @@ function _erc7821AuthorizedExecutor(
-## `EIP7702Utils` +## `EIP7702Utils` - + @@ -1415,7 +1412,7 @@ import "@openzeppelin/contracts/account/utils/EIP7702Utils.sol"; Library with common EIP-7702 utility functions. -See [ERC-7702](https://eips.ethereum.org/EIPS/eip-7702). +See [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702).

Functions

@@ -1445,9 +1442,9 @@ Returns the address of the delegate if `account` has an EIP-7702 delegation setu
-## `IEntryPointExtra` +## `IEntryPointExtra` - + @@ -1485,9 +1482,9 @@ This is available on all entrypoint since v0.4.0, but is not formally part of th
-## `ERC4337Utils` +## `ERC4337Utils` - + @@ -1506,7 +1503,9 @@ See [ERC-4337](https://eips.ethereum.org/EIPS/eip-4337).
- [parseValidationData(validationData)](#ERC4337Utils-parseValidationData-uint256-) - [packValidationData(aggregator, validAfter, validUntil)](#ERC4337Utils-packValidationData-address-uint48-uint48-) +- [packValidationData(aggregator, validAfter, validUntil, range)](#ERC4337Utils-packValidationData-address-uint48-uint48-enum-ERC4337Utils-ValidationRange-) - [packValidationData(sigSuccess, validAfter, validUntil)](#ERC4337Utils-packValidationData-bool-uint48-uint48-) +- [packValidationData(sigSuccess, validAfter, validUntil, range)](#ERC4337Utils-packValidationData-bool-uint48-uint48-enum-ERC4337Utils-ValidationRange-) - [combineValidationData(validationData1, validationData2)](#ERC4337Utils-combineValidationData-uint256-uint256-) - [getValidationData(validationData)](#ERC4337Utils-getValidationData-uint256-) - [hash(self, entrypoint)](#ERC4337Utils-hash-struct-PackedUserOperation-address-) @@ -1521,6 +1520,7 @@ See [ERC-4337](https://eips.ethereum.org/EIPS/eip-4337). - [paymasterVerificationGasLimit(self)](#ERC4337Utils-paymasterVerificationGasLimit-struct-PackedUserOperation-) - [paymasterPostOpGasLimit(self)](#ERC4337Utils-paymasterPostOpGasLimit-struct-PackedUserOperation-) - [paymasterData(self)](#ERC4337Utils-paymasterData-struct-PackedUserOperation-) +- [paymasterSignature(self)](#ERC4337Utils-paymasterSignature-struct-PackedUserOperation-)
@@ -1528,7 +1528,7 @@ See [ERC-4337](https://eips.ethereum.org/EIPS/eip-4337).
-

parseValidationData(uint256 validationData) → address aggregator, uint48 validAfter, uint48 validUntil

+

parseValidationData(uint256 validationData) → address aggregator, uint48 validAfter, uint48 validUntil, enum ERC4337Utils.ValidationRange range

internal

# @@ -1536,7 +1536,8 @@ See [ERC-4337](https://eips.ethereum.org/EIPS/eip-4337).
-Parses the validation data into its components. See [`ERC4337Utils.packValidationData`](#ERC4337Utils-packValidationData-bool-uint48-uint48-). +Parses the validation data into its components and the validity range. See [`ERC4337Utils.packValidationData`](#ERC4337Utils-packValidationData-bool-uint48-uint48-enum-ERC4337Utils-ValidationRange-). +Strips away the highest bit flag from the `validAfter` and `validUntil` fields.
@@ -1558,6 +1559,24 @@ Packs the validation data into a single uint256. See [`ERC4337Utils.parseValidat
+ + +
+
+

packValidationData(address aggregator, uint48 validAfter, uint48 validUntil, enum ERC4337Utils.ValidationRange range) → uint256

+
+

internal

+# +
+
+
+ +Variant of [`ERC4337Utils.packValidationData`](#ERC4337Utils-packValidationData-bool-uint48-uint48-enum-ERC4337Utils-ValidationRange-) that forces which validity range to use. This overwrites the presence of +flags in `validAfter` and `validUntil`). + +
+
+
@@ -1570,7 +1589,25 @@ Packs the validation data into a single uint256. See [`ERC4337Utils.parseValidat
-Same as [`ERC4337Utils.packValidationData`](#ERC4337Utils-packValidationData-bool-uint48-uint48-), but with a boolean signature success flag. +Variant of [`ERC4337Utils.packValidationData`](#ERC4337Utils-packValidationData-bool-uint48-uint48-enum-ERC4337Utils-ValidationRange-) that uses a boolean success flag instead of an aggregator address. + +
+
+ + + +
+
+

packValidationData(bool sigSuccess, uint48 validAfter, uint48 validUntil, enum ERC4337Utils.ValidationRange range) → uint256

+
+

internal

+# +
+
+
+ +Variant of [`ERC4337Utils.packValidationData`](#ERC4337Utils-packValidationData-bool-uint48-uint48-enum-ERC4337Utils-ValidationRange-) that uses a boolean success flag instead of an aggregator address and that +forces which validity range to use. This overwrites the presence of flags in `validAfter` and `validUntil`).
@@ -1592,6 +1629,10 @@ Combines two validation data into a single one. The `aggregator` is set to [`ERC4337Utils.SIG_VALIDATION_SUCCESS`](#ERC4337Utils-SIG_VALIDATION_SUCCESS-uint256) if both are successful, while the `validAfter` is the maximum and the `validUntil` is the minimum of both. + +Returns `SIG_VALIDATION_FAILED` if the validation ranges differ. + +
@@ -1812,6 +1853,25 @@ Returns the third section of `paymasterAndData` from the [`PackedUserOperation`]
Returns the fourth section of `paymasterAndData` from the [`PackedUserOperation`](/contracts/5.x/api/interfaces#PackedUserOperation). +If a paymaster signature is present, it is excluded from the returned data. + +
+
+ + + +
+
+

paymasterSignature(struct PackedUserOperation self) → bytes

+
+

internal

+# +
+
+
+ +Returns the paymaster signature from `paymasterAndData` (EntryPoint v0.9+). +Returns empty bytes if no paymaster signature is present.
@@ -1820,9 +1880,9 @@ Returns the fourth section of `paymasterAndData` from the [`PackedUserOperation`
-## `Mode` +## `Mode` - + @@ -1836,9 +1896,9 @@ import "@openzeppelin/contracts/account/utils/draft-ERC7579Utils.sol";
-## `CallType` +## `CallType` - + @@ -1852,9 +1912,9 @@ import "@openzeppelin/contracts/account/utils/draft-ERC7579Utils.sol";
-## `ExecType` +## `ExecType` - + @@ -1868,9 +1928,9 @@ import "@openzeppelin/contracts/account/utils/draft-ERC7579Utils.sol";
-## `ModeSelector` +## `ModeSelector` - + @@ -1884,9 +1944,9 @@ import "@openzeppelin/contracts/account/utils/draft-ERC7579Utils.sol";
-## `ModePayload` +## `ModePayload` - + @@ -1900,9 +1960,9 @@ import "@openzeppelin/contracts/account/utils/draft-ERC7579Utils.sol";
-## `ERC7579Utils` +## `ERC7579Utils` - + @@ -2285,9 +2345,9 @@ Input calldata not properly formatted and possibly malicious.
-## `eqCallType` +## `eqCallType` - + @@ -2320,9 +2380,9 @@ Compares two `CallType` values for equality.
-## `eqExecType` +## `eqExecType` - + @@ -2355,9 +2415,9 @@ Compares two `ExecType` values for equality.
-## `eqModeSelector` +## `eqModeSelector` - + @@ -2390,9 +2450,9 @@ Compares two `ModeSelector` values for equality.
-## `eqModePayload` +## `eqModePayload` - + @@ -2420,3 +2480,4 @@ Compares two `ModePayload` values for equality.
+ diff --git a/content/contracts/5.x/api/crosschain.mdx b/content/contracts/5.x/api/crosschain.mdx index 864666f4..5c4998e7 100644 --- a/content/contracts/5.x/api/crosschain.mdx +++ b/content/contracts/5.x/api/crosschain.mdx @@ -5,48 +5,280 @@ description: "Smart contract crosschain utilities and implementations" This directory contains contracts for sending and receiving cross chain messages that follows the ERC-7786 standard. -* [`ERC7786Recipient`](#ERC7786Recipient): generic ERC-7786 crosschain contract that receives messages from a trusted gateway +* [`CrosschainLinked`](#CrosschainLinked): helper to facilitate communication between a contract on one chain and counterparts on remote chains through ERC-7786 gateways. +* [`CrosschainRemoteExecutor`](#CrosschainRemoteExecutor): executor contract that relays transaction from a controller on a remote chain. +* [`ERC7786Recipient`](#ERC7786Recipient): generic ERC-7786 crosschain contract that receives messages from a trusted gateway. + +Additionally there are multiple bridge constructions: + +* [`BridgeFungible`](#BridgeFungible): Core bridging logic for crosschain ERC-20 transfer. Used by [`BridgeERC20`](#BridgeERC20), [`BridgeERC7802`](#BridgeERC7802) and [`ERC20Crosschain`](/contracts/5.x/api/token/ERC20#ERC20Crosschain), +* [`BridgeNonFungible`](#BridgeNonFungible): Core bridging logic for crosschain ERC-721 transfer. Used by [`BridgeERC721`](#BridgeERC721) and [`ERC721Crosschain`](/contracts/5.x/api/token/ERC721#ERC721Crosschain), +* [`BridgeMultiToken`](#BridgeMultiToken): Core bridging logic for crosschain ERC-1155 transfer. Used by [`BridgeERC1155`](#BridgeERC1155) and [`ERC1155Crosschain`](/contracts/5.x/api/token/ERC1155#ERC1155Crosschain), +* [`BridgeERC20`](#BridgeERC20): Standalone bridge contract to connect an ERC-20 token contract with counterparts on remote chains, +* [`BridgeERC721`](#BridgeERC721): Standalone bridge contract to connect an ERC-721 token contract with counterparts on remote chains, +* [`BridgeERC1155`](#BridgeERC1155): Standalone bridge contract to connect an ERC-1155 token contract with counterparts on remote chains, +* [`BridgeERC7802`](#BridgeERC7802): Standalone bridge contract to connect an ERC-7802 token contract with counterparts on remote chains. ## Helpers +[`CrosschainLinked`](#CrosschainLinked) + +[`CrosschainRemoteExecutor`](#CrosschainRemoteExecutor) + [`ERC7786Recipient`](#ERC7786Recipient) - +## Bridges + +[`BridgeFungible`](#BridgeFungible) + +[`BridgeNonFungible`](#BridgeNonFungible) + +[`BridgeMultiToken`](#BridgeMultiToken) + +[`BridgeERC20`](#BridgeERC20) + +[`BridgeERC721`](#BridgeERC721) + +[`BridgeERC1155`](#BridgeERC1155) + +[`BridgeERC7802`](#BridgeERC7802) + +
-## `ERC7786Recipient` +## `CrosschainLinked` - +
```solidity -import "@openzeppelin/contracts/crosschain/ERC7786Recipient.sol"; +import "@openzeppelin/contracts/crosschain/CrosschainLinked.sol"; ``` -Base implementation of an ERC-7786 compliant cross-chain message receiver. +Core bridging mechanism. -This abstract contract exposes the `receiveMessage` function that is used for communication with (one or multiple) -destination gateways. This contract leaves two functions unimplemented: +This contract contains the logic to register and send messages to counterparts on remote chains using ERC-7786 +gateways. It ensure received messages originate from a counterpart. This is the base of token bridges such as +[`BridgeFungible`](#BridgeFungible). -* [`ERC7786Recipient._isAuthorizedGateway`](#ERC7786Recipient-_isAuthorizedGateway-address-bytes-), an internal getter used to verify whether an address is recognised by the contract as a -valid ERC-7786 destination gateway. One or multiple gateway can be supported. Note that any malicious address for -which this function returns true would be able to impersonate any account on any other chain sending any message. +Contracts that inherit from this contract can use the internal [`CrosschainLinked._sendMessageToCounterpart`](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) to send messages to their +counterpart on a foreign chain. They must override the [`CrosschainRemoteExecutor._processMessage`](#CrosschainRemoteExecutor-_processMessage-address-bytes32-bytes-bytes-) function to handle messages that have +been verified. + +
+

Functions

+
+- [constructor(links)](#CrosschainLinked-constructor-struct-CrosschainLinked-Link---) +- [getLink(chain)](#CrosschainLinked-getLink-bytes-) +- [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) +- [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) +- [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) +#### ERC7786Recipient [!toc] +- [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) +- [_processMessage(gateway, receiveId, sender, payload)](#ERC7786Recipient-_processMessage-address-bytes32-bytes-bytes-) +#### IERC7786Recipient [!toc] +
+
+ +
+

Events

+
+- [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) +#### ERC7786Recipient [!toc] +#### IERC7786Recipient [!toc] +
+
+ +
+

Errors

+
+- [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) +#### ERC7786Recipient [!toc] +- [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) +#### IERC7786Recipient [!toc] +
+
+ + + +
+
+

constructor(struct CrosschainLinked.Link[] links)

+
+

internal

+# +
+
+
+ +
+
+ + + +
+
+

getLink(bytes chain) → address gateway, bytes counterpart

+
+

public

+# +
+
+
+ +Returns the ERC-7786 gateway used for sending and receiving cross-chain messages to a given chain. + +Note: The `chain` parameter is a "chain-only" InteroperableAddress (empty address) and the `counterpart` returns +the full InteroperableAddress (chain ref + address) that is on `chain`. + +
+
+ + + +
+
+

_setLink(address gateway, bytes counterpart, bool allowOverride)

+
+

internal

+# +
+
+
+ +Internal setter to change the ERC-7786 gateway and counterpart for a given chain. Called at construction. + +Note: The `counterpart` parameter is the full InteroperableAddress (chain ref + address). + +
+
+ + + +
+
+

_sendMessageToCounterpart(bytes chain, bytes payload, bytes[] attributes) → bytes32

+
+

internal

+# +
+
+
+ +Internal messaging function + +Note: The `chain` parameter is a "chain-only" InteroperableAddress (empty address). + +
+
+ + + +
+
+

_isAuthorizedGateway(address instance, bytes sender) → bool

+
+

internal

+# +
+
+
+ +Virtual getter that returns whether an address is a valid ERC-7786 gateway for a given sender. + +The `sender` parameter is an interoperable address that include the source chain. The chain part can be +extracted using the [`InteroperableAddress`](/contracts/5.x/api/utils#InteroperableAddress) library to selectively authorize gateways based on the origin chain +of a message. + +
+
+ + + +
+
+

LinkRegistered(address gateway, bytes counterpart)

+
+

event

+# +
+
+ +
+ +Emitted when a new link is registered. + +Note: the `counterpart` argument is a full InteroperableAddress (chain ref + address). + +
+
+ + -* [`ERC7786Recipient._processMessage`](#ERC7786Recipient-_processMessage-address-bytes32-bytes-bytes-), the internal function that will be called with any message that has been validated. +
+
+

LinkAlreadyRegistered(bytes chain)

+
+

error

+# +
+
+
+ +Reverted when trying to register a link for a chain that is already registered. + +Note: the `chain` argument is a "chain-only" InteroperableAddress (empty address). + +
+
+ + + +
+ +## `CrosschainRemoteExecutor` -This contract implements replay protection, meaning that if two messages are received from the same gateway with the -same `receiveId`, then the second one will NOT be executed, regardless of the result of [`ERC7786Recipient._isAuthorizedGateway`](#ERC7786Recipient-_isAuthorizedGateway-address-bytes-). + + + + +
+ +```solidity +import "@openzeppelin/contracts/crosschain/CrosschainRemoteExecutor.sol"; +``` + +Helper contract used to relay transactions received from a controller through an ERC-7786 gateway. This is +used by the [`GovernorCrosschain`](/contracts/5.x/api/governance#GovernorCrosschain) governance module for the execution of cross-chain actions. + +A [`CrosschainRemoteExecutor`](#CrosschainRemoteExecutor) address can be seen as the local identity of a remote executor on another chain. It +holds assets and permissions for the sake of its controller.

Functions

+- [constructor(initialGateway, initialController)](#CrosschainRemoteExecutor-constructor-address-bytes-) +- [gateway()](#CrosschainRemoteExecutor-gateway--) +- [controller()](#CrosschainRemoteExecutor-controller--) +- [reconfigure(newGateway, newController)](#CrosschainRemoteExecutor-reconfigure-address-bytes-) +- [_setup(gateway_, controller_)](#CrosschainRemoteExecutor-_setup-address-bytes-) +- [_isAuthorizedGateway(instance, sender)](#CrosschainRemoteExecutor-_isAuthorizedGateway-address-bytes-) +- [_processMessage(, , , payload)](#CrosschainRemoteExecutor-_processMessage-address-bytes32-bytes-bytes-) +#### ERC7786Recipient [!toc] - [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) -- [_isAuthorizedGateway(gateway, sender)](#ERC7786Recipient-_isAuthorizedGateway-address-bytes-) -- [_processMessage(gateway, receiveId, sender, payload)](#ERC7786Recipient-_processMessage-address-bytes32-bytes-bytes-) +#### IERC7786Recipient [!toc] +
+
+ +
+

Events

+
+- [CrosschainControllerSet(gateway, controller)](#CrosschainRemoteExecutor-CrosschainControllerSet-address-bytes-) +#### ERC7786Recipient [!toc] #### IERC7786Recipient [!toc]
@@ -54,39 +286,106 @@ same `receiveId`, then the second one will NOT be executed, regardless of the re

Errors

+- [AccessRestricted()](#CrosschainRemoteExecutor-AccessRestricted--) +#### ERC7786Recipient [!toc] - [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) -- [ERC7786RecipientMessageAlreadyProcessed(gateway, receiveId)](#ERC7786Recipient-ERC7786RecipientMessageAlreadyProcessed-address-bytes32-) #### IERC7786Recipient [!toc]
- +
-

receiveMessage(bytes32 receiveId, bytes sender, bytes payload) → bytes4

+

constructor(address initialGateway, bytes initialController)

-

external

-# +

public

+#
-Endpoint for receiving cross-chain message. +
+
-This function may be called directly by the gateway. + +
+
+

gateway() → address

+
+

public

+#
+
- +Accessor that returns the address of the gateway used by this remote executor. + +
+
+ +
-

_isAuthorizedGateway(address gateway, bytes sender) → bool

+

controller() → bytes

+
+

public

+# +
+
+
+ +Accessor that returns the interoperable address of the controller allowed to relay instructions to this +remote executor. + +
+
+ + + +
+
+

reconfigure(address newGateway, bytes newController)

+
+

public

+# +
+
+
+ +Endpoint allowing the controller to reconfigure the executor. This must be called by the executor itself +following an instruction from the controller. + +
+
+ + + +
+
+

_setup(address gateway_, bytes controller_)

internal

-# +# +
+
+
+ +Internal setter to reconfigure the gateway and controller. + +
+
+ + + +
+
+

_isAuthorizedGateway(address instance, bytes sender) → bool

+
+

internal

+#
@@ -100,49 +399,1558 @@ of a message.
- +
-

_processMessage(address gateway, bytes32 receiveId, bytes sender, bytes payload)

+

_processMessage(address, bytes32, bytes, bytes payload)

internal

-# +#
Virtual function that should contain the logic to execute when a cross-chain message is received. + +This function should revert on failure. Any silent failure from this function will result in the message +being marked as received and not being retryable. + +
- +
-

ERC7786RecipientUnauthorizedGateway(address gateway, bytes sender)

+

CrosschainControllerSet(address gateway, bytes controller)

-

error

-# +

event

+#
+
+Emitted when the gateway or controller of this remote executor is updated. +
- +
-

ERC7786RecipientMessageAlreadyProcessed(address gateway, bytes32 receiveId)

+

AccessRestricted()

error

-# +#
+Reverted when a non-controller tries to relay instructions to this executor. + +
+ + + +
+ +## `ERC7786Recipient` + + + + +
+ +```solidity +import "@openzeppelin/contracts/crosschain/ERC7786Recipient.sol"; +``` + +Base implementation of an ERC-7786 compliant cross-chain message receiver. + +This abstract contract exposes the `receiveMessage` function that is used for communication with (one or multiple) +destination gateways. This contract leaves two functions unimplemented: + +* [`CrosschainLinked._isAuthorizedGateway`](#CrosschainLinked-_isAuthorizedGateway-address-bytes-), an internal getter used to verify whether an address is recognised by the contract as a +valid ERC-7786 destination gateway. One or multiple gateway can be supported. Note that any malicious address for +which this function returns true would be able to impersonate any account on any other chain sending any message. + +* [`CrosschainRemoteExecutor._processMessage`](#CrosschainRemoteExecutor-_processMessage-address-bytes32-bytes-bytes-), the internal function that will be called with any message that has been validated. + +ERC-7786 requires the gateway to ensure messages are not delivered more than once. Therefore, we don't need to keep +track of the processed receiveId. + +@custom:stateless + +
+

Functions

+
+- [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) +- [_isAuthorizedGateway(gateway, sender)](#ERC7786Recipient-_isAuthorizedGateway-address-bytes-) +- [_processMessage(gateway, receiveId, sender, payload)](#ERC7786Recipient-_processMessage-address-bytes32-bytes-bytes-) +#### IERC7786Recipient [!toc] +
+
+ +
+

Errors

+
+- [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) +#### IERC7786Recipient [!toc] +
+
+ + + +
+
+

receiveMessage(bytes32 receiveId, bytes sender, bytes payload) → bytes4

+
+

external

+# +
+
+
+ +Endpoint for receiving cross-chain message. + +This function may be called directly by the gateway. + +
+
+ + + +
+
+

_isAuthorizedGateway(address gateway, bytes sender) → bool

+
+

internal

+# +
+
+
+ +Virtual getter that returns whether an address is a valid ERC-7786 gateway for a given sender. + +The `sender` parameter is an interoperable address that include the source chain. The chain part can be +extracted using the [`InteroperableAddress`](/contracts/5.x/api/utils#InteroperableAddress) library to selectively authorize gateways based on the origin chain +of a message. + +
+
+ + + +
+
+

_processMessage(address gateway, bytes32 receiveId, bytes sender, bytes payload)

+
+

internal

+# +
+
+
+ +Virtual function that should contain the logic to execute when a cross-chain message is received. + + +This function should revert on failure. Any silent failure from this function will result in the message +being marked as received and not being retryable. + + +
+
+ + + +
+
+

ERC7786RecipientUnauthorizedGateway(address gateway, bytes sender)

+
+

error

+# +
+
+
+ +Error thrown if the gateway is not authorized to send messages to this contract on behalf of the sender. + +
+
+ + + +
+ +## `BridgeERC1155` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/crosschain/bridges/BridgeERC1155.sol"; +``` + +This is a variant of [`BridgeMultiToken`](#BridgeMultiToken) that implements the bridge logic for ERC-1155 tokens that do not expose +a crosschain mint and burn mechanism. Instead, it takes custody of bridged assets. + +
+

Functions

+
+- [constructor(token_)](#BridgeERC1155-constructor-contract-IERC1155-) +- [token()](#BridgeERC1155-token--) +- [crosschainTransferFrom(from, to, id, value)](#BridgeERC1155-crosschainTransferFrom-address-bytes-uint256-uint256-) +- [crosschainTransferFrom(from, to, ids, values)](#BridgeERC1155-crosschainTransferFrom-address-bytes-uint256---uint256---) +- [_onSend(from, ids, values)](#BridgeERC1155-_onSend-address-uint256---uint256---) +- [_onReceive(to, ids, values)](#BridgeERC1155-_onReceive-address-uint256---uint256---) +- [onERC1155Received(operator, , , , )](#BridgeERC1155-onERC1155Received-address-address-uint256-uint256-bytes-) +- [onERC1155BatchReceived(operator, , , , )](#BridgeERC1155-onERC1155BatchReceived-address-address-uint256---uint256---bytes-) +#### ERC1155Holder [!toc] +- [supportsInterface(interfaceId)](#ERC1155Holder-supportsInterface-bytes4-) +#### IERC1155Receiver [!toc] +#### ERC165 [!toc] +#### IERC165 [!toc] +#### BridgeMultiToken [!toc] +- [_crosschainTransfer(from, to, ids, values)](#BridgeMultiToken-_crosschainTransfer-address-bytes-uint256---uint256---) +- [_processMessage(, receiveId, , payload)](#BridgeMultiToken-_processMessage-address-bytes32-bytes-bytes-) +#### CrosschainLinked [!toc] +- [getLink(chain)](#CrosschainLinked-getLink-bytes-) +- [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) +- [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) +- [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) +#### ERC7786Recipient [!toc] +- [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) +#### IERC7786Recipient [!toc] +
+
+ +
+

Events

+
+#### ERC1155Holder [!toc] +#### IERC1155Receiver [!toc] +#### ERC165 [!toc] +#### IERC165 [!toc] +#### BridgeMultiToken [!toc] +- [CrosschainMultiTokenTransferSent(sendId, from, to, ids, values)](#BridgeMultiToken-CrosschainMultiTokenTransferSent-bytes32-address-bytes-uint256---uint256---) +- [CrosschainMultiTokenTransferReceived(receiveId, from, to, ids, values)](#BridgeMultiToken-CrosschainMultiTokenTransferReceived-bytes32-bytes-address-uint256---uint256---) +#### CrosschainLinked [!toc] +- [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) +#### ERC7786Recipient [!toc] +#### IERC7786Recipient [!toc] +
+
+ +
+

Errors

+
+#### ERC1155Holder [!toc] +#### IERC1155Receiver [!toc] +#### ERC165 [!toc] +#### IERC165 [!toc] +#### BridgeMultiToken [!toc] +#### CrosschainLinked [!toc] +- [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) +#### ERC7786Recipient [!toc] +- [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) +#### IERC7786Recipient [!toc] +
+
+ + + +
+
+

constructor(contract IERC1155 token_)

+
+

internal

+# +
+
+
+ +
+
+ + + +
+
+

token() → contract IERC1155

+
+

public

+# +
+
+
+ +
+
+ + + +
+
+

crosschainTransferFrom(address from, bytes to, uint256 id, uint256 value) → bytes32

+
+

public

+# +
+
+
+ +Transfer `amount` tokens to a crosschain receiver. + +Note: The `to` parameter is the full InteroperableAddress (chain ref + address). + +
+
+ + + +
+
+

crosschainTransferFrom(address from, bytes to, uint256[] ids, uint256[] values) → bytes32

+
+

public

+# +
+
+
+ +Transfer `amount` tokens to a crosschain receiver. + +Note: The `to` parameter is the full InteroperableAddress (chain ref + address). + +
+
+ + + +
+
+

_onSend(address from, uint256[] ids, uint256[] values)

+
+

internal

+# +
+
+
+ +"Locking" tokens is done by taking custody + +
+
+ + + +
+
+

_onReceive(address to, uint256[] ids, uint256[] values)

+
+

internal

+# +
+
+
+ +"Unlocking" tokens is done by releasing custody + +
+
+ + + +
+
+

onERC1155Received(address operator, address, uint256, uint256, bytes) → bytes4

+
+

public

+# +
+
+
+ +Support receiving tokens only if the transfer was initiated by the bridge itself. + +
+
+ + + +
+
+

onERC1155BatchReceived(address operator, address, uint256[], uint256[], bytes) → bytes4

+
+

public

+# +
+
+
+ +Support receiving tokens only if the transfer was initiated by the bridge itself. + +
+
+ + + +
+ +## `BridgeERC20` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/crosschain/bridges/BridgeERC20.sol"; +``` + +This is a variant of [`BridgeFungible`](#BridgeFungible) that implements the bridge logic for ERC-20 tokens that do not expose a +crosschain mint and burn mechanism. Instead, it takes custody of bridged assets. + +
+

Functions

+
+- [constructor(token_)](#BridgeERC20-constructor-contract-IERC20-) +- [token()](#BridgeERC20-token--) +- [_onSend(from, amount)](#BridgeERC20-_onSend-address-uint256-) +- [_onReceive(to, amount)](#BridgeERC20-_onReceive-address-uint256-) +#### BridgeFungible [!toc] +- [crosschainTransfer(to, amount)](#BridgeFungible-crosschainTransfer-bytes-uint256-) +- [_crosschainTransfer(from, to, amount)](#BridgeFungible-_crosschainTransfer-address-bytes-uint256-) +- [_processMessage(, receiveId, , payload)](#BridgeFungible-_processMessage-address-bytes32-bytes-bytes-) +#### CrosschainLinked [!toc] +- [getLink(chain)](#CrosschainLinked-getLink-bytes-) +- [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) +- [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) +- [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) +#### ERC7786Recipient [!toc] +- [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) +#### IERC7786Recipient [!toc] +
+
+ +
+

Events

+
+#### BridgeFungible [!toc] +- [CrosschainFungibleTransferSent(sendId, from, to, amount)](#BridgeFungible-CrosschainFungibleTransferSent-bytes32-address-bytes-uint256-) +- [CrosschainFungibleTransferReceived(receiveId, from, to, amount)](#BridgeFungible-CrosschainFungibleTransferReceived-bytes32-bytes-address-uint256-) +#### CrosschainLinked [!toc] +- [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) +#### ERC7786Recipient [!toc] +#### IERC7786Recipient [!toc] +
+
+ +
+

Errors

+
+#### BridgeFungible [!toc] +#### CrosschainLinked [!toc] +- [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) +#### ERC7786Recipient [!toc] +- [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) +#### IERC7786Recipient [!toc] +
+
+ + + +
+
+

constructor(contract IERC20 token_)

+
+

internal

+# +
+
+
+ +
+
+ + + +
+
+

token() → contract IERC20

+
+

public

+# +
+
+
+ +
+
+ + + +
+
+

_onSend(address from, uint256 amount)

+
+

internal

+# +
+
+
+ +"Locking" tokens is done by taking custody + +
+
+ + + +
+
+

_onReceive(address to, uint256 amount)

+
+

internal

+# +
+
+
+ +"Unlocking" tokens is done by releasing custody + +
+
+ + + +
+ +## `BridgeERC721` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/crosschain/bridges/BridgeERC721.sol"; +``` + +This is a variant of [`BridgeNonFungible`](#BridgeNonFungible) that implements the bridge logic for ERC-721 tokens that do not expose +a crosschain mint and burn mechanism. Instead, it takes custody of bridged assets. + +
+

Functions

+
+- [constructor(token_)](#BridgeERC721-constructor-contract-IERC721-) +- [token()](#BridgeERC721-token--) +- [crosschainTransferFrom(from, to, tokenId)](#BridgeERC721-crosschainTransferFrom-address-bytes-uint256-) +- [_onSend(from, tokenId)](#BridgeERC721-_onSend-address-uint256-) +- [_onReceive(to, tokenId)](#BridgeERC721-_onReceive-address-uint256-) +#### BridgeNonFungible [!toc] +- [_crosschainTransfer(from, to, tokenId)](#BridgeNonFungible-_crosschainTransfer-address-bytes-uint256-) +- [_processMessage(, receiveId, , payload)](#BridgeNonFungible-_processMessage-address-bytes32-bytes-bytes-) +#### CrosschainLinked [!toc] +- [getLink(chain)](#CrosschainLinked-getLink-bytes-) +- [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) +- [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) +- [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) +#### ERC7786Recipient [!toc] +- [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) +#### IERC7786Recipient [!toc] +
+
+ +
+

Events

+
+#### BridgeNonFungible [!toc] +- [CrosschainNonFungibleTransferSent(sendId, from, to, tokenId)](#BridgeNonFungible-CrosschainNonFungibleTransferSent-bytes32-address-bytes-uint256-) +- [CrosschainNonFungibleTransferReceived(receiveId, from, to, tokenId)](#BridgeNonFungible-CrosschainNonFungibleTransferReceived-bytes32-bytes-address-uint256-) +#### CrosschainLinked [!toc] +- [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) +#### ERC7786Recipient [!toc] +#### IERC7786Recipient [!toc] +
+
+ +
+

Errors

+
+#### BridgeNonFungible [!toc] +#### CrosschainLinked [!toc] +- [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) +#### ERC7786Recipient [!toc] +- [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) +#### IERC7786Recipient [!toc] +
+
+ + + +
+
+

constructor(contract IERC721 token_)

+
+

internal

+# +
+
+
+ +
+
+ + + +
+
+

token() → contract IERC721

+
+

public

+# +
+
+
+ +
+
+ + + +
+
+

crosschainTransferFrom(address from, bytes to, uint256 tokenId) → bytes32

+
+

public

+# +
+
+
+ +Transfer `tokenId` from `from` (on this chain) to `to` (on a different chain). + +The `to` parameter is the full InteroperableAddress that references both the destination chain and the account +on that chain. Similarly to the underlying token's [`ERC721.transferFrom`](/contracts/5.x/api/token/ERC721#ERC721-transferFrom-address-address-uint256-) function, this function can be called +either by the token holder or by anyone that is approved by the token holder. It reuses the token's allowance +system, meaning that an account that is "approved for all" or "approved for tokenId" can perform the crosschain +transfer directly without having to take temporary custody of the token. + +
+
+ + + +
+
+

_onSend(address from, uint256 tokenId)

+
+

internal

+# +
+
+
+ +"Locking" tokens is done by taking custody + +
+
+ + + +
+
+

_onReceive(address to, uint256 tokenId)

+
+

internal

+# +
+
+
+ +"Unlocking" tokens is done by releasing custody + +
+
+ + + +
+ +## `BridgeERC7802` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/crosschain/bridges/BridgeERC7802.sol"; +``` + +This is a variant of [`BridgeFungible`](#BridgeFungible) that implements the bridge logic for ERC-7802 compliant tokens. + +
+

Functions

+
+- [constructor(token_)](#BridgeERC7802-constructor-contract-IERC7802-) +- [token()](#BridgeERC7802-token--) +- [_onSend(from, amount)](#BridgeERC7802-_onSend-address-uint256-) +- [_onReceive(to, amount)](#BridgeERC7802-_onReceive-address-uint256-) +#### BridgeFungible [!toc] +- [crosschainTransfer(to, amount)](#BridgeFungible-crosschainTransfer-bytes-uint256-) +- [_crosschainTransfer(from, to, amount)](#BridgeFungible-_crosschainTransfer-address-bytes-uint256-) +- [_processMessage(, receiveId, , payload)](#BridgeFungible-_processMessage-address-bytes32-bytes-bytes-) +#### CrosschainLinked [!toc] +- [getLink(chain)](#CrosschainLinked-getLink-bytes-) +- [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) +- [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) +- [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) +#### ERC7786Recipient [!toc] +- [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) +#### IERC7786Recipient [!toc] +
+
+ +
+

Events

+
+#### BridgeFungible [!toc] +- [CrosschainFungibleTransferSent(sendId, from, to, amount)](#BridgeFungible-CrosschainFungibleTransferSent-bytes32-address-bytes-uint256-) +- [CrosschainFungibleTransferReceived(receiveId, from, to, amount)](#BridgeFungible-CrosschainFungibleTransferReceived-bytes32-bytes-address-uint256-) +#### CrosschainLinked [!toc] +- [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) +#### ERC7786Recipient [!toc] +#### IERC7786Recipient [!toc] +
+
+ +
+

Errors

+
+#### BridgeFungible [!toc] +#### CrosschainLinked [!toc] +- [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) +#### ERC7786Recipient [!toc] +- [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) +#### IERC7786Recipient [!toc] +
+
+ + + +
+
+

constructor(contract IERC7802 token_)

+
+

internal

+# +
+
+
+ +
+
+ + + +
+
+

token() → contract IERC7802

+
+

public

+# +
+
+
+ +
+
+ + + +
+
+

_onSend(address from, uint256 amount)

+
+

internal

+# +
+
+
+ +"Locking" tokens using an ERC-7802 crosschain burn + +
+
+ + + +
+
+

_onReceive(address to, uint256 amount)

+
+

internal

+# +
+
+
+ +"Unlocking" tokens using an ERC-7802 crosschain mint + +
+
+ + + +
+ +## `BridgeFungible` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/crosschain/bridges/abstract/BridgeFungible.sol"; +``` + +Base contract for bridging ERC-20 between chains using an ERC-7786 gateway. + +In order to use this contract, two functions must be implemented to link it to the token: +* [`BridgeERC1155._onSend`](#BridgeERC1155-_onSend-address-uint256---uint256---): called when a crosschain transfer is going out. Must take the sender tokens or revert. +* [`BridgeERC1155._onReceive`](#BridgeERC1155-_onReceive-address-uint256---uint256---): called when a crosschain transfer is coming in. Must give tokens to the receiver. + +This base contract is used by the [`BridgeERC20`](#BridgeERC20), which interfaces with legacy ERC-20 tokens, and [`BridgeERC7802`](#BridgeERC7802), +which interface with ERC-7802 to provide an approve-free user experience. It is also used by the [`ERC20Crosschain`](/contracts/5.x/api/token/ERC20#ERC20Crosschain) +extension, which embeds the bridge logic directly in the token contract. + +
+

Functions

+
+- [crosschainTransfer(to, amount)](#BridgeFungible-crosschainTransfer-bytes-uint256-) +- [_crosschainTransfer(from, to, amount)](#BridgeFungible-_crosschainTransfer-address-bytes-uint256-) +- [_processMessage(, receiveId, , payload)](#BridgeFungible-_processMessage-address-bytes32-bytes-bytes-) +- [_onSend(from, amount)](#BridgeFungible-_onSend-address-uint256-) +- [_onReceive(to, amount)](#BridgeFungible-_onReceive-address-uint256-) +#### CrosschainLinked [!toc] +- [getLink(chain)](#CrosschainLinked-getLink-bytes-) +- [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) +- [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) +- [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) +#### ERC7786Recipient [!toc] +- [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) +#### IERC7786Recipient [!toc] +
+
+ +
+

Events

+
+- [CrosschainFungibleTransferSent(sendId, from, to, amount)](#BridgeFungible-CrosschainFungibleTransferSent-bytes32-address-bytes-uint256-) +- [CrosschainFungibleTransferReceived(receiveId, from, to, amount)](#BridgeFungible-CrosschainFungibleTransferReceived-bytes32-bytes-address-uint256-) +#### CrosschainLinked [!toc] +- [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) +#### ERC7786Recipient [!toc] +#### IERC7786Recipient [!toc] +
+
+ +
+

Errors

+
+#### CrosschainLinked [!toc] +- [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) +#### ERC7786Recipient [!toc] +- [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) +#### IERC7786Recipient [!toc] +
+
+ + + +
+
+

crosschainTransfer(bytes to, uint256 amount) → bytes32

+
+

public

+# +
+
+
+ +Transfer `amount` tokens to a crosschain receiver. + +Note: The `to` parameter is the full InteroperableAddress (chain ref + address). + +
+
+ + + +
+
+

_crosschainTransfer(address from, bytes to, uint256 amount) → bytes32

+
+

internal

+# +
+
+
+ +Internal crosschain transfer function. + +Note: The `to` parameter is the full InteroperableAddress (chain ref + address). + +
+
+ + + +
+
+

_processMessage(address, bytes32 receiveId, bytes, bytes payload)

+
+

internal

+# +
+
+
+ +Virtual function that should contain the logic to execute when a cross-chain message is received. + + +This function should revert on failure. Any silent failure from this function will result in the message +being marked as received and not being retryable. + + +
+
+ + + +
+
+

_onSend(address from, uint256 amount)

+
+

internal

+# +
+
+
+ +Virtual function: implementation is required to handle token being burnt or locked on the source chain. + +
+
+ + + +
+
+

_onReceive(address to, uint256 amount)

+
+

internal

+# +
+
+
+ +Virtual function: implementation is required to handle token being minted or unlocked on the destination chain. + +
+
+ + + +
+
+

CrosschainFungibleTransferSent(bytes32 indexed sendId, address indexed from, bytes to, uint256 amount)

+
+

event

+# +
+
+ +
+ +Emitted when a crosschain ERC-20 transfer is sent. + +
+
+ + +
+
+

CrosschainFungibleTransferReceived(bytes32 indexed receiveId, bytes from, address indexed to, uint256 amount)

+
+

event

+# +
+
+ +
+ +Emitted when a crosschain ERC-20 transfer is received. + +
+
+ + + +
+ +## `BridgeMultiToken` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/crosschain/bridges/abstract/BridgeMultiToken.sol"; +``` + +Base contract for bridging ERC-1155 between chains using an ERC-7786 gateway. + +In order to use this contract, two functions must be implemented to link it to the token: +* [`BridgeERC1155._onSend`](#BridgeERC1155-_onSend-address-uint256---uint256---): called when a crosschain transfer is going out. Must take the sender tokens or revert. +* [`BridgeERC1155._onReceive`](#BridgeERC1155-_onReceive-address-uint256---uint256---): called when a crosschain transfer is coming in. Must give tokens to the receiver. + +This base contract is used by the [`BridgeERC1155`](#BridgeERC1155), which interfaces with legacy ERC-1155 tokens. It is also used by +the [`ERC1155Crosschain`](/contracts/5.x/api/token/ERC1155#ERC1155Crosschain) extension, which embeds the bridge logic directly in the token contract. + +This base contract implements the crosschain transfer operation though internal functions. It is for the the "child +contracts" that inherit from this to implement the external interfaces and make this functions accessible. + +
+

Functions

+
+- [_crosschainTransfer(from, to, ids, values)](#BridgeMultiToken-_crosschainTransfer-address-bytes-uint256---uint256---) +- [_processMessage(, receiveId, , payload)](#BridgeMultiToken-_processMessage-address-bytes32-bytes-bytes-) +- [_onSend(from, ids, values)](#BridgeMultiToken-_onSend-address-uint256---uint256---) +- [_onReceive(to, ids, values)](#BridgeMultiToken-_onReceive-address-uint256---uint256---) +#### CrosschainLinked [!toc] +- [getLink(chain)](#CrosschainLinked-getLink-bytes-) +- [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) +- [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) +- [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) +#### ERC7786Recipient [!toc] +- [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) +#### IERC7786Recipient [!toc] +
+
+ +
+

Events

+
+- [CrosschainMultiTokenTransferSent(sendId, from, to, ids, values)](#BridgeMultiToken-CrosschainMultiTokenTransferSent-bytes32-address-bytes-uint256---uint256---) +- [CrosschainMultiTokenTransferReceived(receiveId, from, to, ids, values)](#BridgeMultiToken-CrosschainMultiTokenTransferReceived-bytes32-bytes-address-uint256---uint256---) +#### CrosschainLinked [!toc] +- [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) +#### ERC7786Recipient [!toc] +#### IERC7786Recipient [!toc] +
+
+ +
+

Errors

+
+#### CrosschainLinked [!toc] +- [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) +#### ERC7786Recipient [!toc] +- [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) +#### IERC7786Recipient [!toc] +
+
+ + + +
+
+

_crosschainTransfer(address from, bytes to, uint256[] ids, uint256[] values) → bytes32

+
+

internal

+# +
+
+
+ +Internal crosschain transfer function. + +Note: The `to` parameter is the full InteroperableAddress (chain ref + address). + +
+
+ + + +
+
+

_processMessage(address, bytes32 receiveId, bytes, bytes payload)

+
+

internal

+# +
+
+
+ +Virtual function that should contain the logic to execute when a cross-chain message is received. + + +This function should revert on failure. Any silent failure from this function will result in the message +being marked as received and not being retryable. + + +
+
+ + + +
+
+

_onSend(address from, uint256[] ids, uint256[] values)

+
+

internal

+# +
+
+
+ +Virtual function: implementation is required to handle token being burnt or locked on the source chain. + +
+
+ + + +
+
+

_onReceive(address to, uint256[] ids, uint256[] values)

+
+

internal

+# +
+
+
+ +Virtual function: implementation is required to handle token being minted or unlocked on the destination chain. + +
+
+ + + +
+
+

CrosschainMultiTokenTransferSent(bytes32 indexed sendId, address indexed from, bytes to, uint256[] ids, uint256[] values)

+
+

event

+# +
+
+ +
+ +
+
+ + +
+
+

CrosschainMultiTokenTransferReceived(bytes32 indexed receiveId, bytes from, address indexed to, uint256[] ids, uint256[] values)

+
+

event

+# +
+
+ +
+ +
+
+ + + +
+ +## `BridgeNonFungible` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/crosschain/bridges/abstract/BridgeNonFungible.sol"; +``` + +Base contract for bridging ERC-721 between chains using an ERC-7786 gateway. + +In order to use this contract, two functions must be implemented to link it to the token: +* [`BridgeERC1155._onSend`](#BridgeERC1155-_onSend-address-uint256---uint256---): called when a crosschain transfer is going out. Must take the sender tokens or revert. +* [`BridgeERC1155._onReceive`](#BridgeERC1155-_onReceive-address-uint256---uint256---): called when a crosschain transfer is coming in. Must give tokens to the receiver. + +This base contract is used by the [`BridgeERC721`](#BridgeERC721), which interfaces with legacy ERC-721 tokens. It is also used by +the [`ERC721Crosschain`](/contracts/5.x/api/token/ERC721#ERC721Crosschain) extension, which embeds the bridge logic directly in the token contract. + +
+

Functions

+
+- [_crosschainTransfer(from, to, tokenId)](#BridgeNonFungible-_crosschainTransfer-address-bytes-uint256-) +- [_processMessage(, receiveId, , payload)](#BridgeNonFungible-_processMessage-address-bytes32-bytes-bytes-) +- [_onSend(from, tokenId)](#BridgeNonFungible-_onSend-address-uint256-) +- [_onReceive(to, tokenId)](#BridgeNonFungible-_onReceive-address-uint256-) +#### CrosschainLinked [!toc] +- [getLink(chain)](#CrosschainLinked-getLink-bytes-) +- [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) +- [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) +- [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) +#### ERC7786Recipient [!toc] +- [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) +#### IERC7786Recipient [!toc] +
+
+ +
+

Events

+
+- [CrosschainNonFungibleTransferSent(sendId, from, to, tokenId)](#BridgeNonFungible-CrosschainNonFungibleTransferSent-bytes32-address-bytes-uint256-) +- [CrosschainNonFungibleTransferReceived(receiveId, from, to, tokenId)](#BridgeNonFungible-CrosschainNonFungibleTransferReceived-bytes32-bytes-address-uint256-) +#### CrosschainLinked [!toc] +- [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) +#### ERC7786Recipient [!toc] +#### IERC7786Recipient [!toc] +
+
+ +
+

Errors

+
+#### CrosschainLinked [!toc] +- [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) +#### ERC7786Recipient [!toc] +- [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) +#### IERC7786Recipient [!toc] +
+
+ + + +
+
+

_crosschainTransfer(address from, bytes to, uint256 tokenId) → bytes32

+
+

internal

+# +
+
+
+ +Internal crosschain transfer function. + + +The `to` parameter is the full InteroperableAddress (chain ref + address). + + +
+
+ + + +
+
+

_processMessage(address, bytes32 receiveId, bytes, bytes payload)

+
+

internal

+# +
+
+
+ +Virtual function that should contain the logic to execute when a cross-chain message is received. + + +This function should revert on failure. Any silent failure from this function will result in the message +being marked as received and not being retryable. + + +
+
+ + + +
+
+

_onSend(address from, uint256 tokenId)

+
+

internal

+# +
+
+
+ +Virtual function: implementation is required to handle token being burnt or locked on the source chain. + +
+
+ + + +
+
+

_onReceive(address to, uint256 tokenId)

+
+

internal

+# +
+
+
+ +Virtual function: implementation is required to handle token being minted or unlocked on the destination chain. + +
+
+ + + +
+
+

CrosschainNonFungibleTransferSent(bytes32 indexed sendId, address indexed from, bytes to, uint256 tokenId)

+
+

event

+# +
+
+ +
+ +Emitted when a crosschain ERC-721 transfer is sent. + +
+
+ + +
+
+

CrosschainNonFungibleTransferReceived(bytes32 indexed receiveId, bytes from, address indexed to, uint256 tokenId)

+
+

event

+# +
+
+ +
+ +Emitted when a crosschain ERC-721 transfer is received. + +
+
+ + + +
+ +## `BridgeERC20Core` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/crosschain/bridges/BridgeERC20Core.sol"; +``` + +Base contract for bridging ERC-20 between chains using an ERC-7786 gateway. + +In order to use this contract, two functions must be implemented to link it to the token: +* [`BridgeERC1155._onSend`](#BridgeERC1155-_onSend-address-uint256---uint256---): called when a crosschain transfer is going out. Must take the sender tokens or revert. +* [`BridgeERC1155._onReceive`](#BridgeERC1155-_onReceive-address-uint256---uint256---): called when a crosschain transfer is coming in. Must give tokens to the receiver. + +This base contract is used by the [`BridgeERC20`](#BridgeERC20), which interfaces with legacy ERC-20 tokens, and [`BridgeERC7802`](#BridgeERC7802), +which interface with ERC-7802 to provide an approve-free user experience. It is also used by the [`ERC20Crosschain`](/contracts/5.x/api/token/ERC20#ERC20Crosschain) +extension, which embeds the bridge logic directly in the token contract. + +
+

Functions

+
+- [crosschainTransfer(to, amount)](#BridgeERC20Core-crosschainTransfer-bytes-uint256-) +- [_crosschainTransfer(from, to, amount)](#BridgeERC20Core-_crosschainTransfer-address-bytes-uint256-) +- [_processMessage(, receiveId, , payload)](#BridgeERC20Core-_processMessage-address-bytes32-bytes-bytes-) +- [_onSend(from, amount)](#BridgeERC20Core-_onSend-address-uint256-) +- [_onReceive(to, amount)](#BridgeERC20Core-_onReceive-address-uint256-) +#### CrosschainLinked [!toc] +- [getLink(chain)](#CrosschainLinked-getLink-bytes-) +- [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) +- [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) +- [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) +#### ERC7786Recipient [!toc] +- [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) +#### IERC7786Recipient [!toc] +
+
+ +
+

Events

+
+- [CrosschainERC20TransferSent(sendId, from, to, amount)](#BridgeERC20Core-CrosschainERC20TransferSent-bytes32-address-bytes-uint256-) +- [CrosschainERC20TransferReceived(receiveId, from, to, amount)](#BridgeERC20Core-CrosschainERC20TransferReceived-bytes32-bytes-address-uint256-) +#### CrosschainLinked [!toc] +- [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) +#### ERC7786Recipient [!toc] +#### IERC7786Recipient [!toc] +
+
+ +
+

Errors

+
+#### CrosschainLinked [!toc] +- [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) +#### ERC7786Recipient [!toc] +- [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) +- [ERC7786RecipientMessageAlreadyProcessed(gateway, receiveId)](#ERC7786Recipient-ERC7786RecipientMessageAlreadyProcessed-address-bytes32-) +#### IERC7786Recipient [!toc] +
+
+ + + +
+
+

crosschainTransfer(bytes to, uint256 amount) → bytes32

+
+

public

+# +
+
+
+ +Transfer `amount` tokens to a crosschain receiver. + +Note: The `to` parameter is the full InteroperableAddress (chain ref + address). + +
+
+ + + +
+
+

_crosschainTransfer(address from, bytes to, uint256 amount) → bytes32

+
+

internal

+# +
+
+
+ +Internal crosschain transfer function. + +Note: The `to` parameter is the full InteroperableAddress (chain ref + address). + +
+
+ + + +
+
+

_processMessage(address, bytes32 receiveId, bytes, bytes payload)

+
+

internal

+# +
+
+
+ +Virtual function that should contain the logic to execute when a cross-chain message is received. + +
+
+ + + +
+
+

_onSend(address from, uint256 amount)

+
+

internal

+# +
+
+
+ +Virtual function: implementation is required to handle token being burnt or locked on the source chain. + +
+
+ + + +
+
+

_onReceive(address to, uint256 amount)

+
+

internal

+# +
+
+
+ +Virtual function: implementation is required to handle token being minted or unlocked on the destination chain. + +
+
+ + + +
+
+

CrosschainERC20TransferSent(bytes32 indexed sendId, address indexed from, bytes to, uint256 amount)

+
+

event

+# +
+
+ +
+ +
+
+ + +
+
+

CrosschainERC20TransferReceived(bytes32 indexed receiveId, bytes from, address indexed to, uint256 amount)

+
+

event

+# +
+
+ +
+ +
+
+ diff --git a/content/contracts/5.x/api/finance.mdx b/content/contracts/5.x/api/finance.mdx index 3dea4798..2415528e 100644 --- a/content/contracts/5.x/api/finance.mdx +++ b/content/contracts/5.x/api/finance.mdx @@ -17,9 +17,9 @@ This directory includes primitives for financial systems:
-## `VestingWallet` +## `VestingWallet` - + @@ -383,9 +383,9 @@ an asset given its total historical allocation.
-## `VestingWalletCliff` +## `VestingWalletCliff` - + @@ -524,3 +524,4 @@ The specified cliff duration is larger than the vesting duration.
+ diff --git a/content/contracts/5.x/api/governance.mdx b/content/contracts/5.x/api/governance.mdx index d177b40a..16af3c51 100644 --- a/content/contracts/5.x/api/governance.mdx +++ b/content/contracts/5.x/api/governance.mdx @@ -37,12 +37,13 @@ Timelock extensions add a delay for governance decisions to be executed. The wor Other extensions can customize the behavior or interface in multiple ways. -* [`GovernorStorage`](#GovernorStorage): Stores the proposal details onchain and provides enumerability of the proposals. This can be useful for some L2 chains where storage is cheap compared to calldata. -* [`GovernorSettings`](#GovernorSettings): Manages some of the settings (voting delay, voting period duration, and proposal threshold) in a way that can be updated through a governance proposal, without requiring an upgrade. +* [`GovernorCrosschain`](#GovernorCrosschain): Helps with the execution of crosschain operation using `CrosschainRemoteExector` and ERC-7786 gateways. +* [`GovernorNoncesKeyed`](#GovernorNoncesKeyed): An extension of [`Governor`](#Governor) with support for keyed nonces in addition to traditional nonces when voting by signature. * [`GovernorPreventLateQuorum`](#GovernorPreventLateQuorum): Ensures there is a minimum voting period after quorum is reached as a security protection against large voters. * [`GovernorProposalGuardian`](#GovernorProposalGuardian): Adds a proposal guardian that can cancel proposals at any stage in their lifecycle--this permission is passed on to the proposers if the guardian is not set. +* [`GovernorSettings`](#GovernorSettings): Manages some of the settings (voting delay, voting period duration, and proposal threshold) in a way that can be updated through a governance proposal, without requiring an upgrade. +* [`GovernorStorage`](#GovernorStorage): Stores the proposal details onchain and provides enumerability of the proposals. This can be useful for some L2 chains where storage is cheap compared to calldata. * [`GovernorSuperQuorum`](#GovernorSuperQuorum): Extension of [`Governor`](#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. -* [`GovernorNoncesKeyed`](#GovernorNoncesKeyed): An extension of [`Governor`](#Governor) with support for keyed nonces in addition to traditional nonces when voting by signature. In addition to modules and extensions, the core contract requires a few virtual functions to be implemented to your particular specifications: @@ -82,17 +83,19 @@ Functions of the `Governor` contract do not include access control. If you want [`GovernorTimelockCompound`](#GovernorTimelockCompound) -[`GovernorSettings`](#GovernorSettings) +[`GovernorCrosschain`](#GovernorCrosschain) -[`GovernorPreventLateQuorum`](#GovernorPreventLateQuorum) +[`GovernorNoncesKeyed`](#GovernorNoncesKeyed) -[`GovernorStorage`](#GovernorStorage) +[`GovernorPreventLateQuorum`](#GovernorPreventLateQuorum) [`GovernorProposalGuardian`](#GovernorProposalGuardian) -[`GovernorSuperQuorum`](#GovernorSuperQuorum) +[`GovernorSettings`](#GovernorSettings) -[`GovernorNoncesKeyed`](#GovernorNoncesKeyed) +[`GovernorStorage`](#GovernorStorage) + +[`GovernorSuperQuorum`](#GovernorSuperQuorum) ## Utils @@ -123,7 +126,7 @@ In a governance system, the [`TimelockController`](#TimelockController) contract #### Operation structure -Operation executed by the [`TimelockController`](contracts/5.x/api/governance#TimelockController) can contain one or multiple subsequent calls. Depending on whether you need to multiple calls to be executed atomically, you can either use simple or batched operations. +Operation executed by the [`TimelockController`](/contracts/5.x/api/governance#TimelockController) can contain one or multiple subsequent calls. Depending on whether you need multiple calls to be executed atomically, you can either use simple or batched operations. Both operations contain: @@ -146,16 +149,16 @@ Timelocked operations are identified by a unique id (their hash) and follow a sp `Unset` -> `Pending` -> `Pending` + `Ready` -> `Done` -* By calling [`schedule`](contracts/5.x/api/governance#TimelockController-schedule-address-uint256-bytes-bytes32-bytes32-uint256-) (or [`scheduleBatch`](contracts/5.x/api/governance#TimelockController-scheduleBatch-address---uint256---bytes---bytes32-bytes32-uint256-)), a proposer moves the operation from the `Unset` to the `Pending` state. This starts a timer that must be longer than the minimum delay. The timer expires at a timestamp accessible through the [`getTimestamp`](contracts/5.x/api/governance#TimelockController-getTimestamp-bytes32-) method. +* By calling [`schedule`](/contracts/5.x/api/governance#TimelockController-schedule-address-uint256-bytes-bytes32-bytes32-uint256-) (or [`scheduleBatch`](/contracts/5.x/api/governance#TimelockController-scheduleBatch-address---uint256---bytes---bytes32-bytes32-uint256-)), a proposer moves the operation from the `Unset` to the `Pending` state. This starts a timer that must be longer than the minimum delay. The timer expires at a timestamp accessible through the [`getTimestamp`](/contracts/5.x/api/governance#TimelockController-getTimestamp-bytes32-) method. * Once the timer expires, the operation automatically gets the `Ready` state. At this point, it can be executed. -* By calling [`execute`](contracts/5.x/api/governance#TimelockController-TimelockController-execute-address-uint256-bytes-bytes32-bytes32-) (or [`executeBatch`](contracts/5.x/api/governance#TimelockController-executeBatch-address---uint256---bytes---bytes32-bytes32-)), an executor triggers the operation’s underlying transactions and moves it to the `Done` state. If the operation has a predecessor, it has to be in the `Done` state for this transition to succeed. -* [`cancel`](contracts/5.x/api/governance#TimelockController-TimelockController-cancel-bytes32-) allows proposers to cancel any `Pending` operation. This resets the operation to the `Unset` state. It is thus possible for a proposer to re-schedule an operation that has been cancelled. In this case, the timer restarts when the operation is rescheduled. +* By calling [`execute`](/contracts/5.x/api/governance#TimelockController-TimelockController-execute-address-uint256-bytes-bytes32-bytes32-) (or [`executeBatch`](/contracts/5.x/api/governance#TimelockController-executeBatch-address---uint256---bytes---bytes32-bytes32-)), an executor triggers the operation’s underlying transactions and moves it to the `Done` state. If the operation has a predecessor, it has to be in the `Done` state for this transition to succeed. +* [`cancel`](/contracts/5.x/api/governance#TimelockController-TimelockController-cancel-bytes32-) allows proposers to cancel any `Pending` operation. This resets the operation to the `Unset` state. It is thus possible for a proposer to re-schedule an operation that has been cancelled. In this case, the timer restarts when the operation is rescheduled. Operations status can be queried using the functions: -* [`isOperationPending(bytes32)`](contracts/5.x/api/governance#TimelockController-isOperationPending-bytes32-) -* [`isOperationReady(bytes32)`](contracts/5.x/api/governance#TimelockController-isOperationReady-bytes32-) -* [`isOperationDone(bytes32)`](contracts/5.x/api/governance#TimelockController-isOperationDone-bytes32-) +* [`isOperationPending(bytes32)`](/contracts/5.x/api/governance#TimelockController-isOperationPending-bytes32-) +* [`isOperationReady(bytes32)`](/contracts/5.x/api/governance#TimelockController-isOperationReady-bytes32-) +* [`isOperationDone(bytes32)`](/contracts/5.x/api/governance#TimelockController-isOperationDone-bytes32-) #### Roles @@ -168,7 +171,7 @@ The admins are in charge of managing proposers and executors. For the timelock t The proposers are in charge of scheduling (and cancelling) operations. This is a critical role, that should be given to governing entities. This could be an EOA, a multisig, or a DAO. -**Proposer fight:** Having multiple proposers, while providing redundancy in case one becomes unavailable, can be dangerous. As proposer have their say on all operations, they could cancel operations they disagree with, including operations to remove them for the proposers. +**Proposer fight:** Having multiple proposers, while providing redundancy in case one becomes unavailable, can be dangerous. Proposers have a say on all operations--they could cancel operations they disagree with, including operations to remove them from the list of proposers. This role is identified by the **PROPOSER_ROLE** value: `0xb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1` @@ -187,9 +190,9 @@ A live contract without at least one proposer and one executor is locked. Make s
-## `Governor` +## `Governor` - + @@ -335,7 +338,6 @@ This contract is abstract and requires several functions to be implemented in va - [GovernorInvalidVoteType()](#IGovernor-GovernorInvalidVoteType--) - [GovernorInvalidVoteParams()](#IGovernor-GovernorInvalidVoteParams--) - [GovernorQueueNotImplemented()](#IGovernor-GovernorQueueNotImplemented--) -- [GovernorNotQueuedProposal(proposalId)](#IGovernor-GovernorNotQueuedProposal-uint256-) - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) @@ -367,7 +369,7 @@ parameter setters in [`GovernorSettings`](#GovernorSettings) are protected using 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 [`Governor._executor`](#Governor-_executor--). The executor is only able to invoke these -functions during the execution of the governor's [`AccessManager.execute`](/contracts/5.x/api/access#AccessManager-execute-address-bytes-) function, and not under any other circumstances. Thus, +functions during the execution of the governor's [`Governor.execute`](#Governor-execute-address---uint256---bytes---bytes32-) 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). @@ -645,7 +647,7 @@ Whether a proposal needs to be queued before execution.
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 [`AccessManager.execute`](/contracts/5.x/api/access#AccessManager-execute-address-bytes-) +itself, the function reverts if `msg.data` is not whitelisted as a result of an [`Governor.execute`](#Governor-execute-address---uint256---bytes---bytes32-) operation. See [`Governor.onlyGovernance`](#Governor-onlyGovernance--).
@@ -888,7 +890,7 @@ performed (for example adding a vault/timelock). 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 [`AccessManager.execute`](/contracts/5.x/api/access#AccessManager-execute-address-bytes-). +true or emit the `ProposalExecuted` event. Executing a proposal should be done using [`Governor.execute`](#Governor-execute-address---uint256---bytes---bytes32-).
@@ -1291,6 +1293,23 @@ If requirements are not met, reverts with a [`IGovernor.GovernorUnexpectedPropos
+Check if the proposer is authorized to submit a proposal with the given description. + +If the proposal description ends with `#proposer=0x???`, where `0x???` is an address written as a hex string +(case insensitive), then the submission of this proposal will only be authorized to said address. + +This is used for frontrunning protection. By adding this pattern at the end of their proposal, one can ensure +that no other address can submit the same proposal. An attacker would have to either remove or change that part, +which would result in a different proposal id. + +If the description does not match this pattern, it is unrestricted and anyone can submit it. This includes: + +- If the `0x???` part is not a valid hex string. +- If the `0x???` part is a valid hex string, but does not contain exactly 40 hex digits. +- If it ends with the expected suffix followed by newlines or other whitespace. +- If it ends with some other similar suffix, e.g. `#other=abc`. +- If it does not end with any such suffix. +
@@ -1458,9 +1477,9 @@ quorum depending on values such as the totalSupply of a token at this timepoint
-## `IGovernor` +## `IGovernor` - + @@ -1544,7 +1563,6 @@ Making event parameters `indexed` affects how events are decoded, potentially br - [GovernorInvalidVoteType()](#IGovernor-GovernorInvalidVoteType--) - [GovernorInvalidVoteParams()](#IGovernor-GovernorInvalidVoteParams--) - [GovernorQueueNotImplemented()](#IGovernor-GovernorQueueNotImplemented--) -- [GovernorNotQueuedProposal(proposalId)](#IGovernor-GovernorNotQueuedProposal-uint256-) - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) @@ -2428,23 +2446,6 @@ Queue operation is not implemented for this governor. Execute should be called d
- - -
-
-

GovernorNotQueuedProposal(uint256 proposalId)

-
-

error

-# -
-
-
- -The proposal hasn't been queued yet. - -
-
-
@@ -2501,9 +2502,9 @@ The given `account` is unable to cancel the proposal with given `proposalId`.
-## `TimelockController` +## `TimelockController` - + @@ -2705,6 +2706,13 @@ Contract might receive/hold ETH as part of the maintenance process.
+Returns true if this contract implements the interface defined by +`interfaceId`. See the corresponding +[ERC section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) +to learn more about how these ids are created. + +This function call must use less than 30 000 gas. +
@@ -3270,9 +3278,9 @@ The caller account is not authorized.
-## `GovernorCountingFractional` +## `GovernorCountingFractional` - + @@ -3431,7 +3439,6 @@ _Available since v5.1._ - [GovernorInvalidVoteType()](#IGovernor-GovernorInvalidVoteType--) - [GovernorInvalidVoteParams()](#IGovernor-GovernorInvalidVoteParams--) - [GovernorQueueNotImplemented()](#IGovernor-GovernorQueueNotImplemented--) -- [GovernorNotQueuedProposal(proposalId)](#IGovernor-GovernorNotQueuedProposal-uint256-) - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) @@ -3634,9 +3641,9 @@ A fractional vote params uses more votes than are available for that user.
-## `GovernorCountingOverridable` +## `GovernorCountingOverridable` - + @@ -3786,7 +3793,6 @@ token that inherits [`VotesExtended`](#VotesExtended). - [GovernorInvalidVoteType()](#IGovernor-GovernorInvalidVoteType--) - [GovernorInvalidVoteParams()](#IGovernor-GovernorInvalidVoteParams--) - [GovernorQueueNotImplemented()](#IGovernor-GovernorQueueNotImplemented--) -- [GovernorNotQueuedProposal(proposalId)](#IGovernor-GovernorNotQueuedProposal-uint256-) - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) @@ -4092,9 +4098,9 @@ A delegated vote on `proposalId` was overridden by `weight`
-## `GovernorCountingSimple` +## `GovernorCountingSimple` - + @@ -4230,7 +4236,6 @@ Extension of [`Governor`](#Governor) for simple, 3 options, vote counting. - [GovernorInvalidVoteType()](#IGovernor-GovernorInvalidVoteType--) - [GovernorInvalidVoteParams()](#IGovernor-GovernorInvalidVoteParams--) - [GovernorQueueNotImplemented()](#IGovernor-GovernorQueueNotImplemented--) -- [GovernorNotQueuedProposal(proposalId)](#IGovernor-GovernorNotQueuedProposal-uint256-) - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) @@ -4366,13 +4371,203 @@ See [`Governor._countVote`](#Governor-_countVote-uint256-address-uint8-uint256-b
+ + +
+ +## `GovernorCrosschain` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/governance/extensions/GovernorCrosschain.sol"; +``` + +Extension of [`Governor`](#Governor) for cross-chain governance through ERC-7786 gateways and [`CrosschainRemoteExecutor`](/contracts/5.x/api/crosschain#CrosschainRemoteExecutor). + +
+

Functions

+
+- [relayCrosschain(gateway, executor, mode, executionCalldata)](#GovernorCrosschain-relayCrosschain-address-bytes-Mode-bytes-) +- [_crosschainExecute(gateway, executor, mode, executionCalldata)](#GovernorCrosschain-_crosschainExecute-address-bytes-Mode-bytes-) +#### Governor [!toc] +- [receive()](#Governor-receive--) +- [supportsInterface(interfaceId)](#Governor-supportsInterface-bytes4-) +- [name()](#Governor-name--) +- [version()](#Governor-version--) +- [hashProposal(targets, values, calldatas, descriptionHash)](#Governor-hashProposal-address---uint256---bytes---bytes32-) +- [getProposalId(targets, values, calldatas, descriptionHash)](#Governor-getProposalId-address---uint256---bytes---bytes32-) +- [state(proposalId)](#Governor-state-uint256-) +- [proposalThreshold()](#Governor-proposalThreshold--) +- [proposalSnapshot(proposalId)](#Governor-proposalSnapshot-uint256-) +- [proposalDeadline(proposalId)](#Governor-proposalDeadline-uint256-) +- [proposalProposer(proposalId)](#Governor-proposalProposer-uint256-) +- [proposalEta(proposalId)](#Governor-proposalEta-uint256-) +- [proposalNeedsQueuing()](#Governor-proposalNeedsQueuing-uint256-) +- [_checkGovernance()](#Governor-_checkGovernance--) +- [_quorumReached(proposalId)](#Governor-_quorumReached-uint256-) +- [_voteSucceeded(proposalId)](#Governor-_voteSucceeded-uint256-) +- [_getVotes(account, timepoint, params)](#Governor-_getVotes-address-uint256-bytes-) +- [_countVote(proposalId, account, support, totalWeight, params)](#Governor-_countVote-uint256-address-uint8-uint256-bytes-) +- [_tallyUpdated(proposalId)](#Governor-_tallyUpdated-uint256-) +- [_defaultParams()](#Governor-_defaultParams--) +- [propose(targets, values, calldatas, description)](#Governor-propose-address---uint256---bytes---string-) +- [_propose(targets, values, calldatas, description, proposer)](#Governor-_propose-address---uint256---bytes---string-address-) +- [queue(targets, values, calldatas, descriptionHash)](#Governor-queue-address---uint256---bytes---bytes32-) +- [_queueOperations(, , , , )](#Governor-_queueOperations-uint256-address---uint256---bytes---bytes32-) +- [execute(targets, values, calldatas, descriptionHash)](#Governor-execute-address---uint256---bytes---bytes32-) +- [_executeOperations(, targets, values, calldatas, )](#Governor-_executeOperations-uint256-address---uint256---bytes---bytes32-) +- [cancel(targets, values, calldatas, descriptionHash)](#Governor-cancel-address---uint256---bytes---bytes32-) +- [_cancel(targets, values, calldatas, descriptionHash)](#Governor-_cancel-address---uint256---bytes---bytes32-) +- [getVotes(account, timepoint)](#Governor-getVotes-address-uint256-) +- [getVotesWithParams(account, timepoint, params)](#Governor-getVotesWithParams-address-uint256-bytes-) +- [castVote(proposalId, support)](#Governor-castVote-uint256-uint8-) +- [castVoteWithReason(proposalId, support, reason)](#Governor-castVoteWithReason-uint256-uint8-string-) +- [castVoteWithReasonAndParams(proposalId, support, reason, params)](#Governor-castVoteWithReasonAndParams-uint256-uint8-string-bytes-) +- [castVoteBySig(proposalId, support, voter, signature)](#Governor-castVoteBySig-uint256-uint8-address-bytes-) +- [castVoteWithReasonAndParamsBySig(proposalId, support, voter, reason, params, signature)](#Governor-castVoteWithReasonAndParamsBySig-uint256-uint8-address-string-bytes-bytes-) +- [_validateVoteSig(proposalId, support, voter, signature)](#Governor-_validateVoteSig-uint256-uint8-address-bytes-) +- [_validateExtendedVoteSig(proposalId, support, voter, reason, params, signature)](#Governor-_validateExtendedVoteSig-uint256-uint8-address-string-bytes-bytes-) +- [_castVote(proposalId, account, support, reason)](#Governor-_castVote-uint256-address-uint8-string-) +- [_castVote(proposalId, account, support, reason, params)](#Governor-_castVote-uint256-address-uint8-string-bytes-) +- [relay(target, value, data)](#Governor-relay-address-uint256-bytes-) +- [_executor()](#Governor-_executor--) +- [onERC721Received(, , , )](#Governor-onERC721Received-address-address-uint256-bytes-) +- [onERC1155Received(, , , , )](#Governor-onERC1155Received-address-address-uint256-uint256-bytes-) +- [onERC1155BatchReceived(, , , , )](#Governor-onERC1155BatchReceived-address-address-uint256---uint256---bytes-) +- [_encodeStateBitmap(proposalState)](#Governor-_encodeStateBitmap-enum-IGovernor-ProposalState-) +- [_validateStateBitmap(proposalId, allowedStates)](#Governor-_validateStateBitmap-uint256-bytes32-) +- [_isValidDescriptionForProposer(proposer, description)](#Governor-_isValidDescriptionForProposer-address-string-) +- [_validateCancel(proposalId, caller)](#Governor-_validateCancel-uint256-address-) +- [clock()](#Governor-clock--) +- [CLOCK_MODE()](#Governor-CLOCK_MODE--) +- [votingDelay()](#Governor-votingDelay--) +- [votingPeriod()](#Governor-votingPeriod--) +- [quorum(timepoint)](#Governor-quorum-uint256-) +- [BALLOT_TYPEHASH()](#Governor-BALLOT_TYPEHASH-bytes32) +- [EXTENDED_BALLOT_TYPEHASH()](#Governor-EXTENDED_BALLOT_TYPEHASH-bytes32) +#### IERC1155Receiver [!toc] +#### IERC721Receiver [!toc] +#### IGovernor [!toc] +- [COUNTING_MODE()](#IGovernor-COUNTING_MODE--) +- [hasVoted(proposalId, account)](#IGovernor-hasVoted-uint256-address-) +#### IERC6372 [!toc] +#### Nonces [!toc] +- [nonces(owner)](#Nonces-nonces-address-) +- [_useNonce(owner)](#Nonces-_useNonce-address-) +- [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) +#### EIP712 [!toc] +- [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) +- [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) +- [eip712Domain()](#EIP712-eip712Domain--) +- [_EIP712Name()](#EIP712-_EIP712Name--) +- [_EIP712Version()](#EIP712-_EIP712Version--) +#### IERC5267 [!toc] +#### ERC165 [!toc] +#### IERC165 [!toc] +
+
+ +
+

Events

+
+#### Governor [!toc] +#### IERC1155Receiver [!toc] +#### IERC721Receiver [!toc] +#### IGovernor [!toc] +- [ProposalCreated(proposalId, proposer, targets, values, signatures, calldatas, voteStart, voteEnd, description)](#IGovernor-ProposalCreated-uint256-address-address---uint256---string---bytes---uint256-uint256-string-) +- [ProposalQueued(proposalId, etaSeconds)](#IGovernor-ProposalQueued-uint256-uint256-) +- [ProposalExecuted(proposalId)](#IGovernor-ProposalExecuted-uint256-) +- [ProposalCanceled(proposalId)](#IGovernor-ProposalCanceled-uint256-) +- [VoteCast(voter, proposalId, support, weight, reason)](#IGovernor-VoteCast-address-uint256-uint8-uint256-string-) +- [VoteCastWithParams(voter, proposalId, support, weight, reason, params)](#IGovernor-VoteCastWithParams-address-uint256-uint8-uint256-string-bytes-) +#### IERC6372 [!toc] +#### Nonces [!toc] +#### EIP712 [!toc] +#### IERC5267 [!toc] +- [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) +#### ERC165 [!toc] +#### IERC165 [!toc] +
+
+ +
+

Errors

+
+#### Governor [!toc] +#### IERC1155Receiver [!toc] +#### IERC721Receiver [!toc] +#### IGovernor [!toc] +- [GovernorInvalidProposalLength(targets, calldatas, values)](#IGovernor-GovernorInvalidProposalLength-uint256-uint256-uint256-) +- [GovernorAlreadyCastVote(voter)](#IGovernor-GovernorAlreadyCastVote-address-) +- [GovernorDisabledDeposit()](#IGovernor-GovernorDisabledDeposit--) +- [GovernorOnlyExecutor(account)](#IGovernor-GovernorOnlyExecutor-address-) +- [GovernorNonexistentProposal(proposalId)](#IGovernor-GovernorNonexistentProposal-uint256-) +- [GovernorUnexpectedProposalState(proposalId, current, expectedStates)](#IGovernor-GovernorUnexpectedProposalState-uint256-enum-IGovernor-ProposalState-bytes32-) +- [GovernorInvalidVotingPeriod(votingPeriod)](#IGovernor-GovernorInvalidVotingPeriod-uint256-) +- [GovernorInsufficientProposerVotes(proposer, votes, threshold)](#IGovernor-GovernorInsufficientProposerVotes-address-uint256-uint256-) +- [GovernorRestrictedProposer(proposer)](#IGovernor-GovernorRestrictedProposer-address-) +- [GovernorInvalidVoteType()](#IGovernor-GovernorInvalidVoteType--) +- [GovernorInvalidVoteParams()](#IGovernor-GovernorInvalidVoteParams--) +- [GovernorQueueNotImplemented()](#IGovernor-GovernorQueueNotImplemented--) +- [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) +- [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) +- [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) +#### IERC6372 [!toc] +#### Nonces [!toc] +- [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) +#### EIP712 [!toc] +#### IERC5267 [!toc] +#### ERC165 [!toc] +#### IERC165 [!toc] +
+
+ + + +
+
+

relayCrosschain(address gateway, bytes executor, Mode mode, bytes executionCalldata)

+
+

public

+# +
+
+
+ +Send crosschain instruction to an arbitrary remote executor via an arbitrary ERC-7786 gateway. + +
+
+ + + +
+
+

_crosschainExecute(address gateway, bytes executor, Mode mode, bytes executionCalldata)

+
+

internal

+# +
+
+
+ +Send crosschain instruction to an arbitrary remote executor via an arbitrary ERC-7786 gateway. + +
+
+
-## `GovernorNoncesKeyed` +## `GovernorNoncesKeyed` - + @@ -4518,7 +4713,6 @@ Traditional (un-keyed) nonces are still supported and can continue to be used as - [GovernorInvalidVoteType()](#IGovernor-GovernorInvalidVoteType--) - [GovernorInvalidVoteParams()](#IGovernor-GovernorInvalidVoteParams--) - [GovernorQueueNotImplemented()](#IGovernor-GovernorQueueNotImplemented--) -- [GovernorNotQueuedProposal(proposalId)](#IGovernor-GovernorNotQueuedProposal-uint256-) - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) @@ -4595,9 +4789,9 @@ Side effects may be skipped depending on the linearization of the function.
-## `GovernorPreventLateQuorum` +## `GovernorPreventLateQuorum` - + @@ -4744,7 +4938,6 @@ proposal. - [GovernorInvalidVoteType()](#IGovernor-GovernorInvalidVoteType--) - [GovernorInvalidVoteParams()](#IGovernor-GovernorInvalidVoteParams--) - [GovernorQueueNotImplemented()](#IGovernor-GovernorQueueNotImplemented--) -- [GovernorNotQueuedProposal(proposalId)](#IGovernor-GovernorNotQueuedProposal-uint256-) - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) @@ -4911,9 +5104,9 @@ Emitted when the [`GovernorPreventLateQuorum.lateQuorumVoteExtension`](#Governor
-## `GovernorProposalGuardian` +## `GovernorProposalGuardian` - + @@ -5056,7 +5249,6 @@ if the proposal guardian is not configured, then proposers take this role for th - [GovernorInvalidVoteType()](#IGovernor-GovernorInvalidVoteType--) - [GovernorInvalidVoteParams()](#IGovernor-GovernorInvalidVoteParams--) - [GovernorQueueNotImplemented()](#IGovernor-GovernorQueueNotImplemented--) -- [GovernorNotQueuedProposal(proposalId)](#IGovernor-GovernorNotQueuedProposal-uint256-) - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) @@ -5166,9 +5358,9 @@ Override [`Governor._validateCancel`](#Governor-_validateCancel-uint256-address-
-## `GovernorSequentialProposalId` +## `GovernorSequentialProposalId` - + @@ -5307,7 +5499,6 @@ sequential ids. - [GovernorInvalidVoteType()](#IGovernor-GovernorInvalidVoteType--) - [GovernorInvalidVoteParams()](#IGovernor-GovernorInvalidVoteParams--) - [GovernorQueueNotImplemented()](#IGovernor-GovernorQueueNotImplemented--) -- [GovernorNotQueuedProposal(proposalId)](#IGovernor-GovernorNotQueuedProposal-uint256-) - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) @@ -5413,9 +5604,9 @@ The [`GovernorSequentialProposalId.latestProposalId`](#GovernorSequentialProposa
-## `GovernorSettings` +## `GovernorSettings` - + @@ -5560,7 +5751,6 @@ Extension of [`Governor`](#Governor) for settings updatable through governance. - [GovernorInvalidVoteType()](#IGovernor-GovernorInvalidVoteType--) - [GovernorInvalidVoteParams()](#IGovernor-GovernorInvalidVoteParams--) - [GovernorQueueNotImplemented()](#IGovernor-GovernorQueueNotImplemented--) -- [GovernorNotQueuedProposal(proposalId)](#IGovernor-GovernorNotQueuedProposal-uint256-) - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) @@ -5802,9 +5992,9 @@ Emits a [`GovernorSettings.ProposalThresholdSet`](#GovernorSettings-ProposalThre
-## `GovernorStorage` +## `GovernorStorage` - + @@ -5951,7 +6141,6 @@ Use cases for this module include: - [GovernorInvalidVoteType()](#IGovernor-GovernorInvalidVoteType--) - [GovernorInvalidVoteParams()](#IGovernor-GovernorInvalidVoteParams--) - [GovernorQueueNotImplemented()](#IGovernor-GovernorQueueNotImplemented--) -- [GovernorNotQueuedProposal(proposalId)](#IGovernor-GovernorNotQueuedProposal-uint256-) - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) @@ -6088,9 +6277,9 @@ Returns the details (including the proposalId) of a proposal given its sequentia
-## `GovernorSuperQuorum` +## `GovernorSuperQuorum` - + @@ -6229,7 +6418,6 @@ extension must implement [`GovernorCountingFractional.proposalVotes`](#GovernorC - [GovernorInvalidVoteType()](#IGovernor-GovernorInvalidVoteType--) - [GovernorInvalidVoteParams()](#IGovernor-GovernorInvalidVoteParams--) - [GovernorQueueNotImplemented()](#IGovernor-GovernorQueueNotImplemented--) -- [GovernorNotQueuedProposal(proposalId)](#IGovernor-GovernorNotQueuedProposal-uint256-) - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) @@ -6321,9 +6509,9 @@ types of scenarios.
-## `GovernorTimelockAccess` +## `GovernorTimelockAccess` - + @@ -6343,7 +6531,7 @@ and [`GovernorTimelockCompound`](#GovernorTimelockCompound), where the timelock permissions. Operations that are delay-restricted by the manager, however, will be executed through the [`AccessManager.execute`](/contracts/5.x/api/access#AccessManager-execute-address-bytes-) function. -==== Security Considerations +#### 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 @@ -6499,7 +6687,6 @@ the same time. See [`AccessManager.schedule`](/contracts/5.x/api/access#AccessMa - [GovernorInvalidVoteType()](#IGovernor-GovernorInvalidVoteType--) - [GovernorInvalidVoteParams()](#IGovernor-GovernorInvalidVoteParams--) - [GovernorQueueNotImplemented()](#IGovernor-GovernorQueueNotImplemented--) -- [GovernorNotQueuedProposal(proposalId)](#IGovernor-GovernorNotQueuedProposal-uint256-) - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) @@ -6848,9 +7035,9 @@ Emits a [`IGovernor.ProposalCanceled`](#IGovernor-ProposalCanceled-uint256-) eve
-## `GovernorTimelockCompound` +## `GovernorTimelockCompound` - + @@ -6997,7 +7184,6 @@ inaccessible from a proposal, unless executed via [`Governor.relay`](#Governor-r - [GovernorInvalidVoteType()](#IGovernor-GovernorInvalidVoteType--) - [GovernorInvalidVoteParams()](#IGovernor-GovernorInvalidVoteParams--) - [GovernorQueueNotImplemented()](#IGovernor-GovernorQueueNotImplemented--) -- [GovernorNotQueuedProposal(proposalId)](#IGovernor-GovernorNotQueuedProposal-uint256-) - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) @@ -7186,7 +7372,9 @@ Note that if the timelock admin has been handed over in a previous operation, we 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. + +It is not recommended to change the timelock while there are other queued governance proposals. +
@@ -7213,9 +7401,9 @@ Emitted when the timelock controller used for proposal execution is modified.
-## `GovernorTimelockControl` +## `GovernorTimelockControl` - + @@ -7367,7 +7555,6 @@ proposals that have been approved by the voters, effectively executing a Denial - [GovernorInvalidVoteType()](#IGovernor-GovernorInvalidVoteType--) - [GovernorInvalidVoteParams()](#IGovernor-GovernorInvalidVoteParams--) - [GovernorQueueNotImplemented()](#IGovernor-GovernorQueueNotImplemented--) -- [GovernorNotQueuedProposal(proposalId)](#IGovernor-GovernorNotQueuedProposal-uint256-) - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) @@ -7532,7 +7719,9 @@ Address through which the governor executes action. In this case, the timelock. 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. + +It is not recommended to change the timelock while there are other queued governance proposals. +
@@ -7559,9 +7748,9 @@ Emitted when the timelock controller used for proposal execution is modified.
-## `GovernorVotes` +## `GovernorVotes` - + @@ -7699,7 +7888,6 @@ token. - [GovernorInvalidVoteType()](#IGovernor-GovernorInvalidVoteType--) - [GovernorInvalidVoteParams()](#IGovernor-GovernorInvalidVoteParams--) - [GovernorQueueNotImplemented()](#IGovernor-GovernorQueueNotImplemented--) -- [GovernorNotQueuedProposal(proposalId)](#IGovernor-GovernorNotQueuedProposal-uint256-) - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) @@ -7799,9 +7987,9 @@ Machine-readable description of the clock as specified in ERC-6372.
-## `GovernorVotesQuorumFraction` +## `GovernorVotesQuorumFraction` - + @@ -7950,7 +8138,6 @@ fraction of the total supply. - [GovernorInvalidVoteType()](#IGovernor-GovernorInvalidVoteType--) - [GovernorInvalidVoteParams()](#IGovernor-GovernorInvalidVoteParams--) - [GovernorQueueNotImplemented()](#IGovernor-GovernorQueueNotImplemented--) -- [GovernorNotQueuedProposal(proposalId)](#IGovernor-GovernorNotQueuedProposal-uint256-) - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) @@ -8154,9 +8341,9 @@ The quorum set is not a valid fraction.
-## `GovernorVotesSuperQuorumFraction` +## `GovernorVotesSuperQuorumFraction` - + @@ -8322,7 +8509,6 @@ the `Succeeded` state before the proposal deadline. - [GovernorInvalidVoteType()](#IGovernor-GovernorInvalidVoteType--) - [GovernorInvalidVoteParams()](#IGovernor-GovernorInvalidVoteParams--) - [GovernorQueueNotImplemented()](#IGovernor-GovernorQueueNotImplemented--) -- [GovernorNotQueuedProposal(proposalId)](#IGovernor-GovernorNotQueuedProposal-uint256-) - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) @@ -8573,9 +8759,9 @@ The quorum set is not valid as it exceeds the super quorum.
-## `IVotes` +## `IVotes` - + @@ -8780,9 +8966,9 @@ The signature used has expired.
-## `Votes` +## `Votes` - + @@ -9206,9 +9392,9 @@ Lookup to future votes is not available.
-## `VotesExtended` +## `VotesExtended` - + @@ -9396,3 +9582,4 @@ should be zero. Total supply of voting units will be adjusted with mints and bur
+ diff --git a/content/contracts/5.x/api/interfaces.mdx b/content/contracts/5.x/api/interfaces.mdx index 92d69448..00fcd245 100644 --- a/content/contracts/5.x/api/interfaces.mdx +++ b/content/contracts/5.x/api/interfaces.mdx @@ -30,6 +30,8 @@ are useful to interact with third party contracts that implement them. * [`IERC1820Implementer`](#IERC1820Implementer) * [`IERC1820Registry`](#IERC1820Registry) * [`IERC1822Proxiable`](#IERC1822Proxiable) +* [`IERC1967`](#IERC1967) +* [`IERC2309`](#IERC2309) * [`IERC2612`](#IERC2612) * [`IERC2981`](#IERC2981) * [`IERC3156FlashLender`](#IERC3156FlashLender) @@ -44,11 +46,18 @@ are useful to interact with third party contracts that implement them. * [`IERC6909ContentURI`](#IERC6909ContentURI) * [`IERC6909Metadata`](#IERC6909Metadata) * [`IERC6909TokenSupply`](#IERC6909TokenSupply) +* [`IERC7579Module`](#IERC7579Module) +* [`IERC7579Validator`](#IERC7579Validator) +* [`IERC7579Hook`](#IERC7579Hook) +* [`IERC7579Execution`](#IERC7579Execution) +* [`IERC7579AccountConfig`](#IERC7579AccountConfig) +* [`IERC7579ModuleConfig`](#IERC7579ModuleConfig) * [`IERC7674`](#IERC7674) - [`IERC7751`](#IERC7751) * [`IERC7786GatewaySource`](#IERC7786GatewaySource) * [`IERC7786Recipient`](#IERC7786Recipient) * [`IERC7802`](#IERC7802) +* [`IERC7913SignatureVerifier`](#IERC7913SignatureVerifier) ## Detailed ABI @@ -72,6 +81,10 @@ are useful to interact with third party contracts that implement them. [`IERC1822Proxiable`](#IERC1822Proxiable) +[`IERC1967`](#IERC1967) + +[`IERC2309`](#IERC2309) + [`IERC2612`](#IERC2612) [`IERC2981`](#IERC2981) @@ -100,6 +113,18 @@ are useful to interact with third party contracts that implement them. [`IERC6909TokenSupply`](#IERC6909TokenSupply) +[`IERC7579Module`](#IERC7579Module) + +[`IERC7579Validator`](#IERC7579Validator) + +[`IERC7579Hook`](#IERC7579Hook) + +[`IERC7579Execution`](#IERC7579Execution) + +[`IERC7579AccountConfig`](#IERC7579AccountConfig) + +[`IERC7579ModuleConfig`](#IERC7579ModuleConfig) + [`IERC7674`](#IERC7674) [`IERC7751`](#IERC7751) @@ -110,13 +135,15 @@ are useful to interact with third party contracts that implement them. [`IERC7802`](#IERC7802) +[`IERC7913SignatureVerifier`](#IERC7913SignatureVerifier) +
-## `IERC1271` +## `IERC1271` - + @@ -157,9 +184,9 @@ Should return whether the signature provided is valid for the provided data
-## `IERC1363` +## `IERC1363` - + @@ -313,733 +340,310 @@ caller's tokens and then calls [`IERC1363Spender.onApprovalReceived`](#IERC1363S
- +
-## `IERC1363Receiver` +## `IERC1967` - +
```solidity -import "@openzeppelin/contracts/interfaces/IERC1363Receiver.sol"; +import "@openzeppelin/contracts/interfaces/IERC1967.sol"; ``` -Interface for any contract that wants to support `transferAndCall` or `transferFromAndCall` -from ERC-1363 token contracts. +ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
-

Functions

+

Events

-- [onTransferReceived(operator, from, value, data)](#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) +- [Upgraded(implementation)](#IERC1967-Upgraded-address-) +- [AdminChanged(previousAdmin, newAdmin)](#IERC1967-AdminChanged-address-address-) +- [BeaconUpgraded(beacon)](#IERC1967-BeaconUpgraded-address-)
- +
-

onTransferReceived(address operator, address from, uint256 value, bytes data) → bytes4

+

Upgraded(address indexed implementation)

-

external

-# +

event

+#
+
-Whenever ERC-1363 tokens are transferred to this contract via `transferAndCall` or `transferFromAndCall` -by `operator` from `from`, this function is called. +Emitted when the implementation is upgraded. - -To accept the transfer, this must return -`bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))` -(i.e. 0x88a7ca5c, or its own function selector). - +
+
+ + +
+
+

AdminChanged(address previousAdmin, address newAdmin)

+
+

event

+# +
+
+ +
+ +Emitted when the admin account has changed.
+ - +
+
+

BeaconUpgraded(address indexed beacon)

+
+

event

+# +
+
+ +
+ +Emitted when the beacon is changed. + +
+
+ +
-## `IERC1363Spender` +## `IERC2309` - +
```solidity -import "@openzeppelin/contracts/interfaces/IERC1363Spender.sol"; +import "@openzeppelin/contracts/interfaces/IERC2309.sol"; ``` -Interface for any contract that wants to support `approveAndCall` -from ERC-1363 token contracts. +ERC-2309: ERC-721 Consecutive Transfer Extension.
-

Functions

+

Events

-- [onApprovalReceived(owner, value, data)](#IERC1363Spender-onApprovalReceived-address-uint256-bytes-) +- [ConsecutiveTransfer(fromTokenId, toTokenId, fromAddress, toAddress)](#IERC2309-ConsecutiveTransfer-uint256-uint256-address-address-)
- +
-

onApprovalReceived(address owner, uint256 value, bytes data) → bytes4

+

ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed fromAddress, address indexed toAddress)

-

external

-# +

event

+#
-
-Whenever an ERC-1363 token `owner` approves this contract via `approveAndCall` -to spend their tokens, this function is called. +
- -To accept the approval, this must return -`bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))` -(i.e. 0x7b04a2d0, or its own function selector). - +Emitted when the tokens from `fromTokenId` to `toTokenId` are transferred from `fromAddress` to `toAddress`.
- +
-## `IERC1820Implementer` +## `IERC2981` - +
```solidity -import "@openzeppelin/contracts/interfaces/IERC1820Implementer.sol"; +import "@openzeppelin/contracts/interfaces/IERC2981.sol"; ``` -Interface for an ERC-1820 implementer, as defined in the -[ERC](https://eips.ethereum.org/EIPS/eip-1820#interface-implementation-erc1820implementerinterface). -Used by contracts that will be registered as implementers in the -[`IERC1820Registry`](#IERC1820Registry). +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

-- [canImplementInterfaceForAddress(interfaceHash, account)](#IERC1820Implementer-canImplementInterfaceForAddress-bytes32-address-) +- [royaltyInfo(tokenId, salePrice)](#IERC2981-royaltyInfo-uint256-uint256-) +#### IERC165 [!toc] +- [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-)
- +
-

canImplementInterfaceForAddress(bytes32 interfaceHash, address account) → bytes32

+

royaltyInfo(uint256 tokenId, uint256 salePrice) → address receiver, uint256 royaltyAmount

external

-# +#
-Returns a special value (`ERC1820_ACCEPT_MAGIC`) if this contract -implements `interfaceHash` for `account`. +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. -See [`IERC1820Registry.setInterfaceImplementer`](#IERC1820Registry-setInterfaceImplementer-address-bytes32-address-). + +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. +
- +
-## `IERC1820Registry` +## `IERC3156FlashBorrower` - +
```solidity -import "@openzeppelin/contracts/interfaces/IERC1820Registry.sol"; +import "@openzeppelin/contracts/interfaces/IERC3156FlashBorrower.sol"; ``` -Interface of the global ERC-1820 Registry, as defined in the -[ERC](https://eips.ethereum.org/EIPS/eip-1820). 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`](/contracts/5.x/api/utils#IERC165) interfaces can also be queried via the registry. - -For an in-depth explanation and source code analysis, see the ERC text. +Interface of the ERC-3156 FlashBorrower, as defined in +[ERC-3156](https://eips.ethereum.org/EIPS/eip-3156).

Functions

-- [setManager(account, newManager)](#IERC1820Registry-setManager-address-address-) -- [getManager(account)](#IERC1820Registry-getManager-address-) -- [setInterfaceImplementer(account, _interfaceHash, implementer)](#IERC1820Registry-setInterfaceImplementer-address-bytes32-address-) -- [getInterfaceImplementer(account, _interfaceHash)](#IERC1820Registry-getInterfaceImplementer-address-bytes32-) -- [interfaceHash(interfaceName)](#IERC1820Registry-interfaceHash-string-) -- [updateERC165Cache(account, interfaceId)](#IERC1820Registry-updateERC165Cache-address-bytes4-) -- [implementsERC165Interface(account, interfaceId)](#IERC1820Registry-implementsERC165Interface-address-bytes4-) -- [implementsERC165InterfaceNoCache(account, interfaceId)](#IERC1820Registry-implementsERC165InterfaceNoCache-address-bytes4-) -
-
- -
-

Events

-
-- [InterfaceImplementerSet(account, interfaceHash, implementer)](#IERC1820Registry-InterfaceImplementerSet-address-bytes32-address-) -- [ManagerChanged(account, newManager)](#IERC1820Registry-ManagerChanged-address-address-) +- [onFlashLoan(initiator, token, amount, fee, data)](#IERC3156FlashBorrower-onFlashLoan-address-address-uint256-uint256-bytes-)
- +
-

setManager(address account, address newManager)

+

onFlashLoan(address initiator, address token, uint256 amount, uint256 fee, bytes data) → bytes32

external

-# +#
-Sets `newManager` as the manager for `account`. A manager of an -account is able to set interface implementers for it. +Receive a flash loan. -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 [`IERC1820Registry.ManagerChanged`](#IERC1820Registry-ManagerChanged-address-address-) event. + -Requirements: +
-- the caller must be the current manager for `account`. +## `IERC3156FlashLender` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/interfaces/IERC3156FlashLender.sol"; +``` + +Interface of the ERC-3156 FlashLender, as defined in +[ERC-3156](https://eips.ethereum.org/EIPS/eip-3156). +
+

Functions

+
+- [maxFlashLoan(token)](#IERC3156FlashLender-maxFlashLoan-address-) +- [flashFee(token, amount)](#IERC3156FlashLender-flashFee-address-uint256-) +- [flashLoan(receiver, token, amount, data)](#IERC3156FlashLender-flashLoan-contract-IERC3156FlashBorrower-address-uint256-bytes-)
- +
-

getManager(address account) → address

+

maxFlashLoan(address token) → uint256

external

-# +#
-Returns the manager for `account`. - -See [`IERC1820Registry.setManager`](#IERC1820Registry-setManager-address-address-). +The amount of currency available to be lent.
- +
-

setInterfaceImplementer(address account, bytes32 _interfaceHash, address implementer)

+

flashFee(address token, uint256 amount) → uint256

external

-# +#
-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 [`IERC1820Registry.interfaceHash`](#IERC1820Registry-interfaceHash-string-) to learn how these are created. - -Emits an [`IERC1820Registry.InterfaceImplementerSet`](#IERC1820Registry-InterfaceImplementerSet-address-bytes32-address-) event. - -Requirements: - -- the caller must be the current manager for `account`. -- `interfaceHash` must not be an [`IERC165`](/contracts/5.x/api/utils#IERC165) interface id (i.e. it must not -end in 28 zeroes). -- `implementer` must implement [`IERC1820Implementer`](#IERC1820Implementer) and return true when -queried for support, unless `implementer` is the caller. See -[`IERC1820Implementer.canImplementInterfaceForAddress`](#IERC1820Implementer-canImplementInterfaceForAddress-bytes32-address-). +The fee to be charged for a given loan.
- +
-

getInterfaceImplementer(address account, bytes32 _interfaceHash) → address

+

flashLoan(contract IERC3156FlashBorrower receiver, address token, uint256 amount, bytes data) → bool

external

-# +#
-Returns the implementer of `interfaceHash` for `account`. If no such -implementer is registered, returns the zero address. - -If `interfaceHash` is an [`IERC165`](/contracts/5.x/api/utils#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. +Initiate a flash loan.
- - -
-
-

interfaceHash(string interfaceName) → bytes32

-
-

external

-# -
-
-
- -Returns the interface hash for an `interfaceName`, as defined in the -corresponding -[section of the ERC](https://eips.ethereum.org/EIPS/eip-1820#interface-name). - -
-
- - - -
-
-

updateERC165Cache(address account, bytes4 interfaceId)

-
-

external

-# -
-
-
- -
-
- - - -
-
-

implementsERC165Interface(address account, bytes4 interfaceId) → bool

-
-

external

-# -
-
-
- -
-
- - - -
-
-

implementsERC165InterfaceNoCache(address account, bytes4 interfaceId) → bool

-
-

external

-# -
-
-
- -
-
- - - -
-
-

InterfaceImplementerSet(address indexed account, bytes32 indexed interfaceHash, address indexed implementer)

-
-

event

-# -
-
- -
- -
-
- - -
-
-

ManagerChanged(address indexed account, address indexed newManager)

-
-

event

-# -
-
- -
- -
-
- - - -
- -## `IERC1967` - - - - - -
- -```solidity -import "@openzeppelin/contracts/interfaces/IERC1967.sol"; -``` - -ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC. - -
-

Events

-
-- [Upgraded(implementation)](#IERC1967-Upgraded-address-) -- [AdminChanged(previousAdmin, newAdmin)](#IERC1967-AdminChanged-address-address-) -- [BeaconUpgraded(beacon)](#IERC1967-BeaconUpgraded-address-) -
-
- - - -
-
-

Upgraded(address indexed implementation)

-
-

event

-# -
-
- -
- -Emitted when the implementation is upgraded. - -
-
- - -
-
-

AdminChanged(address previousAdmin, address newAdmin)

-
-

event

-# -
-
- -
- -Emitted when the admin account has changed. - -
-
- - -
-
-

BeaconUpgraded(address indexed beacon)

-
-

event

-# -
-
- -
- -Emitted when the beacon is changed. - -
-
- - - -
- -## `IERC2309` - - - - - -
- -```solidity -import "@openzeppelin/contracts/interfaces/IERC2309.sol"; -``` - -ERC-2309: ERC-721 Consecutive Transfer Extension. - -
-

Events

-
-- [ConsecutiveTransfer(fromTokenId, toTokenId, fromAddress, toAddress)](#IERC2309-ConsecutiveTransfer-uint256-uint256-address-address-) -
-
- - - -
-
-

ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed fromAddress, address indexed toAddress)

-
-

event

-# -
-
- -
- -Emitted when the tokens from `fromTokenId` to `toTokenId` are transferred from `fromAddress` to `toAddress`. - -
-
- - - -
- -## `IERC2612` - - - - - -
- -```solidity -import "@openzeppelin/contracts/interfaces/IERC2612.sol"; -``` - -
-

Functions

-
-#### IERC20Permit [!toc] -- [permit(owner, spender, value, deadline, v, r, s)](#IERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) -- [nonces(owner)](#IERC20Permit-nonces-address-) -- [DOMAIN_SEPARATOR()](#IERC20Permit-DOMAIN_SEPARATOR--) -
-
- - - -
- -## `IERC2981` - - - - - -
- -```solidity -import "@openzeppelin/contracts/interfaces/IERC2981.sol"; -``` - -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(tokenId, salePrice)](#IERC2981-royaltyInfo-uint256-uint256-) -#### IERC165 [!toc] -- [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) -
-
- - - -
-
-

royaltyInfo(uint256 tokenId, uint256 salePrice) → address receiver, uint256 royaltyAmount

-
-

external

-# -
-
-
- -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. - - -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. - - -
-
- - - -
- -## `IERC3156FlashBorrower` - - - - - -
- -```solidity -import "@openzeppelin/contracts/interfaces/IERC3156FlashBorrower.sol"; -``` - -Interface of the ERC-3156 FlashBorrower, as defined in -[ERC-3156](https://eips.ethereum.org/EIPS/eip-3156). - -
-

Functions

-
-- [onFlashLoan(initiator, token, amount, fee, data)](#IERC3156FlashBorrower-onFlashLoan-address-address-uint256-uint256-bytes-) -
-
- - - -
-
-

onFlashLoan(address initiator, address token, uint256 amount, uint256 fee, bytes data) → bytes32

-
-

external

-# -
-
-
- -Receive a flash loan. - -
-
- - - -
- -## `IERC3156FlashLender` - - - - - -
- -```solidity -import "@openzeppelin/contracts/interfaces/IERC3156FlashLender.sol"; -``` - -Interface of the ERC-3156 FlashLender, as defined in -[ERC-3156](https://eips.ethereum.org/EIPS/eip-3156). - -
-

Functions

-
-- [maxFlashLoan(token)](#IERC3156FlashLender-maxFlashLoan-address-) -- [flashFee(token, amount)](#IERC3156FlashLender-flashFee-address-uint256-) -- [flashLoan(receiver, token, amount, data)](#IERC3156FlashLender-flashLoan-contract-IERC3156FlashBorrower-address-uint256-bytes-) -
-
- - - -
-
-

maxFlashLoan(address token) → uint256

-
-

external

-# -
-
-
- -The amount of currency available to be lent. - -
-
- - - -
-
-

flashFee(address token, uint256 amount) → uint256

-
-

external

-# -
-
-
- -The fee to be charged for a given loan. - -
-
- - - -
-
-

flashLoan(contract IERC3156FlashBorrower receiver, address token, uint256 amount, bytes data) → bool

-
-

external

-# -
-
-
- -Initiate a flash loan. - -
-
- - +
-## `IERC4626` +## `IERC4626` - + @@ -1549,9 +1153,9 @@ Those methods should be performed separately.
-## `IERC4906` +## `IERC4906` - + @@ -1635,9 +1239,9 @@ timely update the images and related attributes of the NFTs.
-## `IERC5267` +## `IERC5267` - + @@ -1701,9 +1305,9 @@ MAY be emitted to signal that the domain could have changed.
-## `IERC5313` +## `IERC5313` - + @@ -1745,9 +1349,9 @@ Gets the address of the owner.
-## `IERC5805` +## `IERC5805` - + @@ -1796,9 +1400,9 @@ import "@openzeppelin/contracts/interfaces/IERC5805.sol";
-## `IERC6372` +## `IERC6372` - + @@ -1854,9 +1458,9 @@ Description of the clock
-## `IERC6909` +## `IERC6909` - + @@ -2002,90 +1606,270 @@ Must return true. Transfers `amount` of token type `id` from the caller's account to `receiver`. -Must return true. +Must return true. + +
+
+ + + +
+
+

transferFrom(address sender, address receiver, uint256 id, uint256 amount) → bool

+
+

external

+# +
+
+
+ +Transfers `amount` of token type `id` from `sender` to `receiver`. + +Must return true. + +
+
+ + + +
+
+

Approval(address indexed owner, address indexed spender, uint256 indexed id, uint256 amount)

+
+

event

+# +
+
+ +
+ +Emitted when the allowance of a `spender` for an `owner` is set for a token of type `id`. +The new allowance is `amount`. + +
+
+ + +
+
+

OperatorSet(address indexed owner, address indexed spender, bool approved)

+
+

event

+# +
+
+ +
+ +Emitted when `owner` grants or revokes operator status for a `spender`. + +
+
+ + +
+
+

Transfer(address caller, address indexed sender, address indexed receiver, uint256 indexed id, uint256 amount)

+
+

event

+# +
+
+ +
+ +Emitted when `amount` tokens of type `id` are moved from `sender` to `receiver` initiated by `caller`. + +
+
+ + + +
+ +## `IERC6909Metadata` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/interfaces/IERC6909.sol"; +``` + +Optional extension of [`IERC6909`](#IERC6909) that adds metadata functions. + +
+

Functions

+
+- [name(id)](#IERC6909Metadata-name-uint256-) +- [symbol(id)](#IERC6909Metadata-symbol-uint256-) +- [decimals(id)](#IERC6909Metadata-decimals-uint256-) +#### IERC6909 [!toc] +- [balanceOf(owner, id)](#IERC6909-balanceOf-address-uint256-) +- [allowance(owner, spender, id)](#IERC6909-allowance-address-address-uint256-) +- [isOperator(owner, spender)](#IERC6909-isOperator-address-address-) +- [approve(spender, id, amount)](#IERC6909-approve-address-uint256-uint256-) +- [setOperator(spender, approved)](#IERC6909-setOperator-address-bool-) +- [transfer(receiver, id, amount)](#IERC6909-transfer-address-uint256-uint256-) +- [transferFrom(sender, receiver, id, amount)](#IERC6909-transferFrom-address-address-uint256-uint256-) +#### IERC165 [!toc] +- [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) +
+
+ +
+

Events

+
+#### IERC6909 [!toc] +- [Approval(owner, spender, id, amount)](#IERC6909-Approval-address-address-uint256-uint256-) +- [OperatorSet(owner, spender, approved)](#IERC6909-OperatorSet-address-address-bool-) +- [Transfer(caller, sender, receiver, id, amount)](#IERC6909-Transfer-address-address-address-uint256-uint256-) +#### IERC165 [!toc] +
+
+ + + +
+
+

name(uint256 id) → string

+
+

external

+# +
+
+
+ +Returns the name of the token of type `id`. + +
+
+ + + +
+
+

symbol(uint256 id) → string

+
+

external

+# +
+
+
+ +Returns the ticker symbol of the token of type `id`.
- +
-

transferFrom(address sender, address receiver, uint256 id, uint256 amount) → bool

+

decimals(uint256 id) → uint8

external

-# +#
-Transfers `amount` of token type `id` from `sender` to `receiver`. - -Must return true. +Returns the number of decimals for the token of type `id`.
- + + +
+ +## `IERC6909ContentURI` + + + + -
-
-

Approval(address indexed owner, address indexed spender, uint256 indexed id, uint256 amount)

-
-

event

-# -
-
+```solidity +import "@openzeppelin/contracts/interfaces/IERC6909.sol"; +``` -Emitted when the allowance of a `spender` for an `owner` is set for a token of type `id`. -The new allowance is `amount`. +Optional extension of [`IERC6909`](#IERC6909) that adds content URI functions. + +
+

Functions

+
+- [contractURI()](#IERC6909ContentURI-contractURI--) +- [tokenURI(id)](#IERC6909ContentURI-tokenURI-uint256-) +#### IERC6909 [!toc] +- [balanceOf(owner, id)](#IERC6909-balanceOf-address-uint256-) +- [allowance(owner, spender, id)](#IERC6909-allowance-address-address-uint256-) +- [isOperator(owner, spender)](#IERC6909-isOperator-address-address-) +- [approve(spender, id, amount)](#IERC6909-approve-address-uint256-uint256-) +- [setOperator(spender, approved)](#IERC6909-setOperator-address-bool-) +- [transfer(receiver, id, amount)](#IERC6909-transfer-address-uint256-uint256-) +- [transferFrom(sender, receiver, id, amount)](#IERC6909-transferFrom-address-address-uint256-uint256-) +#### IERC165 [!toc] +- [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) +
+
+
+

Events

+
+#### IERC6909 [!toc] +- [Approval(owner, spender, id, amount)](#IERC6909-Approval-address-address-uint256-uint256-) +- [OperatorSet(owner, spender, approved)](#IERC6909-OperatorSet-address-address-bool-) +- [Transfer(caller, sender, receiver, id, amount)](#IERC6909-Transfer-address-address-address-uint256-uint256-) +#### IERC165 [!toc]
- + +
-

OperatorSet(address indexed owner, address indexed spender, bool approved)

+

contractURI() → string

-

event

-# +

external

+#
-
-Emitted when `owner` grants or revokes operator status for a `spender`. +Returns URI for the contract.
- + +
-

Transfer(address caller, address indexed sender, address indexed receiver, uint256 indexed id, uint256 amount)

+

tokenURI(uint256 id) → string

-

event

-# +

external

+#
-
-Emitted when `amount` tokens of type `id` are moved from `sender` to `receiver` initiated by `caller`. +Returns the URI for the token of type `id`.
- +
-## `IERC6909Metadata` +## `IERC6909TokenSupply` - + @@ -2095,14 +1879,12 @@ Emitted when `amount` tokens of type `id` are moved from `sender` to `receiver` import "@openzeppelin/contracts/interfaces/IERC6909.sol"; ``` -Optional extension of [`IERC6909`](#IERC6909) that adds metadata functions. +Optional extension of [`IERC6909`](#IERC6909) that adds a token supply function.

Functions

-- [name(id)](#IERC6909Metadata-name-uint256-) -- [symbol(id)](#IERC6909Metadata-symbol-uint256-) -- [decimals(id)](#IERC6909Metadata-decimals-uint256-) +- [totalSupply(id)](#IERC6909TokenSupply-totalSupply-uint256-) #### IERC6909 [!toc] - [balanceOf(owner, id)](#IERC6909-balanceOf-address-uint256-) - [allowance(owner, spender, id)](#IERC6909-allowance-address-address-uint256-) @@ -2127,2847 +1909,3067 @@ Optional extension of [`IERC6909`](#IERC6909) that adds metadata functions.
- +
-

name(uint256 id) → string

+

totalSupply(uint256 id) → uint256

external

-# +#
-Returns the name of the token of type `id`. +Returns the total supply of the token of type `id`.
- + + +
+ +## `IERC7913SignatureVerifier` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/interfaces/IERC7913.sol"; +``` + +Signature verifier interface. + +
+

Functions

+
+- [verify(key, hash, signature)](#IERC7913SignatureVerifier-verify-bytes-bytes32-bytes-) +
+
+ +
-

symbol(uint256 id) → string

+

verify(bytes key, bytes32 hash, bytes signature) → bytes4

external

-# +#
-Returns the ticker symbol of the token of type `id`. +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
- + + +
+ +## `IERC1822Proxiable` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC1822.sol"; +``` + +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()](#IERC1822Proxiable-proxiableUUID--) +
+
+ +
-

decimals(uint256 id) → uint8

+

proxiableUUID() → bytes32

external

-# +#
-Returns the number of decimals for the token of type `id`. +Returns the storage slot that the proxiable contract assumes is being used to store the implementation +address. + + +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. +
- +
-## `IERC6909ContentURI` +## `PackedUserOperation` - +
```solidity -import "@openzeppelin/contracts/interfaces/IERC6909.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; ``` -Optional extension of [`IERC6909`](#IERC6909) that adds content URI functions. +A [user operation](https://github.com/ethereum/ercs/blob/master/ERCS/erc-4337.md#useroperation) is composed of the following elements: +- `sender` (`address`): The account making the operation +- `nonce` (`uint256`): Anti-replay parameter (see “Semi-abstracted Nonce Support” ) +- `factory` (`address`): account factory, only for new accounts +- `factoryData` (`bytes`): data for account factory (only if account factory exists) +- `callData` (`bytes`): The data to pass to the sender during the main execution call +- `callGasLimit` (`uint256`): The amount of gas to allocate the main execution call +- `verificationGasLimit` (`uint256`): The amount of gas to allocate for the verification step +- `preVerificationGas` (`uint256`): Extra gas to pay the bundler +- `maxFeePerGas` (`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 code +- `paymasterPostOpGasLimit` (`uint256`): The amount of gas to allocate for the paymaster post-operation code +- `paymasterData` (`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) + For EntryPoint v0.9+, may optionally include `paymasterSignature` at the end: + `paymaster || paymasterVerificationGasLimit || paymasterPostOpGasLimit || paymasterData || paymasterSignature || paymasterSignatureSize || PAYMASTER_SIG_MAGIC` +- `signature` (`bytes`) + + + +
+ +## `IAggregator` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; +``` + +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 [ERC-7766](https://eips.ethereum.org/EIPS/eip-7766)

Functions

-- [contractURI()](#IERC6909ContentURI-contractURI--) -- [tokenURI(id)](#IERC6909ContentURI-tokenURI-uint256-) -#### IERC6909 [!toc] -- [balanceOf(owner, id)](#IERC6909-balanceOf-address-uint256-) -- [allowance(owner, spender, id)](#IERC6909-allowance-address-address-uint256-) -- [isOperator(owner, spender)](#IERC6909-isOperator-address-address-) -- [approve(spender, id, amount)](#IERC6909-approve-address-uint256-uint256-) -- [setOperator(spender, approved)](#IERC6909-setOperator-address-bool-) -- [transfer(receiver, id, amount)](#IERC6909-transfer-address-uint256-uint256-) -- [transferFrom(sender, receiver, id, amount)](#IERC6909-transferFrom-address-address-uint256-uint256-) -#### IERC165 [!toc] -- [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) +- [validateUserOpSignature(userOp)](#IAggregator-validateUserOpSignature-struct-PackedUserOperation-) +- [aggregateSignatures(userOps)](#IAggregator-aggregateSignatures-struct-PackedUserOperation---) +- [validateSignatures(userOps, signature)](#IAggregator-validateSignatures-struct-PackedUserOperation---bytes-) +
+
+ + + +
+
+

validateUserOpSignature(struct PackedUserOperation userOp) → bytes sigForUserOp

+
+

external

+#
+
+ +Validates the signature for a user operation. +Returns an alternative signature that should be used during bundling. -
-

Events

-
-#### IERC6909 [!toc] -- [Approval(owner, spender, id, amount)](#IERC6909-Approval-address-address-uint256-uint256-) -- [OperatorSet(owner, spender, approved)](#IERC6909-OperatorSet-address-address-bool-) -- [Transfer(caller, sender, receiver, id, amount)](#IERC6909-Transfer-address-address-address-uint256-uint256-) -#### IERC165 [!toc]
- +
-

contractURI() → string

+

aggregateSignatures(struct PackedUserOperation[] userOps) → bytes aggregatesSignature

external

-# +#
-Returns URI for the contract. +Returns an aggregated signature for a batch of user operation's signatures.
- +
-

tokenURI(uint256 id) → string

+

validateSignatures(struct PackedUserOperation[] userOps, bytes signature)

external

-# +#
-Returns the URI for the token of type `id`. +Validates that the aggregated signature is valid for the user operations. + +Requirements: + +- The aggregated signature MUST match the given list of operations.
- +
-## `IERC6909TokenSupply` +## `IEntryPointNonces` - +
```solidity -import "@openzeppelin/contracts/interfaces/IERC6909.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; ``` -Optional extension of [`IERC6909`](#IERC6909) that adds a token supply function. +Handle nonce management for accounts. -
-

Functions

-
-- [totalSupply(id)](#IERC6909TokenSupply-totalSupply-uint256-) -#### IERC6909 [!toc] -- [balanceOf(owner, id)](#IERC6909-balanceOf-address-uint256-) -- [allowance(owner, spender, id)](#IERC6909-allowance-address-address-uint256-) -- [isOperator(owner, spender)](#IERC6909-isOperator-address-address-) -- [approve(spender, id, amount)](#IERC6909-approve-address-uint256-uint256-) -- [setOperator(spender, approved)](#IERC6909-setOperator-address-bool-) -- [transfer(receiver, id, amount)](#IERC6909-transfer-address-uint256-uint256-) -- [transferFrom(sender, receiver, id, amount)](#IERC6909-transferFrom-address-address-uint256-uint256-) -#### IERC165 [!toc] -- [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) -
-
+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 [ERC-4337 semi-abstracted nonce support](https://eips.ethereum.org/EIPS/eip-4337#semi-abstracted-nonce-support).
-

Events

+

Functions

-#### IERC6909 [!toc] -- [Approval(owner, spender, id, amount)](#IERC6909-Approval-address-address-uint256-uint256-) -- [OperatorSet(owner, spender, approved)](#IERC6909-OperatorSet-address-address-bool-) -- [Transfer(caller, sender, receiver, id, amount)](#IERC6909-Transfer-address-address-address-uint256-uint256-) -#### IERC165 [!toc] +- [getNonce(sender, key)](#IEntryPointNonces-getNonce-address-uint192-)
- +
-

totalSupply(uint256 id) → uint256

+

getNonce(address sender, uint192 key) → uint256 nonce

external

-# +#
-Returns the total supply of the token of type `id`. +Returns the nonce for a `sender` account and a `key`. + +Nonces for a certain `key` are always increasing.
- +
-## `IERC7751` +## `IEntryPointStake` - +
```solidity -import "@openzeppelin/contracts/interfaces/IERC7751.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; ``` -Wrapping of bubbled up reverts -Interface of the [ERC-7751](https://eips.ethereum.org/EIPS/eip-7751) wrapping of bubbled up reverts. +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 [reputation, throttling and banning.](https://eips.ethereum.org/EIPS/eip-4337#reputation-scoring-and-throttlingbanning-for-global-entities))
-

Errors

+

Functions

-- [WrappedError(target, selector, reason, details)](#IERC7751-WrappedError-address-bytes4-bytes-bytes-) +- [balanceOf(account)](#IEntryPointStake-balanceOf-address-) +- [depositTo(account)](#IEntryPointStake-depositTo-address-) +- [withdrawTo(withdrawAddress, withdrawAmount)](#IEntryPointStake-withdrawTo-address-payable-uint256-) +- [addStake(unstakeDelaySec)](#IEntryPointStake-addStake-uint32-) +- [unlockStake()](#IEntryPointStake-unlockStake--) +- [withdrawStake(withdrawAddress)](#IEntryPointStake-withdrawStake-address-payable-)
- +
-

WrappedError(address target, bytes4 selector, bytes reason, bytes details)

+

balanceOf(address account) → uint256

-

error

-# +

external

+#
+Returns the balance of the account. +
- - -
- -## `IERC777` - - - - + +
+
+

depositTo(address account)

+
+

external

+#
+
+
-```solidity -import "@openzeppelin/contracts/interfaces/IERC777.sol"; -``` +Deposits `msg.value` to the account. -Interface of the ERC-777 Token standard as defined in the ERC. +
+
-This contract uses the -[ERC-1820 registry standard](https://eips.ethereum.org/EIPS/eip-1820) to let -token holders and recipients react to token movements by using setting implementers -for the associated interfaces in said registry. See [`IERC1820Registry`](#IERC1820Registry) and -[`IERC1820Implementer`](#IERC1820Implementer). + -
-

Functions

-
-- [name()](#IERC777-name--) -- [symbol()](#IERC777-symbol--) -- [granularity()](#IERC777-granularity--) -- [totalSupply()](#IERC777-totalSupply--) -- [balanceOf(owner)](#IERC777-balanceOf-address-) -- [send(recipient, amount, data)](#IERC777-send-address-uint256-bytes-) -- [burn(amount, data)](#IERC777-burn-uint256-bytes-) -- [isOperatorFor(operator, tokenHolder)](#IERC777-isOperatorFor-address-address-) -- [authorizeOperator(operator)](#IERC777-authorizeOperator-address-) -- [revokeOperator(operator)](#IERC777-revokeOperator-address-) -- [defaultOperators()](#IERC777-defaultOperators--) -- [operatorSend(sender, recipient, amount, data, operatorData)](#IERC777-operatorSend-address-address-uint256-bytes-bytes-) -- [operatorBurn(account, amount, data, operatorData)](#IERC777-operatorBurn-address-uint256-bytes-bytes-) +
+
+

withdrawTo(address payable withdrawAddress, uint256 withdrawAmount)

+
+

external

+#
+
+ +Withdraws `withdrawAmount` from the account to `withdrawAddress`. -
-

Events

-
-- [Minted(operator, to, amount, data, operatorData)](#IERC777-Minted-address-address-uint256-bytes-bytes-) -- [Burned(operator, from, amount, data, operatorData)](#IERC777-Burned-address-address-uint256-bytes-bytes-) -- [AuthorizedOperator(operator, tokenHolder)](#IERC777-AuthorizedOperator-address-address-) -- [RevokedOperator(operator, tokenHolder)](#IERC777-RevokedOperator-address-address-) -- [Sent(operator, from, to, amount, data, operatorData)](#IERC777-Sent-address-address-address-uint256-bytes-bytes-)
- +
-

name() → string

+

addStake(uint32 unstakeDelaySec)

external

-# +#
-Returns the name of the token. +Adds stake to the account with an unstake delay of `unstakeDelaySec`.
- +
-

symbol() → string

+

unlockStake()

external

-# +#
-Returns the symbol of the token, usually a shorter version of the -name. +Unlocks the stake of the account.
- +
-

granularity() → uint256

+

withdrawStake(address payable withdrawAddress)

external

-# +#
-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. +Withdraws the stake of the account to `withdrawAddress`. -For most token contracts, this value will equal 1. +
+
+ + + +
+ +## `IEntryPoint` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; +``` + +Entry point for user operations. + +User operations are validated and executed by this contract. + +
+

Functions

+
+- [handleOps(ops, beneficiary)](#IEntryPoint-handleOps-struct-PackedUserOperation---address-payable-) +- [handleAggregatedOps(opsPerAggregator, beneficiary)](#IEntryPoint-handleAggregatedOps-struct-IEntryPoint-UserOpsPerAggregator---address-payable-) +#### IEntryPointStake [!toc] +- [balanceOf(account)](#IEntryPointStake-balanceOf-address-) +- [depositTo(account)](#IEntryPointStake-depositTo-address-) +- [withdrawTo(withdrawAddress, withdrawAmount)](#IEntryPointStake-withdrawTo-address-payable-uint256-) +- [addStake(unstakeDelaySec)](#IEntryPointStake-addStake-uint32-) +- [unlockStake()](#IEntryPointStake-unlockStake--) +- [withdrawStake(withdrawAddress)](#IEntryPointStake-withdrawStake-address-payable-) +#### IEntryPointNonces [!toc] +- [getNonce(sender, key)](#IEntryPointNonces-getNonce-address-uint192-) +
+
+
+

Errors

+
+- [FailedOp(opIndex, reason)](#IEntryPoint-FailedOp-uint256-string-) +- [FailedOpWithRevert(opIndex, reason, inner)](#IEntryPoint-FailedOpWithRevert-uint256-string-bytes-) +#### IEntryPointStake [!toc] +#### IEntryPointNonces [!toc]
- +
-

totalSupply() → uint256

+

handleOps(struct PackedUserOperation[] ops, address payable beneficiary)

external

-# +#
-Returns the amount of tokens in existence. +Executes a batch of user operations.
- +
-

balanceOf(address owner) → uint256

+

handleAggregatedOps(struct IEntryPoint.UserOpsPerAggregator[] opsPerAggregator, address payable beneficiary)

external

-# +#
-Returns the amount of tokens owned by an account (`owner`). +Executes a batch of aggregated user operations per aggregator.
- +
-

send(address recipient, uint256 amount, bytes data)

+

FailedOp(uint256 opIndex, string reason)

-

external

-# +

error

+#
-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`](#IERC777Sender) and [`IERC777Recipient`](#IERC777Recipient). - -Emits a [`IERC777.Sent`](#IERC777-Sent-address-address-address-uint256-bytes-bytes-) event. - -Requirements - -- the caller must have at least `amount` tokens. -- `recipient` cannot be the zero address. -- if `recipient` is a contract, it must implement the [`IERC777Recipient`](#IERC777Recipient) -interface. +A user operation at `opIndex` failed with `reason`.
- +
-

burn(uint256 amount, bytes data)

+

FailedOpWithRevert(uint256 opIndex, string reason, bytes inner)

-

external

-# +

error

+#
-Destroys `amount` tokens from the caller's account, reducing the -total supply. +A user operation at `opIndex` failed with `reason` and `inner` returned data. -If a send hook is registered for the caller, the corresponding function -will be called with `data` and empty `operatorData`. See [`IERC777Sender`](#IERC777Sender). +
+
-Emits a [`IERC777.Burned`](#IERC777-Burned-address-address-uint256-bytes-bytes-) event. + -Requirements +
-- the caller must have at least `amount` tokens. +## `IAccount` + + + + + +
+```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; +``` + +Base interface for an ERC-4337 account. + +
+

Functions

+
+- [validateUserOp(userOp, userOpHash, missingAccountFunds)](#IAccount-validateUserOp-struct-PackedUserOperation-bytes32-uint256-)
- +
-

isOperatorFor(address operator, address tokenHolder) → bool

+

validateUserOp(struct PackedUserOperation userOp, bytes32 userOpHash, uint256 missingAccountFunds) → uint256 validationData

external

-# +#
-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. +Validates a user operation. -See [`IERC777.operatorSend`](#IERC777-operatorSend-address-address-uint256-bytes-bytes-) and [`IERC777.operatorBurn`](#IERC777-operatorBurn-address-uint256-bytes-bytes-). +* 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 contract +- `validUntil` (`uint48`): The UserOp is valid only up to this time. Zero for “infinite”. +- `validAfter` (`uint48`): The UserOp is valid only after this time. -
-
-

authorizeOperator(address operator)

-
-

external

-#
-
-Make an account an operator of the caller. + -See [`IERC777.isOperatorFor`](#IERC777-isOperatorFor-address-address-). +
-Emits an [`IERC777.AuthorizedOperator`](#IERC777-AuthorizedOperator-address-address-) event. +## `IAccountExecute` -Requirements + + + -- `operator` cannot be calling address. +
+ +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; +``` + +Support for executing user operations by prepending the [`IAccountExecute.executeUserOp`](#IAccountExecute-executeUserOp-struct-PackedUserOperation-bytes32-) function selector +to the UserOperation's `callData`. +
+

Functions

+
+- [executeUserOp(userOp, userOpHash)](#IAccountExecute-executeUserOp-struct-PackedUserOperation-bytes32-)
- +
-

revokeOperator(address operator)

+

executeUserOp(struct PackedUserOperation userOp, bytes32 userOpHash)

external

-# +#
-Revoke an account's operator status for the caller. +Executes a user operation. -See [`IERC777.isOperatorFor`](#IERC777-isOperatorFor-address-address-) and [`IERC777.defaultOperators`](#IERC777-defaultOperators--). +
+
-Emits a [`IERC777.RevokedOperator`](#IERC777-RevokedOperator-address-address-) event. + -Requirements +
-- `operator` cannot be calling address. +## `IPaymaster` + + + + +
+ +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; +``` + +Interface for a paymaster contract that agrees to pay for the gas costs of a user operation. + + +A paymaster must hold a stake to cover the required entrypoint stake and also the gas for the transaction. + + +
+

Functions

+
+- [validatePaymasterUserOp(userOp, userOpHash, maxCost)](#IPaymaster-validatePaymasterUserOp-struct-PackedUserOperation-bytes32-uint256-) +- [postOp(mode, context, actualGasCost, actualUserOpFeePerGas)](#IPaymaster-postOp-enum-IPaymaster-PostOpMode-bytes-uint256-uint256-)
- +
-

defaultOperators() → address[]

+

validatePaymasterUserOp(struct PackedUserOperation userOp, bytes32 userOpHash, uint256 maxCost) → bytes context, uint256 validationData

external

-# +#
-Returns the list of default operators. These accounts are operators -for all token holders, even if [`IERC777.authorizeOperator`](#IERC777-authorizeOperator-address-) was never called on -them. +Validates whether the paymaster is willing to pay for the user operation. See +[`IAccount.validateUserOp`](#IAccount-validateUserOp-struct-PackedUserOperation-bytes32-uint256-) for additional information on the return value. -This list is immutable, but individual holders may revoke these via -[`IERC777.revokeOperator`](#IERC777-revokeOperator-address-), in which case [`IERC777.isOperatorFor`](#IERC777-isOperatorFor-address-address-) will return false. + +Bundlers will reject this method if it modifies the state, unless it's whitelisted. +
- +
-

operatorSend(address sender, address recipient, uint256 amount, bytes data, bytes operatorData)

+

postOp(enum IPaymaster.PostOpMode mode, bytes context, uint256 actualGasCost, uint256 actualUserOpFeePerGas)

external

-# +#
-Moves `amount` tokens from `sender` to `recipient`. The caller must -be an operator of `sender`. +Verifies the sender is the entrypoint. -If send or receive hooks are registered for `sender` and `recipient`, -the corresponding functions will be called with `data` and -`operatorData`. See [`IERC777Sender`](#IERC777Sender) and [`IERC777Recipient`](#IERC777Recipient). +
+
-Emits a [`IERC777.Sent`](#IERC777-Sent-address-address-address-uint256-bytes-bytes-) event. + -Requirements +
-- `sender` cannot be the zero address. -- `sender` must have at least `amount` tokens. -- the caller must be an operator for `sender`. -- `recipient` cannot be the zero address. -- if `recipient` is a contract, it must implement the [`IERC777Recipient`](#IERC777Recipient) -interface. +## `IERC20Errors` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC6093.sol"; +``` + +Standard ERC-20 Errors +Interface of the [ERC-6093](https://eips.ethereum.org/EIPS/eip-6093) custom errors for ERC-20 tokens. +
+

Errors

+
+- [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) +- [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) +- [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) +- [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) +- [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) +- [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-)
- +
-

operatorBurn(address account, uint256 amount, bytes data, bytes operatorData)

+

ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed)

-

external

-# +

error

+#
-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`](#IERC777Sender). - -Emits a [`IERC777.Burned`](#IERC777-Burned-address-address-uint256-bytes-bytes-) event. - -Requirements - -- `account` cannot be the zero address. -- `account` must have at least `amount` tokens. -- the caller must be an operator for `account`. +Indicates an error related to the current `balance` of a `sender`. Used in transfers.
- +
-

Minted(address indexed operator, address indexed to, uint256 amount, bytes data, bytes operatorData)

+

ERC20InvalidSender(address sender)

-

event

-# +

error

+#
-
-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. +Indicates a failure with the token `sender`. Used in transfers.
- + +
-

Burned(address indexed operator, address indexed from, uint256 amount, bytes data, bytes operatorData)

+

ERC20InvalidReceiver(address receiver)

-

event

-# +

error

+#
-
-Emitted when `operator` destroys `amount` tokens from `account`. - -Note that some additional user `data` and `operatorData` can be logged in the event. +Indicates a failure with the token `receiver`. Used in transfers.
- + +
-

AuthorizedOperator(address indexed operator, address indexed tokenHolder)

+

ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed)

-

event

-# +

error

+#
-
-Emitted when `operator` is made operator for `tokenHolder`. +Indicates a failure with the `spender`’s `allowance`. Used in transfers.
- + +
-

RevokedOperator(address indexed operator, address indexed tokenHolder)

+

ERC20InvalidApprover(address approver)

-

event

-# +

error

+#
-
-Emitted when `operator` is revoked its operator status for `tokenHolder`. +Indicates a failure with the `approver` of a token to be approved. Used in approvals.
- + +
-

Sent(address indexed operator, address indexed from, address indexed to, uint256 amount, bytes data, bytes operatorData)

+

ERC20InvalidSpender(address spender)

-

event

-# +

error

+#
-
+Indicates a failure with the `spender` to be approved. Used in approvals. +
- +
-## `IERC777Recipient` +## `IERC721Errors` - +
```solidity -import "@openzeppelin/contracts/interfaces/IERC777Recipient.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC6093.sol"; ``` -Interface of the ERC-777 Tokens Recipient standard as defined in the ERC. - -Accounts can be notified of [`IERC777`](#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 -[ERC-1820 global registry](https://eips.ethereum.org/EIPS/eip-1820). - -See [`IERC1820Registry`](#IERC1820Registry) and [`IERC1820Implementer`](#IERC1820Implementer). +Standard ERC-721 Errors +Interface of the [ERC-6093](https://eips.ethereum.org/EIPS/eip-6093) custom errors for ERC-721 tokens.
-

Functions

+

Errors

-- [tokensReceived(operator, from, to, amount, userData, operatorData)](#IERC777Recipient-tokensReceived-address-address-address-uint256-bytes-bytes-) +- [ERC721InvalidOwner(owner)](#IERC721Errors-ERC721InvalidOwner-address-) +- [ERC721NonexistentToken(tokenId)](#IERC721Errors-ERC721NonexistentToken-uint256-) +- [ERC721IncorrectOwner(sender, tokenId, owner)](#IERC721Errors-ERC721IncorrectOwner-address-uint256-address-) +- [ERC721InvalidSender(sender)](#IERC721Errors-ERC721InvalidSender-address-) +- [ERC721InvalidReceiver(receiver)](#IERC721Errors-ERC721InvalidReceiver-address-) +- [ERC721InsufficientApproval(operator, tokenId)](#IERC721Errors-ERC721InsufficientApproval-address-uint256-) +- [ERC721InvalidApprover(approver)](#IERC721Errors-ERC721InvalidApprover-address-) +- [ERC721InvalidOperator(operator)](#IERC721Errors-ERC721InvalidOperator-address-)
- +
-

tokensReceived(address operator, address from, address to, uint256 amount, bytes userData, bytes operatorData)

+

ERC721InvalidOwner(address owner)

-

external

-# +

error

+#
-Called by an [`IERC777`](#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`](#IERC777-balanceOf-address-), etc., can be used to query the post-operation state. - -This function may revert to prevent the operation from being executed. +Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-721. +Used in balance queries.
- - -
- -## `IERC777Sender` - - - - + +
+
+

ERC721NonexistentToken(uint256 tokenId)

+
+

error

+#
+
+
-```solidity -import "@openzeppelin/contracts/interfaces/IERC777Sender.sol"; -``` - -Interface of the ERC-777 Tokens Sender standard as defined in the ERC. - -[`IERC777`](#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 -[ERC-1820 global registry](https://eips.ethereum.org/EIPS/eip-1820). - -See [`IERC1820Registry`](#IERC1820Registry) and [`IERC1820Implementer`](#IERC1820Implementer). +Indicates a `tokenId` whose `owner` is the zero address. -
-

Functions

-
-- [tokensToSend(operator, from, to, amount, userData, operatorData)](#IERC777Sender-tokensToSend-address-address-address-uint256-bytes-bytes-)
- +
-

tokensToSend(address operator, address from, address to, uint256 amount, bytes userData, bytes operatorData)

+

ERC721IncorrectOwner(address sender, uint256 tokenId, address owner)

-

external

-# +

error

+#
-Called by an [`IERC777`](#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. +Indicates an error related to the ownership over a particular token. Used in transfers. -This call occurs _before_ the token contract's state is updated, so -[`IERC777.balanceOf`](#IERC777-balanceOf-address-), etc., can be used to query the pre-operation state. +
+
-This function may revert to prevent the operation from being executed. + +
+
+

ERC721InvalidSender(address sender)

+
+

error

+#
+
- - -
+Indicates a failure with the token `sender`. Used in transfers. -## `IERC7913SignatureVerifier` +
+
- - - + +
+
+

ERC721InvalidReceiver(address receiver)

+
+

error

+#
+
+
-```solidity -import "@openzeppelin/contracts/interfaces/IERC7913.sol"; -``` - -Signature verifier interface. +Indicates a failure with the token `receiver`. Used in transfers. -
-

Functions

-
-- [verify(key, hash, signature)](#IERC7913SignatureVerifier-verify-bytes-bytes32-bytes-)
- +
-

verify(bytes key, bytes32 hash, bytes signature) → bytes4

+

ERC721InsufficientApproval(address operator, uint256 tokenId)

-

external

-# +

error

+#
-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 +Indicates a failure with the `operator`’s approval. Used in transfers.
- - -
- -## `IERC1822Proxiable` - - - - + +
+
+

ERC721InvalidApprover(address approver)

+
+

error

+#
+
+
-```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC1822.sol"; -``` - -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. +Indicates a failure with the `approver` of a token to be approved. Used in approvals. -
-

Functions

-
-- [proxiableUUID()](#IERC1822Proxiable-proxiableUUID--)
- +
-

proxiableUUID() → bytes32

+

ERC721InvalidOperator(address operator)

-

external

-# +

error

+#
-Returns the storage slot that the proxiable contract assumes is being used to store the implementation -address. - - -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. - +Indicates a failure with the `operator` to be approved. Used in approvals.
- +
-## `PackedUserOperation` +## `IERC1155Errors` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC6093.sol"; ``` -A [user operation](https://github.com/ethereum/ercs/blob/master/ERCS/erc-4337.md#useroperation) is composed of the following elements: -- `sender` (`address`): The account making the operation -- `nonce` (`uint256`): Anti-replay parameter (see “Semi-abstracted Nonce Support” ) -- `factory` (`address`): account factory, only for new accounts -- `factoryData` (`bytes`): data for account factory (only if account factory exists) -- `callData` (`bytes`): The data to pass to the sender during the main execution call -- `callGasLimit` (`uint256`): The amount of gas to allocate the main execution call -- `verificationGasLimit` (`uint256`): The amount of gas to allocate for the verification step -- `preVerificationGas` (`uint256`): Extra gas to pay the bundler -- `maxFeePerGas` (`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 code -- `paymasterPostOpGasLimit` (`uint256`): The amount of gas to allocate for the paymaster post-operation code -- `paymasterData` (`bytes`): Data for paymaster (only if paymaster exists) -- `signature` (`bytes`): Data passed into the account to verify authorization +Standard ERC-1155 Errors +Interface of the [ERC-6093](https://eips.ethereum.org/EIPS/eip-6093) custom errors for ERC-1155 tokens. + +
+

Errors

+
+- [ERC1155InsufficientBalance(sender, balance, needed, tokenId)](#IERC1155Errors-ERC1155InsufficientBalance-address-uint256-uint256-uint256-) +- [ERC1155InvalidSender(sender)](#IERC1155Errors-ERC1155InvalidSender-address-) +- [ERC1155InvalidReceiver(receiver)](#IERC1155Errors-ERC1155InvalidReceiver-address-) +- [ERC1155MissingApprovalForAll(operator, owner)](#IERC1155Errors-ERC1155MissingApprovalForAll-address-address-) +- [ERC1155InvalidApprover(approver)](#IERC1155Errors-ERC1155InvalidApprover-address-) +- [ERC1155InvalidOperator(operator)](#IERC1155Errors-ERC1155InvalidOperator-address-) +- [ERC1155InvalidArrayLength(idsLength, valuesLength)](#IERC1155Errors-ERC1155InvalidArrayLength-uint256-uint256-) +
+
-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`) + - +
+
+

ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId)

+
+

error

+# +
+
+
-
+Indicates an error related to the current `balance` of a `sender`. Used in transfers. -## `IAggregator` +
+
- - - + +
+
+

ERC1155InvalidSender(address sender)

+
+

error

+#
+
+
-```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; -``` +Indicates a failure with the token `sender`. Used in transfers. -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. +
+
+

ERC1155InvalidReceiver(address receiver)

+
+

error

+# +
+
+
-See [ERC-7766](https://eips.ethereum.org/EIPS/eip-7766) +Indicates a failure with the token `receiver`. Used in transfers. -
-

Functions

-
-- [validateUserOpSignature(userOp)](#IAggregator-validateUserOpSignature-struct-PackedUserOperation-) -- [aggregateSignatures(userOps)](#IAggregator-aggregateSignatures-struct-PackedUserOperation---) -- [validateSignatures(userOps, signature)](#IAggregator-validateSignatures-struct-PackedUserOperation---bytes-)
- +
-

validateUserOpSignature(struct PackedUserOperation userOp) → bytes sigForUserOp

+

ERC1155MissingApprovalForAll(address operator, address owner)

-

external

-# +

error

+#
-Validates the signature for a user operation. -Returns an alternative signature that should be used during bundling. +Indicates a failure with the `operator`’s approval. Used in transfers.
- +
-

aggregateSignatures(struct PackedUserOperation[] userOps) → bytes aggregatesSignature

+

ERC1155InvalidApprover(address approver)

-

external

-# +

error

+#
-Returns an aggregated signature for a batch of user operation's signatures. +Indicates a failure with the `approver` of a token to be approved. Used in approvals.
- +
-

validateSignatures(struct PackedUserOperation[] userOps, bytes signature)

+

ERC1155InvalidOperator(address operator)

-

external

-# +

error

+#
-Validates that the aggregated signature is valid for the user operations. +Indicates a failure with the `operator` to be approved. Used in approvals. -Requirements: +
+
-- The aggregated signature MUST match the given list of operations. + +
+
+

ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength)

+
+

error

+#
+
- +Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. +Used in batch transfers. + +
+
+ +
-## `IEntryPointNonces` +## `VALIDATION_SUCCESS` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; ``` -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 [ERC-4337 semi-abstracted nonce support](https://eips.ethereum.org/EIPS/eip-4337#semi-abstracted-nonce-support). +## `VALIDATION_FAILED` + + + + -
-

Functions

-
-- [getNonce(sender, key)](#IEntryPointNonces-getNonce-address-uint192-) -
- +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +``` + + + +
+ +## `MODULE_TYPE_VALIDATOR` + + + + -
-
-

getNonce(address sender, uint192 key) → uint256 nonce

-
-

external

-# -
-
-Returns the nonce for a `sender` account and a `key`. +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +``` -Nonces for a certain `key` are always increasing. + + +
+ +## `MODULE_TYPE_EXECUTOR` + + + +
+ +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +``` + + + +
+ +## `MODULE_TYPE_FALLBACK` + + + + +
- +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +``` + +
-## `IEntryPointStake` +## `MODULE_TYPE_HOOK` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; ``` -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 [reputation, throttling and banning.](https://eips.ethereum.org/EIPS/eip-4337#reputation-scoring-and-throttlingbanning-for-global-entities)) +
+ +## `IERC7579Module` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +``` + +Minimal configuration interface for ERC-7579 modules

Functions

-- [balanceOf(account)](#IEntryPointStake-balanceOf-address-) -- [depositTo(account)](#IEntryPointStake-depositTo-address-) -- [withdrawTo(withdrawAddress, withdrawAmount)](#IEntryPointStake-withdrawTo-address-payable-uint256-) -- [addStake(unstakeDelaySec)](#IEntryPointStake-addStake-uint32-) -- [unlockStake()](#IEntryPointStake-unlockStake--) -- [withdrawStake(withdrawAddress)](#IEntryPointStake-withdrawStake-address-payable-) +- [onInstall(data)](#IERC7579Module-onInstall-bytes-) +- [onUninstall(data)](#IERC7579Module-onUninstall-bytes-) +- [isModuleType(moduleTypeId)](#IERC7579Module-isModuleType-uint256-)
- +
-

balanceOf(address account) → uint256

+

onInstall(bytes data)

external

-# +#
-Returns the balance of the account. +This function is called by the smart account during installation of the module
- +
-

depositTo(address account)

+

onUninstall(bytes data)

external

-# +#
-Deposits `msg.value` to the account. +This function is called by the smart account during uninstallation of the module
- +
-

withdrawTo(address payable withdrawAddress, uint256 withdrawAmount)

+

isModuleType(uint256 moduleTypeId) → bool

external

-# +#
-Withdraws `withdrawAmount` from the account to `withdrawAddress`. +Returns boolean value if module is a certain type
- + + +
+ +## `IERC7579Validator` + + + + -
-
-

addStake(uint32 unstakeDelaySec)

-
-

external

-# -
-
-Adds stake to the account with an unstake delay of `unstakeDelaySec`. +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +``` + +ERC-7579 Validation module (type 1). + +A module that implements logic to validate user operations and signatures. +
+

Functions

+
+- [validateUserOp(userOp, userOpHash)](#IERC7579Validator-validateUserOp-struct-PackedUserOperation-bytes32-) +- [isValidSignatureWithSender(sender, hash, signature)](#IERC7579Validator-isValidSignatureWithSender-address-bytes32-bytes-) +#### IERC7579Module [!toc] +- [onInstall(data)](#IERC7579Module-onInstall-bytes-) +- [onUninstall(data)](#IERC7579Module-onUninstall-bytes-) +- [isModuleType(moduleTypeId)](#IERC7579Module-isModuleType-uint256-)
- +
-

unlockStake()

+

validateUserOp(struct PackedUserOperation userOp, bytes32 userOpHash) → uint256

external

-# +#
-Unlocks the stake of the account. +Validates a UserOperation
- +
-

withdrawStake(address payable withdrawAddress)

+

isValidSignatureWithSender(address sender, bytes32 hash, bytes signature) → bytes4

external

-# +#
-Withdraws the stake of the account to `withdrawAddress`. +Validates a signature using ERC-1271
- +
-## `IEntryPoint` +## `IERC7579Hook` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; ``` -Entry point for user operations. +ERC-7579 Hooks module (type 4). -User operations are validated and executed by this contract. +A module that implements logic to execute before and after the account executes a user operation, +either individually or batched.

Functions

-- [handleOps(ops, beneficiary)](#IEntryPoint-handleOps-struct-PackedUserOperation---address-payable-) -- [handleAggregatedOps(opsPerAggregator, beneficiary)](#IEntryPoint-handleAggregatedOps-struct-IEntryPoint-UserOpsPerAggregator---address-payable-) -#### IEntryPointStake [!toc] -- [balanceOf(account)](#IEntryPointStake-balanceOf-address-) -- [depositTo(account)](#IEntryPointStake-depositTo-address-) -- [withdrawTo(withdrawAddress, withdrawAmount)](#IEntryPointStake-withdrawTo-address-payable-uint256-) -- [addStake(unstakeDelaySec)](#IEntryPointStake-addStake-uint32-) -- [unlockStake()](#IEntryPointStake-unlockStake--) -- [withdrawStake(withdrawAddress)](#IEntryPointStake-withdrawStake-address-payable-) -#### IEntryPointNonces [!toc] -- [getNonce(sender, key)](#IEntryPointNonces-getNonce-address-uint192-) -
-
- -
-

Errors

-
-- [FailedOp(opIndex, reason)](#IEntryPoint-FailedOp-uint256-string-) -- [FailedOpWithRevert(opIndex, reason, inner)](#IEntryPoint-FailedOpWithRevert-uint256-string-bytes-) -#### IEntryPointStake [!toc] -#### IEntryPointNonces [!toc] +- [preCheck(msgSender, value, msgData)](#IERC7579Hook-preCheck-address-uint256-bytes-) +- [postCheck(hookData)](#IERC7579Hook-postCheck-bytes-) +#### IERC7579Module [!toc] +- [onInstall(data)](#IERC7579Module-onInstall-bytes-) +- [onUninstall(data)](#IERC7579Module-onUninstall-bytes-) +- [isModuleType(moduleTypeId)](#IERC7579Module-isModuleType-uint256-)
- +
-

handleOps(struct PackedUserOperation[] ops, address payable beneficiary)

+

preCheck(address msgSender, uint256 value, bytes msgData) → bytes hookData

external

-# +#
-Executes a batch of user operations. +Called by the smart account before execution
- +
-

handleAggregatedOps(struct IEntryPoint.UserOpsPerAggregator[] opsPerAggregator, address payable beneficiary)

+

postCheck(bytes hookData)

external

-# +#
-Executes a batch of aggregated user operations per aggregator. +Called by the smart account after execution
- - -
-
-

FailedOp(uint256 opIndex, string reason)

-
-

error

-# -
-
-
+ -A user operation at `opIndex` failed with `reason`. +
-
-
+## `Execution` - + + + -
-
-

FailedOpWithRevert(uint256 opIndex, string reason, bytes inner)

-
-

error

-#
-
-
-A user operation at `opIndex` failed with `reason` and `inner` returned data. - -
-
+```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +``` - +
-## `IAccount` +## `IERC7579Execution` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; ``` -Base interface for an ERC-4337 account. +ERC-7579 Execution. + +Accounts should implement this interface so that the Entrypoint and ERC-7579 modules can execute operations.

Functions

-- [validateUserOp(userOp, userOpHash, missingAccountFunds)](#IAccount-validateUserOp-struct-PackedUserOperation-bytes32-uint256-) +- [execute(mode, executionCalldata)](#IERC7579Execution-execute-bytes32-bytes-) +- [executeFromExecutor(mode, executionCalldata)](#IERC7579Execution-executeFromExecutor-bytes32-bytes-)
- +
-

validateUserOp(struct PackedUserOperation userOp, bytes32 userOpHash, uint256 missingAccountFunds) → uint256 validationData

+

execute(bytes32 mode, bytes executionCalldata)

external

-# +#
-Validates a user operation. +Executes a transaction on behalf of the account. -* 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 contract -- `validUntil` (`uint48`): The UserOp is valid only up to this time. Zero for “infinite”. -- `validAfter` (`uint48`): The UserOp is valid only after this time. +
+
+

executeFromExecutor(bytes32 mode, bytes executionCalldata) → bytes[] returnData

+
+

external

+# +
+
+
+ +Executes a transaction on behalf of the account. + This function is intended to be called by Executor Modules
- +
-## `IAccountExecute` +## `IERC7579AccountConfig` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; ``` -Support for executing user operations by prepending the [`IAccountExecute.executeUserOp`](#IAccountExecute-executeUserOp-struct-PackedUserOperation-bytes32-) function selector -to the UserOperation's `callData`. +ERC-7579 Account Config. + +Accounts should implement this interface to expose information that identifies the account, supported modules and capabilities.

Functions

-- [executeUserOp(userOp, userOpHash)](#IAccountExecute-executeUserOp-struct-PackedUserOperation-bytes32-) +- [accountId()](#IERC7579AccountConfig-accountId--) +- [supportsExecutionMode(encodedMode)](#IERC7579AccountConfig-supportsExecutionMode-bytes32-) +- [supportsModule(moduleTypeId)](#IERC7579AccountConfig-supportsModule-uint256-)
- +
-

executeUserOp(struct PackedUserOperation userOp, bytes32 userOpHash)

+

accountId() → string accountImplementationId

external

-# +#
-Executes a user operation. - -
-
- - - -
- -## `IPaymaster` - - - - - -
- -```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; -``` - -Interface for a paymaster contract that agrees to pay for the gas costs of a user operation. - - -A paymaster must hold a stake to cover the required entrypoint stake and also the gas for the transaction. - +Returns the account id of the smart account -
-

Functions

-
-- [validatePaymasterUserOp(userOp, userOpHash, maxCost)](#IPaymaster-validatePaymasterUserOp-struct-PackedUserOperation-bytes32-uint256-) -- [postOp(mode, context, actualGasCost, actualUserOpFeePerGas)](#IPaymaster-postOp-enum-IPaymaster-PostOpMode-bytes-uint256-uint256-)
- +
-

validatePaymasterUserOp(struct PackedUserOperation userOp, bytes32 userOpHash, uint256 maxCost) → bytes context, uint256 validationData

+

supportsExecutionMode(bytes32 encodedMode) → bool

external

-# +#
-Validates whether the paymaster is willing to pay for the user operation. See -[`IAccount.validateUserOp`](#IAccount-validateUserOp-struct-PackedUserOperation-bytes32-uint256-) for additional information on the return value. - - -Bundlers will reject this method if it modifies the state, unless it's whitelisted. - +Function to check if the account supports a certain execution mode (see above)
- +
-

postOp(enum IPaymaster.PostOpMode mode, bytes context, uint256 actualGasCost, uint256 actualUserOpFeePerGas)

+

supportsModule(uint256 moduleTypeId) → bool

external

-# +#
-Verifies the sender is the entrypoint. +Function to check if the account supports a certain module typeId
- +
-## `IERC20Errors` +## `IERC7579ModuleConfig` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC6093.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; ``` -Standard ERC-20 Errors -Interface of the [ERC-6093](https://eips.ethereum.org/EIPS/eip-6093) custom errors for ERC-20 tokens. - -
-

Errors

-
-- [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) -- [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) -- [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) -- [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) -- [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) -- [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -
-
+ERC-7579 Module Config. - +Accounts should implement this interface to allow installing and uninstalling modules. -
-
-

ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed)

-
-

error

-# +
+

Functions

+
+- [installModule(moduleTypeId, module, initData)](#IERC7579ModuleConfig-installModule-uint256-address-bytes-) +- [uninstallModule(moduleTypeId, module, deInitData)](#IERC7579ModuleConfig-uninstallModule-uint256-address-bytes-) +- [isModuleInstalled(moduleTypeId, module, additionalContext)](#IERC7579ModuleConfig-isModuleInstalled-uint256-address-bytes-)
-
- -Indicates an error related to the current `balance` of a `sender`. Used in transfers. +
+

Events

+
+- [ModuleInstalled(moduleTypeId, module)](#IERC7579ModuleConfig-ModuleInstalled-uint256-address-) +- [ModuleUninstalled(moduleTypeId, module)](#IERC7579ModuleConfig-ModuleUninstalled-uint256-address-)
- +
-

ERC20InvalidSender(address sender)

+

installModule(uint256 moduleTypeId, address module, bytes initData)

-

error

-# +

external

+#
-Indicates a failure with the token `sender`. Used in transfers. +Installs a Module of a certain type on the smart account
- +
-

ERC20InvalidReceiver(address receiver)

+

uninstallModule(uint256 moduleTypeId, address module, bytes deInitData)

-

error

-# +

external

+#
-Indicates a failure with the token `receiver`. Used in transfers. +Uninstalls a Module of a certain type on the smart account
- +
-

ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed)

+

isModuleInstalled(uint256 moduleTypeId, address module, bytes additionalContext) → bool

-

error

-# +

external

+#
-Indicates a failure with the `spender`’s `allowance`. Used in transfers. +Returns whether a module is installed on the smart account
- +
-

ERC20InvalidApprover(address approver)

+

ModuleInstalled(uint256 moduleTypeId, address module)

-

error

-# +

event

+#
-
-Indicates a failure with the `approver` of a token to be approved. Used in approvals. +
- - +
-

ERC20InvalidSpender(address spender)

+

ModuleUninstalled(uint256 moduleTypeId, address module)

-

error

-# +

event

+#
-
-Indicates a failure with the `spender` to be approved. Used in approvals. +
- +
-## `IERC721Errors` +## `IERC7674` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC6093.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC7674.sol"; ``` -Standard ERC-721 Errors -Interface of the [ERC-6093](https://eips.ethereum.org/EIPS/eip-6093) custom errors for ERC-721 tokens. +Temporary Approval Extension for ERC-20 ([ERC-7674](https://github.com/ethereum/ERCs/pull/358))
-

Errors

+

Functions

-- [ERC721InvalidOwner(owner)](#IERC721Errors-ERC721InvalidOwner-address-) -- [ERC721NonexistentToken(tokenId)](#IERC721Errors-ERC721NonexistentToken-uint256-) -- [ERC721IncorrectOwner(sender, tokenId, owner)](#IERC721Errors-ERC721IncorrectOwner-address-uint256-address-) -- [ERC721InvalidSender(sender)](#IERC721Errors-ERC721InvalidSender-address-) -- [ERC721InvalidReceiver(receiver)](#IERC721Errors-ERC721InvalidReceiver-address-) -- [ERC721InsufficientApproval(operator, tokenId)](#IERC721Errors-ERC721InsufficientApproval-address-uint256-) -- [ERC721InvalidApprover(approver)](#IERC721Errors-ERC721InvalidApprover-address-) -- [ERC721InvalidOperator(operator)](#IERC721Errors-ERC721InvalidOperator-address-) +- [temporaryApprove(spender, value)](#IERC7674-temporaryApprove-address-uint256-) +#### IERC20 [!toc] +- [totalSupply()](#IERC20-totalSupply--) +- [balanceOf(account)](#IERC20-balanceOf-address-) +- [transfer(to, value)](#IERC20-transfer-address-uint256-) +- [allowance(owner, spender)](#IERC20-allowance-address-address-) +- [approve(spender, value)](#IERC20-approve-address-uint256-) +- [transferFrom(from, to, value)](#IERC20-transferFrom-address-address-uint256-)
- +
+

Events

+
+#### IERC20 [!toc] +- [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) +- [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) +
+
+ +
-

ERC721InvalidOwner(address owner)

+

temporaryApprove(address spender, uint256 value) → bool success

-

error

-# +

external

+#
-Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-721. -Used in balance queries. +Set the temporary allowance, allowing `spender` to withdraw (within the same transaction) assets +held by the caller.
- + -
-
-

ERC721NonexistentToken(uint256 tokenId)

-
-

error

-# -
-
-
+
-Indicates a `tokenId` whose `owner` is the zero address. +## `IERC7786GatewaySource` + + + + -
- +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC7786.sol"; +``` -
-
-

ERC721IncorrectOwner(address sender, uint256 tokenId, address owner)

-
-

error

-# -
-
-
+Interface for ERC-7786 source gateways. -Indicates an error related to the ownership over a particular token. Used in transfers. +See ERC-7786 for more details +
+

Functions

+
+- [supportsAttribute(selector)](#IERC7786GatewaySource-supportsAttribute-bytes4-) +- [sendMessage(recipient, payload, attributes)](#IERC7786GatewaySource-sendMessage-bytes-bytes-bytes---)
- - -
-
-

ERC721InvalidSender(address sender)

-
-

error

-# +
+

Events

+
+- [MessageSent(sendId, sender, recipient, payload, value, attributes)](#IERC7786GatewaySource-MessageSent-bytes32-bytes-bytes-bytes-uint256-bytes---)
-
- -Indicates a failure with the token `sender`. Used in transfers. +
+

Errors

+
+- [UnsupportedAttribute(selector)](#IERC7786GatewaySource-UnsupportedAttribute-bytes4-)
- +
-

ERC721InvalidReceiver(address receiver)

+

supportsAttribute(bytes4 selector) → bool

-

error

-# +

external

+#
-Indicates a failure with the token `receiver`. Used in transfers. +Getter to check whether an attribute is supported or not.
- +
-

ERC721InsufficientApproval(address operator, uint256 tokenId)

+

sendMessage(bytes recipient, bytes payload, bytes[] attributes) → bytes32 sendId

-

error

-# +

external

+#
-Indicates a failure with the `operator`’s approval. Used in transfers. +Endpoint for creating a new message. If the message requires further (gateway specific) processing before +it can be sent to the destination chain, then a non-zero `sendId` must be returned. Otherwise, the +message MUST be sent and this function must return 0. + +* MUST emit a [`IERC7786GatewaySource.MessageSent`](#IERC7786GatewaySource-MessageSent-bytes32-bytes-bytes-bytes-uint256-bytes---) event. + +If any of the `attributes` is not supported, this function SHOULD revert with an [`IERC7786GatewaySource.UnsupportedAttribute`](#IERC7786GatewaySource-UnsupportedAttribute-bytes4-) error. +Other errors SHOULD revert with errors not specified in ERC-7786.
- +
-

ERC721InvalidApprover(address approver)

+

MessageSent(bytes32 indexed sendId, bytes sender, bytes recipient, bytes payload, uint256 value, bytes[] attributes)

-

error

-# +

event

+#
+
-Indicates a failure with the `approver` of a token to be approved. Used in approvals. +Event emitted when a message is created. If `sendId` is zero, no further processing is necessary. If +`sendId` is not zero, then further (gateway specific, and non-standardized) action is required.
- +
-

ERC721InvalidOperator(address operator)

+

UnsupportedAttribute(bytes4 selector)

error

-# +#
-Indicates a failure with the `operator` to be approved. Used in approvals. +This error is thrown when a message creation fails because of an unsupported attribute being specified.
- +
-## `IERC1155Errors` +## `IERC7786Recipient` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC6093.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC7786.sol"; ``` -Standard ERC-1155 Errors -Interface of the [ERC-6093](https://eips.ethereum.org/EIPS/eip-6093) custom errors for ERC-1155 tokens. +Interface for the ERC-7786 client contract (receiver). + +See ERC-7786 for more details
-

Errors

+

Functions

-- [ERC1155InsufficientBalance(sender, balance, needed, tokenId)](#IERC1155Errors-ERC1155InsufficientBalance-address-uint256-uint256-uint256-) -- [ERC1155InvalidSender(sender)](#IERC1155Errors-ERC1155InvalidSender-address-) -- [ERC1155InvalidReceiver(receiver)](#IERC1155Errors-ERC1155InvalidReceiver-address-) -- [ERC1155MissingApprovalForAll(operator, owner)](#IERC1155Errors-ERC1155MissingApprovalForAll-address-address-) -- [ERC1155InvalidApprover(approver)](#IERC1155Errors-ERC1155InvalidApprover-address-) -- [ERC1155InvalidOperator(operator)](#IERC1155Errors-ERC1155InvalidOperator-address-) -- [ERC1155InvalidArrayLength(idsLength, valuesLength)](#IERC1155Errors-ERC1155InvalidArrayLength-uint256-uint256-) +- [receiveMessage(receiveId, sender, payload)](#IERC7786Recipient-receiveMessage-bytes32-bytes-bytes-)
- +
-

ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId)

+

receiveMessage(bytes32 receiveId, bytes sender, bytes payload) → bytes4

-

error

-# +

external

+#
-Indicates an error related to the current `balance` of a `sender`. Used in transfers. - -
-
+Endpoint for receiving cross-chain message. - +This function may be called directly by the gateway. -
-
-

ERC1155InvalidSender(address sender)

-
-

error

-#
-
-Indicates a failure with the token `sender`. Used in transfers. + + +
+ +## `IERC7802` + + + + -
- +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC7802.sol"; +``` -
-
-

ERC1155InvalidReceiver(address receiver)

-
-

error

-# +
+

Functions

+
+- [crosschainMint(_to, _amount)](#IERC7802-crosschainMint-address-uint256-) +- [crosschainBurn(_from, _amount)](#IERC7802-crosschainBurn-address-uint256-) +#### IERC165 [!toc] +- [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-)
-
- -Indicates a failure with the token `receiver`. Used in transfers. +
+

Events

+
+- [CrosschainMint(to, amount, sender)](#IERC7802-CrosschainMint-address-uint256-address-) +- [CrosschainBurn(from, amount, sender)](#IERC7802-CrosschainBurn-address-uint256-address-) +#### IERC165 [!toc]
- +
-

ERC1155MissingApprovalForAll(address operator, address owner)

+

crosschainMint(address _to, uint256 _amount)

-

error

-# +

external

+#
-Indicates a failure with the `operator`’s approval. Used in transfers. -
- +
-

ERC1155InvalidApprover(address approver)

+

crosschainBurn(address _from, uint256 _amount)

-

error

-# +

external

+#
-Indicates a failure with the `approver` of a token to be approved. Used in approvals. -
- +
-

ERC1155InvalidOperator(address operator)

+

CrosschainMint(address indexed to, uint256 amount, address indexed sender)

-

error

-# +

event

+#
-
-Indicates a failure with the `operator` to be approved. Used in approvals. +
- - +
-

ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength)

+

CrosschainBurn(address indexed from, uint256 amount, address indexed sender)

-

error

-# +

event

+#
-
-Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. -Used in batch transfers. +
- +
-## `VALIDATION_SUCCESS` +## `IERC7821` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC7821.sol"; ``` - - -
+Interface for minimal batch executor. -## `VALIDATION_FAILED` +
+

Functions

+
+- [execute(mode, executionData)](#IERC7821-execute-bytes32-bytes-) +- [supportsExecutionMode(mode)](#IERC7821-supportsExecutionMode-bytes32-) +
+
- - - + +
+
+

execute(bytes32 mode, bytes executionData)

+
+

external

+#
+
+
-```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; -``` - - +Executes the calls in `executionData`. +Reverts and bubbles up error if any call fails. -
+`executionData` encoding: +- If `opData` is empty, `executionData` is simply `abi.encode(calls)`. +- Else, `executionData` is `abi.encode(calls, opData)`. + See: https://eips.ethereum.org/EIPS/eip-7579 -## `MODULE_TYPE_VALIDATOR` +Supported modes: +- `bytes32(0x01000000000000000000...)`: does not support optional `opData`. +- `bytes32(0x01000000000078210001...)`: supports optional `opData`. - - - +Authorization checks: +- If `opData` is empty, the implementation SHOULD require that + `msg.sender == address(this)`. +- If `opData` is not empty, the implementation SHOULD use the signature + encoded in `opData` to determine if the caller can perform the execution. -
+`opData` may be used to store additional data for authentication, +paymaster data, gas limits, etc. -```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; -``` +For calldata compression efficiency, if a Call.to is `address(0)`, +it will be replaced with `address(this)`. - +
+
-
+ -## `MODULE_TYPE_EXECUTOR` +
+
+

supportsExecutionMode(bytes32 mode) → bool

+
+

external

+# +
+
+
- - - +This function is provided for frontends to detect support. +Only returns true for: +- `bytes32(0x01000000000000000000...)`: does not support optional `opData`. +- `bytes32(0x01000000000078210001...)`: supports optional `opData`. +
-```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; -``` - - +
-## `MODULE_TYPE_FALLBACK` +## `IERC1363Receiver` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +import "@openzeppelin/contracts/interfaces/IERC1363Receiver.sol"; ``` - - -
+Interface for any contract that wants to support `transferAndCall` or `transferFromAndCall` +from ERC-1363 token contracts. -## `MODULE_TYPE_HOOK` +
+

Functions

+
+- [onTransferReceived(operator, from, value, data)](#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) +
+
- - - + +
+
+

onTransferReceived(address operator, address from, uint256 value, bytes data) → bytes4

+
+

external

+# +
+
-```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; -``` +Whenever ERC-1363 tokens are transferred to this contract via `transferAndCall` or `transferFromAndCall` +by `operator` from `from`, this function is called. - + +To accept the transfer, this must return +`bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))` +(i.e. 0x88a7ca5c, or its own function selector). + + +
+
+ +
-## `IERC7579Module` +## `IERC1363Spender` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +import "@openzeppelin/contracts/interfaces/IERC1363Spender.sol"; ``` -Minimal configuration interface for ERC-7579 modules +Interface for any contract that wants to support `approveAndCall` +from ERC-1363 token contracts.

Functions

-- [onInstall(data)](#IERC7579Module-onInstall-bytes-) -- [onUninstall(data)](#IERC7579Module-onUninstall-bytes-) -- [isModuleType(moduleTypeId)](#IERC7579Module-isModuleType-uint256-) +- [onApprovalReceived(owner, value, data)](#IERC1363Spender-onApprovalReceived-address-uint256-bytes-)
- +
-

onInstall(bytes data)

+

onApprovalReceived(address owner, uint256 value, bytes data) → bytes4

external

-# +#
-This function is called by the smart account during installation of the module +Whenever an ERC-1363 token `owner` approves this contract via `approveAndCall` +to spend their tokens, this function is called. + + +To accept the approval, this must return +`bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))` +(i.e. 0x7b04a2d0, or its own function selector). +
- + + +
+ +## `IERC1820Implementer` + + + + -
-
-

onUninstall(bytes data)

-
-

external

-# -
-
-This function is called by the smart account during uninstallation of the module +```solidity +import "@openzeppelin/contracts/interfaces/IERC1820Implementer.sol"; +``` + +Interface for an ERC-1820 implementer, as defined in the +[ERC](https://eips.ethereum.org/EIPS/eip-1820#interface-implementation-erc1820implementerinterface). +Used by contracts that will be registered as implementers in the +[`IERC1820Registry`](#IERC1820Registry). +
+

Functions

+
+- [canImplementInterfaceForAddress(interfaceHash, account)](#IERC1820Implementer-canImplementInterfaceForAddress-bytes32-address-)
- +
-

isModuleType(uint256 moduleTypeId) → bool

+

canImplementInterfaceForAddress(bytes32 interfaceHash, address account) → bytes32

external

-# +#
-Returns boolean value if module is a certain type +Returns a special value (`ERC1820_ACCEPT_MAGIC`) if this contract +implements `interfaceHash` for `account`. + +See [`IERC1820Registry.setInterfaceImplementer`](#IERC1820Registry-setInterfaceImplementer-address-bytes32-address-).
- +
-## `IERC7579Validator` +## `IERC1820Registry` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +import "@openzeppelin/contracts/interfaces/IERC1820Registry.sol"; ``` -ERC-7579 Validation module (type 1). +Interface of the global ERC-1820 Registry, as defined in the +[ERC](https://eips.ethereum.org/EIPS/eip-1820). Accounts may register +implementers for interfaces in this registry, as well as query support. -A module that implements logic to validate user operations and signatures. +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`](/contracts/5.x/api/utils#IERC165) interfaces can also be queried via the registry. + +For an in-depth explanation and source code analysis, see the ERC text.

Functions

-- [validateUserOp(userOp, userOpHash)](#IERC7579Validator-validateUserOp-struct-PackedUserOperation-bytes32-) -- [isValidSignatureWithSender(sender, hash, signature)](#IERC7579Validator-isValidSignatureWithSender-address-bytes32-bytes-) -#### IERC7579Module [!toc] -- [onInstall(data)](#IERC7579Module-onInstall-bytes-) -- [onUninstall(data)](#IERC7579Module-onUninstall-bytes-) -- [isModuleType(moduleTypeId)](#IERC7579Module-isModuleType-uint256-) +- [setManager(account, newManager)](#IERC1820Registry-setManager-address-address-) +- [getManager(account)](#IERC1820Registry-getManager-address-) +- [setInterfaceImplementer(account, _interfaceHash, implementer)](#IERC1820Registry-setInterfaceImplementer-address-bytes32-address-) +- [getInterfaceImplementer(account, _interfaceHash)](#IERC1820Registry-getInterfaceImplementer-address-bytes32-) +- [interfaceHash(interfaceName)](#IERC1820Registry-interfaceHash-string-) +- [updateERC165Cache(account, interfaceId)](#IERC1820Registry-updateERC165Cache-address-bytes4-) +- [implementsERC165Interface(account, interfaceId)](#IERC1820Registry-implementsERC165Interface-address-bytes4-) +- [implementsERC165InterfaceNoCache(account, interfaceId)](#IERC1820Registry-implementsERC165InterfaceNoCache-address-bytes4-)
- +
+

Events

+
+- [InterfaceImplementerSet(account, interfaceHash, implementer)](#IERC1820Registry-InterfaceImplementerSet-address-bytes32-address-) +- [ManagerChanged(account, newManager)](#IERC1820Registry-ManagerChanged-address-address-) +
+
+ +
-

validateUserOp(struct PackedUserOperation userOp, bytes32 userOpHash) → uint256

+

setManager(address account, address newManager)

external

-# +#
-Validates a UserOperation +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 [`IERC1820Registry.ManagerChanged`](#IERC1820Registry-ManagerChanged-address-address-) event. + +Requirements: + +- the caller must be the current manager for `account`.
- +
-

isValidSignatureWithSender(address sender, bytes32 hash, bytes signature) → bytes4

+

getManager(address account) → address

external

-# +#
-Validates a signature using ERC-1271 +Returns the manager for `account`. + +See [`IERC1820Registry.setManager`](#IERC1820Registry-setManager-address-address-).
- + -
+
+
+

setInterfaceImplementer(address account, bytes32 _interfaceHash, address implementer)

+
+

external

+# +
+
+
-## `IERC7579Hook` +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 [`IERC1820Registry.interfaceHash`](#IERC1820Registry-interfaceHash-string-) to learn how these are created. -```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; -``` +Emits an [`IERC1820Registry.InterfaceImplementerSet`](#IERC1820Registry-InterfaceImplementerSet-address-bytes32-address-) event. -ERC-7579 Hooks module (type 4). +Requirements: -A module that implements logic to execute before and after the account executes a user operation, -either individually or batched. +- the caller must be the current manager for `account`. +- `interfaceHash` must not be an [`IERC165`](/contracts/5.x/api/utils#IERC165) interface id (i.e. it must not +end in 28 zeroes). +- `implementer` must implement [`IERC1820Implementer`](#IERC1820Implementer) and return true when +queried for support, unless `implementer` is the caller. See +[`IERC1820Implementer.canImplementInterfaceForAddress`](#IERC1820Implementer-canImplementInterfaceForAddress-bytes32-address-). -
-

Functions

-
-- [preCheck(msgSender, value, msgData)](#IERC7579Hook-preCheck-address-uint256-bytes-) -- [postCheck(hookData)](#IERC7579Hook-postCheck-bytes-) -#### IERC7579Module [!toc] -- [onInstall(data)](#IERC7579Module-onInstall-bytes-) -- [onUninstall(data)](#IERC7579Module-onUninstall-bytes-) -- [isModuleType(moduleTypeId)](#IERC7579Module-isModuleType-uint256-)
- +
-

preCheck(address msgSender, uint256 value, bytes msgData) → bytes hookData

+

getInterfaceImplementer(address account, bytes32 _interfaceHash) → address

external

-# +#
-Called by the smart account before execution +Returns the implementer of `interfaceHash` for `account`. If no such +implementer is registered, returns the zero address. + +If `interfaceHash` is an [`IERC165`](/contracts/5.x/api/utils#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.
- +
-

postCheck(bytes hookData)

+

interfaceHash(string interfaceName) → bytes32

external

-# +#
-Called by the smart account after execution +Returns the interface hash for an `interfaceName`, as defined in the +corresponding +[section of the ERC](https://eips.ethereum.org/EIPS/eip-1820#interface-name).
- - -
- -## `Execution` - - - - + +
+
+

updateERC165Cache(address account, bytes4 interfaceId)

+
+

external

+#
- -```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; -``` - - - -
- -## `IERC7579Execution` - - - - -
+
-```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; -``` +
+
-ERC-7579 Execution. + -Accounts should implement this interface so that the Entrypoint and ERC-7579 modules can execute operations. +
+
+

implementsERC165Interface(address account, bytes4 interfaceId) → bool

+
+

external

+# +
+
+
-
-

Functions

-
-- [execute(mode, executionCalldata)](#IERC7579Execution-execute-bytes32-bytes-) -- [executeFromExecutor(mode, executionCalldata)](#IERC7579Execution-executeFromExecutor-bytes32-bytes-)
- +
-

execute(bytes32 mode, bytes executionCalldata)

+

implementsERC165InterfaceNoCache(address account, bytes4 interfaceId) → bool

external

-# +#
-Executes a transaction on behalf of the account. -
- +
-

executeFromExecutor(bytes32 mode, bytes executionCalldata) → bytes[] returnData

+

InterfaceImplementerSet(address indexed account, bytes32 indexed interfaceHash, address indexed implementer)

-

external

-# +

event

+#
+
-Executes a transaction on behalf of the account. - This function is intended to be called by Executor Modules +
+
+ +
+
+

ManagerChanged(address indexed account, address indexed newManager)

+
+

event

+#
- +
+ +
+
+ +
-## `IERC7579AccountConfig` +## `IERC2612` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +import "@openzeppelin/contracts/interfaces/IERC2612.sol"; ``` -ERC-7579 Account Config. - -Accounts should implement this interface to expose information that identifies the account, supported modules and capabilities. -

Functions

-- [accountId()](#IERC7579AccountConfig-accountId--) -- [supportsExecutionMode(encodedMode)](#IERC7579AccountConfig-supportsExecutionMode-bytes32-) -- [supportsModule(moduleTypeId)](#IERC7579AccountConfig-supportsModule-uint256-) +#### IERC20Permit [!toc] +- [permit(owner, spender, value, deadline, v, r, s)](#IERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) +- [nonces(owner)](#IERC20Permit-nonces-address-) +- [DOMAIN_SEPARATOR()](#IERC20Permit-DOMAIN_SEPARATOR--)
- - -
-
-

accountId() → string accountImplementationId

-
-

external

-# -
-
-
+ -Returns the account id of the smart account +
-
-
+## `IERC7751` - + + + -
-
-

supportsExecutionMode(bytes32 encodedMode) → bool

-
-

external

-#
-
-
-Function to check if the account supports a certain execution mode (see above) +```solidity +import "@openzeppelin/contracts/interfaces/IERC7751.sol"; +``` + +Wrapping of bubbled up reverts +Interface of the [ERC-7751](https://eips.ethereum.org/EIPS/eip-7751) wrapping of bubbled up reverts. +
+

Errors

+
+- [WrappedError(target, selector, reason, details)](#IERC7751-WrappedError-address-bytes4-bytes-bytes-)
- +
-

supportsModule(uint256 moduleTypeId) → bool

+

WrappedError(address target, bytes4 selector, bytes reason, bytes details)

-

external

-# +

error

+#
-Function to check if the account supports a certain module typeId -
- +
-## `IERC7579ModuleConfig` +## `IERC777` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +import "@openzeppelin/contracts/interfaces/IERC777.sol"; ``` -ERC-7579 Module Config. +Interface of the ERC-777 Token standard as defined in the ERC. -Accounts should implement this interface to allow installing and uninstalling modules. +This contract uses the +[ERC-1820 registry standard](https://eips.ethereum.org/EIPS/eip-1820) to let +token holders and recipients react to token movements by using setting implementers +for the associated interfaces in said registry. See [`IERC1820Registry`](#IERC1820Registry) and +[`IERC1820Implementer`](#IERC1820Implementer).

Functions

-- [installModule(moduleTypeId, module, initData)](#IERC7579ModuleConfig-installModule-uint256-address-bytes-) -- [uninstallModule(moduleTypeId, module, deInitData)](#IERC7579ModuleConfig-uninstallModule-uint256-address-bytes-) -- [isModuleInstalled(moduleTypeId, module, additionalContext)](#IERC7579ModuleConfig-isModuleInstalled-uint256-address-bytes-) +- [name()](#IERC777-name--) +- [symbol()](#IERC777-symbol--) +- [granularity()](#IERC777-granularity--) +- [totalSupply()](#IERC777-totalSupply--) +- [balanceOf(owner)](#IERC777-balanceOf-address-) +- [send(recipient, amount, data)](#IERC777-send-address-uint256-bytes-) +- [burn(amount, data)](#IERC777-burn-uint256-bytes-) +- [isOperatorFor(operator, tokenHolder)](#IERC777-isOperatorFor-address-address-) +- [authorizeOperator(operator)](#IERC777-authorizeOperator-address-) +- [revokeOperator(operator)](#IERC777-revokeOperator-address-) +- [defaultOperators()](#IERC777-defaultOperators--) +- [operatorSend(sender, recipient, amount, data, operatorData)](#IERC777-operatorSend-address-address-uint256-bytes-bytes-) +- [operatorBurn(account, amount, data, operatorData)](#IERC777-operatorBurn-address-uint256-bytes-bytes-)

Events

-- [ModuleInstalled(moduleTypeId, module)](#IERC7579ModuleConfig-ModuleInstalled-uint256-address-) -- [ModuleUninstalled(moduleTypeId, module)](#IERC7579ModuleConfig-ModuleUninstalled-uint256-address-) +- [Minted(operator, to, amount, data, operatorData)](#IERC777-Minted-address-address-uint256-bytes-bytes-) +- [Burned(operator, from, amount, data, operatorData)](#IERC777-Burned-address-address-uint256-bytes-bytes-) +- [AuthorizedOperator(operator, tokenHolder)](#IERC777-AuthorizedOperator-address-address-) +- [RevokedOperator(operator, tokenHolder)](#IERC777-RevokedOperator-address-address-) +- [Sent(operator, from, to, amount, data, operatorData)](#IERC777-Sent-address-address-address-uint256-bytes-bytes-)
- +
-

installModule(uint256 moduleTypeId, address module, bytes initData)

+

name() → string

external

-# +#
-Installs a Module of a certain type on the smart account +Returns the name of the token.
- +
-

uninstallModule(uint256 moduleTypeId, address module, bytes deInitData)

+

symbol() → string

external

-# +#
-Uninstalls a Module of a certain type on the smart account +Returns the symbol of the token, usually a shorter version of the +name.
- +
-

isModuleInstalled(uint256 moduleTypeId, address module, bytes additionalContext) → bool

+

granularity() → uint256

external

-# +#
-Returns whether a module is installed on the smart account +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.
- +
-

ModuleInstalled(uint256 moduleTypeId, address module)

+

totalSupply() → uint256

-

event

-# +

external

+#
-
+Returns the amount of tokens in existence. +
- + +
-

ModuleUninstalled(uint256 moduleTypeId, address module)

+

balanceOf(address owner) → uint256

-

event

-# +

external

+#
-
+Returns the amount of tokens owned by an account (`owner`). +
- - -
+ -## `IERC7674` +
+
+

send(address recipient, uint256 amount, bytes data)

+
+

external

+# +
+
+
- - - +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`](#IERC777Sender) and [`IERC777Recipient`](#IERC777Recipient). -```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7674.sol"; -``` +Emits a [`IERC777.Sent`](#IERC777-Sent-address-address-address-uint256-bytes-bytes-) event. -Temporary Approval Extension for ERC-20 ([ERC-7674](https://github.com/ethereum/ERCs/pull/358)) +Requirements -
-

Functions

-
-- [temporaryApprove(spender, value)](#IERC7674-temporaryApprove-address-uint256-) -#### IERC20 [!toc] -- [totalSupply()](#IERC20-totalSupply--) -- [balanceOf(account)](#IERC20-balanceOf-address-) -- [transfer(to, value)](#IERC20-transfer-address-uint256-) -- [allowance(owner, spender)](#IERC20-allowance-address-address-) -- [approve(spender, value)](#IERC20-approve-address-uint256-) -- [transferFrom(from, to, value)](#IERC20-transferFrom-address-address-uint256-) -
-
+- the caller must have at least `amount` tokens. +- `recipient` cannot be the zero address. +- if `recipient` is a contract, it must implement the [`IERC777Recipient`](#IERC777Recipient) +interface. -
-

Events

-
-#### IERC20 [!toc] -- [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) -- [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-)
- +
-

temporaryApprove(address spender, uint256 value) → bool success

+

burn(uint256 amount, bytes data)

external

-# +#
-Set the temporary allowance, allowing `spender` to withdraw (within the same transaction) assets -held by the caller. - -
-
+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`](#IERC777Sender). -
+Emits a [`IERC777.Burned`](#IERC777-Burned-address-address-uint256-bytes-bytes-) event. -## `IERC7786GatewaySource` +Requirements - - - +- the caller must have at least `amount` tokens. +
-```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7786.sol"; -``` - -Interface for ERC-7786 source gateways. - -See ERC-7786 for more details + -
-

Functions

-
-- [supportsAttribute(selector)](#IERC7786GatewaySource-supportsAttribute-bytes4-) -- [sendMessage(recipient, payload, attributes)](#IERC7786GatewaySource-sendMessage-bytes-bytes-bytes---) +
+
+

isOperatorFor(address operator, address tokenHolder) → bool

+
+

external

+#
+
-
-

Events

-
-- [MessageSent(sendId, sender, recipient, payload, value, attributes)](#IERC7786GatewaySource-MessageSent-bytes32-bytes-bytes-bytes-uint256-bytes---) -
-
+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 [`IERC777.operatorSend`](#IERC777-operatorSend-address-address-uint256-bytes-bytes-) and [`IERC777.operatorBurn`](#IERC777-operatorBurn-address-uint256-bytes-bytes-). -
-

Errors

-
-- [UnsupportedAttribute(selector)](#IERC7786GatewaySource-UnsupportedAttribute-bytes4-)
- +
-

supportsAttribute(bytes4 selector) → bool

+

authorizeOperator(address operator)

external

-# +#
-Getter to check whether an attribute is supported or not. +Make an account an operator of the caller. + +See [`IERC777.isOperatorFor`](#IERC777-isOperatorFor-address-address-). + +Emits an [`IERC777.AuthorizedOperator`](#IERC777-AuthorizedOperator-address-address-) event. + +Requirements + +- `operator` cannot be calling address.
- +
-

sendMessage(bytes recipient, bytes payload, bytes[] attributes) → bytes32 sendId

+

revokeOperator(address operator)

external

-# +#
-Endpoint for creating a new message. If the message requires further (gateway specific) processing before -it can be sent to the destination chain, then a non-zero `sendId` must be returned. Otherwise, the -message MUST be sent and this function must return 0. +Revoke an account's operator status for the caller. + +See [`IERC777.isOperatorFor`](#IERC777-isOperatorFor-address-address-) and [`IERC777.defaultOperators`](#IERC777-defaultOperators--). -* MUST emit a [`IERC7786GatewaySource.MessageSent`](#IERC7786GatewaySource-MessageSent-bytes32-bytes-bytes-bytes-uint256-bytes---) event. +Emits a [`IERC777.RevokedOperator`](#IERC777-RevokedOperator-address-address-) event. -If any of the `attributes` is not supported, this function SHOULD revert with an [`IERC7786GatewaySource.UnsupportedAttribute`](#IERC7786GatewaySource-UnsupportedAttribute-bytes4-) error. -Other errors SHOULD revert with errors not specified in ERC-7786. +Requirements + +- `operator` cannot be calling address.
- +
-

MessageSent(bytes32 indexed sendId, bytes sender, bytes recipient, bytes payload, uint256 value, bytes[] attributes)

+

defaultOperators() → address[]

-

event

-# +

external

+#
-
-Event emitted when a message is created. If `sendId` is zero, no further processing is necessary. If -`sendId` is not zero, then further (gateway specific, and non-standardized) action is required. +Returns the list of default operators. These accounts are operators +for all token holders, even if [`IERC777.authorizeOperator`](#IERC777-authorizeOperator-address-) was never called on +them. + +This list is immutable, but individual holders may revoke these via +[`IERC777.revokeOperator`](#IERC777-revokeOperator-address-), in which case [`IERC777.isOperatorFor`](#IERC777-isOperatorFor-address-address-) will return false.
- +
-

UnsupportedAttribute(bytes4 selector)

+

operatorSend(address sender, address recipient, uint256 amount, bytes data, bytes operatorData)

-

error

-# +

external

+#
-This error is thrown when a message creation fails because of an unsupported attribute being specified. - -
-
- - - -
- -## `IERC7786Recipient` - - - - +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`](#IERC777Sender) and [`IERC777Recipient`](#IERC777Recipient). -```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7786.sol"; -``` +Emits a [`IERC777.Sent`](#IERC777-Sent-address-address-address-uint256-bytes-bytes-) event. -Interface for the ERC-7786 client contract (receiver). +Requirements -See ERC-7786 for more details +- `sender` cannot be the zero address. +- `sender` must have at least `amount` tokens. +- the caller must be an operator for `sender`. +- `recipient` cannot be the zero address. +- if `recipient` is a contract, it must implement the [`IERC777Recipient`](#IERC777Recipient) +interface. -
-

Functions

-
-- [receiveMessage(receiveId, sender, payload)](#IERC7786Recipient-receiveMessage-bytes32-bytes-bytes-)
- +
-

receiveMessage(bytes32 receiveId, bytes sender, bytes payload) → bytes4

+

operatorBurn(address account, uint256 amount, bytes data, bytes operatorData)

external

-# +#
-Endpoint for receiving cross-chain message. - -This function may be called directly by the gateway. - -
-
+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`](#IERC777Sender). -
+Emits a [`IERC777.Burned`](#IERC777-Burned-address-address-uint256-bytes-bytes-) event. -## `IERC7802` +Requirements - - - +- `account` cannot be the zero address. +- `account` must have at least `amount` tokens. +- the caller must be an operator for `account`. +
-```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7802.sol"; -``` + -
-

Functions

-
-- [crosschainMint(_to, _amount)](#IERC7802-crosschainMint-address-uint256-) -- [crosschainBurn(_from, _amount)](#IERC7802-crosschainBurn-address-uint256-) -#### IERC165 [!toc] -- [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) +
+
+

Minted(address indexed operator, address indexed to, uint256 amount, bytes data, bytes operatorData)

+
+

event

+#
-
-

Events

-
-- [CrosschainMint(to, amount, sender)](#IERC7802-CrosschainMint-address-uint256-address-) -- [CrosschainBurn(from, amount, sender)](#IERC7802-CrosschainBurn-address-uint256-address-) -#### IERC165 [!toc] +
+ +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. +
- - +
-

crosschainMint(address _to, uint256 _amount)

+

Burned(address indexed operator, address indexed from, uint256 amount, bytes data, bytes operatorData)

-

external

-# +

event

+#
+
+Emitted when `operator` destroys `amount` tokens from `account`. + +Note that some additional user `data` and `operatorData` can be logged in the event. +
- - +
-

crosschainBurn(address _from, uint256 _amount)

+

AuthorizedOperator(address indexed operator, address indexed tokenHolder)

-

external

-# +

event

+#
+
+Emitted when `operator` is made operator for `tokenHolder`. +
- - +
-

CrosschainMint(address indexed to, uint256 amount, address indexed sender)

+

RevokedOperator(address indexed operator, address indexed tokenHolder)

event

-# +#
+Emitted when `operator` is revoked its operator status for `tokenHolder`. +
- +
-

CrosschainBurn(address indexed from, uint256 amount, address indexed sender)

+

Sent(address indexed operator, address indexed from, address indexed to, uint256 amount, bytes data, bytes operatorData)

event

-# +#
@@ -4976,87 +4978,115 @@ import "@openzeppelin/contracts/interfaces/draft-IERC7802.sol";
- +
-## `IERC7821` +## `IERC777Recipient` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7821.sol"; +import "@openzeppelin/contracts/interfaces/IERC777Recipient.sol"; ``` -Interface for minimal batch executor. +Interface of the ERC-777 Tokens Recipient standard as defined in the ERC. + +Accounts can be notified of [`IERC777`](#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 +[ERC-1820 global registry](https://eips.ethereum.org/EIPS/eip-1820). + +See [`IERC1820Registry`](#IERC1820Registry) and [`IERC1820Implementer`](#IERC1820Implementer).

Functions

-- [execute(mode, executionData)](#IERC7821-execute-bytes32-bytes-) -- [supportsExecutionMode(mode)](#IERC7821-supportsExecutionMode-bytes32-) +- [tokensReceived(operator, from, to, amount, userData, operatorData)](#IERC777Recipient-tokensReceived-address-address-address-uint256-bytes-bytes-)
- +
-

execute(bytes32 mode, bytes executionData)

+

tokensReceived(address operator, address from, address to, uint256 amount, bytes userData, bytes operatorData)

external

-# +#
-Executes the calls in `executionData`. -Reverts and bubbles up error if any call fails. +Called by an [`IERC777`](#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. -`executionData` encoding: -- If `opData` is empty, `executionData` is simply `abi.encode(calls)`. -- Else, `executionData` is `abi.encode(calls, opData)`. - See: https://eips.ethereum.org/EIPS/eip-7579 +This call occurs _after_ the token contract's state is updated, so +[`IERC777.balanceOf`](#IERC777-balanceOf-address-), etc., can be used to query the post-operation state. -Supported modes: -- `bytes32(0x01000000000000000000...)`: does not support optional `opData`. -- `bytes32(0x01000000000078210001...)`: supports optional `opData`. +This function may revert to prevent the operation from being executed. -Authorization checks: -- If `opData` is empty, the implementation SHOULD require that - `msg.sender == address(this)`. -- If `opData` is not empty, the implementation SHOULD use the signature - encoded in `opData` to determine if the caller can perform the execution. +
+
-`opData` may be used to store additional data for authentication, -paymaster data, gas limits, etc. + -For calldata compression efficiency, if a Call.to is `address(0)`, -it will be replaced with `address(this)`. +
+ +## `IERC777Sender` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/interfaces/IERC777Sender.sol"; +``` +Interface of the ERC-777 Tokens Sender standard as defined in the ERC. + +[`IERC777`](#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 +[ERC-1820 global registry](https://eips.ethereum.org/EIPS/eip-1820). + +See [`IERC1820Registry`](#IERC1820Registry) and [`IERC1820Implementer`](#IERC1820Implementer). + +
+

Functions

+
+- [tokensToSend(operator, from, to, amount, userData, operatorData)](#IERC777Sender-tokensToSend-address-address-address-uint256-bytes-bytes-)
- +
-

supportsExecutionMode(bytes32 mode) → bool

+

tokensToSend(address operator, address from, address to, uint256 amount, bytes userData, bytes operatorData)

external

-# +#
-This function is provided for frontends to detect support. -Only returns true for: -- `bytes32(0x01000000000000000000...)`: does not support optional `opData`. -- `bytes32(0x01000000000078210001...)`: supports optional `opData`. +Called by an [`IERC777`](#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`](#IERC777-balanceOf-address-), etc., can be used to query the pre-operation state. + +This function may revert to prevent the operation from being executed.
+ diff --git a/content/contracts/5.x/api/metatx.mdx b/content/contracts/5.x/api/metatx.mdx index 4fcbd986..966c6b41 100644 --- a/content/contracts/5.x/api/metatx.mdx +++ b/content/contracts/5.x/api/metatx.mdx @@ -20,9 +20,9 @@ This directory includes contracts for adding meta-transaction capabilities (i.e.
-## `ERC2771Context` +## `ERC2771Context` - + @@ -32,7 +32,7 @@ This directory includes contracts for adding meta-transaction capabilities (i.e. import "@openzeppelin/contracts/metatx/ERC2771Context.sol"; ``` -Context variant with ERC-2771 support. +Context variant with ERC-2771 support. See [`ERC2771Context._msgSender`](#ERC2771Context-_msgSender--) for the calldata format. Avoid using this pattern in contracts that rely on a specific calldata length as they'll @@ -168,9 +168,9 @@ ERC-2771 specifies the context as being a single address (20 bytes).
-## `ERC2771Forwarder` +## `ERC2771Forwarder` - + @@ -188,7 +188,7 @@ This forwarder operates on forward requests that include: * `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. +* `nonce` (implicit): Taken from [`Nonces`](/contracts/5.x/api/utils#Nonces) for `from` and included in the signed typed data. * `deadline`: A timestamp after which the request is not executable anymore. * `data`: Encoded `msg.data` to send with the requested call. @@ -205,7 +205,7 @@ handle `msg.data.length == 0`. `ERC2771Context` in OpenZeppelin Contracts versio do not handle this properly. -==== Security Considerations +#### 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, @@ -258,6 +258,7 @@ used to execute arbitrary code.

Errors

+- [ERC2771ForwarderFailureInAtomicBatch()](#ERC2771Forwarder-ERC2771ForwarderFailureInAtomicBatch--) - [ERC2771ForwarderInvalidSigner(signer, from)](#ERC2771Forwarder-ERC2771ForwarderInvalidSigner-address-address-) - [ERC2771ForwarderMismatchedValue(requestedValue, msgValue)](#ERC2771Forwarder-ERC2771ForwarderMismatchedValue-uint256-uint256-) - [ERC2771ForwarderExpiredRequest(deadline)](#ERC2771Forwarder-ERC2771ForwarderExpiredRequest-uint48-) @@ -304,7 +305,7 @@ A transaction is considered valid when the target trusts this forwarder, the req (deadline is not met), and the signer matches the `from` parameter of the signed request. -A request may return false here but it won't cause [`TimelockController.executeBatch`](/contracts/5.x/api/governance#TimelockController-executeBatch-address---uint256---bytes---bytes32-bytes32-) to revert if a refund +A request may return false here but it won't cause [`ERC2771Forwarder.executeBatch`](#ERC2771Forwarder-executeBatch-struct-ERC2771Forwarder-ForwardRequestData---address-payable-) to revert if a refund receiver is provided. @@ -330,7 +331,7 @@ out of gas. Will revert if the request is invalid or the call reverts, in this c Requirements: - The request value should be equal to the provided `msg.value`. -- The request should be valid according to [`IERC7913SignatureVerifier.verify`](/contracts/5.x/api/interfaces#IERC7913SignatureVerifier-verify-bytes-bytes32-bytes-). +- The request should be valid according to [`ERC2771Forwarder.verify`](#ERC2771Forwarder-verify-struct-ERC2771Forwarder-ForwardRequestData-).
@@ -347,9 +348,9 @@ Requirements:
-Batch version of [`AccessManager.execute`](/contracts/5.x/api/access#AccessManager-execute-address-bytes-) with optional refunding and atomic execution. +Batch version of [`ERC2771Forwarder.execute`](#ERC2771Forwarder-execute-struct-ERC2771Forwarder-ForwardRequestData-) with optional refunding and atomic execution. -In case a batch contains at least one invalid request (see [`IERC7913SignatureVerifier.verify`](/contracts/5.x/api/interfaces#IERC7913SignatureVerifier-verify-bytes-bytes32-bytes-)), the +In case a batch contains at least one invalid request (see [`ERC2771Forwarder.verify`](#ERC2771Forwarder-verify-struct-ERC2771Forwarder-ForwardRequestData-)), 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. @@ -363,7 +364,7 @@ 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 [`IERC7913SignatureVerifier.verify`](/contracts/5.x/api/interfaces#IERC7913SignatureVerifier-verify-bytes-bytes32-bytes-)) when `refundReceiver` is the zero address. +- All of the requests should be valid (see [`ERC2771Forwarder.verify`](#ERC2771Forwarder-verify-struct-ERC2771Forwarder-ForwardRequestData-)) when `refundReceiver` is the zero address. Setting a zero `refundReceiver` guarantees an all-or-nothing requests execution only for @@ -387,7 +388,7 @@ subcall, the second-level call may revert without the top-level call reverting.
Validates if the provided request can be executed at current block timestamp with -the given `request.signature` on behalf of `request.signer`. +the given `request.signature` on behalf of `request.from`.
@@ -408,7 +409,7 @@ Returns a tuple with the recovered the signer of an EIP712 forward request messa and a boolean indicating if the signature is valid. -The signature is considered valid if [`ECDSA.tryRecover`](/contracts/5.x/api/utils/cryptography#ECDSA-tryRecover-bytes32-uint8-bytes32-bytes32-) indicates no recover error for it. +The signature is considered valid if [`ECDSA.tryRecoverCalldata`](/contracts/5.x/api/utils/cryptography#ECDSA-tryRecoverCalldata-bytes32-bytes-) indicates no recover error for it.
@@ -433,7 +434,7 @@ 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 [`IERC7913SignatureVerifier.verify`](/contracts/5.x/api/interfaces#IERC7913SignatureVerifier-verify-bytes-bytes32-bytes-)) if the `requireValidRequest` is true. +- The request must be valid (see [`ERC2771Forwarder.verify`](#ERC2771Forwarder-verify-struct-ERC2771Forwarder-ForwardRequestData-)) if the `requireValidRequest` is true. Emits an [`ERC2771Forwarder.ExecutedForwardRequest`](#ERC2771Forwarder-ExecutedForwardRequest-address-uint256-bool-) event. @@ -494,6 +495,23 @@ the requested call to run out of gas.
+ + +
+
+

ERC2771ForwarderFailureInAtomicBatch()

+
+

error

+# +
+
+
+ +One of the calls in an atomic batch failed. + +
+
+
@@ -561,3 +579,4 @@ The request target doesn't trust the `forwarder`.
+ diff --git a/content/contracts/5.x/api/proxy.mdx b/content/contracts/5.x/api/proxy.mdx index 0b1cd166..9be54050 100644 --- a/content/contracts/5.x/api/proxy.mdx +++ b/content/contracts/5.x/api/proxy.mdx @@ -22,10 +22,10 @@ There are two alternative ways to add upgradeability to an ERC-1967 proxy. Their **🔥 CAUTION**\ Using upgradeable proxies correctly and securely is a difficult task that requires deep knowledge of the proxy pattern, Solidity, and the EVM. Unless you want a lot of low level control, we recommend using the [OpenZeppelin Upgrades Plugins](/upgrades-plugins) for Hardhat and Foundry. -A different family of proxies are beacon proxies. This pattern, popularized by Dharma, allows multiple proxies to be upgraded to a different implementation in a single transaction. +A different family of proxies is beacon proxies. This pattern, popularized by Dharma, allows multiple proxies to be upgraded to a different implementation in a single transaction. * [`BeaconProxy`](#BeaconProxy): A proxy that retrieves its implementation from a beacon contract. -* [`UpgradeableBeacon`](#UpgradeableBeacon): A beacon contract with a built in admin that can upgrade the [`BeaconProxy`](#BeaconProxy) pointing to it. +* [`UpgradeableBeacon`](#UpgradeableBeacon): A beacon contract with a built-in admin that can upgrade the [`BeaconProxy`](#BeaconProxy) pointing to it. In this pattern, the proxy contract doesn’t hold the implementation address in storage like an ERC-1967 proxy. Instead, the address is stored in a separate beacon contract. The `upgrade` operations are sent to the beacon instead of to the proxy contract, and all proxies that follow that beacon are automatically upgraded. @@ -90,9 +90,9 @@ The current implementation of this security mechanism uses [ERC-1822](https://ei
-## `Clones` +## `Clones` - + @@ -474,9 +474,9 @@ Get the immutable args attached to a clone.
-## `ERC1967Proxy` +## `ERC1967Proxy` - + @@ -496,6 +496,7 @@ implementation behind the proxy.
- [constructor(implementation, _data)](#ERC1967Proxy-constructor-address-bytes-) - [_implementation()](#ERC1967Proxy-_implementation--) +- [_unsafeAllowUninitialized()](#ERC1967Proxy-_unsafeAllowUninitialized--) #### Proxy [!toc] - [_delegate(implementation)](#Proxy-_delegate-address-) - [_fallback()](#Proxy-_fallback--) @@ -503,6 +504,14 @@ implementation behind the proxy.
+
+

Errors

+
+- [ERC1967ProxyUninitialized()](#ERC1967Proxy-ERC1967ProxyUninitialized--) +#### Proxy [!toc] +
+
+
@@ -517,8 +526,11 @@ implementation behind the proxy. 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. +Provided `_data` is passed 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. By default construction +will fail if `_data` is empty. This behavior can be overridden using a custom [`ERC1967Proxy._unsafeAllowUninitialized`](#ERC1967Proxy-_unsafeAllowUninitialized--) that +returns true. In that case, empty `_data` is ignored and no delegate call to the implementation is performed +during construction. Requirements: @@ -550,13 +562,53 @@ the [`eth_getStorageAt`](https://eth.wiki/json-rpc/API#eth_getstorageat) RPC cal
+ + +
+
+

_unsafeAllowUninitialized() → bool

+
+

internal

+# +
+
+
+ +Returns whether the proxy can be left uninitialized. + + +Override this function to allow the proxy to be left uninitialized. +Consider uninitialized proxies might be susceptible to man-in-the-middle threats +where the proxy is replaced with a malicious one. + + +
+
+ + + +
+
+

ERC1967ProxyUninitialized()

+
+

error

+# +
+
+
+ +The proxy is left uninitialized. + +
+
+
-## `ERC1967Utils` +## `ERC1967Utils` - + @@ -645,7 +697,7 @@ Returns the current admin. To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using -the [`eth_getStorageAt`](https://eth.wiki/json-rpc/API#eth_getstorageat) RPC call. +the [`eth_getStorageAt`](https://ethereum.org/developers/docs/apis/json-rpc/#eth_getstorageat) RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` @@ -706,9 +758,11 @@ to avoid stuck value in the contract. Emits an [`IERC1967.BeaconUpgraded`](/contracts/5.x/api/interfaces#IERC1967-BeaconUpgraded-address-) event. -CAUTION: Invoking this function has no effect on an instance of [`BeaconProxy`](#BeaconProxy) since v5, since + +Invoking this function has no effect on an instance of [`BeaconProxy`](#BeaconProxy) since v5, since it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for efficiency. +
@@ -785,9 +839,9 @@ An upgrade function sees `msg.value > 0` that may be lost.
-## `Proxy` +## `Proxy` - + @@ -801,8 +855,8 @@ This abstract contract provides a fallback function that delegates all calls to instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to be specified by overriding the virtual [`ERC1967Proxy._implementation`](#ERC1967Proxy-_implementation--) function. -Additionally, delegation to the implementation can be triggered manually through the [`AccountERC7579._fallback`](/contracts/5.x/api/account#AccountERC7579-_fallback--) function, or to a -different contract through the [`Votes._delegate`](/contracts/5.x/api/governance#Votes-_delegate-address-address-) function. +Additionally, delegation to the implementation can be triggered manually through the [`Proxy._fallback`](#Proxy-_fallback--) function, or to a +different contract through the [`Proxy._delegate`](#Proxy-_delegate-address-) function. The success and return data of the delegated call will be returned back to the caller of the proxy. @@ -848,7 +902,7 @@ This function does not return to its internal call site, it will return directly
This is a virtual function that should be overridden so it returns the address to which the fallback -function and [`AccountERC7579._fallback`](/contracts/5.x/api/account#AccountERC7579-_fallback--) should delegate. +function and [`Proxy._fallback`](#Proxy-_fallback--) should delegate.
@@ -894,9 +948,9 @@ function in the contract matches the call data.
-## `BeaconProxy` +## `BeaconProxy` - + @@ -912,8 +966,10 @@ The beacon address can only be set once during construction, and cannot be chang immutable variable to avoid unnecessary storage reads, and also in the beacon storage slot specified by [ERC-1967](https://eips.ethereum.org/EIPS/eip-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 + +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. + Do not use the implementation logic to modify the beacon storage slot. Doing so would leave the proxy in @@ -997,9 +1053,9 @@ Returns the beacon.
-## `IBeacon` +## `IBeacon` - + @@ -1037,164 +1093,13 @@ Must return an address that can be used as a delegate call target.
- - -
- -## `UpgradeableBeacon` - - - - - -
- -```solidity -import "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; -``` - -This contract is used in conjunction with one or more instances of [`BeaconProxy`](#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. - -
-

Functions

-
-- [constructor(implementation_, initialOwner)](#UpgradeableBeacon-constructor-address-address-) -- [implementation()](#UpgradeableBeacon-implementation--) -- [upgradeTo(newImplementation)](#UpgradeableBeacon-upgradeTo-address-) -#### Ownable [!toc] -- [owner()](#Ownable-owner--) -- [_checkOwner()](#Ownable-_checkOwner--) -- [renounceOwnership()](#Ownable-renounceOwnership--) -- [transferOwnership(newOwner)](#Ownable-transferOwnership-address-) -- [_transferOwnership(newOwner)](#Ownable-_transferOwnership-address-) -#### IBeacon [!toc] -
-
- -
-

Events

-
-- [Upgraded(implementation)](#UpgradeableBeacon-Upgraded-address-) -#### Ownable [!toc] -- [OwnershipTransferred(previousOwner, newOwner)](#Ownable-OwnershipTransferred-address-address-) -#### IBeacon [!toc] -
-
- -
-

Errors

-
-- [BeaconInvalidImplementation(implementation)](#UpgradeableBeacon-BeaconInvalidImplementation-address-) -#### Ownable [!toc] -- [OwnableUnauthorizedAccount(account)](#Ownable-OwnableUnauthorizedAccount-address-) -- [OwnableInvalidOwner(owner)](#Ownable-OwnableInvalidOwner-address-) -#### IBeacon [!toc] -
-
- - - -
-
-

constructor(address implementation_, address initialOwner)

-
-

public

-# -
-
-
- -Sets the address of the initial implementation, and the initial owner who can upgrade the beacon. - -
-
- - - -
-
-

implementation() → address

-
-

public

-# -
-
-
- -Returns the current implementation address. - -
-
- - - -
-
-

upgradeTo(address newImplementation)

-
-

public

-# -
-
-
- -Upgrades the beacon to a new implementation. - -Emits an [`IERC1967.Upgraded`](/contracts/5.x/api/interfaces#IERC1967-Upgraded-address-) event. - -Requirements: - -- msg.sender must be the owner of the contract. -- `newImplementation` must be a contract. - -
-
- - - -
-
-

Upgraded(address indexed implementation)

-
-

event

-# -
-
- -
- -Emitted when the implementation returned by the beacon is changed. - -
-
- - - -
-
-

BeaconInvalidImplementation(address implementation)

-
-

error

-# -
-
-
- -The `implementation` of the beacon is invalid. - -
-
-
-## `ProxyAdmin` +## `ProxyAdmin` - + @@ -1305,9 +1210,9 @@ during an upgrade.
-## `ITransparentUpgradeableProxy` +## `ITransparentUpgradeableProxy` - + @@ -1361,9 +1266,9 @@ See [`UUPSUpgradeable.upgradeToAndCall`](#UUPSUpgradeable-upgradeToAndCall-addre
-## `TransparentUpgradeableProxy` +## `TransparentUpgradeableProxy` - + @@ -1428,6 +1333,7 @@ could render the `upgradeToAndCall` function inaccessible, preventing upgradeabi - [_fallback()](#TransparentUpgradeableProxy-_fallback--) #### ERC1967Proxy [!toc] - [_implementation()](#ERC1967Proxy-_implementation--) +- [_unsafeAllowUninitialized()](#ERC1967Proxy-_unsafeAllowUninitialized--) #### Proxy [!toc] - [_delegate(implementation)](#Proxy-_delegate-address-) - [fallback()](#Proxy-fallback--) @@ -1439,6 +1345,7 @@ could render the `upgradeToAndCall` function inaccessible, preventing upgradeabi
- [ProxyDeniedAdminAccess()](#TransparentUpgradeableProxy-ProxyDeniedAdminAccess--) #### ERC1967Proxy [!toc] +- [ERC1967ProxyUninitialized()](#ERC1967Proxy-ERC1967ProxyUninitialized--) #### Proxy [!toc]
@@ -1513,90 +1420,502 @@ The proxy caller is the current admin, and can't fallback to the proxy target.
- +
-## `Initializable` +## `UUPSUpgradeable` - +
```solidity -import "@openzeppelin/contracts/proxy/utils/Initializable.sol"; -``` - -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 [`Initializable.initializer`](#Initializable-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] -```solidity -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"); - } -} +import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol"; ``` - -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`](#ERC1967Proxy-constructor-address-bytes-). - - -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. +An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an +[`ERC1967Proxy`](#ERC1967Proxy), when this contract is set as the implementation behind such a proxy. - -Avoid leaving a contract uninitialized. +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. -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 [`Initializable._disableInitializers`](#Initializable-_disableInitializers--) function in the constructor to automatically lock it when it is deployed: +The [`UUPSUpgradeable._authorizeUpgrade`](#UUPSUpgradeable-_authorizeUpgrade-address-) function must be overridden to include access restriction to the upgrade mechanism. -[.hljs-theme-light.nopadding] -``` -/// @custom:oz-upgrades-unsafe-allow constructor -constructor() { - _disableInitializers(); -} -``` - +@custom:stateless

Modifiers

-- [initializer()](#Initializable-initializer--) -- [reinitializer(version)](#Initializable-reinitializer-uint64-) -- [onlyInitializing()](#Initializable-onlyInitializing--) +- [onlyProxy()](#UUPSUpgradeable-onlyProxy--) +- [notDelegated()](#UUPSUpgradeable-notDelegated--)

Functions

-- [_checkInitializing()](#Initializable-_checkInitializing--) -- [_disableInitializers()](#Initializable-_disableInitializers--) -- [_getInitializedVersion()](#Initializable-_getInitializedVersion--) -- [_isInitializing()](#Initializable-_isInitializing--) -- [_initializableStorageSlot()](#Initializable-_initializableStorageSlot--) -
+- [proxiableUUID()](#UUPSUpgradeable-proxiableUUID--) +- [upgradeToAndCall(newImplementation, data)](#UUPSUpgradeable-upgradeToAndCall-address-bytes-) +- [_checkProxy()](#UUPSUpgradeable-_checkProxy--) +- [_checkNotDelegated()](#UUPSUpgradeable-_checkNotDelegated--) +- [_authorizeUpgrade(newImplementation)](#UUPSUpgradeable-_authorizeUpgrade-address-) +- [UPGRADE_INTERFACE_VERSION()](#UUPSUpgradeable-UPGRADE_INTERFACE_VERSION-string) +#### IERC1822Proxiable [!toc] +
+
+ +
+

Errors

+
+- [UUPSUnauthorizedCallContext()](#UUPSUpgradeable-UUPSUnauthorizedCallContext--) +- [UUPSUnsupportedProxiableUUID(slot)](#UUPSUpgradeable-UUPSUnsupportedProxiableUUID-bytes32-) +#### IERC1822Proxiable [!toc] +
+
+ + + +
+
+

onlyProxy()

+
+

internal

+# +
+
+ +
+ +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. + +
+
+ + + +
+
+

notDelegated()

+
+

internal

+# +
+
+ +
+ +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. + +
+
+ + + +
+
+

proxiableUUID() → bytes32

+
+

external

+# +
+
+
+ +Implementation of the ERC-1822 [`UUPSUpgradeable.proxiableUUID`](#UUPSUpgradeable-proxiableUUID--) function. This returns the storage slot used by the +implementation. It is used to validate the implementation's compatibility when performing an upgrade. + + +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. + + +
+
+ + + +
+
+

upgradeToAndCall(address newImplementation, bytes data)

+
+

public

+# +
+
+
+ +Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call +encoded in `data`. + +Calls [`UUPSUpgradeable._authorizeUpgrade`](#UUPSUpgradeable-_authorizeUpgrade-address-). + +Emits an [`UpgradeableBeacon.Upgraded`](#UpgradeableBeacon-Upgraded-address-) event. + +
+
+ + + +
+
+

_checkProxy()

+
+

internal

+# +
+
+
+ +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. + +
+
+ + + +
+
+

_checkNotDelegated()

+
+

internal

+# +
+
+
+ +Reverts if the execution is performed via delegatecall. +See [`UUPSUpgradeable.notDelegated`](#UUPSUpgradeable-notDelegated--). + +
+
+ + + +
+
+

_authorizeUpgrade(address newImplementation)

+
+

internal

+# +
+
+
+ +Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by +[`ERC1967Utils.upgradeToAndCall`](#ERC1967Utils-upgradeToAndCall-address-bytes-). + +Normally, this function will use an [access control](/contracts/5.x/api/access) modifier such as [`Ownable.onlyOwner`](/contracts/5.x/api/access#Ownable-onlyOwner--). + +```solidity +function _authorizeUpgrade(address) internal onlyOwner {} +``` + +
+
+ + + +
+
+

UPGRADE_INTERFACE_VERSION() → string

+
+

public

+# +
+
+
+ +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. + +
+
+ + + +
+
+

UUPSUnauthorizedCallContext()

+
+

error

+# +
+
+
+ +The call is from an unauthorized context. + +
+
+ + + +
+
+

UUPSUnsupportedProxiableUUID(bytes32 slot)

+
+

error

+# +
+
+
+ +The storage `slot` is unsupported as a UUID. + +
+
+ + + +
+ +## `UpgradeableBeacon` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; +``` + +This contract is used in conjunction with one or more instances of [`BeaconProxy`](#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. + +
+

Functions

+
+- [constructor(implementation_, initialOwner)](#UpgradeableBeacon-constructor-address-address-) +- [implementation()](#UpgradeableBeacon-implementation--) +- [upgradeTo(newImplementation)](#UpgradeableBeacon-upgradeTo-address-) +#### Ownable [!toc] +- [owner()](#Ownable-owner--) +- [_checkOwner()](#Ownable-_checkOwner--) +- [renounceOwnership()](#Ownable-renounceOwnership--) +- [transferOwnership(newOwner)](#Ownable-transferOwnership-address-) +- [_transferOwnership(newOwner)](#Ownable-_transferOwnership-address-) +#### IBeacon [!toc] +
+
+ +
+

Events

+
+- [Upgraded(implementation)](#UpgradeableBeacon-Upgraded-address-) +#### Ownable [!toc] +- [OwnershipTransferred(previousOwner, newOwner)](#Ownable-OwnershipTransferred-address-address-) +#### IBeacon [!toc] +
+
+ +
+

Errors

+
+- [BeaconInvalidImplementation(implementation)](#UpgradeableBeacon-BeaconInvalidImplementation-address-) +#### Ownable [!toc] +- [OwnableUnauthorizedAccount(account)](#Ownable-OwnableUnauthorizedAccount-address-) +- [OwnableInvalidOwner(owner)](#Ownable-OwnableInvalidOwner-address-) +#### IBeacon [!toc] +
+
+ + + +
+
+

constructor(address implementation_, address initialOwner)

+
+

public

+# +
+
+
+ +Sets the address of the initial implementation, and the initial owner who can upgrade the beacon. + +
+
+ + + +
+
+

implementation() → address

+
+

public

+# +
+
+
+ +Returns the current implementation address. + +
+
+ + + +
+
+

upgradeTo(address newImplementation)

+
+

public

+# +
+
+
+ +Upgrades the beacon to a new implementation. + +Emits an [`UpgradeableBeacon.Upgraded`](#UpgradeableBeacon-Upgraded-address-) event. + +Requirements: + +- msg.sender must be the owner of the contract. +- `newImplementation` must be a contract. + +
+
+ + + +
+
+

Upgraded(address indexed implementation)

+
+

event

+# +
+
+ +
+ +Emitted when the implementation returned by the beacon is changed. + +
+
+ + + +
+
+

BeaconInvalidImplementation(address implementation)

+
+

error

+# +
+
+
+ +The `implementation` of the beacon is invalid. + +
+
+ + + +
+ +## `Initializable` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/proxy/utils/Initializable.sol"; +``` + +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 [`Initializable.initializer`](#Initializable-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] +```solidity +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"); + } +} +``` + + +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`](#ERC1967Proxy-constructor-address-bytes-). + + + +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 [`Initializable._disableInitializers`](#Initializable-_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(); +} +``` + +
+

Modifiers

+
+- [initializer()](#Initializable-initializer--) +- [reinitializer(version)](#Initializable-reinitializer-uint64-) +- [onlyInitializing()](#Initializable-onlyInitializing--) +
+
+ +
+

Functions

+
+- [_checkInitializing()](#Initializable-_checkInitializing--) +- [_disableInitializers()](#Initializable-_disableInitializers--) +- [_getInitializedVersion()](#Initializable-_getInitializedVersion--) +- [_isInitializing()](#Initializable-_isInitializing--) +- [_initializableStorageSlot()](#Initializable-_initializableStorageSlot--) +
@@ -1839,262 +2158,3 @@ The contract is not initializing.
- - -
- -## `UUPSUpgradeable` - - - - - -
- -```solidity -import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol"; -``` - -An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an -[`ERC1967Proxy`](#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 [`UUPSUpgradeable._authorizeUpgrade`](#UUPSUpgradeable-_authorizeUpgrade-address-) function must be overridden to include access restriction to the upgrade mechanism. - -@custom:stateless - -
-

Modifiers

-
-- [onlyProxy()](#UUPSUpgradeable-onlyProxy--) -- [notDelegated()](#UUPSUpgradeable-notDelegated--) -
-
- -
-

Functions

-
-- [proxiableUUID()](#UUPSUpgradeable-proxiableUUID--) -- [upgradeToAndCall(newImplementation, data)](#UUPSUpgradeable-upgradeToAndCall-address-bytes-) -- [_checkProxy()](#UUPSUpgradeable-_checkProxy--) -- [_checkNotDelegated()](#UUPSUpgradeable-_checkNotDelegated--) -- [_authorizeUpgrade(newImplementation)](#UUPSUpgradeable-_authorizeUpgrade-address-) -- [UPGRADE_INTERFACE_VERSION()](#UUPSUpgradeable-UPGRADE_INTERFACE_VERSION-string) -#### IERC1822Proxiable [!toc] -
-
- -
-

Errors

-
-- [UUPSUnauthorizedCallContext()](#UUPSUpgradeable-UUPSUnauthorizedCallContext--) -- [UUPSUnsupportedProxiableUUID(slot)](#UUPSUpgradeable-UUPSUnsupportedProxiableUUID-bytes32-) -#### IERC1822Proxiable [!toc] -
-
- - - -
-
-

onlyProxy()

-
-

internal

-# -
-
- -
- -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. - -
-
- - - -
-
-

notDelegated()

-
-

internal

-# -
-
- -
- -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. - -
-
- - - -
-
-

proxiableUUID() → bytes32

-
-

external

-# -
-
-
- -Implementation of the ERC-1822 [`IERC1822Proxiable.proxiableUUID`](/contracts/5.x/api/interfaces#IERC1822Proxiable-proxiableUUID--) function. This returns the storage slot used by the -implementation. It is used to validate the implementation's compatibility when performing an upgrade. - - -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. - - -
-
- - - -
-
-

upgradeToAndCall(address newImplementation, bytes data)

-
-

public

-# -
-
-
- -Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call -encoded in `data`. - -Calls [`UUPSUpgradeable._authorizeUpgrade`](#UUPSUpgradeable-_authorizeUpgrade-address-). - -Emits an [`IERC1967.Upgraded`](/contracts/5.x/api/interfaces#IERC1967-Upgraded-address-) event. - -
-
- - - -
-
-

_checkProxy()

-
-

internal

-# -
-
-
- -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. - -
-
- - - -
-
-

_checkNotDelegated()

-
-

internal

-# -
-
-
- -Reverts if the execution is performed via delegatecall. -See [`UUPSUpgradeable.notDelegated`](#UUPSUpgradeable-notDelegated--). - -
-
- - - -
-
-

_authorizeUpgrade(address newImplementation)

-
-

internal

-# -
-
-
- -Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by -[`ERC1967Utils.upgradeToAndCall`](#ERC1967Utils-upgradeToAndCall-address-bytes-). - -Normally, this function will use an [access control](/contracts/5.x/api/access) modifier such as [`Ownable.onlyOwner`](/contracts/5.x/api/access#Ownable-onlyOwner--). - -```solidity -function _authorizeUpgrade(address) internal onlyOwner {} -``` - -
-
- - - -
-
-

UPGRADE_INTERFACE_VERSION() → string

-
-

public

-# -
-
-
- -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. - -
-
- - - -
-
-

UUPSUnauthorizedCallContext()

-
-

error

-# -
-
-
- -The call is from an unauthorized context. - -
-
- - - -
-
-

UUPSUnsupportedProxiableUUID(bytes32 slot)

-
-

error

-# -
-
-
- -The storage `slot` is unsupported as a UUID. - -
-
diff --git a/content/contracts/5.x/api/token/ERC1155.mdx b/content/contracts/5.x/api/token/ERC1155.mdx index 69846298..acdcbe2b 100644 --- a/content/contracts/5.x/api/token/ERC1155.mdx +++ b/content/contracts/5.x/api/token/ERC1155.mdx @@ -13,6 +13,7 @@ Additionally there are multiple custom extensions, including: * designation of addresses that can pause token transfers for all users ([`ERC1155Pausable`](#ERC1155Pausable)). * destruction of own tokens ([`ERC1155Burnable`](#ERC1155Burnable)). +* crosschain bridging of tokens through ERC-7786 gateways ([`ERC1155Crosschain`](#ERC1155Crosschain)). This core set of contracts is designed to be unopinionated, allowing developers to access the internal functions in ERC-1155 (such as [`_mint`](#ERC1155-_mint-address-uint256-uint256-bytes-)) and expose them as external functions in the way they prefer. @@ -30,10 +31,12 @@ This core set of contracts is designed to be unopinionated, allowing developers ## Extensions -[`ERC1155Pausable`](#ERC1155Pausable) - [`ERC1155Burnable`](#ERC1155Burnable) +[`ERC1155Crosschain`](#ERC1155Crosschain) + +[`ERC1155Pausable`](#ERC1155Pausable) + [`ERC1155Supply`](#ERC1155Supply) [`ERC1155URIStorage`](#ERC1155URIStorage) @@ -48,9 +51,9 @@ This core set of contracts is designed to be unopinionated, allowing developers
-## `ERC1155` +## `ERC1155` - + @@ -76,8 +79,10 @@ Originally based on code by Enjin: https://github.com/enjin/erc-1155 - [isApprovedForAll(account, operator)](#ERC1155-isApprovedForAll-address-address-) - [safeTransferFrom(from, to, id, value, data)](#ERC1155-safeTransferFrom-address-address-uint256-uint256-bytes-) - [safeBatchTransferFrom(from, to, ids, values, data)](#ERC1155-safeBatchTransferFrom-address-address-uint256---uint256---bytes-) +- [_checkAuthorized(operator, owner)](#ERC1155-_checkAuthorized-address-address-) - [_update(from, to, ids, values)](#ERC1155-_update-address-address-uint256---uint256---) - [_updateWithAcceptanceCheck(from, to, ids, values, data)](#ERC1155-_updateWithAcceptanceCheck-address-address-uint256---uint256---bytes-) +- [_updateWithAcceptanceCheck(from, to, ids, values, data, batch)](#ERC1155-_updateWithAcceptanceCheck-address-address-uint256---uint256---bytes-bool-) - [_safeTransferFrom(from, to, id, value, data)](#ERC1155-_safeTransferFrom-address-address-uint256-uint256-bytes-) - [_safeBatchTransferFrom(from, to, ids, values, data)](#ERC1155-_safeBatchTransferFrom-address-address-uint256---uint256---bytes-) - [_setURI(newuri)](#ERC1155-_setURI-string-) @@ -316,7 +321,7 @@ acceptance magic value.
-[Batched](/contracts/5.x/erc1155) version of [`ERC1155.safeTransferFrom`](#ERC1155-safeTransferFrom-address-address-uint256-uint256-bytes-). +[Batched](/contracts/5.x/erc1155#batch-operations) version of [`ERC1155.safeTransferFrom`](#ERC1155-safeTransferFrom-address-address-uint256-uint256-bytes-). This function can potentially allow a reentrancy attack when transferring tokens @@ -336,6 +341,23 @@ acceptance magic value.
+ + +
+
+

_checkAuthorized(address operator, address owner)

+
+

internal

+# +
+
+
+ +Checks if `operator` is authorized to transfer tokens owned by `owner`. Reverts with [`IERC1155Errors.ERC1155MissingApprovalForAll`](/contracts/5.x/api/interfaces#IERC1155Errors-ERC1155MissingApprovalForAll-address-address-) if not. + +
+
+
@@ -360,7 +382,7 @@ Requirements: - `ids` and `values` must have the same length. -The ERC-1155 acceptance check is not performed in this function. See [`ERC1155._updateWithAcceptanceCheck`](#ERC1155-_updateWithAcceptanceCheck-address-address-uint256---uint256---bytes-) instead. +The ERC-1155 acceptance check is not performed in this function. See [`ERC1155._updateWithAcceptanceCheck`](#ERC1155-_updateWithAcceptanceCheck-address-address-uint256---uint256---bytes-bool-) instead.
@@ -388,6 +410,36 @@ update to the contract state after this function would break the check-effect-in overriding [`ERC1155._update`](#ERC1155-_update-address-address-uint256---uint256---) instead. + +This version is kept for backward compatibility. We recommend calling the alternative version with a boolean +flag in order to achieve better control over which hook to call. + + +
+
+ + + +
+
+

_updateWithAcceptanceCheck(address from, address to, uint256[] ids, uint256[] values, bytes data, bool batch)

+
+

internal

+# +
+
+
+ +Version of [`ERC1155._update`](#ERC1155-_update-address-address-uint256---uint256---) that performs the token acceptance check by calling +[`IERC1155Receiver.onERC1155Received`](#IERC1155Receiver-onERC1155Received-address-address-uint256-uint256-bytes-) or [`IERC1155Receiver.onERC1155BatchReceived`](#IERC1155Receiver-onERC1155BatchReceived-address-address-uint256---uint256---bytes-) on the receiver address if it +contains code (eg. is a smart contract at the moment of execution). + + +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 [`ERC1155._update`](#ERC1155-_update-address-address-uint256---uint256---) instead. + +
@@ -429,7 +481,7 @@ acceptance magic value.
-[Batched](/contracts/5.x/erc1155) version of [`ERC1155._safeTransferFrom`](#ERC1155-_safeTransferFrom-address-address-uint256-uint256-bytes-). +[Batched](/contracts/5.x/erc1155#batch-operations) version of [`ERC1155._safeTransferFrom`](#ERC1155-_safeTransferFrom-address-address-uint256-uint256-bytes-). Emits a [`IERC1155.TransferBatch`](#IERC1155-TransferBatch-address-address-address-uint256---uint256---) event. @@ -512,7 +564,7 @@ acceptance magic value.
-[Batched](/contracts/5.x/erc1155) version of [`ERC1155._mint`](#ERC1155-_mint-address-uint256-uint256-bytes-). +[Batched](/contracts/5.x/erc1155#batch-operations) version of [`ERC1155._mint`](#ERC1155-_mint-address-uint256-uint256-bytes-). Emits a [`IERC1155.TransferBatch`](#IERC1155-TransferBatch-address-address-address-uint256---uint256---) event. @@ -562,7 +614,7 @@ Requirements:
-[Batched](/contracts/5.x/erc1155) version of [`ERC1155._burn`](#ERC1155-_burn-address-uint256-uint256-). +[Batched](/contracts/5.x/erc1155#batch-operations) version of [`ERC1155._burn`](#ERC1155-_burn-address-uint256-uint256-). Emits a [`IERC1155.TransferBatch`](#IERC1155-TransferBatch-address-address-address-uint256---uint256---) event. @@ -593,6 +645,7 @@ Emits an [`IERC1155.ApprovalForAll`](#IERC1155-ApprovalForAll-address-address-bo Requirements: +- `owner` cannot be the zero address. - `operator` cannot be the zero address.
@@ -602,9 +655,9 @@ Requirements:
-## `IERC1155` +## `IERC1155` - + @@ -671,7 +724,7 @@ Returns the value of tokens of token type `id` owned by `account`.
-[Batched](/contracts/5.x/erc1155) version of [`IERC6909.balanceOf`](../interfaces#IERC6909-balanceOf-address-uint256-). +[Batched](/contracts/5.x/erc1155#batch-operations) version of [`ERC1155.balanceOf`](#ERC1155-balanceOf-address-uint256-). Requirements: @@ -768,7 +821,7 @@ acceptance magic value.
-[Batched](/contracts/5.x/erc1155) version of [`ERC1155.safeTransferFrom`](#ERC1155-safeTransferFrom-address-address-uint256-uint256-bytes-). +[Batched](/contracts/5.x/erc1155#batch-operations) version of [`ERC1155.safeTransferFrom`](#ERC1155-safeTransferFrom-address-address-uint256-uint256-bytes-). This function can potentially allow a reentrancy attack when transferring tokens @@ -867,9 +920,9 @@ returned by [`IERC1155MetadataURI.uri`](#IERC1155MetadataURI-uri-uint256-).
-## `IERC1155Receiver` +## `IERC1155Receiver` - + @@ -945,9 +998,9 @@ To accept the transfer(s), this must return
-## `ERC1155Burnable` +## `ERC1155Burnable` - + @@ -974,8 +1027,10 @@ own tokens and those that they have been approved to use. - [isApprovedForAll(account, operator)](#ERC1155-isApprovedForAll-address-address-) - [safeTransferFrom(from, to, id, value, data)](#ERC1155-safeTransferFrom-address-address-uint256-uint256-bytes-) - [safeBatchTransferFrom(from, to, ids, values, data)](#ERC1155-safeBatchTransferFrom-address-address-uint256---uint256---bytes-) +- [_checkAuthorized(operator, owner)](#ERC1155-_checkAuthorized-address-address-) - [_update(from, to, ids, values)](#ERC1155-_update-address-address-uint256---uint256---) - [_updateWithAcceptanceCheck(from, to, ids, values, data)](#ERC1155-_updateWithAcceptanceCheck-address-address-uint256---uint256---bytes-) +- [_updateWithAcceptanceCheck(from, to, ids, values, data, batch)](#ERC1155-_updateWithAcceptanceCheck-address-address-uint256---uint256---bytes-bool-) - [_safeTransferFrom(from, to, id, value, data)](#ERC1155-_safeTransferFrom-address-address-uint256-uint256-bytes-) - [_safeBatchTransferFrom(from, to, ids, values, data)](#ERC1155-_safeBatchTransferFrom-address-address-uint256---uint256---bytes-) - [_setURI(newuri)](#ERC1155-_setURI-string-) @@ -1057,13 +1112,198 @@ own tokens and those that they have been approved to use.
+ + +
+ +## `ERC1155Crosschain` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Crosschain.sol"; +``` + +Extension of [`ERC1155`](#ERC1155) that makes it natively cross-chain using the ERC-7786 based [`BridgeMultiToken`](/contracts/5.x/api/crosschain#BridgeMultiToken). + +This extension makes the token compatible with: +* [`ERC1155Crosschain`](#ERC1155Crosschain) instances on other chains, +* [`ERC1155`](#ERC1155) instances on other chains that are bridged using [`BridgeERC1155`](/contracts/5.x/api/crosschain#BridgeERC1155), + +
+

Functions

+
+- [crosschainTransferFrom(from, to, id, value)](#ERC1155Crosschain-crosschainTransferFrom-address-bytes-uint256-uint256-) +- [crosschainTransferFrom(from, to, ids, values)](#ERC1155Crosschain-crosschainTransferFrom-address-bytes-uint256---uint256---) +- [_onSend(from, ids, values)](#ERC1155Crosschain-_onSend-address-uint256---uint256---) +- [_onReceive(to, ids, values)](#ERC1155Crosschain-_onReceive-address-uint256---uint256---) +#### BridgeMultiToken [!toc] +- [_crosschainTransfer(from, to, ids, values)](#BridgeMultiToken-_crosschainTransfer-address-bytes-uint256---uint256---) +- [_processMessage(, receiveId, , payload)](#BridgeMultiToken-_processMessage-address-bytes32-bytes-bytes-) +#### CrosschainLinked [!toc] +- [getLink(chain)](#CrosschainLinked-getLink-bytes-) +- [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) +- [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) +- [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) +#### ERC7786Recipient [!toc] +- [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) +#### IERC7786Recipient [!toc] +#### ERC1155 [!toc] +- [supportsInterface(interfaceId)](#ERC1155-supportsInterface-bytes4-) +- [uri()](#ERC1155-uri-uint256-) +- [balanceOf(account, id)](#ERC1155-balanceOf-address-uint256-) +- [balanceOfBatch(accounts, ids)](#ERC1155-balanceOfBatch-address---uint256---) +- [setApprovalForAll(operator, approved)](#ERC1155-setApprovalForAll-address-bool-) +- [isApprovedForAll(account, operator)](#ERC1155-isApprovedForAll-address-address-) +- [safeTransferFrom(from, to, id, value, data)](#ERC1155-safeTransferFrom-address-address-uint256-uint256-bytes-) +- [safeBatchTransferFrom(from, to, ids, values, data)](#ERC1155-safeBatchTransferFrom-address-address-uint256---uint256---bytes-) +- [_checkAuthorized(operator, owner)](#ERC1155-_checkAuthorized-address-address-) +- [_update(from, to, ids, values)](#ERC1155-_update-address-address-uint256---uint256---) +- [_updateWithAcceptanceCheck(from, to, ids, values, data)](#ERC1155-_updateWithAcceptanceCheck-address-address-uint256---uint256---bytes-) +- [_updateWithAcceptanceCheck(from, to, ids, values, data, batch)](#ERC1155-_updateWithAcceptanceCheck-address-address-uint256---uint256---bytes-bool-) +- [_safeTransferFrom(from, to, id, value, data)](#ERC1155-_safeTransferFrom-address-address-uint256-uint256-bytes-) +- [_safeBatchTransferFrom(from, to, ids, values, data)](#ERC1155-_safeBatchTransferFrom-address-address-uint256---uint256---bytes-) +- [_setURI(newuri)](#ERC1155-_setURI-string-) +- [_mint(to, id, value, data)](#ERC1155-_mint-address-uint256-uint256-bytes-) +- [_mintBatch(to, ids, values, data)](#ERC1155-_mintBatch-address-uint256---uint256---bytes-) +- [_burn(from, id, value)](#ERC1155-_burn-address-uint256-uint256-) +- [_burnBatch(from, ids, values)](#ERC1155-_burnBatch-address-uint256---uint256---) +- [_setApprovalForAll(owner, operator, approved)](#ERC1155-_setApprovalForAll-address-address-bool-) +#### IERC1155Errors [!toc] +#### IERC1155MetadataURI [!toc] +#### IERC1155 [!toc] +#### ERC165 [!toc] +#### IERC165 [!toc] +
+
+ +
+

Events

+
+#### BridgeMultiToken [!toc] +- [CrosschainMultiTokenTransferSent(sendId, from, to, ids, values)](#BridgeMultiToken-CrosschainMultiTokenTransferSent-bytes32-address-bytes-uint256---uint256---) +- [CrosschainMultiTokenTransferReceived(receiveId, from, to, ids, values)](#BridgeMultiToken-CrosschainMultiTokenTransferReceived-bytes32-bytes-address-uint256---uint256---) +#### CrosschainLinked [!toc] +- [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) +#### ERC7786Recipient [!toc] +#### IERC7786Recipient [!toc] +#### ERC1155 [!toc] +#### IERC1155Errors [!toc] +#### IERC1155MetadataURI [!toc] +#### IERC1155 [!toc] +- [TransferSingle(operator, from, to, id, value)](#IERC1155-TransferSingle-address-address-address-uint256-uint256-) +- [TransferBatch(operator, from, to, ids, values)](#IERC1155-TransferBatch-address-address-address-uint256---uint256---) +- [ApprovalForAll(account, operator, approved)](#IERC1155-ApprovalForAll-address-address-bool-) +- [URI(value, id)](#IERC1155-URI-string-uint256-) +#### ERC165 [!toc] +#### IERC165 [!toc] +
+
+ +
+

Errors

+
+#### BridgeMultiToken [!toc] +#### CrosschainLinked [!toc] +- [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) +#### ERC7786Recipient [!toc] +- [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) +#### IERC7786Recipient [!toc] +#### ERC1155 [!toc] +#### IERC1155Errors [!toc] +- [ERC1155InsufficientBalance(sender, balance, needed, tokenId)](#IERC1155Errors-ERC1155InsufficientBalance-address-uint256-uint256-uint256-) +- [ERC1155InvalidSender(sender)](#IERC1155Errors-ERC1155InvalidSender-address-) +- [ERC1155InvalidReceiver(receiver)](#IERC1155Errors-ERC1155InvalidReceiver-address-) +- [ERC1155MissingApprovalForAll(operator, owner)](#IERC1155Errors-ERC1155MissingApprovalForAll-address-address-) +- [ERC1155InvalidApprover(approver)](#IERC1155Errors-ERC1155InvalidApprover-address-) +- [ERC1155InvalidOperator(operator)](#IERC1155Errors-ERC1155InvalidOperator-address-) +- [ERC1155InvalidArrayLength(idsLength, valuesLength)](#IERC1155Errors-ERC1155InvalidArrayLength-uint256-uint256-) +#### IERC1155MetadataURI [!toc] +#### IERC1155 [!toc] +#### ERC165 [!toc] +#### IERC165 [!toc] +
+
+ + + +
+
+

crosschainTransferFrom(address from, bytes to, uint256 id, uint256 value) → bytes32

+
+

public

+# +
+
+
+ +TransferFrom variant of [`ERC1155Crosschain.crosschainTransferFrom`](#ERC1155Crosschain-crosschainTransferFrom-address-bytes-uint256---uint256---), using ERC1155 allowance from the sender to the caller. + +
+
+ + + +
+
+

crosschainTransferFrom(address from, bytes to, uint256[] ids, uint256[] values) → bytes32

+
+

public

+# +
+
+
+ +TransferFrom variant of [`ERC1155Crosschain.crosschainTransferFrom`](#ERC1155Crosschain-crosschainTransferFrom-address-bytes-uint256---uint256---), using ERC1155 allowance from the sender to the caller. + +
+
+ + + +
+
+

_onSend(address from, uint256[] ids, uint256[] values)

+
+

internal

+# +
+
+
+ +"Locking" tokens is achieved through burning + +
+
+ + + +
+
+

_onReceive(address to, uint256[] ids, uint256[] values)

+
+

internal

+# +
+
+
+ +"Unlocking" tokens is achieved through minting + +
+
+
-## `ERC1155Pausable` +## `ERC1155Pausable` - + @@ -1082,8 +1322,8 @@ event of a large bug. 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`](../utils#Pausable-_pause--) and [`Pausable._unpause`](../utils#Pausable-_unpause--) internal functions, with appropriate -access control, e.g. using [`AccessControl`](../access#AccessControl) or [`Ownable`](../access#Ownable). Not doing so will +[`Pausable._pause`](/contracts/5.x/api/utils#Pausable-_pause--) and [`Pausable._unpause`](/contracts/5.x/api/utils#Pausable-_unpause--) internal functions, with appropriate +access control, e.g. using [`AccessControl`](/contracts/5.x/api/access#AccessControl) or [`Ownable`](/contracts/5.x/api/access#Ownable). Not doing so will make the contract pause mechanism of the contract unreachable, and thus unusable. @@ -1106,7 +1346,9 @@ make the contract pause mechanism of the contract unreachable, and thus unusable - [isApprovedForAll(account, operator)](#ERC1155-isApprovedForAll-address-address-) - [safeTransferFrom(from, to, id, value, data)](#ERC1155-safeTransferFrom-address-address-uint256-uint256-bytes-) - [safeBatchTransferFrom(from, to, ids, values, data)](#ERC1155-safeBatchTransferFrom-address-address-uint256---uint256---bytes-) +- [_checkAuthorized(operator, owner)](#ERC1155-_checkAuthorized-address-address-) - [_updateWithAcceptanceCheck(from, to, ids, values, data)](#ERC1155-_updateWithAcceptanceCheck-address-address-uint256---uint256---bytes-) +- [_updateWithAcceptanceCheck(from, to, ids, values, data, batch)](#ERC1155-_updateWithAcceptanceCheck-address-address-uint256---uint256---bytes-bool-) - [_safeTransferFrom(from, to, id, value, data)](#ERC1155-_safeTransferFrom-address-address-uint256-uint256-bytes-) - [_safeBatchTransferFrom(from, to, ids, values, data)](#ERC1155-_safeBatchTransferFrom-address-address-uint256---uint256---bytes-) - [_setURI(newuri)](#ERC1155-_setURI-string-) @@ -1189,9 +1431,9 @@ Requirements:
-## `ERC1155Supply` +## `ERC1155Supply` - + @@ -1204,16 +1446,18 @@ import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol"; 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. +clearly identified. Note: While a `totalSupply` of 1 may mean the +corresponding token is an NFT, there are no inherent guarantees that +no more tokens with the same id will be minted in future. 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. + +This extension should not be added in an upgrade to an already deployed contract. +

Functions

@@ -1231,7 +1475,9 @@ CAUTION: This extension should not be added in an upgrade to an already deployed - [isApprovedForAll(account, operator)](#ERC1155-isApprovedForAll-address-address-) - [safeTransferFrom(from, to, id, value, data)](#ERC1155-safeTransferFrom-address-address-uint256-uint256-bytes-) - [safeBatchTransferFrom(from, to, ids, values, data)](#ERC1155-safeBatchTransferFrom-address-address-uint256---uint256---bytes-) +- [_checkAuthorized(operator, owner)](#ERC1155-_checkAuthorized-address-address-) - [_updateWithAcceptanceCheck(from, to, ids, values, data)](#ERC1155-_updateWithAcceptanceCheck-address-address-uint256---uint256---bytes-) +- [_updateWithAcceptanceCheck(from, to, ids, values, data, batch)](#ERC1155-_updateWithAcceptanceCheck-address-address-uint256---uint256---bytes-bool-) - [_safeTransferFrom(from, to, id, value, data)](#ERC1155-_safeTransferFrom-address-address-uint256-uint256-bytes-) - [_safeBatchTransferFrom(from, to, ids, values, data)](#ERC1155-_safeBatchTransferFrom-address-address-uint256---uint256---bytes-) - [_setURI(newuri)](#ERC1155-_setURI-string-) @@ -1295,7 +1541,7 @@ CAUTION: This extension should not be added in an upgrade to an already deployed
-Total value of tokens in with a given id. +Total value of tokens with a given id.
@@ -1329,7 +1575,7 @@ Total value of tokens.
-Indicates whether any token exist with a given id, or not. +Indicates whether any tokens exist with a given id, or not.
@@ -1358,7 +1604,7 @@ Requirements: - `ids` and `values` must have the same length. -The ERC-1155 acceptance check is not performed in this function. See [`ERC1155._updateWithAcceptanceCheck`](#ERC1155-_updateWithAcceptanceCheck-address-address-uint256---uint256---bytes-) instead. +The ERC-1155 acceptance check is not performed in this function. See [`ERC1155._updateWithAcceptanceCheck`](#ERC1155-_updateWithAcceptanceCheck-address-address-uint256---uint256---bytes-bool-) instead.
@@ -1368,9 +1614,9 @@ The ERC-1155 acceptance check is not performed in this function. See [`ERC1155._
-## `ERC1155URIStorage` +## `ERC1155URIStorage` - + @@ -1397,8 +1643,10 @@ Inspired by the [`ERC721URIStorage`](/contracts/5.x/api/token/ERC721#ERC721URISt - [isApprovedForAll(account, operator)](#ERC1155-isApprovedForAll-address-address-) - [safeTransferFrom(from, to, id, value, data)](#ERC1155-safeTransferFrom-address-address-uint256-uint256-bytes-) - [safeBatchTransferFrom(from, to, ids, values, data)](#ERC1155-safeBatchTransferFrom-address-address-uint256---uint256---bytes-) +- [_checkAuthorized(operator, owner)](#ERC1155-_checkAuthorized-address-address-) - [_update(from, to, ids, values)](#ERC1155-_update-address-address-uint256---uint256---) - [_updateWithAcceptanceCheck(from, to, ids, values, data)](#ERC1155-_updateWithAcceptanceCheck-address-address-uint256---uint256---bytes-) +- [_updateWithAcceptanceCheck(from, to, ids, values, data, batch)](#ERC1155-_updateWithAcceptanceCheck-address-address-uint256---uint256---bytes-bool-) - [_safeTransferFrom(from, to, id, value, data)](#ERC1155-_safeTransferFrom-address-address-uint256-uint256-bytes-) - [_safeBatchTransferFrom(from, to, ids, values, data)](#ERC1155-_safeBatchTransferFrom-address-address-uint256---uint256---bytes-) - [_setURI(newuri)](#ERC1155-_setURI-string-) @@ -1520,9 +1768,9 @@ Sets `baseURI` as the `_baseURI` for all tokens
-## `IERC1155MetadataURI` +## `IERC1155MetadataURI` - + @@ -1587,9 +1835,9 @@ clients with the actual token type ID.
-## `ERC1155Holder` +## `ERC1155Holder` - + @@ -1676,9 +1924,9 @@ This function call must use less than 30 000 gas.
-## `ERC1155Utils` +## `ERC1155Utils` - + @@ -1745,3 +1993,4 @@ the transfer.
+ diff --git a/content/contracts/5.x/api/token/ERC20.mdx b/content/contracts/5.x/api/token/ERC20.mdx index f0473dda..272a596c 100644 --- a/content/contracts/5.x/api/token/ERC20.mdx +++ b/content/contracts/5.x/api/token/ERC20.mdx @@ -21,6 +21,7 @@ Additionally there are multiple custom extensions, including: * [`ERC20Bridgeable`](#ERC20Bridgeable): compatibility with crosschain bridges through ERC-7802. * [`ERC20Burnable`](#ERC20Burnable): destruction of own tokens. * [`ERC20Capped`](#ERC20Capped): enforcement of a cap to the total supply when minting tokens. +* [`ERC20Crosschain`](#ERC20Crosschain): embedded [`BridgeFungible`](/contracts/5.x/api/crosschain#BridgeFungible) bridge, making the token crosschain through the use of ERC-7786 gateways. * [`ERC20Pausable`](#ERC20Pausable): ability to pause token transfers. * [`ERC20FlashMint`](#ERC20FlashMint): token level support for flash loans through the minting and burning of ephemeral tokens (standardized as ERC-3156). * [`ERC20Votes`](#ERC20Votes): support for voting and vote delegation. [See the governance guide for a minimal example (with the required overrides when combining ERC20 + ERC20Permit + ERC20Votes)](/contracts/5.x/api/governance#token). @@ -35,7 +36,7 @@ Finally, there are some utilities to interact with ERC-20 contracts in various w Other utilities that support ERC-20 assets can be found in the codebase: -* ERC-20 tokens can be timelocked (held for a beneficiary until a specified time) or vested (released following a given schedule) using a [`VestingWallet`](../finance#VestingWallet). +* ERC-20 tokens can be timelocked (held for a beneficiary until a specified time) or vested (released following a given schedule) using a [`VestingWallet`](/contracts/5.x/api/finance#VestingWallet). This core set of contracts is designed to be unopinionated, allowing developers to access the internal functions in ERC-20 (such as [`_mint`](#ERC20-_mint-address-uint256-)) and expose them as external functions in the way they prefer. @@ -61,6 +62,8 @@ This core set of contracts is designed to be unopinionated, allowing developers [`ERC20Capped`](#ERC20Capped) +[`ERC20Crosschain`](#ERC20Crosschain) + [`ERC20Pausable`](#ERC20Pausable) [`ERC20Votes`](#ERC20Votes) @@ -85,9 +88,9 @@ This core set of contracts is designed to be unopinionated, allowing developers
-## `ERC20` +## `ERC20` - + @@ -100,7 +103,7 @@ import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; Implementation of the [`IERC20`](#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 [`ERC1155._mint`](/contracts/5.x/api/token/ERC1155#ERC1155-_mint-address-uint256-uint256-bytes-). +that a supply mechanism has to be added in a derived contract using [`ERC20._mint`](#ERC20-_mint-address-uint256-). For a detailed writeup see our guide @@ -108,7 +111,7 @@ For a detailed writeup see our guide to implement supply mechanisms](https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226). -The default value of [`IERC6909Metadata.decimals`](../interfaces#IERC6909Metadata-decimals-uint256-) is 18. To change this, you should override +The default value of [`ERC20.decimals`](#ERC20-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 @@ -180,7 +183,7 @@ applications.
-Sets the values for [`Governor.name`](../governance#Governor-name--) and [`IERC6909Metadata.symbol`](../interfaces#IERC6909Metadata-symbol-uint256-). +Sets the values for [`ERC20.name`](#ERC20-name--) and [`ERC20.symbol`](#ERC20-symbol--). Both values are immutable: they can only be set once during construction. @@ -320,10 +323,10 @@ Requirements:
Returns the remaining number of tokens that `spender` will be -allowed to spend on behalf of `owner` through [`IERC6909.transferFrom`](../interfaces#IERC6909-transferFrom-address-address-uint256-uint256-). This is +allowed to spend on behalf of `owner` through [`ERC20.transferFrom`](#ERC20-transferFrom-address-address-uint256-). This is zero by default. -This value changes when [`IERC6909.approve`](../interfaces#IERC6909-approve-address-uint256-uint256-) or [`IERC6909.transferFrom`](../interfaces#IERC6909-transferFrom-address-address-uint256-uint256-) are called. +This value changes when [`ERC20.approve`](#ERC20-approve-address-uint256-) or [`ERC20.transferFrom`](#ERC20-transferFrom-address-address-uint256-) are called.
@@ -368,7 +371,7 @@ Requirements: See [`IERC20.transferFrom`](#IERC20-transferFrom-address-address-uint256-). -Skips emitting an [`IERC6909.Approval`](../interfaces#IERC6909-Approval-address-address-uint256-uint256-) event indicating an allowance update. This is not +Skips emitting an [`IERC20.Approval`](#IERC20-Approval-address-address-uint256-) event indicating an allowance update. This is not required by the ERC. See [_approve](#ERC20-_approve-address-address-uint256-bool-). @@ -400,13 +403,13 @@ Requirements: Moves a `value` amount of tokens from `from` to `to`. -This internal function is equivalent to [`IERC6909.transfer`](../interfaces#IERC6909-transfer-address-uint256-uint256-), and can be used to +This internal function is equivalent to [`ERC20.transfer`](#ERC20-transfer-address-uint256-), and can be used to e.g. implement automatic token fees, slashing mechanisms, etc. -Emits a [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event. +Emits a [`IERC20.Transfer`](#IERC20-Transfer-address-address-uint256-) event. -This function is not virtual, [`ERC1155._update`](/contracts/5.x/api/token/ERC1155#ERC1155-_update-address-address-uint256---uint256---) should be overridden instead. +This function is not virtual, [`ERC20._update`](#ERC20-_update-address-address-uint256-) should be overridden instead.
@@ -428,7 +431,7 @@ Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding this function. -Emits a [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event. +Emits a [`IERC20.Transfer`](#IERC20-Transfer-address-address-uint256-) event.
@@ -448,10 +451,10 @@ Emits a [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-ad Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0). Relies on the `_update` mechanism -Emits a [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event with `from` set to the zero address. +Emits a [`IERC20.Transfer`](#IERC20-Transfer-address-address-uint256-) event with `from` set to the zero address. -This function is not virtual, [`ERC1155._update`](/contracts/5.x/api/token/ERC1155#ERC1155-_update-address-address-uint256---uint256---) should be overridden instead. +This function is not virtual, [`ERC20._update`](#ERC20-_update-address-address-uint256-) should be overridden instead.
@@ -472,10 +475,10 @@ This function is not virtual, [`ERC1155._update`](/contracts/5.x/api/token/ERC11 Destroys a `value` amount of tokens from `account`, lowering the total supply. Relies on the `_update` mechanism. -Emits a [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event with `to` set to the zero address. +Emits a [`IERC20.Transfer`](#IERC20-Transfer-address-address-uint256-) event with `to` set to the zero address. -This function is not virtual, [`ERC1155._update`](/contracts/5.x/api/token/ERC1155#ERC1155-_update-address-address-uint256---uint256---) should be overridden instead +This function is not virtual, [`ERC20._update`](#ERC20-_update-address-address-uint256-) should be overridden instead
@@ -498,7 +501,7 @@ 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 [`IERC6909.Approval`](../interfaces#IERC6909-Approval-address-address-uint256-uint256-) event. +Emits an [`IERC20.Approval`](#IERC20-Approval-address-address-uint256-) event. Requirements: @@ -522,7 +525,7 @@ Overrides to this logic should be done to the variant with an additional `bool e
-Variant of [`ERC20._approve`](#ERC20-_approve-address-address-uint256-bool-) with an optional flag to enable or disable the [`IERC6909.Approval`](../interfaces#IERC6909-Approval-address-address-uint256-uint256-) event. +Variant of [`ERC20._approve`](#ERC20-_approve-address-address-uint256-bool-) with an optional flag to enable or disable the [`IERC20.Approval`](#IERC20-Approval-address-address-uint256-) event. By default (when calling [`ERC20._approve`](#ERC20-_approve-address-address-uint256-bool-)) the flag is set to true. On the other hand, approval changes made by `_spendAllowance` during the `transferFrom` operation sets the flag to false. This saves gas by not emitting any @@ -559,7 +562,7 @@ 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 [`IERC6909.Approval`](../interfaces#IERC6909-Approval-address-address-uint256-uint256-) event. +Does not emit an [`IERC20.Approval`](#IERC20-Approval-address-address-uint256-) event.
@@ -568,9 +571,9 @@ Does not emit an [`IERC6909.Approval`](../interfaces#IERC6909-Approval-address-a
-## `IERC20` +## `IERC20` - + @@ -652,7 +655,7 @@ Moves a `value` amount of tokens from the caller's account to `to`. Returns a boolean value indicating whether the operation succeeded. -Emits a [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event. +Emits a [`IERC20.Transfer`](#IERC20-Transfer-address-address-uint256-) event.
@@ -670,10 +673,10 @@ Emits a [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-ad
Returns the remaining number of tokens that `spender` will be -allowed to spend on behalf of `owner` through [`IERC6909.transferFrom`](../interfaces#IERC6909-transferFrom-address-address-uint256-uint256-). This is +allowed to spend on behalf of `owner` through [`ERC20.transferFrom`](#ERC20-transferFrom-address-address-uint256-). This is zero by default. -This value changes when [`IERC6909.approve`](../interfaces#IERC6909-approve-address-uint256-uint256-) or [`IERC6909.transferFrom`](../interfaces#IERC6909-transferFrom-address-address-uint256-uint256-) are called. +This value changes when [`ERC20.approve`](#ERC20-approve-address-uint256-) or [`ERC20.transferFrom`](#ERC20-transferFrom-address-address-uint256-) are called.
@@ -704,7 +707,7 @@ desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 -Emits an [`IERC6909.Approval`](../interfaces#IERC6909-Approval-address-address-uint256-uint256-) event. +Emits an [`IERC20.Approval`](#IERC20-Approval-address-address-uint256-) event.
@@ -727,7 +730,7 @@ allowance. Returns a boolean value indicating whether the operation succeeded. -Emits a [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event. +Emits a [`IERC20.Transfer`](#IERC20-Transfer-address-address-uint256-) event.
@@ -766,46 +769,57 @@ Note that `value` may be zero.
Emitted when the allowance of a `spender` for an `owner` is set by -a call to [`IERC6909.approve`](../interfaces#IERC6909-approve-address-uint256-uint256-). `value` is the new allowance. +a call to [`ERC20.approve`](#ERC20-approve-address-uint256-). `value` is the new allowance.
- +
-## `ERC1363` +## `ERC20Crosschain` - +
```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC1363.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Crosschain.sol"; ``` -Extension of [`ERC20`](#ERC20) tokens that adds support for code execution after transfers and approvals -on recipient contracts. Calls after transfers are enabled through the [`ERC1363.transferAndCall`](#ERC1363-transferAndCall-address-uint256-bytes-) and -[`ERC1363.transferFromAndCall`](#ERC1363-transferFromAndCall-address-address-uint256-bytes-) methods while calls after approvals can be made with [`ERC1363.approveAndCall`](#ERC1363-approveAndCall-address-uint256-bytes-) +Extension of [`ERC20`](#ERC20) that makes it natively cross-chain using the ERC-7786 based [`BridgeFungible`](/contracts/5.x/api/crosschain#BridgeFungible). -_Available since v5.1._ +This extension makes the token compatible with counterparts on other chains, which can be: +* [`ERC20Crosschain`](#ERC20Crosschain) instances, +* [`ERC20`](#ERC20) instances that are bridged using [`BridgeERC20`](/contracts/5.x/api/crosschain#BridgeERC20), +* [`ERC20Bridgeable`](#ERC20Bridgeable) instances that are bridged using [`BridgeERC7802`](/contracts/5.x/api/crosschain#BridgeERC7802). + +It is mostly equivalent to inheriting from both [`ERC20Bridgeable`](#ERC20Bridgeable) and [`BridgeERC7802`](/contracts/5.x/api/crosschain#BridgeERC7802), and configuring them such +that: +* `token` (on the [`BridgeERC7802`](/contracts/5.x/api/crosschain#BridgeERC7802) side) is `address(this)`, +* `_checkTokenBridge` (on the [`ERC20Bridgeable`](#ERC20Bridgeable) side) is implemented such that it only accepts self-calls.

Functions

-- [supportsInterface(interfaceId)](#ERC1363-supportsInterface-bytes4-) -- [transferAndCall(to, value)](#ERC1363-transferAndCall-address-uint256-) -- [transferAndCall(to, value, data)](#ERC1363-transferAndCall-address-uint256-bytes-) -- [transferFromAndCall(from, to, value)](#ERC1363-transferFromAndCall-address-address-uint256-) -- [transferFromAndCall(from, to, value, data)](#ERC1363-transferFromAndCall-address-address-uint256-bytes-) -- [approveAndCall(spender, value)](#ERC1363-approveAndCall-address-uint256-) -- [approveAndCall(spender, value, data)](#ERC1363-approveAndCall-address-uint256-bytes-) -#### IERC1363 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] +- [crosschainTransferFrom(from, to, amount)](#ERC20Crosschain-crosschainTransferFrom-address-bytes-uint256-) +- [_onSend(from, amount)](#ERC20Crosschain-_onSend-address-uint256-) +- [_onReceive(to, amount)](#ERC20Crosschain-_onReceive-address-uint256-) +#### BridgeFungible [!toc] +- [crosschainTransfer(to, amount)](#BridgeFungible-crosschainTransfer-bytes-uint256-) +- [_crosschainTransfer(from, to, amount)](#BridgeFungible-_crosschainTransfer-address-bytes-uint256-) +- [_processMessage(, receiveId, , payload)](#BridgeFungible-_processMessage-address-bytes32-bytes-bytes-) +#### CrosschainLinked [!toc] +- [getLink(chain)](#CrosschainLinked-getLink-bytes-) +- [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) +- [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) +- [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) +#### ERC7786Recipient [!toc] +- [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) +#### IERC7786Recipient [!toc] #### ERC20 [!toc] - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) @@ -832,9 +846,13 @@ _Available since v5.1._

Events

-#### IERC1363 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] +#### BridgeFungible [!toc] +- [CrosschainFungibleTransferSent(sendId, from, to, amount)](#BridgeFungible-CrosschainFungibleTransferSent-bytes32-address-bytes-uint256-) +- [CrosschainFungibleTransferReceived(receiveId, from, to, amount)](#BridgeFungible-CrosschainFungibleTransferReceived-bytes32-bytes-address-uint256-) +#### CrosschainLinked [!toc] +- [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) +#### ERC7786Recipient [!toc] +#### IERC7786Recipient [!toc] #### ERC20 [!toc] #### IERC20Errors [!toc] #### IERC20Metadata [!toc] @@ -847,12 +865,12 @@ _Available since v5.1._

Errors

-- [ERC1363TransferFailed(receiver, value)](#ERC1363-ERC1363TransferFailed-address-uint256-) -- [ERC1363TransferFromFailed(sender, receiver, value)](#ERC1363-ERC1363TransferFromFailed-address-address-uint256-) -- [ERC1363ApproveFailed(spender, value)](#ERC1363-ERC1363ApproveFailed-address-uint256-) -#### IERC1363 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] +#### BridgeFungible [!toc] +#### CrosschainLinked [!toc] +- [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) +#### ERC7786Recipient [!toc] +- [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) +#### IERC7786Recipient [!toc] #### ERC20 [!toc] #### IERC20Errors [!toc] - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) @@ -866,236 +884,343 @@ _Available since v5.1._
- +
-

supportsInterface(bytes4 interfaceId) → bool

+

crosschainTransferFrom(address from, bytes to, uint256 amount) → bytes32

public

-# +#
-Returns true if this contract implements the interface defined by -`interfaceId`. See the corresponding -[ERC section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) -to learn more about how these ids are created. - -This function call must use less than 30 000 gas. +Variant of [`BridgeFungible.crosschainTransfer`](/contracts/5.x/api/crosschain#BridgeFungible-crosschainTransfer-bytes-uint256-) that allows an authorized account (using ERC20 allowance) to operate on `from`'s assets.
- +
-

transferAndCall(address to, uint256 value) → bool

+

_onSend(address from, uint256 amount)

-

public

-# +

internal

+#
-Moves a `value` amount of tokens from the caller's account to `to` -and then calls [`IERC1363Receiver.onTransferReceived`](../interfaces#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) on `to`. Returns a flag that indicates -if the call succeeded. - -Requirements: - -- The target has code (i.e. is a contract). -- The target `to` must implement the [`IERC1363Receiver`](../interfaces#IERC1363Receiver) interface. -- The target must return the [`IERC1363Receiver.onTransferReceived`](../interfaces#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) selector to accept the transfer. -- The internal [`IERC6909.transfer`](../interfaces#IERC6909-transfer-address-uint256-uint256-) must succeed (returned `true`). +"Locking" tokens is achieved through burning
- +
-

transferAndCall(address to, uint256 value, bytes data) → bool

+

_onReceive(address to, uint256 amount)

-

public

-# +

internal

+#
-Variant of [`IERC1363.transferAndCall`](../interfaces#IERC1363-transferAndCall-address-uint256-bytes-) that accepts an additional `data` parameter with -no specified format. +"Unlocking" tokens is achieved through minting
- + + +
+ +## `ERC20FlashMint` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/token/ERC20/extensions/ERC20FlashMint.sol"; +``` + +Implementation of the ERC-3156 Flash loans extension, as defined in +[ERC-3156](https://eips.ethereum.org/EIPS/eip-3156). + +Adds the [`ERC20FlashMint.flashLoan`](#ERC20FlashMint-flashLoan-contract-IERC3156FlashBorrower-address-uint256-bytes-) method, which provides flash loan support at the token +level. By default there is no fee, but this can be changed by overriding [`ERC20FlashMint.flashFee`](#ERC20FlashMint-flashFee-address-uint256-). + + +When this extension is used along with the [`ERC20Capped`](#ERC20Capped) or [`ERC20Votes`](#ERC20Votes) extensions, +[`ERC20FlashMint.maxFlashLoan`](#ERC20FlashMint-maxFlashLoan-address-) will not correctly reflect the maximum that can be flash minted. We recommend +overriding [`ERC20FlashMint.maxFlashLoan`](#ERC20FlashMint-maxFlashLoan-address-) so that it correctly reflects the supply cap. + + +
+

Functions

+
+- [maxFlashLoan(token)](#ERC20FlashMint-maxFlashLoan-address-) +- [flashFee(token, value)](#ERC20FlashMint-flashFee-address-uint256-) +- [_flashFee(, )](#ERC20FlashMint-_flashFee-address-uint256-) +- [_flashFeeReceiver()](#ERC20FlashMint-_flashFeeReceiver--) +- [flashLoan(receiver, token, value, data)](#ERC20FlashMint-flashLoan-contract-IERC3156FlashBorrower-address-uint256-bytes-) +#### IERC3156FlashLender [!toc] +#### ERC20 [!toc] +- [name()](#ERC20-name--) +- [symbol()](#ERC20-symbol--) +- [decimals()](#ERC20-decimals--) +- [totalSupply()](#ERC20-totalSupply--) +- [balanceOf(account)](#ERC20-balanceOf-address-) +- [transfer(to, value)](#ERC20-transfer-address-uint256-) +- [allowance(owner, spender)](#ERC20-allowance-address-address-) +- [approve(spender, value)](#ERC20-approve-address-uint256-) +- [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) +- [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) +- [_update(from, to, value)](#ERC20-_update-address-address-uint256-) +- [_mint(account, value)](#ERC20-_mint-address-uint256-) +- [_burn(account, value)](#ERC20-_burn-address-uint256-) +- [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) +- [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) +- [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) +#### IERC20Errors [!toc] +#### IERC20Metadata [!toc] +#### IERC20 [!toc] +
+
+ +
+

Events

+
+#### IERC3156FlashLender [!toc] +#### ERC20 [!toc] +#### IERC20Errors [!toc] +#### IERC20Metadata [!toc] +#### IERC20 [!toc] +- [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) +- [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) +
+
+ +
+

Errors

+
+- [ERC3156UnsupportedToken(token)](#ERC20FlashMint-ERC3156UnsupportedToken-address-) +- [ERC3156ExceededMaxLoan(maxLoan)](#ERC20FlashMint-ERC3156ExceededMaxLoan-uint256-) +- [ERC3156InvalidReceiver(receiver)](#ERC20FlashMint-ERC3156InvalidReceiver-address-) +#### IERC3156FlashLender [!toc] +#### ERC20 [!toc] +#### IERC20Errors [!toc] +- [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) +- [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) +- [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) +- [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) +- [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) +- [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) +#### IERC20Metadata [!toc] +#### IERC20 [!toc] +
+
+ +
-

transferFromAndCall(address from, address to, uint256 value) → bool

+

maxFlashLoan(address token) → uint256

public

-# +#
-Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism -and then calls [`IERC1363Receiver.onTransferReceived`](../interfaces#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) on `to`. Returns a flag that indicates -if the call succeeded. - -Requirements: +Returns the maximum amount of tokens available for loan. -- The target has code (i.e. is a contract). -- The target `to` must implement the [`IERC1363Receiver`](../interfaces#IERC1363Receiver) interface. -- The target must return the [`IERC1363Receiver.onTransferReceived`](../interfaces#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) selector to accept the transfer. -- The internal [`IERC6909.transferFrom`](../interfaces#IERC6909-transferFrom-address-address-uint256-uint256-) must succeed (returned `true`). + +This function will not automatically detect any supply cap +added by other extensions, such as [`ERC20Capped`](#ERC20Capped). If necessary, +override this function to take a supply cap into account. +
- +
-

transferFromAndCall(address from, address to, uint256 value, bytes data) → bool

+

flashFee(address token, uint256 value) → uint256

public

-# +#
-Variant of [`IERC1363.transferFromAndCall`](../interfaces#IERC1363-transferFromAndCall-address-address-uint256-bytes-) that accepts an additional `data` parameter with -no specified format. +Returns the fee applied when doing flash loans. This function calls +the [`ERC20FlashMint._flashFee`](#ERC20FlashMint-_flashFee-address-uint256-) function which returns the fee applied when doing flash +loans.
- +
-

approveAndCall(address spender, uint256 value) → bool

+

_flashFee(address, uint256) → uint256

-

public

-# +

internal

+#
-Sets a `value` amount of tokens as the allowance of `spender` over the -caller's tokens and then calls [`IERC1363Spender.onApprovalReceived`](../interfaces#IERC1363Spender-onApprovalReceived-address-uint256-bytes-) on `spender`. -Returns a flag that indicates if the call succeeded. +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. -Requirements: +
+
-- The target has code (i.e. is a contract). -- The target `spender` must implement the [`IERC1363Spender`](../interfaces#IERC1363Spender) interface. -- The target must return the [`IERC1363Spender.onApprovalReceived`](../interfaces#IERC1363Spender-onApprovalReceived-address-uint256-bytes-) selector to accept the approval. -- The internal [`IERC6909.approve`](../interfaces#IERC6909-approve-address-uint256-uint256-) must succeed (returned `true`). + +
+
+

_flashFeeReceiver() → address

+
+

internal

+#
+
- +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. + +
+
+ +
-

approveAndCall(address spender, uint256 value, bytes data) → bool

+

flashLoan(contract IERC3156FlashBorrower receiver, address token, uint256 value, bytes data) → bool

public

-# +#
-Variant of [`IERC1363.approveAndCall`](../interfaces#IERC1363-approveAndCall-address-uint256-bytes-) that accepts an additional `data` parameter with -no specified format. +Performs a flash loan. New tokens are minted and sent to the +`receiver`, who is required to implement the [`IERC3156FlashBorrower`](/contracts/5.x/api/interfaces#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.
- +
-

ERC1363TransferFailed(address receiver, uint256 value)

+

ERC3156UnsupportedToken(address token)

error

-# +#
-Indicates a failure within the [`IERC6909.transfer`](../interfaces#IERC6909-transfer-address-uint256-uint256-) part of a transferAndCall operation. +The loan token is not valid.
- +
-

ERC1363TransferFromFailed(address sender, address receiver, uint256 value)

+

ERC3156ExceededMaxLoan(uint256 maxLoan)

error

-# +#
-Indicates a failure within the [`IERC6909.transferFrom`](../interfaces#IERC6909-transferFrom-address-address-uint256-uint256-) part of a transferFromAndCall operation. +The requested loan exceeds the max loan value for `token`.
- +
-

ERC1363ApproveFailed(address spender, uint256 value)

+

ERC3156InvalidReceiver(address receiver)

error

-# +#
-Indicates a failure within the [`IERC6909.approve`](../interfaces#IERC6909-approve-address-uint256-uint256-) part of a approveAndCall operation. +The receiver of a flashloan is not a valid [`IERC3156FlashBorrower.onFlashLoan`](/contracts/5.x/api/interfaces#IERC3156FlashBorrower-onFlashLoan-address-address-uint256-uint256-bytes-) implementer.
- +
-## `ERC20Burnable` +## `ERC20Permit` - +
```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol"; ``` -Extension of [`ERC20`](#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). +Implementation of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in +[ERC-2612](https://eips.ethereum.org/EIPS/eip-2612). + +Adds the [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) method, which can be used to change an account's ERC-20 allowance (see [`IERC20.allowance`](#IERC20-allowance-address-address-)) by +presenting a message signed by the account. By not relying on `[`IERC20.approve`](#IERC20-approve-address-uint256-)`, the token holder account doesn't +need to send a transaction, and thus is not required to hold Ether at all.

Functions

-- [burn(value)](#ERC20Burnable-burn-uint256-) -- [burnFrom(account, value)](#ERC20Burnable-burnFrom-address-uint256-) +- [constructor(name)](#ERC20Permit-constructor-string-) +- [permit(owner, spender, value, deadline, v, r, s)](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) +- [nonces(owner)](#ERC20Permit-nonces-address-) +- [DOMAIN_SEPARATOR()](#ERC20Permit-DOMAIN_SEPARATOR--) +#### Nonces [!toc] +- [_useNonce(owner)](#Nonces-_useNonce-address-) +- [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) +#### EIP712 [!toc] +- [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) +- [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) +- [eip712Domain()](#EIP712-eip712Domain--) +- [_EIP712Name()](#EIP712-_EIP712Name--) +- [_EIP712Version()](#EIP712-_EIP712Version--) +#### IERC5267 [!toc] +#### IERC20Permit [!toc] #### ERC20 [!toc] - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) @@ -1122,7 +1247,12 @@ recognized off-chain (via event analysis).

Events

-#### ERC20 [!toc] +#### Nonces [!toc] +#### EIP712 [!toc] +#### IERC5267 [!toc] +- [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) +#### IERC20Permit [!toc] +#### ERC20 [!toc] #### IERC20Errors [!toc] #### IERC20Metadata [!toc] #### IERC20 [!toc] @@ -1134,6 +1264,13 @@ recognized off-chain (via event analysis).

Errors

+- [ERC2612ExpiredSignature(deadline)](#ERC20Permit-ERC2612ExpiredSignature-uint256-) +- [ERC2612InvalidSigner(signer, owner)](#ERC20Permit-ERC2612InvalidSigner-address-address-) +#### Nonces [!toc] +- [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) +#### EIP712 [!toc] +#### IERC5267 [!toc] +#### IERC20Permit [!toc] #### ERC20 [!toc] #### IERC20Errors [!toc] - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) @@ -1147,74 +1284,206 @@ recognized off-chain (via event analysis).
- +
-

burn(uint256 value)

+

constructor(string name)

-

public

-# +

internal

+#
-Destroys a `value` amount of tokens from the caller. +Initializes the [`EIP712`](/contracts/5.x/api/utils/cryptography#EIP712) domain separator using the `name` parameter, and setting `version` to `"1"`. -See [`ERC20._burn`](#ERC20-_burn-address-uint256-). +It's a good idea to use the same `name` that is defined as the ERC-20 token name.
- +
-

burnFrom(address account, uint256 value)

+

permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)

public

-# +#
-Destroys a `value` amount of tokens from `account`, deducting from -the caller's allowance. +Sets `value` as the allowance of `spender` over ``owner``'s tokens, +given ``owner``'s signed approval. -See [`ERC20._burn`](#ERC20-_burn-address-uint256-) and [`ERC20.allowance`](#ERC20-allowance-address-address-). + +The same issues [`IERC20.approve`](#IERC20-approve-address-uint256-) has related to transaction +ordering also applies here. + + +Emits an [`IERC20.Approval`](#IERC20-Approval-address-address-uint256-) event. Requirements: -- the caller must have allowance for ``accounts``'s tokens of at least -`value`. +- `spender` cannot be the zero address. +- `deadline` must be a timestamp in the future. +- `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` +over the EIP712-formatted function arguments. +- the signature must use ``owner``'s current nonce (see [`ERC20Permit.nonces`](#ERC20Permit-nonces-address-)). + +For more information on the signature format, see the +[relevant EIP +section](https://eips.ethereum.org/EIPS/eip-2612#specification). + + +See Security Considerations above. +
- + + +
+
+

nonces(address owner) → uint256

+
+

public

+# +
+
+
+ +Returns the current nonce for `owner`. This value must be +included whenever a signature is generated for [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-). + +Every successful call to [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) increases ``owner``'s nonce by one. This +prevents a signature from being used multiple times. + +
+
+ + + +
+
+

DOMAIN_SEPARATOR() → bytes32

+
+

external

+# +
+
+
+ +Returns the domain separator used in the encoding of the signature for [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-), as defined by [`EIP712`](/contracts/5.x/api/utils/cryptography#EIP712). + +
+
+ + + +
+
+

ERC2612ExpiredSignature(uint256 deadline)

+
+

error

+# +
+
+
+ +Permit deadline has expired. + +
+
+ + + +
+
+

ERC2612InvalidSigner(address signer, address owner)

+
+

error

+# +
+
+
+ +Mismatched signature. + +
+
+ +
-## `ERC20Capped` +## `ERC20Votes` - +
```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol"; ``` -Extension of [`ERC20`](#ERC20) that adds a cap to the supply of tokens. +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. + + +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`](/contracts/5.x/api/governance#Votes-delegate-address-) function directly, or by providing a signature to be used with [`Votes.delegateBySig`](/contracts/5.x/api/governance#Votes-delegateBySig-address-uint256-uint256-uint8-bytes32-bytes32-). Voting +power can be queried through the public accessors [`Votes.getVotes`](/contracts/5.x/api/governance#Votes-getVotes-address-) and [`Votes.getPastVotes`](/contracts/5.x/api/governance#Votes-getPastVotes-address-uint256-). + +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

-- [constructor(cap_)](#ERC20Capped-constructor-uint256-) -- [cap()](#ERC20Capped-cap--) -- [_update(from, to, value)](#ERC20Capped-_update-address-address-uint256-) +- [_maxSupply()](#ERC20Votes-_maxSupply--) +- [_update(from, to, value)](#ERC20Votes-_update-address-address-uint256-) +- [_getVotingUnits(account)](#ERC20Votes-_getVotingUnits-address-) +- [numCheckpoints(account)](#ERC20Votes-numCheckpoints-address-) +- [checkpoints(account, pos)](#ERC20Votes-checkpoints-address-uint32-) +#### Votes [!toc] +- [clock()](#Votes-clock--) +- [CLOCK_MODE()](#Votes-CLOCK_MODE--) +- [_validateTimepoint(timepoint)](#Votes-_validateTimepoint-uint256-) +- [getVotes(account)](#Votes-getVotes-address-) +- [getPastVotes(account, timepoint)](#Votes-getPastVotes-address-uint256-) +- [getPastTotalSupply(timepoint)](#Votes-getPastTotalSupply-uint256-) +- [_getTotalSupply()](#Votes-_getTotalSupply--) +- [delegates(account)](#Votes-delegates-address-) +- [delegate(delegatee)](#Votes-delegate-address-) +- [delegateBySig(delegatee, nonce, expiry, v, r, s)](#Votes-delegateBySig-address-uint256-uint256-uint8-bytes32-bytes32-) +- [_delegate(account, delegatee)](#Votes-_delegate-address-address-) +- [_transferVotingUnits(from, to, amount)](#Votes-_transferVotingUnits-address-address-uint256-) +- [_moveDelegateVotes(from, to, amount)](#Votes-_moveDelegateVotes-address-address-uint256-) +- [_numCheckpoints(account)](#Votes-_numCheckpoints-address-) +- [_checkpoints(account, pos)](#Votes-_checkpoints-address-uint32-) +#### IERC5805 [!toc] +#### IVotes [!toc] +#### IERC6372 [!toc] +#### Nonces [!toc] +- [nonces(owner)](#Nonces-nonces-address-) +- [_useNonce(owner)](#Nonces-_useNonce-address-) +- [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) +#### EIP712 [!toc] +- [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) +- [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) +- [eip712Domain()](#EIP712-eip712Domain--) +- [_EIP712Name()](#EIP712-_EIP712Name--) +- [_EIP712Version()](#EIP712-_EIP712Version--) +#### IERC5267 [!toc] #### ERC20 [!toc] - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) @@ -1240,6 +1509,16 @@ Extension of [`ERC20`](#ERC20) that adds a cap to the supply of tokens.

Events

+#### Votes [!toc] +#### IERC5805 [!toc] +#### IVotes [!toc] +- [DelegateChanged(delegator, fromDelegate, toDelegate)](#IVotes-DelegateChanged-address-address-address-) +- [DelegateVotesChanged(delegate, previousVotes, newVotes)](#IVotes-DelegateVotesChanged-address-uint256-uint256-) +#### IERC6372 [!toc] +#### Nonces [!toc] +#### EIP712 [!toc] +#### IERC5267 [!toc] +- [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) #### ERC20 [!toc] #### IERC20Errors [!toc] #### IERC20Metadata [!toc] @@ -1252,8 +1531,18 @@ Extension of [`ERC20`](#ERC20) that adds a cap to the supply of tokens.

Errors

-- [ERC20ExceededCap(increasedSupply, cap)](#ERC20Capped-ERC20ExceededCap-uint256-uint256-) -- [ERC20InvalidCap(cap)](#ERC20Capped-ERC20InvalidCap-uint256-) +- [ERC20ExceededSafeSupply(increasedSupply, cap)](#ERC20Votes-ERC20ExceededSafeSupply-uint256-uint256-) +#### Votes [!toc] +- [ERC6372InconsistentClock()](#Votes-ERC6372InconsistentClock--) +- [ERC5805FutureLookup(timepoint, clock)](#Votes-ERC5805FutureLookup-uint256-uint48-) +#### IERC5805 [!toc] +#### IVotes [!toc] +- [VotesExpiredSignature(expiry)](#IVotes-VotesExpiredSignature-uint256-) +#### IERC6372 [!toc] +#### Nonces [!toc] +- [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) +#### EIP712 [!toc] +#### IERC5267 [!toc] #### ERC20 [!toc] #### IERC20Errors [!toc] - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) @@ -1267,137 +1556,163 @@ Extension of [`ERC20`](#ERC20) that adds a cap to the supply of tokens.
- +
-

constructor(uint256 cap_)

+

_maxSupply() → uint256

internal

-# +#
-Sets the value of the `cap`. This value is immutable, it can only be -set once during construction. +Maximum token supply. Defaults to `type(uint208).max` (2^208^ - 1). + +This maximum is enforced in [`ERC20._update`](#ERC20-_update-address-address-uint256-). 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`](/contracts/5.x/api/governance#Votes). Increasing this value will not +remove the underlying limitation, and will cause [`ERC20._update`](#ERC20-_update-address-address-uint256-) to fail because of a math overflow in +[`Votes._transferVotingUnits`](/contracts/5.x/api/governance#Votes-_transferVotingUnits-address-address-uint256-). 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.
- +
-

cap() → uint256

+

_update(address from, address to, uint256 value)

-

public

-# +

internal

+#
-Returns the cap on the token's total supply. +Move voting power when tokens are transferred. + +Emits a [`IVotes.DelegateVotesChanged`](/contracts/5.x/api/governance#IVotes-DelegateVotesChanged-address-uint256-uint256-) event.
- +
-

_update(address from, address to, uint256 value)

+

_getVotingUnits(address account) → uint256

internal

-# +#
-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. +Returns the voting units of an `account`. -Emits a [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event. + +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. +
- +
-

ERC20ExceededCap(uint256 increasedSupply, uint256 cap)

+

numCheckpoints(address account) → uint32

-

error

-# +

public

+#
-Total supply cap has been exceeded. +Get number of checkpoints for `account`.
- +
-

ERC20InvalidCap(uint256 cap)

+

checkpoints(address account, uint32 pos) → struct Checkpoints.Checkpoint208

-

error

-# +

public

+#
-The supplied cap is not a valid cap. +Get the `pos`-th checkpoint for `account`.
- + + +
+
+

ERC20ExceededSafeSupply(uint256 increasedSupply, uint256 cap)

+
+

error

+# +
+
+
+ +Total supply cap has been exceeded, introducing a risk of votes overflowing. + +
+
+ +
-## `ERC20FlashMint` +## `ERC20Wrapper` - +
```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC20FlashMint.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Wrapper.sol"; ``` -Implementation of the ERC-3156 Flash loans extension, as defined in -[ERC-3156](https://eips.ethereum.org/EIPS/eip-3156). +Extension of the ERC-20 token contract to support token wrapping. -Adds the [`IERC3156FlashLender.flashLoan`](../interfaces#IERC3156FlashLender-flashLoan-contract-IERC3156FlashBorrower-address-uint256-bytes-) method, which provides flash loan support at the token -level. By default there is no fee, but this can be changed by overriding [`IERC3156FlashLender.flashFee`](../interfaces#IERC3156FlashLender-flashFee-address-uint256-). +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`](#ERC20Votes) will allow the +wrapping of an existing "basic" ERC-20 into a governance token. - -When this extension is used along with the [`ERC20Capped`](#ERC20Capped) or [`ERC20Votes`](#ERC20Votes) extensions, -[`IERC3156FlashLender.maxFlashLoan`](../interfaces#IERC3156FlashLender-maxFlashLoan-address-) will not correctly reflect the maximum that can be flash minted. We recommend -overriding [`IERC3156FlashLender.maxFlashLoan`](../interfaces#IERC3156FlashLender-maxFlashLoan-address-) so that it correctly reflects the supply cap. + +Any mechanism in which the underlying token changes the [`ERC20.balanceOf`](#ERC20-balanceOf-address-) 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 [`ERC20Wrapper._recover`](#ERC20Wrapper-_recover-address-) +for recovering value accrued to the wrapper.

Functions

-- [maxFlashLoan(token)](#ERC20FlashMint-maxFlashLoan-address-) -- [flashFee(token, value)](#ERC20FlashMint-flashFee-address-uint256-) -- [_flashFee(token, value)](#ERC20FlashMint-_flashFee-address-uint256-) -- [_flashFeeReceiver()](#ERC20FlashMint-_flashFeeReceiver--) -- [flashLoan(receiver, token, value, data)](#ERC20FlashMint-flashLoan-contract-IERC3156FlashBorrower-address-uint256-bytes-) -#### IERC3156FlashLender [!toc] +- [constructor(underlyingToken)](#ERC20Wrapper-constructor-contract-IERC20-) +- [decimals()](#ERC20Wrapper-decimals--) +- [underlying()](#ERC20Wrapper-underlying--) +- [depositFor(account, value)](#ERC20Wrapper-depositFor-address-uint256-) +- [withdrawTo(account, value)](#ERC20Wrapper-withdrawTo-address-uint256-) +- [_recover(account)](#ERC20Wrapper-_recover-address-) #### ERC20 [!toc] - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) -- [decimals()](#ERC20-decimals--) - [totalSupply()](#ERC20-totalSupply--) - [balanceOf(account)](#ERC20-balanceOf-address-) - [transfer(to, value)](#ERC20-transfer-address-uint256-) @@ -1420,7 +1735,6 @@ overriding [`IERC3156FlashLender.maxFlashLoan`](../interfaces#IERC3156FlashLende

Events

-#### IERC3156FlashLender [!toc] #### ERC20 [!toc] #### IERC20Errors [!toc] #### IERC20Metadata [!toc] @@ -1433,10 +1747,7 @@ overriding [`IERC3156FlashLender.maxFlashLoan`](../interfaces#IERC3156FlashLende

Errors

-- [ERC3156UnsupportedToken(token)](#ERC20FlashMint-ERC3156UnsupportedToken-address-) -- [ERC3156ExceededMaxLoan(maxLoan)](#ERC20FlashMint-ERC3156ExceededMaxLoan-uint256-) -- [ERC3156InvalidReceiver(receiver)](#ERC20FlashMint-ERC3156InvalidReceiver-address-) -#### IERC3156FlashLender [!toc] +- [ERC20InvalidUnderlying(token)](#ERC20Wrapper-ERC20InvalidUnderlying-address-) #### ERC20 [!toc] #### IERC20Errors [!toc] - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) @@ -1450,196 +1761,221 @@ overriding [`IERC3156FlashLender.maxFlashLoan`](../interfaces#IERC3156FlashLende
- +
-

maxFlashLoan(address token) → uint256

+

constructor(contract IERC20 underlyingToken)

-

public

-# +

internal

+#
-Returns the maximum amount of tokens available for loan. -
- +
-

flashFee(address token, uint256 value) → uint256

+

decimals() → uint8

public

-# -
-
-
- -Returns the fee applied when doing flash loans. This function calls -the [`ERC20FlashMint._flashFee`](#ERC20FlashMint-_flashFee-address-uint256-) function which returns the fee applied when doing flash -loans. - -
-
- - - -
-
-

_flashFee(address token, uint256 value) → uint256

-
-

internal

-# +#
-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. -
- +
-

_flashFeeReceiver() → address

+

underlying() → contract IERC20

-

internal

-# +

public

+#
-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. +Returns the address of the underlying ERC-20 token that is being wrapped.
- +
-

flashLoan(contract IERC3156FlashBorrower receiver, address token, uint256 value, bytes data) → bool

+

depositFor(address account, uint256 value) → bool

public

-# +#
-Performs a flash loan. New tokens are minted and sent to the -`receiver`, who is required to implement the [`IERC3156FlashBorrower`](../interfaces#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. +Allow a user to deposit underlying tokens and mint the corresponding number of wrapped tokens.
- +
-

ERC3156UnsupportedToken(address token)

+

withdrawTo(address account, uint256 value) → bool

-

error

-# +

public

+#
-The loan token is not valid. +Allow a user to burn a number of wrapped tokens and withdraw the corresponding number of underlying tokens.
- +
-

ERC3156ExceededMaxLoan(uint256 maxLoan)

+

_recover(address account) → uint256

-

error

-# +

internal

+#
-The requested loan exceeds the max loan value for `token`. +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.
- +
-

ERC3156InvalidReceiver(address receiver)

+

ERC20InvalidUnderlying(address token)

error

-# +#
-The receiver of a flashloan is not a valid [`IERC3156FlashBorrower.onFlashLoan`](../interfaces#IERC3156FlashBorrower-onFlashLoan-address-address-uint256-uint256-bytes-) implementer. +The underlying token couldn't be wrapped.
- +
-## `ERC20Pausable` +## `ERC4626` - +
```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol"; ``` -ERC-20 token with pausable token transfers, minting and burning. +Implementation of the ERC-4626 "Tokenized Vault Standard" as defined in +[ERC-4626](https://eips.ethereum.org/EIPS/eip-4626). -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. +This extension allows the minting and burning of "shares" (represented using the ERC-20 inheritance) in exchange for +underlying "assets" through standardized [`ERC4626.deposit`](#ERC4626-deposit-uint256-address-), [`ERC4626.mint`](#ERC4626-mint-uint256-address-), [`ERC4626.redeem`](#ERC4626-redeem-uint256-address-address-) and [`ERC20Burnable.burn`](#ERC20Burnable-burn-uint256-) 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. - -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`](../utils#Pausable-_pause--) and [`Pausable._unpause`](../utils#Pausable-_unpause--) internal functions, with appropriate -access control, e.g. using [`AccessControl`](../access#AccessControl) or [`Ownable`](../access#Ownable). Not doing so will -make the contract pause mechanism of the contract unreachable, and thus unusable. - +[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 +[ERC4626Router](https://github.com/fei-protocol/ERC4626#erc4626router-and-base). + +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 [here](/contracts/5.x/erc4626#inflation-attack). + +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 [ERC-4626 guide](/contracts/5.x/erc4626). +#### [NOTE] +#### When overriding this contract, some elements must be considered: + +* When overriding the behavior of the deposit or withdraw mechanisms, it is recommended to override the internal +functions. Overriding [`ERC4626._deposit`](#ERC4626-_deposit-address-address-uint256-uint256-) automatically affects both [`ERC4626.deposit`](#ERC4626-deposit-uint256-address-) and [`ERC4626.mint`](#ERC4626-mint-uint256-address-). Similarly, overriding [`ERC4626._withdraw`](#ERC4626-_withdraw-address-address-address-uint256-uint256-) +automatically affects both [`ERC4626.withdraw`](#ERC4626-withdraw-uint256-address-address-) and [`ERC4626.redeem`](#ERC4626-redeem-uint256-address-address-). Overall it is not recommended to override the public facing +functions since that could lead to inconsistent behaviors between the [`ERC4626.deposit`](#ERC4626-deposit-uint256-address-) and [`ERC4626.mint`](#ERC4626-mint-uint256-address-) or between [`ERC4626.withdraw`](#ERC4626-withdraw-uint256-address-address-) and +[`ERC4626.redeem`](#ERC4626-redeem-uint256-address-address-), which is documented to have led to loss of funds. + +* Overrides to the deposit or withdraw mechanism must be reflected in the preview functions as well. + +* [`ERC4626.maxWithdraw`](#ERC4626-maxWithdraw-address-) depends on [`ERC4626.maxRedeem`](#ERC4626-maxRedeem-address-). Therefore, overriding [`ERC4626.maxRedeem`](#ERC4626-maxRedeem-address-) only is enough. On the other hand, +overriding [`ERC4626.maxWithdraw`](#ERC4626-maxWithdraw-address-) only would have no effect on [`ERC4626.maxRedeem`](#ERC4626-maxRedeem-address-), and could create an inconsistency between the two +functions. + +* If [`ERC4626.previewRedeem`](#ERC4626-previewRedeem-uint256-) is overridden to revert, [`ERC4626.maxWithdraw`](#ERC4626-maxWithdraw-address-) must be overridden as necessary to ensure it +always return successfully.

Functions

-- [_update(from, to, value)](#ERC20Pausable-_update-address-address-uint256-) -#### Pausable [!toc] -- [paused()](#Pausable-paused--) -- [_requireNotPaused()](#Pausable-_requireNotPaused--) -- [_requirePaused()](#Pausable-_requirePaused--) -- [_pause()](#Pausable-_pause--) -- [_unpause()](#Pausable-_unpause--) +- [constructor(asset_)](#ERC4626-constructor-contract-IERC20-) +- [decimals()](#ERC4626-decimals--) +- [asset()](#ERC4626-asset--) +- [totalAssets()](#ERC4626-totalAssets--) +- [convertToShares(assets)](#ERC4626-convertToShares-uint256-) +- [convertToAssets(shares)](#ERC4626-convertToAssets-uint256-) +- [maxDeposit()](#ERC4626-maxDeposit-address-) +- [maxMint()](#ERC4626-maxMint-address-) +- [maxWithdraw(owner)](#ERC4626-maxWithdraw-address-) +- [maxRedeem(owner)](#ERC4626-maxRedeem-address-) +- [previewDeposit(assets)](#ERC4626-previewDeposit-uint256-) +- [previewMint(shares)](#ERC4626-previewMint-uint256-) +- [previewWithdraw(assets)](#ERC4626-previewWithdraw-uint256-) +- [previewRedeem(shares)](#ERC4626-previewRedeem-uint256-) +- [deposit(assets, receiver)](#ERC4626-deposit-uint256-address-) +- [mint(shares, receiver)](#ERC4626-mint-uint256-address-) +- [withdraw(assets, receiver, owner)](#ERC4626-withdraw-uint256-address-address-) +- [redeem(shares, receiver, owner)](#ERC4626-redeem-uint256-address-address-) +- [_convertToShares(assets, rounding)](#ERC4626-_convertToShares-uint256-enum-Math-Rounding-) +- [_convertToAssets(shares, rounding)](#ERC4626-_convertToAssets-uint256-enum-Math-Rounding-) +- [_deposit(caller, receiver, assets, shares)](#ERC4626-_deposit-address-address-uint256-uint256-) +- [_withdraw(caller, receiver, owner, assets, shares)](#ERC4626-_withdraw-address-address-address-uint256-uint256-) +- [_transferIn(from, assets)](#ERC4626-_transferIn-address-uint256-) +- [_transferOut(to, assets)](#ERC4626-_transferOut-address-uint256-) +- [_decimalsOffset()](#ERC4626-_decimalsOffset--) +#### IERC4626 [!toc] #### ERC20 [!toc] - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) -- [decimals()](#ERC20-decimals--) - [totalSupply()](#ERC20-totalSupply--) - [balanceOf(account)](#ERC20-balanceOf-address-) - [transfer(to, value)](#ERC20-transfer-address-uint256-) @@ -1647,6 +1983,7 @@ make the contract pause mechanism of the contract unreachable, and thus unusable - [approve(spender, value)](#ERC20-approve-address-uint256-) - [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) - [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) +- [_update(from, to, value)](#ERC20-_update-address-address-uint256-) - [_mint(account, value)](#ERC20-_mint-address-uint256-) - [_burn(account, value)](#ERC20-_burn-address-uint256-) - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) @@ -1661,9 +1998,9 @@ make the contract pause mechanism of the contract unreachable, and thus unusable

Events

-#### Pausable [!toc] -- [Paused(account)](#Pausable-Paused-address-) -- [Unpaused(account)](#Pausable-Unpaused-address-) +#### IERC4626 [!toc] +- [Deposit(sender, owner, assets, shares)](#IERC4626-Deposit-address-address-uint256-uint256-) +- [Withdraw(sender, receiver, owner, assets, shares)](#IERC4626-Withdraw-address-address-address-uint256-uint256-) #### ERC20 [!toc] #### IERC20Errors [!toc] #### IERC20Metadata [!toc] @@ -1676,9 +2013,11 @@ make the contract pause mechanism of the contract unreachable, and thus unusable

Errors

-#### Pausable [!toc] -- [EnforcedPause()](#Pausable-EnforcedPause--) -- [ExpectedPause()](#Pausable-ExpectedPause--) +- [ERC4626ExceededMaxDeposit(receiver, assets, max)](#ERC4626-ERC4626ExceededMaxDeposit-address-uint256-uint256-) +- [ERC4626ExceededMaxMint(receiver, shares, max)](#ERC4626-ERC4626ExceededMaxMint-address-uint256-uint256-) +- [ERC4626ExceededMaxWithdraw(owner, assets, max)](#ERC4626-ERC4626ExceededMaxWithdraw-address-uint256-uint256-) +- [ERC4626ExceededMaxRedeem(owner, shares, max)](#ERC4626-ERC4626ExceededMaxRedeem-address-uint256-uint256-) +#### IERC4626 [!toc] #### ERC20 [!toc] #### IERC20Errors [!toc] - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) @@ -1692,1749 +2031,1691 @@ make the contract pause mechanism of the contract unreachable, and thus unusable
- +
-

_update(address from, address to, uint256 value)

+

constructor(contract IERC20 asset_)

internal

-# +#
-See [`ERC20._update`](#ERC20-_update-address-address-uint256-). - -Requirements: - -- the contract must not be paused. +Set the underlying asset contract. This must be an ERC20-compatible contract (ERC-20 or ERC-777).
- - -
- -## `ERC20Permit` - - - - + +
+
+

decimals() → uint8

+
+

public

+#
+
+
-```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol"; -``` - -Implementation of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in -[ERC-2612](https://eips.ethereum.org/EIPS/eip-2612). +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. -Adds the [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) method, which can be used to change an account's ERC-20 allowance (see [`IERC20.allowance`](#IERC20-allowance-address-address-)) by -presenting a message signed by the account. By not relying on `[`IERC20.approve`](#IERC20-approve-address-uint256-)`, the token holder account doesn't -need to send a transaction, and thus is not required to hold Ether at all. +See [`IERC20Metadata.decimals`](#IERC20Metadata-decimals--). -
-

Functions

-
-- [constructor(name)](#ERC20Permit-constructor-string-) -- [permit(owner, spender, value, deadline, v, r, s)](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) -- [nonces(owner)](#ERC20Permit-nonces-address-) -- [DOMAIN_SEPARATOR()](#ERC20Permit-DOMAIN_SEPARATOR--) -#### Nonces [!toc] -- [_useNonce(owner)](#Nonces-_useNonce-address-) -- [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### EIP712 [!toc] -- [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) -- [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) -- [eip712Domain()](#EIP712-eip712Domain--) -- [_EIP712Name()](#EIP712-_EIP712Name--) -- [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### IERC20Permit [!toc] -#### ERC20 [!toc] -- [name()](#ERC20-name--) -- [symbol()](#ERC20-symbol--) -- [decimals()](#ERC20-decimals--) -- [totalSupply()](#ERC20-totalSupply--) -- [balanceOf(account)](#ERC20-balanceOf-address-) -- [transfer(to, value)](#ERC20-transfer-address-uint256-) -- [allowance(owner, spender)](#ERC20-allowance-address-address-) -- [approve(spender, value)](#ERC20-approve-address-uint256-) -- [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) -- [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) -- [_update(from, to, value)](#ERC20-_update-address-address-uint256-) -- [_mint(account, value)](#ERC20-_mint-address-uint256-) -- [_burn(account, value)](#ERC20-_burn-address-uint256-) -- [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) -- [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) -- [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc]
-
-

Events

-
-#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] -- [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### IERC20Permit [!toc] -#### ERC20 [!toc] -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] -- [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) -- [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + + +
+
+

asset() → address

+
+

public

+#
+
+ +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. -
-

Errors

-
-- [ERC2612ExpiredSignature(deadline)](#ERC20Permit-ERC2612ExpiredSignature-uint256-) -- [ERC2612InvalidSigner(signer, owner)](#ERC20Permit-ERC2612InvalidSigner-address-address-) -#### Nonces [!toc] -- [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### IERC20Permit [!toc] -#### ERC20 [!toc] -#### IERC20Errors [!toc] -- [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) -- [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) -- [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) -- [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) -- [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) -- [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -#### IERC20Metadata [!toc] -#### IERC20 [!toc]
- +
-

constructor(string name)

+

totalAssets() → uint256

-

internal

-# +

public

+#
-Initializes the [`EIP712`](../utils/cryptography#EIP712) domain separator using the `name` parameter, and setting `version` to `"1"`. +Returns the total amount of the underlying asset that is “managed” by Vault. -It's a good idea to use the same `name` that is defined as the ERC-20 token name. +- 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.
- +
-

permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)

+

convertToShares(uint256 assets) → uint256

public

-# +#
-Sets `value` as the allowance of `spender` over ``owner``'s tokens, -given ``owner``'s signed approval. +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. - -The same issues [`IERC20.approve`](#IERC20-approve-address-uint256-) has related to transaction -ordering also applies here. +- 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. + + +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. -Emits an [`IERC6909.Approval`](../interfaces#IERC6909-Approval-address-address-uint256-uint256-) event. +
+
-Requirements: + -- `spender` cannot be the zero address. -- `deadline` must be a timestamp in the future. -- `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` -over the EIP712-formatted function arguments. -- the signature must use ``owner``'s current nonce (see [`ERC20Permit.nonces`](#ERC20Permit-nonces-address-)). +
+
+

convertToAssets(uint256 shares) → uint256

+
+

public

+# +
+
+
-For more information on the signature format, see the -[relevant EIP -section](https://eips.ethereum.org/EIPS/eip-2612#specification). +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. -CAUTION: See Security Considerations above. + +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. +
- +
-

nonces(address owner) → uint256

+

maxDeposit(address) → uint256

public

-# +#
-Returns the current nonce for `owner`. This value must be -included whenever a signature is generated for [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-). +Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver, +through a deposit call. -Every successful call to [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) increases ``owner``'s nonce by one. This -prevents a signature from being used multiple times. +- 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.
- +
-

DOMAIN_SEPARATOR() → bytes32

+

maxMint(address) → uint256

-

external

-# +

public

+#
-Returns the domain separator used in the encoding of the signature for [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-), as defined by [`EIP712`](../utils/cryptography#EIP712). +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.
- +
-

ERC2612ExpiredSignature(uint256 deadline)

+

maxWithdraw(address owner) → uint256

-

error

-# +

public

+#
-Permit deadline has expired. +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.
- +
-

ERC2612InvalidSigner(address signer, address owner)

+

maxRedeem(address owner) → uint256

-

error

-# +

public

+#
-Mismatched signature. +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.
- - -
- -## `ERC20Votes` - - - - + +
+
+

previewDeposit(uint256 assets) → uint256

+
+

public

+# +
+
-```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol"; -``` +Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given +current on-chain conditions. -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. +- 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. -This contract does not provide interface compatibility with Compound's COMP token. +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. -This extension keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either -by calling the [`Votes.delegate`](../governance#Votes-delegate-address-) function directly, or by providing a signature to be used with [`Votes.delegateBySig`](../governance#Votes-delegateBySig-address-uint256-uint256-uint8-bytes32-bytes32-). Voting -power can be queried through the public accessors [`Votes.getVotes`](../governance#Votes-getVotes-address-) and [`Votes.getPastVotes`](../governance#Votes-getPastVotes-address-uint256-). +
+
-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()](#ERC20Votes-_maxSupply--) -- [_update(from, to, value)](#ERC20Votes-_update-address-address-uint256-) -- [_getVotingUnits(account)](#ERC20Votes-_getVotingUnits-address-) -- [numCheckpoints(account)](#ERC20Votes-numCheckpoints-address-) -- [checkpoints(account, pos)](#ERC20Votes-checkpoints-address-uint32-) -#### Votes [!toc] -- [clock()](#Votes-clock--) -- [CLOCK_MODE()](#Votes-CLOCK_MODE--) -- [_validateTimepoint(timepoint)](#Votes-_validateTimepoint-uint256-) -- [getVotes(account)](#Votes-getVotes-address-) -- [getPastVotes(account, timepoint)](#Votes-getPastVotes-address-uint256-) -- [getPastTotalSupply(timepoint)](#Votes-getPastTotalSupply-uint256-) -- [_getTotalSupply()](#Votes-_getTotalSupply--) -- [delegates(account)](#Votes-delegates-address-) -- [delegate(delegatee)](#Votes-delegate-address-) -- [delegateBySig(delegatee, nonce, expiry, v, r, s)](#Votes-delegateBySig-address-uint256-uint256-uint8-bytes32-bytes32-) -- [_delegate(account, delegatee)](#Votes-_delegate-address-address-) -- [_transferVotingUnits(from, to, amount)](#Votes-_transferVotingUnits-address-address-uint256-) -- [_moveDelegateVotes(from, to, amount)](#Votes-_moveDelegateVotes-address-address-uint256-) -- [_numCheckpoints(account)](#Votes-_numCheckpoints-address-) -- [_checkpoints(account, pos)](#Votes-_checkpoints-address-uint32-) -#### IERC5805 [!toc] -#### IVotes [!toc] -#### IERC6372 [!toc] -#### Nonces [!toc] -- [nonces(owner)](#Nonces-nonces-address-) -- [_useNonce(owner)](#Nonces-_useNonce-address-) -- [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### EIP712 [!toc] -- [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) -- [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) -- [eip712Domain()](#EIP712-eip712Domain--) -- [_EIP712Name()](#EIP712-_EIP712Name--) -- [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### ERC20 [!toc] -- [name()](#ERC20-name--) -- [symbol()](#ERC20-symbol--) -- [decimals()](#ERC20-decimals--) -- [totalSupply()](#ERC20-totalSupply--) -- [balanceOf(account)](#ERC20-balanceOf-address-) -- [transfer(to, value)](#ERC20-transfer-address-uint256-) -- [allowance(owner, spender)](#ERC20-allowance-address-address-) -- [approve(spender, value)](#ERC20-approve-address-uint256-) -- [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) -- [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) -- [_mint(account, value)](#ERC20-_mint-address-uint256-) -- [_burn(account, value)](#ERC20-_burn-address-uint256-) -- [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) -- [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) -- [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] +
+
+

previewMint(uint256 shares) → uint256

+
+

public

+#
+
+ +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. + + +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. + -
-

Events

-
-#### Votes [!toc] -#### IERC5805 [!toc] -#### IVotes [!toc] -- [DelegateChanged(delegator, fromDelegate, toDelegate)](#IVotes-DelegateChanged-address-address-address-) -- [DelegateVotesChanged(delegate, previousVotes, newVotes)](#IVotes-DelegateVotesChanged-address-uint256-uint256-) -#### IERC6372 [!toc] -#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] -- [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### ERC20 [!toc] -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] -- [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) -- [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-)
-
-

Errors

-
-- [ERC20ExceededSafeSupply(increasedSupply, cap)](#ERC20Votes-ERC20ExceededSafeSupply-uint256-uint256-) -#### Votes [!toc] -- [ERC6372InconsistentClock()](#Votes-ERC6372InconsistentClock--) -- [ERC5805FutureLookup(timepoint, clock)](#Votes-ERC5805FutureLookup-uint256-uint48-) -#### IERC5805 [!toc] -#### IVotes [!toc] -- [VotesExpiredSignature(expiry)](#IVotes-VotesExpiredSignature-uint256-) -#### IERC6372 [!toc] -#### Nonces [!toc] -- [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### ERC20 [!toc] -#### IERC20Errors [!toc] -- [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) -- [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) -- [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) -- [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) -- [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) -- [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + + +
+
+

previewWithdraw(uint256 assets) → uint256

+
+

public

+#
+
- +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. + + +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. + + +
+
+ +
-

_maxSupply() → uint256

+

previewRedeem(uint256 shares) → uint256

-

internal

-# +

public

+#
-Maximum token supply. Defaults to `type(uint208).max` (2^208^ - 1). +Allows an on-chain or off-chain user to simulate the effects of their redemption at the current block, +given current on-chain conditions. -This maximum is enforced in [`ERC1155._update`](/contracts/5.x/api/token/ERC1155#ERC1155-_update-address-address-uint256---uint256---). 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`](../governance#Votes). Increasing this value will not -remove the underlying limitation, and will cause [`ERC1155._update`](/contracts/5.x/api/token/ERC1155#ERC1155-_update-address-address-uint256---uint256---) to fail because of a math overflow in -[`Votes._transferVotingUnits`](../governance#Votes-_transferVotingUnits-address-address-uint256-). 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. +- 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. + + +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. +
- +
-

_update(address from, address to, uint256 value)

+

deposit(uint256 assets, address receiver) → uint256

-

internal

-# +

public

+#
-Move voting power when tokens are transferred. +Deposit `assets` underlying tokens and send the corresponding number of vault shares (`shares`) to `receiver`. -Emits a [`IVotes.DelegateVotesChanged`](../governance#IVotes-DelegateVotesChanged-address-uint256-uint256-) event. +- 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). + + +most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. +
- +
-

_getVotingUnits(address account) → uint256

+

mint(uint256 shares, address receiver) → uint256

-

internal

-# +

public

+#
-Returns the voting units of an `account`. +Mints exactly `shares` vault shares to `receiver` in exchange for `assets` underlying tokens. - -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. +- 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). + + +most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
- +
-

numCheckpoints(address account) → uint32

+

withdraw(uint256 assets, address receiver, address owner) → uint256

public

-# +#
-Get number of checkpoints for `account`. +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.
- +
-

checkpoints(address account, uint32 pos) → struct Checkpoints.Checkpoint208

+

redeem(uint256 shares, address receiver, address owner) → uint256

public

-# +#
-Get the `pos`-th checkpoint for `account`. +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). + + +some implementations will require pre-requesting to the Vault before a withdrawal may be performed. +Those methods should be performed separately. +
- +
-

ERC20ExceededSafeSupply(uint256 increasedSupply, uint256 cap)

+

_convertToShares(uint256 assets, enum Math.Rounding rounding) → uint256

-

error

-# +

internal

+#
-Total supply cap has been exceeded, introducing a risk of votes overflowing. +Internal conversion function (from assets to shares) with support for rounding direction. + +
+
+ + + +
+
+

_convertToAssets(uint256 shares, enum Math.Rounding rounding) → uint256

+
+

internal

+# +
+
+
+ +Internal conversion function (from shares to assets) with support for rounding direction.
- - -
- -## `ERC20Wrapper` - - - - + +
+
+

_deposit(address caller, address receiver, uint256 assets, uint256 shares)

+
+

internal

+#
+
+
-```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Wrapper.sol"; -``` - -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`](#ERC20Votes) will allow the -wrapping of an existing "basic" ERC-20 into a governance token. - - -Any mechanism in which the underlying token changes the [`IERC6909.balanceOf`](../interfaces#IERC6909-balanceOf-address-uint256-) 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 [`ERC20Wrapper._recover`](#ERC20Wrapper-_recover-address-) -for recovering value accrued to the wrapper. - +Deposit/mint common workflow. -
-

Functions

-
-- [constructor(underlyingToken)](#ERC20Wrapper-constructor-contract-IERC20-) -- [decimals()](#ERC20Wrapper-decimals--) -- [underlying()](#ERC20Wrapper-underlying--) -- [depositFor(account, value)](#ERC20Wrapper-depositFor-address-uint256-) -- [withdrawTo(account, value)](#ERC20Wrapper-withdrawTo-address-uint256-) -- [_recover(account)](#ERC20Wrapper-_recover-address-) -#### ERC20 [!toc] -- [name()](#ERC20-name--) -- [symbol()](#ERC20-symbol--) -- [totalSupply()](#ERC20-totalSupply--) -- [balanceOf(account)](#ERC20-balanceOf-address-) -- [transfer(to, value)](#ERC20-transfer-address-uint256-) -- [allowance(owner, spender)](#ERC20-allowance-address-address-) -- [approve(spender, value)](#ERC20-approve-address-uint256-) -- [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) -- [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) -- [_update(from, to, value)](#ERC20-_update-address-address-uint256-) -- [_mint(account, value)](#ERC20-_mint-address-uint256-) -- [_burn(account, value)](#ERC20-_burn-address-uint256-) -- [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) -- [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) -- [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc]
-
-

Events

-
-#### ERC20 [!toc] -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] -- [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) -- [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + + +
+
+

_withdraw(address caller, address receiver, address owner, uint256 assets, uint256 shares)

+
+

internal

+#
+
+ +Withdraw/redeem common workflow. -
-

Errors

-
-- [ERC20InvalidUnderlying(token)](#ERC20Wrapper-ERC20InvalidUnderlying-address-) -#### ERC20 [!toc] -#### IERC20Errors [!toc] -- [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) -- [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) -- [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) -- [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) -- [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) -- [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -#### IERC20Metadata [!toc] -#### IERC20 [!toc]
- +
-

constructor(contract IERC20 underlyingToken)

+

_transferIn(address from, uint256 assets)

internal

-# +#
+Performs a transfer in of underlying assets. The default implementation uses `SafeERC20`. Used by [`ERC4626._deposit`](#ERC4626-_deposit-address-address-uint256-uint256-). +
- +
-

decimals() → uint8

+

_transferOut(address to, uint256 assets)

-

public

-# +

internal

+#
+Performs a transfer out of underlying assets. The default implementation uses `SafeERC20`. Used by [`ERC4626._withdraw`](#ERC4626-_withdraw-address-address-address-uint256-uint256-). +
- +
-

underlying() → contract IERC20

+

_decimalsOffset() → uint8

-

public

-# +

internal

+#
-Returns the address of the underlying ERC-20 token that is being wrapped. -
- +
-

depositFor(address account, uint256 value) → bool

+

ERC4626ExceededMaxDeposit(address receiver, uint256 assets, uint256 max)

-

public

-# +

error

+#
-Allow a user to deposit underlying tokens and mint the corresponding number of wrapped tokens. +Attempted to deposit more assets than the max amount for `receiver`.
- +
-

withdrawTo(address account, uint256 value) → bool

+

ERC4626ExceededMaxMint(address receiver, uint256 shares, uint256 max)

-

public

-# +

error

+#
-Allow a user to burn a number of wrapped tokens and withdraw the corresponding number of underlying tokens. +Attempted to mint more shares than the max amount for `receiver`.
- +
-

_recover(address account) → uint256

+

ERC4626ExceededMaxWithdraw(address owner, uint256 assets, uint256 max)

-

internal

-# +

error

+#
-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. +Attempted to withdraw more assets than the max amount for `owner`.
- +
-

ERC20InvalidUnderlying(address token)

+

ERC4626ExceededMaxRedeem(address owner, uint256 shares, uint256 max)

error

-# +#
-The underlying token couldn't be wrapped. +Attempted to redeem more shares than the max amount for `owner`.
- +
-## `ERC4626` +## `IERC20Metadata` - +
```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; ``` -Implementation of the ERC-4626 "Tokenized Vault Standard" as defined in -[ERC-4626](https://eips.ethereum.org/EIPS/eip-4626). - -This extension allows the minting and burning of "shares" (represented using the ERC-20 inheritance) in exchange for -underlying "assets" through standardized [`IERC4626.deposit`](../interfaces#IERC4626-deposit-uint256-address-), [`IERC4626.mint`](../interfaces#IERC4626-mint-uint256-address-), [`IERC4626.redeem`](../interfaces#IERC4626-redeem-uint256-address-address-) and [`IERC777.burn`](../interfaces#IERC777-burn-uint256-bytes-) 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. - - -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 -[ERC4626Router](https://github.com/fei-protocol/ERC4626#erc4626router-and-base). - -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 [here](/contracts/5.x/erc4626#inflation-attack). - -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 [ERC-4626 guide](/contracts/5.x/erc4626). - - -When overriding this contract, some elements must be considered: - -* When overriding the behavior of the deposit or withdraw mechanisms, it is recommended to override the internal -functions. Overriding [`ERC4626._deposit`](#ERC4626-_deposit-address-address-uint256-uint256-) automatically affects both [`IERC4626.deposit`](../interfaces#IERC4626-deposit-uint256-address-) and [`IERC4626.mint`](../interfaces#IERC4626-mint-uint256-address-). Similarly, overriding [`ERC4626._withdraw`](#ERC4626-_withdraw-address-address-address-uint256-uint256-) -automatically affects both [`IERC4626.withdraw`](../interfaces#IERC4626-withdraw-uint256-address-address-) and [`IERC4626.redeem`](../interfaces#IERC4626-redeem-uint256-address-address-). Overall it is not recommended to override the public facing -functions since that could lead to inconsistent behaviors between the [`IERC4626.deposit`](../interfaces#IERC4626-deposit-uint256-address-) and [`IERC4626.mint`](../interfaces#IERC4626-mint-uint256-address-) or between [`IERC4626.withdraw`](../interfaces#IERC4626-withdraw-uint256-address-address-) and -[`IERC4626.redeem`](../interfaces#IERC4626-redeem-uint256-address-address-), which is documented to have lead to loss of funds. - -* Overrides to the deposit or withdraw mechanism must be reflected in the preview functions as well. - -* [`IERC4626.maxWithdraw`](../interfaces#IERC4626-maxWithdraw-address-) depends on [`IERC4626.maxRedeem`](../interfaces#IERC4626-maxRedeem-address-). Therefore, overriding [`IERC4626.maxRedeem`](../interfaces#IERC4626-maxRedeem-address-) only is enough. On the other hand, -overriding [`IERC4626.maxWithdraw`](../interfaces#IERC4626-maxWithdraw-address-) only would have no effect on [`IERC4626.maxRedeem`](../interfaces#IERC4626-maxRedeem-address-), and could create an inconsistency between the two -functions. - -* If [`IERC4626.previewRedeem`](../interfaces#IERC4626-previewRedeem-uint256-) is overridden to revert, [`IERC4626.maxWithdraw`](../interfaces#IERC4626-maxWithdraw-address-) must be overridden as necessary to ensure it -always return successfully. - +Interface for the optional metadata functions from the ERC-20 standard.

Functions

-- [constructor(asset_)](#ERC4626-constructor-contract-IERC20-) -- [decimals()](#ERC4626-decimals--) -- [asset()](#ERC4626-asset--) -- [totalAssets()](#ERC4626-totalAssets--) -- [convertToShares(assets)](#ERC4626-convertToShares-uint256-) -- [convertToAssets(shares)](#ERC4626-convertToAssets-uint256-) -- [maxDeposit()](#ERC4626-maxDeposit-address-) -- [maxMint()](#ERC4626-maxMint-address-) -- [maxWithdraw(owner)](#ERC4626-maxWithdraw-address-) -- [maxRedeem(owner)](#ERC4626-maxRedeem-address-) -- [previewDeposit(assets)](#ERC4626-previewDeposit-uint256-) -- [previewMint(shares)](#ERC4626-previewMint-uint256-) -- [previewWithdraw(assets)](#ERC4626-previewWithdraw-uint256-) -- [previewRedeem(shares)](#ERC4626-previewRedeem-uint256-) -- [deposit(assets, receiver)](#ERC4626-deposit-uint256-address-) -- [mint(shares, receiver)](#ERC4626-mint-uint256-address-) -- [withdraw(assets, receiver, owner)](#ERC4626-withdraw-uint256-address-address-) -- [redeem(shares, receiver, owner)](#ERC4626-redeem-uint256-address-address-) -- [_convertToShares(assets, rounding)](#ERC4626-_convertToShares-uint256-enum-Math-Rounding-) -- [_convertToAssets(shares, rounding)](#ERC4626-_convertToAssets-uint256-enum-Math-Rounding-) -- [_deposit(caller, receiver, assets, shares)](#ERC4626-_deposit-address-address-uint256-uint256-) -- [_withdraw(caller, receiver, owner, assets, shares)](#ERC4626-_withdraw-address-address-address-uint256-uint256-) -- [_decimalsOffset()](#ERC4626-_decimalsOffset--) -#### IERC4626 [!toc] -#### ERC20 [!toc] -- [name()](#ERC20-name--) -- [symbol()](#ERC20-symbol--) -- [totalSupply()](#ERC20-totalSupply--) -- [balanceOf(account)](#ERC20-balanceOf-address-) -- [transfer(to, value)](#ERC20-transfer-address-uint256-) -- [allowance(owner, spender)](#ERC20-allowance-address-address-) -- [approve(spender, value)](#ERC20-approve-address-uint256-) -- [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) -- [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) -- [_update(from, to, value)](#ERC20-_update-address-address-uint256-) -- [_mint(account, value)](#ERC20-_mint-address-uint256-) -- [_burn(account, value)](#ERC20-_burn-address-uint256-) -- [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) -- [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) -- [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] -
-
- -
-

Events

-
-#### IERC4626 [!toc] -- [Deposit(sender, owner, assets, shares)](#IERC4626-Deposit-address-address-uint256-uint256-) -- [Withdraw(sender, receiver, owner, assets, shares)](#IERC4626-Withdraw-address-address-address-uint256-uint256-) -#### ERC20 [!toc] -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] +- [name()](#IERC20Metadata-name--) +- [symbol()](#IERC20Metadata-symbol--) +- [decimals()](#IERC20Metadata-decimals--) #### IERC20 [!toc] -- [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) -- [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) +- [totalSupply()](#IERC20-totalSupply--) +- [balanceOf(account)](#IERC20-balanceOf-address-) +- [transfer(to, value)](#IERC20-transfer-address-uint256-) +- [allowance(owner, spender)](#IERC20-allowance-address-address-) +- [approve(spender, value)](#IERC20-approve-address-uint256-) +- [transferFrom(from, to, value)](#IERC20-transferFrom-address-address-uint256-)
-

Errors

+

Events

-- [ERC4626ExceededMaxDeposit(receiver, assets, max)](#ERC4626-ERC4626ExceededMaxDeposit-address-uint256-uint256-) -- [ERC4626ExceededMaxMint(receiver, shares, max)](#ERC4626-ERC4626ExceededMaxMint-address-uint256-uint256-) -- [ERC4626ExceededMaxWithdraw(owner, assets, max)](#ERC4626-ERC4626ExceededMaxWithdraw-address-uint256-uint256-) -- [ERC4626ExceededMaxRedeem(owner, shares, max)](#ERC4626-ERC4626ExceededMaxRedeem-address-uint256-uint256-) -#### IERC4626 [!toc] -#### ERC20 [!toc] -#### IERC20Errors [!toc] -- [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) -- [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) -- [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) -- [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) -- [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) -- [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -#### IERC20Metadata [!toc] #### IERC20 [!toc] +- [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) +- [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-)
- +
-

constructor(contract IERC20 asset_)

+

name() → string

-

internal

-# +

external

+#
-Set the underlying asset contract. This must be an ERC20-compatible contract (ERC-20 or ERC-777). +Returns the name of the token.
- +
-

decimals() → uint8

+

symbol() → string

-

public

-# +

external

+#
-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`](#IERC20Metadata-decimals--). +Returns the symbol of the token.
- +
-

asset() → address

+

decimals() → uint8

-

public

-# +

external

+#
-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. +Returns the decimals places of the token.
- + + +
+ +## `IERC20Permit` + + + + -
-
-

totalAssets() → uint256

-
-

public

-# -
-
-Returns the total amount of the underlying asset that is “managed” by Vault. +```solidity +import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol"; +``` -- 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. +Interface of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in +[ERC-2612](https://eips.ethereum.org/EIPS/eip-2612). + +Adds the [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) method, which can be used to change an account's ERC-20 allowance (see [`IERC20.allowance`](#IERC20-allowance-address-address-)) by +presenting a message signed by the account. By not relying on [`IERC20.approve`](#IERC20-approve-address-uint256-), 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: + +```solidity +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`](#SafeERC20-safeTransferFrom-contract-IERC20-address-address-uint256-)). + +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(owner, spender, value, deadline, v, r, s)](#IERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) +- [nonces(owner)](#IERC20Permit-nonces-address-) +- [DOMAIN_SEPARATOR()](#IERC20Permit-DOMAIN_SEPARATOR--)
- +
-

convertToShares(uint256 assets) → uint256

+

permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)

-

public

-# +

external

+#
-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. +Sets `value` as the allowance of `spender` over ``owner``'s tokens, +given ``owner``'s signed approval. -- 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. + +The same issues [`IERC20.approve`](#IERC20-approve-address-uint256-) has related to transaction +ordering also applies here. + - -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. +Emits an [`IERC20.Approval`](#IERC20-Approval-address-address-uint256-) event. + +Requirements: + +- `spender` cannot be the zero address. +- `deadline` must be a timestamp in the future. +- `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` +over the EIP712-formatted function arguments. +- the signature must use ``owner``'s current nonce (see [`ERC20Permit.nonces`](#ERC20Permit-nonces-address-)). + +For more information on the signature format, see the +[relevant EIP +section](https://eips.ethereum.org/EIPS/eip-2612#specification). + + +See Security Considerations above.
- +
-

convertToAssets(uint256 shares) → uint256

+

nonces(address owner) → uint256

-

public

-# +

external

+#
-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. +Returns the current nonce for `owner`. This value must be +included whenever a signature is generated for [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-). - -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. - +Every successful call to [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) increases ``owner``'s nonce by one. This +prevents a signature from being used multiple times.
- +
-

maxDeposit(address) → uint256

+

DOMAIN_SEPARATOR() → bytes32

-

public

-# +

external

+#
-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. +Returns the domain separator used in the encoding of the signature for [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-), as defined by [`EIP712`](/contracts/5.x/api/utils/cryptography#EIP712).
- + -
-
-

maxMint(address) → uint256

-
-

public

-# +
+ +## `ERC20TemporaryApproval` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20TemporaryApproval.sol"; +``` + +Extension of [`ERC20`](#ERC20) that adds support for temporary allowances following ERC-7674. + + +This is a draft contract. The corresponding ERC is still subject to changes. + + +_Available since v5.1._ + +
+

Functions

+
+- [allowance(owner, spender)](#ERC20TemporaryApproval-allowance-address-address-) +- [_temporaryAllowance(owner, spender)](#ERC20TemporaryApproval-_temporaryAllowance-address-address-) +- [temporaryApprove(spender, value)](#ERC20TemporaryApproval-temporaryApprove-address-uint256-) +- [_temporaryApprove(owner, spender, value)](#ERC20TemporaryApproval-_temporaryApprove-address-address-uint256-) +- [_spendAllowance(owner, spender, value)](#ERC20TemporaryApproval-_spendAllowance-address-address-uint256-) +#### IERC7674 [!toc] +#### ERC20 [!toc] +- [name()](#ERC20-name--) +- [symbol()](#ERC20-symbol--) +- [decimals()](#ERC20-decimals--) +- [totalSupply()](#ERC20-totalSupply--) +- [balanceOf(account)](#ERC20-balanceOf-address-) +- [transfer(to, value)](#ERC20-transfer-address-uint256-) +- [approve(spender, value)](#ERC20-approve-address-uint256-) +- [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) +- [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) +- [_update(from, to, value)](#ERC20-_update-address-address-uint256-) +- [_mint(account, value)](#ERC20-_mint-address-uint256-) +- [_burn(account, value)](#ERC20-_burn-address-uint256-) +- [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) +- [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) +#### IERC20Errors [!toc] +#### IERC20Metadata [!toc] +#### IERC20 [!toc]
-
-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. +
+

Events

+
+#### IERC7674 [!toc] +#### ERC20 [!toc] +#### IERC20Errors [!toc] +#### IERC20Metadata [!toc] +#### IERC20 [!toc] +- [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) +- [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) +
+
+
+

Errors

+
+#### IERC7674 [!toc] +#### ERC20 [!toc] +#### IERC20Errors [!toc] +- [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) +- [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) +- [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) +- [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) +- [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) +- [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) +#### IERC20Metadata [!toc] +#### IERC20 [!toc]
- +
-

maxWithdraw(address owner) → uint256

+

allowance(address owner, address spender) → uint256

public

-# +#
-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. +[`ERC20.allowance`](#ERC20-allowance-address-address-) 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.
- +
-

maxRedeem(address owner) → uint256

+

_temporaryAllowance(address owner, address spender) → uint256

-

public

-# +

internal

+#
-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. +Internal getter for the current temporary allowance that `spender` has over `owner` tokens.
- +
-

previewDeposit(uint256 assets) → uint256

+

temporaryApprove(address spender, uint256 value) → bool

public

-# +#
-Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given -current on-chain conditions. +Alternative to [`ERC20.approve`](#ERC20-approve-address-uint256-) that sets a `value` amount of tokens as the temporary allowance of `spender` over +the caller's tokens. -- 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. +Returns a boolean value indicating whether the operation succeeded. - -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. - +Requirements: +- `spender` cannot be the zero address. + +Does NOT emit an [`IERC20.Approval`](#IERC20-Approval-address-address-uint256-) event.
- +
-

previewMint(uint256 shares) → uint256

+

_temporaryApprove(address owner, address spender, uint256 value)

-

public

-# +

internal

+#
-Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given -current on-chain conditions. +Sets `value` as the temporary allowance of `spender` over the `owner`'s tokens. -- 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. +This internal function is equivalent to `temporaryApprove`, and can be used to e.g. set automatic allowances +for certain subsystems, etc. - -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. - +Requirements: +- `owner` cannot be the zero address. +- `spender` cannot be the zero address. + +Does NOT emit an [`IERC20.Approval`](#IERC20-Approval-address-address-uint256-) event.
- +
-

previewWithdraw(uint256 assets) → uint256

+

_spendAllowance(address owner, address spender, uint256 value)

-

public

-# +

internal

+#
-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. - +[`ERC20._spendAllowance`](#ERC20-_spendAllowance-address-address-uint256-) override that consumes the temporary allowance (if any) before eventually falling back +to consuming the persistent allowance. -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. +This function skips calling `super._spendAllowance` if the temporary allowance +is enough to cover the spending.
- - -
-
-

previewRedeem(uint256 shares) → uint256

-
-

public

-# -
-
-
+ -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. +## `SafeERC20` - -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. - + + + -
- +```solidity +import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; +``` -
-
-

deposit(uint256 assets, address receiver) → uint256

-
-

public

-# +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(token, to, value)](#SafeERC20-safeTransfer-contract-IERC20-address-uint256-) +- [safeTransferFrom(token, from, to, value)](#SafeERC20-safeTransferFrom-contract-IERC20-address-address-uint256-) +- [trySafeTransfer(token, to, value)](#SafeERC20-trySafeTransfer-contract-IERC20-address-uint256-) +- [trySafeTransferFrom(token, from, to, value)](#SafeERC20-trySafeTransferFrom-contract-IERC20-address-address-uint256-) +- [safeIncreaseAllowance(token, spender, value)](#SafeERC20-safeIncreaseAllowance-contract-IERC20-address-uint256-) +- [safeDecreaseAllowance(token, spender, requestedDecrease)](#SafeERC20-safeDecreaseAllowance-contract-IERC20-address-uint256-) +- [forceApprove(token, spender, value)](#SafeERC20-forceApprove-contract-IERC20-address-uint256-) +- [transferAndCallRelaxed(token, to, value, data)](#SafeERC20-transferAndCallRelaxed-contract-IERC1363-address-uint256-bytes-) +- [transferFromAndCallRelaxed(token, from, to, value, data)](#SafeERC20-transferFromAndCallRelaxed-contract-IERC1363-address-address-uint256-bytes-) +- [approveAndCallRelaxed(token, to, value, data)](#SafeERC20-approveAndCallRelaxed-contract-IERC1363-address-uint256-bytes-)
-
- -Deposit `assets` underlying tokens and send the corresponding number of vault shares (`shares`) to `receiver`. - -- 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). - - -most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. - +
+

Errors

+
+- [SafeERC20FailedOperation(token)](#SafeERC20-SafeERC20FailedOperation-address-) +- [SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease)](#SafeERC20-SafeERC20FailedDecreaseAllowance-address-uint256-uint256-)
- +
-

mint(uint256 shares, address receiver) → uint256

+

safeTransfer(contract IERC20 token, address to, uint256 value)

-

public

-# +

internal

+#
-Mints exactly `shares` vault shares to `receiver` in exchange for `assets` 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). - - -most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. - +Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, +non-reverting calls are assumed to be successful.
- +
-

withdraw(uint256 assets, address receiver, address owner) → uint256

+

safeTransferFrom(contract IERC20 token, address from, address to, uint256 value)

-

public

-# +

internal

+#
-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. +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.
- +
-

redeem(uint256 shares, address receiver, address owner) → uint256

+

trySafeTransfer(contract IERC20 token, address to, uint256 value) → bool

-

public

-# +

internal

+#
-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). - - -some implementations will require pre-requesting to the Vault before a withdrawal may be performed. -Those methods should be performed separately. - +Variant of [`SafeERC20.safeTransfer`](#SafeERC20-safeTransfer-contract-IERC20-address-uint256-) that returns a bool instead of reverting if the operation is not successful.
- +
-

_convertToShares(uint256 assets, enum Math.Rounding rounding) → uint256

+

trySafeTransferFrom(contract IERC20 token, address from, address to, uint256 value) → bool

internal

-# +#
-Internal conversion function (from assets to shares) with support for rounding direction. +Variant of [`SafeERC20.safeTransferFrom`](#SafeERC20-safeTransferFrom-contract-IERC20-address-address-uint256-) that returns a bool instead of reverting if the operation is not successful.
- +
-

_convertToAssets(uint256 shares, enum Math.Rounding rounding) → uint256

+

safeIncreaseAllowance(contract IERC20 token, address spender, uint256 value)

internal

-# +#
-Internal conversion function (from shares to assets) with support for rounding direction. +Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, +non-reverting calls are assumed to be successful. + + +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 [`SafeERC20.safeIncreaseAllowance`](#SafeERC20-safeIncreaseAllowance-contract-IERC20-address-uint256-) or [`SafeERC20.safeDecreaseAllowance`](#SafeERC20-safeDecreaseAllowance-contract-IERC20-address-uint256-) operation on a token contract +that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior. +
- +
-

_deposit(address caller, address receiver, uint256 assets, uint256 shares)

+

safeDecreaseAllowance(contract IERC20 token, address spender, uint256 requestedDecrease)

internal

-# +#
-Deposit/mint common workflow. +Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no +value, non-reverting calls are assumed to be successful. + + +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 [`SafeERC20.safeIncreaseAllowance`](#SafeERC20-safeIncreaseAllowance-contract-IERC20-address-uint256-) or [`SafeERC20.safeDecreaseAllowance`](#SafeERC20-safeDecreaseAllowance-contract-IERC20-address-uint256-) operation on a token contract +that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior. +
- +
-

_withdraw(address caller, address receiver, address owner, uint256 assets, uint256 shares)

+

forceApprove(contract IERC20 token, address spender, uint256 value)

internal

-# +#
-Withdraw/redeem common workflow. +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. + + +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. +
- +
-

_decimalsOffset() → uint8

+

transferAndCallRelaxed(contract IERC1363 token, address to, uint256 value, bytes data)

internal

-# +#
+Performs an [`ERC1363`](#ERC1363) transferAndCall, with a fallback to the simple [`ERC20`](#ERC20) transfer if the target has no +code. This can be used to implement an [`ERC721`](/contracts/5.x/api/token/ERC721#ERC721)-like safe transfer that relies on [`ERC1363`](#ERC1363) checks when +targeting contracts. + +Reverts if the returned value is other than `true`. +
- +
-

ERC4626ExceededMaxDeposit(address receiver, uint256 assets, uint256 max)

+

transferFromAndCallRelaxed(contract IERC1363 token, address from, address to, uint256 value, bytes data)

-

error

-# +

internal

+#
-Attempted to deposit more assets than the max amount for `receiver`. +Performs an [`ERC1363`](#ERC1363) transferFromAndCall, with a fallback to the simple [`ERC20`](#ERC20) transferFrom if the target +has no code. This can be used to implement an [`ERC721`](/contracts/5.x/api/token/ERC721#ERC721)-like safe transfer that relies on [`ERC1363`](#ERC1363) checks when +targeting contracts. + +Reverts if the returned value is other than `true`.
- +
-

ERC4626ExceededMaxMint(address receiver, uint256 shares, uint256 max)

+

approveAndCallRelaxed(contract IERC1363 token, address to, uint256 value, bytes data)

-

error

-# +

internal

+#
-Attempted to mint more shares than the max amount for `receiver`. +Performs an [`ERC1363`](#ERC1363) approveAndCall, with a fallback to the simple [`ERC20`](#ERC20) approve if the target has no +code. This can be used to implement an [`ERC721`](/contracts/5.x/api/token/ERC721#ERC721)-like safe transfer that rely on [`ERC1363`](#ERC1363) checks when +targeting contracts. + + +When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as [`SafeERC20.forceApprove`](#SafeERC20-forceApprove-contract-IERC20-address-uint256-). +Oppositely, when the recipient address (`to`) has code, this function only attempts to call [`ERC1363.approveAndCall`](#ERC1363-approveAndCall-address-uint256-bytes-) +once without retrying, and relies on the returned value to be true. + + +Reverts if the returned value is other than `true`.
- +
-

ERC4626ExceededMaxWithdraw(address owner, uint256 assets, uint256 max)

+

SafeERC20FailedOperation(address token)

error

-# +#
-Attempted to withdraw more assets than the max amount for `receiver`. +An operation with an ERC-20 token failed.
- +
-

ERC4626ExceededMaxRedeem(address owner, uint256 shares, uint256 max)

+

SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease)

error

-# +#
-Attempted to redeem more shares than the max amount for `receiver`. +Indicates a failed `decreaseAllowance` request.
- +
-## `IERC20Metadata` +## `ERC1363` - +
```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/ERC1363.sol"; ``` -Interface for the optional metadata functions from the ERC-20 standard. +Extension of [`ERC20`](#ERC20) tokens that adds support for code execution after transfers and approvals +on recipient contracts. Calls after transfers are enabled through the [`ERC1363.transferAndCall`](#ERC1363-transferAndCall-address-uint256-bytes-) and +[`ERC1363.transferFromAndCall`](#ERC1363-transferFromAndCall-address-address-uint256-bytes-) methods while calls after approvals can be made with [`ERC1363.approveAndCall`](#ERC1363-approveAndCall-address-uint256-bytes-) + +_Available since v5.1._

Functions

-- [name()](#IERC20Metadata-name--) -- [symbol()](#IERC20Metadata-symbol--) -- [decimals()](#IERC20Metadata-decimals--) +- [supportsInterface(interfaceId)](#ERC1363-supportsInterface-bytes4-) +- [transferAndCall(to, value)](#ERC1363-transferAndCall-address-uint256-) +- [transferAndCall(to, value, data)](#ERC1363-transferAndCall-address-uint256-bytes-) +- [transferFromAndCall(from, to, value)](#ERC1363-transferFromAndCall-address-address-uint256-) +- [transferFromAndCall(from, to, value, data)](#ERC1363-transferFromAndCall-address-address-uint256-bytes-) +- [approveAndCall(spender, value)](#ERC1363-approveAndCall-address-uint256-) +- [approveAndCall(spender, value, data)](#ERC1363-approveAndCall-address-uint256-bytes-) +#### IERC1363 [!toc] +#### ERC165 [!toc] +#### IERC165 [!toc] +#### ERC20 [!toc] +- [name()](#ERC20-name--) +- [symbol()](#ERC20-symbol--) +- [decimals()](#ERC20-decimals--) +- [totalSupply()](#ERC20-totalSupply--) +- [balanceOf(account)](#ERC20-balanceOf-address-) +- [transfer(to, value)](#ERC20-transfer-address-uint256-) +- [allowance(owner, spender)](#ERC20-allowance-address-address-) +- [approve(spender, value)](#ERC20-approve-address-uint256-) +- [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) +- [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) +- [_update(from, to, value)](#ERC20-_update-address-address-uint256-) +- [_mint(account, value)](#ERC20-_mint-address-uint256-) +- [_burn(account, value)](#ERC20-_burn-address-uint256-) +- [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) +- [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) +- [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) +#### IERC20Errors [!toc] +#### IERC20Metadata [!toc] #### IERC20 [!toc] -- [totalSupply()](#IERC20-totalSupply--) -- [balanceOf(account)](#IERC20-balanceOf-address-) -- [transfer(to, value)](#IERC20-transfer-address-uint256-) -- [allowance(owner, spender)](#IERC20-allowance-address-address-) -- [approve(spender, value)](#IERC20-approve-address-uint256-) -- [transferFrom(from, to, value)](#IERC20-transferFrom-address-address-uint256-)

Events

+#### IERC1363 [!toc] +#### ERC165 [!toc] +#### IERC165 [!toc] +#### ERC20 [!toc] +#### IERC20Errors [!toc] +#### IERC20Metadata [!toc] #### IERC20 [!toc] - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-)
- +
+

Errors

+
+- [ERC1363TransferFailed(receiver, value)](#ERC1363-ERC1363TransferFailed-address-uint256-) +- [ERC1363TransferFromFailed(sender, receiver, value)](#ERC1363-ERC1363TransferFromFailed-address-address-uint256-) +- [ERC1363ApproveFailed(spender, value)](#ERC1363-ERC1363ApproveFailed-address-uint256-) +#### IERC1363 [!toc] +#### ERC165 [!toc] +#### IERC165 [!toc] +#### ERC20 [!toc] +#### IERC20Errors [!toc] +- [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) +- [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) +- [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) +- [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) +- [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) +- [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) +#### IERC20Metadata [!toc] +#### IERC20 [!toc] +
+
+ + + +
+
+

supportsInterface(bytes4 interfaceId) → bool

+
+

public

+# +
+
+
+ +Returns true if this contract implements the interface defined by +`interfaceId`. See the corresponding +[ERC section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) +to learn more about how these ids are created. + +This function call must use less than 30 000 gas. + +
+
+ + + +
+
+

transferAndCall(address to, uint256 value) → bool

+
+

public

+# +
+
+
+ +Moves a `value` amount of tokens from the caller's account to `to` +and then calls [`IERC1363Receiver.onTransferReceived`](/contracts/5.x/api/interfaces#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) on `to`. Returns a flag that indicates +if the call succeeded. + +Requirements: + +- The target has code (i.e. is a contract). +- The target `to` must implement the [`IERC1363Receiver`](/contracts/5.x/api/interfaces#IERC1363Receiver) interface. +- The target must return the [`IERC1363Receiver.onTransferReceived`](/contracts/5.x/api/interfaces#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) selector to accept the transfer. +- The internal [`ERC20.transfer`](#ERC20-transfer-address-uint256-) must succeed (returned `true`). + +
+
+ +
-

name() → string

+

transferAndCall(address to, uint256 value, bytes data) → bool

-

external

-# +

public

+#
-Returns the name of the token. +Variant of [`ERC1363.transferAndCall`](#ERC1363-transferAndCall-address-uint256-bytes-) that accepts an additional `data` parameter with +no specified format.
- +
-

symbol() → string

+

transferFromAndCall(address from, address to, uint256 value) → bool

-

external

-# +

public

+#
-Returns the symbol of the token. +Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism +and then calls [`IERC1363Receiver.onTransferReceived`](/contracts/5.x/api/interfaces#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) on `to`. Returns a flag that indicates +if the call succeeded. + +Requirements: + +- The target has code (i.e. is a contract). +- The target `to` must implement the [`IERC1363Receiver`](/contracts/5.x/api/interfaces#IERC1363Receiver) interface. +- The target must return the [`IERC1363Receiver.onTransferReceived`](/contracts/5.x/api/interfaces#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) selector to accept the transfer. +- The internal [`ERC20.transferFrom`](#ERC20-transferFrom-address-address-uint256-) must succeed (returned `true`).
- +
-

decimals() → uint8

+

transferFromAndCall(address from, address to, uint256 value, bytes data) → bool

-

external

-# +

public

+#
-Returns the decimals places of the token. +Variant of [`ERC1363.transferFromAndCall`](#ERC1363-transferFromAndCall-address-address-uint256-bytes-) that accepts an additional `data` parameter with +no specified format.
- - -
- -## `IERC20Permit` - - - - + +
+
+

approveAndCall(address spender, uint256 value) → bool

+
+

public

+#
+
+
-```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol"; -``` - -Interface of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in -[ERC-2612](https://eips.ethereum.org/EIPS/eip-2612). - -Adds the [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) method, which can be used to change an account's ERC-20 allowance (see [`IERC20.allowance`](#IERC20-allowance-address-address-)) by -presenting a message signed by the account. By not relying on [`IERC20.approve`](#IERC20-approve-address-uint256-), 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: - -```solidity -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); - ... -} -``` +Sets a `value` amount of tokens as the allowance of `spender` over the +caller's tokens and then calls [`IERC1363Spender.onApprovalReceived`](/contracts/5.x/api/interfaces#IERC1363Spender-onApprovalReceived-address-uint256-bytes-) on `spender`. +Returns a flag that indicates if the call succeeded. -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`](#SafeERC20-safeTransferFrom-contract-IERC20-address-address-uint256-)). +Requirements: -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. +- The target has code (i.e. is a contract). +- The target `spender` must implement the [`IERC1363Spender`](/contracts/5.x/api/interfaces#IERC1363Spender) interface. +- The target must return the [`IERC1363Spender.onApprovalReceived`](/contracts/5.x/api/interfaces#IERC1363Spender-onApprovalReceived-address-uint256-bytes-) selector to accept the approval. +- The internal [`ERC20.approve`](#ERC20-approve-address-uint256-) must succeed (returned `true`). -
-

Functions

-
-- [permit(owner, spender, value, deadline, v, r, s)](#IERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) -- [nonces(owner)](#IERC20Permit-nonces-address-) -- [DOMAIN_SEPARATOR()](#IERC20Permit-DOMAIN_SEPARATOR--)
- +
-

permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)

+

approveAndCall(address spender, uint256 value, bytes data) → bool

-

external

-# +

public

+#
-Sets `value` as the allowance of `spender` over ``owner``'s tokens, -given ``owner``'s signed approval. - - -The same issues [`IERC20.approve`](#IERC20-approve-address-uint256-) has related to transaction -ordering also applies here. - - -Emits an [`IERC6909.Approval`](../interfaces#IERC6909-Approval-address-address-uint256-uint256-) event. +Variant of [`ERC1363.approveAndCall`](#ERC1363-approveAndCall-address-uint256-bytes-) that accepts an additional `data` parameter with +no specified format. -Requirements: +
+
-- `spender` cannot be the zero address. -- `deadline` must be a timestamp in the future. -- `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` -over the EIP712-formatted function arguments. -- the signature must use ``owner``'s current nonce (see [`ERC20Permit.nonces`](#ERC20Permit-nonces-address-)). + -For more information on the signature format, see the -[relevant EIP -section](https://eips.ethereum.org/EIPS/eip-2612#specification). +
+
+

ERC1363TransferFailed(address receiver, uint256 value)

+
+

error

+# +
+
+
-CAUTION: See Security Considerations above. +Indicates a failure within the [`ERC20.transfer`](#ERC20-transfer-address-uint256-) part of a transferAndCall operation.
- +
-

nonces(address owner) → uint256

+

ERC1363TransferFromFailed(address sender, address receiver, uint256 value)

-

external

-# +

error

+#
-Returns the current nonce for `owner`. This value must be -included whenever a signature is generated for [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-). - -Every successful call to [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) increases ``owner``'s nonce by one. This -prevents a signature from being used multiple times. +Indicates a failure within the [`ERC20.transferFrom`](#ERC20-transferFrom-address-address-uint256-) part of a transferFromAndCall operation.
- +
-

DOMAIN_SEPARATOR() → bytes32

+

ERC1363ApproveFailed(address spender, uint256 value)

-

external

-# +

error

+#
-Returns the domain separator used in the encoding of the signature for [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-), as defined by [`EIP712`](../utils/cryptography#EIP712). +Indicates a failure within the [`ERC20.approve`](#ERC20-approve-address-uint256-) part of a approveAndCall operation.
- +
-## `ERC20Bridgeable` +## `ERC20Burnable` - +
```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Bridgeable.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; ``` -ERC20 extension that implements the standard token interface according to -[ERC-7802](https://eips.ethereum.org/EIPS/eip-7802). - -
-

Modifiers

-
-- [onlyTokenBridge()](#ERC20Bridgeable-onlyTokenBridge--) -
-
+Extension of [`ERC20`](#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

-- [supportsInterface(interfaceId)](#ERC20Bridgeable-supportsInterface-bytes4-) -- [crosschainMint(to, value)](#ERC20Bridgeable-crosschainMint-address-uint256-) -- [crosschainBurn(from, value)](#ERC20Bridgeable-crosschainBurn-address-uint256-) -- [_checkTokenBridge(caller)](#ERC20Bridgeable-_checkTokenBridge-address-) -#### IERC7802 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] +- [burn(value)](#ERC20Burnable-burn-uint256-) +- [burnFrom(account, value)](#ERC20Burnable-burnFrom-address-uint256-) #### ERC20 [!toc] - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) @@ -3461,11 +3742,6 @@ ERC20 extension that implements the standard token interface according to

Events

-#### IERC7802 [!toc] -- [CrosschainMint(to, amount, sender)](#IERC7802-CrosschainMint-address-uint256-address-) -- [CrosschainBurn(from, amount, sender)](#IERC7802-CrosschainBurn-address-uint256-address-) -#### ERC165 [!toc] -#### IERC165 [!toc] #### ERC20 [!toc] #### IERC20Errors [!toc] #### IERC20Metadata [!toc] @@ -3478,9 +3754,6 @@ ERC20 extension that implements the standard token interface according to

Errors

-#### IERC7802 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] #### ERC20 [!toc] #### IERC20Errors [!toc] - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) @@ -3494,133 +3767,74 @@ ERC20 extension that implements the standard token interface according to
- - -
-
-

onlyTokenBridge()

-
-

internal

-# -
-
- -
- -Modifier to restrict access to the token bridge. - -
-
- - - -
-
-

supportsInterface(bytes4 interfaceId) → bool

-
-

public

-# -
-
-
- -Returns true if this contract implements the interface defined by -`interfaceId`. See the corresponding -[ERC section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) -to learn more about how these ids are created. - -This function call must use less than 30 000 gas. - -
-
- - +
-

crosschainMint(address to, uint256 value)

+

burn(uint256 value)

public

-# +#
-See [`IERC7802.crosschainMint`](../interfaces#IERC7802-crosschainMint-address-uint256-). Emits a [`IERC7802.CrosschainMint`](../interfaces#IERC7802-CrosschainMint-address-uint256-address-) event. - -
-
- - - -
-
-

crosschainBurn(address from, uint256 value)

-
-

public

-# -
-
-
+Destroys a `value` amount of tokens from the caller. -See [`IERC7802.crosschainBurn`](../interfaces#IERC7802-crosschainBurn-address-uint256-). Emits a [`IERC7802.CrosschainBurn`](../interfaces#IERC7802-CrosschainBurn-address-uint256-address-) event. +See [`ERC20._burn`](#ERC20-_burn-address-uint256-).
- +
-

_checkTokenBridge(address caller)

-
-

internal

-# +

burnFrom(address account, uint256 value)

+
+

public

+#
-Checks if the caller is a trusted token bridge. MUST revert otherwise. +Destroys a `value` amount of tokens from `account`, deducting from +the caller's allowance. -Developers should implement this function using an access control mechanism that allows -customizing the list of allowed senders. Consider using [`AccessControl`](../access#AccessControl) or [`AccessManaged`](../access#AccessManaged). +See [`ERC20._burn`](#ERC20-_burn-address-uint256-) and [`ERC20.allowance`](#ERC20-allowance-address-address-). + +Requirements: + +- the caller must have allowance for ``accounts``'s tokens of at least +`value`.
- +
-## `ERC20TemporaryApproval` +## `ERC20Capped` - +
```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20TemporaryApproval.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol"; ``` -Extension of [`ERC20`](#ERC20) that adds support for temporary allowances following ERC-7674. - - -This is a draft contract. The corresponding ERC is still subject to changes. - - -_Available since v5.1._ +Extension of [`ERC20`](#ERC20) that adds a cap to the supply of tokens.

Functions

-- [allowance(owner, spender)](#ERC20TemporaryApproval-allowance-address-address-) -- [_temporaryAllowance(owner, spender)](#ERC20TemporaryApproval-_temporaryAllowance-address-address-) -- [temporaryApprove(spender, value)](#ERC20TemporaryApproval-temporaryApprove-address-uint256-) -- [_temporaryApprove(owner, spender, value)](#ERC20TemporaryApproval-_temporaryApprove-address-address-uint256-) -- [_spendAllowance(owner, spender, value)](#ERC20TemporaryApproval-_spendAllowance-address-address-uint256-) -#### IERC7674 [!toc] +- [constructor(cap_)](#ERC20Capped-constructor-uint256-) +- [cap()](#ERC20Capped-cap--) +- [_update(from, to, value)](#ERC20Capped-_update-address-address-uint256-) #### ERC20 [!toc] - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) @@ -3628,14 +3842,15 @@ _Available since v5.1._ - [totalSupply()](#ERC20-totalSupply--) - [balanceOf(account)](#ERC20-balanceOf-address-) - [transfer(to, value)](#ERC20-transfer-address-uint256-) +- [allowance(owner, spender)](#ERC20-allowance-address-address-) - [approve(spender, value)](#ERC20-approve-address-uint256-) - [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) - [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) -- [_update(from, to, value)](#ERC20-_update-address-address-uint256-) - [_mint(account, value)](#ERC20-_mint-address-uint256-) - [_burn(account, value)](#ERC20-_burn-address-uint256-) - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) +- [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) #### IERC20Errors [!toc] #### IERC20Metadata [!toc] #### IERC20 [!toc] @@ -3645,7 +3860,6 @@ _Available since v5.1._

Events

-#### IERC7674 [!toc] #### ERC20 [!toc] #### IERC20Errors [!toc] #### IERC20Metadata [!toc] @@ -3658,7 +3872,8 @@ _Available since v5.1._

Errors

-#### IERC7674 [!toc] +- [ERC20ExceededCap(increasedSupply, cap)](#ERC20Capped-ERC20ExceededCap-uint256-uint256-) +- [ERC20InvalidCap(cap)](#ERC20Capped-ERC20InvalidCap-uint256-) #### ERC20 [!toc] #### IERC20Errors [!toc] - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) @@ -3672,521 +3887,515 @@ _Available since v5.1._
- +
-

allowance(address owner, address spender) → uint256

+

constructor(uint256 cap_)

-

public

-# +

internal

+#
-[`IERC6909.allowance`](../interfaces#IERC6909-allowance-address-address-uint256-) 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. +Sets the value of the `cap`. This value is immutable, it can only be +set once during construction.
- +
-

_temporaryAllowance(address owner, address spender) → uint256

+

cap() → uint256

-

internal

-# +

public

+#
-Internal getter for the current temporary allowance that `spender` has over `owner` tokens. +Returns the cap on the token's total supply.
- +
-

temporaryApprove(address spender, uint256 value) → bool

+

_update(address from, address to, uint256 value)

-

public

-# +

internal

+#
-Alternative to [`IERC6909.approve`](../interfaces#IERC6909-approve-address-uint256-uint256-) 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: -- `spender` cannot be the zero address. +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. -Does NOT emit an [`IERC6909.Approval`](../interfaces#IERC6909-Approval-address-address-uint256-uint256-) event. +Emits a [`IERC20.Transfer`](#IERC20-Transfer-address-address-uint256-) event.
- +
-

_temporaryApprove(address owner, address spender, uint256 value)

+

ERC20ExceededCap(uint256 increasedSupply, uint256 cap)

-

internal

-# +

error

+#
-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: -- `owner` cannot be the zero address. -- `spender` cannot be the zero address. - -Does NOT emit an [`IERC6909.Approval`](../interfaces#IERC6909-Approval-address-address-uint256-uint256-) event. +Total supply cap has been exceeded.
- +
-

_spendAllowance(address owner, address spender, uint256 value)

+

ERC20InvalidCap(uint256 cap)

-

internal

-# +

error

+#
-[`ERC20._spendAllowance`](#ERC20-_spendAllowance-address-address-uint256-) override that consumes the temporary allowance (if any) before eventually falling back -to consuming the persistent allowance. - -This function skips calling `super._spendAllowance` if the temporary allowance -is enough to cover the spending. - +The supplied cap is not a valid cap.
- +
-## `ERC1363Utils` +## `ERC20Pausable` - +
```solidity -import "@openzeppelin/contracts/token/ERC20/utils/ERC1363Utils.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol"; ``` -Library that provides common ERC-1363 utility functions. +ERC-20 token with pausable token transfers, minting and burning. -See [ERC-1363](https://eips.ethereum.org/EIPS/eip-1363). +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. + + +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`](/contracts/5.x/api/utils#Pausable-_pause--) and [`Pausable._unpause`](/contracts/5.x/api/utils#Pausable-_unpause--) internal functions, with appropriate +access control, e.g. using [`AccessControl`](/contracts/5.x/api/access#AccessControl) or [`Ownable`](/contracts/5.x/api/access#Ownable). Not doing so will +make the contract pause mechanism of the contract unreachable, and thus unusable. +

Functions

-- [checkOnERC1363TransferReceived(operator, from, to, value, data)](#ERC1363Utils-checkOnERC1363TransferReceived-address-address-address-uint256-bytes-) -- [checkOnERC1363ApprovalReceived(operator, spender, value, data)](#ERC1363Utils-checkOnERC1363ApprovalReceived-address-address-uint256-bytes-) +- [_update(from, to, value)](#ERC20Pausable-_update-address-address-uint256-) +#### Pausable [!toc] +- [paused()](#Pausable-paused--) +- [_requireNotPaused()](#Pausable-_requireNotPaused--) +- [_requirePaused()](#Pausable-_requirePaused--) +- [_pause()](#Pausable-_pause--) +- [_unpause()](#Pausable-_unpause--) +#### ERC20 [!toc] +- [name()](#ERC20-name--) +- [symbol()](#ERC20-symbol--) +- [decimals()](#ERC20-decimals--) +- [totalSupply()](#ERC20-totalSupply--) +- [balanceOf(account)](#ERC20-balanceOf-address-) +- [transfer(to, value)](#ERC20-transfer-address-uint256-) +- [allowance(owner, spender)](#ERC20-allowance-address-address-) +- [approve(spender, value)](#ERC20-approve-address-uint256-) +- [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) +- [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) +- [_mint(account, value)](#ERC20-_mint-address-uint256-) +- [_burn(account, value)](#ERC20-_burn-address-uint256-) +- [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) +- [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) +- [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) +#### IERC20Errors [!toc] +#### IERC20Metadata [!toc] +#### IERC20 [!toc]
-

Errors

+

Events

-- [ERC1363InvalidReceiver(receiver)](#ERC1363Utils-ERC1363InvalidReceiver-address-) -- [ERC1363InvalidSpender(spender)](#ERC1363Utils-ERC1363InvalidSpender-address-) -
-
- - - -
-
-

checkOnERC1363TransferReceived(address operator, address from, address to, uint256 value, bytes data)

-
-

internal

-# +#### Pausable [!toc] +- [Paused(account)](#Pausable-Paused-address-) +- [Unpaused(account)](#Pausable-Unpaused-address-) +#### ERC20 [!toc] +#### IERC20Errors [!toc] +#### IERC20Metadata [!toc] +#### IERC20 [!toc] +- [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) +- [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-)
-
- -Performs a call to [`IERC1363Receiver.onTransferReceived`](../interfaces#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) on a target address. - -Requirements: - -- The target has code (i.e. is a contract). -- The target `to` must implement the [`IERC1363Receiver`](../interfaces#IERC1363Receiver) interface. -- The target must return the [`IERC1363Receiver.onTransferReceived`](../interfaces#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) selector to accept the transfer. +
+

Errors

+
+#### Pausable [!toc] +- [EnforcedPause()](#Pausable-EnforcedPause--) +- [ExpectedPause()](#Pausable-ExpectedPause--) +#### ERC20 [!toc] +#### IERC20Errors [!toc] +- [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) +- [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) +- [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) +- [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) +- [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) +- [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) +#### IERC20Metadata [!toc] +#### IERC20 [!toc]
- +
-

checkOnERC1363ApprovalReceived(address operator, address spender, uint256 value, bytes data)

+

_update(address from, address to, uint256 value)

internal

-# +#
-Performs a call to [`IERC1363Spender.onApprovalReceived`](../interfaces#IERC1363Spender-onApprovalReceived-address-uint256-bytes-) on a target address. +See [`ERC20._update`](#ERC20-_update-address-address-uint256-). Requirements: -- The target has code (i.e. is a contract). -- The target `spender` must implement the [`IERC1363Spender`](../interfaces#IERC1363Spender) interface. -- The target must return the [`IERC1363Spender.onApprovalReceived`](../interfaces#IERC1363Spender-onApprovalReceived-address-uint256-bytes-) selector to accept the approval. - -
-
- - - -
-
-

ERC1363InvalidReceiver(address receiver)

-
-

error

-# -
-
-
- -Indicates a failure with the token `receiver`. Used in transfers. - -
-
- - - -
-
-

ERC1363InvalidSpender(address spender)

-
-

error

-# -
-
-
- -Indicates a failure with the token `spender`. Used in approvals. +- the contract must not be paused.
- +
-## `SafeERC20` +## `ERC20Bridgeable` - +
```solidity -import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Bridgeable.sol"; ``` -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. - +ERC20 extension that implements the standard token interface according to +[ERC-7802](https://eips.ethereum.org/EIPS/eip-7802). +
-

Functions

+

Modifiers

-- [safeTransfer(token, to, value)](#SafeERC20-safeTransfer-contract-IERC20-address-uint256-) -- [safeTransferFrom(token, from, to, value)](#SafeERC20-safeTransferFrom-contract-IERC20-address-address-uint256-) -- [trySafeTransfer(token, to, value)](#SafeERC20-trySafeTransfer-contract-IERC20-address-uint256-) -- [trySafeTransferFrom(token, from, to, value)](#SafeERC20-trySafeTransferFrom-contract-IERC20-address-address-uint256-) -- [safeIncreaseAllowance(token, spender, value)](#SafeERC20-safeIncreaseAllowance-contract-IERC20-address-uint256-) -- [safeDecreaseAllowance(token, spender, requestedDecrease)](#SafeERC20-safeDecreaseAllowance-contract-IERC20-address-uint256-) -- [forceApprove(token, spender, value)](#SafeERC20-forceApprove-contract-IERC20-address-uint256-) -- [transferAndCallRelaxed(token, to, value, data)](#SafeERC20-transferAndCallRelaxed-contract-IERC1363-address-uint256-bytes-) -- [transferFromAndCallRelaxed(token, from, to, value, data)](#SafeERC20-transferFromAndCallRelaxed-contract-IERC1363-address-address-uint256-bytes-) -- [approveAndCallRelaxed(token, to, value, data)](#SafeERC20-approveAndCallRelaxed-contract-IERC1363-address-uint256-bytes-) +- [onlyTokenBridge()](#ERC20Bridgeable-onlyTokenBridge--)
-

Errors

+

Functions

-- [SafeERC20FailedOperation(token)](#SafeERC20-SafeERC20FailedOperation-address-) -- [SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease)](#SafeERC20-SafeERC20FailedDecreaseAllowance-address-uint256-uint256-) +- [supportsInterface(interfaceId)](#ERC20Bridgeable-supportsInterface-bytes4-) +- [crosschainMint(to, value)](#ERC20Bridgeable-crosschainMint-address-uint256-) +- [crosschainBurn(from, value)](#ERC20Bridgeable-crosschainBurn-address-uint256-) +- [_checkTokenBridge(caller)](#ERC20Bridgeable-_checkTokenBridge-address-) +#### IERC7802 [!toc] +#### ERC165 [!toc] +#### IERC165 [!toc] +#### ERC20 [!toc] +- [name()](#ERC20-name--) +- [symbol()](#ERC20-symbol--) +- [decimals()](#ERC20-decimals--) +- [totalSupply()](#ERC20-totalSupply--) +- [balanceOf(account)](#ERC20-balanceOf-address-) +- [transfer(to, value)](#ERC20-transfer-address-uint256-) +- [allowance(owner, spender)](#ERC20-allowance-address-address-) +- [approve(spender, value)](#ERC20-approve-address-uint256-) +- [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) +- [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) +- [_update(from, to, value)](#ERC20-_update-address-address-uint256-) +- [_mint(account, value)](#ERC20-_mint-address-uint256-) +- [_burn(account, value)](#ERC20-_burn-address-uint256-) +- [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) +- [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) +- [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) +#### IERC20Errors [!toc] +#### IERC20Metadata [!toc] +#### IERC20 [!toc]
- - -
-
-

safeTransfer(contract IERC20 token, address to, uint256 value)

-
-

internal

-# +
+

Events

+
+#### IERC7802 [!toc] +- [CrosschainMint(to, amount, sender)](#IERC7802-CrosschainMint-address-uint256-address-) +- [CrosschainBurn(from, amount, sender)](#IERC7802-CrosschainBurn-address-uint256-address-) +#### ERC165 [!toc] +#### IERC165 [!toc] +#### ERC20 [!toc] +#### IERC20Errors [!toc] +#### IERC20Metadata [!toc] +#### IERC20 [!toc] +- [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) +- [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-)
-
- -Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, -non-reverting calls are assumed to be successful. +
+

Errors

+
+#### IERC7802 [!toc] +#### ERC165 [!toc] +#### IERC165 [!toc] +#### ERC20 [!toc] +#### IERC20Errors [!toc] +- [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) +- [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) +- [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) +- [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) +- [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) +- [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) +#### IERC20Metadata [!toc] +#### IERC20 [!toc]
- +
-

safeTransferFrom(contract IERC20 token, address from, address to, uint256 value)

+

onlyTokenBridge()

internal

-# +#
+
-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. +Modifier to restrict access to the token bridge.
- +
-

trySafeTransfer(contract IERC20 token, address to, uint256 value) → bool

+

supportsInterface(bytes4 interfaceId) → bool

-

internal

-# +

public

+#
-Variant of [`SafeERC20.safeTransfer`](#SafeERC20-safeTransfer-contract-IERC20-address-uint256-) that returns a bool instead of reverting if the operation is not successful. +Returns true if this contract implements the interface defined by +`interfaceId`. See the corresponding +[ERC section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) +to learn more about how these ids are created. + +This function call must use less than 30 000 gas.
- +
-

trySafeTransferFrom(contract IERC20 token, address from, address to, uint256 value) → bool

+

crosschainMint(address to, uint256 value)

-

internal

-# +

public

+#
-Variant of [`ERC1155.safeTransferFrom`](/contracts/5.x/api/token/ERC1155#ERC1155-safeTransferFrom-address-address-uint256-uint256-bytes-) that returns a bool instead of reverting if the operation is not successful. +See [`IERC7802.crosschainMint`](/contracts/5.x/api/interfaces#IERC7802-crosschainMint-address-uint256-). Emits a [`IERC7802.CrosschainMint`](/contracts/5.x/api/interfaces#IERC7802-CrosschainMint-address-uint256-address-) event.
- +
-

safeIncreaseAllowance(contract IERC20 token, address spender, uint256 value)

+

crosschainBurn(address from, uint256 value)

-

internal

-# +

public

+#
-Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, -non-reverting calls are assumed to be successful. - - -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 [`SafeERC20.safeIncreaseAllowance`](#SafeERC20-safeIncreaseAllowance-contract-IERC20-address-uint256-) or [`SafeERC20.safeDecreaseAllowance`](#SafeERC20-safeDecreaseAllowance-contract-IERC20-address-uint256-) operation on a token contract -that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior. - +See [`IERC7802.crosschainBurn`](/contracts/5.x/api/interfaces#IERC7802-crosschainBurn-address-uint256-). Emits a [`IERC7802.CrosschainBurn`](/contracts/5.x/api/interfaces#IERC7802-CrosschainBurn-address-uint256-address-) event.
- +
-

safeDecreaseAllowance(contract IERC20 token, address spender, uint256 requestedDecrease)

+

_checkTokenBridge(address caller)

internal

-# +#
-Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no -value, non-reverting calls are assumed to be successful. +Checks if the caller is a trusted token bridge. MUST revert otherwise. - -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 [`SafeERC20.safeIncreaseAllowance`](#SafeERC20-safeIncreaseAllowance-contract-IERC20-address-uint256-) or [`SafeERC20.safeDecreaseAllowance`](#SafeERC20-safeDecreaseAllowance-contract-IERC20-address-uint256-) operation on a token contract -that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior. - +Developers should implement this function using an access control mechanism that allows +customizing the list of allowed senders. Consider using [`AccessControl`](/contracts/5.x/api/access#AccessControl) or [`AccessManaged`](/contracts/5.x/api/access#AccessManaged).
- + -
-
-

forceApprove(contract IERC20 token, address spender, uint256 value)

-
-

internal

-# -
-
-
+
-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. +## `ERC1363Utils` - -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. - + + + -
- +```solidity +import "@openzeppelin/contracts/token/ERC20/utils/ERC1363Utils.sol"; +``` -
-
-

transferAndCallRelaxed(contract IERC1363 token, address to, uint256 value, bytes data)

-
-

internal

-# -
-
-
+Library that provides common ERC-1363 utility functions. -Performs an [`ERC1363`](#ERC1363) transferAndCall, with a fallback to the simple [`ERC20`](#ERC20) transfer if the target has no -code. This can be used to implement an [`ERC721`](/contracts/5.x/api/token/ERC721#ERC721)-like safe transfer that relies on [`ERC1363`](#ERC1363) checks when -targeting contracts. +See [ERC-1363](https://eips.ethereum.org/EIPS/eip-1363). -Reverts if the returned value is other than `true`. +
+

Functions

+
+- [checkOnERC1363TransferReceived(operator, from, to, value, data)](#ERC1363Utils-checkOnERC1363TransferReceived-address-address-address-uint256-bytes-) +- [checkOnERC1363ApprovalReceived(operator, spender, value, data)](#ERC1363Utils-checkOnERC1363ApprovalReceived-address-address-uint256-bytes-) +
+
+
+

Errors

+
+- [ERC1363InvalidReceiver(receiver)](#ERC1363Utils-ERC1363InvalidReceiver-address-) +- [ERC1363InvalidSpender(spender)](#ERC1363Utils-ERC1363InvalidSpender-address-)
- +
-

transferFromAndCallRelaxed(contract IERC1363 token, address from, address to, uint256 value, bytes data)

+

checkOnERC1363TransferReceived(address operator, address from, address to, uint256 value, bytes data)

internal

-# +#
-Performs an [`ERC1363`](#ERC1363) transferFromAndCall, with a fallback to the simple [`ERC20`](#ERC20) transferFrom if the target -has no code. This can be used to implement an [`ERC721`](/contracts/5.x/api/token/ERC721#ERC721)-like safe transfer that relies on [`ERC1363`](#ERC1363) checks when -targeting contracts. +Performs a call to [`IERC1363Receiver.onTransferReceived`](/contracts/5.x/api/interfaces#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) on a target address. -Reverts if the returned value is other than `true`. +Requirements: + +- The target has code (i.e. is a contract). +- The target `to` must implement the [`IERC1363Receiver`](/contracts/5.x/api/interfaces#IERC1363Receiver) interface. +- The target must return the [`IERC1363Receiver.onTransferReceived`](/contracts/5.x/api/interfaces#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) selector to accept the transfer.
- +
-

approveAndCallRelaxed(contract IERC1363 token, address to, uint256 value, bytes data)

+

checkOnERC1363ApprovalReceived(address operator, address spender, uint256 value, bytes data)

internal

-# +#
-Performs an [`ERC1363`](#ERC1363) approveAndCall, with a fallback to the simple [`ERC20`](#ERC20) approve if the target has no -code. This can be used to implement an [`ERC721`](/contracts/5.x/api/token/ERC721#ERC721)-like safe transfer that rely on [`ERC1363`](#ERC1363) checks when -targeting contracts. +Performs a call to [`IERC1363Spender.onApprovalReceived`](/contracts/5.x/api/interfaces#IERC1363Spender-onApprovalReceived-address-uint256-bytes-) on a target address. - -When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as [`SafeERC20.forceApprove`](#SafeERC20-forceApprove-contract-IERC20-address-uint256-). -Oppositely, when the recipient address (`to`) has code, this function only attempts to call [`ERC1363.approveAndCall`](#ERC1363-approveAndCall-address-uint256-bytes-) -once without retrying, and relies on the returned value to be true. - +Requirements: -Reverts if the returned value is other than `true`. +- The target has code (i.e. is a contract). +- The target `spender` must implement the [`IERC1363Spender`](/contracts/5.x/api/interfaces#IERC1363Spender) interface. +- The target must return the [`IERC1363Spender.onApprovalReceived`](/contracts/5.x/api/interfaces#IERC1363Spender-onApprovalReceived-address-uint256-bytes-) selector to accept the approval.
- +
-

SafeERC20FailedOperation(address token)

+

ERC1363InvalidReceiver(address receiver)

error

-# +#
-An operation with an ERC-20 token failed. +Indicates a failure with the token `receiver`. Used in transfers.
- +
-

SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease)

+

ERC1363InvalidSpender(address spender)

error

-# +#
-Indicates a failed `decreaseAllowance` request. +Indicates a failure with the token `spender`. Used in approvals.
+ diff --git a/content/contracts/5.x/api/token/ERC6909.mdx b/content/contracts/5.x/api/token/ERC6909.mdx index 5430787f..c0272555 100644 --- a/content/contracts/5.x/api/token/ERC6909.mdx +++ b/content/contracts/5.x/api/token/ERC6909.mdx @@ -7,10 +7,10 @@ This set of interfaces and contracts are all related to the [ERC-6909 Minimal Mu The ERC consists of four interfaces which fulfill different roles--the interfaces are as follows: -1. [`IERC6909`](../interfaces#IERC6909): Base interface for a vanilla ERC6909 token. -2. [`IERC6909ContentURI`](../interfaces#IERC6909ContentURI): Extends the base interface and adds content URI (contract and token level) functionality. -3. [`IERC6909Metadata`](../interfaces#IERC6909Metadata): Extends the base interface and adds metadata functionality, which exposes a name, symbol, and decimals for each token id. -4. [`IERC6909TokenSupply`](../interfaces#IERC6909TokenSupply): Extends the base interface and adds total supply functionality for each token id. +1. [`IERC6909`](/contracts/5.x/api/interfaces#IERC6909): Base interface for a vanilla ERC6909 token. +2. [`IERC6909ContentURI`](/contracts/5.x/api/interfaces#IERC6909ContentURI): Extends the base interface and adds content URI (contract and token level) functionality. +3. [`IERC6909Metadata`](/contracts/5.x/api/interfaces#IERC6909Metadata): Extends the base interface and adds metadata functionality, which exposes a name, symbol, and decimals for each token id. +4. [`IERC6909TokenSupply`](/contracts/5.x/api/interfaces#IERC6909TokenSupply): Extends the base interface and adds total supply functionality for each token id. Implementations are provided for each of the 4 interfaces defined in the ERC. @@ -30,9 +30,9 @@ Implementations are provided for each of the 4 interfaces defined in the ERC.
-## `ERC6909` +## `ERC6909` - + @@ -265,10 +265,10 @@ Must return true. Creates `amount` of token `id` and assigns them to `account`, by transferring it from address(0). Relies on the `_update` mechanism. -Emits a [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event with `from` set to the zero address. +Emits a [`IERC6909.Transfer`](/contracts/5.x/api/interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event with `from` set to the zero address. -This function is not virtual, [`ERC1155._update`](/contracts/5.x/api/token/ERC1155#ERC1155-_update-address-address-uint256---uint256---) should be overridden instead. +This function is not virtual, [`ERC6909._update`](#ERC6909-_update-address-address-uint256-uint256-) should be overridden instead.
@@ -290,10 +290,10 @@ Moves `amount` of token `id` from `from` to `to` without checking for approvals. 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 [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event. +Emits a [`IERC6909.Transfer`](/contracts/5.x/api/interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event. -This function is not virtual, [`ERC1155._update`](/contracts/5.x/api/token/ERC1155#ERC1155-_update-address-address-uint256---uint256---) should be overridden instead. +This function is not virtual, [`ERC6909._update`](#ERC6909-_update-address-address-uint256-uint256-) should be overridden instead.
@@ -314,10 +314,10 @@ This function is not virtual, [`ERC1155._update`](/contracts/5.x/api/token/ERC11 Destroys a `amount` of token `id` from `account`. Relies on the `_update` mechanism. -Emits a [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event with `to` set to the zero address. +Emits a [`IERC6909.Transfer`](/contracts/5.x/api/interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event with `to` set to the zero address. -This function is not virtual, [`ERC1155._update`](/contracts/5.x/api/token/ERC1155#ERC1155-_update-address-address-uint256---uint256---) should be overridden instead +This function is not virtual, [`ERC6909._update`](#ERC6909-_update-address-address-uint256-uint256-) should be overridden instead
@@ -339,7 +339,7 @@ Transfers `amount` of token `id` from `from` to `to`, or alternatively mints (or (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding this function. -Emits a [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event. +Emits a [`IERC6909.Transfer`](/contracts/5.x/api/interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event.
@@ -361,7 +361,7 @@ 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 [`IERC6909.Approval`](../interfaces#IERC6909-Approval-address-address-uint256-uint256-) event. +Emits an [`IERC6909.Approval`](/contracts/5.x/api/interfaces#IERC6909-Approval-address-address-uint256-uint256-) event. Requirements: @@ -388,7 +388,7 @@ 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 [`IERC6909.OperatorSet`](../interfaces#IERC6909-OperatorSet-address-address-bool-) event. +Emits an [`IERC6909.OperatorSet`](/contracts/5.x/api/interfaces#IERC6909-OperatorSet-address-address-bool-) event. Requirements: @@ -415,7 +415,7 @@ 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 [`IERC6909.Approval`](../interfaces#IERC6909-Approval-address-address-uint256-uint256-) event. +Does not emit an [`IERC6909.Approval`](/contracts/5.x/api/interfaces#IERC6909-Approval-address-address-uint256-uint256-) event.
@@ -514,9 +514,9 @@ Does not emit an [`IERC6909.Approval`](../interfaces#IERC6909-Approval-address-a
-## `ERC6909ContentURI` +## `ERC6909ContentURI` - + @@ -531,13 +531,13 @@ Implementation of the Content URI extension defined in ERC6909.

Functions

+- [supportsInterface(interfaceId)](#ERC6909ContentURI-supportsInterface-bytes4-) - [contractURI()](#ERC6909ContentURI-contractURI--) - [tokenURI(id)](#ERC6909ContentURI-tokenURI-uint256-) - [_setContractURI(newContractURI)](#ERC6909ContentURI-_setContractURI-string-) - [_setTokenURI(id, newTokenURI)](#ERC6909ContentURI-_setTokenURI-uint256-string-) #### IERC6909ContentURI [!toc] #### ERC6909 [!toc] -- [supportsInterface(interfaceId)](#ERC6909-supportsInterface-bytes4-) - [balanceOf(owner, id)](#ERC6909-balanceOf-address-uint256-) - [allowance(owner, spender, id)](#ERC6909-allowance-address-address-uint256-) - [isOperator(owner, spender)](#ERC6909-isOperator-address-address-) @@ -591,6 +591,28 @@ Implementation of the Content URI extension defined in ERC6909.
+ + +
+
+

supportsInterface(bytes4 interfaceId) → bool

+
+

public

+# +
+
+
+ +Returns true if this contract implements the interface defined by +`interfaceId`. See the corresponding +[ERC section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) +to learn more about how these ids are created. + +This function call must use less than 30 000 gas. + +
+
+
@@ -637,7 +659,7 @@ Returns the URI for the token of type `id`.
-Sets the [`IERC6909ContentURI.contractURI`](../interfaces#IERC6909ContentURI-contractURI--) for the contract. +Sets the [`ERC6909ContentURI.contractURI`](#ERC6909ContentURI-contractURI--) for the contract. Emits a [`ERC6909ContentURI.ContractURIUpdated`](#ERC6909ContentURI-ContractURIUpdated--) event. @@ -656,9 +678,9 @@ Emits a [`ERC6909ContentURI.ContractURIUpdated`](#ERC6909ContentURI-ContractURIU
-Sets the [`IERC6909ContentURI.tokenURI`](../interfaces#IERC6909ContentURI-tokenURI-uint256-) for a given token of type `id`. +Sets the [`ERC6909ContentURI.tokenURI`](#ERC6909ContentURI-tokenURI-uint256-) for a given token of type `id`. -Emits a [`IERC1155.URI`](/contracts/5.x/api/token/ERC1155#IERC1155-URI-string-uint256-) event. +Emits a [`ERC6909ContentURI.URI`](#ERC6909ContentURI-URI-string-uint256-) event.
@@ -702,9 +724,9 @@ See [`IERC1155.URI`](/contracts/5.x/api/token/ERC1155#IERC1155-URI-string-uint25
-## `ERC6909Metadata` +## `ERC6909Metadata` - + @@ -722,12 +744,12 @@ Implementation of the Metadata extension defined in ERC6909. Exposes the name, s - [name(id)](#ERC6909Metadata-name-uint256-) - [symbol(id)](#ERC6909Metadata-symbol-uint256-) - [decimals(id)](#ERC6909Metadata-decimals-uint256-) +- [supportsInterface(interfaceId)](#ERC6909Metadata-supportsInterface-bytes4-) - [_setName(id, newName)](#ERC6909Metadata-_setName-uint256-string-) - [_setSymbol(id, newSymbol)](#ERC6909Metadata-_setSymbol-uint256-string-) - [_setDecimals(id, newDecimals)](#ERC6909Metadata-_setDecimals-uint256-uint8-) #### IERC6909Metadata [!toc] #### ERC6909 [!toc] -- [supportsInterface(interfaceId)](#ERC6909-supportsInterface-bytes4-) - [balanceOf(owner, id)](#ERC6909-balanceOf-address-uint256-) - [allowance(owner, spender, id)](#ERC6909-allowance-address-address-uint256-) - [isOperator(owner, spender)](#ERC6909-isOperator-address-address-) @@ -833,6 +855,28 @@ Returns the number of decimals for the token of type `id`.
+ + +
+
+

supportsInterface(bytes4 interfaceId) → bool

+
+

public

+# +
+
+
+ +Returns true if this contract implements the interface defined by +`interfaceId`. See the corresponding +[ERC section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) +to learn more about how these ids are created. + +This function call must use less than 30 000 gas. + +
+
+
@@ -946,9 +990,9 @@ The decimals value for token of type `id` was updated to `newDecimals`.
-## `ERC6909TokenSupply` +## `ERC6909TokenSupply` - + @@ -965,10 +1009,10 @@ Tracks the total supply of each token id individually.

Functions

- [totalSupply(id)](#ERC6909TokenSupply-totalSupply-uint256-) +- [supportsInterface(interfaceId)](#ERC6909TokenSupply-supportsInterface-bytes4-) - [_update(from, to, id, amount)](#ERC6909TokenSupply-_update-address-address-uint256-uint256-) #### IERC6909TokenSupply [!toc] #### ERC6909 [!toc] -- [supportsInterface(interfaceId)](#ERC6909-supportsInterface-bytes4-) - [balanceOf(owner, id)](#ERC6909-balanceOf-address-uint256-) - [allowance(owner, spender, id)](#ERC6909-allowance-address-address-uint256-) - [isOperator(owner, spender)](#ERC6909-isOperator-address-address-) @@ -1036,6 +1080,28 @@ Returns the total supply of the token of type `id`.
+ + +
+
+

supportsInterface(bytes4 interfaceId) → bool

+
+

public

+# +
+
+
+ +Returns true if this contract implements the interface defined by +`interfaceId`. See the corresponding +[ERC section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) +to learn more about how these ids are created. + +This function call must use less than 30 000 gas. + +
+
+
@@ -1052,3 +1118,4 @@ Override the `_update` function to update the total supply of each token id as n
+ diff --git a/content/contracts/5.x/api/token/ERC721.mdx b/content/contracts/5.x/api/token/ERC721.mdx index 72f8829e..feb48797 100644 --- a/content/contracts/5.x/api/token/ERC721.mdx +++ b/content/contracts/5.x/api/token/ERC721.mdx @@ -24,12 +24,13 @@ OpenZeppelin Contracts provides implementations of all four interfaces: Additionally there are a few of other extensions: +* [`ERC721Burnable`](#ERC721Burnable): A way for token holders to burn their own tokens. * [`ERC721Consecutive`](#ERC721Consecutive): An implementation of [ERC-2309](https://eips.ethereum.org/EIPS/eip-2309) for minting batches of tokens during construction, in accordance with ERC-721. +* [`ERC721Crosschain`](#ERC721Crosschain): Embedded [`BridgeNonFungible`](/contracts/5.x/api/crosschain#BridgeNonFungible) bridge, making the token crosschain through the use of ERC-7786 gateways. +* [`ERC721Pausable`](#ERC721Pausable): A primitive to pause contract operation. +* [`ERC721Royalty`](#ERC721Royalty): A way to signal royalty information following ERC-2981. * [`ERC721URIStorage`](#ERC721URIStorage): A more flexible but more expensive way of storing metadata. * [`ERC721Votes`](#ERC721Votes): Support for voting and vote delegation. -* [`ERC721Royalty`](#ERC721Royalty): A way to signal royalty information following ERC-2981. -* [`ERC721Pausable`](#ERC721Pausable): A primitive to pause contract operation. -* [`ERC721Burnable`](#ERC721Burnable): A way for token holders to burn their own tokens. * [`ERC721Wrapper`](#ERC721Wrapper): Wrapper to create an ERC-721 backed by another ERC-721, with deposit and withdraw methods. Useful in conjunction with [`ERC721Votes`](#ERC721Votes). @@ -52,18 +53,20 @@ This core set of contracts is designed to be unopinionated, allowing developers ## Extensions -[`ERC721Pausable`](#ERC721Pausable) - [`ERC721Burnable`](#ERC721Burnable) [`ERC721Consecutive`](#ERC721Consecutive) -[`ERC721URIStorage`](#ERC721URIStorage) +[`ERC721Crosschain`](#ERC721Crosschain) -[`ERC721Votes`](#ERC721Votes) +[`ERC721Pausable`](#ERC721Pausable) [`ERC721Royalty`](#ERC721Royalty) +[`ERC721URIStorage`](#ERC721URIStorage) + +[`ERC721Votes`](#ERC721Votes) + [`ERC721Wrapper`](#ERC721Wrapper) ## Utilities @@ -76,9 +79,9 @@ This core set of contracts is designed to be unopinionated, allowing developers
-## `ERC721` +## `ERC721` - + @@ -308,7 +311,7 @@ Returns the Uniform Resource Identifier (URI) for `tokenId` token.
-Base URI for computing [`IERC6909ContentURI.tokenURI`](../interfaces#IERC6909ContentURI-tokenURI-uint256-). If set, the resulting URI for each +Base URI for computing [`ERC721.tokenURI`](#ERC721-tokenURI-uint256-). 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. @@ -337,7 +340,7 @@ Requirements: - The caller must own the token or be an approved operator. - `tokenId` must exist. -Emits an [`IERC6909.Approval`](../interfaces#IERC6909-Approval-address-address-uint256-uint256-) event. +Emits an [`IERC721.Approval`](#IERC721-Approval-address-address-uint256-) event.
@@ -376,13 +379,13 @@ Requirements:
Approve or remove `operator` as an operator for the caller. -Operators can call [`IERC6909.transferFrom`](../interfaces#IERC6909-transferFrom-address-address-uint256-uint256-) or [`ERC1155.safeTransferFrom`](/contracts/5.x/api/token/ERC1155#ERC1155-safeTransferFrom-address-address-uint256-uint256-bytes-) for any token owned by the caller. +Operators can call [`ERC721.transferFrom`](#ERC721-transferFrom-address-address-uint256-) or [`ERC721.safeTransferFrom`](#ERC721-safeTransferFrom-address-address-uint256-bytes-) for any token owned by the caller. Requirements: - The `operator` cannot be the address zero. -Emits an [`IERC1155.ApprovalForAll`](/contracts/5.x/api/token/ERC1155#IERC1155-ApprovalForAll-address-address-bool-) event. +Emits an [`IERC721.ApprovalForAll`](#IERC721-ApprovalForAll-address-address-bool-) event.
@@ -401,7 +404,7 @@ Emits an [`IERC1155.ApprovalForAll`](/contracts/5.x/api/token/ERC1155#IERC1155-A Returns if the `operator` is allowed to manage all of the assets of `owner`. -See [`ERC1155.setApprovalForAll`](/contracts/5.x/api/token/ERC1155#ERC1155-setApprovalForAll-address-bool-) +See [`ERC721.setApprovalForAll`](#ERC721-setApprovalForAll-address-bool-)
@@ -422,7 +425,7 @@ Transfers `tokenId` token from `from` to `to`. 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 [`ERC1155.safeTransferFrom`](/contracts/5.x/api/token/ERC1155#ERC1155-safeTransferFrom-address-address-uint256-uint256-bytes-) prevents loss, though the caller must +or else they may be permanently lost. Usage of [`ERC721.safeTransferFrom`](#ERC721-safeTransferFrom-address-address-uint256-bytes-) prevents loss, though the caller must understand this adds an external call which potentially creates a reentrancy vulnerability. @@ -431,9 +434,9 @@ Requirements: - `from` cannot be the zero address. - `to` cannot be the zero address. - `tokenId` token must be owned by `from`. -- If the caller is not `from`, it must be approved to move this token by either [`IERC6909.approve`](../interfaces#IERC6909-approve-address-uint256-uint256-) or [`ERC1155.setApprovalForAll`](/contracts/5.x/api/token/ERC1155#ERC1155-setApprovalForAll-address-bool-). +- If the caller is not `from`, it must be approved to move this token by either [`ERC721.approve`](#ERC721-approve-address-uint256-) or [`ERC721.setApprovalForAll`](#ERC721-setApprovalForAll-address-bool-). -Emits a [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event. +Emits a [`IERC721.Transfer`](#IERC721-Transfer-address-address-uint256-) event.
@@ -458,12 +461,12 @@ Requirements: - `from` cannot be the zero address. - `to` cannot be the zero address. - `tokenId` token must exist and be owned by `from`. -- If the caller is not `from`, it must have been allowed to move this token by either [`IERC6909.approve`](../interfaces#IERC6909-approve-address-uint256-uint256-) or - [`ERC1155.setApprovalForAll`](/contracts/5.x/api/token/ERC1155#ERC1155-setApprovalForAll-address-bool-). +- If the caller is not `from`, it must have been allowed to move this token by either [`ERC721.approve`](#ERC721-approve-address-uint256-) or + [`ERC721.setApprovalForAll`](#ERC721-setApprovalForAll-address-bool-). - If `to` refers to a smart contract, it must implement [`IERC721Receiver.onERC721Received`](#IERC721Receiver-onERC721Received-address-address-uint256-bytes-), which is called upon a safe transfer. -Emits a [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event. +Emits a [`IERC721.Transfer`](#IERC721-Transfer-address-address-uint256-) event.
@@ -487,11 +490,11 @@ Requirements: - `from` cannot be the zero address. - `to` cannot be the zero address. - `tokenId` token must exist and be owned by `from`. -- If the caller is not `from`, it must be approved to move this token by either [`IERC6909.approve`](../interfaces#IERC6909-approve-address-uint256-uint256-) or [`ERC1155.setApprovalForAll`](/contracts/5.x/api/token/ERC1155#ERC1155-setApprovalForAll-address-bool-). +- If the caller is not `from`, it must be approved to move this token by either [`ERC721.approve`](#ERC721-approve-address-uint256-) or [`ERC721.setApprovalForAll`](#ERC721-setApprovalForAll-address-bool-). - If `to` refers to a smart contract, it must implement [`IERC721Receiver.onERC721Received`](#IERC721Receiver-onERC721Received-address-address-uint256-bytes-), which is called upon a safe transfer. -Emits a [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event. +Emits a [`IERC721.Transfer`](#IERC721-Transfer-address-address-uint256-) event.
@@ -631,7 +634,7 @@ Transfers `tokenId` from its current owner to `to`, or alternatively mints (or b 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 [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event. +Emits a [`IERC721.Transfer`](#IERC721-Transfer-address-address-uint256-) event. If overriding this function in a way that tracks balances, see also [`ERC721._increaseBalance`](#ERC721-_increaseBalance-address-uint128-). @@ -663,7 +666,7 @@ Requirements: - `tokenId` must not exist. - `to` cannot be the zero address. -Emits a [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event. +Emits a [`IERC721.Transfer`](#IERC721-Transfer-address-address-uint256-) event.
@@ -687,7 +690,7 @@ Requirements: - `tokenId` must not exist. - If `to` refers to a smart contract, it must implement [`IERC721Receiver.onERC721Received`](#IERC721Receiver-onERC721Received-address-address-uint256-bytes-), which is called upon a safe transfer. -Emits a [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event. +Emits a [`IERC721.Transfer`](#IERC721-Transfer-address-address-uint256-) event.
@@ -730,7 +733,7 @@ Requirements: - `tokenId` must exist. -Emits a [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event. +Emits a [`IERC721.Transfer`](#IERC721-Transfer-address-address-uint256-) event.
@@ -748,14 +751,14 @@ Emits a [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-ad
Transfers `tokenId` from `from` to `to`. - As opposed to [`IERC6909.transferFrom`](../interfaces#IERC6909-transferFrom-address-address-uint256-uint256-), this imposes no restrictions on msg.sender. + As opposed to [`ERC721.transferFrom`](#ERC721-transferFrom-address-address-uint256-), this imposes no restrictions on msg.sender. Requirements: - `to` cannot be the zero address. - `tokenId` token must be owned by `from`. -Emits a [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event. +Emits a [`IERC721.Transfer`](#IERC721-Transfer-address-address-uint256-) event.
@@ -777,7 +780,7 @@ 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 [`ERC1155.safeTransferFrom`](/contracts/5.x/api/token/ERC1155#ERC1155-safeTransferFrom-address-address-uint256-uint256-bytes-) in the sense that it invokes +This internal function is like [`ERC721.safeTransferFrom`](#ERC721-safeTransferFrom-address-address-uint256-bytes-) in the sense that it invokes [`IERC721Receiver.onERC721Received`](#IERC721Receiver-onERC721Received-address-address-uint256-bytes-) on the receiver, and can be used to e.g. implement alternative mechanisms to perform token transfer, such as signature-based. @@ -788,7 +791,7 @@ Requirements: - `from` cannot be the zero address. - If `to` refers to a smart contract, it must implement [`IERC721Receiver.onERC721Received`](#IERC721Receiver-onERC721Received-address-address-uint256-bytes-), which is called upon a safe transfer. -Emits a [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event. +Emits a [`IERC721.Transfer`](#IERC721-Transfer-address-address-uint256-) event.
@@ -828,7 +831,7 @@ 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 [`IERC6909.Approval`](../interfaces#IERC6909-Approval-address-address-uint256-uint256-) event. +Emits an [`IERC721.Approval`](#IERC721-Approval-address-address-uint256-) event. Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument. @@ -847,7 +850,7 @@ Overrides to this logic should be done to the variant with an additional `bool e
-Variant of `_approve` with an optional flag to enable or disable the [`IERC6909.Approval`](../interfaces#IERC6909-Approval-address-address-uint256-uint256-) event. The event is not +Variant of `_approve` with an optional flag to enable or disable the [`IERC721.Approval`](#IERC721-Approval-address-address-uint256-) event. The event is not emitted in the context of transfers.
@@ -870,7 +873,7 @@ Approve `operator` to operate on all of `owner` tokens Requirements: - operator can't be the address zero. -Emits an [`IERC1155.ApprovalForAll`](/contracts/5.x/api/token/ERC1155#IERC1155-ApprovalForAll-address-address-bool-) event. +Emits an [`IERC721.ApprovalForAll`](#IERC721-ApprovalForAll-address-address-bool-) event.
@@ -899,9 +902,9 @@ Overrides to ownership logic should be done to [`ERC721._ownerOf`](#ERC721-_owne
-## `IERC721` +## `IERC721` - + @@ -997,11 +1000,11 @@ Requirements: - `from` cannot be the zero address. - `to` cannot be the zero address. - `tokenId` token must exist and be owned by `from`. -- If the caller is not `from`, it must be approved to move this token by either [`IERC6909.approve`](../interfaces#IERC6909-approve-address-uint256-uint256-) or [`ERC1155.setApprovalForAll`](/contracts/5.x/api/token/ERC1155#ERC1155-setApprovalForAll-address-bool-). +- If the caller is not `from`, it must be approved to move this token by either [`ERC721.approve`](#ERC721-approve-address-uint256-) or [`ERC721.setApprovalForAll`](#ERC721-setApprovalForAll-address-bool-). - If `to` refers to a smart contract, it must implement [`IERC721Receiver.onERC721Received`](#IERC721Receiver-onERC721Received-address-address-uint256-bytes-), which is called upon a safe transfer. -Emits a [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event. +Emits a [`IERC721.Transfer`](#IERC721-Transfer-address-address-uint256-) event.
@@ -1026,12 +1029,12 @@ Requirements: - `from` cannot be the zero address. - `to` cannot be the zero address. - `tokenId` token must exist and be owned by `from`. -- If the caller is not `from`, it must have been allowed to move this token by either [`IERC6909.approve`](../interfaces#IERC6909-approve-address-uint256-uint256-) or - [`ERC1155.setApprovalForAll`](/contracts/5.x/api/token/ERC1155#ERC1155-setApprovalForAll-address-bool-). +- If the caller is not `from`, it must have been allowed to move this token by either [`ERC721.approve`](#ERC721-approve-address-uint256-) or + [`ERC721.setApprovalForAll`](#ERC721-setApprovalForAll-address-bool-). - If `to` refers to a smart contract, it must implement [`IERC721Receiver.onERC721Received`](#IERC721Receiver-onERC721Received-address-address-uint256-bytes-), which is called upon a safe transfer. -Emits a [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event. +Emits a [`IERC721.Transfer`](#IERC721-Transfer-address-address-uint256-) event.
@@ -1052,7 +1055,7 @@ Transfers `tokenId` token from `from` to `to`. 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 [`ERC1155.safeTransferFrom`](/contracts/5.x/api/token/ERC1155#ERC1155-safeTransferFrom-address-address-uint256-uint256-bytes-) prevents loss, though the caller must +or else they may be permanently lost. Usage of [`ERC721.safeTransferFrom`](#ERC721-safeTransferFrom-address-address-uint256-bytes-) prevents loss, though the caller must understand this adds an external call which potentially creates a reentrancy vulnerability. @@ -1061,9 +1064,9 @@ Requirements: - `from` cannot be the zero address. - `to` cannot be the zero address. - `tokenId` token must be owned by `from`. -- If the caller is not `from`, it must be approved to move this token by either [`IERC6909.approve`](../interfaces#IERC6909-approve-address-uint256-uint256-) or [`ERC1155.setApprovalForAll`](/contracts/5.x/api/token/ERC1155#ERC1155-setApprovalForAll-address-bool-). +- If the caller is not `from`, it must be approved to move this token by either [`ERC721.approve`](#ERC721-approve-address-uint256-) or [`ERC721.setApprovalForAll`](#ERC721-setApprovalForAll-address-bool-). -Emits a [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event. +Emits a [`IERC721.Transfer`](#IERC721-Transfer-address-address-uint256-) event.
@@ -1090,7 +1093,7 @@ Requirements: - The caller must own the token or be an approved operator. - `tokenId` must exist. -Emits an [`IERC6909.Approval`](../interfaces#IERC6909-Approval-address-address-uint256-uint256-) event. +Emits an [`IERC721.Approval`](#IERC721-Approval-address-address-uint256-) event.
@@ -1108,13 +1111,13 @@ Emits an [`IERC6909.Approval`](../interfaces#IERC6909-Approval-address-address-u
Approve or remove `operator` as an operator for the caller. -Operators can call [`IERC6909.transferFrom`](../interfaces#IERC6909-transferFrom-address-address-uint256-uint256-) or [`ERC1155.safeTransferFrom`](/contracts/5.x/api/token/ERC1155#ERC1155-safeTransferFrom-address-address-uint256-uint256-bytes-) for any token owned by the caller. +Operators can call [`ERC721.transferFrom`](#ERC721-transferFrom-address-address-uint256-) or [`ERC721.safeTransferFrom`](#ERC721-safeTransferFrom-address-address-uint256-bytes-) for any token owned by the caller. Requirements: - The `operator` cannot be the address zero. -Emits an [`IERC1155.ApprovalForAll`](/contracts/5.x/api/token/ERC1155#IERC1155-ApprovalForAll-address-address-bool-) event. +Emits an [`IERC721.ApprovalForAll`](#IERC721-ApprovalForAll-address-address-bool-) event.
@@ -1154,7 +1157,7 @@ Requirements: Returns if the `operator` is allowed to manage all of the assets of `owner`. -See [`ERC1155.setApprovalForAll`](/contracts/5.x/api/token/ERC1155#ERC1155-setApprovalForAll-address-bool-) +See [`ERC721.setApprovalForAll`](#ERC721-setApprovalForAll-address-bool-)
@@ -1215,9 +1218,9 @@ Emitted when `owner` enables or disables (`approved`) `operator` to manage all o
-## `IERC721Receiver` +## `IERC721Receiver` - + @@ -1265,9 +1268,9 @@ The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.
-## `ERC721Burnable` +## `ERC721Burnable` - + @@ -1383,9 +1386,9 @@ Requirements:
-## `ERC721Consecutive` +## `ERC721Consecutive` - + @@ -1406,7 +1409,7 @@ Using this extension removes the ability to mint single tokens during contract c regained after construction. During construction, only batch minting is allowed. -This extension does not call the [`ERC1155._update`](/contracts/5.x/api/token/ERC1155#ERC1155-_update-address-address-uint256---uint256---) function for tokens minted in batch. Any logic added to this +This extension does not call the [`ERC721._update`](#ERC721-_update-address-uint256-address-) function for tokens minted in batch. Any logic added to this function through overrides will not be triggered when tokens are minted in batch. You may want to also override [`ERC721._increaseBalance`](#ERC721-_increaseBalance-address-uint128-) or [`ERC721Consecutive._mintConsecutive`](#ERC721Consecutive-_mintConsecutive-address-uint96-) to account for these mints. @@ -1568,12 +1571,16 @@ Requirements: - `batchSize` must not be greater than [`ERC721Consecutive._maxBatchSize`](#ERC721Consecutive-_maxBatchSize--). - The function is called in the constructor of the contract (directly or indirectly). -CAUTION: Does not emit a `Transfer` event. This is ERC-721 compliant as long as it is done inside of the + +Does not emit a `Transfer` event. This is ERC-721 compliant as long as it is done inside of the constructor, which is enforced by this function. + -CAUTION: Does not invoke `onERC721Received` on the receiver. + +Does not invoke `onERC721Received` on the receiver. + -Emits a [`IERC2309.ConsecutiveTransfer`](../interfaces#IERC2309-ConsecutiveTransfer-uint256-uint256-address-address-) event. +Emits a [`IERC2309.ConsecutiveTransfer`](/contracts/5.x/api/interfaces#IERC2309-ConsecutiveTransfer-uint256-uint256-address-address-) event.
@@ -1594,7 +1601,7 @@ See [`ERC721._update`](#ERC721-_update-address-uint256-address-). Override versi Using [`ERC721Consecutive`](#ERC721Consecutive) prevents minting during construction in favor of [`ERC721Consecutive._mintConsecutive`](#ERC721Consecutive-_mintConsecutive-address-uint96-). -After construction, [`ERC721Consecutive._mintConsecutive`](#ERC721Consecutive-_mintConsecutive-address-uint96-) is no longer available and minting through [`ERC1155._update`](/contracts/5.x/api/token/ERC1155#ERC1155-_update-address-address-uint256---uint256---) becomes available. +After construction, [`ERC721Consecutive._mintConsecutive`](#ERC721Consecutive-_mintConsecutive-address-uint96-) is no longer available and minting through [`ERC721._update`](#ERC721-_update-address-uint256-address-) becomes available.
@@ -1687,13 +1694,191 @@ Batch burn is not supported.
+ + +
+ +## `ERC721Crosschain` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Crosschain.sol"; +``` + +Extension of [`ERC721`](#ERC721) that makes it natively cross-chain using the ERC-7786 based [`BridgeNonFungible`](/contracts/5.x/api/crosschain#BridgeNonFungible). + +This extension makes the token compatible with: +* [`ERC721Crosschain`](#ERC721Crosschain) instances on other chains, +* [`ERC721`](#ERC721) instances on other chains that are bridged using [`BridgeERC721`](/contracts/5.x/api/crosschain#BridgeERC721), + +
+

Functions

+
+- [crosschainTransferFrom(from, to, tokenId)](#ERC721Crosschain-crosschainTransferFrom-address-bytes-uint256-) +- [_onSend(from, tokenId)](#ERC721Crosschain-_onSend-address-uint256-) +- [_onReceive(to, tokenId)](#ERC721Crosschain-_onReceive-address-uint256-) +#### BridgeNonFungible [!toc] +- [_crosschainTransfer(from, to, tokenId)](#BridgeNonFungible-_crosschainTransfer-address-bytes-uint256-) +- [_processMessage(, receiveId, , payload)](#BridgeNonFungible-_processMessage-address-bytes32-bytes-bytes-) +#### CrosschainLinked [!toc] +- [getLink(chain)](#CrosschainLinked-getLink-bytes-) +- [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) +- [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) +- [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) +#### ERC7786Recipient [!toc] +- [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) +#### IERC7786Recipient [!toc] +#### ERC721 [!toc] +- [supportsInterface(interfaceId)](#ERC721-supportsInterface-bytes4-) +- [balanceOf(owner)](#ERC721-balanceOf-address-) +- [ownerOf(tokenId)](#ERC721-ownerOf-uint256-) +- [name()](#ERC721-name--) +- [symbol()](#ERC721-symbol--) +- [tokenURI(tokenId)](#ERC721-tokenURI-uint256-) +- [_baseURI()](#ERC721-_baseURI--) +- [approve(to, tokenId)](#ERC721-approve-address-uint256-) +- [getApproved(tokenId)](#ERC721-getApproved-uint256-) +- [setApprovalForAll(operator, approved)](#ERC721-setApprovalForAll-address-bool-) +- [isApprovedForAll(owner, operator)](#ERC721-isApprovedForAll-address-address-) +- [transferFrom(from, to, tokenId)](#ERC721-transferFrom-address-address-uint256-) +- [safeTransferFrom(from, to, tokenId)](#ERC721-safeTransferFrom-address-address-uint256-) +- [safeTransferFrom(from, to, tokenId, data)](#ERC721-safeTransferFrom-address-address-uint256-bytes-) +- [_ownerOf(tokenId)](#ERC721-_ownerOf-uint256-) +- [_getApproved(tokenId)](#ERC721-_getApproved-uint256-) +- [_isAuthorized(owner, spender, tokenId)](#ERC721-_isAuthorized-address-address-uint256-) +- [_checkAuthorized(owner, spender, tokenId)](#ERC721-_checkAuthorized-address-address-uint256-) +- [_increaseBalance(account, value)](#ERC721-_increaseBalance-address-uint128-) +- [_update(to, tokenId, auth)](#ERC721-_update-address-uint256-address-) +- [_mint(to, tokenId)](#ERC721-_mint-address-uint256-) +- [_safeMint(to, tokenId)](#ERC721-_safeMint-address-uint256-) +- [_safeMint(to, tokenId, data)](#ERC721-_safeMint-address-uint256-bytes-) +- [_burn(tokenId)](#ERC721-_burn-uint256-) +- [_transfer(from, to, tokenId)](#ERC721-_transfer-address-address-uint256-) +- [_safeTransfer(from, to, tokenId)](#ERC721-_safeTransfer-address-address-uint256-) +- [_safeTransfer(from, to, tokenId, data)](#ERC721-_safeTransfer-address-address-uint256-bytes-) +- [_approve(to, tokenId, auth)](#ERC721-_approve-address-uint256-address-) +- [_approve(to, tokenId, auth, emitEvent)](#ERC721-_approve-address-uint256-address-bool-) +- [_setApprovalForAll(owner, operator, approved)](#ERC721-_setApprovalForAll-address-address-bool-) +- [_requireOwned(tokenId)](#ERC721-_requireOwned-uint256-) +#### IERC721Errors [!toc] +#### IERC721Metadata [!toc] +#### IERC721 [!toc] +#### ERC165 [!toc] +#### IERC165 [!toc] +
+
+ +
+

Events

+
+#### BridgeNonFungible [!toc] +- [CrosschainNonFungibleTransferSent(sendId, from, to, tokenId)](#BridgeNonFungible-CrosschainNonFungibleTransferSent-bytes32-address-bytes-uint256-) +- [CrosschainNonFungibleTransferReceived(receiveId, from, to, tokenId)](#BridgeNonFungible-CrosschainNonFungibleTransferReceived-bytes32-bytes-address-uint256-) +#### CrosschainLinked [!toc] +- [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) +#### ERC7786Recipient [!toc] +#### IERC7786Recipient [!toc] +#### ERC721 [!toc] +#### IERC721Errors [!toc] +#### IERC721Metadata [!toc] +#### IERC721 [!toc] +- [Transfer(from, to, tokenId)](#IERC721-Transfer-address-address-uint256-) +- [Approval(owner, approved, tokenId)](#IERC721-Approval-address-address-uint256-) +- [ApprovalForAll(owner, operator, approved)](#IERC721-ApprovalForAll-address-address-bool-) +#### ERC165 [!toc] +#### IERC165 [!toc] +
+
+ +
+

Errors

+
+#### BridgeNonFungible [!toc] +#### CrosschainLinked [!toc] +- [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) +#### ERC7786Recipient [!toc] +- [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) +#### IERC7786Recipient [!toc] +#### ERC721 [!toc] +#### IERC721Errors [!toc] +- [ERC721InvalidOwner(owner)](#IERC721Errors-ERC721InvalidOwner-address-) +- [ERC721NonexistentToken(tokenId)](#IERC721Errors-ERC721NonexistentToken-uint256-) +- [ERC721IncorrectOwner(sender, tokenId, owner)](#IERC721Errors-ERC721IncorrectOwner-address-uint256-address-) +- [ERC721InvalidSender(sender)](#IERC721Errors-ERC721InvalidSender-address-) +- [ERC721InvalidReceiver(receiver)](#IERC721Errors-ERC721InvalidReceiver-address-) +- [ERC721InsufficientApproval(operator, tokenId)](#IERC721Errors-ERC721InsufficientApproval-address-uint256-) +- [ERC721InvalidApprover(approver)](#IERC721Errors-ERC721InvalidApprover-address-) +- [ERC721InvalidOperator(operator)](#IERC721Errors-ERC721InvalidOperator-address-) +#### IERC721Metadata [!toc] +#### IERC721 [!toc] +#### ERC165 [!toc] +#### IERC165 [!toc] +
+
+ + + +
+
+

crosschainTransferFrom(address from, bytes to, uint256 tokenId) → bytes32

+
+

public

+# +
+
+
+ +Crosschain variant of [`ERC721.transferFrom`](#ERC721-transferFrom-address-address-uint256-), using the allowance system from the underlying ERC-721 token. + +
+
+ + + +
+
+

_onSend(address from, uint256 tokenId)

+
+

internal

+# +
+
+
+ +"Locking" tokens is achieved through burning + +
+
+ + + +
+
+

_onReceive(address to, uint256 tokenId)

+
+

internal

+# +
+
+
+ +"Unlocking" tokens is achieved through minting + +
+
+
-## `ERC721Enumerable` +## `ERC721Enumerable` - + @@ -1706,8 +1891,10 @@ import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; This implements an optional extension of [`ERC721`](#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`](#ERC721) extensions that implement custom `balanceOf` logic, such as [`ERC721Consecutive`](#ERC721Consecutive), + +[`ERC721`](#ERC721) extensions that implement custom `balanceOf` logic, such as [`ERC721Consecutive`](#ERC721Consecutive), interfere with enumerability and should not be used together with [`ERC721Enumerable`](#ERC721Enumerable). +

Functions

@@ -1830,7 +2017,7 @@ This function call must use less than 30 000 gas.
Returns a token ID owned by `owner` at a given `index` of its token list. -Use along with [`IERC6909.balanceOf`](../interfaces#IERC6909-balanceOf-address-uint256-) to enumerate all of ``owner``'s tokens. +Use along with [`ERC721.balanceOf`](#ERC721-balanceOf-address-) to enumerate all of ``owner``'s tokens.
@@ -1865,7 +2052,7 @@ Returns the total amount of tokens stored by the contract.
Returns a token ID at a given `index` of all the tokens stored by the contract. -Use along with [`IERC6909TokenSupply.totalSupply`](../interfaces#IERC6909TokenSupply-totalSupply-uint256-) to enumerate all tokens. +Use along with [`ERC721Enumerable.totalSupply`](#ERC721Enumerable-totalSupply--) to enumerate all tokens.
@@ -1888,7 +2075,7 @@ Transfers `tokenId` from its current owner to `to`, or alternatively mints (or b 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 [`IERC6909.Transfer`](../interfaces#IERC6909-Transfer-address-address-address-uint256-uint256-) event. +Emits a [`IERC721.Transfer`](#IERC721-Transfer-address-address-uint256-) event. If overriding this function in a way that tracks balances, see also [`ERC721._increaseBalance`](#ERC721-_increaseBalance-address-uint128-). @@ -1954,9 +2141,9 @@ Batch mint is not allowed.
-## `ERC721Pausable` +## `ERC721Pausable` - + @@ -1975,8 +2162,8 @@ event of a large bug. 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`](../utils#Pausable-_pause--) and [`Pausable._unpause`](../utils#Pausable-_unpause--) internal functions, with appropriate -access control, e.g. using [`AccessControl`](../access#AccessControl) or [`Ownable`](../access#Ownable). Not doing so will +[`Pausable._pause`](/contracts/5.x/api/utils#Pausable-_pause--) and [`Pausable._unpause`](/contracts/5.x/api/utils#Pausable-_unpause--) internal functions, with appropriate +access control, e.g. using [`AccessControl`](/contracts/5.x/api/access#AccessControl) or [`Ownable`](/contracts/5.x/api/access#Ownable). Not doing so will make the contract pause mechanism of the contract unreachable, and thus unusable. @@ -2095,9 +2282,9 @@ Requirements:
-## `ERC721Royalty` +## `ERC721Royalty` - + @@ -2232,9 +2419,9 @@ voluntarily pay royalties together with sales, but note that this standard is no
-## `ERC721URIStorage` +## `ERC721URIStorage` - + @@ -2252,6 +2439,7 @@ ERC-721 token with storage based token URI management. - [supportsInterface(interfaceId)](#ERC721URIStorage-supportsInterface-bytes4-) - [tokenURI(tokenId)](#ERC721URIStorage-tokenURI-uint256-) - [_setTokenURI(tokenId, _tokenURI)](#ERC721URIStorage-_setTokenURI-uint256-string-) +- [_suffixURI(tokenId)](#ERC721URIStorage-_suffixURI-uint256-) #### ERC721 [!toc] - [balanceOf(owner)](#ERC721-balanceOf-address-) - [ownerOf(tokenId)](#ERC721-ownerOf-uint256-) @@ -2381,7 +2569,24 @@ This function call must use less than 30 000 gas. Sets `_tokenURI` as the tokenURI of `tokenId`. -Emits [`IERC4906.MetadataUpdate`](../interfaces#IERC4906-MetadataUpdate-uint256-). +Emits [`IERC4906.MetadataUpdate`](/contracts/5.x/api/interfaces#IERC4906-MetadataUpdate-uint256-). + +
+
+ + + +
+
+

_suffixURI(uint256 tokenId) → string

+
+

internal

+# +
+
+
+ +Returns the suffix part of the tokenURI for `tokenId`.
@@ -2390,9 +2595,9 @@ Emits [`IERC4906.MetadataUpdate`](../interfaces#IERC4906-MetadataUpdate-uint256-
-## `ERC721Votes` +## `ERC721Votes` - + @@ -2402,7 +2607,7 @@ Emits [`IERC4906.MetadataUpdate`](../interfaces#IERC4906-MetadataUpdate-uint256- import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Votes.sol"; ``` -Extension of ERC-721 to support voting and delegation as implemented by [`Votes`](../governance#Votes), where each individual NFT counts +Extension of ERC-721 to support voting and delegation as implemented by [`Votes`](/contracts/5.x/api/governance#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 @@ -2553,7 +2758,7 @@ the votes in governance decisions, or they can delegate to themselves to be thei See [`ERC721._update`](#ERC721-_update-address-uint256-address-). Adjusts votes when tokens are transferred. -Emits a [`IVotes.DelegateVotesChanged`](../governance#IVotes-DelegateVotesChanged-address-uint256-uint256-) event. +Emits a [`IVotes.DelegateVotesChanged`](/contracts/5.x/api/governance#IVotes-DelegateVotesChanged-address-uint256-uint256-) event.
@@ -2600,9 +2805,9 @@ See [`ERC721._increaseBalance`](#ERC721-_increaseBalance-address-uint128-). We n
-## `ERC721Wrapper` +## `ERC721Wrapper` - + @@ -2771,7 +2976,7 @@ Overrides [`IERC721Receiver.onERC721Received`](#IERC721Receiver-onERC721Received this contract. In case there's data attached, it validates that the operator is this contract, so only trusted data -is accepted from [`ERC20Wrapper.depositFor`](/contracts/5.x/api/token/ERC20#ERC20Wrapper-depositFor-address-uint256-). +is accepted from [`ERC721Wrapper.depositFor`](#ERC721Wrapper-depositFor-address-uint256---). Doesn't work with unsafe transfers (eg. [`IERC721.transferFrom`](#IERC721-transferFrom-address-address-uint256-)). Use [`ERC721Wrapper._recover`](#ERC721Wrapper-_recover-address-uint256-) @@ -2837,9 +3042,9 @@ The received ERC-721 token couldn't be wrapped.
-## `IERC721Enumerable` +## `IERC721Enumerable` - + @@ -2913,7 +3118,7 @@ Returns the total amount of tokens stored by the contract.
Returns a token ID owned by `owner` at a given `index` of its token list. -Use along with [`IERC6909.balanceOf`](../interfaces#IERC6909-balanceOf-address-uint256-) to enumerate all of ``owner``'s tokens. +Use along with [`ERC721.balanceOf`](#ERC721-balanceOf-address-) to enumerate all of ``owner``'s tokens.
@@ -2931,7 +3136,7 @@ Use along with [`IERC6909.balanceOf`](../interfaces#IERC6909-balanceOf-address-u
Returns a token ID at a given `index` of all the tokens stored by the contract. -Use along with [`IERC6909TokenSupply.totalSupply`](../interfaces#IERC6909TokenSupply-totalSupply-uint256-) to enumerate all tokens. +Use along with [`ERC721Enumerable.totalSupply`](#ERC721Enumerable-totalSupply--) to enumerate all tokens.
@@ -2940,9 +3145,9 @@ Use along with [`IERC6909TokenSupply.totalSupply`](../interfaces#IERC6909TokenSu
-## `IERC721Metadata` +## `IERC721Metadata` - + @@ -3041,9 +3246,9 @@ Returns the Uniform Resource Identifier (URI) for `tokenId` token.
-## `ERC721Holder` +## `ERC721Holder` - + @@ -3092,9 +3297,9 @@ Always returns `IERC721Receiver.onERC721Received.selector`.
-## `ERC721Utils` +## `ERC721Utils` - + @@ -3138,3 +3343,4 @@ the transfer.
+ diff --git a/content/contracts/5.x/api/token/common.mdx b/content/contracts/5.x/api/token/common.mdx index a1f70f22..5985aff5 100644 --- a/content/contracts/5.x/api/token/common.mdx +++ b/content/contracts/5.x/api/token/common.mdx @@ -16,9 +16,9 @@ Functionality that is common to multiple token standards.
-## `ERC2981` +## `ERC2981` - + @@ -280,3 +280,4 @@ The royalty receiver for `tokenId` is invalid.
+ diff --git a/content/contracts/5.x/api/utils.mdx b/content/contracts/5.x/api/utils.mdx index 38b05b49..00dc1578 100644 --- a/content/contracts/5.x/api/utils.mdx +++ b/content/contracts/5.x/api/utils.mdx @@ -42,6 +42,7 @@ Miscellaneous contracts and libraries containing utility functions you can use t * [`RelayedCall`](#RelayedCall): A library for performing calls that use minimal and predictable relayers to hide the sender. * [`RLP`](#RLP): Library for encoding and decoding data in Ethereum’s Recursive Length Prefix format. * [`ShortStrings`](#ShortStrings): Library to encode (and decode) short strings into (or from) a single bytes32 slot for optimizing costs. Short strings are limited to 31 characters. +* [`SimulateCall`](#SimulateCall): Library for simulating contract calls, enabling safe inspection of call results without affecting on-chain state. * [`SlotDerivation`](#SlotDerivation): Methods for deriving storage slot from ERC-7201 namespaces as well as from constructions such as mapping and arrays. * [`StorageSlot`](#StorageSlot): Methods for accessing specific storage slots formatted as common primitive types. * [`Strings`](#Strings): Common operations for strings formatting. @@ -76,7 +77,7 @@ Because Solidity does not support generic types, [`EnumerableMap`](#EnumerableMa This set of interfaces and contracts deal with [type introspection](https://en.wikipedia.org/wiki/Type_introspection) of contracts, that is, examining which functions can be called on them. This is usually referred to as a contract’s _interface_. -Ethereum contracts have no native concept of an interface, so applications must usually simply trust they are not making an incorrect call. For trusted setups this is a non-issue, but often unknown and untrusted third-party addresses need to be interacted with. There may even not be any direct calls to them! (e.g. ERC-20 tokens may be sent to a contract that lacks a way to transfer them out of it, locking them forever). In these cases, a contract _declaring_ its interface can be very helpful in preventing errors. +Ethereum contracts have no native concept of an interface, so applications must usually simply trust that they are not making an incorrect call. For trusted setups this is a non-issue, but often unknown and untrusted third-party addresses need to be interacted with. There may not even be any direct calls to them! (e.g. ERC-20 tokens may be sent to a contract that lacks a way to transfer them out of it, locking them forever). In these cases, a contract _declaring_ its interface can be very helpful in preventing errors. [`IERC165`](#IERC165) @@ -148,6 +149,8 @@ Ethereum contracts have no native concept of an interface, so applications must [`ShortStrings`](#ShortStrings) +[`SimulateCall`](#SimulateCall) + [`SlotDerivation`](#SlotDerivation) [`StorageSlot`](#StorageSlot) @@ -162,9 +165,9 @@ Ethereum contracts have no native concept of an interface, so applications must
-## `Address` +## `Address` - + @@ -247,7 +250,7 @@ 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`](#Errors-FailedCall--) error. +`Errors.FailedCall` error. Returns the raw returned data. To convert to the expected return value, use [`abi.decode`](https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions). @@ -332,7 +335,7 @@ but performing a delegate call.
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`](#Errors-FailedCall--)) in case +was not a contract or bubbling up the revert reason (falling back to `Errors.FailedCall`) in case of an unsuccessful call. @@ -355,7 +358,7 @@ This function is DEPRECATED and may be removed in the next major release.
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`](#Errors-FailedCall--) error. +revert reason or with a default `Errors.FailedCall` error.
@@ -381,9 +384,9 @@ There's no code at `target` (it is not a contract).
-## `Arrays` +## `Arrays` - + @@ -417,10 +420,16 @@ Collection of functions related to array types. - [slice(array, start, end)](#Arrays-slice-uint256---uint256-uint256-) - [splice(array, start)](#Arrays-splice-address---uint256-) - [splice(array, start, end)](#Arrays-splice-address---uint256-uint256-) +- [replace(array, pos, replacement)](#Arrays-replace-address---uint256-address---) +- [replace(array, pos, replacement, offset, length)](#Arrays-replace-address---uint256-address---uint256-uint256-) - [splice(array, start)](#Arrays-splice-bytes32---uint256-) - [splice(array, start, end)](#Arrays-splice-bytes32---uint256-uint256-) +- [replace(array, pos, replacement)](#Arrays-replace-bytes32---uint256-bytes32---) +- [replace(array, pos, replacement, offset, length)](#Arrays-replace-bytes32---uint256-bytes32---uint256-uint256-) - [splice(array, start)](#Arrays-splice-uint256---uint256-) - [splice(array, start, end)](#Arrays-splice-uint256---uint256-uint256-) +- [replace(array, pos, replacement)](#Arrays-replace-uint256---uint256-uint256---) +- [replace(array, pos, replacement, offset, length)](#Arrays-replace-uint256---uint256-uint256---uint256-uint256-) - [unsafeAccess(arr, pos)](#Arrays-unsafeAccess-address---uint256-) - [unsafeAccess(arr, pos)](#Arrays-unsafeAccess-bytes32---uint256-) - [unsafeAccess(arr, pos)](#Arrays-unsafeAccess-uint256---uint256-) @@ -836,14 +845,12 @@ replicates the behavior of [Javascript's `Array.slice`](https://developer.mozill
-Moves the content of `array`, from `start` (included) to the end of `array` to the start of that array. +Moves the content of `array`, from `start` (included) to the end of `array` to the start of that array, +and shrinks the array length accordingly, effectively overwriting the array with array[start:]. This function modifies the provided array in place. If you need to preserve the original array, use [`Arrays.slice`](#Arrays-slice-uint256---uint256-uint256-) instead. - -replicates the behavior of [Javascript's `Array.splice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice) -
@@ -860,14 +867,63 @@ replicates the behavior of [Javascript's `Array.splice`](https://developer.mozil
-Moves the content of `array`, from `start` (included) to `end` (excluded) to the start of that array. The +Moves the content of `array`, from `start` (included) to `end` (excluded) to the start of that array, +and shrinks the array length accordingly, effectively overwriting the array with array[start:end]. The `end` argument is truncated to the length of the `array`. This function modifies the provided array in place. If you need to preserve the original array, use [`Arrays.slice`](#Arrays-slice-uint256---uint256-uint256-) instead. + +
+
+ + + +
+
+

replace(address[] array, uint256 pos, address[] replacement) → address[]

+
+

internal

+# +
+
+
+ +Replaces elements in `array` starting at `pos` with all elements from `replacement`. + +Parameters are clamped to valid ranges (e.g. `pos` is clamped to `[0, array.length]`). +If `pos >= array.length`, no replacement occurs and the array is returned unchanged. + + +This function modifies the provided array in place. + + +
+
+ + + +
+
+

replace(address[] array, uint256 pos, address[] replacement, uint256 offset, uint256 length) → address[]

+
+

internal

+# +
+
+
+ +Replaces elements in `array` starting at `pos` with elements from `replacement` starting at `offset`. +Copies at most `length` elements from `replacement` to `array`. + +Parameters are clamped to valid ranges (i.e. `pos` is clamped to `[0, array.length]`, `offset` is +clamped to `[0, replacement.length]`, and `length` is clamped to `min(length, replacement.length - offset, +array.length - pos)`). If `pos >= array.length` or `offset >= replacement.length`, no replacement occurs +and the array is returned unchanged. + -replicates the behavior of [Javascript's `Array.splice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice) +This function modifies the provided array in place.
@@ -885,14 +941,12 @@ replicates the behavior of [Javascript's `Array.splice`](https://developer.mozil
-Moves the content of `array`, from `start` (included) to the end of `array` to the start of that array. +Moves the content of `array`, from `start` (included) to the end of `array` to the start of that array, +and shrinks the array length accordingly, effectively overwriting the array with array[start:]. This function modifies the provided array in place. If you need to preserve the original array, use [`Arrays.slice`](#Arrays-slice-uint256---uint256-uint256-) instead. - -replicates the behavior of [Javascript's `Array.splice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice) -
@@ -909,14 +963,63 @@ replicates the behavior of [Javascript's `Array.splice`](https://developer.mozil
-Moves the content of `array`, from `start` (included) to `end` (excluded) to the start of that array. The +Moves the content of `array`, from `start` (included) to `end` (excluded) to the start of that array, +and shrinks the array length accordingly, effectively overwriting the array with array[start:end]. The `end` argument is truncated to the length of the `array`. This function modifies the provided array in place. If you need to preserve the original array, use [`Arrays.slice`](#Arrays-slice-uint256---uint256-uint256-) instead. + +
+
+ + + +
+
+

replace(bytes32[] array, uint256 pos, bytes32[] replacement) → bytes32[]

+
+

internal

+# +
+
+
+ +Replaces elements in `array` starting at `pos` with all elements from `replacement`. + +Parameters are clamped to valid ranges (e.g. `pos` is clamped to `[0, array.length]`). +If `pos >= array.length`, no replacement occurs and the array is returned unchanged. + + +This function modifies the provided array in place. + + +
+
+ + + +
+
+

replace(bytes32[] array, uint256 pos, bytes32[] replacement, uint256 offset, uint256 length) → bytes32[]

+
+

internal

+# +
+
+
+ +Replaces elements in `array` starting at `pos` with elements from `replacement` starting at `offset`. +Copies at most `length` elements from `replacement` to `array`. + +Parameters are clamped to valid ranges (i.e. `pos` is clamped to `[0, array.length]`, `offset` is +clamped to `[0, replacement.length]`, and `length` is clamped to `min(length, replacement.length - offset, +array.length - pos)`). If `pos >= array.length` or `offset >= replacement.length`, no replacement occurs +and the array is returned unchanged. + -replicates the behavior of [Javascript's `Array.splice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice) +This function modifies the provided array in place.
@@ -934,14 +1037,12 @@ replicates the behavior of [Javascript's `Array.splice`](https://developer.mozil
-Moves the content of `array`, from `start` (included) to the end of `array` to the start of that array. +Moves the content of `array`, from `start` (included) to the end of `array` to the start of that array, +and shrinks the array length accordingly, effectively overwriting the array with array[start:]. This function modifies the provided array in place. If you need to preserve the original array, use [`Arrays.slice`](#Arrays-slice-uint256---uint256-uint256-) instead. - -replicates the behavior of [Javascript's `Array.splice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice) -
@@ -958,14 +1059,63 @@ replicates the behavior of [Javascript's `Array.splice`](https://developer.mozil
-Moves the content of `array`, from `start` (included) to `end` (excluded) to the start of that array. The +Moves the content of `array`, from `start` (included) to `end` (excluded) to the start of that array, +and shrinks the array length accordingly, effectively overwriting the array with array[start:end]. The `end` argument is truncated to the length of the `array`. This function modifies the provided array in place. If you need to preserve the original array, use [`Arrays.slice`](#Arrays-slice-uint256---uint256-uint256-) instead. + +
+
+ + + +
+
+

replace(uint256[] array, uint256 pos, uint256[] replacement) → uint256[]

+
+

internal

+# +
+
+
+ +Replaces elements in `array` starting at `pos` with all elements from `replacement`. + +Parameters are clamped to valid ranges (e.g. `pos` is clamped to `[0, array.length]`). +If `pos >= array.length`, no replacement occurs and the array is returned unchanged. + + +This function modifies the provided array in place. + + +
+
+ + + +
+
+

replace(uint256[] array, uint256 pos, uint256[] replacement, uint256 offset, uint256 length) → uint256[]

+
+

internal

+# +
+
+
+ +Replaces elements in `array` starting at `pos` with elements from `replacement` starting at `offset`. +Copies at most `length` elements from `replacement` to `array`. + +Parameters are clamped to valid ranges (i.e. `pos` is clamped to `[0, array.length]`, `offset` is +clamped to `[0, replacement.length]`, and `length` is clamped to `min(length, replacement.length - offset, +array.length - pos)`). If `pos >= array.length` or `offset >= replacement.length`, no replacement occurs +and the array is returned unchanged. + -replicates the behavior of [Javascript's `Array.splice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice) +This function modifies the provided array in place.
@@ -1196,7 +1346,7 @@ Only use if you are certain `pos` is lower than the array length. Helper to set the length of a dynamic array. Directly writing to `.length` is forbidden. -this does not clear elements if length is reduced, of initialize elements if length is increased. +this does not clear elements if length is reduced, or initialize elements if length is increased.
@@ -1217,7 +1367,7 @@ this does not clear elements if length is reduced, of initialize elements if len Helper to set the length of a dynamic array. Directly writing to `.length` is forbidden. -this does not clear elements if length is reduced, of initialize elements if length is increased. +this does not clear elements if length is reduced, or initialize elements if length is increased.
@@ -1238,7 +1388,7 @@ this does not clear elements if length is reduced, of initialize elements if len Helper to set the length of a dynamic array. Directly writing to `.length` is forbidden. -this does not clear elements if length is reduced, of initialize elements if length is increased. +this does not clear elements if length is reduced, or initialize elements if length is increased.
@@ -1259,7 +1409,7 @@ this does not clear elements if length is reduced, of initialize elements if len Helper to set the length of a dynamic array. Directly writing to `.length` is forbidden. -this does not clear elements if length is reduced, of initialize elements if length is increased. +this does not clear elements if length is reduced, or initialize elements if length is increased.
@@ -1280,7 +1430,7 @@ this does not clear elements if length is reduced, of initialize elements if len Helper to set the length of a dynamic array. Directly writing to `.length` is forbidden. -this does not clear elements if length is reduced, of initialize elements if length is increased. +this does not clear elements if length is reduced, or initialize elements if length is increased.
@@ -1290,9 +1440,9 @@ this does not clear elements if length is reduced, of initialize elements if len
-## `Base58` +## `Base58` - + @@ -1386,9 +1536,9 @@ Unrecognized Base58 character on decoding.
-## `Base64` +## `Base64` - + @@ -1467,7 +1617,7 @@ Converts a Base64 `string` to the `bytes` it represents. * Supports padded and unpadded inputs. * Supports both encoding ([`Base58.encode`](#Base58-encode-bytes-) and [`Base64.encodeURL`](#Base64-encodeURL-bytes-)) seamlessly. -* Does NOT revert if the input is not a valid Base64 string. +* Reverts with [`Base64.InvalidBase64Char`](#Base64-InvalidBase64Char-bytes1-) if the input contains an invalid character.
@@ -1491,9 +1641,9 @@ Converts a Base64 `string` to the `bytes` it represents.
-## `Blockhash` +## `Blockhash` - + @@ -1549,9 +1699,9 @@ by returning zero, consistent with the EVM's native `BLOCKHASH` behavior.
-## `Bytes` +## `Bytes` - + @@ -1574,7 +1724,10 @@ Bytes operations. - [slice(buffer, start, end)](#Bytes-slice-bytes-uint256-uint256-) - [splice(buffer, start)](#Bytes-splice-bytes-uint256-) - [splice(buffer, start, end)](#Bytes-splice-bytes-uint256-uint256-) +- [replace(buffer, pos, replacement)](#Bytes-replace-bytes-uint256-bytes-) +- [replace(buffer, pos, replacement, offset, length)](#Bytes-replace-bytes-uint256-bytes-uint256-uint256-) - [concat(buffers)](#Bytes-concat-bytes---) +- [toNibbles(input)](#Bytes-toNibbles-bytes-) - [equal(a, b)](#Bytes-equal-bytes-bytes-) - [reverseBytes32(value)](#Bytes-reverseBytes32-bytes32-) - [reverseBytes16(value)](#Bytes-reverseBytes16-bytes16-) @@ -1733,14 +1886,12 @@ replicates the behavior of [Javascript's `Array.slice`](https://developer.mozill
-Moves the content of `buffer`, from `start` (included) to the end of `buffer` to the start of that buffer. +Moves the content of `buffer`, from `start` (included) to the end of `buffer` to the start of that buffer, +and shrinks the buffer length accordingly, effectively overriding the content of buffer with buffer[start:]. This function modifies the provided buffer in place. If you need to preserve the original buffer, use [`Arrays.slice`](#Arrays-slice-uint256---uint256-uint256-) instead - -replicates the behavior of [Javascript's `Array.splice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice) -
@@ -1757,14 +1908,63 @@ replicates the behavior of [Javascript's `Array.splice`](https://developer.mozil
-Moves the content of `buffer`, from `start` (included) to end (excluded) to the start of that buffer. The -`end` argument is truncated to the length of the `buffer`. +Moves the content of `buffer`, from `start` (included) to `end` (excluded) to the start of that buffer, +and shrinks the buffer length accordingly, effectively overriding the content of buffer with buffer[start:end]. +The `end` argument is truncated to the length of the `buffer`. This function modifies the provided buffer in place. If you need to preserve the original buffer, use [`Arrays.slice`](#Arrays-slice-uint256---uint256-uint256-) instead + +
+
+ + + +
+
+

replace(bytes buffer, uint256 pos, bytes replacement) → bytes

+
+

internal

+# +
+
+
+ +Replaces bytes in `buffer` starting at `pos` with all bytes from `replacement`. + +Parameters are clamped to valid ranges (i.e. `pos` is clamped to `[0, buffer.length]`). +If `pos >= buffer.length`, no replacement occurs and the buffer is returned unchanged. + + +This function modifies the provided buffer in place. + + +
+
+ + + +
+
+

replace(bytes buffer, uint256 pos, bytes replacement, uint256 offset, uint256 length) → bytes

+
+

internal

+# +
+
+
+ +Replaces bytes in `buffer` starting at `pos` with bytes from `replacement` starting at `offset`. +Copies at most `length` bytes from `replacement` to `buffer`. + +Parameters are clamped to valid ranges (i.e. `pos` is clamped to `[0, buffer.length]`, `offset` is +clamped to `[0, replacement.length]`, and `length` is clamped to `min(length, replacement.length - offset, +buffer.length - pos))`. If `pos >= buffer.length` or `offset >= replacement.length`, no replacement occurs +and the buffer is returned unchanged. + -replicates the behavior of [Javascript's `Array.splice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice) +This function modifies the provided buffer in place.
@@ -1795,6 +1995,25 @@ significantly less readable. It might be worth benchmarking the savings of the f
+ + +
+
+

toNibbles(bytes input) → bytes output

+
+

internal

+# +
+
+
+ +Split each byte in `input` into two nibbles (4 bits each) + +Example: hex"01234567" → hex"0001020304050607" + +
+
+
@@ -1920,9 +2139,9 @@ if the buffer is all zeros.
-## `CAIP10` +## `CAIP10` - + @@ -2020,9 +2239,9 @@ parsed using the [`CAIP2`](#CAIP2) library.
-## `CAIP2` +## `CAIP2` - + @@ -2118,9 +2337,9 @@ This function does not verify that the CAIP-2 input is properly formatted.
-## `Calldata` +## `Calldata` - + @@ -2174,9 +2393,9 @@ Helper library for manipulating objects in calldata.
-## `Comparators` +## `Comparators` - + @@ -2232,9 +2451,9 @@ _Available since v5.1._
-## `Context` +## `Context` - + @@ -2311,9 +2530,9 @@ This contract is only required for intermediate, library-like contracts.
-## `Create2` +## `Create2` - + @@ -2432,9 +2651,9 @@ There's no code to deploy.
-## `Errors` +## `Errors` - + @@ -2535,9 +2754,9 @@ A necessary precompile is missing.
-## `LowLevelCall` +## `LowLevelCall` - + @@ -2601,7 +2820,7 @@ Performs a Solidity function call using a low level `call` and ignoring the retu
-Same as [`LowLevelCall.callNoReturn`](#LowLevelCall-callNoReturn-address-uint256-bytes-), but allows to specify the value to be sent in the call. +Same as `callNoReturn-address-bytes`, but allows specifying the value to be sent in the call.
@@ -2619,7 +2838,7 @@ Same as [`LowLevelCall.callNoReturn`](#LowLevelCall-callNoReturn-address-uint256
Performs a Solidity function call using a low level `call` and returns the first 64 bytes of the result -in the scratch space of memory. Useful for functions that return a tuple of single-word values. +in the scratch space of memory. Useful for functions that return a tuple with two single-word values. Do not assume that the results are zero if `success` is false. Memory can be already allocated @@ -2641,7 +2860,7 @@ and this function doesn't zero it out.
-Same as `callReturnBytes32Pair`, but allows to specify the value to be sent in the call. +Same as `callReturn64Bytes-address-bytes`, but allows specifying the value to be sent in the call.
@@ -2676,7 +2895,7 @@ Performs a Solidity function call using a low level `staticcall` and ignoring th
Performs a Solidity function call using a low level `staticcall` and returns the first 64 bytes of the result -in the scratch space of memory. Useful for functions that return a tuple of single-word values. +in the scratch space of memory. Useful for functions that return a tuple with two single-word values. Do not assume that the results are zero if `success` is false. Memory can be already allocated @@ -2716,7 +2935,7 @@ Performs a Solidity function call using a low level `delegatecall` and ignoring
Performs a Solidity function call using a low level `delegatecall` and returns the first 64 bytes of the result -in the scratch space of memory. Useful for functions that return a tuple of single-word values. +in the scratch space of memory. Useful for functions that return a tuple with two single-word values. Do not assume that the results are zero if `success` is false. Memory can be already allocated @@ -2796,9 +3015,9 @@ Revert with the return data from the last call.
-## `Memory` +## `Memory` - + @@ -2824,9 +3043,7 @@ guidelines for [Memory Safety](https://docs.soliditylang.org/en/v0.8.20/assembly

Functions

- [getFreeMemoryPointer()](#Memory-getFreeMemoryPointer--) -- [setFreeMemoryPointer(ptr)](#Memory-setFreeMemoryPointer-Memory-Pointer-) -- [asBytes32(ptr)](#Memory-asBytes32-Memory-Pointer-) -- [asPointer(value)](#Memory-asPointer-bytes32-) +- [unsafeSetFreeMemoryPointer(ptr)](#Memory-unsafeSetFreeMemoryPointer-Memory-Pointer-) - [forward(ptr, offset)](#Memory-forward-Memory-Pointer-uint256-) - [equal(ptr1, ptr2)](#Memory-equal-Memory-Pointer-Memory-Pointer-) - [asSlice(self)](#Memory-asSlice-bytes-) @@ -2835,6 +3052,8 @@ guidelines for [Memory Safety](https://docs.soliditylang.org/en/v0.8.20/assembly - [slice(self, offset, len)](#Memory-slice-Memory-Slice-uint256-uint256-) - [load(self, offset)](#Memory-load-Memory-Slice-uint256-) - [toBytes(self)](#Memory-toBytes-Memory-Slice-) +- [equal(a, b)](#Memory-equal-Memory-Slice-Memory-Slice-) +- [isReserved(self)](#Memory-isReserved-Memory-Slice-)
@@ -2855,20 +3074,24 @@ Returns a `Pointer` to the current free `Pointer`.
- +
-

setFreeMemoryPointer(Memory.Pointer ptr)

+

unsafeSetFreeMemoryPointer(Memory.Pointer ptr)

internal

-# +#
Sets the free `Pointer` to a specific value. +The solidity memory layout requires that the FMP is never set to a value lower than 0x80. Setting the +FMP to a value lower than 0x80 may cause unexpected behavior. Deallocating all memory can be achieved by +setting the FMP to 0x80. + Everything after the pointer may be overwritten. @@ -2876,40 +3099,6 @@ Everything after the pointer may be overwritten.
- - -
-
-

asBytes32(Memory.Pointer ptr) → bytes32

-
-

internal

-# -
-
-
- -`Pointer` to `bytes32`. Expects a pointer to a properly ABI-encoded `bytes` object. - -
-
- - - -
-
-

asPointer(bytes32 value) → Memory.Pointer

-
-

internal

-# -
-
-
- -`bytes32` to `Pointer`. Expects a pointer to a properly ABI-encoded `bytes` object. - -
-
-
@@ -2990,7 +3179,7 @@ Returns the length of a given slice (equiv to self.length for calldata slices)
-Offset a memory slice (equivalent to self[start:] for calldata slices) +Offset a memory slice (equivalent to self[offset:] for calldata slices)
@@ -3007,7 +3196,7 @@ Offset a memory slice (equivalent to self[start:] for calldata slices)
-Offset and cut a Slice (equivalent to self[start:start+length] for calldata slices) +Offset and cut a Slice (equivalent to self[offset:offset+len] for calldata slices)
@@ -3050,13 +3239,47 @@ Extract the data corresponding to a Slice (allocate new memory)
+ + +
+
+

equal(Memory.Slice a, Memory.Slice b) → bool result

+
+

internal

+# +
+
+
+ +Returns true if the two slices contain the same data. + +
+
+ + + +
+
+

isReserved(Memory.Slice self) → bool result

+
+

internal

+# +
+
+
+ +Returns true if the memory occupied by the slice is reserved (i.e. before the free memory pointer) + +
+
+
-## `Multicall` +## `Multicall` - + @@ -3107,9 +3330,9 @@ Receives and executes a batch of function calls on this contract.
-## `Nonces` +## `Nonces` - + @@ -3211,9 +3434,9 @@ The nonce used for an `account` is not the expected current nonce.
-## `NoncesKeyed` +## `NoncesKeyed` - + @@ -3335,9 +3558,9 @@ This version takes the key and the nonce as two different parameters.
-## `Packing` +## `Packing` - + @@ -6798,9 +7021,9 @@ _Available since v5.1._
-## `Panic` +## `Panic` - + @@ -6857,9 +7080,9 @@ the internal constants with predefined codes.
-## `Pausable` +## `Pausable` - + @@ -7122,9 +7345,9 @@ The operation failed because the contract is not paused.
-## `RLP` +## `RLP` - + @@ -7143,6 +7366,33 @@ Inspired by * https://github.com/succinctlabs/optimism-bedrock-contracts/blob/main/rlp/RLPWriter.sol * https://github.com/succinctlabs/optimism-bedrock-contracts/blob/main/rlp/RLPReader.sol +## Canonical vs Non-Canonical Encodings + +According to the Ethereum Yellow Paper, a "canonical" RLP encoding is the unique, minimal +representation of a value. For scalar values (integers), this means: + +* No leading zero bytes (e.g., `0x0123` should be encoded as 2 bytes, not `0x000123` as 3 bytes) +* Single bytes less than 0x80 must be encoded directly without a prefix wrapper +* Zero is represented as an empty byte array (prefix `0x80`) + +A "non-canonical" encoding represents the same value but doesn't follow these minimality rules. +For example, encoding the integer 1234 (0x04d2) with a leading zero as `0x830004d2` instead +of the canonical `0x8204d2`. + +[IMPORTANT] +#### This implementation takes a permissive approach to decoding, accepting some non-canonical +encodings (e.g., scalar values with leading zero bytes) that would be rejected by +strict implementations like go-ethereum. This design choice prioritizes compatibility +with diverse RLP encoders in the ecosystem over strict adherence to the Yellow Paper +specification's canonicalization requirements. + +Users should be aware that: + +* Multiple different RLP encodings may decode to the same value (non-injective) +* Encoding followed by decoding is guaranteed to work correctly +* External RLP data from untrusted sources may have non-canonical encodings +* Improperly wrapped single bytes (< 0x80) are still rejected as invalid +

Functions

@@ -7372,7 +7622,10 @@ This follows the de facto ecosystem standard where booleans are treated as 0/1 i
-Encode an address as RLP. +Encode an address as an RLP item of fixed size (20 bytes). + +The address is encoded with its leading zeros (if it has any). If someone wants to encode the address as a scalar, +they can cast it to an uint256 and then call the corresponding [`Base58.encode`](#Base58-encode-bytes-) function.
@@ -7389,7 +7642,9 @@ Encode an address as RLP.
-Encode a uint256 as RLP. +Encode an uint256 as an RLP scalar. + +Unlike `encode-bytes32-`, this function uses scalar encoding that removes the prefix zeros.
@@ -7398,7 +7653,7 @@ Encode a uint256 as RLP.
-

encode(bytes32 input) → bytes

+

encode(bytes32 input) → bytes result

internal

# @@ -7406,7 +7661,9 @@ Encode a uint256 as RLP.
-Encode a bytes32 as RLP. Type alias for #RLP-encode-uint256-. +Encode a bytes32 as an RLP item of fixed size (32 bytes). + +Unlike `encode-uint256-`, this function uses array encoding that preserves the prefix zeros.
@@ -7440,7 +7697,7 @@ Encode a bytes buffer as RLP.
-Encode a string as RLP. Type alias for #Base58-encode-bytes-. +Encode a string as RLP. Type alias for `encode-bytes-`.
@@ -7458,6 +7715,8 @@ Encode a string as RLP. Type alias for #Base58-encode-bytes-.
Encode an array of bytes as RLP. +This function expects an array of already encoded bytes, not raw bytes. +Users should call [`Base58.encode`](#Base58-encode-bytes-) on each element of the array before calling it.
@@ -7466,7 +7725,7 @@ Encode an array of bytes as RLP.
-

encode(struct RLP.Encoder self) → bytes result

+

encode(struct RLP.Encoder self) → bytes

internal

# @@ -7491,7 +7750,13 @@ Encode an encoder (list of bytes) as RLP
-Decode an RLP encoded bool. See #RLP-encode-bool- +Decode an RLP encoded bool. See `encode-bool` + + +This function treats any non-zero value as `true`, which is more permissive +than some implementations (e.g., go-ethereum only accepts `0x00` for false and `0x01` +for true). For example, `0x02`, `0x03`, etc. will all decode as `true`. +
@@ -7508,7 +7773,16 @@ Decode an RLP encoded bool. See #RLP-encode-bool-
-Decode an RLP encoded address. See #RLP-encode-address- +Decode an RLP encoded address. See `encode-address` + +[NOTE] +#### This function accepts both single-byte encodings (for values 0-127, including +precompile addresses like 0x01) and the standard 21-byte encoding with the `0x94` prefix. +For example, `0x01` decodes to `0x0000000000000000000000000000000000000001`. + +Additionally, like [`RLP.readUint256`](#RLP-readUint256-Memory-Slice-), this function accepts non-canonical encodings with +leading zeros. For instance, both `0x01` and `0x940000000000000000000000000000000000000001` +decode to the same address.
@@ -7525,7 +7799,20 @@ Decode an RLP encoded address. See #RLP-encode-address-
-Decode an RLP encoded uint256. See #RLP-encode-uint256- +Decode an RLP encoded uint256. See `encode-uint256` + +[NOTE] +#### This function accepts non-canonical encodings with leading zero bytes for multi-byte values, +which differs from the Ethereum Yellow Paper specification and some reference +implementations like go-ethereum. For example, both `0x88ab54a98ceb1f0ad2` and +`0x8900ab54a98ceb1f0ad2` will decode to the same uint256 value (12345678901234567890). + +However, single bytes less than 0x80 must NOT be wrapped with a prefix. For example, +`0x8100` is invalid (should be `0x00`), but `0x820000` is valid (two zero bytes). + +This permissive behavior is intentional for compatibility with various RLP encoders +in the ecosystem, but users should be aware that multiple RLP encodings may map +to the same decoded value (non-injective decoding).
@@ -7542,7 +7829,14 @@ Decode an RLP encoded uint256. See #RLP-encode-uint256-
-Decode an RLP encoded bytes32. See #RLP-encode-bytes32- +Decode an RLP encoded bytes32. See `encode-bytes32` + + +Since this function delegates to [`RLP.readUint256`](#RLP-readUint256-Memory-Slice-), it inherits the non-canonical +encoding acceptance behavior for multi-byte values. Multiple RLP encodings with different +leading zero bytes may decode to the same bytes32 value, but single bytes < 0x80 must +not be wrapped with a prefix (e.g., `0x820000` is valid, but `0x8100` is not). +
@@ -7559,7 +7853,7 @@ Decode an RLP encoded bytes32. See #RLP-encode-bytes32-
-Decodes an RLP encoded bytes. See #Base58-encode-bytes- +Decodes an RLP encoded bytes. See `encode-bytes`
@@ -7576,7 +7870,7 @@ Decodes an RLP encoded bytes. See #Base58-encode-bytes-
-Decodes an RLP encoded string. See #RLP-encode-string- +Decodes an RLP encoded string. See `encode-string`
@@ -7593,7 +7887,12 @@ Decodes an RLP encoded string. See #RLP-encode-string-
-Decodes an RLP encoded list into an array of RLP Items. +Decodes an RLP encoded list in a memory slice into an array of RLP Items. + + +The returned array contains slice references into the original payload, not copied bytes. Any further +modification of the input buffer may cause the output result to become invalid. +
@@ -7714,6 +8013,11 @@ Decode an RLP encoded string from bytes. See [`RLP.readString`](#RLP-readString- Decode an RLP encoded list from bytes. See [`RLP.readList`](#RLP-readList-Memory-Slice-) + +The returned array contains slice references into the original payload, not copied bytes. Any further +modification of the input buffer may cause the output result to become invalid. + +
@@ -7729,930 +8033,702 @@ Decode an RLP encoded list from bytes. See [`RLP.readList`](#RLP-readList-Memory
-The item is not properly formatted and cannot de decoded. +The item is not properly formatted and cannot be decoded.
- +
-## `ReentrancyGuard` +## `RelayedCall` - +
```solidity -import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; +import "@openzeppelin/contracts/utils/RelayedCall.sol"; ``` -Contract module that helps prevent reentrant calls to a function. +Library for performing external calls through dynamically deployed relay contracts that hide the original +caller's address from the target contract. This pattern is used in ERC-4337's EntryPoint for account factory +calls and ERC-6942 for safe factory interactions. -Inheriting from `ReentrancyGuard` will make the [`ReentrancyGuard.nonReentrant`](#ReentrancyGuard-nonReentrant--) modifier -available, which can be applied to functions to make sure there are no nested -(reentrant) calls to them. +When privileged contracts need to make arbitrary external calls based on user input, calling the target directly +can be risky because the target sees the privileged contract as `msg.sender` and could exploit this trust +relationship. This library solves this by deploying minimal relay contracts that act as intermediaries, ensuring +the target only sees the unprivileged relay address as `msg.sender`. -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. +For example, instead of `target.call(data)` where the target sees this contract as `msg.sender`, use +[`RelayedCall.relayCall`](#RelayedCall-relayCall-address-uint256-bytes-bytes32-) where the target sees a relay address as `msg.sender`. -If EIP-1153 (transient storage) is available on the chain you're deploying at, -consider using [`ReentrancyGuardTransient`](#ReentrancyGuardTransient) instead. +This library uses the PUSH0 opcode that was introduced in the Shanghai hardfork. While this instruction is +now widely supported, developers using the library on exotic chains should verify that their target chain has +supports for EIP-3855. - -If you would like to learn more about reentrancy and alternative ways -to protect against it, check out our blog post -[Reentrancy After Istanbul](https://blog.openzeppelin.com/reentrancy-after-istanbul/). - - - -Deprecated. This storage-based reentrancy guard will be removed and replaced -by the [`ReentrancyGuardTransient`](#ReentrancyGuardTransient) variant in v6.0. - - -@custom:stateless - -
-

Modifiers

-
-- [nonReentrant()](#ReentrancyGuard-nonReentrant--) -- [nonReentrantView()](#ReentrancyGuard-nonReentrantView--) -
-
-

Functions

-- [constructor()](#ReentrancyGuard-constructor--) -- [_reentrancyGuardEntered()](#ReentrancyGuard-_reentrancyGuardEntered--) -- [_reentrancyGuardStorageSlot()](#ReentrancyGuard-_reentrancyGuardStorageSlot--) -
-
- -
-

Errors

-
-- [ReentrancyGuardReentrantCall()](#ReentrancyGuard-ReentrancyGuardReentrantCall--) +- [relayCall(target, data)](#RelayedCall-relayCall-address-bytes-) +- [relayCall(target, value, data)](#RelayedCall-relayCall-address-uint256-bytes-) +- [relayCall(target, data, salt)](#RelayedCall-relayCall-address-bytes-bytes32-) +- [relayCall(target, value, data, salt)](#RelayedCall-relayCall-address-uint256-bytes-bytes32-) +- [getRelayer()](#RelayedCall-getRelayer--) +- [getRelayer(salt)](#RelayedCall-getRelayer-bytes32-)
- +
-

nonReentrant()

+

relayCall(address target, bytes data) → bool success, bytes retData

internal

-# +#
-
-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. +Relays a call to the target contract through a dynamically deployed relay contract.
- +
-

nonReentrantView()

+

relayCall(address target, uint256 value, bytes data) → bool success, bytes retData

internal

-# +#
-
-A `view` only version of [`ReentrancyGuard.nonReentrant`](#ReentrancyGuard-nonReentrant--). Use to block view functions -from being called, preventing reading from inconsistent contract state. - -CAUTION: This is a "view" modifier and does not change the reentrancy -status. Use it only on view functions. For payable or non-payable functions, -use the standard [`ReentrancyGuard.nonReentrant`](#ReentrancyGuard-nonReentrant--) modifier instead. +Same as `relayCall-address-bytes` but with a value.
- +
-

constructor()

+

relayCall(address target, bytes data, bytes32 salt) → bool success, bytes retData

internal

-# +#
+Same as `relayCall-address-bytes` but with a salt. +
- +
-

_reentrancyGuardEntered() → bool

+

relayCall(address target, uint256 value, bytes data, bytes32 salt) → bool success, bytes retData

internal

-# +#
-Returns true if the reentrancy guard is currently set to "entered", which indicates there is a -`nonReentrant` function in the call stack. +Same as `relayCall-address-bytes` but with a salt and a value.
- +
-

_reentrancyGuardStorageSlot() → bytes32

+

getRelayer() → address

internal

-# +#
+Same as [`RelayedCall.getRelayer`](#RelayedCall-getRelayer-bytes32-) but with a `bytes32(0)` default salt. +
- +
-

ReentrancyGuardReentrantCall()

+

getRelayer(bytes32 salt) → address relayer

-

error

-# +

internal

+#
-Unauthorized reentrant call. +Returns the relayer address for a given salt.
- +
-## `ReentrancyGuardTransient` +## `ShortString` - +
```solidity -import "@openzeppelin/contracts/utils/ReentrancyGuardTransient.sol"; +import "@openzeppelin/contracts/utils/ShortStrings.sol"; ``` -Variant of [`ReentrancyGuard`](#ReentrancyGuard) that uses transient storage. + - -This variant only works on networks where EIP-1153 is available. - +
-_Available since v5.1._ +## `ShortStrings` -@custom:stateless + + + -
-

Modifiers

-
-- [nonReentrant()](#ReentrancyGuardTransient-nonReentrant--) -- [nonReentrantView()](#ReentrancyGuardTransient-nonReentrantView--) -
+```solidity +import "@openzeppelin/contracts/utils/ShortStrings.sol"; +``` + +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: + +```solidity +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); + } +} +``` +

Functions

-- [_reentrancyGuardEntered()](#ReentrancyGuardTransient-_reentrancyGuardEntered--) -- [_reentrancyGuardStorageSlot()](#ReentrancyGuardTransient-_reentrancyGuardStorageSlot--) +- [toShortString(str)](#ShortStrings-toShortString-string-) +- [toString(sstr)](#ShortStrings-toString-ShortString-) +- [byteLength(sstr)](#ShortStrings-byteLength-ShortString-) +- [toShortStringWithFallback(value, store)](#ShortStrings-toShortStringWithFallback-string-string-) +- [toStringWithFallback(value, store)](#ShortStrings-toStringWithFallback-ShortString-string-) +- [byteLengthWithFallback(value, store)](#ShortStrings-byteLengthWithFallback-ShortString-string-)

Errors

-- [ReentrancyGuardReentrantCall()](#ReentrancyGuardTransient-ReentrancyGuardReentrantCall--) +- [StringTooLong(str)](#ShortStrings-StringTooLong-string-) +- [InvalidShortString()](#ShortStrings-InvalidShortString--)
- +
-

nonReentrant()

+

toShortString(string str) → ShortString

internal

-# +#
-
-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. +Encode a string of at most 31 chars into a `ShortString`. + +This will trigger a `StringTooLong` error is the input string is too long.
- +
-

nonReentrantView()

+

toString(ShortString sstr) → string

internal

-# +# +
+
+
+ +Decode a `ShortString` back to a "normal" string. +
+ + +
+
+

byteLength(ShortString sstr) → uint256

+
+

internal

+# +
+
-A `view` only version of [`ReentrancyGuard.nonReentrant`](#ReentrancyGuard-nonReentrant--). Use to block view functions -from being called, preventing reading from inconsistent contract state. +Return the length of a `ShortString`. -CAUTION: This is a "view" modifier and does not change the reentrancy -status. Use it only on view functions. For payable or non-payable functions, -use the standard [`ReentrancyGuard.nonReentrant`](#ReentrancyGuard-nonReentrant--) modifier instead. +
+
+ + +
+
+

toShortStringWithFallback(string value, string store) → ShortString

+
+

internal

+#
+
- +Encode a string into a `ShortString`, or write it to storage if it is too long. + +
+
+ +
-

_reentrancyGuardEntered() → bool

+

toStringWithFallback(ShortString value, string store) → string

internal

-# +#
-Returns true if the reentrancy guard is currently set to "entered", which indicates there is a -`nonReentrant` function in the call stack. +Decode a string that was encoded to `ShortString` or written to storage using [`ShortStrings.toShortStringWithFallback`](#ShortStrings-toShortStringWithFallback-string-string-).
- +
-

_reentrancyGuardStorageSlot() → bytes32

+

byteLengthWithFallback(ShortString value, string store) → uint256

internal

-# +#
+Return the length of a string that was encoded to `ShortString` or written to storage using +[`ShortStrings.toShortStringWithFallback`](#ShortStrings-toShortStringWithFallback-string-string-). + + +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. + +
- +
-

ReentrancyGuardReentrantCall()

+

StringTooLong(string str)

error

-# +#
-Unauthorized reentrant call. +
+
+ + + +
+
+

InvalidShortString()

+
+

error

+# +
+
+
- +
-## `RelayedCall` +## `SimulateCall` - +
```solidity -import "@openzeppelin/contracts/utils/RelayedCall.sol"; +import "@openzeppelin/contracts/utils/SimulateCall.sol"; ``` -Library for performing external calls through dynamically deployed relay contracts that hide the original -caller's address from the target contract. This pattern is used in ERC-4337's EntryPoint for account factory -calls and ERC-6942 for safe factory interactions. - -When privileged contracts need to make arbitrary external calls based on user input, calling the target directly -can be risky because the target sees the privileged contract as `msg.sender` and could exploit this trust -relationship. This library solves this by deploying minimal relay contracts that act as intermediaries, ensuring -the target only sees the unprivileged relay address as `msg.sender`. +Library for simulating external calls and inspecting the result of the call while reverting any state changes +of events the call may have produced. -For example, instead of `target.call(data)` where the target sees this contract as `msg.sender`, use -[`RelayedCall.relayCall`](#RelayedCall-relayCall-address-uint256-bytes-bytes32-) where the target sees a relay address as `msg.sender`. +This pattern is useful when you need to simulate the result of a call without actually executing it on-chain. Since +the address of the sender is preserved, this supports simulating calls that perform token swap that use the caller's +balance, or any operation that is restricted to the caller.

Functions

-- [relayCall(target, data)](#RelayedCall-relayCall-address-bytes-) -- [relayCall(target, value, data)](#RelayedCall-relayCall-address-uint256-bytes-) -- [relayCall(target, data, salt)](#RelayedCall-relayCall-address-bytes-bytes32-) -- [relayCall(target, value, data, salt)](#RelayedCall-relayCall-address-uint256-bytes-bytes32-) -- [getRelayer()](#RelayedCall-getRelayer--) -- [getRelayer(salt)](#RelayedCall-getRelayer-bytes32-) -
-
- - - -
-
-

relayCall(address target, bytes data) → bool, bytes

-
-

internal

-# -
-
-
- -Relays a call to the target contract through a dynamically deployed relay contract. - -
-
- - - -
-
-

relayCall(address target, uint256 value, bytes data) → bool, bytes

-
-

internal

-# -
-
-
- -Same as [`RelayedCall.relayCall`](#RelayedCall-relayCall-address-uint256-bytes-bytes32-) but with a value. - +- [simulateCall(target, data)](#SimulateCall-simulateCall-address-bytes-) +- [simulateCall(target, value, data)](#SimulateCall-simulateCall-address-uint256-bytes-) +- [getSimulator()](#SimulateCall-getSimulator--)
- +
-

relayCall(address target, bytes data, bytes32 salt) → bool, bytes

+

simulateCall(address target, bytes data) → bool success, bytes retData

internal

-# +#
-Same as [`RelayedCall.relayCall`](#RelayedCall-relayCall-address-uint256-bytes-bytes32-) but with a salt. +Simulates a call to the target contract through a dynamically deployed simulator.
- +
-

relayCall(address target, uint256 value, bytes data, bytes32 salt) → bool, bytes

+

simulateCall(address target, uint256 value, bytes data) → bool success, bytes retData

internal

-# +#
-Same as [`RelayedCall.relayCall`](#RelayedCall-relayCall-address-uint256-bytes-bytes32-) but with a salt and a value. +Same as `simulateCall-address-bytes` but with a value.
- +
-

getRelayer() → address

+

getSimulator() → address instance

internal

-# +#
-Same as [`RelayedCall.getRelayer`](#RelayedCall-getRelayer-bytes32-) but with a `bytes32(0)` default salt. - -
-
- - +Returns the simulator address. -
-
-

getRelayer(bytes32 salt) → address relayer

-
-

internal

-# -
-
-
+The simulator REVERTs on success and RETURNs on failure, preserving the return data in both cases. -Returns the relayer address for a given salt. +* A failed target call returns the return data and succeeds in our context (no state changes). +* A successful target call causes a revert in our context (undoing all state changes) while still +capturing the return data.
- - -
- -## `ShortString` - - - - - -
- -```solidity -import "@openzeppelin/contracts/utils/ShortStrings.sol"; -``` - - +
-## `ShortStrings` +## `SlotDerivation` - +
```solidity -import "@openzeppelin/contracts/utils/ShortStrings.sol"; +import "@openzeppelin/contracts/utils/SlotDerivation.sol"; ``` -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. +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. -Usage example: +See [Solidity docs for mappings and dynamic arrays.](https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays). +Example usage: ```solidity -contract Named { - using ShortStrings for *; +contract Example { + // Add the library methods + using StorageSlot for bytes32; + using SlotDerivation for *; - ShortString private immutable _name; - string private _nameFallback; + // Declare a namespace + string private constant _NAMESPACE = ""; // eg. OpenZeppelin.Slot - constructor(string memory contractName) { - _name = contractName.toShortStringWithFallback(_nameFallback); + function setValueInNamespace(uint256 key, address newValue) internal { + _NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value = newValue; } - function name() external view returns (string memory) { - return _name.toStringWithFallback(_nameFallback); + function getValueInNamespace(uint256 key) internal view returns (address) { + return _NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value; } } ``` + +Consider using this library along with [`StorageSlot`](#StorageSlot). + + + +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

-- [toShortString(str)](#ShortStrings-toShortString-string-) -- [toString(sstr)](#ShortStrings-toString-ShortString-) -- [byteLength(sstr)](#ShortStrings-byteLength-ShortString-) -- [toShortStringWithFallback(value, store)](#ShortStrings-toShortStringWithFallback-string-string-) -- [toStringWithFallback(value, store)](#ShortStrings-toStringWithFallback-ShortString-string-) -- [byteLengthWithFallback(value, store)](#ShortStrings-byteLengthWithFallback-ShortString-string-) +- [erc7201Slot(namespace)](#SlotDerivation-erc7201Slot-string-) +- [offset(slot, pos)](#SlotDerivation-offset-bytes32-uint256-) +- [deriveArray(slot)](#SlotDerivation-deriveArray-bytes32-) +- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-address-) +- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-bool-) +- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-bytes32-) +- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-uint256-) +- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-int256-) +- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-string-) +- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-bytes-)
-
-

Errors

-
-- [StringTooLong(str)](#ShortStrings-StringTooLong-string-) -- [InvalidShortString()](#ShortStrings-InvalidShortString--) + + +
+
+

erc7201Slot(string namespace) → bytes32 slot

+
+

internal

+#
+
- +Derive an ERC-7201 slot from a string (namespace). + +
+
+ +
-

toShortString(string str) → ShortString

+

offset(bytes32 slot, uint256 pos) → bytes32 result

internal

-# +#
-Encode a string of at most 31 chars into a `ShortString`. - -This will trigger a `StringTooLong` error is the input string is too long. +Add an offset to a slot to get the n-th element of a structure or an array.
- +
-

toString(ShortString sstr) → string

+

deriveArray(bytes32 slot) → bytes32 result

internal

-# +#
-Decode a `ShortString` back to a "normal" string. +Derive the location of the first element in an array from the slot where the length is stored.
- +
-

byteLength(ShortString sstr) → uint256

+

deriveMapping(bytes32 slot, address key) → bytes32 result

internal

-# +#
-Return the length of a `ShortString`. +Derive the location of a mapping element from the key.
- +
-

toShortStringWithFallback(string value, string store) → ShortString

+

deriveMapping(bytes32 slot, bool key) → bytes32 result

internal

-# +#
-Encode a string into a `ShortString`, or write it to storage if it is too long. +Derive the location of a mapping element from the key.
- +
-

toStringWithFallback(ShortString value, string store) → string

+

deriveMapping(bytes32 slot, bytes32 key) → bytes32 result

internal

-# +#
-Decode a string that was encoded to `ShortString` or written to storage using [`ShortStrings.toShortStringWithFallback`](#ShortStrings-toShortStringWithFallback-string-string-). +Derive the location of a mapping element from the key.
- +
-

byteLengthWithFallback(ShortString value, string store) → uint256

+

deriveMapping(bytes32 slot, uint256 key) → bytes32 result

internal

-# +#
-Return the length of a string that was encoded to `ShortString` or written to storage using -[`ShortStrings.toShortStringWithFallback`](#ShortStrings-toShortStringWithFallback-string-string-). - - -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. - +Derive the location of a mapping element from the key.
- +
-

StringTooLong(string str)

+

deriveMapping(bytes32 slot, int256 key) → bytes32 result

-

error

-# +

internal

+#
+Derive the location of a mapping element from the key. +
- +
-

InvalidShortString()

+

deriveMapping(bytes32 slot, string key) → bytes32 result

-

error

-# +

internal

+#
+Derive the location of a mapping element from the key. +
- - -
+ -## `SlotDerivation` +
+
+

deriveMapping(bytes32 slot, bytes key) → bytes32 result

+
+

internal

+# +
+
+
- - - - -
- -```solidity -import "@openzeppelin/contracts/utils/SlotDerivation.sol"; -``` - -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 [Solidity docs for mappings and dynamic arrays.](https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays). - -Example usage: -```solidity -contract Example { - // Add the library methods - using StorageSlot for bytes32; - using SlotDerivation for *; - - // Declare a namespace - string private constant _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; - } -} -``` - - -Consider using this library along with [`StorageSlot`](#StorageSlot). - - - -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(namespace)](#SlotDerivation-erc7201Slot-string-) -- [offset(slot, pos)](#SlotDerivation-offset-bytes32-uint256-) -- [deriveArray(slot)](#SlotDerivation-deriveArray-bytes32-) -- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-address-) -- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-bool-) -- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-bytes32-) -- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-uint256-) -- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-int256-) -- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-string-) -- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-bytes-) -
-
- - - -
-
-

erc7201Slot(string namespace) → bytes32 slot

-
-

internal

-# -
-
-
- -Derive an ERC-7201 slot from a string (namespace). - -
-
- - - -
-
-

offset(bytes32 slot, uint256 pos) → bytes32 result

-
-

internal

-# -
-
-
- -Add an offset to a slot to get the n-th element of a structure or an array. - -
-
- - - -
-
-

deriveArray(bytes32 slot) → bytes32 result

-
-

internal

-# -
-
-
- -Derive the location of the first element in an array from the slot where the length is stored. - -
-
- - - -
-
-

deriveMapping(bytes32 slot, address key) → bytes32 result

-
-

internal

-# -
-
-
- -Derive the location of a mapping element from the key. - -
-
- - - -
-
-

deriveMapping(bytes32 slot, bool key) → bytes32 result

-
-

internal

-# -
-
-
- -Derive the location of a mapping element from the key. - -
-
- - - -
-
-

deriveMapping(bytes32 slot, bytes32 key) → bytes32 result

-
-

internal

-# -
-
-
- -Derive the location of a mapping element from the key. - -
-
- - - -
-
-

deriveMapping(bytes32 slot, uint256 key) → bytes32 result

-
-

internal

-# -
-
-
- -Derive the location of a mapping element from the key. - -
-
- - - -
-
-

deriveMapping(bytes32 slot, int256 key) → bytes32 result

-
-

internal

-# -
-
-
- -Derive the location of a mapping element from the key. - -
-
- - - -
-
-

deriveMapping(bytes32 slot, string key) → bytes32 result

-
-

internal

-# -
-
-
- -Derive the location of a mapping element from the key. - -
-
- - - -
-
-

deriveMapping(bytes32 slot, bytes key) → bytes32 result

-
-

internal

-# -
-
-
- -Derive the location of a mapping element from the key. +Derive the location of a mapping element from the key.
@@ -8661,9 +8737,9 @@ Derive the location of a mapping element from the key.
-## `StorageSlot` +## `StorageSlot` - + @@ -8873,9 +8949,9 @@ Returns an `BytesSlot` representation of the bytes storage pointer `store`.
-## `Strings` +## `Strings` - + @@ -9098,7 +9174,7 @@ Requirements:
-Variant of #Strings-parseUint-string- that parses a substring of `input` located between position `begin` (included) and +Variant of `parseUint-string` that parses a substring of `input` located between position `begin` (included) and `end` (excluded). Requirements: @@ -9120,7 +9196,7 @@ Requirements:
-Variant of #Strings-parseUint-string- that returns false if the parsing fails because of an invalid character. +Variant of `parseUint-string` that returns false if the parsing fails because of an invalid character. This function will revert if the result does not fit in a `uint256`. @@ -9141,7 +9217,7 @@ This function will revert if the result does not fit in a `uint256`.
-Variant of #Strings-parseUint-string-uint256-uint256- that returns false if the parsing fails because of an invalid +Variant of `parseUint-string-uint256-uint256` that returns false if the parsing fails because of an invalid character. @@ -9184,7 +9260,7 @@ Requirements:
-Variant of #Strings-parseInt-string- that parses a substring of `input` located between position `begin` (included) and +Variant of `parseInt-string` that parses a substring of `input` located between position `begin` (included) and `end` (excluded). Requirements: @@ -9206,7 +9282,7 @@ Requirements:
-Variant of #Strings-parseInt-string- that returns false if the parsing fails because of an invalid character or if +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`. @@ -9228,7 +9304,7 @@ This function will revert if the absolute value of the result does not fit in a
-Variant of #Strings-parseInt-string-uint256-uint256- that returns false if the parsing fails because of an invalid +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`. @@ -9271,7 +9347,7 @@ Requirements:
-Variant of #Strings-parseHexUint-string- that parses a substring of `input` located between position `begin` (included) and +Variant of `parseHexUint-string` that parses a substring of `input` located between position `begin` (included) and `end` (excluded). Requirements: @@ -9293,7 +9369,7 @@ Requirements:
-Variant of #Strings-parseHexUint-string- that returns false if the parsing fails because of an invalid character. +Variant of `parseHexUint-string` that returns false if the parsing fails because of an invalid character. This function will revert if the result does not fit in a `uint256`. @@ -9314,7 +9390,7 @@ This function will revert if the result does not fit in a `uint256`.
-Variant of #Strings-parseHexUint-string-uint256-uint256- that returns false if the parsing fails because of an +Variant of `parseHexUint-string-uint256-uint256` that returns false if the parsing fails because of an invalid character. @@ -9339,7 +9415,7 @@ This function will revert if the result does not fit in a `uint256`. 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][`SafeCast.toUint240`](#SafeCast-toUint240-uint256-)` +- The string must be formatted as `(0x)?[0-9a-fA-F]`40``
@@ -9356,11 +9432,11 @@ Requirements:
-Variant of #Strings-parseAddress-string- that parses a substring of `input` located between position `begin` (included) and +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][`SafeCast.toUint240`](#SafeCast-toUint240-uint256-)` +- The substring must be formatted as `(0x)?[0-9a-fA-F]`40``
@@ -9377,8 +9453,8 @@ Requirements:
-Variant of #Strings-parseAddress-string- that returns false if the parsing fails because the input is not a properly -formatted address. See #Strings-parseAddress-string- requirements. +Variant of `parseAddress-string` that returns false if the parsing fails because the input is not a properly +formatted address. See `parseAddress-string` requirements.
@@ -9395,8 +9471,8 @@ formatted address. See #Strings-parseAddress-string- requirements.
-Variant of #Strings-parseAddress-string-uint256-uint256- that returns false if the parsing fails because input is not a properly -formatted address. See #Strings-parseAddress-string-uint256-uint256- requirements. +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.
@@ -9420,9 +9496,10 @@ This function should only be used in double quoted JSON strings. Single quotes a -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. +This function escapes backslashes (including those in \uXXXX sequences) and the characters in ranges +defined in section 2.5 of RFC-4627 (U+0000 to U+001F, U+0022 and U+005C). All control characters in U+0000 +to U+001F are escaped (\b, \t, \n, \f, \r use short form; others use \u00XX). ECMAScript's `JSON.parse` does +recover escaped unicode characters that are not in this range, but other tooling may provide different results.
@@ -9483,9 +9560,9 @@ The string being parsed is not a properly formatted address.
-## `TransientSlot` +## `TransientSlot` - + @@ -9802,9 +9879,9 @@ Store `value` at location `slot` in transient storage.
-## `InteroperableAddress` +## `InteroperableAddress` - + @@ -9874,7 +9951,7 @@ ERC-7930, including interoperable addresses with empty chain reference or empty
-Variant of #InteroperableAddress-formatV1-bytes2-bytes-bytes- specific to EVM chains. Returns the ERC-7930 interoperable +Variant of `formatV1-bytes2-bytes-bytes-` specific to EVM chains. Returns the ERC-7930 interoperable address (version 1) for a given chainid and ethereum address.
@@ -9892,7 +9969,7 @@ address (version 1) for a given chainid and ethereum address.
-Variant of #InteroperableAddress-formatV1-bytes2-bytes-bytes- that specifies an EVM chain without an address. +Variant of `formatV1-bytes2-bytes-bytes-` that specifies an EVM chain without an address.
@@ -9909,7 +9986,7 @@ Variant of #InteroperableAddress-formatV1-bytes2-bytes-bytes- that specifies an
-Variant of #InteroperableAddress-formatV1-bytes2-bytes-bytes- that specifies an EVM address without a chain reference. +Variant of `formatV1-bytes2-bytes-bytes-` that specifies an EVM address without a chain reference.
@@ -9927,7 +10004,12 @@ Variant of #InteroperableAddress-formatV1-bytes2-bytes-bytes- that specifies an
Parse a ERC-7930 interoperable address (version 1) into its different components. Reverts if the input is -not following a version 1 of ERC-7930 +not following a version 1 of ERC-7930. + + +Trailing bytes after a valid v1 encoding are ignored. The same decoded address may therefore correspond +to multiple distinct input byte strings. +
@@ -9999,6 +10081,11 @@ Variant of [`InteroperableAddress.tryParseV1`](#InteroperableAddress-tryParseV1- Parse a ERC-7930 interoperable address (version 1) corresponding to an EIP-155 chain. The `chainId` and `addr` return values will be zero if the input doesn't include a chainReference or an address, respectively. + +Trailing bytes after a valid v1 encoding are ignored. The same decoded (chainId, addr) may therefore +correspond to multiple distinct input byte strings. + + Requirements: * The input must be a valid ERC-7930 interoperable address (version 1) @@ -10093,9 +10180,9 @@ Variant of [`InteroperableAddress.tryParseEvmV1`](#InteroperableAddress-tryParse
-## `ERC165` +## `ERC165` - + @@ -10107,7 +10194,7 @@ import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; Implementation of the [`IERC165`](#IERC165) interface. -Contracts that want to implement ERC-165 should inherit from this contract and override [`AccessControl.supportsInterface`](/contracts/5.x/api/access#AccessControl-supportsInterface-bytes4-) to check +Contracts that want to implement ERC-165 should inherit from this contract and override [`ERC165.supportsInterface`](#ERC165-supportsInterface-bytes4-) to check for the additional interface id that will be supported. For example: ```solidity @@ -10150,9 +10237,9 @@ This function call must use less than 30 000 gas.
-## `ERC165Checker` +## `ERC165Checker` - + @@ -10289,9 +10376,9 @@ Interface identification is specified in ERC-165.
-## `IERC165` +## `IERC165` - + @@ -10342,9 +10429,9 @@ This function call must use less than 30 000 gas.
-## `Math` +## `Math` - + @@ -11065,9 +11152,9 @@ Counts the number of leading zero bits in a uint256.
-## `SafeCast` +## `SafeCast` - + @@ -12759,7 +12846,7 @@ Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
-Value doesn't fit in an uint of `bits` size. +Value doesn't fit in a uint of `bits` size.
@@ -12776,7 +12863,7 @@ Value doesn't fit in an uint of `bits` size.
-An int value doesn't fit in an uint of `bits` size. +An int value doesn't fit in a uint of `bits` size.
@@ -12810,7 +12897,7 @@ Value doesn't fit in an int of `bits` size.
-An uint value doesn't fit in an int of `bits` size. +A uint value doesn't fit in an int of `bits` size.
@@ -12819,9 +12906,9 @@ An uint value doesn't fit in an int of `bits` size.
-## `SignedMath` +## `SignedMath` - + @@ -12940,9 +13027,9 @@ Returns the absolute unsigned value of a signed value.
-## `Accumulators` +## `Accumulators` - + @@ -12960,14 +13047,14 @@ to existing data and performs a single memory allocation during flattening (O(n) Uses 0x00 as sentinel value for empty state (i.e. null pointers) -==== How it works +#### How it works 1. Create an empty accumulator with null head/tail pointers 2. Add data using [`RLP.push`](#RLP-push-struct-RLP-Encoder-struct-RLP-Encoder-) (append) or [`Accumulators.shift`](#Accumulators-shift-struct-Accumulators-Accumulator-Memory-Slice-) (prepend). It creates linked list nodes 3. Each node stores a reference to existing data (no copying) 4. Call [`Accumulators.flatten`](#Accumulators-flatten-struct-Accumulators-Accumulator-) to materialize the final concatenated result in a single operation -==== Performance +#### Performance * Addition: O(1) per operation (just pointer manipulation) * Flattening: O(n) single pass with one memory allocation @@ -13091,9 +13178,9 @@ Flatten all the bytes entries in an Accumulator into a single buffer
-## `BitMaps` +## `BitMaps` - + @@ -13197,9 +13284,9 @@ Unsets the bit at `index`.
-## `Checkpoints` +## `Checkpoints` - + @@ -13889,9 +13976,9 @@ A value was attempted to be inserted on a past checkpoint.
-## `CircularBuffer` +## `CircularBuffer` - + @@ -13910,6 +13997,7 @@ structure. Elements can't be removed but the data structure can be cleared. See [`CircularBuffer.clear`](#CircularBuffer-clear-struct-CircularBuffer-Bytes32CircularBuffer-). Complexity: + - insertion ([`RLP.push`](#RLP-push-struct-RLP-Encoder-struct-RLP-Encoder-)): O(1) - lookup ([`CircularBuffer.last`](#CircularBuffer-last-struct-CircularBuffer-Bytes32CircularBuffer-uint256-)): O(1) - inclusion ([`CircularBuffer.includes`](#CircularBuffer-includes-struct-CircularBuffer-Bytes32CircularBuffer-bytes32-)): O(N) (worst case) @@ -13927,9 +14015,21 @@ contract Example { // Declare a buffer storage variable CircularBuffer.Bytes32CircularBuffer private myBuffer; + + constructor() { + myBuffer.setup(16); // Initialize the buffer with a non-zero fixed size (e.g., 16) + } + + function pushValue(bytes32 value) external { + myBuffer.push(value); // Safe to push because the buffer was initialized in the constructor + } } ``` + +Make sure to call [`CircularBuffer.setup`](#CircularBuffer-setup-struct-CircularBuffer-Bytes32CircularBuffer-uint256-) on your buffer during construction/initialization + + _Available since v5.1._
@@ -14104,9 +14204,9 @@ Error emitted when trying to setup a buffer with a size of 0.
-## `DoubleEndedQueue` +## `DoubleEndedQueue` - + @@ -14131,12 +14231,19 @@ DoubleEndedQueue.Bytes32Deque queue;

Functions

- [pushBack(deque, value)](#DoubleEndedQueue-pushBack-struct-DoubleEndedQueue-Bytes32Deque-bytes32-) +- [tryPushBack(deque, value)](#DoubleEndedQueue-tryPushBack-struct-DoubleEndedQueue-Bytes32Deque-bytes32-) - [popBack(deque)](#DoubleEndedQueue-popBack-struct-DoubleEndedQueue-Bytes32Deque-) +- [tryPopBack(deque)](#DoubleEndedQueue-tryPopBack-struct-DoubleEndedQueue-Bytes32Deque-) - [pushFront(deque, value)](#DoubleEndedQueue-pushFront-struct-DoubleEndedQueue-Bytes32Deque-bytes32-) +- [tryPushFront(deque, value)](#DoubleEndedQueue-tryPushFront-struct-DoubleEndedQueue-Bytes32Deque-bytes32-) - [popFront(deque)](#DoubleEndedQueue-popFront-struct-DoubleEndedQueue-Bytes32Deque-) +- [tryPopFront(deque)](#DoubleEndedQueue-tryPopFront-struct-DoubleEndedQueue-Bytes32Deque-) - [front(deque)](#DoubleEndedQueue-front-struct-DoubleEndedQueue-Bytes32Deque-) +- [tryFront(deque)](#DoubleEndedQueue-tryFront-struct-DoubleEndedQueue-Bytes32Deque-) - [back(deque)](#DoubleEndedQueue-back-struct-DoubleEndedQueue-Bytes32Deque-) +- [tryBack(deque)](#DoubleEndedQueue-tryBack-struct-DoubleEndedQueue-Bytes32Deque-) - [at(deque, index)](#DoubleEndedQueue-at-struct-DoubleEndedQueue-Bytes32Deque-uint256-) +- [tryAt(deque, index)](#DoubleEndedQueue-tryAt-struct-DoubleEndedQueue-Bytes32Deque-uint256-) - [clear(deque)](#DoubleEndedQueue-clear-struct-DoubleEndedQueue-Bytes32Deque-) - [length(deque)](#DoubleEndedQueue-length-struct-DoubleEndedQueue-Bytes32Deque-) - [empty(deque)](#DoubleEndedQueue-empty-struct-DoubleEndedQueue-Bytes32Deque-) @@ -14162,68 +14269,145 @@ Reverts with [`Panic.RESOURCE_ERROR`](#Panic-RESOURCE_ERROR-uint256) if the queu
- +
-

popBack(struct DoubleEndedQueue.Bytes32Deque deque) → bytes32 value

+

tryPushBack(struct DoubleEndedQueue.Bytes32Deque deque, bytes32 value) → bool success

internal

-# +#
-Removes the item at the end of the queue and returns it. +Attempts to insert an item at the end of the queue. -Reverts with [`Panic.EMPTY_ARRAY_POP`](#Panic-EMPTY_ARRAY_POP-uint256) if the queue is empty. +Returns `false` if the queue is full. Never reverts.
- +
-

pushFront(struct DoubleEndedQueue.Bytes32Deque deque, bytes32 value)

+

popBack(struct DoubleEndedQueue.Bytes32Deque deque) → bytes32

internal

-# +#
-Inserts an item at the beginning of the queue. +Removes the item at the end of the queue and returns it. -Reverts with [`Panic.RESOURCE_ERROR`](#Panic-RESOURCE_ERROR-uint256) if the queue is full. +Reverts with [`Panic.EMPTY_ARRAY_POP`](#Panic-EMPTY_ARRAY_POP-uint256) if the queue is empty.
- +
-

popFront(struct DoubleEndedQueue.Bytes32Deque deque) → bytes32 value

+

tryPopBack(struct DoubleEndedQueue.Bytes32Deque deque) → bool success, bytes32 value

internal

-# +#
-Removes the item at the beginning of the queue and returns it. +Attempts to remove the item at the end of the queue and return it. + +Returns `(false, 0x00)` if the queue is empty. Never reverts. + +
+
+ + + +
+
+

pushFront(struct DoubleEndedQueue.Bytes32Deque deque, bytes32 value)

+
+

internal

+# +
+
+
+ +Inserts an item at the beginning of the queue. + +Reverts with [`Panic.RESOURCE_ERROR`](#Panic-RESOURCE_ERROR-uint256) if the queue is full. + +
+
+ + + +
+
+

tryPushFront(struct DoubleEndedQueue.Bytes32Deque deque, bytes32 value) → bool success

+
+

internal

+# +
+
+
+ +Attempts to insert an item at the beginning of the queue. + +Returns `false` if the queue is full. Never reverts. + +
+
+ + + +
+
+

popFront(struct DoubleEndedQueue.Bytes32Deque deque) → bytes32

+
+

internal

+# +
+
+
+ +Removes the item at the beginning of the queue and returns it. Reverts with [`Panic.EMPTY_ARRAY_POP`](#Panic-EMPTY_ARRAY_POP-uint256) if the queue is empty.
+ + +
+
+

tryPopFront(struct DoubleEndedQueue.Bytes32Deque deque) → bool success, bytes32 value

+
+

internal

+# +
+
+
+ +Attempts to remove the item at the beginning of the queue and +return it. + +Returns `(false, 0x00)` if the queue is empty. Never reverts. + +
+
+
-

front(struct DoubleEndedQueue.Bytes32Deque deque) → bytes32 value

+

front(struct DoubleEndedQueue.Bytes32Deque deque) → bytes32

internal

# @@ -14238,11 +14422,30 @@ Reverts with [`Panic.ARRAY_OUT_OF_BOUNDS`](#Panic-ARRAY_OUT_OF_BOUNDS-uint256) i
+ + +
+
+

tryFront(struct DoubleEndedQueue.Bytes32Deque deque) → bool success, bytes32 value

+
+

internal

+# +
+
+
+ +Attempts to return the item at the beginning of the queue. + +Returns `(false, 0x00)` if the queue is empty. Never reverts. + +
+
+
-

back(struct DoubleEndedQueue.Bytes32Deque deque) → bytes32 value

+

back(struct DoubleEndedQueue.Bytes32Deque deque) → bytes32

internal

# @@ -14257,11 +14460,30 @@ Reverts with [`Panic.ARRAY_OUT_OF_BOUNDS`](#Panic-ARRAY_OUT_OF_BOUNDS-uint256) i
+ + +
+
+

tryBack(struct DoubleEndedQueue.Bytes32Deque deque) → bool success, bytes32 value

+
+

internal

+# +
+
+
+ +Attempts to return the item at the end of the queue. + +Returns `(false, 0x00)` if the queue is empty. Never reverts. + +
+
+
-

at(struct DoubleEndedQueue.Bytes32Deque deque, uint256 index) → bytes32 value

+

at(struct DoubleEndedQueue.Bytes32Deque deque, uint256 index) → bytes32

internal

# @@ -14277,6 +14499,26 @@ Reverts with [`Panic.ARRAY_OUT_OF_BOUNDS`](#Panic-ARRAY_OUT_OF_BOUNDS-uint256) i
+ + +
+
+

tryAt(struct DoubleEndedQueue.Bytes32Deque deque, uint256 index) → bool success, bytes32 value

+
+

internal

+# +
+
+
+ +Attempts to return the item at a position in the queue given by `index`, with the first item at +0 and the last item at `length(deque) - 1`. + +Returns `(false, 0x00)` if the index is out of bounds. Never reverts. + +
+
+
@@ -14337,9 +14579,9 @@ Returns true if the queue is empty.
-## `EnumerableMap` +## `EnumerableMap` - + @@ -14382,15 +14624,15 @@ The following map types are supported: - `address -> bytes32` (`AddressToBytes32Map`) since v5.1.0 - `bytes32 -> address` (`Bytes32ToAddressMap`) since v5.1.0 - `bytes -> bytes` (`BytesToBytesMap`) since v5.4.0 +- `bytes4 -> address` (`Bytes4ToAddressMap`) since v5.6.0 - -Trying to delete such a structure from storage will likely result in data corruption, rendering the structure +[WARNING] +#### Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable. See [ethereum/solidity#11843](https://github.com/ethereum/solidity/pull/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

@@ -14485,6 +14727,16 @@ array of EnumerableMap. - [get(map, key)](#EnumerableMap-get-struct-EnumerableMap-Bytes32ToAddressMap-bytes32-) - [keys(map)](#EnumerableMap-keys-struct-EnumerableMap-Bytes32ToAddressMap-) - [keys(map, start, end)](#EnumerableMap-keys-struct-EnumerableMap-Bytes32ToAddressMap-uint256-uint256-) +- [set(map, key, value)](#EnumerableMap-set-struct-EnumerableMap-Bytes4ToAddressMap-bytes4-address-) +- [remove(map, key)](#EnumerableMap-remove-struct-EnumerableMap-Bytes4ToAddressMap-bytes4-) +- [clear(map)](#EnumerableMap-clear-struct-EnumerableMap-Bytes4ToAddressMap-) +- [contains(map, key)](#EnumerableMap-contains-struct-EnumerableMap-Bytes4ToAddressMap-bytes4-) +- [length(map)](#EnumerableMap-length-struct-EnumerableMap-Bytes4ToAddressMap-) +- [at(map, index)](#EnumerableMap-at-struct-EnumerableMap-Bytes4ToAddressMap-uint256-) +- [tryGet(map, key)](#EnumerableMap-tryGet-struct-EnumerableMap-Bytes4ToAddressMap-bytes4-) +- [get(map, key)](#EnumerableMap-get-struct-EnumerableMap-Bytes4ToAddressMap-bytes4-) +- [keys(map)](#EnumerableMap-keys-struct-EnumerableMap-Bytes4ToAddressMap-) +- [keys(map, start, end)](#EnumerableMap-keys-struct-EnumerableMap-Bytes4ToAddressMap-uint256-uint256-) - [set(map, key, value)](#EnumerableMap-set-struct-EnumerableMap-BytesToBytesMap-bytes-bytes-) - [remove(map, key)](#EnumerableMap-remove-struct-EnumerableMap-BytesToBytesMap-bytes-) - [clear(map)](#EnumerableMap-clear-struct-EnumerableMap-BytesToBytesMap-) @@ -16369,14 +16621,14 @@ uncallable if the map grows to a point where copying to memory consumes too much
- +
-

set(struct EnumerableMap.BytesToBytesMap map, bytes key, bytes value) → bool

+

set(struct EnumerableMap.Bytes4ToAddressMap map, bytes4 key, address value) → bool

internal

-# +#
@@ -16390,33 +16642,33 @@ already present.
- +
-

remove(struct EnumerableMap.BytesToBytesMap map, bytes key) → bool

+

remove(struct EnumerableMap.Bytes4ToAddressMap map, bytes4 key) → bool

internal

-# +#
-Removes a key-value pair from a map. O(1). +Removes a value from a map. O(1). Returns true if the key was removed from the map, that is if it was present.
- +
-

clear(struct EnumerableMap.BytesToBytesMap map)

+

clear(struct EnumerableMap.Bytes4ToAddressMap map)

internal

-# +#
@@ -16424,21 +16676,22 @@ Returns true if the key was removed from the map, that is if it was present. Removes all the entries from a map. O(n). -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. +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.
- +
-

contains(struct EnumerableMap.BytesToBytesMap map, bytes key) → bool

+

contains(struct EnumerableMap.Bytes4ToAddressMap map, bytes4 key) → bool

internal

-# +#
@@ -16448,39 +16701,38 @@ Returns true if the key is in the map. O(1).
- +
-

length(struct EnumerableMap.BytesToBytesMap map) → uint256

+

length(struct EnumerableMap.Bytes4ToAddressMap map) → uint256

internal

-# +#
-Returns the number of key-value pairs in the map. O(1). +Returns the number of elements in the map. O(1).
- +
-

at(struct EnumerableMap.BytesToBytesMap map, uint256 index) → bytes key, bytes value

+

at(struct EnumerableMap.Bytes4ToAddressMap map, uint256 index) → bytes4 key, address value

internal

-# +#
-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. +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: @@ -16489,14 +16741,14 @@ Requirements:
- +
-

tryGet(struct EnumerableMap.BytesToBytesMap map, bytes key) → bool exists, bytes value

+

tryGet(struct EnumerableMap.Bytes4ToAddressMap map, bytes4 key) → bool exists, address value

internal

-# +#
@@ -16507,14 +16759,14 @@ Does not revert if `key` is not in the map.
- +
-

get(struct EnumerableMap.BytesToBytesMap map, bytes key) → bytes value

+

get(struct EnumerableMap.Bytes4ToAddressMap map, bytes4 key) → address

internal

-# +#
@@ -16528,14 +16780,14 @@ Requirements:
- +
-

keys(struct EnumerableMap.BytesToBytesMap map) → bytes[]

+

keys(struct EnumerableMap.Bytes4ToAddressMap map) → bytes4[]

internal

-# +#
@@ -16552,14 +16804,14 @@ uncallable if the map grows to a point where copying to memory consumes too much
- +
-

keys(struct EnumerableMap.BytesToBytesMap map, uint256 start, uint256 end) → bytes[]

+

keys(struct EnumerableMap.Bytes4ToAddressMap map, uint256 start, uint256 end) → bytes4[]

internal

-# +#
@@ -16576,94 +16828,301 @@ uncallable if the map grows to a point where copying to memory consumes too much
- +
-

EnumerableMapNonexistentKey(bytes32 key)

+

set(struct EnumerableMap.BytesToBytesMap map, bytes key, bytes value) → bool

-

error

-# +

internal

+#
-Query for a nonexistent map key. +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.
- +
-

EnumerableMapNonexistentBytesKey(bytes key)

+

remove(struct EnumerableMap.BytesToBytesMap map, bytes key) → bool

-

error

-# +

internal

+#
-Query for a nonexistent map key. +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.
- + -
+
+
+

clear(struct EnumerableMap.BytesToBytesMap map)

+
+

internal

+# +
+
+
-## `EnumerableSet` +Removes all the entries from a map. O(n). - - - + +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. + +
-```solidity -import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; -``` + -Library for managing -[sets](https://en.wikipedia.org/wiki/Set_(abstract_data_type)) of primitive -types. +
+
+

contains(struct EnumerableMap.BytesToBytesMap map, bytes key) → bool

+
+

internal

+# +
+
+
-Sets have the following properties: +Returns true if the key is in the map. O(1). -- 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). +
+
-```solidity -contract Example { - // Add the library methods - using EnumerableSet for EnumerableSet.AddressSet; + - // Declare a set state variable - EnumerableSet.AddressSet private mySet; -} -``` +
+
+

length(struct EnumerableMap.BytesToBytesMap map) → uint256

+
+

internal

+# +
+
+
-The following types are supported: +Returns the number of key-value pairs in the map. O(1). -- `bytes32` (`Bytes32Set`) since v3.3.0 -- `address` (`AddressSet`) since v3.3.0 -- `uint256` (`UintSet`) since v3.3.0 -- `string` (`StringSet`) since v5.4.0 -- `bytes` (`BytesSet`) since v5.4.0 +
+
- -Trying to delete such a structure from storage will likely result in data corruption, rendering the structure -unusable. -See [ethereum/solidity#11843](https://github.com/ethereum/solidity/pull/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. +
+
+

at(struct EnumerableMap.BytesToBytesMap map, uint256 index) → bytes key, bytes value

+
+

internal

+# +
+
+
+ +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: + +- `index` must be strictly less than [`Memory.length`](#Memory-length-Memory-Slice-). + +
+
+ + + +
+
+

tryGet(struct EnumerableMap.BytesToBytesMap map, bytes key) → bool exists, bytes value

+
+

internal

+# +
+
+
+ +Tries to return the value associated with `key`. O(1). +Does not revert if `key` is not in the map. + +
+
+ + + +
+
+

get(struct EnumerableMap.BytesToBytesMap map, bytes key) → bytes value

+
+

internal

+# +
+
+
+ +Returns the value associated with `key`. O(1). + +Requirements: + +- `key` must be in the map. + +
+
+ + + +
+
+

keys(struct EnumerableMap.BytesToBytesMap map) → bytes[]

+
+

internal

+# +
+
+
+ +Returns an array containing all the keys + + +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. + + +
+
+ + + +
+
+

keys(struct EnumerableMap.BytesToBytesMap map, uint256 start, uint256 end) → bytes[]

+
+

internal

+# +
+
+
+ +Returns an array containing a slice of the keys + + +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. +
+
+ + + +
+
+

EnumerableMapNonexistentKey(bytes32 key)

+
+

error

+# +
+
+
+ +Query for a nonexistent map key. + +
+
+ + + +
+
+

EnumerableMapNonexistentBytesKey(bytes key)

+
+

error

+# +
+
+
+ +Query for a nonexistent map key. + +
+
+ + + +
+ +## `EnumerableSet` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; +``` + +Library for managing +[sets](https://en.wikipedia.org/wiki/Set_(abstract_data_type)) 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). + +```solidity +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.0 +- `address` (`AddressSet`) since v3.3.0 +- `uint256` (`UintSet`) since v3.3.0 +- `string` (`StringSet`) since v5.4.0 +- `bytes` (`BytesSet`) since v5.4.0 +- `bytes4` (`Bytes4Set`) since v5.6.0 + +[WARNING] +#### Trying to delete such a structure from storage will likely result in data corruption, rendering the structure +unusable. +See [ethereum/solidity#11843](https://github.com/ethereum/solidity/pull/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

@@ -16675,6 +17134,14 @@ array of EnumerableSet. - [at(set, index)](#EnumerableSet-at-struct-EnumerableSet-Bytes32Set-uint256-) - [values(set)](#EnumerableSet-values-struct-EnumerableSet-Bytes32Set-) - [values(set, start, end)](#EnumerableSet-values-struct-EnumerableSet-Bytes32Set-uint256-uint256-) +- [add(set, value)](#EnumerableSet-add-struct-EnumerableSet-Bytes4Set-bytes4-) +- [remove(set, value)](#EnumerableSet-remove-struct-EnumerableSet-Bytes4Set-bytes4-) +- [clear(set)](#EnumerableSet-clear-struct-EnumerableSet-Bytes4Set-) +- [contains(set, value)](#EnumerableSet-contains-struct-EnumerableSet-Bytes4Set-bytes4-) +- [length(set)](#EnumerableSet-length-struct-EnumerableSet-Bytes4Set-) +- [at(set, index)](#EnumerableSet-at-struct-EnumerableSet-Bytes4Set-uint256-) +- [values(set)](#EnumerableSet-values-struct-EnumerableSet-Bytes4Set-) +- [values(set, start, end)](#EnumerableSet-values-struct-EnumerableSet-Bytes4Set-uint256-uint256-) - [add(set, value)](#EnumerableSet-add-struct-EnumerableSet-AddressSet-address-) - [remove(set, value)](#EnumerableSet-remove-struct-EnumerableSet-AddressSet-address-) - [clear(set)](#EnumerableSet-clear-struct-EnumerableSet-AddressSet-) @@ -16878,14 +17345,14 @@ uncallable if the set grows to a point where copying to memory consumes too much
- +
-

add(struct EnumerableSet.AddressSet set, address value) → bool

+

add(struct EnumerableSet.Bytes4Set set, bytes4 value) → bool

internal

-# +#
@@ -16898,14 +17365,14 @@ already present.
- +
-

remove(struct EnumerableSet.AddressSet set, address value) → bool

+

remove(struct EnumerableSet.Bytes4Set set, bytes4 value) → bool

internal

-# +#
@@ -16918,14 +17385,14 @@ present.
- +
-

clear(struct EnumerableSet.AddressSet set)

+

clear(struct EnumerableSet.Bytes4Set set)

internal

-# +#
@@ -16940,14 +17407,14 @@ function uncallable if the set grows to the point where clearing it consumes too
- +
-

contains(struct EnumerableSet.AddressSet set, address value) → bool

+

contains(struct EnumerableSet.Bytes4Set set, bytes4 value) → bool

internal

-# +#
@@ -16957,14 +17424,14 @@ Returns true if the value is in the set. O(1).
- +
-

length(struct EnumerableSet.AddressSet set) → uint256

+

length(struct EnumerableSet.Bytes4Set set) → uint256

internal

-# +#
@@ -16974,14 +17441,14 @@ Returns the number of values in the set. O(1).
- +
-

at(struct EnumerableSet.AddressSet set, uint256 index) → address

+

at(struct EnumerableSet.Bytes4Set set, uint256 index) → bytes4

internal

-# +#
@@ -16998,14 +17465,14 @@ Requirements:
- +
-

values(struct EnumerableSet.AddressSet set) → address[]

+

values(struct EnumerableSet.Bytes4Set set) → bytes4[]

internal

-# +#
@@ -17022,14 +17489,14 @@ uncallable if the set grows to a point where copying to memory consumes too much
- +
-

values(struct EnumerableSet.AddressSet set, uint256 start, uint256 end) → address[]

+

values(struct EnumerableSet.Bytes4Set set, uint256 start, uint256 end) → bytes4[]

internal

-# +#
@@ -17046,14 +17513,14 @@ uncallable if the set grows to a point where copying to memory consumes too much
- +
-

add(struct EnumerableSet.UintSet set, uint256 value) → bool

+

add(struct EnumerableSet.AddressSet set, address value) → bool

internal

-# +#
@@ -17066,14 +17533,14 @@ already present.
- +
-

remove(struct EnumerableSet.UintSet set, uint256 value) → bool

+

remove(struct EnumerableSet.AddressSet set, address value) → bool

internal

-# +#
@@ -17086,14 +17553,14 @@ present.
- +
-

clear(struct EnumerableSet.UintSet set)

+

clear(struct EnumerableSet.AddressSet set)

internal

-# +#
@@ -17108,14 +17575,14 @@ function uncallable if the set grows to the point where clearing it consumes too
- +
-

contains(struct EnumerableSet.UintSet set, uint256 value) → bool

+

contains(struct EnumerableSet.AddressSet set, address value) → bool

internal

-# +#
@@ -17125,14 +17592,14 @@ Returns true if the value is in the set. O(1).
- +
-

length(struct EnumerableSet.UintSet set) → uint256

+

length(struct EnumerableSet.AddressSet set) → uint256

internal

-# +#
@@ -17142,14 +17609,14 @@ Returns the number of values in the set. O(1).
- +
-

at(struct EnumerableSet.UintSet set, uint256 index) → uint256

+

at(struct EnumerableSet.AddressSet set, uint256 index) → address

internal

-# +#
@@ -17166,14 +17633,182 @@ Requirements:
- +
-

values(struct EnumerableSet.UintSet set) → uint256[]

+

values(struct EnumerableSet.AddressSet set) → address[]

internal

-# +# +
+
+
+ +Return the entire set in an array + + +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. + + +
+
+ + + +
+
+

values(struct EnumerableSet.AddressSet set, uint256 start, uint256 end) → address[]

+
+

internal

+# +
+
+
+ +Return a slice of the set in an array + + +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. + + +
+
+ + + +
+
+

add(struct EnumerableSet.UintSet set, uint256 value) → bool

+
+

internal

+# +
+
+
+ +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. + +
+
+ + + +
+
+

remove(struct EnumerableSet.UintSet set, uint256 value) → bool

+
+

internal

+# +
+
+
+ +Removes a value from a set. O(1). + +Returns true if the value was removed from the set, that is if it was +present. + +
+
+ + + +
+
+

clear(struct EnumerableSet.UintSet set)

+
+

internal

+# +
+
+
+ +Removes all the values from a set. O(n). + + +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. + + +
+
+ + + +
+
+

contains(struct EnumerableSet.UintSet set, uint256 value) → bool

+
+

internal

+# +
+
+
+ +Returns true if the value is in the set. O(1). + +
+
+ + + +
+
+

length(struct EnumerableSet.UintSet set) → uint256

+
+

internal

+# +
+
+
+ +Returns the number of values in the set. O(1). + +
+
+ + + +
+
+

at(struct EnumerableSet.UintSet set, uint256 index) → uint256

+
+

internal

+# +
+
+
+ +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: + +- `index` must be strictly less than [`Memory.length`](#Memory-length-Memory-Slice-). + +
+
+ + + +
+
+

values(struct EnumerableSet.UintSet set) → uint256[]

+
+

internal

+#
@@ -17554,9 +18189,9 @@ uncallable if the set grows to a point where copying to memory consumes too much
-## `Heap` +## `Heap` - + @@ -17573,9 +18208,10 @@ Heaps are represented as a tree of values where the first element (index 0) is t index i is the child of the node at index (i-1)/2 and the parent of nodes at index 2*i+1 and 2*i+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 ordered so that, per the comparator, each node has lower priority than its parent; as a +consequence, the highest-priority value is at the root. This value can be looked up in constant time (O(1)) at +`heap.tree[0]`. By default, the comparator is `Comparators.lt`, which treats smaller values as higher priority +(min-heap). Using `Comparators.gt` yields a max-heap. The structure is designed to perform the following operations with the corresponding complexities: @@ -17798,9 +18434,9 @@ Removes all elements in the heap.
-## `MerkleTree` +## `MerkleTree` - + @@ -18066,9 +18702,9 @@ Error emitted when the proof used during an update is invalid (could not reprodu
-## `Time` +## `Time` - + @@ -18240,3 +18876,331 @@ pack the components into a Delay object.
+ + + +
+ +## `ReentrancyGuard` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; +``` + +Contract module that helps prevent reentrant calls to a function. + +Inheriting from `ReentrancyGuard` will make the [`ReentrancyGuard.nonReentrant`](#ReentrancyGuard-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. + + +If EIP-1153 (transient storage) is available on the chain you're deploying at, +consider using [`ReentrancyGuardTransient`](#ReentrancyGuardTransient) instead. + + + +If you would like to learn more about reentrancy and alternative ways +to protect against it, check out our blog post +[Reentrancy After Istanbul](https://blog.openzeppelin.com/reentrancy-after-istanbul/). + + + +Deprecated. This storage-based reentrancy guard will be removed and replaced +by the [`ReentrancyGuardTransient`](#ReentrancyGuardTransient) variant in v6.0. + + +@custom:stateless + +
+

Modifiers

+
+- [nonReentrant()](#ReentrancyGuard-nonReentrant--) +- [nonReentrantView()](#ReentrancyGuard-nonReentrantView--) +
+
+ +
+

Functions

+
+- [constructor()](#ReentrancyGuard-constructor--) +- [_reentrancyGuardEntered()](#ReentrancyGuard-_reentrancyGuardEntered--) +- [_reentrancyGuardStorageSlot()](#ReentrancyGuard-_reentrancyGuardStorageSlot--) +
+
+ +
+

Errors

+
+- [ReentrancyGuardReentrantCall()](#ReentrancyGuard-ReentrancyGuardReentrantCall--) +
+
+ + + +
+
+

nonReentrant()

+
+

internal

+# +
+
+ +
+ +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. + +
+
+ + + +
+
+

nonReentrantView()

+
+

internal

+# +
+
+ +
+ +A `view` only version of [`ReentrancyGuard.nonReentrant`](#ReentrancyGuard-nonReentrant--). Use to block view functions +from being called, preventing reading from inconsistent contract state. + + +This is a "view" modifier and does not change the reentrancy +status. Use it only on view functions. For payable or non-payable functions, +use the standard [`ReentrancyGuard.nonReentrant`](#ReentrancyGuard-nonReentrant--) modifier instead. + + +
+
+ + + +
+
+

constructor()

+
+

internal

+# +
+
+
+ +
+
+ + + +
+
+

_reentrancyGuardEntered() → bool

+
+

internal

+# +
+
+
+ +Returns true if the reentrancy guard is currently set to "entered", which indicates there is a +`nonReentrant` function in the call stack. + +
+
+ + + +
+
+

_reentrancyGuardStorageSlot() → bytes32

+
+

internal

+# +
+
+
+ +
+
+ + + +
+
+

ReentrancyGuardReentrantCall()

+
+

error

+# +
+
+
+ +Unauthorized reentrant call. + +
+
+ + + +
+ +## `ReentrancyGuardTransient` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/utils/ReentrancyGuardTransient.sol"; +``` + +Variant of [`ReentrancyGuard`](#ReentrancyGuard) that uses transient storage. + + +This variant only works on networks where EIP-1153 is available. + + +_Available since v5.1._ + +@custom:stateless + +
+

Modifiers

+
+- [nonReentrant()](#ReentrancyGuardTransient-nonReentrant--) +- [nonReentrantView()](#ReentrancyGuardTransient-nonReentrantView--) +
+
+ +
+

Functions

+
+- [_reentrancyGuardEntered()](#ReentrancyGuardTransient-_reentrancyGuardEntered--) +- [_reentrancyGuardStorageSlot()](#ReentrancyGuardTransient-_reentrancyGuardStorageSlot--) +
+
+ +
+

Errors

+
+- [ReentrancyGuardReentrantCall()](#ReentrancyGuardTransient-ReentrancyGuardReentrantCall--) +
+
+ + + +
+
+

nonReentrant()

+
+

internal

+# +
+
+ +
+ +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. + +
+
+ + + +
+
+

nonReentrantView()

+
+

internal

+# +
+
+ +
+ +A `view` only version of [`ReentrancyGuard.nonReentrant`](#ReentrancyGuard-nonReentrant--). Use to block view functions +from being called, preventing reading from inconsistent contract state. + + +This is a "view" modifier and does not change the reentrancy +status. Use it only on view functions. For payable or non-payable functions, +use the standard [`ReentrancyGuard.nonReentrant`](#ReentrancyGuard-nonReentrant--) modifier instead. + + +
+
+ + + +
+
+

_reentrancyGuardEntered() → bool

+
+

internal

+# +
+
+
+ +Returns true if the reentrancy guard is currently set to "entered", which indicates there is a +`nonReentrant` function in the call stack. + +
+
+ + + +
+
+

_reentrancyGuardStorageSlot() → bytes32

+
+

internal

+# +
+
+
+ +
+
+ + + +
+
+

ReentrancyGuardReentrantCall()

+
+

error

+# +
+
+
+ +Unauthorized reentrant call. + +
+
+ diff --git a/content/contracts/5.x/api/utils/cryptography.mdx b/content/contracts/5.x/api/utils/cryptography.mdx index 13e43174..0f812237 100644 --- a/content/contracts/5.x/api/utils/cryptography.mdx +++ b/content/contracts/5.x/api/utils/cryptography.mdx @@ -11,6 +11,7 @@ A collection of contracts and libraries that implement various signature validat * [`SignatureChecker`](#SignatureChecker): A library helper to support regular ECDSA from EOAs as well as ERC-1271 signatures for smart contracts. * [`Hashes`](#Hashes): Commonly used hash functions. * [`MerkleProof`](#MerkleProof): Functions for verifying [Merkle Tree](https://en.wikipedia.org/wiki/Merkle_tree) proofs. +* [`TrieProof`](#TrieProof): Library for verifying Ethereum Merkle-Patricia trie inclusion proofs. * [`EIP712`](#EIP712): Contract with functions to allow processing signed typed structure data according to [EIP-712](https://eips.ethereum.org/EIPS/eip-712). * [`ERC7739Utils`](#ERC7739Utils): Utilities library that implements a defensive rehashing mechanism to prevent replayability of smart contract signatures based on ERC-7739. * [`WebAuthn`](#WebAuthn): Library for verifying WebAuthn Authentication Assertions. @@ -38,6 +39,8 @@ A collection of contracts and libraries that implement various signature validat [`MerkleProof`](#MerkleProof) +[`TrieProof`](#TrieProof) + [`EIP712`](#EIP712) [`ERC7739Utils`](#ERC7739Utils) @@ -76,9 +79,9 @@ A collection of contracts and libraries that implement various signature validat
-## `ECDSA` +## `ECDSA` - + @@ -263,7 +266,7 @@ See [ERC-2098 short signatures](https://eips.ethereum.org/EIPS/eip-2098)
-Overload of [`ECDSA.recover`](#ECDSA-recover-bytes32-uint8-bytes32-bytes32-) that receives the `r and `vs` short-signature fields separately. +Overload of [`ECDSA.recover`](#ECDSA-recover-bytes32-uint8-bytes32-bytes32-) that receives the `r` and `vs` short-signature fields separately.
@@ -339,7 +342,7 @@ Consider validating the result before use, or use [`ECDSA.tryRecover`](#ECDSA-tr
-Variant of [`CAIP10.parse`](#CAIP10-parse-string-) that takes a signature in calldata +Variant of [`ECDSA.parse`](#ECDSA-parse-bytes-) that takes a signature in calldata
@@ -356,7 +359,7 @@ Variant of [`CAIP10.parse`](#CAIP10-parse-string-) that takes a signature in cal
-The signature derives the `address(0)`. +The signature is invalid.
@@ -399,9 +402,9 @@ The signature has an S value that is in the upper half order.
-## `EIP712` +## `EIP712` - + @@ -478,7 +481,8 @@ The meaning of `name` and `version` is specified in - `version`: the current major version of the signing domain. -These parameters cannot be changed except through a [smart contract upgrade](/contracts/5.x/learn/upgrading-smart-contracts). +These parameters cannot be changed except through a [smart +contract upgrade](/contracts/5.x/learn/upgrading-smart-contracts).
@@ -596,9 +600,9 @@ It only reads from storage if necessary (in case the value is too large to fit i
-## `Hashes` +## `Hashes` - + @@ -662,9 +666,9 @@ Implementation of keccak256(abi.encode(a, b)) that doesn't allocate or expand me
-## `MerkleProof` +## `MerkleProof` - + @@ -923,7 +927,9 @@ Returns true if the `leaves` can be simultaneously proven to be a part of a Merk This version handles multiproofs in memory with the default hashing function. -CAUTION: Not all Merkle trees admit multiproofs. See [`MerkleProof.processMultiProof`](#MerkleProof-processMultiProof-bytes32---bool---bytes32---function--bytes32-bytes32--view-returns--bytes32--) for details. + +Not all Merkle trees admit multiproofs. See [`MerkleProof.processMultiProof`](#MerkleProof-processMultiProof-bytes32---bool---bytes32---function--bytes32-bytes32--view-returns--bytes32--) for details. + Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`. @@ -952,9 +958,11 @@ 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 + +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). + The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op, @@ -982,7 +990,9 @@ Returns true if the `leaves` can be simultaneously proven to be a part of a Merk This version handles multiproofs in memory with a custom hashing function. -CAUTION: Not all Merkle trees admit multiproofs. See [`MerkleProof.processMultiProof`](#MerkleProof-processMultiProof-bytes32---bool---bytes32---function--bytes32-bytes32--view-returns--bytes32--) for details. + +Not all Merkle trees admit multiproofs. See [`MerkleProof.processMultiProof`](#MerkleProof-processMultiProof-bytes32---bool---bytes32---function--bytes32-bytes32--view-returns--bytes32--) for details. + Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`. @@ -1011,9 +1021,11 @@ 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 + +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). + The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op, @@ -1041,7 +1053,9 @@ Returns true if the `leaves` can be simultaneously proven to be a part of a Merk This version handles multiproofs in calldata with the default hashing function. -CAUTION: Not all Merkle trees admit multiproofs. See [`MerkleProof.processMultiProof`](#MerkleProof-processMultiProof-bytes32---bool---bytes32---function--bytes32-bytes32--view-returns--bytes32--) for details. + +Not all Merkle trees admit multiproofs. See [`MerkleProof.processMultiProof`](#MerkleProof-processMultiProof-bytes32---bool---bytes32---function--bytes32-bytes32--view-returns--bytes32--) for details. + Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`. @@ -1070,9 +1084,11 @@ 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 + +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). + The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op, @@ -1100,7 +1116,9 @@ Returns true if the `leaves` can be simultaneously proven to be a part of a Merk This version handles multiproofs in calldata with a custom hashing function. -CAUTION: Not all Merkle trees admit multiproofs. See [`MerkleProof.processMultiProof`](#MerkleProof-processMultiProof-bytes32---bool---bytes32---function--bytes32-bytes32--view-returns--bytes32--) for details. + +Not all Merkle trees admit multiproofs. See [`MerkleProof.processMultiProof`](#MerkleProof-processMultiProof-bytes32---bool---bytes32---function--bytes32-bytes32--view-returns--bytes32--) for details. + Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`. @@ -1129,9 +1147,11 @@ 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 + +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). + The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op, @@ -1163,9 +1183,9 @@ The multiproof provided is not valid.
-## `MessageHashUtils` +## `MessageHashUtils` - + @@ -1189,6 +1209,16 @@ specifications. - [toDataWithIntendedValidatorHash(validator, data)](#MessageHashUtils-toDataWithIntendedValidatorHash-address-bytes-) - [toDataWithIntendedValidatorHash(validator, messageHash)](#MessageHashUtils-toDataWithIntendedValidatorHash-address-bytes32-) - [toTypedDataHash(domainSeparator, structHash)](#MessageHashUtils-toTypedDataHash-bytes32-bytes32-) +- [toDomainSeparator(fields, name, version, chainId, verifyingContract, salt)](#MessageHashUtils-toDomainSeparator-bytes1-string-string-uint256-address-bytes32-) +- [toDomainSeparator(fields, nameHash, versionHash, chainId, verifyingContract, salt)](#MessageHashUtils-toDomainSeparator-bytes1-bytes32-bytes32-uint256-address-bytes32-) +- [toDomainTypeHash(fields)](#MessageHashUtils-toDomainTypeHash-bytes1-) +
+
+ +
+

Errors

+
+- [ERC5267ExtensionsNotSupported()](#MessageHashUtils-ERC5267ExtensionsNotSupported--)
@@ -1281,7 +1311,7 @@ See [`ECDSA.recover`](#ECDSA-recover-bytes32-uint8-bytes32-bytes32-).
-Variant of #MessageHashUtils-toDataWithIntendedValidatorHash-address-bytes- optimized for cases where `data` is a bytes32. +Variant of `toDataWithIntendedValidatorHash-address-bytes` optimized for cases where `data` is a bytes32.
@@ -1309,13 +1339,91 @@ See [`ECDSA.recover`](#ECDSA-recover-bytes32-uint8-bytes32-bytes32-).
+ + +
+
+

toDomainSeparator(bytes1 fields, string name, string version, uint256 chainId, address verifyingContract, bytes32 salt) → bytes32 hash

+
+

internal

+# +
+
+
+ +Returns the EIP-712 domain separator constructed from an `eip712Domain`. See [`IERC5267.eip712Domain`](/contracts/5.x/api/interfaces#IERC5267-eip712Domain--) + +This function dynamically constructs the domain separator based on which fields are present in the +`fields` parameter. It contains flags that indicate which domain fields are present: + +* Bit 0 (0x01): name +* Bit 1 (0x02): version +* Bit 2 (0x04): chainId +* Bit 3 (0x08): verifyingContract +* Bit 4 (0x10): salt + +Arguments that correspond to fields which are not present in `fields` are ignored. For example, if `fields` is +`0x0f` (`0b01111`), then the `salt` parameter is ignored. + +
+
+ + + +
+
+

toDomainSeparator(bytes1 fields, bytes32 nameHash, bytes32 versionHash, uint256 chainId, address verifyingContract, bytes32 salt) → bytes32 hash

+
+

internal

+# +
+
+
+ +Variant of `toDomainSeparator-bytes1-string-string-uint256-address-bytes32` that uses hashed name and version. + +
+
+ + + +
+
+

toDomainTypeHash(bytes1 fields) → bytes32 hash

+
+

internal

+# +
+
+
+ +Builds an EIP-712 domain type hash depending on the `fields` provided, following [ERC-5267](https://eips.ethereum.org/EIPS/eip-5267) + +
+
+ + + +
+
+

ERC5267ExtensionsNotSupported()

+
+

error

+# +
+
+
+ +
+
+
-## `P256` +## `P256` - + @@ -1379,7 +1487,7 @@ bytecode.
-Same as [`IERC7913SignatureVerifier.verify`](../interfaces#IERC7913SignatureVerifier-verify-bytes-bytes32-bytes-), but it will revert if the required precompile is not available. +Same as [`MerkleProof.verify`](#MerkleProof-verify-bytes32---bytes32-bytes32-function--bytes32-bytes32--view-returns--bytes32--), 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. @@ -1399,7 +1507,7 @@ otherwise the returned value may be misinterpreted as a positive boolean.
-Same as [`IERC7913SignatureVerifier.verify`](../interfaces#IERC7913SignatureVerifier-verify-bytes-bytes32-bytes-), but only the Solidity implementation is used. +Same as [`MerkleProof.verify`](#MerkleProof-verify-bytes32---bytes32-bytes32-function--bytes32-bytes32--view-returns--bytes32--), but only the Solidity implementation is used.
@@ -1434,7 +1542,7 @@ Public key recovery
Checks if (x, y) are valid coordinates of a point on the curve. -In particular this function checks that x < P and y < P. +In particular this function checks that x < P and y < P.
@@ -1443,9 +1551,9 @@ In particular this function checks that x < P and y < P.
-## `RSA` +## `RSA` - + @@ -1530,9 +1638,9 @@ using a low exponent out of security concerns.
-## `SignatureChecker` +## `SignatureChecker` - + @@ -1556,6 +1664,7 @@ See [ERC-1271](https://eips.ethereum.org/EIPS/eip-1271) and [ERC-7913](https://e - [isValidSignatureNow(signer, hash, signature)](#SignatureChecker-isValidSignatureNow-address-bytes32-bytes-) - [isValidSignatureNowCalldata(signer, hash, signature)](#SignatureChecker-isValidSignatureNowCalldata-address-bytes32-bytes-) - [isValidERC1271SignatureNow(signer, hash, signature)](#SignatureChecker-isValidERC1271SignatureNow-address-bytes32-bytes-) +- [isValidERC1271SignatureNowCalldata(signer, hash, signature)](#SignatureChecker-isValidERC1271SignatureNowCalldata-address-bytes32-bytes-) - [isValidSignatureNow(signer, hash, signature)](#SignatureChecker-isValidSignatureNow-bytes-bytes32-bytes-) - [areValidSignaturesNow(hash, signers, signatures)](#SignatureChecker-areValidSignaturesNow-bytes32-bytes---bytes---)
@@ -1582,7 +1691,7 @@ change through time. It could return true at block N and false at block N+1 (or -For an extended version of this function that supports ERC-7913 signatures, see #SignatureChecker-isValidSignatureNow-bytes-bytes32-bytes-. +For an extended version of this function that supports ERC-7913 signatures, see `isValidSignatureNow-bytes-bytes32-bytes-`.
@@ -1628,6 +1737,21 @@ change through time. It could return true at block N and false at block N+1 (or
+ + +
+
+

isValidERC1271SignatureNowCalldata(address signer, bytes32 hash, bytes signature) → bool result

+
+

internal

+# +
+
+
+ +
+
+
@@ -1647,9 +1771,9 @@ The signer is a `bytes` object that is the concatenation of an address and optio Verification is done as follows: -* If `signer.length < 20`: verification fails +* If `signer.length < 20`: verification fails * If `signer.length == 20`: verification is done using [`SignatureChecker.isValidSignatureNow`](#SignatureChecker-isValidSignatureNow-bytes-bytes32-bytes-) -* Otherwise: verification is done using [`IERC7913SignatureVerifier`](../interfaces#IERC7913SignatureVerifier) +* Otherwise: verification is done using [`IERC7913SignatureVerifier`](/contracts/5.x/api/interfaces#IERC7913SignatureVerifier) Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus @@ -1685,13 +1809,134 @@ change through time. It could return true at block N and false at block N+1 (or
+ + +
+ +## `TrieProof` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/utils/cryptography/TrieProof.sol"; +``` + +Library for verifying Ethereum Merkle-Patricia trie inclusion proofs. + +The [`TrieProof.traverse`](#TrieProof-traverse-bytes32-bytes-bytes---) and [`MerkleProof.verify`](#MerkleProof-verify-bytes32---bytes32-bytes32-function--bytes32-bytes32--view-returns--bytes32--) functions can be used to prove the following value: + +* Transaction against the transactionsRoot of a block. +* Event against receiptsRoot of a block. +* Account details (RLP encoding of [nonce, balance, storageRoot, codeHash]) against the stateRoot of a block. +* Storage slot (RLP encoding of the value) against the storageRoot of a account. + +Proving a storage slot is usually done in 3 steps: + +* From the stateRoot of a block, process the account proof (see `eth_getProof`) to get the account details. +* RLP decode the account details to extract the storageRoot. +* Use storageRoot of that account to process the storageProof (again, see `eth_getProof`). + +See [Merkle-Patricia trie](https://ethereum.org/en/developers/docs/data-structures-and-encoding/patricia-merkle-trie) + +Based on [this implementation from optimism](https://github.com/ethereum-optimism/optimism/blob/ef970556e668b271a152124023a8d6bb5159bacf/packages/contracts-bedrock/src/libraries/trie/MerkleTrie.sol). + +
+

Functions

+
+- [verify(value, root, key, proof)](#TrieProof-verify-bytes-bytes32-bytes-bytes---) +- [traverse(root, key, proof)](#TrieProof-traverse-bytes32-bytes-bytes---) +- [tryTraverse(root, key, proof)](#TrieProof-tryTraverse-bytes32-bytes-bytes---) +
+
+ +
+

Errors

+
+- [TrieProofTraversalError(err)](#TrieProof-TrieProofTraversalError-enum-TrieProof-ProofError-) +
+
+ + + +
+
+

verify(bytes value, bytes32 root, bytes key, bytes[] proof) → bool

+
+

internal

+# +
+
+
+ +Verifies a `proof` against a given `key`, `value`, `and root` hash. + +
+
+ + + +
+
+

traverse(bytes32 root, bytes key, bytes[] proof) → bytes

+
+

internal

+# +
+
+
+ +Traverses a proof with a given key and returns the value. + +Reverts with [`TrieProof.TrieProofTraversalError`](#TrieProof-TrieProofTraversalError-enum-TrieProof-ProofError-) if proof is invalid. + +
+
+ + + +
+
+

tryTraverse(bytes32 root, bytes key, bytes[] proof) → bytes value, enum TrieProof.ProofError err

+
+

internal

+# +
+
+
+ +Traverses a proof with a given key and returns the value and an error flag +instead of reverting if the proof is invalid. This function may still revert if +malformed input leads to RLP decoding errors. + +
+
+ + + +
+
+

TrieProofTraversalError(enum TrieProof.ProofError err)

+
+

error

+# +
+
+
+ +
+
+
-## `WebAuthn` +## `WebAuthn` - + @@ -1711,15 +1956,18 @@ signatures generated during WebAuthn authentication ceremonies as specified in t For blockchain use cases, the following WebAuthn validations are intentionally omitted: -* Origin validation: Origin verification in `clientDataJSON` is omitted as blockchain - contexts rely on authenticator and dapp frontend enforcement. Standard authenticators - implement proper origin validation. +* Origin validation: Origin verification in `clientDataJSON` is omitted. This check is the + responsibility of the authenticator and does not have a meaningful on-chain use case; standard + authenticators implement proper origin validation before signing. * RP ID hash validation: Verification of `rpIdHash` in authenticatorData against expected - RP ID hash is omitted. This is typically handled by platform-level security measures. - Including an expiry timestamp in signed data is recommended for enhanced security. -* Signature counter: Verification of signature counter increments is omitted. While - useful for detecting credential cloning, on-chain operations typically include nonce - protection, making this check redundant. + RP ID hash is omitted. This check is the responsibility of the authenticator and does not have + a meaningful on-chain use case; it is typically enforced at the platform level. +* Signature counter: Verification of signature counter increments is omitted. The + signature counter is maintained by authenticators per the WebAuthn spec to detect + credential cloning, but validating it requires storing per-credential mutable state + (the last seen counter value) which is impractical for most smart contract applications. + Additionally, counter enforcement is primarily an authenticator responsibility, not a + contract-level concern. * Extension outputs: Extension output value verification is omitted as these are not essential for core authentication security in blockchain applications. * Attestation: Attestation object verification is omitted as this implementation @@ -1810,9 +2058,9 @@ cause revert/panic.
-## `ERC7739Utils` +## `ERC7739Utils` - + @@ -1825,7 +2073,8 @@ import "@openzeppelin/contracts/utils/cryptography/draft-ERC7739Utils.sol"; Utilities to process [ERC-7739](https://ercs.ethereum.org/ERCS/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 [EIP-712](/contracts/5.x/api/utils/cryptography#EIP712-_domainSeparatorV4) +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: @@ -1837,7 +2086,8 @@ A smart contract domain can validate a signature for a typed data structure in t A provider for a smart contract wallet would need to return this signature as the result of a call to `personal_sign` or `eth_signTypedData`, and this may be unsupported by API clients that expect a return value of 129 bytes, or specifically the `r,s,v` parameters -of an [ECDSA](/contracts/5.x/api/utils/cryptography#ECDSA) signature, as is for example specified for [EIP-712](/contracts/5.x/api/utils/cryptography#EIP712). +of an xref:api:utils/cryptography#ECDSA[ECDSA] signature, as is for example specified for +xref:api:utils/cryptography#EIP712[EIP-712].
@@ -1899,7 +2149,6 @@ Constructed as follows: This function returns empty if the input format is invalid instead of reverting. -data instead.
@@ -1921,7 +2170,7 @@ Nests an `ERC-191` digest into a `PersonalSign` EIP-712 struct, and returns the This struct hash must be combined with a domain separator, using [`MessageHashUtils.toTypedDataHash`](#MessageHashUtils-toTypedDataHash-bytes32-bytes32-) before being verified/recovered. -This is used to simulates the `personal_sign` RPC method in the context of smart contracts. +This is used to simulate the `personal_sign` RPC method in the context of smart contracts.
@@ -1957,7 +2206,7 @@ before being verified/recovered.
-Variant of #ERC7739Utils-typedDataSignStructHash-string-string-bytes32-bytes- that takes a content descriptor +Variant of `typedDataSignStructHash-string-string-bytes32-bytes` that takes a content descriptor and decodes the `contentsName` and `contentsType` out of it.
@@ -2008,9 +2257,9 @@ length.
-## `AbstractSigner` +## `AbstractSigner` - + @@ -2022,7 +2271,7 @@ import "@openzeppelin/contracts/utils/cryptography/signers/AbstractSigner.sol"; Abstract contract for signature validation. -Developers must implement [`AccountERC7579._rawSignatureValidation`](../account#AccountERC7579-_rawSignatureValidation-bytes32-bytes-) and use it as the lowest-level signature validation mechanism. +Developers must implement [`AbstractSigner._rawSignatureValidation`](#AbstractSigner-_rawSignatureValidation-bytes32-bytes-) and use it as the lowest-level signature validation mechanism. @custom:stateless @@ -2049,8 +2298,9 @@ Signature validation algorithm. 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 ([ECDSA](/contracts/5.x/api/utils/cryptography#ECDSA), -[P256](/contracts/5.x/api/utils/cryptography#P256) or [RSA](/contracts/5.x/api/utils/cryptography#RSA)). +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]).
@@ -2060,9 +2310,9 @@ cryptographic verification. It is important to review and test thoroughly before
-## `MultiSignerERC7913` +## `MultiSignerERC7913` - + @@ -2260,6 +2510,15 @@ Requirements: * Each of `newSigners` must be at least 20 bytes long. Reverts with [`MultiSignerERC7913.MultiSignerERC7913InvalidSigner`](#MultiSignerERC7913-MultiSignerERC7913InvalidSigner-bytes-) if not. * Each of `newSigners` must not be authorized. See [`MultiSignerERC7913.isSigner`](#MultiSignerERC7913-isSigner-bytes-). Reverts with [`MultiSignerERC7913.MultiSignerERC7913AlreadyExists`](#MultiSignerERC7913-MultiSignerERC7913AlreadyExists-bytes-) if so. + +This function does not validate that signers are controlled or represent appropriate entities. Integrators +must ensure signers are properly validated before adding them. Problematic signers can compromise +the multisig's security or functionality. Examples include uncontrolled addresses (e.g., `address(0)`), +the account's own address (which may cause recursive validation loops), or contracts that may unintentionally +allow arbitrary validation (e.g. using the identity precompile at `address(0x04)`, which would return the +ERC-1271 magic value for any `isValidSignature` call). + +
@@ -2562,9 +2821,9 @@ The `threshold` is unreachable given the number of `signers`.
-## `MultiSignerERC7913Weighted` +## `MultiSignerERC7913Weighted` - + @@ -2893,9 +3152,9 @@ Thrown when the arrays lengths don't match. See [`MultiSignerERC7913Weighted._se
-## `SignerECDSA` +## `SignerECDSA` - + @@ -2905,9 +3164,9 @@ Thrown when the arrays lengths don't match. See [`MultiSignerERC7913Weighted._se import "@openzeppelin/contracts/utils/cryptography/signers/SignerECDSA.sol"; ``` -Implementation of [`AbstractSigner`](#AbstractSigner) using [ECDSA](/contracts/5.x/api/utils/cryptography#ECDSA) signatures. +Implementation of [`AbstractSigner`](#AbstractSigner) using xref:api:utils/cryptography#ECDSA[ECDSA] signatures. -For [`Account`](../account#Account) usage, a [`SignerECDSA._setSigner`](#SignerECDSA-_setSigner-address-) function is provided to set the [`SignerECDSA.signer`](#SignerECDSA-signer--) address. +For [`Account`](/contracts/5.x/api/account#Account) usage, a [`SignerECDSA._setSigner`](#SignerECDSA-_setSigner-address-) function is provided to set the [`SignerECDSA.signer`](#SignerECDSA-signer--) address. Doing so is easier for a factory, who is likely to use initializable clones of this contract. Example of usage: @@ -3002,7 +3261,9 @@ Signature validation algorithm. 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 ([ECDSA](/contracts/5.x/api/utils/cryptography#ECDSA), [P256](/contracts/5.x/api/utils/cryptography#P256) or [RSA](/contracts/5.x/api/utils/cryptography#RSA)). +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]).
@@ -3012,9 +3273,9 @@ cryptographic verification. It is important to review and test thoroughly before
-## `SignerEIP7702` +## `SignerEIP7702` - + @@ -3024,7 +3285,7 @@ cryptographic verification. It is important to review and test thoroughly before import "@openzeppelin/contracts/utils/cryptography/signers/SignerEIP7702.sol"; ``` -Implementation of [`AbstractSigner`](#AbstractSigner) for implementation for an EOA. Useful for ERC-7702 accounts. +Implementation of [`AbstractSigner`](#AbstractSigner) for implementation for an EOA. Useful for EIP-7702 accounts. @custom:stateless @@ -3057,9 +3318,9 @@ Validates the signature using the EOA's address (i.e. `address(this)`).
-## `SignerERC7913` +## `SignerERC7913` - + @@ -3072,7 +3333,7 @@ import "@openzeppelin/contracts/utils/cryptography/signers/SignerERC7913.sol"; Implementation of [`AbstractSigner`](#AbstractSigner) using [ERC-7913](https://eips.ethereum.org/EIPS/eip-7913) signature verification. -For [`Account`](../account#Account) usage, a [`SignerECDSA._setSigner`](#SignerECDSA-_setSigner-address-) function is provided to set the ERC-7913 formatted [`SignerECDSA.signer`](#SignerECDSA-signer--). +For [`Account`](/contracts/5.x/api/account#Account) usage, a [`SignerECDSA._setSigner`](#SignerECDSA-_setSigner-address-) function is provided to set the ERC-7913 formatted [`SignerECDSA.signer`](#SignerECDSA-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`. @@ -3168,7 +3429,7 @@ Sets the signer (i.e. `verifier || key`) with an ERC-7913 formatted signer.
-Verifies a signature using #SignatureChecker-isValidSignatureNow-bytes-bytes32-bytes- +Verifies a signature using `SignatureChecker-isValidSignatureNow-bytes-bytes32-bytes-` with [`SignerECDSA.signer`](#SignerECDSA-signer--), `hash` and `signature`.
@@ -3178,9 +3439,9 @@ with [`SignerECDSA.signer`](#SignerECDSA-signer--), `hash` and `signature`.
-## `SignerP256` +## `SignerP256` - + @@ -3190,9 +3451,9 @@ with [`SignerECDSA.signer`](#SignerECDSA-signer--), `hash` and `signature`. import "@openzeppelin/contracts/utils/cryptography/signers/SignerP256.sol"; ``` -Implementation of [`AbstractSigner`](#AbstractSigner) using [P256](/contracts/5.x/api/utils/cryptography#P256) signatures. +Implementation of [`AbstractSigner`](#AbstractSigner) using xref:api:utils/cryptography#P256[P256] signatures. -For [`Account`](../account#Account) usage, a [`SignerECDSA._setSigner`](#SignerECDSA-_setSigner-address-) function is provided to set the [`SignerECDSA.signer`](#SignerECDSA-signer--) public key. +For [`Account`](/contracts/5.x/api/account#Account) usage, a [`SignerECDSA._setSigner`](#SignerECDSA-_setSigner-address-) function is provided to set the [`SignerECDSA.signer`](#SignerECDSA-signer--) public key. Doing so is easier for a factory, who is likely to use initializable clones of this contract. Example of usage: @@ -3295,7 +3556,9 @@ Signature validation algorithm. 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 ([ECDSA](/contracts/5.x/api/utils/cryptography#ECDSA), [P256](/contracts/5.x/api/utils/cryptography#P256) or [RSA](/contracts/5.x/api/utils/cryptography#RSA)). +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]).
@@ -3320,9 +3583,9 @@ cryptographic verification. It is important to review and test thoroughly before
-## `SignerRSA` +## `SignerRSA` - + @@ -3332,9 +3595,9 @@ cryptographic verification. It is important to review and test thoroughly before import "@openzeppelin/contracts/utils/cryptography/signers/SignerRSA.sol"; ``` -Implementation of [`AbstractSigner`](#AbstractSigner) using [RSA](/contracts/5.x/api/utils/cryptography#RSA) signatures. +Implementation of [`AbstractSigner`](#AbstractSigner) using xref:api:utils/cryptography#RSA[RSA] signatures. -For [`Account`](../account#Account) usage, a [`SignerECDSA._setSigner`](#SignerECDSA-_setSigner-address-) function is provided to set the [`SignerECDSA.signer`](#SignerECDSA-signer--) public key. +For [`Account`](/contracts/5.x/api/account#Account) usage, a [`SignerECDSA._setSigner`](#SignerECDSA-_setSigner-address-) function is provided to set the [`SignerECDSA.signer`](#SignerECDSA-signer--) public key. Doing so is easier for a factory, who is likely to use initializable clones of this contract. Example of usage: @@ -3441,9 +3704,9 @@ encoding as per section 9.2 (step 1) of the RFC.
-## `SignerWebAuthn` +## `SignerWebAuthn` - + @@ -3510,9 +3773,7 @@ or during initialization (if used as a clone) may leave the signer either front- Validates a raw signature using the WebAuthn authentication assertion. -In case the signature can't be validated, it falls back to the -[`SignerP256._rawSignatureValidation`](#SignerP256-_rawSignatureValidation-bytes32-bytes-) method for raw P256 signature validation by passing -the raw `r` and `s` values from the signature. +Returns `false` if the signature is not a valid WebAuthn authentication assertion.
@@ -3521,9 +3782,9 @@ the raw `r` and `s` values from the signature.
-## `ERC7739` +## `ERC7739` - + @@ -3538,11 +3799,13 @@ Validates signatures wrapping the message hash in a nested EIP712 type. See [`ER 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 [`AccountERC7579._rawSignatureValidation`](../account#AccountERC7579-_rawSignatureValidation-bytes32-bytes-) function, which passes the wrapped message hash, +This contract requires implementing the [`AbstractSigner._rawSignatureValidation`](#AbstractSigner-_rawSignatureValidation-bytes32-bytes-) function, which passes the wrapped message hash, which may be either an typed data or a personal sign nested type. -[EIP-712](/contracts/5.x/api/utils/cryptography#EIP712) uses [ShortStrings](/contracts/5.x/api/utils/cryptography#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 +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 [ERC-7562 storage access rules](https://eips.ethereum.org/EIPS/eip-7562#storage-rules)). @@ -3600,9 +3863,9 @@ A nested EIP-712 type might be presented in 2 different ways:
-## `ERC7913P256Verifier` +## `ERC7913P256Verifier` - + @@ -3649,9 +3912,9 @@ SHOULD return 0xffffffff or revert if the key is empty
-## `ERC7913RSAVerifier` +## `ERC7913RSAVerifier` - + @@ -3698,9 +3961,9 @@ SHOULD return 0xffffffff or revert if the key is empty
-## `ERC7913WebAuthnVerifier` +## `ERC7913WebAuthnVerifier` - + @@ -3716,7 +3979,7 @@ This verifier enables the validation of WebAuthn signatures using P256 public ke The key is expected to be a 64-byte concatenation of the P256 public key coordinates (qx || qy). The signature is expected to be an abi-encoded [`WebAuthn.WebAuthnAuth`](#WebAuthn-WebAuthnAuth) struct. -Uses `WebAuthn-verifyMinimal` for signature verification, which performs the essential +Uses [`WebAuthn.verify`](#WebAuthn-verify-bytes-struct-WebAuthn-WebAuthnAuth-bytes32-bytes32-bool-) for signature verification, which performs the essential WebAuthn checks: type validation, challenge matching, and cryptographic signature verification. @@ -3753,3 +4016,4 @@ SHOULD return 0xffffffff or revert if the key is empty
+ From cd2d32e0870559171e1e486975395b5d589005fd Mon Sep 17 00:00:00 2001 From: stevep0z <255929980+stevep0z@users.noreply.github.com> Date: Thu, 2 Apr 2026 11:36:27 -0500 Subject: [PATCH 03/11] feat: collapsible inherited functions in API reference TOC sections Wrap inherited function/event/error listings in
/ toggles so the contract's own items are prominent and inherited items are accessible but not overwhelming. Only renders toggles for inherited contracts that have items for that section (no empty toggles). Also regenerates API reference output with updated template. --- content/community-contracts/api/access.mdx | 9 +- content/community-contracts/api/account.mdx | 378 +++-- .../community-contracts/api/crosschain.mdx | 157 +- .../community-contracts/api/governance.mdx | 73 +- .../community-contracts/api/interfaces.mdx | 54 +- content/community-contracts/api/proxy.mdx | 12 +- content/community-contracts/api/token.mdx | 350 ++-- content/community-contracts/api/utils.mdx | 18 +- .../api/utils/cryptography.mdx | 34 +- content/contracts/5.x/api/access.mdx | 180 +- content/contracts/5.x/api/account.mdx | 96 +- content/contracts/5.x/api/crosschain.mdx | 375 +++-- content/contracts/5.x/api/finance.mdx | 49 +- content/contracts/5.x/api/governance.mdx | 1469 ++++++++++------- content/contracts/5.x/api/interfaces.mdx | 204 ++- content/contracts/5.x/api/metatx.mdx | 29 +- content/contracts/5.x/api/proxy.mdx | 80 +- content/contracts/5.x/api/token/ERC1155.mdx | 290 ++-- content/contracts/5.x/api/token/ERC20.mdx | 550 +++--- content/contracts/5.x/api/token/ERC6909.mdx | 104 +- content/contracts/5.x/api/token/ERC721.mdx | 532 +++--- content/contracts/5.x/api/token/common.mdx | 6 - content/contracts/5.x/api/utils.mdx | 13 +- .../contracts/5.x/api/utils/cryptography.mdx | 77 +- docgen/templates-md/contract.hbs | 48 +- 25 files changed, 3115 insertions(+), 2072 deletions(-) diff --git a/content/community-contracts/api/access.mdx b/content/community-contracts/api/access.mdx index 6023bc9c..4594dfc6 100644 --- a/content/community-contracts/api/access.mdx +++ b/content/community-contracts/api/access.mdx @@ -15,16 +15,16 @@ This directory contains utility contracts to restrict access control in smart co
-## `AccessManagerLight` +## `AccessManagerLight` - +
```solidity -import "@openzeppelin/community-contracts/contracts/access/manager/AccessManagerLight.sol"; +import "@openzeppelin/contracts/access/manager/AccessManagerLight.sol"; ``` Light version of an AccessManager contract that defines `bytes8` roles @@ -64,7 +64,6 @@ manage the roles of other users. - [PUBLIC_ROLE()](#AccessManagerLight-PUBLIC_ROLE-uint8) - [ADMIN_MASK()](#AccessManagerLight-ADMIN_MASK-Masks-Mask) - [PUBLIC_MASK()](#AccessManagerLight-PUBLIC_MASK-Masks-Mask) -#### IAuthority [!toc]
@@ -75,7 +74,6 @@ manage the roles of other users. - [GroupRemoved(user, group)](#AccessManagerLight-GroupRemoved-address-uint8-) - [GroupAdmins(group, admins)](#AccessManagerLight-GroupAdmins-uint8-Masks-Mask-) - [RequirementsSet(target, selector, groups)](#AccessManagerLight-RequirementsSet-address-bytes4-Masks-Mask-) -#### IAuthority [!toc]
@@ -83,7 +81,6 @@ manage the roles of other users.

Errors

- [MissingPermissions(user, permissions, requirement)](#AccessManagerLight-MissingPermissions-address-Masks-Mask-Masks-Mask-) -#### IAuthority [!toc]
diff --git a/content/community-contracts/api/account.mdx b/content/community-contracts/api/account.mdx index ae6ac946..3d969298 100644 --- a/content/community-contracts/api/account.mdx +++ b/content/community-contracts/api/account.mdx @@ -60,16 +60,16 @@ This directory includes contracts to build accounts for ERC-4337. These include:
-## `ERC7579DelayedExecutor` +## `ERC7579DelayedExecutor` - +
```solidity -import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579DelayedExecutor.sol"; +import "@openzeppelin/contracts/account/modules/ERC7579DelayedExecutor.sol"; ``` Extension of [`ERC7579Executor`](#ERC7579Executor) that allows scheduling and executing delayed operations @@ -137,10 +137,13 @@ useful to pre-schedule operations for non-deployed accounts (e.g. subscriptions) - [_cancel(account, mode, executionCalldata, salt)](#ERC7579DelayedExecutor-_cancel-address-bytes32-bytes-bytes32-) - [_validateStateBitmap(operationId, allowedStates)](#ERC7579DelayedExecutor-_validateStateBitmap-bytes32-bytes32-) - [_encodeStateBitmap(operationState)](#ERC7579DelayedExecutor-_encodeStateBitmap-enum-ERC7579DelayedExecutor-OperationState-) -#### ERC7579Executor [!toc] +
+ERC7579Executor + - [isModuleType(moduleTypeId)](#ERC7579Executor-isModuleType-uint256-) - [execute(account, salt, mode, data)](#ERC7579Executor-execute-address-bytes32-bytes32-bytes-) -#### IERC7579Module [!toc] + +
@@ -151,9 +154,12 @@ useful to pre-schedule operations for non-deployed accounts (e.g. subscriptions) - [ERC7579ExecutorOperationCanceled(account, operationId)](#ERC7579DelayedExecutor-ERC7579ExecutorOperationCanceled-address-bytes32-) - [ERC7579ExecutorDelayUpdated(account, newDelay, effectTime)](#ERC7579DelayedExecutor-ERC7579ExecutorDelayUpdated-address-uint32-uint48-) - [ERC7579ExecutorExpirationUpdated(account, newExpiration)](#ERC7579DelayedExecutor-ERC7579ExecutorExpirationUpdated-address-uint32-) -#### ERC7579Executor [!toc] +
+ERC7579Executor + - [ERC7579ExecutorOperationExecuted(account, salt, mode, executionCalldata)](#ERC7579Executor-ERC7579ExecutorOperationExecuted-address-bytes32-bytes32-bytes-) -#### IERC7579Module [!toc] + +
@@ -162,8 +168,6 @@ useful to pre-schedule operations for non-deployed accounts (e.g. subscriptions)
- [ERC7579ExecutorUnexpectedOperationState(operationId, currentState, allowedStates)](#ERC7579DelayedExecutor-ERC7579ExecutorUnexpectedOperationState-bytes32-enum-ERC7579DelayedExecutor-OperationState-bytes32-) - [ERC7579ExecutorModuleNotInstalled()](#ERC7579DelayedExecutor-ERC7579ExecutorModuleNotInstalled--) -#### ERC7579Executor [!toc] -#### IERC7579Module [!toc]
@@ -795,16 +799,16 @@ The module is not installed on the account.
-## `ERC7579Executor` +## `ERC7579Executor` - +
```solidity -import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579Executor.sol"; +import "@openzeppelin/contracts/account/modules/ERC7579Executor.sol"; ``` Basic implementation for ERC-7579 executor modules that provides execution functionality @@ -828,9 +832,13 @@ security features, see [`ERC7579DelayedExecutor`](#ERC7579DelayedExecutor). - [execute(account, salt, mode, data)](#ERC7579Executor-execute-address-bytes32-bytes32-bytes-) - [_validateExecution(account, salt, mode, data)](#ERC7579Executor-_validateExecution-address-bytes32-bytes32-bytes-) - [_execute(account, mode, salt, executionCalldata)](#ERC7579Executor-_execute-address-bytes32-bytes32-bytes-) -#### IERC7579Module [!toc] +
+IERC7579Module + - [onInstall(data)](#IERC7579Module-onInstall-bytes-) - [onUninstall(data)](#IERC7579Module-onUninstall-bytes-) + +
@@ -838,7 +846,6 @@ security features, see [`ERC7579DelayedExecutor`](#ERC7579DelayedExecutor).

Events

- [ERC7579ExecutorOperationExecuted(account, salt, mode, executionCalldata)](#ERC7579Executor-ERC7579ExecutorOperationExecuted-address-bytes32-bytes32-bytes-) -#### IERC7579Module [!toc]
@@ -958,16 +965,16 @@ Emitted when an operation is executed.
-## `ERC7579Multisig` +## `ERC7579Multisig` - +
```solidity -import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579Multisig.sol"; +import "@openzeppelin/contracts/account/modules/ERC7579Multisig.sol"; ``` Implementation of an [`ERC7579Validator`](#ERC7579Validator) that uses ERC-7913 signers for multisignature @@ -1001,12 +1008,14 @@ a social recovery operation. - [_validateReachableThreshold(account)](#ERC7579Multisig-_validateReachableThreshold-address-) - [_validateSignatures(account, hash, signingSigners, signatures)](#ERC7579Multisig-_validateSignatures-address-bytes32-bytes---bytes---) - [_validateThreshold(account, validatingSigners)](#ERC7579Multisig-_validateThreshold-address-bytes---) -#### ERC7579Validator [!toc] +
+ERC7579Validator + - [isModuleType(moduleTypeId)](#ERC7579Validator-isModuleType-uint256-) - [validateUserOp(userOp, userOpHash)](#ERC7579Validator-validateUserOp-struct-PackedUserOperation-bytes32-) - [isValidSignatureWithSender(, hash, signature)](#ERC7579Validator-isValidSignatureWithSender-address-bytes32-bytes-) -#### IERC7579Validator [!toc] -#### IERC7579Module [!toc] + +
@@ -1016,9 +1025,6 @@ a social recovery operation. - [ERC7913SignerAdded(account, signer)](#ERC7579Multisig-ERC7913SignerAdded-address-bytes-) - [ERC7913SignerRemoved(account, signer)](#ERC7579Multisig-ERC7913SignerRemoved-address-bytes-) - [ERC7913ThresholdSet(account, threshold)](#ERC7579Multisig-ERC7913ThresholdSet-address-uint64-) -#### ERC7579Validator [!toc] -#### IERC7579Validator [!toc] -#### IERC7579Module [!toc]
@@ -1030,9 +1036,6 @@ a social recovery operation. - [ERC7579MultisigInvalidSigner(signer)](#ERC7579Multisig-ERC7579MultisigInvalidSigner-bytes-) - [ERC7579MultisigZeroThreshold()](#ERC7579Multisig-ERC7579MultisigZeroThreshold--) - [ERC7579MultisigUnreachableThreshold(signers, threshold)](#ERC7579Multisig-ERC7579MultisigUnreachableThreshold-uint64-uint64-) -#### ERC7579Validator [!toc] -#### IERC7579Validator [!toc] -#### IERC7579Module [!toc]
@@ -1532,16 +1535,16 @@ The `threshold` is unreachable given the number of `signers`.
-## `ERC7579MultisigConfirmation` +## `ERC7579MultisigConfirmation` - +
```solidity -import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579MultisigConfirmation.sol"; +import "@openzeppelin/contracts/account/modules/ERC7579MultisigConfirmation.sol"; ``` Extension of [`ERC7579Multisig`](#ERC7579Multisig) that requires explicit confirmation signatures @@ -1561,14 +1564,19 @@ explicitly agreed to their roles.
- [_signableConfirmationHash(account, deadline)](#ERC7579MultisigConfirmation-_signableConfirmationHash-address-uint256-) - [_addSigners(account, newSigners)](#ERC7579MultisigConfirmation-_addSigners-address-bytes---) -#### EIP712 [!toc] +
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### ERC7579Multisig [!toc] + +
+
+ERC7579Multisig + - [onInstall(initData)](#ERC7579Multisig-onInstall-bytes-) - [onUninstall()](#ERC7579Multisig-onUninstall-bytes-) - [getSigners(account, start, end)](#ERC7579Multisig-getSigners-address-uint64-uint64-) @@ -1584,28 +1592,36 @@ explicitly agreed to their roles. - [_validateReachableThreshold(account)](#ERC7579Multisig-_validateReachableThreshold-address-) - [_validateSignatures(account, hash, signingSigners, signatures)](#ERC7579Multisig-_validateSignatures-address-bytes32-bytes---bytes---) - [_validateThreshold(account, validatingSigners)](#ERC7579Multisig-_validateThreshold-address-bytes---) -#### ERC7579Validator [!toc] + +
+
+ERC7579Validator + - [isModuleType(moduleTypeId)](#ERC7579Validator-isModuleType-uint256-) - [validateUserOp(userOp, userOpHash)](#ERC7579Validator-validateUserOp-struct-PackedUserOperation-bytes32-) - [isValidSignatureWithSender(, hash, signature)](#ERC7579Validator-isValidSignatureWithSender-address-bytes32-bytes-) -#### IERC7579Validator [!toc] -#### IERC7579Module [!toc] + +

Events

-#### EIP712 [!toc] -#### IERC5267 [!toc] +
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### ERC7579Multisig [!toc] + +
+
+ERC7579Multisig + - [ERC7913SignerAdded(account, signer)](#ERC7579Multisig-ERC7913SignerAdded-address-bytes-) - [ERC7913SignerRemoved(account, signer)](#ERC7579Multisig-ERC7913SignerRemoved-address-bytes-) - [ERC7913ThresholdSet(account, threshold)](#ERC7579Multisig-ERC7913ThresholdSet-address-uint64-) -#### ERC7579Validator [!toc] -#### IERC7579Validator [!toc] -#### IERC7579Module [!toc] + +
@@ -1614,17 +1630,16 @@ explicitly agreed to their roles.
- [ERC7579MultisigInvalidConfirmationSignature(signer)](#ERC7579MultisigConfirmation-ERC7579MultisigInvalidConfirmationSignature-bytes-) - [ERC7579MultisigExpiredConfirmation(deadline)](#ERC7579MultisigConfirmation-ERC7579MultisigExpiredConfirmation-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### ERC7579Multisig [!toc] +
+ERC7579Multisig + - [ERC7579MultisigAlreadyExists(signer)](#ERC7579Multisig-ERC7579MultisigAlreadyExists-bytes-) - [ERC7579MultisigNonexistentSigner(signer)](#ERC7579Multisig-ERC7579MultisigNonexistentSigner-bytes-) - [ERC7579MultisigInvalidSigner(signer)](#ERC7579Multisig-ERC7579MultisigInvalidSigner-bytes-) - [ERC7579MultisigZeroThreshold()](#ERC7579Multisig-ERC7579MultisigZeroThreshold--) - [ERC7579MultisigUnreachableThreshold(signers, threshold)](#ERC7579Multisig-ERC7579MultisigUnreachableThreshold-uint64-uint64-) -#### ERC7579Validator [!toc] -#### IERC7579Validator [!toc] -#### IERC7579Module [!toc] + +
@@ -1711,16 +1726,16 @@ Error thrown when a confirmation signature has expired
-## `ERC7579MultisigStorage` +## `ERC7579MultisigStorage` - +
```solidity -import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579MultisigStorage.sol"; +import "@openzeppelin/contracts/account/modules/ERC7579MultisigStorage.sol"; ``` Extension of [`ERC7579Multisig`](#ERC7579Multisig) that allows storing presigned approvals in storage. @@ -1739,7 +1754,9 @@ and the validation will check the storage mapping instead of cryptographic verif - [presigned(account, signer, hash)](#ERC7579MultisigStorage-presigned-address-bytes-bytes32-) - [presign(account, signer, hash, signature)](#ERC7579MultisigStorage-presign-address-bytes-bytes32-bytes-) - [_validateSignatures(account, hash, signingSigners, signatures)](#ERC7579MultisigStorage-_validateSignatures-address-bytes32-bytes---bytes---) -#### ERC7579Multisig [!toc] +
+ERC7579Multisig + - [onInstall(initData)](#ERC7579Multisig-onInstall-bytes-) - [onUninstall()](#ERC7579Multisig-onUninstall-bytes-) - [getSigners(account, start, end)](#ERC7579Multisig-getSigners-address-uint64-uint64-) @@ -1755,12 +1772,16 @@ and the validation will check the storage mapping instead of cryptographic verif - [_setThreshold(account, newThreshold)](#ERC7579Multisig-_setThreshold-address-uint64-) - [_validateReachableThreshold(account)](#ERC7579Multisig-_validateReachableThreshold-address-) - [_validateThreshold(account, validatingSigners)](#ERC7579Multisig-_validateThreshold-address-bytes---) -#### ERC7579Validator [!toc] + +
+
+ERC7579Validator + - [isModuleType(moduleTypeId)](#ERC7579Validator-isModuleType-uint256-) - [validateUserOp(userOp, userOpHash)](#ERC7579Validator-validateUserOp-struct-PackedUserOperation-bytes32-) - [isValidSignatureWithSender(, hash, signature)](#ERC7579Validator-isValidSignatureWithSender-address-bytes32-bytes-) -#### IERC7579Validator [!toc] -#### IERC7579Module [!toc] + +
@@ -1768,28 +1789,30 @@ and the validation will check the storage mapping instead of cryptographic verif

Events

- [ERC7579MultisigStoragePresigned(account, hash, signer)](#ERC7579MultisigStorage-ERC7579MultisigStoragePresigned-address-bytes32-bytes-) -#### ERC7579Multisig [!toc] +
+ERC7579Multisig + - [ERC7913SignerAdded(account, signer)](#ERC7579Multisig-ERC7913SignerAdded-address-bytes-) - [ERC7913SignerRemoved(account, signer)](#ERC7579Multisig-ERC7913SignerRemoved-address-bytes-) - [ERC7913ThresholdSet(account, threshold)](#ERC7579Multisig-ERC7913ThresholdSet-address-uint64-) -#### ERC7579Validator [!toc] -#### IERC7579Validator [!toc] -#### IERC7579Module [!toc] + +

Errors

-#### ERC7579Multisig [!toc] +
+ERC7579Multisig + - [ERC7579MultisigAlreadyExists(signer)](#ERC7579Multisig-ERC7579MultisigAlreadyExists-bytes-) - [ERC7579MultisigNonexistentSigner(signer)](#ERC7579Multisig-ERC7579MultisigNonexistentSigner-bytes-) - [ERC7579MultisigInvalidSigner(signer)](#ERC7579Multisig-ERC7579MultisigInvalidSigner-bytes-) - [ERC7579MultisigZeroThreshold()](#ERC7579Multisig-ERC7579MultisigZeroThreshold--) - [ERC7579MultisigUnreachableThreshold(signers, threshold)](#ERC7579Multisig-ERC7579MultisigUnreachableThreshold-uint64-uint64-) -#### ERC7579Validator [!toc] -#### IERC7579Validator [!toc] -#### IERC7579Module [!toc] + +
@@ -1878,16 +1901,16 @@ Emitted when a signer signs a hash
-## `ERC7579MultisigWeighted` +## `ERC7579MultisigWeighted` - +
```solidity -import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579MultisigWeighted.sol"; +import "@openzeppelin/contracts/account/modules/ERC7579MultisigWeighted.sol"; ``` Extension of [`ERC7579Multisig`](#ERC7579Multisig) that supports weighted signatures. @@ -1922,7 +1945,9 @@ signatures with a total weight of at least 4 (e.g., one with weight 1 and one wi - [_removeSigners(account, oldSigners)](#ERC7579MultisigWeighted-_removeSigners-address-bytes---) - [_validateReachableThreshold(account)](#ERC7579MultisigWeighted-_validateReachableThreshold-address-) - [_validateThreshold(account, validatingSigners)](#ERC7579MultisigWeighted-_validateThreshold-address-bytes---) -#### ERC7579Multisig [!toc] +
+ERC7579Multisig + - [getSigners(account, start, end)](#ERC7579Multisig-getSigners-address-uint64-uint64-) - [getSignerCount(account)](#ERC7579Multisig-getSignerCount-address-) - [isSigner(account, signer)](#ERC7579Multisig-isSigner-address-bytes-) @@ -1933,12 +1958,16 @@ signatures with a total weight of at least 4 (e.g., one with weight 1 and one wi - [_rawERC7579Validation(account, hash, signature)](#ERC7579Multisig-_rawERC7579Validation-address-bytes32-bytes-) - [_setThreshold(account, newThreshold)](#ERC7579Multisig-_setThreshold-address-uint64-) - [_validateSignatures(account, hash, signingSigners, signatures)](#ERC7579Multisig-_validateSignatures-address-bytes32-bytes---bytes---) -#### ERC7579Validator [!toc] + +
+
+ERC7579Validator + - [isModuleType(moduleTypeId)](#ERC7579Validator-isModuleType-uint256-) - [validateUserOp(userOp, userOpHash)](#ERC7579Validator-validateUserOp-struct-PackedUserOperation-bytes32-) - [isValidSignatureWithSender(, hash, signature)](#ERC7579Validator-isValidSignatureWithSender-address-bytes32-bytes-) -#### IERC7579Validator [!toc] -#### IERC7579Module [!toc] + +
@@ -1946,13 +1975,14 @@ signatures with a total weight of at least 4 (e.g., one with weight 1 and one wi

Events

- [ERC7579MultisigWeightChanged(account, signer, weight)](#ERC7579MultisigWeighted-ERC7579MultisigWeightChanged-address-bytes-uint64-) -#### ERC7579Multisig [!toc] +
+ERC7579Multisig + - [ERC7913SignerAdded(account, signer)](#ERC7579Multisig-ERC7913SignerAdded-address-bytes-) - [ERC7913SignerRemoved(account, signer)](#ERC7579Multisig-ERC7913SignerRemoved-address-bytes-) - [ERC7913ThresholdSet(account, threshold)](#ERC7579Multisig-ERC7913ThresholdSet-address-uint64-) -#### ERC7579Validator [!toc] -#### IERC7579Validator [!toc] -#### IERC7579Module [!toc] + +
@@ -1961,15 +1991,16 @@ signatures with a total weight of at least 4 (e.g., one with weight 1 and one wi
- [ERC7579MultisigInvalidWeight(signer, weight)](#ERC7579MultisigWeighted-ERC7579MultisigInvalidWeight-bytes-uint64-) - [ERC7579MultisigMismatchedLength()](#ERC7579MultisigWeighted-ERC7579MultisigMismatchedLength--) -#### ERC7579Multisig [!toc] +
+ERC7579Multisig + - [ERC7579MultisigAlreadyExists(signer)](#ERC7579Multisig-ERC7579MultisigAlreadyExists-bytes-) - [ERC7579MultisigNonexistentSigner(signer)](#ERC7579Multisig-ERC7579MultisigNonexistentSigner-bytes-) - [ERC7579MultisigInvalidSigner(signer)](#ERC7579Multisig-ERC7579MultisigInvalidSigner-bytes-) - [ERC7579MultisigZeroThreshold()](#ERC7579Multisig-ERC7579MultisigZeroThreshold--) - [ERC7579MultisigUnreachableThreshold(signers, threshold)](#ERC7579Multisig-ERC7579MultisigUnreachableThreshold-uint64-uint64-) -#### ERC7579Validator [!toc] -#### IERC7579Validator [!toc] -#### IERC7579Module [!toc] + +
@@ -2250,16 +2281,16 @@ Thrown when the arrays lengths don't match.
-## `ERC7579SelectorExecutor` +## `ERC7579SelectorExecutor` - +
```solidity -import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579SelectorExecutor.sol"; +import "@openzeppelin/contracts/account/modules/ERC7579SelectorExecutor.sol"; ``` Implementation of an [`ERC7579Executor`](#ERC7579Executor) that allows authorizing specific function selectors @@ -2281,11 +2312,14 @@ in the set will be allowed to execute. - [_addSelectors(account, newSelectors)](#ERC7579SelectorExecutor-_addSelectors-address-bytes4---) - [_removeSelectors(account, oldSelectors)](#ERC7579SelectorExecutor-_removeSelectors-address-bytes4---) - [_validateExecution(account, , , data)](#ERC7579SelectorExecutor-_validateExecution-address-bytes32-bytes32-bytes-) -#### ERC7579Executor [!toc] +
+ERC7579Executor + - [isModuleType(moduleTypeId)](#ERC7579Executor-isModuleType-uint256-) - [execute(account, salt, mode, data)](#ERC7579Executor-execute-address-bytes32-bytes32-bytes-) - [_execute(account, mode, salt, executionCalldata)](#ERC7579Executor-_execute-address-bytes32-bytes32-bytes-) -#### IERC7579Module [!toc] + +
@@ -2294,9 +2328,12 @@ in the set will be allowed to execute.
- [ERC7579ExecutorSelectorAuthorized(account, selector)](#ERC7579SelectorExecutor-ERC7579ExecutorSelectorAuthorized-address-bytes4-) - [ERC7579ExecutorSelectorRemoved(account, selector)](#ERC7579SelectorExecutor-ERC7579ExecutorSelectorRemoved-address-bytes4-) -#### ERC7579Executor [!toc] +
+ERC7579Executor + - [ERC7579ExecutorOperationExecuted(account, salt, mode, executionCalldata)](#ERC7579Executor-ERC7579ExecutorOperationExecuted-address-bytes32-bytes32-bytes-) -#### IERC7579Module [!toc] + +
@@ -2304,8 +2341,6 @@ in the set will be allowed to execute.

Errors

- [ERC7579ExecutorSelectorNotAuthorized(selector)](#ERC7579SelectorExecutor-ERC7579ExecutorSelectorNotAuthorized-bytes4-) -#### ERC7579Executor [!toc] -#### IERC7579Module [!toc]
@@ -2529,16 +2564,16 @@ Error thrown when attempting to execute a non-authorized selector
-## `ERC7579Signature` +## `ERC7579Signature` - +
```solidity -import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579Signature.sol"; +import "@openzeppelin/contracts/account/modules/ERC7579Signature.sol"; ``` Implementation of [`ERC7579Validator`](#ERC7579Validator) module using ERC-7913 signature verification. @@ -2561,12 +2596,14 @@ backup. - [setSigner(signer_)](#ERC7579Signature-setSigner-bytes-) - [_setSigner(account, signer_)](#ERC7579Signature-_setSigner-address-bytes-) - [_rawERC7579Validation(account, hash, signature)](#ERC7579Signature-_rawERC7579Validation-address-bytes32-bytes-) -#### ERC7579Validator [!toc] +
+ERC7579Validator + - [isModuleType(moduleTypeId)](#ERC7579Validator-isModuleType-uint256-) - [validateUserOp(userOp, userOpHash)](#ERC7579Validator-validateUserOp-struct-PackedUserOperation-bytes32-) - [isValidSignatureWithSender(, hash, signature)](#ERC7579Validator-isValidSignatureWithSender-address-bytes32-bytes-) -#### IERC7579Validator [!toc] -#### IERC7579Module [!toc] + +
@@ -2574,9 +2611,6 @@ backup.

Events

- [ERC7579SignatureSignerSet(account, signer)](#ERC7579Signature-ERC7579SignatureSignerSet-address-bytes-) -#### ERC7579Validator [!toc] -#### IERC7579Validator [!toc] -#### IERC7579Module [!toc]
@@ -2584,9 +2618,6 @@ backup.

Errors

- [ERC7579SignatureInvalidSignerLength()](#ERC7579Signature-ERC7579SignatureInvalidSignerLength--) -#### ERC7579Validator [!toc] -#### IERC7579Validator [!toc] -#### IERC7579Module [!toc]
@@ -2748,16 +2779,16 @@ Thrown when the signer length is less than 20 bytes.
-## `ERC7579Validator` +## `ERC7579Validator` - +
```solidity -import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579Validator.sol"; +import "@openzeppelin/contracts/account/modules/ERC7579Validator.sol"; ``` Abstract validator module for ERC-7579 accounts. @@ -2811,10 +2842,13 @@ function execute( - [validateUserOp(userOp, userOpHash)](#ERC7579Validator-validateUserOp-struct-PackedUserOperation-bytes32-) - [isValidSignatureWithSender(, hash, signature)](#ERC7579Validator-isValidSignatureWithSender-address-bytes32-bytes-) - [_rawERC7579Validation(account, hash, signature)](#ERC7579Validator-_rawERC7579Validation-address-bytes32-bytes-) -#### IERC7579Validator [!toc] -#### IERC7579Module [!toc] +
+IERC7579Module + - [onInstall(data)](#IERC7579Module-onInstall-bytes-) - [onUninstall(data)](#IERC7579Module-onUninstall-bytes-) + +
@@ -2899,16 +2933,16 @@ handle cryptographic verification to prevent unauthorized access.
-## `PaymasterCore` +## `PaymasterCore` - +
```solidity -import "@openzeppelin/community-contracts/contracts/account/paymaster/PaymasterCore.sol"; +import "@openzeppelin/contracts/account/paymaster/PaymasterCore.sol"; ``` A simple ERC4337 paymaster implementation. This base implementation only includes the minimal logic to validate @@ -2951,7 +2985,6 @@ See [Paymaster's unstaked reputation rules](https://eips.ethereum.org/EIPS/eip-7 - [withdrawStake(to)](#PaymasterCore-withdrawStake-address-payable-) - [_checkEntryPoint()](#PaymasterCore-_checkEntryPoint--) - [_authorizeWithdraw()](#PaymasterCore-_authorizeWithdraw--) -#### IPaymaster [!toc]
@@ -2959,7 +2992,6 @@ See [Paymaster's unstaked reputation rules](https://eips.ethereum.org/EIPS/eip-7

Errors

- [PaymasterUnauthorized(sender)](#PaymasterCore-PaymasterUnauthorized-address-) -#### IPaymaster [!toc]
@@ -3247,16 +3279,16 @@ Unauthorized call to the paymaster.
-## `PaymasterERC20` +## `PaymasterERC20` - +
```solidity -import "@openzeppelin/community-contracts/contracts/account/paymaster/PaymasterERC20.sol"; +import "@openzeppelin/contracts/account/paymaster/PaymasterERC20.sol"; ``` Extension of [`PaymasterCore`](#PaymasterCore) that enables users to pay gas with ERC-20 tokens. @@ -3288,7 +3320,9 @@ The contract follows a pre-charge and refund model: - [_tokenPriceDenominator()](#PaymasterERC20-_tokenPriceDenominator--) - [_erc20Cost(cost, feePerGas, tokenPrice)](#PaymasterERC20-_erc20Cost-uint256-uint256-uint256-) - [withdrawTokens(token, recipient, amount)](#PaymasterERC20-withdrawTokens-contract-IERC20-address-uint256-) -#### PaymasterCore [!toc] +
+PaymasterCore + - [entryPoint()](#PaymasterCore-entryPoint--) - [validatePaymasterUserOp(userOp, userOpHash, maxCost)](#PaymasterCore-validatePaymasterUserOp-struct-PackedUserOperation-bytes32-uint256-) - [postOp(mode, context, actualGasCost, actualUserOpFeePerGas)](#PaymasterCore-postOp-enum-IPaymaster-PostOpMode-bytes-uint256-uint256-) @@ -3299,7 +3333,8 @@ The contract follows a pre-charge and refund model: - [withdrawStake(to)](#PaymasterCore-withdrawStake-address-payable-) - [_checkEntryPoint()](#PaymasterCore-_checkEntryPoint--) - [_authorizeWithdraw()](#PaymasterCore-_authorizeWithdraw--) -#### IPaymaster [!toc] + +
@@ -3307,8 +3342,6 @@ The contract follows a pre-charge and refund model:

Events

- [UserOperationSponsored(userOpHash, token, tokenAmount, tokenPrice)](#PaymasterERC20-UserOperationSponsored-bytes32-address-uint256-uint256-) -#### PaymasterCore [!toc] -#### IPaymaster [!toc]
@@ -3316,9 +3349,12 @@ The contract follows a pre-charge and refund model:

Errors

- [PaymasterERC20FailedRefund(token, prefundAmount, actualAmount, prefundContext)](#PaymasterERC20-PaymasterERC20FailedRefund-contract-IERC20-uint256-uint256-bytes-) -#### PaymasterCore [!toc] +
+PaymasterCore + - [PaymasterUnauthorized(sender)](#PaymasterCore-PaymasterUnauthorized-address-) -#### IPaymaster [!toc] + +
@@ -3563,16 +3599,16 @@ and the `actualAmount` of `token`.
-## `PaymasterERC20Guarantor` +## `PaymasterERC20Guarantor` - +
```solidity -import "@openzeppelin/community-contracts/contracts/account/paymaster/PaymasterERC20Guarantor.sol"; +import "@openzeppelin/contracts/account/paymaster/PaymasterERC20Guarantor.sol"; ``` Extension of [`PaymasterERC20`](#PaymasterERC20) that enables third parties to guarantee user operations. @@ -3600,7 +3636,9 @@ logic based on the specific requirements of the application. - [_refund(token, tokenPrice, actualGasCost, actualUserOpFeePerGas, prefunder, prefundAmount, prefundContext)](#PaymasterERC20Guarantor-_refund-contract-IERC20-uint256-uint256-uint256-address-uint256-bytes-) - [_fetchGuarantor(userOp)](#PaymasterERC20Guarantor-_fetchGuarantor-struct-PackedUserOperation-) - [_guaranteedPostOpCost()](#PaymasterERC20Guarantor-_guaranteedPostOpCost--) -#### PaymasterERC20 [!toc] +
+PaymasterERC20 + - [_validatePaymasterUserOp(userOp, userOpHash, maxCost)](#PaymasterERC20-_validatePaymasterUserOp-struct-PackedUserOperation-bytes32-uint256-) - [_postOp(, context, actualGasCost, actualUserOpFeePerGas)](#PaymasterERC20-_postOp-enum-IPaymaster-PostOpMode-bytes-uint256-uint256-) - [_fetchDetails(userOp, userOpHash)](#PaymasterERC20-_fetchDetails-struct-PackedUserOperation-bytes32-) @@ -3608,7 +3646,11 @@ logic based on the specific requirements of the application. - [_tokenPriceDenominator()](#PaymasterERC20-_tokenPriceDenominator--) - [_erc20Cost(cost, feePerGas, tokenPrice)](#PaymasterERC20-_erc20Cost-uint256-uint256-uint256-) - [withdrawTokens(token, recipient, amount)](#PaymasterERC20-withdrawTokens-contract-IERC20-address-uint256-) -#### PaymasterCore [!toc] + +
+
+PaymasterCore + - [entryPoint()](#PaymasterCore-entryPoint--) - [validatePaymasterUserOp(userOp, userOpHash, maxCost)](#PaymasterCore-validatePaymasterUserOp-struct-PackedUserOperation-bytes32-uint256-) - [postOp(mode, context, actualGasCost, actualUserOpFeePerGas)](#PaymasterCore-postOp-enum-IPaymaster-PostOpMode-bytes-uint256-uint256-) @@ -3619,7 +3661,8 @@ logic based on the specific requirements of the application. - [withdrawStake(to)](#PaymasterCore-withdrawStake-address-payable-) - [_checkEntryPoint()](#PaymasterCore-_checkEntryPoint--) - [_authorizeWithdraw()](#PaymasterCore-_authorizeWithdraw--) -#### IPaymaster [!toc] + +
@@ -3627,21 +3670,30 @@ logic based on the specific requirements of the application.

Events

- [UserOperationGuaranteed(userOpHash, guarantor, prefundAmount)](#PaymasterERC20Guarantor-UserOperationGuaranteed-bytes32-address-uint256-) -#### PaymasterERC20 [!toc] +
+PaymasterERC20 + - [UserOperationSponsored(userOpHash, token, tokenAmount, tokenPrice)](#PaymasterERC20-UserOperationSponsored-bytes32-address-uint256-uint256-) -#### PaymasterCore [!toc] -#### IPaymaster [!toc] + +

Errors

-#### PaymasterERC20 [!toc] +
+PaymasterERC20 + - [PaymasterERC20FailedRefund(token, prefundAmount, actualAmount, prefundContext)](#PaymasterERC20-PaymasterERC20FailedRefund-contract-IERC20-uint256-uint256-bytes-) -#### PaymasterCore [!toc] + +
+
+PaymasterCore + - [PaymasterUnauthorized(sender)](#PaymasterCore-PaymasterUnauthorized-address-) -#### IPaymaster [!toc] + +
@@ -3752,16 +3804,16 @@ Emitted when a user operation identified by `userOpHash` is guaranteed by a `gua
-## `PaymasterERC721Owner` +## `PaymasterERC721Owner` - +
```solidity -import "@openzeppelin/community-contracts/contracts/account/paymaster/PaymasterERC721Owner.sol"; +import "@openzeppelin/contracts/account/paymaster/PaymasterERC721Owner.sol"; ``` Extension of [`PaymasterCore`](#PaymasterCore) that supports account based on ownership of an ERC-721 token. @@ -3776,7 +3828,9 @@ during construction (or via [`PaymasterERC721Owner._setToken`](#PaymasterERC721O - [token()](#PaymasterERC721Owner-token--) - [_setToken(token_)](#PaymasterERC721Owner-_setToken-contract-IERC721-) - [_validatePaymasterUserOp(userOp, , )](#PaymasterERC721Owner-_validatePaymasterUserOp-struct-PackedUserOperation-bytes32-uint256-) -#### PaymasterCore [!toc] +
+PaymasterCore + - [entryPoint()](#PaymasterCore-entryPoint--) - [validatePaymasterUserOp(userOp, userOpHash, maxCost)](#PaymasterCore-validatePaymasterUserOp-struct-PackedUserOperation-bytes32-uint256-) - [postOp(mode, context, actualGasCost, actualUserOpFeePerGas)](#PaymasterCore-postOp-enum-IPaymaster-PostOpMode-bytes-uint256-uint256-) @@ -3788,7 +3842,8 @@ during construction (or via [`PaymasterERC721Owner._setToken`](#PaymasterERC721O - [withdrawStake(to)](#PaymasterCore-withdrawStake-address-payable-) - [_checkEntryPoint()](#PaymasterCore-_checkEntryPoint--) - [_authorizeWithdraw()](#PaymasterCore-_authorizeWithdraw--) -#### IPaymaster [!toc] + +
@@ -3796,17 +3851,18 @@ during construction (or via [`PaymasterERC721Owner._setToken`](#PaymasterERC721O

Events

- [PaymasterERC721OwnerTokenSet(token)](#PaymasterERC721Owner-PaymasterERC721OwnerTokenSet-contract-IERC721-) -#### PaymasterCore [!toc] -#### IPaymaster [!toc]

Errors

-#### PaymasterCore [!toc] +
+PaymasterCore + - [PaymasterUnauthorized(sender)](#PaymasterCore-PaymasterUnauthorized-address-) -#### IPaymaster [!toc] + +
@@ -3904,16 +3960,16 @@ Emitted when the paymaster token is set.
-## `PaymasterSigner` +## `PaymasterSigner` - +
```solidity -import "@openzeppelin/community-contracts/contracts/account/paymaster/PaymasterSigner.sol"; +import "@openzeppelin/contracts/account/paymaster/PaymasterSigner.sol"; ``` Extension of [`PaymasterCore`](#PaymasterCore) that adds signature validation. See `SignerECDSA`, `SignerP256` or `SignerRSA`. @@ -3932,7 +3988,9 @@ contract MyPaymasterECDSASigner is PaymasterSigner, SignerECDSA { - [_signableUserOpHash(userOp, validAfter, validUntil)](#PaymasterSigner-_signableUserOpHash-struct-PackedUserOperation-uint48-uint48-) - [_validatePaymasterUserOp(userOp, , )](#PaymasterSigner-_validatePaymasterUserOp-struct-PackedUserOperation-bytes32-uint256-) - [_decodePaymasterUserOp(userOp)](#PaymasterSigner-_decodePaymasterUserOp-struct-PackedUserOperation-) -#### PaymasterCore [!toc] +
+PaymasterCore + - [entryPoint()](#PaymasterCore-entryPoint--) - [validatePaymasterUserOp(userOp, userOpHash, maxCost)](#PaymasterCore-validatePaymasterUserOp-struct-PackedUserOperation-bytes32-uint256-) - [postOp(mode, context, actualGasCost, actualUserOpFeePerGas)](#PaymasterCore-postOp-enum-IPaymaster-PostOpMode-bytes-uint256-uint256-) @@ -3944,40 +4002,48 @@ contract MyPaymasterECDSASigner is PaymasterSigner, SignerECDSA { - [withdrawStake(to)](#PaymasterCore-withdrawStake-address-payable-) - [_checkEntryPoint()](#PaymasterCore-_checkEntryPoint--) - [_authorizeWithdraw()](#PaymasterCore-_authorizeWithdraw--) -#### IPaymaster [!toc] -#### EIP712 [!toc] + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### AbstractSigner [!toc] + +
+
+AbstractSigner + - [_rawSignatureValidation(hash, signature)](#AbstractSigner-_rawSignatureValidation-bytes32-bytes-) + +

Events

-#### PaymasterCore [!toc] -#### IPaymaster [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] +
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### AbstractSigner [!toc] + +

Errors

-#### PaymasterCore [!toc] +
+PaymasterCore + - [PaymasterUnauthorized(sender)](#PaymasterCore-PaymasterUnauthorized-address-) -#### IPaymaster [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### AbstractSigner [!toc] + +
diff --git a/content/community-contracts/api/crosschain.mdx b/content/community-contracts/api/crosschain.mdx index 1995d1fd..9bf23c6b 100644 --- a/content/community-contracts/api/crosschain.mdx +++ b/content/community-contracts/api/crosschain.mdx @@ -25,16 +25,16 @@ Developers can access interoperability protocols through gateway adapters. The l
-## `ERC7786OpenBridge` +## `ERC7786OpenBridge` - +
```solidity -import "@openzeppelin/community-contracts/contracts/crosschain/ERC7786OpenBridge.sol"; +import "@openzeppelin/contracts/crosschain/ERC7786OpenBridge.sol"; ``` N of M gateway: Sends your message through M independent gateways. It will be delivered to the recipient by an @@ -62,20 +62,26 @@ equivalent bridge on the destination chain if N of the M gateways agree. - [_removeGateway(gateway)](#ERC7786OpenBridge-_removeGateway-address-) - [_setThreshold(newThreshold)](#ERC7786OpenBridge-_setThreshold-uint8-) - [_registerRemoteBridge(bridge)](#ERC7786OpenBridge-_registerRemoteBridge-bytes-) -#### Pausable [!toc] +
+Pausable + - [paused()](#Pausable-paused--) - [_requireNotPaused()](#Pausable-_requireNotPaused--) - [_requirePaused()](#Pausable-_requirePaused--) - [_pause()](#Pausable-_pause--) - [_unpause()](#Pausable-_unpause--) -#### Ownable [!toc] + +
+
+Ownable + - [owner()](#Ownable-owner--) - [_checkOwner()](#Ownable-_checkOwner--) - [renounceOwnership()](#Ownable-renounceOwnership--) - [transferOwnership(newOwner)](#Ownable-transferOwnership-address-) - [_transferOwnership(newOwner)](#Ownable-_transferOwnership-address-) -#### IERC7786Recipient [!toc] -#### IERC7786GatewaySource [!toc] + +
@@ -90,14 +96,25 @@ equivalent bridge on the destination chain if N of the M gateways agree. - [GatewayRemoved(gateway)](#ERC7786OpenBridge-GatewayRemoved-address-) - [ThresholdUpdated(threshold)](#ERC7786OpenBridge-ThresholdUpdated-uint8-) - [RemoteRegistered(remote)](#ERC7786OpenBridge-RemoteRegistered-bytes-) -#### Pausable [!toc] +
+Pausable + - [Paused(account)](#Pausable-Paused-address-) - [Unpaused(account)](#Pausable-Unpaused-address-) -#### Ownable [!toc] + +
+
+Ownable + - [OwnershipTransferred(previousOwner, newOwner)](#Ownable-OwnershipTransferred-address-address-) -#### IERC7786Recipient [!toc] -#### IERC7786GatewaySource [!toc] + +
+
+IERC7786GatewaySource + - [MessageSent(sendId, sender, recipient, payload, value, attributes)](#IERC7786GatewaySource-MessageSent-bytes32-bytes-bytes-bytes-uint256-bytes---) + +
@@ -113,15 +130,26 @@ equivalent bridge on the destination chain if N of the M gateways agree. - [ERC7786OpenBridgeThresholdViolation()](#ERC7786OpenBridge-ERC7786OpenBridgeThresholdViolation--) - [ERC7786OpenBridgeInvalidExecutionReturnValue()](#ERC7786OpenBridge-ERC7786OpenBridgeInvalidExecutionReturnValue--) - [RemoteAlreadyRegistered(remote)](#ERC7786OpenBridge-RemoteAlreadyRegistered-bytes-) -#### Pausable [!toc] +
+Pausable + - [EnforcedPause()](#Pausable-EnforcedPause--) - [ExpectedPause()](#Pausable-ExpectedPause--) -#### Ownable [!toc] + +
+
+Ownable + - [OwnableUnauthorizedAccount(account)](#Ownable-OwnableUnauthorizedAccount-address-) - [OwnableInvalidOwner(owner)](#Ownable-OwnableInvalidOwner-address-) -#### IERC7786Recipient [!toc] -#### IERC7786GatewaySource [!toc] + +
+
+IERC7786GatewaySource + - [UnsupportedAttribute(selector)](#IERC7786GatewaySource-UnsupportedAttribute-bytes4-) + +
@@ -717,16 +745,16 @@ Recovery method in case value is ever received through [`ERC7786OpenBridge.recei
-## `AxelarGatewayAdapter` +## `AxelarGatewayAdapter` - +
```solidity -import "@openzeppelin/community-contracts/contracts/crosschain/axelar/AxelarGatewayAdapter.sol"; +import "@openzeppelin/contracts/crosschain/axelar/AxelarGatewayAdapter.sol"; ``` Implementation of an ERC-7786 gateway destination adapter for the Axelar Network in dual mode. @@ -756,17 +784,23 @@ networks (could be base58, base64, ...) but Axelar doesn't support that. - [sendMessage(recipient, payload, attributes)](#AxelarGatewayAdapter-sendMessage-bytes-bytes-bytes---) - [_execute(commandId, axelarSourceChain, axelarSourceAddress, adapterPayload)](#AxelarGatewayAdapter-_execute-bytes32-string-string-bytes-) - [_stringifyAddress(chainType, addr)](#AxelarGatewayAdapter-_stringifyAddress-bytes2-bytes-) -#### AxelarExecutable [!toc] +
+AxelarExecutable + - [execute(commandId, sourceChain, sourceAddress, payload)](#AxelarExecutable-execute-bytes32-string-string-bytes-) - [gateway()](#AxelarExecutable-gateway--) -#### IAxelarExecutable [!toc] -#### Ownable [!toc] + +
+
+Ownable + - [owner()](#Ownable-owner--) - [_checkOwner()](#Ownable-_checkOwner--) - [renounceOwnership()](#Ownable-renounceOwnership--) - [transferOwnership(newOwner)](#Ownable-transferOwnership-address-) - [_transferOwnership(newOwner)](#Ownable-_transferOwnership-address-) -#### IERC7786GatewaySource [!toc] + +
@@ -775,12 +809,18 @@ networks (could be base58, base64, ...) but Axelar doesn't support that.
- [RegisteredRemoteGateway(remote)](#AxelarGatewayAdapter-RegisteredRemoteGateway-bytes-) - [RegisteredChainEquivalence(erc7930binary, axelar)](#AxelarGatewayAdapter-RegisteredChainEquivalence-bytes-string-) -#### AxelarExecutable [!toc] -#### IAxelarExecutable [!toc] -#### Ownable [!toc] +
+Ownable + - [OwnershipTransferred(previousOwner, newOwner)](#Ownable-OwnershipTransferred-address-address-) -#### IERC7786GatewaySource [!toc] + +
+
+IERC7786GatewaySource + - [MessageSent(sendId, sender, recipient, payload, value, attributes)](#IERC7786GatewaySource-MessageSent-bytes32-bytes-bytes-bytes-uint256-bytes---) + +
@@ -796,15 +836,26 @@ networks (could be base58, base64, ...) but Axelar doesn't support that. - [InvalidChainIdentifier(erc7930binary)](#AxelarGatewayAdapter-InvalidChainIdentifier-bytes-) - [ChainEquivalenceAlreadyRegistered(erc7930binary, axelar)](#AxelarGatewayAdapter-ChainEquivalenceAlreadyRegistered-bytes-string-) - [RemoteGatewayAlreadyRegistered(chainType, chainReference)](#AxelarGatewayAdapter-RemoteGatewayAlreadyRegistered-bytes2-bytes-) -#### AxelarExecutable [!toc] -#### IAxelarExecutable [!toc] +
+IAxelarExecutable + - [InvalidAddress()](#IAxelarExecutable-InvalidAddress--) - [NotApprovedByGateway()](#IAxelarExecutable-NotApprovedByGateway--) -#### Ownable [!toc] + +
+
+Ownable + - [OwnableUnauthorizedAccount(account)](#Ownable-OwnableUnauthorizedAccount-address-) - [OwnableInvalidOwner(owner)](#Ownable-OwnableInvalidOwner-address-) -#### IERC7786GatewaySource [!toc] + +
+
+IERC7786GatewaySource + - [UnsupportedAttribute(selector)](#IERC7786GatewaySource-UnsupportedAttribute-bytes4-) + +
@@ -1184,16 +1235,16 @@ A chain equivalence has been registered.
-## `ERC7786Attributes` +## `ERC7786Attributes` - +
```solidity -import "@openzeppelin/community-contracts/contracts/crosschain/utils/ERC7786Attributes.sol"; +import "@openzeppelin/contracts/crosschain/utils/ERC7786Attributes.sol"; ``` Library of helper to parse/process ERC-7786 attributes @@ -1226,16 +1277,16 @@ Parse the `requestRelay(uint256,uint256,address)` (0x4cbb573a) attribute into it
-## `WormholeGatewayAdapter` +## `WormholeGatewayAdapter` - +
```solidity -import "@openzeppelin/community-contracts/contracts/crosschain/wormhole/WormholeGatewayAdapter.sol"; +import "@openzeppelin/contracts/crosschain/wormhole/WormholeGatewayAdapter.sol"; ``` An ERC-7786 compliant adapter to send and receive messages via Wormhole. @@ -1270,14 +1321,16 @@ Note: only EVM chains are currently supported - [quoteRelay(recipient, , , value, gasLimit, )](#WormholeGatewayAdapter-quoteRelay-bytes-bytes-bytes---uint256-uint256-address-) - [requestRelay(sendId, gasLimit, refundRecipient)](#WormholeGatewayAdapter-requestRelay-bytes32-uint256-address-) - [receiveWormholeMessages(adapterPayload, additionalMessages, wormholeSourceAddress, wormholeSourceChain, deliveryHash)](#WormholeGatewayAdapter-receiveWormholeMessages-bytes-bytes---bytes32-uint16-bytes32-) -#### Ownable [!toc] +
+Ownable + - [owner()](#Ownable-owner--) - [_checkOwner()](#Ownable-_checkOwner--) - [renounceOwnership()](#Ownable-renounceOwnership--) - [transferOwnership(newOwner)](#Ownable-transferOwnership-address-) - [_transferOwnership(newOwner)](#Ownable-_transferOwnership-address-) -#### IWormholeReceiver [!toc] -#### IERC7786GatewaySource [!toc] + +
@@ -1287,11 +1340,18 @@ Note: only EVM chains are currently supported - [MessageRelayed(sendId)](#WormholeGatewayAdapter-MessageRelayed-bytes32-) - [RegisteredRemoteGateway(chainId, remote)](#WormholeGatewayAdapter-RegisteredRemoteGateway-uint256-address-) - [RegisteredChainEquivalence(chainId, wormholeId)](#WormholeGatewayAdapter-RegisteredChainEquivalence-uint256-uint16-) -#### Ownable [!toc] +
+Ownable + - [OwnershipTransferred(previousOwner, newOwner)](#Ownable-OwnershipTransferred-address-address-) -#### IWormholeReceiver [!toc] -#### IERC7786GatewaySource [!toc] + +
+
+IERC7786GatewaySource + - [MessageSent(sendId, sender, recipient, payload, value, attributes)](#IERC7786GatewaySource-MessageSent-bytes32-bytes-bytes-bytes-uint256-bytes---) + +
@@ -1310,12 +1370,19 @@ Note: only EVM chains are currently supported - [InvalidSendId(sendId)](#WormholeGatewayAdapter-InvalidSendId-bytes32-) - [AdditionalMessagesNotSupported()](#WormholeGatewayAdapter-AdditionalMessagesNotSupported--) - [MessageAlreadyExecuted(chainId, outboxId)](#WormholeGatewayAdapter-MessageAlreadyExecuted-uint256-bytes32-) -#### Ownable [!toc] +
+Ownable + - [OwnableUnauthorizedAccount(account)](#Ownable-OwnableUnauthorizedAccount-address-) - [OwnableInvalidOwner(owner)](#Ownable-OwnableInvalidOwner-address-) -#### IWormholeReceiver [!toc] -#### IERC7786GatewaySource [!toc] + +
+
+IERC7786GatewaySource + - [UnsupportedAttribute(selector)](#IERC7786GatewaySource-UnsupportedAttribute-bytes4-) + +
diff --git a/content/community-contracts/api/governance.mdx b/content/community-contracts/api/governance.mdx index b0a3ff62..c8f9ab83 100644 --- a/content/community-contracts/api/governance.mdx +++ b/content/community-contracts/api/governance.mdx @@ -15,16 +15,16 @@ This directory includes extensions and utilities for on-chain governance.
-## `TimelockControllerEnumerable` +## `TimelockControllerEnumerable` - +
```solidity -import "@openzeppelin/community-contracts/contracts/governance/TimelockControllerEnumerable.sol"; +import "@openzeppelin/contracts/governance/TimelockControllerEnumerable.sol"; ``` Extends the TimelockController to allow for enumerable operations @@ -45,7 +45,9 @@ Extends the TimelockController to allow for enumerable operations - [operationsBatchCount()](#TimelockControllerEnumerable-operationsBatchCount--) - [operationBatch(index)](#TimelockControllerEnumerable-operationBatch-uint256-) - [operationBatch(id)](#TimelockControllerEnumerable-operationBatch-bytes32-) -#### TimelockController [!toc] +
+TimelockController + - [receive()](#TimelockController-receive--) - [supportsInterface(interfaceId)](#TimelockController-supportsInterface-bytes4-) - [isOperation(id)](#TimelockController-isOperation-bytes32-) @@ -65,14 +67,24 @@ Extends the TimelockController to allow for enumerable operations - [PROPOSER_ROLE()](#TimelockController-PROPOSER_ROLE-bytes32) - [EXECUTOR_ROLE()](#TimelockController-EXECUTOR_ROLE-bytes32) - [CANCELLER_ROLE()](#TimelockController-CANCELLER_ROLE-bytes32) -#### ERC1155Holder [!toc] + +
+
+ERC1155Holder + - [onERC1155Received(, , , , )](#ERC1155Holder-onERC1155Received-address-address-uint256-uint256-bytes-) - [onERC1155BatchReceived(, , , , )](#ERC1155Holder-onERC1155BatchReceived-address-address-uint256---uint256---bytes-) -#### IERC1155Receiver [!toc] -#### ERC721Holder [!toc] + +
+
+ERC721Holder + - [onERC721Received(, , , )](#ERC721Holder-onERC721Received-address-address-uint256-bytes-) -#### IERC721Receiver [!toc] -#### AccessControl [!toc] + +
+
+AccessControl + - [hasRole(role, account)](#AccessControl-hasRole-bytes32-address-) - [_checkRole(role)](#AccessControl-_checkRole-bytes32-) - [_checkRole(role, account)](#AccessControl-_checkRole-bytes32-address-) @@ -84,32 +96,32 @@ Extends the TimelockController to allow for enumerable operations - [_grantRole(role, account)](#AccessControl-_grantRole-bytes32-address-) - [_revokeRole(role, account)](#AccessControl-_revokeRole-bytes32-address-) - [DEFAULT_ADMIN_ROLE()](#AccessControl-DEFAULT_ADMIN_ROLE-bytes32) -#### ERC165 [!toc] -#### IERC165 [!toc] -#### IAccessControl [!toc] + +

Events

-#### TimelockController [!toc] +
+TimelockController + - [CallScheduled(id, index, target, value, data, predecessor, delay)](#TimelockController-CallScheduled-bytes32-uint256-address-uint256-bytes-bytes32-uint256-) - [CallExecuted(id, index, target, value, data)](#TimelockController-CallExecuted-bytes32-uint256-address-uint256-bytes-) - [CallSalt(id, salt)](#TimelockController-CallSalt-bytes32-bytes32-) - [Cancelled(id)](#TimelockController-Cancelled-bytes32-) - [MinDelayChange(oldDuration, newDuration)](#TimelockController-MinDelayChange-uint256-uint256-) -#### ERC1155Holder [!toc] -#### IERC1155Receiver [!toc] -#### ERC721Holder [!toc] -#### IERC721Receiver [!toc] -#### AccessControl [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] -#### IAccessControl [!toc] + +
+
+IAccessControl + - [RoleAdminChanged(role, previousAdminRole, newAdminRole)](#IAccessControl-RoleAdminChanged-bytes32-bytes32-bytes32-) - [RoleGranted(role, account, sender)](#IAccessControl-RoleGranted-bytes32-address-address-) - [RoleRevoked(role, account, sender)](#IAccessControl-RoleRevoked-bytes32-address-address-) + +
@@ -121,22 +133,23 @@ Extends the TimelockController to allow for enumerable operations - [OperationBatchIndexNotFound(index)](#TimelockControllerEnumerable-OperationBatchIndexNotFound-uint256-) - [OperationBatchIdNotFound(id)](#TimelockControllerEnumerable-OperationBatchIdNotFound-bytes32-) - [InvalidIndexRange(start, end)](#TimelockControllerEnumerable-InvalidIndexRange-uint256-uint256-) -#### TimelockController [!toc] +
+TimelockController + - [TimelockInvalidOperationLength(targets, payloads, values)](#TimelockController-TimelockInvalidOperationLength-uint256-uint256-uint256-) - [TimelockInsufficientDelay(delay, minDelay)](#TimelockController-TimelockInsufficientDelay-uint256-uint256-) - [TimelockUnexpectedOperationState(operationId, expectedStates)](#TimelockController-TimelockUnexpectedOperationState-bytes32-bytes32-) - [TimelockUnexecutedPredecessor(predecessorId)](#TimelockController-TimelockUnexecutedPredecessor-bytes32-) - [TimelockUnauthorizedCaller(caller)](#TimelockController-TimelockUnauthorizedCaller-address-) -#### ERC1155Holder [!toc] -#### IERC1155Receiver [!toc] -#### ERC721Holder [!toc] -#### IERC721Receiver [!toc] -#### AccessControl [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] -#### IAccessControl [!toc] + +
+
+IAccessControl + - [AccessControlUnauthorizedAccount(account, neededRole)](#IAccessControl-AccessControlUnauthorizedAccount-address-bytes32-) - [AccessControlBadConfirmation()](#IAccessControl-AccessControlBadConfirmation--) + +
diff --git a/content/community-contracts/api/interfaces.mdx b/content/community-contracts/api/interfaces.mdx index 3cb609d2..e5f34825 100644 --- a/content/community-contracts/api/interfaces.mdx +++ b/content/community-contracts/api/interfaces.mdx @@ -20,16 +20,16 @@ These interfaces are available as `.sol` files. These are useful to interact wit
-## `IERC7786Attributes` +## `IERC7786Attributes` - +
```solidity -import "@openzeppelin/community-contracts/contracts/interfaces/IERC7786Attributes.sol"; +import "@openzeppelin/contracts/interfaces/IERC7786Attributes.sol"; ``` Standard attributes for ERC-7786. These attributes may be standardized in different ERCs. @@ -60,16 +60,16 @@ Standard attributes for ERC-7786. These attributes may be standardized in differ
-## `IERC7943Fungible` +## `IERC7943Fungible` - +
```solidity -import "@openzeppelin/community-contracts/contracts/interfaces/IERC7943.sol"; +import "@openzeppelin/contracts/interfaces/IERC7943.sol"; ```
@@ -80,8 +80,12 @@ import "@openzeppelin/community-contracts/contracts/interfaces/IERC7943.sol"; - [canTransact(account)](#IERC7943Fungible-canTransact-address-) - [getFrozenTokens(account)](#IERC7943Fungible-getFrozenTokens-address-) - [canTransfer(from, to, amount)](#IERC7943Fungible-canTransfer-address-address-uint256-) -#### IERC165 [!toc] +
+IERC165 + - [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) + +
@@ -90,7 +94,6 @@ import "@openzeppelin/community-contracts/contracts/interfaces/IERC7943.sol";
- [ForcedTransfer(from, to, amount)](#IERC7943Fungible-ForcedTransfer-address-address-uint256-) - [Frozen(account, amount)](#IERC7943Fungible-Frozen-address-uint256-) -#### IERC165 [!toc]
@@ -100,7 +103,6 @@ import "@openzeppelin/community-contracts/contracts/interfaces/IERC7943.sol"; - [ERC7943CannotTransact(account)](#IERC7943Fungible-ERC7943CannotTransact-address-) - [ERC7943CannotTransfer(from, to, amount)](#IERC7943Fungible-ERC7943CannotTransfer-address-address-uint256-) - [ERC7943InsufficientUnfrozenBalance(account, amount, unfrozen)](#IERC7943Fungible-ERC7943InsufficientUnfrozenBalance-address-uint256-uint256-) -#### IERC165 [!toc]
@@ -269,16 +271,16 @@ This can involve checks like allowlists, blocklists, transfer limits and other p
-## `IERC7943NonFungible` +## `IERC7943NonFungible` - +
```solidity -import "@openzeppelin/community-contracts/contracts/interfaces/IERC7943.sol"; +import "@openzeppelin/contracts/interfaces/IERC7943.sol"; ```
@@ -289,8 +291,12 @@ import "@openzeppelin/community-contracts/contracts/interfaces/IERC7943.sol"; - [canTransact(account)](#IERC7943NonFungible-canTransact-address-) - [getFrozenTokens(account, tokenId)](#IERC7943NonFungible-getFrozenTokens-address-uint256-) - [canTransfer(from, to, tokenId)](#IERC7943NonFungible-canTransfer-address-address-uint256-) -#### IERC165 [!toc] +
+IERC165 + - [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) + +
@@ -299,7 +305,6 @@ import "@openzeppelin/community-contracts/contracts/interfaces/IERC7943.sol";
- [ForcedTransfer(from, to, tokenId)](#IERC7943NonFungible-ForcedTransfer-address-address-uint256-) - [Frozen(account, tokenId, frozenStatus)](#IERC7943NonFungible-Frozen-address-uint256-bool-) -#### IERC165 [!toc]
@@ -309,7 +314,6 @@ import "@openzeppelin/community-contracts/contracts/interfaces/IERC7943.sol"; - [ERC7943CannotTransact(account)](#IERC7943NonFungible-ERC7943CannotTransact-address-) - [ERC7943CannotTransfer(from, to, tokenId)](#IERC7943NonFungible-ERC7943CannotTransfer-address-address-uint256-) - [ERC7943InsufficientUnfrozenBalance(account, tokenId)](#IERC7943NonFungible-ERC7943InsufficientUnfrozenBalance-address-uint256-) -#### IERC165 [!toc] @@ -478,16 +482,16 @@ This can involve checks like allowlists, blocklists, transfer limits and other p
-## `IERC7943MultiToken` +## `IERC7943MultiToken` - +
```solidity -import "@openzeppelin/community-contracts/contracts/interfaces/IERC7943.sol"; +import "@openzeppelin/contracts/interfaces/IERC7943.sol"; ```
@@ -498,8 +502,12 @@ import "@openzeppelin/community-contracts/contracts/interfaces/IERC7943.sol"; - [canTransact(account)](#IERC7943MultiToken-canTransact-address-) - [getFrozenTokens(account, tokenId)](#IERC7943MultiToken-getFrozenTokens-address-uint256-) - [canTransfer(from, to, tokenId, amount)](#IERC7943MultiToken-canTransfer-address-address-uint256-uint256-) -#### IERC165 [!toc] +
+IERC165 + - [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) + +
@@ -508,7 +516,6 @@ import "@openzeppelin/community-contracts/contracts/interfaces/IERC7943.sol";
- [ForcedTransfer(from, to, tokenId, amount)](#IERC7943MultiToken-ForcedTransfer-address-address-uint256-uint256-) - [Frozen(account, tokenId, amount)](#IERC7943MultiToken-Frozen-address-uint256-uint256-) -#### IERC165 [!toc]
@@ -518,7 +525,6 @@ import "@openzeppelin/community-contracts/contracts/interfaces/IERC7943.sol"; - [ERC7943CannotTransact(account)](#IERC7943MultiToken-ERC7943CannotTransact-address-) - [ERC7943CannotTransfer(from, to, tokenId, amount)](#IERC7943MultiToken-ERC7943CannotTransfer-address-address-uint256-uint256-) - [ERC7943InsufficientUnfrozenBalance(account, tokenId, amount, unfrozen)](#IERC7943MultiToken-ERC7943InsufficientUnfrozenBalance-address-uint256-uint256-uint256-) -#### IERC165 [!toc] @@ -687,16 +693,16 @@ This can involve checks like allowlists, blocklists, transfer limits and other p
-## `IDKIMRegistry` +## `IDKIMRegistry` - +
```solidity -import "@openzeppelin/community-contracts/contracts/interfaces/IERC7969.sol"; +import "@openzeppelin/contracts/interfaces/IERC7969.sol"; ``` This interface provides a standard way to register and validate DKIM public key hashes onchain diff --git a/content/community-contracts/api/proxy.mdx b/content/community-contracts/api/proxy.mdx index 1292c7fe..c0d7864b 100644 --- a/content/community-contracts/api/proxy.mdx +++ b/content/community-contracts/api/proxy.mdx @@ -15,16 +15,16 @@ Variants of proxy patterns, which are contracts that allow to forward a call to
-## `HybridProxy` +## `HybridProxy` - +
```solidity -import "@openzeppelin/community-contracts/contracts/proxy/HybridProxy.sol"; +import "@openzeppelin/contracts/proxy/HybridProxy.sol"; ``` A version of an ERC-1967 proxy that uses the address stored in the implementation slot as a beacon. @@ -45,10 +45,14 @@ the returned address will be used as this proxy's implementation.
- [constructor(implementation, data)](#HybridProxy-constructor-address-bytes-) - [_implementation()](#HybridProxy-_implementation--) -#### Proxy [!toc] +
+Proxy + - [_delegate(implementation)](#Proxy-_delegate-address-) - [_fallback()](#Proxy-_fallback--) - [fallback()](#Proxy-fallback--) + +
diff --git a/content/community-contracts/api/token.mdx b/content/community-contracts/api/token.mdx index ab1b9292..5e4e7a87 100644 --- a/content/community-contracts/api/token.mdx +++ b/content/community-contracts/api/token.mdx @@ -32,16 +32,16 @@ Set of extensions and utilities for tokens (e.g ERC-20, ERC-721, ERC-1155) and d
-## `ERC20Allowlist` +## `ERC20Allowlist` - +
```solidity -import "@openzeppelin/community-contracts/contracts/token/ERC20/extensions/ERC20Allowlist.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Allowlist.sol"; ``` Extension of `ERC20` that allows to implement an allowlist @@ -67,7 +67,9 @@ Deprecated. Use [`ERC20Restricted`](#ERC20Restricted) instead. - [_disallowUser(user)](#ERC20Allowlist-_disallowUser-address-) - [_update(from, to, value)](#ERC20Allowlist-_update-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20Allowlist-_approve-address-address-uint256-bool-) -#### ERC20 [!toc] +
+ERC20 + - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) - [decimals()](#ERC20-decimals--) @@ -82,9 +84,8 @@ Deprecated. Use [`ERC20Restricted`](#ERC20Restricted) instead. - [_burn(account, value)](#ERC20-_burn-address-uint256-) - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
@@ -93,12 +94,13 @@ Deprecated. Use [`ERC20Restricted`](#ERC20Restricted) instead.
- [UserAllowed(user)](#ERC20Allowlist-UserAllowed-address-) - [UserDisallowed(user)](#ERC20Allowlist-UserDisallowed-address-) -#### ERC20 [!toc] -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] +
+IERC20 + - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +
@@ -106,16 +108,17 @@ Deprecated. Use [`ERC20Restricted`](#ERC20Restricted) instead.

Errors

- [ERC20Disallowed(user)](#ERC20Allowlist-ERC20Disallowed-address-) -#### ERC20 [!toc] -#### IERC20Errors [!toc] +
+IERC20Errors + - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) - [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) - [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) - [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) - [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) - [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
@@ -260,16 +263,16 @@ The operation failed because the user is not allowed.
-## `ERC20Blocklist` +## `ERC20Blocklist` - +
```solidity -import "@openzeppelin/community-contracts/contracts/token/ERC20/extensions/ERC20Blocklist.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Blocklist.sol"; ``` Extension of `ERC20` that allows to implement a blocklist @@ -295,7 +298,9 @@ Deprecated. Use [`ERC20Restricted`](#ERC20Restricted) instead. - [_unblockUser(user)](#ERC20Blocklist-_unblockUser-address-) - [_update(from, to, value)](#ERC20Blocklist-_update-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20Blocklist-_approve-address-address-uint256-bool-) -#### ERC20 [!toc] +
+ERC20 + - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) - [decimals()](#ERC20-decimals--) @@ -310,9 +315,8 @@ Deprecated. Use [`ERC20Restricted`](#ERC20Restricted) instead. - [_burn(account, value)](#ERC20-_burn-address-uint256-) - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
@@ -321,12 +325,13 @@ Deprecated. Use [`ERC20Restricted`](#ERC20Restricted) instead.
- [UserBlocked(user)](#ERC20Blocklist-UserBlocked-address-) - [UserUnblocked(user)](#ERC20Blocklist-UserUnblocked-address-) -#### ERC20 [!toc] -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] +
+IERC20 + - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +
@@ -334,16 +339,17 @@ Deprecated. Use [`ERC20Restricted`](#ERC20Restricted) instead.

Errors

- [ERC20Blocked(user)](#ERC20Blocklist-ERC20Blocked-address-) -#### ERC20 [!toc] -#### IERC20Errors [!toc] +
+IERC20Errors + - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) - [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) - [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) - [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) - [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) - [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
@@ -488,16 +494,16 @@ The operation failed because the user is blocked.
-## `ERC20Collateral` +## `ERC20Collateral` - +
```solidity -import "@openzeppelin/community-contracts/contracts/token/ERC20/extensions/ERC20Collateral.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Collateral.sol"; ``` Extension of `ERC20` that limits the supply of tokens based @@ -515,8 +521,9 @@ data. This function can call external oracles or use any local storage. - [CLOCK_MODE()](#ERC20Collateral-CLOCK_MODE--) - [collateral()](#ERC20Collateral-collateral--) - [_update(from, to, value)](#ERC20Collateral-_update-address-address-uint256-) -#### IERC6372 [!toc] -#### ERC20 [!toc] +
+ERC20 + - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) - [decimals()](#ERC20-decimals--) @@ -532,22 +539,21 @@ data. This function can call external oracles or use any local storage. - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +

Events

-#### IERC6372 [!toc] -#### ERC20 [!toc] -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] +
+IERC20 + - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +
@@ -556,17 +562,17 @@ data. This function can call external oracles or use any local storage.
- [ERC20ExceededSupply(increasedSupply, cap)](#ERC20Collateral-ERC20ExceededSupply-uint256-uint256-) - [ERC20ExpiredCollateral(timestamp, expiration)](#ERC20Collateral-ERC20ExpiredCollateral-uint48-uint48-) -#### IERC6372 [!toc] -#### ERC20 [!toc] -#### IERC20Errors [!toc] +
+IERC20Errors + - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) - [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) - [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) - [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) - [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) - [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
@@ -711,16 +717,16 @@ Collateral amount has expired.
-## `ERC20Custodian` +## `ERC20Custodian` - +
```solidity -import "@openzeppelin/community-contracts/contracts/token/ERC20/extensions/ERC20Custodian.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Custodian.sol"; ``` Extension of `ERC20` that allows to implement a custodian @@ -754,7 +760,9 @@ Deprecated. Use [`ERC20Freezable`](#ERC20Freezable) instead. - [availableBalance(account)](#ERC20Custodian-availableBalance-address-) - [_isCustodian(user)](#ERC20Custodian-_isCustodian-address-) - [_update(from, to, value)](#ERC20Custodian-_update-address-address-uint256-) -#### ERC20 [!toc] +
+ERC20 + - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) - [decimals()](#ERC20-decimals--) @@ -770,9 +778,8 @@ Deprecated. Use [`ERC20Freezable`](#ERC20Freezable) instead. - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
@@ -781,12 +788,13 @@ Deprecated. Use [`ERC20Freezable`](#ERC20Freezable) instead.
- [TokensFrozen(user, amount)](#ERC20Custodian-TokensFrozen-address-uint256-) - [TokensUnfrozen(user, amount)](#ERC20Custodian-TokensUnfrozen-address-uint256-) -#### ERC20 [!toc] -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] +
+IERC20 + - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +
@@ -796,16 +804,17 @@ Deprecated. Use [`ERC20Freezable`](#ERC20Freezable) instead. - [ERC20InsufficientUnfrozenBalance(user)](#ERC20Custodian-ERC20InsufficientUnfrozenBalance-address-) - [ERC20InsufficientFrozenBalance(user)](#ERC20Custodian-ERC20InsufficientFrozenBalance-address-) - [ERC20NotCustodian()](#ERC20Custodian-ERC20NotCustodian--) -#### ERC20 [!toc] -#### IERC20Errors [!toc] +
+IERC20Errors + - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) - [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) - [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) - [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) - [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) - [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
@@ -1006,16 +1015,16 @@ Error thrown when a non-custodian account attempts to perform a custodian-only o
-## `ERC20Freezable` +## `ERC20Freezable` - +
```solidity -import "@openzeppelin/community-contracts/contracts/token/ERC20/extensions/ERC20Freezable.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Freezable.sol"; ``` Extension of `ERC20` that allows to implement a freezing @@ -1034,7 +1043,9 @@ is reduced using [`ERC20Freezable._setFrozen`](#ERC20Freezable-_setFrozen-addres - [available(account)](#ERC20Freezable-available-address-) - [_setFrozen(account, amount)](#ERC20Freezable-_setFrozen-address-uint256-) - [_update(from, to, value)](#ERC20Freezable-_update-address-address-uint256-) -#### ERC20 [!toc] +
+ERC20 + - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) - [decimals()](#ERC20-decimals--) @@ -1050,21 +1061,21 @@ is reduced using [`ERC20Freezable._setFrozen`](#ERC20Freezable-_setFrozen-addres - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +

Events

-#### ERC20 [!toc] -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] +
+IERC20 + - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +
@@ -1072,16 +1083,17 @@ is reduced using [`ERC20Freezable._setFrozen`](#ERC20Freezable-_setFrozen-addres

Errors

- [ERC20InsufficientUnfrozenBalance(account, needed, available)](#ERC20Freezable-ERC20InsufficientUnfrozenBalance-address-uint256-uint256-) -#### ERC20 [!toc] -#### IERC20Errors [!toc] +
+IERC20Errors + - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) - [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) - [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) - [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) - [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) - [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
@@ -1178,16 +1190,16 @@ The operation failed because the account has insufficient unfrozen balance.
-## `ERC20Restricted` +## `ERC20Restricted` - +
```solidity -import "@openzeppelin/community-contracts/contracts/token/ERC20/extensions/ERC20Restricted.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Restricted.sol"; ``` Extension of `ERC20` that allows to implement user account transfer restrictions @@ -1208,7 +1220,9 @@ to implement an allowlist. - [_allowUser(account)](#ERC20Restricted-_allowUser-address-) - [_resetUser(account)](#ERC20Restricted-_resetUser-address-) - [_checkRestriction(account)](#ERC20Restricted-_checkRestriction-address-) -#### ERC20 [!toc] +
+ERC20 + - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) - [decimals()](#ERC20-decimals--) @@ -1224,9 +1238,8 @@ to implement an allowlist. - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
@@ -1234,12 +1247,13 @@ to implement an allowlist.

Events

- [UserRestrictionsUpdated(account, restriction)](#ERC20Restricted-UserRestrictionsUpdated-address-enum-ERC20Restricted-Restriction-) -#### ERC20 [!toc] -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] +
+IERC20 + - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +
@@ -1247,16 +1261,17 @@ to implement an allowlist.

Errors

- [ERC20UserRestricted(account)](#ERC20Restricted-ERC20UserRestricted-address-) -#### ERC20 [!toc] -#### IERC20Errors [!toc] +
+IERC20Errors + - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) - [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) - [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) - [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) - [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) - [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
@@ -1450,16 +1465,16 @@ The operation failed because the user account is restricted.
-## `ERC20uRWA` +## `ERC20uRWA` - +
```solidity -import "@openzeppelin/community-contracts/contracts/token/ERC20/extensions/ERC20uRWA.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/ERC20uRWA.sol"; ``` Extension of `ERC20` according to [EIP-7943](https://eips.ethereum.org/EIPS/eip-7943). @@ -1481,21 +1496,28 @@ logic. - [_update(from, to, amount)](#ERC20uRWA-_update-address-address-uint256-) - [_checkEnforcer(from, to, amount)](#ERC20uRWA-_checkEnforcer-address-address-uint256-) - [_checkFreezer(account, amount)](#ERC20uRWA-_checkFreezer-address-uint256-) -#### IERC7943Fungible [!toc] -#### ERC20Restricted [!toc] +
+ERC20Restricted + - [getRestriction(account)](#ERC20Restricted-getRestriction-address-) - [_setRestriction(account, restriction)](#ERC20Restricted-_setRestriction-address-enum-ERC20Restricted-Restriction-) - [_blockUser(account)](#ERC20Restricted-_blockUser-address-) - [_allowUser(account)](#ERC20Restricted-_allowUser-address-) - [_resetUser(account)](#ERC20Restricted-_resetUser-address-) - [_checkRestriction(account)](#ERC20Restricted-_checkRestriction-address-) -#### ERC20Freezable [!toc] + +
+
+ERC20Freezable + - [frozen(account)](#ERC20Freezable-frozen-address-) - [available(account)](#ERC20Freezable-available-address-) - [_setFrozen(account, amount)](#ERC20Freezable-_setFrozen-address-uint256-) -#### ERC165 [!toc] -#### IERC165 [!toc] -#### ERC20 [!toc] + +
+
+ERC20 + - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) - [decimals()](#ERC20-decimals--) @@ -1511,55 +1533,71 @@ logic. - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +

Events

-#### IERC7943Fungible [!toc] +
+IERC7943Fungible + - [ForcedTransfer(from, to, amount)](#IERC7943Fungible-ForcedTransfer-address-address-uint256-) - [Frozen(account, amount)](#IERC7943Fungible-Frozen-address-uint256-) -#### ERC20Restricted [!toc] + +
+
+ERC20Restricted + - [UserRestrictionsUpdated(account, restriction)](#ERC20Restricted-UserRestrictionsUpdated-address-enum-ERC20Restricted-Restriction-) -#### ERC20Freezable [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] -#### ERC20 [!toc] -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
+
+IERC20 + - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +

Errors

-#### IERC7943Fungible [!toc] +
+IERC7943Fungible + - [ERC7943CannotTransact(account)](#IERC7943Fungible-ERC7943CannotTransact-address-) - [ERC7943CannotTransfer(from, to, amount)](#IERC7943Fungible-ERC7943CannotTransfer-address-address-uint256-) - [ERC7943InsufficientUnfrozenBalance(account, amount, unfrozen)](#IERC7943Fungible-ERC7943InsufficientUnfrozenBalance-address-uint256-uint256-) -#### ERC20Restricted [!toc] + +
+
+ERC20Restricted + - [ERC20UserRestricted(account)](#ERC20Restricted-ERC20UserRestricted-address-) -#### ERC20Freezable [!toc] + +
+
+ERC20Freezable + - [ERC20InsufficientUnfrozenBalance(account, needed, available)](#ERC20Freezable-ERC20InsufficientUnfrozenBalance-address-uint256-uint256-) -#### ERC165 [!toc] -#### IERC165 [!toc] -#### ERC20 [!toc] -#### IERC20Errors [!toc] + +
+
+IERC20Errors + - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) - [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) - [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) - [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) - [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) - [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
@@ -1771,16 +1809,16 @@ function _checkFreezer(address account, uint256 amount) internal view override o
-## `ERC4626Fees` +## `ERC4626Fees` - +
```solidity -import "@openzeppelin/community-contracts/contracts/token/ERC20/extensions/ERC4626Fees.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/ERC4626Fees.sol"; ``` ERC-4626 vault with entry/exit fees expressed in [basis point (bp)](https://en.wikipedia.org/wiki/Basis_point). @@ -1798,7 +1836,9 @@ ERC-4626 vault with entry/exit fees expressed in [basis point (bp)](https://en.w - [_exitFeeBasisPoints()](#ERC4626Fees-_exitFeeBasisPoints--) - [_entryFeeRecipient()](#ERC4626Fees-_entryFeeRecipient--) - [_exitFeeRecipient()](#ERC4626Fees-_exitFeeRecipient--) -#### ERC4626 [!toc] +
+ERC4626 + - [decimals()](#ERC4626-decimals--) - [asset()](#ERC4626-asset--) - [totalAssets()](#ERC4626-totalAssets--) @@ -1817,8 +1857,11 @@ ERC-4626 vault with entry/exit fees expressed in [basis point (bp)](https://en.w - [_transferIn(from, assets)](#ERC4626-_transferIn-address-uint256-) - [_transferOut(to, assets)](#ERC4626-_transferOut-address-uint256-) - [_decimalsOffset()](#ERC4626-_decimalsOffset--) -#### IERC4626 [!toc] -#### ERC20 [!toc] + +
+
+ERC20 + - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) - [totalSupply()](#ERC20-totalSupply--) @@ -1834,47 +1877,54 @@ ERC-4626 vault with entry/exit fees expressed in [basis point (bp)](https://en.w - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +

Events

-#### ERC4626 [!toc] -#### IERC4626 [!toc] +
+IERC4626 + - [Deposit(sender, owner, assets, shares)](#IERC4626-Deposit-address-address-uint256-uint256-) - [Withdraw(sender, receiver, owner, assets, shares)](#IERC4626-Withdraw-address-address-address-uint256-uint256-) -#### ERC20 [!toc] -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
+
+IERC20 + - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +

Errors

-#### ERC4626 [!toc] +
+ERC4626 + - [ERC4626ExceededMaxDeposit(receiver, assets, max)](#ERC4626-ERC4626ExceededMaxDeposit-address-uint256-uint256-) - [ERC4626ExceededMaxMint(receiver, shares, max)](#ERC4626-ERC4626ExceededMaxMint-address-uint256-uint256-) - [ERC4626ExceededMaxWithdraw(owner, assets, max)](#ERC4626-ERC4626ExceededMaxWithdraw-address-uint256-uint256-) - [ERC4626ExceededMaxRedeem(owner, shares, max)](#ERC4626-ERC4626ExceededMaxRedeem-address-uint256-uint256-) -#### IERC4626 [!toc] -#### ERC20 [!toc] -#### IERC20Errors [!toc] + +
+
+IERC20Errors + - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) - [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) - [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) - [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) - [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) - [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
@@ -2044,16 +2094,16 @@ Send exit fee to [`ERC4626Fees._exitFeeRecipient`](#ERC4626Fees-_exitFeeRecipien
-## `OnTokenTransferAdapter` +## `OnTokenTransferAdapter` - +
```solidity -import "@openzeppelin/community-contracts/contracts/token/OnTokenTransferAdapter.sol"; +import "@openzeppelin/contracts/token/OnTokenTransferAdapter.sol"; ``` This contract exposes the 667 `onTokenTransfer` hook on top of `IERC1363Receiver-onTransferReceived`. @@ -2065,8 +2115,12 @@ Chainlink's Link, that implement the 667 interface for transferAndCall.

Functions

- [onTokenTransfer(from, amount, data)](#OnTokenTransferAdapter-onTokenTransfer-address-uint256-bytes-) -#### IERC1363Receiver [!toc] +
+IERC1363Receiver + - [onTransferReceived(operator, from, value, data)](#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) + +
diff --git a/content/community-contracts/api/utils.mdx b/content/community-contracts/api/utils.mdx index 7992481d..8993dc5e 100644 --- a/content/community-contracts/api/utils.mdx +++ b/content/community-contracts/api/utils.mdx @@ -22,16 +22,16 @@ Miscellaneous contracts and libraries containing utility functions you can use t
-## `Masks` +## `Masks` - +
```solidity -import "@openzeppelin/community-contracts/contracts/utils/Masks.sol"; +import "@openzeppelin/contracts/utils/Masks.sol"; ``` Library for handling bit masks @@ -208,16 +208,16 @@ Returns the symmetric difference (∆) of two masks, also known as disjunctive u
-## `EnumerableMapExtended` +## `EnumerableMapExtended` - +
```solidity -import "@openzeppelin/community-contracts/contracts/utils/structs/EnumerableMapExtended.sol"; +import "@openzeppelin/contracts/utils/structs/EnumerableMapExtended.sol"; ``` Library for managing an enumerable variant of Solidity's @@ -741,16 +741,16 @@ Query for a nonexistent map key.
-## `EnumerableSetExtended` +## `EnumerableSetExtended` - +
```solidity -import "@openzeppelin/community-contracts/contracts/utils/structs/EnumerableSetExtended.sol"; +import "@openzeppelin/contracts/utils/structs/EnumerableSetExtended.sol"; ``` Library for managing diff --git a/content/community-contracts/api/utils/cryptography.mdx b/content/community-contracts/api/utils/cryptography.mdx index 742b7569..30a523fa 100644 --- a/content/community-contracts/api/utils/cryptography.mdx +++ b/content/community-contracts/api/utils/cryptography.mdx @@ -28,16 +28,16 @@ A collection of contracts and libraries that implement various signature validat
-## `DKIMRegistry` +## `DKIMRegistry` - +
```solidity -import "@openzeppelin/community-contracts/contracts/utils/cryptography/DKIMRegistry.sol"; +import "@openzeppelin/contracts/utils/cryptography/DKIMRegistry.sol"; ``` Implementation of the [ERC-7969](https://eips.ethereum.org/EIPS/eip-7969) interface for registering @@ -77,16 +77,19 @@ contract MyDKIMRegistry is DKIMRegistry, Ownable { - [_setKeyHash(domainHash, keyHash)](#DKIMRegistry-_setKeyHash-bytes32-bytes32-) - [_setKeyHashes(domainHash, keyHashes)](#DKIMRegistry-_setKeyHashes-bytes32-bytes32---) - [_revokeKeyHash(domainHash, keyHash)](#DKIMRegistry-_revokeKeyHash-bytes32-bytes32-) -#### IDKIMRegistry [!toc]

Events

-#### IDKIMRegistry [!toc] +
+IDKIMRegistry + - [KeyHashRegistered(domainHash, keyHash)](#IDKIMRegistry-KeyHashRegistered-bytes32-bytes32-) - [KeyHashRevoked(domainHash)](#IDKIMRegistry-KeyHashRevoked-bytes32-) + +
@@ -180,16 +183,16 @@ Emits a [`IDKIMRegistry.KeyHashRevoked`](/community-contracts/api/interfaces#IDK
-## `ZKEmailUtils` +## `ZKEmailUtils` - +
```solidity -import "@openzeppelin/community-contracts/contracts/utils/cryptography/ZKEmailUtils.sol"; +import "@openzeppelin/contracts/utils/cryptography/ZKEmailUtils.sol"; ``` Library for [ZKEmail](https://docs.zk.email) Groth16 proof validation utilities. @@ -327,16 +330,16 @@ into a uint256 array in the order expected by the verifier circuit.
-## `SignerZKEmail` +## `SignerZKEmail` - +
```solidity -import "@openzeppelin/community-contracts/contracts/utils/cryptography/signers/SignerZKEmail.sol"; +import "@openzeppelin/contracts/utils/cryptography/signers/SignerZKEmail.sol"; ``` Implementation of `AbstractSigner` using [ZKEmail](https://docs.zk.email) signatures. @@ -387,7 +390,6 @@ leave the signer either front-runnable or unusable. - [_setDKIMRegistry(registry_)](#SignerZKEmail-_setDKIMRegistry-contract-IDKIMRegistry-) - [_setVerifier(verifier_)](#SignerZKEmail-_setVerifier-contract-IGroth16Verifier-) - [_rawSignatureValidation(hash, signature)](#SignerZKEmail-_rawSignatureValidation-bytes32-bytes-) -#### AbstractSigner [!toc] @@ -395,7 +397,6 @@ leave the signer either front-runnable or unusable.

Errors

- [InvalidEmailProof(err)](#SignerZKEmail-InvalidEmailProof-enum-ZKEmailUtils-EmailProofError-) -#### AbstractSigner [!toc]
@@ -558,16 +559,16 @@ Proof verification error.
-## `ERC7913ZKEmailVerifier` +## `ERC7913ZKEmailVerifier` - +
```solidity -import "@openzeppelin/community-contracts/contracts/utils/cryptography/verifiers/ERC7913ZKEmailVerifier.sol"; +import "@openzeppelin/contracts/utils/cryptography/verifiers/ERC7913ZKEmailVerifier.sol"; ``` ERC-7913 signature verifier that supports ZKEmail accounts. @@ -600,7 +601,6 @@ Example of overriding _decodeKey to enforce a specific verifier, registry:
- [verify(key, hash, signature)](#ERC7913ZKEmailVerifier-verify-bytes-bytes32-bytes-) - [_decodeKey(key)](#ERC7913ZKEmailVerifier-_decodeKey-bytes-) -#### IERC7913SignatureVerifier [!toc]
diff --git a/content/contracts/5.x/api/access.mdx b/content/contracts/5.x/api/access.mdx index 949778d4..a81c684f 100644 --- a/content/contracts/5.x/api/access.mdx +++ b/content/contracts/5.x/api/access.mdx @@ -122,32 +122,33 @@ to enforce additional security measures for this role. - [_grantRole(role, account)](#AccessControl-_grantRole-bytes32-address-) - [_revokeRole(role, account)](#AccessControl-_revokeRole-bytes32-address-) - [DEFAULT_ADMIN_ROLE()](#AccessControl-DEFAULT_ADMIN_ROLE-bytes32) -#### ERC165 [!toc] -#### IERC165 [!toc] -#### IAccessControl [!toc]

Events

-#### ERC165 [!toc] -#### IERC165 [!toc] -#### IAccessControl [!toc] +
+IAccessControl + - [RoleAdminChanged(role, previousAdminRole, newAdminRole)](#IAccessControl-RoleAdminChanged-bytes32-bytes32-bytes32-) - [RoleGranted(role, account, sender)](#IAccessControl-RoleGranted-bytes32-address-address-) - [RoleRevoked(role, account, sender)](#IAccessControl-RoleRevoked-bytes32-address-address-) + +

Errors

-#### ERC165 [!toc] -#### IERC165 [!toc] -#### IAccessControl [!toc] +
+IAccessControl + - [AccessControlUnauthorizedAccount(account, neededRole)](#IAccessControl-AccessControlUnauthorizedAccount-address-bytes32-) - [AccessControlBadConfirmation()](#IAccessControl-AccessControlBadConfirmation--) + +
@@ -990,53 +991,60 @@ contract MyToken is AccessControlDefaultAdminRules { - [rollbackDefaultAdminDelay()](#AccessControlDefaultAdminRules-rollbackDefaultAdminDelay--) - [_rollbackDefaultAdminDelay()](#AccessControlDefaultAdminRules-_rollbackDefaultAdminDelay--) - [_delayChangeWait(newDelay)](#AccessControlDefaultAdminRules-_delayChangeWait-uint48-) -#### AccessControl [!toc] +
+AccessControl + - [hasRole(role, account)](#AccessControl-hasRole-bytes32-address-) - [_checkRole(role)](#AccessControl-_checkRole-bytes32-) - [_checkRole(role, account)](#AccessControl-_checkRole-bytes32-address-) - [getRoleAdmin(role)](#AccessControl-getRoleAdmin-bytes32-) - [DEFAULT_ADMIN_ROLE()](#AccessControl-DEFAULT_ADMIN_ROLE-bytes32) -#### ERC165 [!toc] -#### IERC165 [!toc] -#### IERC5313 [!toc] -#### IAccessControlDefaultAdminRules [!toc] -#### IAccessControl [!toc] + +

Events

-#### AccessControl [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] -#### IERC5313 [!toc] -#### IAccessControlDefaultAdminRules [!toc] +
+IAccessControlDefaultAdminRules + - [DefaultAdminTransferScheduled(newAdmin, acceptSchedule)](#IAccessControlDefaultAdminRules-DefaultAdminTransferScheduled-address-uint48-) - [DefaultAdminTransferCanceled()](#IAccessControlDefaultAdminRules-DefaultAdminTransferCanceled--) - [DefaultAdminDelayChangeScheduled(newDelay, effectSchedule)](#IAccessControlDefaultAdminRules-DefaultAdminDelayChangeScheduled-uint48-uint48-) - [DefaultAdminDelayChangeCanceled()](#IAccessControlDefaultAdminRules-DefaultAdminDelayChangeCanceled--) -#### IAccessControl [!toc] + +
+
+IAccessControl + - [RoleAdminChanged(role, previousAdminRole, newAdminRole)](#IAccessControl-RoleAdminChanged-bytes32-bytes32-bytes32-) - [RoleGranted(role, account, sender)](#IAccessControl-RoleGranted-bytes32-address-address-) - [RoleRevoked(role, account, sender)](#IAccessControl-RoleRevoked-bytes32-address-address-) + +

Errors

-#### AccessControl [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] -#### IERC5313 [!toc] -#### IAccessControlDefaultAdminRules [!toc] +
+IAccessControlDefaultAdminRules + - [AccessControlInvalidDefaultAdmin(defaultAdmin)](#IAccessControlDefaultAdminRules-AccessControlInvalidDefaultAdmin-address-) - [AccessControlEnforcedDefaultAdminRules()](#IAccessControlDefaultAdminRules-AccessControlEnforcedDefaultAdminRules--) - [AccessControlEnforcedDefaultAdminDelay(schedule)](#IAccessControlDefaultAdminRules-AccessControlEnforcedDefaultAdminDelay-uint48-) -#### IAccessControl [!toc] + +
+
+IAccessControl + - [AccessControlUnauthorizedAccount(account, neededRole)](#IAccessControl-AccessControlUnauthorizedAccount-address-bytes32-) - [AccessControlBadConfirmation()](#IAccessControl-AccessControlBadConfirmation--) + +
@@ -1624,7 +1632,9 @@ Extension of [`AccessControl`](#AccessControl) that allows enumerating the membe - [getRoleMembers(role)](#AccessControlEnumerable-getRoleMembers-bytes32-) - [_grantRole(role, account)](#AccessControlEnumerable-_grantRole-bytes32-address-) - [_revokeRole(role, account)](#AccessControlEnumerable-_revokeRole-bytes32-address-) -#### AccessControl [!toc] +
+AccessControl + - [hasRole(role, account)](#AccessControl-hasRole-bytes32-address-) - [_checkRole(role)](#AccessControl-_checkRole-bytes32-) - [_checkRole(role, account)](#AccessControl-_checkRole-bytes32-address-) @@ -1634,37 +1644,35 @@ Extension of [`AccessControl`](#AccessControl) that allows enumerating the membe - [renounceRole(role, callerConfirmation)](#AccessControl-renounceRole-bytes32-address-) - [_setRoleAdmin(role, adminRole)](#AccessControl-_setRoleAdmin-bytes32-bytes32-) - [DEFAULT_ADMIN_ROLE()](#AccessControl-DEFAULT_ADMIN_ROLE-bytes32) -#### ERC165 [!toc] -#### IERC165 [!toc] -#### IAccessControlEnumerable [!toc] -#### IAccessControl [!toc] + +

Events

-#### AccessControl [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] -#### IAccessControlEnumerable [!toc] -#### IAccessControl [!toc] +
+IAccessControl + - [RoleAdminChanged(role, previousAdminRole, newAdminRole)](#IAccessControl-RoleAdminChanged-bytes32-bytes32-bytes32-) - [RoleGranted(role, account, sender)](#IAccessControl-RoleGranted-bytes32-address-address-) - [RoleRevoked(role, account, sender)](#IAccessControl-RoleRevoked-bytes32-address-address-) + +

Errors

-#### AccessControl [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] -#### IAccessControlEnumerable [!toc] -#### IAccessControl [!toc] +
+IAccessControl + - [AccessControlUnauthorizedAccount(account, neededRole)](#IAccessControl-AccessControlUnauthorizedAccount-address-bytes32-) - [AccessControlBadConfirmation()](#IAccessControl-AccessControlBadConfirmation--) + +
@@ -1818,12 +1826,16 @@ External interface of AccessControlDefaultAdminRules declared to support ERC-165 - [changeDefaultAdminDelay(newDelay)](#IAccessControlDefaultAdminRules-changeDefaultAdminDelay-uint48-) - [rollbackDefaultAdminDelay()](#IAccessControlDefaultAdminRules-rollbackDefaultAdminDelay--) - [defaultAdminDelayIncreaseWait()](#IAccessControlDefaultAdminRules-defaultAdminDelayIncreaseWait--) -#### IAccessControl [!toc] +
+IAccessControl + - [hasRole(role, account)](#IAccessControl-hasRole-bytes32-address-) - [getRoleAdmin(role)](#IAccessControl-getRoleAdmin-bytes32-) - [grantRole(role, account)](#IAccessControl-grantRole-bytes32-address-) - [revokeRole(role, account)](#IAccessControl-revokeRole-bytes32-address-) - [renounceRole(role, callerConfirmation)](#IAccessControl-renounceRole-bytes32-address-) + +
@@ -1834,10 +1846,14 @@ External interface of AccessControlDefaultAdminRules declared to support ERC-165 - [DefaultAdminTransferCanceled()](#IAccessControlDefaultAdminRules-DefaultAdminTransferCanceled--) - [DefaultAdminDelayChangeScheduled(newDelay, effectSchedule)](#IAccessControlDefaultAdminRules-DefaultAdminDelayChangeScheduled-uint48-uint48-) - [DefaultAdminDelayChangeCanceled()](#IAccessControlDefaultAdminRules-DefaultAdminDelayChangeCanceled--) -#### IAccessControl [!toc] +
+IAccessControl + - [RoleAdminChanged(role, previousAdminRole, newAdminRole)](#IAccessControl-RoleAdminChanged-bytes32-bytes32-bytes32-) - [RoleGranted(role, account, sender)](#IAccessControl-RoleGranted-bytes32-address-address-) - [RoleRevoked(role, account, sender)](#IAccessControl-RoleRevoked-bytes32-address-address-) + +
@@ -1847,9 +1863,13 @@ External interface of AccessControlDefaultAdminRules declared to support ERC-165 - [AccessControlInvalidDefaultAdmin(defaultAdmin)](#IAccessControlDefaultAdminRules-AccessControlInvalidDefaultAdmin-address-) - [AccessControlEnforcedDefaultAdminRules()](#IAccessControlDefaultAdminRules-AccessControlEnforcedDefaultAdminRules--) - [AccessControlEnforcedDefaultAdminDelay(schedule)](#IAccessControlDefaultAdminRules-AccessControlEnforcedDefaultAdminDelay-uint48-) -#### IAccessControl [!toc] +
+IAccessControl + - [AccessControlUnauthorizedAccount(account, neededRole)](#IAccessControl-AccessControlUnauthorizedAccount-address-bytes32-) - [AccessControlBadConfirmation()](#IAccessControl-AccessControlBadConfirmation--) + +
@@ -2272,31 +2292,43 @@ External interface of AccessControlEnumerable declared to support ERC-165 detect
- [getRoleMember(role, index)](#IAccessControlEnumerable-getRoleMember-bytes32-uint256-) - [getRoleMemberCount(role)](#IAccessControlEnumerable-getRoleMemberCount-bytes32-) -#### IAccessControl [!toc] +
+IAccessControl + - [hasRole(role, account)](#IAccessControl-hasRole-bytes32-address-) - [getRoleAdmin(role)](#IAccessControl-getRoleAdmin-bytes32-) - [grantRole(role, account)](#IAccessControl-grantRole-bytes32-address-) - [revokeRole(role, account)](#IAccessControl-revokeRole-bytes32-address-) - [renounceRole(role, callerConfirmation)](#IAccessControl-renounceRole-bytes32-address-) + +

Events

-#### IAccessControl [!toc] +
+IAccessControl + - [RoleAdminChanged(role, previousAdminRole, newAdminRole)](#IAccessControl-RoleAdminChanged-bytes32-bytes32-bytes32-) - [RoleGranted(role, account, sender)](#IAccessControl-RoleGranted-bytes32-address-address-) - [RoleRevoked(role, account, sender)](#IAccessControl-RoleRevoked-bytes32-address-address-) + +

Errors

-#### IAccessControl [!toc] +
+IAccessControl + - [AccessControlUnauthorizedAccount(account, neededRole)](#IAccessControl-AccessControlUnauthorizedAccount-address-bytes32-) - [AccessControlBadConfirmation()](#IAccessControl-AccessControlBadConfirmation--) + +
@@ -2387,25 +2419,32 @@ functions, and ideally only used in `external` functions. See [`AccessManaged.re - [isConsumingScheduledOp()](#AccessManaged-isConsumingScheduledOp--) - [_setAuthority(newAuthority)](#AccessManaged-_setAuthority-address-) - [_checkCanCall(caller, data)](#AccessManaged-_checkCanCall-address-bytes-) -#### IAccessManaged [!toc]

Events

-#### IAccessManaged [!toc] +
+IAccessManaged + - [AuthorityUpdated(authority)](#IAccessManaged-AuthorityUpdated-address-) + +

Errors

-#### IAccessManaged [!toc] +
+IAccessManaged + - [AccessManagedUnauthorized(caller)](#IAccessManaged-AccessManagedUnauthorized-address-) - [AccessManagedRequiredDelay(caller, delay)](#IAccessManaged-AccessManagedRequiredDelay-address-uint32-) - [AccessManagedInvalidAuthority(authority)](#IAccessManaged-AccessManagedInvalidAuthority-address-) + +
@@ -2668,16 +2707,21 @@ mindful of the danger associated with functions such as [`Ownable.renounceOwners - [updateAuthority(target, newAuthority)](#AccessManager-updateAuthority-address-address-) - [ADMIN_ROLE()](#AccessManager-ADMIN_ROLE-uint64) - [PUBLIC_ROLE()](#AccessManager-PUBLIC_ROLE-uint64) -#### IAccessManager [!toc] -#### Multicall [!toc] +
+Multicall + - [multicall(data)](#Multicall-multicall-bytes---) + +

Events

-#### IAccessManager [!toc] +
+IAccessManager + - [OperationScheduled(operationId, nonce, schedule, caller, target, data)](#IAccessManager-OperationScheduled-bytes32-uint32-uint48-address-address-bytes-) - [OperationExecuted(operationId, nonce)](#IAccessManager-OperationExecuted-bytes32-uint32-) - [OperationCanceled(operationId, nonce)](#IAccessManager-OperationCanceled-bytes32-uint32-) @@ -2690,14 +2734,17 @@ mindful of the danger associated with functions such as [`Ownable.renounceOwners - [TargetClosed(target, closed)](#IAccessManager-TargetClosed-address-bool-) - [TargetFunctionRoleUpdated(target, selector, roleId)](#IAccessManager-TargetFunctionRoleUpdated-address-bytes4-uint64-) - [TargetAdminDelayUpdated(target, delay, since)](#IAccessManager-TargetAdminDelayUpdated-address-uint32-uint48-) -#### Multicall [!toc] + +

Errors

-#### IAccessManager [!toc] +
+IAccessManager + - [AccessManagerAlreadyScheduled(operationId)](#IAccessManager-AccessManagerAlreadyScheduled-bytes32-) - [AccessManagerNotScheduled(operationId)](#IAccessManager-AccessManagerNotScheduled-bytes32-) - [AccessManagerNotReady(operationId)](#IAccessManager-AccessManagerNotReady-bytes32-) @@ -2710,7 +2757,8 @@ mindful of the danger associated with functions such as [`Ownable.renounceOwners - [AccessManagerUnauthorizedConsume(target)](#IAccessManager-AccessManagerUnauthorizedConsume-address-) - [AccessManagerUnauthorizedCancel(msgsender, caller, target, selector)](#IAccessManager-AccessManagerUnauthorizedCancel-address-address-address-bytes4-) - [AccessManagerInvalidInitialAdmin(initialAdmin)](#IAccessManager-AccessManagerInvalidInitialAdmin-address-) -#### Multicall [!toc] + +
@@ -5045,10 +5093,14 @@ from parent (Ownable). - [transferOwnership(newOwner)](#Ownable2Step-transferOwnership-address-) - [_transferOwnership(newOwner)](#Ownable2Step-_transferOwnership-address-) - [acceptOwnership()](#Ownable2Step-acceptOwnership--) -#### Ownable [!toc] +
+Ownable + - [owner()](#Ownable-owner--) - [_checkOwner()](#Ownable-_checkOwner--) - [renounceOwnership()](#Ownable-renounceOwnership--) + +
@@ -5056,17 +5108,25 @@ from parent (Ownable).

Events

- [OwnershipTransferStarted(previousOwner, newOwner)](#Ownable2Step-OwnershipTransferStarted-address-address-) -#### Ownable [!toc] +
+Ownable + - [OwnershipTransferred(previousOwner, newOwner)](#Ownable-OwnershipTransferred-address-address-) + +

Errors

-#### Ownable [!toc] +
+Ownable + - [OwnableUnauthorizedAccount(account)](#Ownable-OwnableUnauthorizedAccount-address-) - [OwnableInvalidOwner(owner)](#Ownable-OwnableInvalidOwner-address-) + +
diff --git a/content/contracts/5.x/api/account.mdx b/content/contracts/5.x/api/account.mdx index 7fc1f8c0..8b021760 100644 --- a/content/contracts/5.x/api/account.mdx +++ b/content/contracts/5.x/api/account.mdx @@ -86,9 +86,12 @@ digital signature validation implementations. - [_checkEntryPoint()](#Account-_checkEntryPoint--) - [_checkEntryPointOrSelf()](#Account-_checkEntryPointOrSelf--) - [receive()](#Account-receive--) -#### IAccount [!toc] -#### AbstractSigner [!toc] +
+AbstractSigner + - [_rawSignatureValidation(hash, signature)](#AbstractSigner-_rawSignatureValidation-bytes32-bytes-) + +
@@ -96,8 +99,6 @@ digital signature validation implementations.

Errors

- [AccountUnauthorized(sender)](#Account-AccountUnauthorized-address-) -#### IAccount [!toc] -#### AbstractSigner [!toc]
@@ -424,11 +425,9 @@ contract MyAccountERC7579 is AccountERC7579, Initializable { - [_extractSignatureValidator(signature)](#AccountERC7579-_extractSignatureValidator-bytes-) - [_decodeFallbackData(data)](#AccountERC7579-_decodeFallbackData-bytes-) - [_rawSignatureValidation(, )](#AccountERC7579-_rawSignatureValidation-bytes32-bytes-) -#### IERC7579ModuleConfig [!toc] -#### IERC7579AccountConfig [!toc] -#### IERC7579Execution [!toc] -#### IERC1271 [!toc] -#### Account [!toc] +
+Account + - [entryPoint()](#Account-entryPoint--) - [getNonce()](#Account-getNonce--) - [getNonce(key)](#Account-getNonce-uint192-) @@ -438,23 +437,21 @@ contract MyAccountERC7579 is AccountERC7579, Initializable { - [_checkEntryPoint()](#Account-_checkEntryPoint--) - [_checkEntryPointOrSelf()](#Account-_checkEntryPointOrSelf--) - [receive()](#Account-receive--) -#### IAccount [!toc] -#### AbstractSigner [!toc] + +

Events

-#### IERC7579ModuleConfig [!toc] +
+IERC7579ModuleConfig + - [ModuleInstalled(moduleTypeId, module)](#IERC7579ModuleConfig-ModuleInstalled-uint256-address-) - [ModuleUninstalled(moduleTypeId, module)](#IERC7579ModuleConfig-ModuleUninstalled-uint256-address-) -#### IERC7579AccountConfig [!toc] -#### IERC7579Execution [!toc] -#### IERC1271 [!toc] -#### Account [!toc] -#### IAccount [!toc] -#### AbstractSigner [!toc] + +
@@ -463,14 +460,12 @@ contract MyAccountERC7579 is AccountERC7579, Initializable {
- [ERC7579MissingFallbackHandler(selector)](#AccountERC7579-ERC7579MissingFallbackHandler-bytes4-) - [ERC7579CannotDecodeFallbackData()](#AccountERC7579-ERC7579CannotDecodeFallbackData--) -#### IERC7579ModuleConfig [!toc] -#### IERC7579AccountConfig [!toc] -#### IERC7579Execution [!toc] -#### IERC1271 [!toc] -#### Account [!toc] +
+Account + - [AccountUnauthorized(sender)](#Account-AccountUnauthorized-address-) -#### IAccount [!toc] -#### AbstractSigner [!toc] + +
@@ -1024,7 +1019,9 @@ modules or further overriding functions that involve hooks. - [_uninstallModule(moduleTypeId, module, deInitData)](#AccountERC7579Hooked-_uninstallModule-uint256-address-bytes-) - [_execute(mode, executionCalldata)](#AccountERC7579Hooked-_execute-Mode-bytes-) - [_fallback()](#AccountERC7579Hooked-_fallback--) -#### AccountERC7579 [!toc] +
+AccountERC7579 + - [fallback()](#AccountERC7579-fallback-bytes-) - [supportsExecutionMode(encodedMode)](#AccountERC7579-supportsExecutionMode-bytes32-) - [installModule(moduleTypeId, module, initData)](#AccountERC7579-installModule-uint256-address-bytes-) @@ -1039,11 +1036,11 @@ modules or further overriding functions that involve hooks. - [_extractSignatureValidator(signature)](#AccountERC7579-_extractSignatureValidator-bytes-) - [_decodeFallbackData(data)](#AccountERC7579-_decodeFallbackData-bytes-) - [_rawSignatureValidation(, )](#AccountERC7579-_rawSignatureValidation-bytes32-bytes-) -#### IERC7579ModuleConfig [!toc] -#### IERC7579AccountConfig [!toc] -#### IERC7579Execution [!toc] -#### IERC1271 [!toc] -#### Account [!toc] + +
+
+Account + - [entryPoint()](#Account-entryPoint--) - [getNonce()](#Account-getNonce--) - [getNonce(key)](#Account-getNonce-uint192-) @@ -1053,24 +1050,21 @@ modules or further overriding functions that involve hooks. - [_checkEntryPoint()](#Account-_checkEntryPoint--) - [_checkEntryPointOrSelf()](#Account-_checkEntryPointOrSelf--) - [receive()](#Account-receive--) -#### IAccount [!toc] -#### AbstractSigner [!toc] + +

Events

-#### AccountERC7579 [!toc] -#### IERC7579ModuleConfig [!toc] +
+IERC7579ModuleConfig + - [ModuleInstalled(moduleTypeId, module)](#IERC7579ModuleConfig-ModuleInstalled-uint256-address-) - [ModuleUninstalled(moduleTypeId, module)](#IERC7579ModuleConfig-ModuleUninstalled-uint256-address-) -#### IERC7579AccountConfig [!toc] -#### IERC7579Execution [!toc] -#### IERC1271 [!toc] -#### Account [!toc] -#### IAccount [!toc] -#### AbstractSigner [!toc] + +
@@ -1078,17 +1072,19 @@ modules or further overriding functions that involve hooks.

Errors

- [ERC7579HookModuleAlreadyPresent(hook)](#AccountERC7579Hooked-ERC7579HookModuleAlreadyPresent-address-) -#### AccountERC7579 [!toc] +
+AccountERC7579 + - [ERC7579MissingFallbackHandler(selector)](#AccountERC7579-ERC7579MissingFallbackHandler-bytes4-) - [ERC7579CannotDecodeFallbackData()](#AccountERC7579-ERC7579CannotDecodeFallbackData--) -#### IERC7579ModuleConfig [!toc] -#### IERC7579AccountConfig [!toc] -#### IERC7579Execution [!toc] -#### IERC1271 [!toc] -#### Account [!toc] + +
+
+Account + - [AccountUnauthorized(sender)](#Account-AccountUnauthorized-address-) -#### IAccount [!toc] -#### AbstractSigner [!toc] + +
@@ -1292,7 +1288,6 @@ Only supports single batch mode (`0x01000000000000000000`). Does not support opt - [execute(mode, executionData)](#ERC7821-execute-bytes32-bytes-) - [supportsExecutionMode(mode)](#ERC7821-supportsExecutionMode-bytes32-) - [_erc7821AuthorizedExecutor(caller, , )](#ERC7821-_erc7821AuthorizedExecutor-address-bytes32-bytes-) -#### IERC7821 [!toc] @@ -1300,7 +1295,6 @@ Only supports single batch mode (`0x01000000000000000000`). Does not support opt

Errors

- [UnsupportedExecutionMode()](#ERC7821-UnsupportedExecutionMode--) -#### IERC7821 [!toc]
diff --git a/content/contracts/5.x/api/crosschain.mdx b/content/contracts/5.x/api/crosschain.mdx index 5c4998e7..5972c391 100644 --- a/content/contracts/5.x/api/crosschain.mdx +++ b/content/contracts/5.x/api/crosschain.mdx @@ -77,10 +77,13 @@ been verified. - [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) - [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) - [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) -#### ERC7786Recipient [!toc] +
+ERC7786Recipient + - [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) - [_processMessage(gateway, receiveId, sender, payload)](#ERC7786Recipient-_processMessage-address-bytes32-bytes-bytes-) -#### IERC7786Recipient [!toc] + +
@@ -88,8 +91,6 @@ been verified.

Events

- [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) -#### ERC7786Recipient [!toc] -#### IERC7786Recipient [!toc]
@@ -97,9 +98,12 @@ been verified.

Errors

- [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) -#### ERC7786Recipient [!toc] +
+ERC7786Recipient + - [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) -#### IERC7786Recipient [!toc] + +
@@ -268,9 +272,12 @@ holds assets and permissions for the sake of its controller. - [_setup(gateway_, controller_)](#CrosschainRemoteExecutor-_setup-address-bytes-) - [_isAuthorizedGateway(instance, sender)](#CrosschainRemoteExecutor-_isAuthorizedGateway-address-bytes-) - [_processMessage(, , , payload)](#CrosschainRemoteExecutor-_processMessage-address-bytes32-bytes-bytes-) -#### ERC7786Recipient [!toc] +
+ERC7786Recipient + - [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) -#### IERC7786Recipient [!toc] + +
@@ -278,8 +285,6 @@ holds assets and permissions for the sake of its controller.

Events

- [CrosschainControllerSet(gateway, controller)](#CrosschainRemoteExecutor-CrosschainControllerSet-address-bytes-) -#### ERC7786Recipient [!toc] -#### IERC7786Recipient [!toc]
@@ -287,9 +292,12 @@ holds assets and permissions for the sake of its controller.

Errors

- [AccessRestricted()](#CrosschainRemoteExecutor-AccessRestricted--) -#### ERC7786Recipient [!toc] +
+ERC7786Recipient + - [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) -#### IERC7786Recipient [!toc] + +
@@ -494,7 +502,6 @@ track of the processed receiveId. - [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) - [_isAuthorizedGateway(gateway, sender)](#ERC7786Recipient-_isAuthorizedGateway-address-bytes-) - [_processMessage(gateway, receiveId, sender, payload)](#ERC7786Recipient-_processMessage-address-bytes32-bytes-bytes-) -#### IERC7786Recipient [!toc] @@ -502,7 +509,6 @@ track of the processed receiveId.

Errors

- [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) -#### IERC7786Recipient [!toc]
@@ -615,55 +621,71 @@ a crosschain mint and burn mechanism. Instead, it takes custody of bridged asset - [_onReceive(to, ids, values)](#BridgeERC1155-_onReceive-address-uint256---uint256---) - [onERC1155Received(operator, , , , )](#BridgeERC1155-onERC1155Received-address-address-uint256-uint256-bytes-) - [onERC1155BatchReceived(operator, , , , )](#BridgeERC1155-onERC1155BatchReceived-address-address-uint256---uint256---bytes-) -#### ERC1155Holder [!toc] +
+ERC1155Holder + - [supportsInterface(interfaceId)](#ERC1155Holder-supportsInterface-bytes4-) -#### IERC1155Receiver [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] -#### BridgeMultiToken [!toc] + +
+
+BridgeMultiToken + - [_crosschainTransfer(from, to, ids, values)](#BridgeMultiToken-_crosschainTransfer-address-bytes-uint256---uint256---) - [_processMessage(, receiveId, , payload)](#BridgeMultiToken-_processMessage-address-bytes32-bytes-bytes-) -#### CrosschainLinked [!toc] + +
+
+CrosschainLinked + - [getLink(chain)](#CrosschainLinked-getLink-bytes-) - [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) - [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) - [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) -#### ERC7786Recipient [!toc] + +
+
+ERC7786Recipient + - [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) -#### IERC7786Recipient [!toc] + +

Events

-#### ERC1155Holder [!toc] -#### IERC1155Receiver [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] -#### BridgeMultiToken [!toc] +
+BridgeMultiToken + - [CrosschainMultiTokenTransferSent(sendId, from, to, ids, values)](#BridgeMultiToken-CrosschainMultiTokenTransferSent-bytes32-address-bytes-uint256---uint256---) - [CrosschainMultiTokenTransferReceived(receiveId, from, to, ids, values)](#BridgeMultiToken-CrosschainMultiTokenTransferReceived-bytes32-bytes-address-uint256---uint256---) -#### CrosschainLinked [!toc] + +
+
+CrosschainLinked + - [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) -#### ERC7786Recipient [!toc] -#### IERC7786Recipient [!toc] + +

Errors

-#### ERC1155Holder [!toc] -#### IERC1155Receiver [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] -#### BridgeMultiToken [!toc] -#### CrosschainLinked [!toc] +
+CrosschainLinked + - [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) -#### ERC7786Recipient [!toc] + +
+
+ERC7786Recipient + - [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) -#### IERC7786Recipient [!toc] + +
@@ -829,43 +851,66 @@ crosschain mint and burn mechanism. Instead, it takes custody of bridged assets. - [token()](#BridgeERC20-token--) - [_onSend(from, amount)](#BridgeERC20-_onSend-address-uint256-) - [_onReceive(to, amount)](#BridgeERC20-_onReceive-address-uint256-) -#### BridgeFungible [!toc] +
+BridgeFungible + - [crosschainTransfer(to, amount)](#BridgeFungible-crosschainTransfer-bytes-uint256-) - [_crosschainTransfer(from, to, amount)](#BridgeFungible-_crosschainTransfer-address-bytes-uint256-) - [_processMessage(, receiveId, , payload)](#BridgeFungible-_processMessage-address-bytes32-bytes-bytes-) -#### CrosschainLinked [!toc] + +
+
+CrosschainLinked + - [getLink(chain)](#CrosschainLinked-getLink-bytes-) - [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) - [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) - [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) -#### ERC7786Recipient [!toc] + +
+
+ERC7786Recipient + - [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) -#### IERC7786Recipient [!toc] + +

Events

-#### BridgeFungible [!toc] +
+BridgeFungible + - [CrosschainFungibleTransferSent(sendId, from, to, amount)](#BridgeFungible-CrosschainFungibleTransferSent-bytes32-address-bytes-uint256-) - [CrosschainFungibleTransferReceived(receiveId, from, to, amount)](#BridgeFungible-CrosschainFungibleTransferReceived-bytes32-bytes-address-uint256-) -#### CrosschainLinked [!toc] + +
+
+CrosschainLinked + - [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) -#### ERC7786Recipient [!toc] -#### IERC7786Recipient [!toc] + +

Errors

-#### BridgeFungible [!toc] -#### CrosschainLinked [!toc] +
+CrosschainLinked + - [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) -#### ERC7786Recipient [!toc] + +
+
+ERC7786Recipient + - [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) -#### IERC7786Recipient [!toc] + +
@@ -960,42 +1005,65 @@ a crosschain mint and burn mechanism. Instead, it takes custody of bridged asset - [crosschainTransferFrom(from, to, tokenId)](#BridgeERC721-crosschainTransferFrom-address-bytes-uint256-) - [_onSend(from, tokenId)](#BridgeERC721-_onSend-address-uint256-) - [_onReceive(to, tokenId)](#BridgeERC721-_onReceive-address-uint256-) -#### BridgeNonFungible [!toc] +
+BridgeNonFungible + - [_crosschainTransfer(from, to, tokenId)](#BridgeNonFungible-_crosschainTransfer-address-bytes-uint256-) - [_processMessage(, receiveId, , payload)](#BridgeNonFungible-_processMessage-address-bytes32-bytes-bytes-) -#### CrosschainLinked [!toc] + +
+
+CrosschainLinked + - [getLink(chain)](#CrosschainLinked-getLink-bytes-) - [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) - [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) - [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) -#### ERC7786Recipient [!toc] + +
+
+ERC7786Recipient + - [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) -#### IERC7786Recipient [!toc] + +

Events

-#### BridgeNonFungible [!toc] +
+BridgeNonFungible + - [CrosschainNonFungibleTransferSent(sendId, from, to, tokenId)](#BridgeNonFungible-CrosschainNonFungibleTransferSent-bytes32-address-bytes-uint256-) - [CrosschainNonFungibleTransferReceived(receiveId, from, to, tokenId)](#BridgeNonFungible-CrosschainNonFungibleTransferReceived-bytes32-bytes-address-uint256-) -#### CrosschainLinked [!toc] + +
+
+CrosschainLinked + - [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) -#### ERC7786Recipient [!toc] -#### IERC7786Recipient [!toc] + +

Errors

-#### BridgeNonFungible [!toc] -#### CrosschainLinked [!toc] +
+CrosschainLinked + - [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) -#### ERC7786Recipient [!toc] + +
+
+ERC7786Recipient + - [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) -#### IERC7786Recipient [!toc] + +
@@ -1111,43 +1179,66 @@ This is a variant of [`BridgeFungible`](#BridgeFungible) that implements the bri - [token()](#BridgeERC7802-token--) - [_onSend(from, amount)](#BridgeERC7802-_onSend-address-uint256-) - [_onReceive(to, amount)](#BridgeERC7802-_onReceive-address-uint256-) -#### BridgeFungible [!toc] +
+BridgeFungible + - [crosschainTransfer(to, amount)](#BridgeFungible-crosschainTransfer-bytes-uint256-) - [_crosschainTransfer(from, to, amount)](#BridgeFungible-_crosschainTransfer-address-bytes-uint256-) - [_processMessage(, receiveId, , payload)](#BridgeFungible-_processMessage-address-bytes32-bytes-bytes-) -#### CrosschainLinked [!toc] + +
+
+CrosschainLinked + - [getLink(chain)](#CrosschainLinked-getLink-bytes-) - [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) - [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) - [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) -#### ERC7786Recipient [!toc] + +
+
+ERC7786Recipient + - [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) -#### IERC7786Recipient [!toc] + +

Events

-#### BridgeFungible [!toc] +
+BridgeFungible + - [CrosschainFungibleTransferSent(sendId, from, to, amount)](#BridgeFungible-CrosschainFungibleTransferSent-bytes32-address-bytes-uint256-) - [CrosschainFungibleTransferReceived(receiveId, from, to, amount)](#BridgeFungible-CrosschainFungibleTransferReceived-bytes32-bytes-address-uint256-) -#### CrosschainLinked [!toc] + +
+
+CrosschainLinked + - [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) -#### ERC7786Recipient [!toc] -#### IERC7786Recipient [!toc] + +

Errors

-#### BridgeFungible [!toc] -#### CrosschainLinked [!toc] +
+CrosschainLinked + - [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) -#### ERC7786Recipient [!toc] + +
+
+ERC7786Recipient + - [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) -#### IERC7786Recipient [!toc] + +
@@ -1249,14 +1340,21 @@ extension, which embeds the bridge logic directly in the token contract. - [_processMessage(, receiveId, , payload)](#BridgeFungible-_processMessage-address-bytes32-bytes-bytes-) - [_onSend(from, amount)](#BridgeFungible-_onSend-address-uint256-) - [_onReceive(to, amount)](#BridgeFungible-_onReceive-address-uint256-) -#### CrosschainLinked [!toc] +
+CrosschainLinked + - [getLink(chain)](#CrosschainLinked-getLink-bytes-) - [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) - [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) - [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) -#### ERC7786Recipient [!toc] + +
+
+ERC7786Recipient + - [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) -#### IERC7786Recipient [!toc] + +
@@ -1265,21 +1363,30 @@ extension, which embeds the bridge logic directly in the token contract.
- [CrosschainFungibleTransferSent(sendId, from, to, amount)](#BridgeFungible-CrosschainFungibleTransferSent-bytes32-address-bytes-uint256-) - [CrosschainFungibleTransferReceived(receiveId, from, to, amount)](#BridgeFungible-CrosschainFungibleTransferReceived-bytes32-bytes-address-uint256-) -#### CrosschainLinked [!toc] +
+CrosschainLinked + - [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) -#### ERC7786Recipient [!toc] -#### IERC7786Recipient [!toc] + +

Errors

-#### CrosschainLinked [!toc] +
+CrosschainLinked + - [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) -#### ERC7786Recipient [!toc] + +
+
+ERC7786Recipient + - [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) -#### IERC7786Recipient [!toc] + +
@@ -1447,14 +1554,21 @@ contracts" that inherit from this to implement the external interfaces and make - [_processMessage(, receiveId, , payload)](#BridgeMultiToken-_processMessage-address-bytes32-bytes-bytes-) - [_onSend(from, ids, values)](#BridgeMultiToken-_onSend-address-uint256---uint256---) - [_onReceive(to, ids, values)](#BridgeMultiToken-_onReceive-address-uint256---uint256---) -#### CrosschainLinked [!toc] +
+CrosschainLinked + - [getLink(chain)](#CrosschainLinked-getLink-bytes-) - [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) - [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) - [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) -#### ERC7786Recipient [!toc] + +
+
+ERC7786Recipient + - [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) -#### IERC7786Recipient [!toc] + +
@@ -1463,21 +1577,30 @@ contracts" that inherit from this to implement the external interfaces and make
- [CrosschainMultiTokenTransferSent(sendId, from, to, ids, values)](#BridgeMultiToken-CrosschainMultiTokenTransferSent-bytes32-address-bytes-uint256---uint256---) - [CrosschainMultiTokenTransferReceived(receiveId, from, to, ids, values)](#BridgeMultiToken-CrosschainMultiTokenTransferReceived-bytes32-bytes-address-uint256---uint256---) -#### CrosschainLinked [!toc] +
+CrosschainLinked + - [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) -#### ERC7786Recipient [!toc] -#### IERC7786Recipient [!toc] + +

Errors

-#### CrosschainLinked [!toc] +
+CrosschainLinked + - [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) -#### ERC7786Recipient [!toc] + +
+
+ERC7786Recipient + - [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) -#### IERC7786Recipient [!toc] + +
@@ -1619,14 +1742,21 @@ the [`ERC721Crosschain`](/contracts/5.x/api/token/ERC721#ERC721Crosschain) exten - [_processMessage(, receiveId, , payload)](#BridgeNonFungible-_processMessage-address-bytes32-bytes-bytes-) - [_onSend(from, tokenId)](#BridgeNonFungible-_onSend-address-uint256-) - [_onReceive(to, tokenId)](#BridgeNonFungible-_onReceive-address-uint256-) -#### CrosschainLinked [!toc] +
+CrosschainLinked + - [getLink(chain)](#CrosschainLinked-getLink-bytes-) - [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) - [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) - [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) -#### ERC7786Recipient [!toc] + +
+
+ERC7786Recipient + - [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) -#### IERC7786Recipient [!toc] + +
@@ -1635,21 +1765,30 @@ the [`ERC721Crosschain`](/contracts/5.x/api/token/ERC721#ERC721Crosschain) exten
- [CrosschainNonFungibleTransferSent(sendId, from, to, tokenId)](#BridgeNonFungible-CrosschainNonFungibleTransferSent-bytes32-address-bytes-uint256-) - [CrosschainNonFungibleTransferReceived(receiveId, from, to, tokenId)](#BridgeNonFungible-CrosschainNonFungibleTransferReceived-bytes32-bytes-address-uint256-) -#### CrosschainLinked [!toc] +
+CrosschainLinked + - [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) -#### ERC7786Recipient [!toc] -#### IERC7786Recipient [!toc] + +

Errors

-#### CrosschainLinked [!toc] +
+CrosschainLinked + - [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) -#### ERC7786Recipient [!toc] + +
+
+ERC7786Recipient + - [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) -#### IERC7786Recipient [!toc] + +
@@ -1799,14 +1938,21 @@ extension, which embeds the bridge logic directly in the token contract. - [_processMessage(, receiveId, , payload)](#BridgeERC20Core-_processMessage-address-bytes32-bytes-bytes-) - [_onSend(from, amount)](#BridgeERC20Core-_onSend-address-uint256-) - [_onReceive(to, amount)](#BridgeERC20Core-_onReceive-address-uint256-) -#### CrosschainLinked [!toc] +
+CrosschainLinked + - [getLink(chain)](#CrosschainLinked-getLink-bytes-) - [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) - [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) - [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) -#### ERC7786Recipient [!toc] + +
+
+ERC7786Recipient + - [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) -#### IERC7786Recipient [!toc] + +
@@ -1815,22 +1961,31 @@ extension, which embeds the bridge logic directly in the token contract.
- [CrosschainERC20TransferSent(sendId, from, to, amount)](#BridgeERC20Core-CrosschainERC20TransferSent-bytes32-address-bytes-uint256-) - [CrosschainERC20TransferReceived(receiveId, from, to, amount)](#BridgeERC20Core-CrosschainERC20TransferReceived-bytes32-bytes-address-uint256-) -#### CrosschainLinked [!toc] +
+CrosschainLinked + - [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) -#### ERC7786Recipient [!toc] -#### IERC7786Recipient [!toc] + +

Errors

-#### CrosschainLinked [!toc] +
+CrosschainLinked + - [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) -#### ERC7786Recipient [!toc] + +
+
+ERC7786Recipient + - [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) - [ERC7786RecipientMessageAlreadyProcessed(gateway, receiveId)](#ERC7786Recipient-ERC7786RecipientMessageAlreadyProcessed-address-bytes32-) -#### IERC7786Recipient [!toc] + +
diff --git a/content/contracts/5.x/api/finance.mdx b/content/contracts/5.x/api/finance.mdx index 2415528e..3b652257 100644 --- a/content/contracts/5.x/api/finance.mdx +++ b/content/contracts/5.x/api/finance.mdx @@ -75,12 +75,16 @@ Consider disabling one of the withdrawal methods. - [vestedAmount(timestamp)](#VestingWallet-vestedAmount-uint64-) - [vestedAmount(token, timestamp)](#VestingWallet-vestedAmount-address-uint64-) - [_vestingSchedule(totalAllocation, timestamp)](#VestingWallet-_vestingSchedule-uint256-uint64-) -#### Ownable [!toc] +
+Ownable + - [owner()](#Ownable-owner--) - [_checkOwner()](#Ownable-_checkOwner--) - [renounceOwnership()](#Ownable-renounceOwnership--) - [transferOwnership(newOwner)](#Ownable-transferOwnership-address-) - [_transferOwnership(newOwner)](#Ownable-_transferOwnership-address-) + +
@@ -89,17 +93,25 @@ Consider disabling one of the withdrawal methods.
- [EtherReleased(amount)](#VestingWallet-EtherReleased-uint256-) - [ERC20Released(token, amount)](#VestingWallet-ERC20Released-address-uint256-) -#### Ownable [!toc] +
+Ownable + - [OwnershipTransferred(previousOwner, newOwner)](#Ownable-OwnershipTransferred-address-address-) + +

Errors

-#### Ownable [!toc] +
+Ownable + - [OwnableUnauthorizedAccount(account)](#Ownable-OwnableUnauthorizedAccount-address-) - [OwnableInvalidOwner(owner)](#Ownable-OwnableInvalidOwner-address-) + +
@@ -405,7 +417,9 @@ _Available since v5.1._ - [constructor(cliffSeconds)](#VestingWalletCliff-constructor-uint64-) - [cliff()](#VestingWalletCliff-cliff--) - [_vestingSchedule(totalAllocation, timestamp)](#VestingWalletCliff-_vestingSchedule-uint256-uint64-) -#### VestingWallet [!toc] +
+VestingWallet + - [receive()](#VestingWallet-receive--) - [start()](#VestingWallet-start--) - [duration()](#VestingWallet-duration--) @@ -418,23 +432,37 @@ _Available since v5.1._ - [release(token)](#VestingWallet-release-address-) - [vestedAmount(timestamp)](#VestingWallet-vestedAmount-uint64-) - [vestedAmount(token, timestamp)](#VestingWallet-vestedAmount-address-uint64-) -#### Ownable [!toc] + +
+
+Ownable + - [owner()](#Ownable-owner--) - [_checkOwner()](#Ownable-_checkOwner--) - [renounceOwnership()](#Ownable-renounceOwnership--) - [transferOwnership(newOwner)](#Ownable-transferOwnership-address-) - [_transferOwnership(newOwner)](#Ownable-_transferOwnership-address-) + +

Events

-#### VestingWallet [!toc] +
+VestingWallet + - [EtherReleased(amount)](#VestingWallet-EtherReleased-uint256-) - [ERC20Released(token, amount)](#VestingWallet-ERC20Released-address-uint256-) -#### Ownable [!toc] + +
+
+Ownable + - [OwnershipTransferred(previousOwner, newOwner)](#Ownable-OwnershipTransferred-address-address-) + +
@@ -442,10 +470,13 @@ _Available since v5.1._

Errors

- [InvalidCliffDuration(cliffSeconds, durationSeconds)](#VestingWalletCliff-InvalidCliffDuration-uint64-uint64-) -#### VestingWallet [!toc] -#### Ownable [!toc] +
+Ownable + - [OwnableUnauthorizedAccount(account)](#Ownable-OwnableUnauthorizedAccount-address-) - [OwnableInvalidOwner(owner)](#Ownable-OwnableInvalidOwner-address-) + +
diff --git a/content/contracts/5.x/api/governance.mdx b/content/contracts/5.x/api/governance.mdx index 16af3c51..8941a9ea 100644 --- a/content/contracts/5.x/api/governance.mdx +++ b/content/contracts/5.x/api/governance.mdx @@ -276,56 +276,63 @@ This contract is abstract and requires several functions to be implemented in va - [quorum(timepoint)](#Governor-quorum-uint256-) - [BALLOT_TYPEHASH()](#Governor-BALLOT_TYPEHASH-bytes32) - [EXTENDED_BALLOT_TYPEHASH()](#Governor-EXTENDED_BALLOT_TYPEHASH-bytes32) -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [COUNTING_MODE()](#IGovernor-COUNTING_MODE--) - [hasVoted(proposalId, account)](#IGovernor-hasVoted-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### EIP712 [!toc] + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Events

-#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [ProposalCreated(proposalId, proposer, targets, values, signatures, calldatas, voteStart, voteEnd, description)](#IGovernor-ProposalCreated-uint256-address-address---uint256---string---bytes---uint256-uint256-string-) - [ProposalQueued(proposalId, etaSeconds)](#IGovernor-ProposalQueued-uint256-uint256-) - [ProposalExecuted(proposalId)](#IGovernor-ProposalExecuted-uint256-) - [ProposalCanceled(proposalId)](#IGovernor-ProposalCanceled-uint256-) - [VoteCast(voter, proposalId, support, weight, reason)](#IGovernor-VoteCast-address-uint256-uint8-uint256-string-) - [VoteCastWithParams(voter, proposalId, support, weight, reason, params)](#IGovernor-VoteCastWithParams-address-uint256-uint8-uint256-string-bytes-) -#### IERC6372 [!toc] -#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
+
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [GovernorInvalidProposalLength(targets, calldatas, values)](#IGovernor-GovernorInvalidProposalLength-uint256-uint256-uint256-) - [GovernorAlreadyCastVote(voter)](#IGovernor-GovernorAlreadyCastVote-address-) - [GovernorDisabledDeposit()](#IGovernor-GovernorDisabledDeposit--) @@ -341,13 +348,14 @@ This contract is abstract and requires several functions to be implemented in va - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -1526,11 +1534,19 @@ Making event parameters `indexed` affects how events are decoded, potentially br - [castVoteWithReasonAndParams(proposalId, support, reason, params)](#IGovernor-castVoteWithReasonAndParams-uint256-uint8-string-bytes-) - [castVoteBySig(proposalId, support, voter, signature)](#IGovernor-castVoteBySig-uint256-uint8-address-bytes-) - [castVoteWithReasonAndParamsBySig(proposalId, support, voter, reason, params, signature)](#IGovernor-castVoteWithReasonAndParamsBySig-uint256-uint8-address-string-bytes-bytes-) -#### IERC6372 [!toc] +
+IERC6372 + - [clock()](#IERC6372-clock--) - [CLOCK_MODE()](#IERC6372-CLOCK_MODE--) -#### IERC165 [!toc] + +
+
+IERC165 + - [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) + +
@@ -1543,8 +1559,6 @@ Making event parameters `indexed` affects how events are decoded, potentially br - [ProposalCanceled(proposalId)](#IGovernor-ProposalCanceled-uint256-) - [VoteCast(voter, proposalId, support, weight, reason)](#IGovernor-VoteCast-address-uint256-uint8-uint256-string-) - [VoteCastWithParams(voter, proposalId, support, weight, reason, params)](#IGovernor-VoteCastWithParams-address-uint256-uint8-uint256-string-bytes-) -#### IERC6372 [!toc] -#### IERC165 [!toc] @@ -1566,8 +1580,6 @@ Making event parameters `indexed` affects how events are decoded, potentially br - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) -#### IERC6372 [!toc] -#### IERC165 [!toc] @@ -2559,14 +2571,22 @@ a multisig or a DAO as the sole proposer. - [PROPOSER_ROLE()](#TimelockController-PROPOSER_ROLE-bytes32) - [EXECUTOR_ROLE()](#TimelockController-EXECUTOR_ROLE-bytes32) - [CANCELLER_ROLE()](#TimelockController-CANCELLER_ROLE-bytes32) -#### ERC1155Holder [!toc] +
+ERC1155Holder + - [onERC1155Received(, , , , )](#ERC1155Holder-onERC1155Received-address-address-uint256-uint256-bytes-) - [onERC1155BatchReceived(, , , , )](#ERC1155Holder-onERC1155BatchReceived-address-address-uint256---uint256---bytes-) -#### IERC1155Receiver [!toc] -#### ERC721Holder [!toc] + +
+
+ERC721Holder + - [onERC721Received(, , , )](#ERC721Holder-onERC721Received-address-address-uint256-bytes-) -#### IERC721Receiver [!toc] -#### AccessControl [!toc] + +
+
+AccessControl + - [hasRole(role, account)](#AccessControl-hasRole-bytes32-address-) - [_checkRole(role)](#AccessControl-_checkRole-bytes32-) - [_checkRole(role, account)](#AccessControl-_checkRole-bytes32-address-) @@ -2578,9 +2598,8 @@ a multisig or a DAO as the sole proposer. - [_grantRole(role, account)](#AccessControl-_grantRole-bytes32-address-) - [_revokeRole(role, account)](#AccessControl-_revokeRole-bytes32-address-) - [DEFAULT_ADMIN_ROLE()](#AccessControl-DEFAULT_ADMIN_ROLE-bytes32) -#### ERC165 [!toc] -#### IERC165 [!toc] -#### IAccessControl [!toc] + +
@@ -2592,17 +2611,14 @@ a multisig or a DAO as the sole proposer. - [CallSalt(id, salt)](#TimelockController-CallSalt-bytes32-bytes32-) - [Cancelled(id)](#TimelockController-Cancelled-bytes32-) - [MinDelayChange(oldDuration, newDuration)](#TimelockController-MinDelayChange-uint256-uint256-) -#### ERC1155Holder [!toc] -#### IERC1155Receiver [!toc] -#### ERC721Holder [!toc] -#### IERC721Receiver [!toc] -#### AccessControl [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] -#### IAccessControl [!toc] +
+IAccessControl + - [RoleAdminChanged(role, previousAdminRole, newAdminRole)](#IAccessControl-RoleAdminChanged-bytes32-bytes32-bytes32-) - [RoleGranted(role, account, sender)](#IAccessControl-RoleGranted-bytes32-address-address-) - [RoleRevoked(role, account, sender)](#IAccessControl-RoleRevoked-bytes32-address-address-) + +
@@ -2614,16 +2630,13 @@ a multisig or a DAO as the sole proposer. - [TimelockUnexpectedOperationState(operationId, expectedStates)](#TimelockController-TimelockUnexpectedOperationState-bytes32-bytes32-) - [TimelockUnexecutedPredecessor(predecessorId)](#TimelockController-TimelockUnexecutedPredecessor-bytes32-) - [TimelockUnauthorizedCaller(caller)](#TimelockController-TimelockUnauthorizedCaller-address-) -#### ERC1155Holder [!toc] -#### IERC1155Receiver [!toc] -#### ERC721Holder [!toc] -#### IERC721Receiver [!toc] -#### AccessControl [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] -#### IAccessControl [!toc] +
+IAccessControl + - [AccessControlUnauthorizedAccount(account, neededRole)](#IAccessControl-AccessControlUnauthorizedAccount-address-bytes32-) - [AccessControlBadConfirmation()](#IAccessControl-AccessControlBadConfirmation--) + +
@@ -3323,7 +3336,9 @@ _Available since v5.1._ - [_quorumReached(proposalId)](#GovernorCountingFractional-_quorumReached-uint256-) - [_voteSucceeded(proposalId)](#GovernorCountingFractional-_voteSucceeded-uint256-) - [_countVote(proposalId, account, support, totalWeight, params)](#GovernorCountingFractional-_countVote-uint256-address-uint8-uint256-bytes-) -#### Governor [!toc] +
+Governor + - [receive()](#Governor-receive--) - [supportsInterface(interfaceId)](#Governor-supportsInterface-bytes4-) - [name()](#Governor-name--) @@ -3376,46 +3391,49 @@ _Available since v5.1._ - [quorum(timepoint)](#Governor-quorum-uint256-) - [BALLOT_TYPEHASH()](#Governor-BALLOT_TYPEHASH-bytes32) - [EXTENDED_BALLOT_TYPEHASH()](#Governor-EXTENDED_BALLOT_TYPEHASH-bytes32) -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### EIP712 [!toc] + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Events

-#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [ProposalCreated(proposalId, proposer, targets, values, signatures, calldatas, voteStart, voteEnd, description)](#IGovernor-ProposalCreated-uint256-address-address---uint256---string---bytes---uint256-uint256-string-) - [ProposalQueued(proposalId, etaSeconds)](#IGovernor-ProposalQueued-uint256-uint256-) - [ProposalExecuted(proposalId)](#IGovernor-ProposalExecuted-uint256-) - [ProposalCanceled(proposalId)](#IGovernor-ProposalCanceled-uint256-) - [VoteCast(voter, proposalId, support, weight, reason)](#IGovernor-VoteCast-address-uint256-uint8-uint256-string-) - [VoteCastWithParams(voter, proposalId, support, weight, reason, params)](#IGovernor-VoteCastWithParams-address-uint256-uint8-uint256-string-bytes-) -#### IERC6372 [!toc] -#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
+
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -3423,10 +3441,9 @@ _Available since v5.1._

Errors

- [GovernorExceedRemainingWeight(voter, usedVotes, remainingWeight)](#GovernorCountingFractional-GovernorExceedRemainingWeight-address-uint256-uint256-) -#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [GovernorInvalidProposalLength(targets, calldatas, values)](#IGovernor-GovernorInvalidProposalLength-uint256-uint256-uint256-) - [GovernorAlreadyCastVote(voter)](#IGovernor-GovernorAlreadyCastVote-address-) - [GovernorDisabledDeposit()](#IGovernor-GovernorDisabledDeposit--) @@ -3442,13 +3459,14 @@ _Available since v5.1._ - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -3671,12 +3689,18 @@ token that inherits [`VotesExtended`](#VotesExtended). - [castOverrideVote(proposalId, support, reason)](#GovernorCountingOverridable-castOverrideVote-uint256-uint8-string-) - [castOverrideVoteBySig(proposalId, support, voter, reason, signature)](#GovernorCountingOverridable-castOverrideVoteBySig-uint256-uint8-address-string-bytes-) - [OVERRIDE_BALLOT_TYPEHASH()](#GovernorCountingOverridable-OVERRIDE_BALLOT_TYPEHASH-bytes32) -#### GovernorVotes [!toc] +
+GovernorVotes + - [token()](#GovernorVotes-token--) - [clock()](#GovernorVotes-clock--) - [CLOCK_MODE()](#GovernorVotes-CLOCK_MODE--) - [_getVotes(account, timepoint, )](#GovernorVotes-_getVotes-address-uint256-bytes-) -#### Governor [!toc] + +
+
+Governor + - [receive()](#Governor-receive--) - [supportsInterface(interfaceId)](#Governor-supportsInterface-bytes4-) - [name()](#Governor-name--) @@ -3726,23 +3750,26 @@ token that inherits [`VotesExtended`](#VotesExtended). - [quorum(timepoint)](#Governor-quorum-uint256-) - [BALLOT_TYPEHASH()](#Governor-BALLOT_TYPEHASH-bytes32) - [EXTENDED_BALLOT_TYPEHASH()](#Governor-EXTENDED_BALLOT_TYPEHASH-bytes32) -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### EIP712 [!toc] + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -3751,24 +3778,23 @@ token that inherits [`VotesExtended`](#VotesExtended).
- [VoteReduced(delegate, proposalId, support, weight)](#GovernorCountingOverridable-VoteReduced-address-uint256-uint8-uint256-) - [OverrideVoteCast(voter, proposalId, support, weight, reason)](#GovernorCountingOverridable-OverrideVoteCast-address-uint256-uint8-uint256-string-) -#### GovernorVotes [!toc] -#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [ProposalCreated(proposalId, proposer, targets, values, signatures, calldatas, voteStart, voteEnd, description)](#IGovernor-ProposalCreated-uint256-address-address---uint256---string---bytes---uint256-uint256-string-) - [ProposalQueued(proposalId, etaSeconds)](#IGovernor-ProposalQueued-uint256-uint256-) - [ProposalExecuted(proposalId)](#IGovernor-ProposalExecuted-uint256-) - [ProposalCanceled(proposalId)](#IGovernor-ProposalCanceled-uint256-) - [VoteCast(voter, proposalId, support, weight, reason)](#IGovernor-VoteCast-address-uint256-uint8-uint256-string-) - [VoteCastWithParams(voter, proposalId, support, weight, reason, params)](#IGovernor-VoteCastWithParams-address-uint256-uint8-uint256-string-bytes-) -#### IERC6372 [!toc] -#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
+
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -3776,11 +3802,9 @@ token that inherits [`VotesExtended`](#VotesExtended).

Errors

- [GovernorAlreadyOverriddenVote(account)](#GovernorCountingOverridable-GovernorAlreadyOverriddenVote-address-) -#### GovernorVotes [!toc] -#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [GovernorInvalidProposalLength(targets, calldatas, values)](#IGovernor-GovernorInvalidProposalLength-uint256-uint256-uint256-) - [GovernorAlreadyCastVote(voter)](#IGovernor-GovernorAlreadyCastVote-address-) - [GovernorDisabledDeposit()](#IGovernor-GovernorDisabledDeposit--) @@ -3796,13 +3820,14 @@ token that inherits [`VotesExtended`](#VotesExtended). - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -4121,7 +4146,9 @@ Extension of [`Governor`](#Governor) for simple, 3 options, vote counting. - [_quorumReached(proposalId)](#GovernorCountingSimple-_quorumReached-uint256-) - [_voteSucceeded(proposalId)](#GovernorCountingSimple-_voteSucceeded-uint256-) - [_countVote(proposalId, account, support, totalWeight, )](#GovernorCountingSimple-_countVote-uint256-address-uint8-uint256-bytes-) -#### Governor [!toc] +
+Governor + - [receive()](#Governor-receive--) - [supportsInterface(interfaceId)](#Governor-supportsInterface-bytes4-) - [name()](#Governor-name--) @@ -4174,56 +4201,58 @@ Extension of [`Governor`](#Governor) for simple, 3 options, vote counting. - [quorum(timepoint)](#Governor-quorum-uint256-) - [BALLOT_TYPEHASH()](#Governor-BALLOT_TYPEHASH-bytes32) - [EXTENDED_BALLOT_TYPEHASH()](#Governor-EXTENDED_BALLOT_TYPEHASH-bytes32) -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### EIP712 [!toc] + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Events

-#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [ProposalCreated(proposalId, proposer, targets, values, signatures, calldatas, voteStart, voteEnd, description)](#IGovernor-ProposalCreated-uint256-address-address---uint256---string---bytes---uint256-uint256-string-) - [ProposalQueued(proposalId, etaSeconds)](#IGovernor-ProposalQueued-uint256-uint256-) - [ProposalExecuted(proposalId)](#IGovernor-ProposalExecuted-uint256-) - [ProposalCanceled(proposalId)](#IGovernor-ProposalCanceled-uint256-) - [VoteCast(voter, proposalId, support, weight, reason)](#IGovernor-VoteCast-address-uint256-uint8-uint256-string-) - [VoteCastWithParams(voter, proposalId, support, weight, reason, params)](#IGovernor-VoteCastWithParams-address-uint256-uint8-uint256-string-bytes-) -#### IERC6372 [!toc] -#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
+
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [GovernorInvalidProposalLength(targets, calldatas, values)](#IGovernor-GovernorInvalidProposalLength-uint256-uint256-uint256-) - [GovernorAlreadyCastVote(voter)](#IGovernor-GovernorAlreadyCastVote-address-) - [GovernorDisabledDeposit()](#IGovernor-GovernorDisabledDeposit--) @@ -4239,13 +4268,14 @@ Extension of [`Governor`](#Governor) for simple, 3 options, vote counting. - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -4394,7 +4424,9 @@ Extension of [`Governor`](#Governor) for cross-chain governance through ERC-7786
- [relayCrosschain(gateway, executor, mode, executionCalldata)](#GovernorCrosschain-relayCrosschain-address-bytes-Mode-bytes-) - [_crosschainExecute(gateway, executor, mode, executionCalldata)](#GovernorCrosschain-_crosschainExecute-address-bytes-Mode-bytes-) -#### Governor [!toc] +
+Governor + - [receive()](#Governor-receive--) - [supportsInterface(interfaceId)](#Governor-supportsInterface-bytes4-) - [name()](#Governor-name--) @@ -4450,58 +4482,65 @@ Extension of [`Governor`](#Governor) for cross-chain governance through ERC-7786 - [quorum(timepoint)](#Governor-quorum-uint256-) - [BALLOT_TYPEHASH()](#Governor-BALLOT_TYPEHASH-bytes32) - [EXTENDED_BALLOT_TYPEHASH()](#Governor-EXTENDED_BALLOT_TYPEHASH-bytes32) -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] + +
+
+IGovernor + - [COUNTING_MODE()](#IGovernor-COUNTING_MODE--) - [hasVoted(proposalId, account)](#IGovernor-hasVoted-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### EIP712 [!toc] + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Events

-#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [ProposalCreated(proposalId, proposer, targets, values, signatures, calldatas, voteStart, voteEnd, description)](#IGovernor-ProposalCreated-uint256-address-address---uint256---string---bytes---uint256-uint256-string-) - [ProposalQueued(proposalId, etaSeconds)](#IGovernor-ProposalQueued-uint256-uint256-) - [ProposalExecuted(proposalId)](#IGovernor-ProposalExecuted-uint256-) - [ProposalCanceled(proposalId)](#IGovernor-ProposalCanceled-uint256-) - [VoteCast(voter, proposalId, support, weight, reason)](#IGovernor-VoteCast-address-uint256-uint8-uint256-string-) - [VoteCastWithParams(voter, proposalId, support, weight, reason, params)](#IGovernor-VoteCastWithParams-address-uint256-uint8-uint256-string-bytes-) -#### IERC6372 [!toc] -#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
+
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [GovernorInvalidProposalLength(targets, calldatas, values)](#IGovernor-GovernorInvalidProposalLength-uint256-uint256-uint256-) - [GovernorAlreadyCastVote(voter)](#IGovernor-GovernorAlreadyCastVote-address-) - [GovernorDisabledDeposit()](#IGovernor-GovernorDisabledDeposit--) @@ -4517,13 +4556,14 @@ Extension of [`Governor`](#Governor) for cross-chain governance through ERC-7786 - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -4590,11 +4630,17 @@ Traditional (un-keyed) nonces are still supported and can continue to be used as - [_useCheckedNonce(owner, nonce)](#GovernorNoncesKeyed-_useCheckedNonce-address-uint256-) - [_validateVoteSig(proposalId, support, voter, signature)](#GovernorNoncesKeyed-_validateVoteSig-uint256-uint8-address-bytes-) - [_validateExtendedVoteSig(proposalId, support, voter, reason, params, signature)](#GovernorNoncesKeyed-_validateExtendedVoteSig-uint256-uint8-address-string-bytes-bytes-) -#### NoncesKeyed [!toc] +
+NoncesKeyed + - [nonces(owner, key)](#NoncesKeyed-nonces-address-uint192-) - [_useNonce(owner, key)](#NoncesKeyed-_useNonce-address-uint192-) - [_useCheckedNonce(owner, key, nonce)](#NoncesKeyed-_useCheckedNonce-address-uint192-uint64-) -#### Governor [!toc] + +
+
+Governor + - [receive()](#Governor-receive--) - [supportsInterface(interfaceId)](#Governor-supportsInterface-bytes4-) - [name()](#Governor-name--) @@ -4648,59 +4694,64 @@ Traditional (un-keyed) nonces are still supported and can continue to be used as - [quorum(timepoint)](#Governor-quorum-uint256-) - [BALLOT_TYPEHASH()](#Governor-BALLOT_TYPEHASH-bytes32) - [EXTENDED_BALLOT_TYPEHASH()](#Governor-EXTENDED_BALLOT_TYPEHASH-bytes32) -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] + +
+
+IGovernor + - [COUNTING_MODE()](#IGovernor-COUNTING_MODE--) - [hasVoted(proposalId, account)](#IGovernor-hasVoted-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) -#### EIP712 [!toc] + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Events

-#### NoncesKeyed [!toc] -#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [ProposalCreated(proposalId, proposer, targets, values, signatures, calldatas, voteStart, voteEnd, description)](#IGovernor-ProposalCreated-uint256-address-address---uint256---string---bytes---uint256-uint256-string-) - [ProposalQueued(proposalId, etaSeconds)](#IGovernor-ProposalQueued-uint256-uint256-) - [ProposalExecuted(proposalId)](#IGovernor-ProposalExecuted-uint256-) - [ProposalCanceled(proposalId)](#IGovernor-ProposalCanceled-uint256-) - [VoteCast(voter, proposalId, support, weight, reason)](#IGovernor-VoteCast-address-uint256-uint8-uint256-string-) - [VoteCastWithParams(voter, proposalId, support, weight, reason, params)](#IGovernor-VoteCastWithParams-address-uint256-uint8-uint256-string-bytes-) -#### IERC6372 [!toc] -#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
+
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### NoncesKeyed [!toc] -#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [GovernorInvalidProposalLength(targets, calldatas, values)](#IGovernor-GovernorInvalidProposalLength-uint256-uint256-uint256-) - [GovernorAlreadyCastVote(voter)](#IGovernor-GovernorAlreadyCastVote-address-) - [GovernorDisabledDeposit()](#IGovernor-GovernorDisabledDeposit--) @@ -4716,13 +4767,14 @@ Traditional (un-keyed) nonces are still supported and can continue to be used as - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -4818,7 +4870,9 @@ proposal. - [lateQuorumVoteExtension()](#GovernorPreventLateQuorum-lateQuorumVoteExtension--) - [setLateQuorumVoteExtension(newVoteExtension)](#GovernorPreventLateQuorum-setLateQuorumVoteExtension-uint48-) - [_setLateQuorumVoteExtension(newVoteExtension)](#GovernorPreventLateQuorum-_setLateQuorumVoteExtension-uint48-) -#### Governor [!toc] +
+Governor + - [receive()](#Governor-receive--) - [supportsInterface(interfaceId)](#Governor-supportsInterface-bytes4-) - [name()](#Governor-name--) @@ -4872,25 +4926,33 @@ proposal. - [quorum(timepoint)](#Governor-quorum-uint256-) - [BALLOT_TYPEHASH()](#Governor-BALLOT_TYPEHASH-bytes32) - [EXTENDED_BALLOT_TYPEHASH()](#Governor-EXTENDED_BALLOT_TYPEHASH-bytes32) -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] + +
+
+IGovernor + - [COUNTING_MODE()](#IGovernor-COUNTING_MODE--) - [hasVoted(proposalId, account)](#IGovernor-hasVoted-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### EIP712 [!toc] + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -4899,33 +4961,32 @@ proposal.
- [ProposalExtended(proposalId, extendedDeadline)](#GovernorPreventLateQuorum-ProposalExtended-uint256-uint64-) - [LateQuorumVoteExtensionSet(oldVoteExtension, newVoteExtension)](#GovernorPreventLateQuorum-LateQuorumVoteExtensionSet-uint64-uint64-) -#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [ProposalCreated(proposalId, proposer, targets, values, signatures, calldatas, voteStart, voteEnd, description)](#IGovernor-ProposalCreated-uint256-address-address---uint256---string---bytes---uint256-uint256-string-) - [ProposalQueued(proposalId, etaSeconds)](#IGovernor-ProposalQueued-uint256-uint256-) - [ProposalExecuted(proposalId)](#IGovernor-ProposalExecuted-uint256-) - [ProposalCanceled(proposalId)](#IGovernor-ProposalCanceled-uint256-) - [VoteCast(voter, proposalId, support, weight, reason)](#IGovernor-VoteCast-address-uint256-uint8-uint256-string-) - [VoteCastWithParams(voter, proposalId, support, weight, reason, params)](#IGovernor-VoteCastWithParams-address-uint256-uint8-uint256-string-bytes-) -#### IERC6372 [!toc] -#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
+
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [GovernorInvalidProposalLength(targets, calldatas, values)](#IGovernor-GovernorInvalidProposalLength-uint256-uint256-uint256-) - [GovernorAlreadyCastVote(voter)](#IGovernor-GovernorAlreadyCastVote-address-) - [GovernorDisabledDeposit()](#IGovernor-GovernorDisabledDeposit--) @@ -4941,13 +5002,14 @@ proposal. - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -5129,7 +5191,9 @@ if the proposal guardian is not configured, then proposers take this role for th - [setProposalGuardian(newProposalGuardian)](#GovernorProposalGuardian-setProposalGuardian-address-) - [_setProposalGuardian(newProposalGuardian)](#GovernorProposalGuardian-_setProposalGuardian-address-) - [_validateCancel(proposalId, caller)](#GovernorProposalGuardian-_validateCancel-uint256-address-) -#### Governor [!toc] +
+Governor + - [receive()](#Governor-receive--) - [supportsInterface(interfaceId)](#Governor-supportsInterface-bytes4-) - [name()](#Governor-name--) @@ -5184,25 +5248,33 @@ if the proposal guardian is not configured, then proposers take this role for th - [quorum(timepoint)](#Governor-quorum-uint256-) - [BALLOT_TYPEHASH()](#Governor-BALLOT_TYPEHASH-bytes32) - [EXTENDED_BALLOT_TYPEHASH()](#Governor-EXTENDED_BALLOT_TYPEHASH-bytes32) -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] + +
+
+IGovernor + - [COUNTING_MODE()](#IGovernor-COUNTING_MODE--) - [hasVoted(proposalId, account)](#IGovernor-hasVoted-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### EIP712 [!toc] + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -5210,33 +5282,32 @@ if the proposal guardian is not configured, then proposers take this role for th

Events

- [ProposalGuardianSet(oldProposalGuardian, newProposalGuardian)](#GovernorProposalGuardian-ProposalGuardianSet-address-address-) -#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [ProposalCreated(proposalId, proposer, targets, values, signatures, calldatas, voteStart, voteEnd, description)](#IGovernor-ProposalCreated-uint256-address-address---uint256---string---bytes---uint256-uint256-string-) - [ProposalQueued(proposalId, etaSeconds)](#IGovernor-ProposalQueued-uint256-uint256-) - [ProposalExecuted(proposalId)](#IGovernor-ProposalExecuted-uint256-) - [ProposalCanceled(proposalId)](#IGovernor-ProposalCanceled-uint256-) - [VoteCast(voter, proposalId, support, weight, reason)](#IGovernor-VoteCast-address-uint256-uint8-uint256-string-) - [VoteCastWithParams(voter, proposalId, support, weight, reason, params)](#IGovernor-VoteCastWithParams-address-uint256-uint8-uint256-string-bytes-) -#### IERC6372 [!toc] -#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
+
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [GovernorInvalidProposalLength(targets, calldatas, values)](#IGovernor-GovernorInvalidProposalLength-uint256-uint256-uint256-) - [GovernorAlreadyCastVote(voter)](#IGovernor-GovernorAlreadyCastVote-address-) - [GovernorDisabledDeposit()](#IGovernor-GovernorDisabledDeposit--) @@ -5252,13 +5323,14 @@ if the proposal guardian is not configured, then proposers take this role for th - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -5380,7 +5452,9 @@ sequential ids. - [latestProposalId()](#GovernorSequentialProposalId-latestProposalId--) - [_propose(targets, values, calldatas, description, proposer)](#GovernorSequentialProposalId-_propose-address---uint256---bytes---string-address-) - [_initializeLatestProposalId(newLatestProposalId)](#GovernorSequentialProposalId-_initializeLatestProposalId-uint256-) -#### Governor [!toc] +
+Governor + - [receive()](#Governor-receive--) - [supportsInterface(interfaceId)](#Governor-supportsInterface-bytes4-) - [name()](#Governor-name--) @@ -5434,48 +5508,56 @@ sequential ids. - [quorum(timepoint)](#Governor-quorum-uint256-) - [BALLOT_TYPEHASH()](#Governor-BALLOT_TYPEHASH-bytes32) - [EXTENDED_BALLOT_TYPEHASH()](#Governor-EXTENDED_BALLOT_TYPEHASH-bytes32) -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] + +
+
+IGovernor + - [COUNTING_MODE()](#IGovernor-COUNTING_MODE--) - [hasVoted(proposalId, account)](#IGovernor-hasVoted-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### EIP712 [!toc] + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Events

-#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [ProposalCreated(proposalId, proposer, targets, values, signatures, calldatas, voteStart, voteEnd, description)](#IGovernor-ProposalCreated-uint256-address-address---uint256---string---bytes---uint256-uint256-string-) - [ProposalQueued(proposalId, etaSeconds)](#IGovernor-ProposalQueued-uint256-uint256-) - [ProposalExecuted(proposalId)](#IGovernor-ProposalExecuted-uint256-) - [ProposalCanceled(proposalId)](#IGovernor-ProposalCanceled-uint256-) - [VoteCast(voter, proposalId, support, weight, reason)](#IGovernor-VoteCast-address-uint256-uint8-uint256-string-) - [VoteCastWithParams(voter, proposalId, support, weight, reason, params)](#IGovernor-VoteCastWithParams-address-uint256-uint8-uint256-string-bytes-) -#### IERC6372 [!toc] -#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
+
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -5483,10 +5565,9 @@ sequential ids.

Errors

- [GovernorAlreadyInitializedLatestProposalId()](#GovernorSequentialProposalId-GovernorAlreadyInitializedLatestProposalId--) -#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [GovernorInvalidProposalLength(targets, calldatas, values)](#IGovernor-GovernorInvalidProposalLength-uint256-uint256-uint256-) - [GovernorAlreadyCastVote(voter)](#IGovernor-GovernorAlreadyCastVote-address-) - [GovernorDisabledDeposit()](#IGovernor-GovernorDisabledDeposit--) @@ -5502,13 +5583,14 @@ sequential ids. - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -5631,7 +5713,9 @@ Extension of [`Governor`](#Governor) for settings updatable through governance. - [_setVotingDelay(newVotingDelay)](#GovernorSettings-_setVotingDelay-uint48-) - [_setVotingPeriod(newVotingPeriod)](#GovernorSettings-_setVotingPeriod-uint32-) - [_setProposalThreshold(newProposalThreshold)](#GovernorSettings-_setProposalThreshold-uint256-) -#### Governor [!toc] +
+Governor + - [receive()](#Governor-receive--) - [supportsInterface(interfaceId)](#Governor-supportsInterface-bytes4-) - [name()](#Governor-name--) @@ -5684,25 +5768,33 @@ Extension of [`Governor`](#Governor) for settings updatable through governance. - [quorum(timepoint)](#Governor-quorum-uint256-) - [BALLOT_TYPEHASH()](#Governor-BALLOT_TYPEHASH-bytes32) - [EXTENDED_BALLOT_TYPEHASH()](#Governor-EXTENDED_BALLOT_TYPEHASH-bytes32) -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] + +
+
+IGovernor + - [COUNTING_MODE()](#IGovernor-COUNTING_MODE--) - [hasVoted(proposalId, account)](#IGovernor-hasVoted-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### EIP712 [!toc] + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -5712,33 +5804,32 @@ Extension of [`Governor`](#Governor) for settings updatable through governance. - [VotingDelaySet(oldVotingDelay, newVotingDelay)](#GovernorSettings-VotingDelaySet-uint256-uint256-) - [VotingPeriodSet(oldVotingPeriod, newVotingPeriod)](#GovernorSettings-VotingPeriodSet-uint256-uint256-) - [ProposalThresholdSet(oldProposalThreshold, newProposalThreshold)](#GovernorSettings-ProposalThresholdSet-uint256-uint256-) -#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [ProposalCreated(proposalId, proposer, targets, values, signatures, calldatas, voteStart, voteEnd, description)](#IGovernor-ProposalCreated-uint256-address-address---uint256---string---bytes---uint256-uint256-string-) - [ProposalQueued(proposalId, etaSeconds)](#IGovernor-ProposalQueued-uint256-uint256-) - [ProposalExecuted(proposalId)](#IGovernor-ProposalExecuted-uint256-) - [ProposalCanceled(proposalId)](#IGovernor-ProposalCanceled-uint256-) - [VoteCast(voter, proposalId, support, weight, reason)](#IGovernor-VoteCast-address-uint256-uint8-uint256-string-) - [VoteCastWithParams(voter, proposalId, support, weight, reason, params)](#IGovernor-VoteCastWithParams-address-uint256-uint8-uint256-string-bytes-) -#### IERC6372 [!toc] -#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
+
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [GovernorInvalidProposalLength(targets, calldatas, values)](#IGovernor-GovernorInvalidProposalLength-uint256-uint256-uint256-) - [GovernorAlreadyCastVote(voter)](#IGovernor-GovernorAlreadyCastVote-address-) - [GovernorDisabledDeposit()](#IGovernor-GovernorDisabledDeposit--) @@ -5754,13 +5845,14 @@ Extension of [`Governor`](#Governor) for settings updatable through governance. - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -6022,7 +6114,9 @@ Use cases for this module include: - [proposalCount()](#GovernorStorage-proposalCount--) - [proposalDetails(proposalId)](#GovernorStorage-proposalDetails-uint256-) - [proposalDetailsAt(index)](#GovernorStorage-proposalDetailsAt-uint256-) -#### Governor [!toc] +
+Governor + - [receive()](#Governor-receive--) - [supportsInterface(interfaceId)](#Governor-supportsInterface-bytes4-) - [name()](#Governor-name--) @@ -6077,58 +6171,65 @@ Use cases for this module include: - [quorum(timepoint)](#Governor-quorum-uint256-) - [BALLOT_TYPEHASH()](#Governor-BALLOT_TYPEHASH-bytes32) - [EXTENDED_BALLOT_TYPEHASH()](#Governor-EXTENDED_BALLOT_TYPEHASH-bytes32) -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] + +
+
+IGovernor + - [COUNTING_MODE()](#IGovernor-COUNTING_MODE--) - [hasVoted(proposalId, account)](#IGovernor-hasVoted-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### EIP712 [!toc] + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Events

-#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [ProposalCreated(proposalId, proposer, targets, values, signatures, calldatas, voteStart, voteEnd, description)](#IGovernor-ProposalCreated-uint256-address-address---uint256---string---bytes---uint256-uint256-string-) - [ProposalQueued(proposalId, etaSeconds)](#IGovernor-ProposalQueued-uint256-uint256-) - [ProposalExecuted(proposalId)](#IGovernor-ProposalExecuted-uint256-) - [ProposalCanceled(proposalId)](#IGovernor-ProposalCanceled-uint256-) - [VoteCast(voter, proposalId, support, weight, reason)](#IGovernor-VoteCast-address-uint256-uint8-uint256-string-) - [VoteCastWithParams(voter, proposalId, support, weight, reason, params)](#IGovernor-VoteCastWithParams-address-uint256-uint8-uint256-string-bytes-) -#### IERC6372 [!toc] -#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
+
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [GovernorInvalidProposalLength(targets, calldatas, values)](#IGovernor-GovernorInvalidProposalLength-uint256-uint256-uint256-) - [GovernorAlreadyCastVote(voter)](#IGovernor-GovernorAlreadyCastVote-address-) - [GovernorDisabledDeposit()](#IGovernor-GovernorDisabledDeposit--) @@ -6144,13 +6245,14 @@ Use cases for this module include: - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -6299,7 +6401,9 @@ extension must implement [`GovernorCountingFractional.proposalVotes`](#GovernorC - [superQuorum(timepoint)](#GovernorSuperQuorum-superQuorum-uint256-) - [proposalVotes(proposalId)](#GovernorSuperQuorum-proposalVotes-uint256-) - [state(proposalId)](#GovernorSuperQuorum-state-uint256-) -#### Governor [!toc] +
+Governor + - [receive()](#Governor-receive--) - [supportsInterface(interfaceId)](#Governor-supportsInterface-bytes4-) - [name()](#Governor-name--) @@ -6354,58 +6458,65 @@ extension must implement [`GovernorCountingFractional.proposalVotes`](#GovernorC - [quorum(timepoint)](#Governor-quorum-uint256-) - [BALLOT_TYPEHASH()](#Governor-BALLOT_TYPEHASH-bytes32) - [EXTENDED_BALLOT_TYPEHASH()](#Governor-EXTENDED_BALLOT_TYPEHASH-bytes32) -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] + +
+
+IGovernor + - [COUNTING_MODE()](#IGovernor-COUNTING_MODE--) - [hasVoted(proposalId, account)](#IGovernor-hasVoted-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### EIP712 [!toc] + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Events

-#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [ProposalCreated(proposalId, proposer, targets, values, signatures, calldatas, voteStart, voteEnd, description)](#IGovernor-ProposalCreated-uint256-address-address---uint256---string---bytes---uint256-uint256-string-) - [ProposalQueued(proposalId, etaSeconds)](#IGovernor-ProposalQueued-uint256-uint256-) - [ProposalExecuted(proposalId)](#IGovernor-ProposalExecuted-uint256-) - [ProposalCanceled(proposalId)](#IGovernor-ProposalCanceled-uint256-) - [VoteCast(voter, proposalId, support, weight, reason)](#IGovernor-VoteCast-address-uint256-uint8-uint256-string-) - [VoteCastWithParams(voter, proposalId, support, weight, reason, params)](#IGovernor-VoteCastWithParams-address-uint256-uint8-uint256-string-bytes-) -#### IERC6372 [!toc] -#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
+
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [GovernorInvalidProposalLength(targets, calldatas, values)](#IGovernor-GovernorInvalidProposalLength-uint256-uint256-uint256-) - [GovernorAlreadyCastVote(voter)](#IGovernor-GovernorAlreadyCastVote-address-) - [GovernorDisabledDeposit()](#IGovernor-GovernorDisabledDeposit--) @@ -6421,13 +6532,14 @@ extension must implement [`GovernorCountingFractional.proposalVotes`](#GovernorC - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -6567,7 +6679,9 @@ the same time. See [`AccessManager.schedule`](/contracts/5.x/api/access#AccessMa - [_queueOperations(proposalId, targets, , calldatas, )](#GovernorTimelockAccess-_queueOperations-uint256-address---uint256---bytes---bytes32-) - [_executeOperations(proposalId, targets, values, calldatas, )](#GovernorTimelockAccess-_executeOperations-uint256-address---uint256---bytes---bytes32-) - [_cancel(targets, values, calldatas, descriptionHash)](#GovernorTimelockAccess-_cancel-address---uint256---bytes---bytes32-) -#### Governor [!toc] +
+Governor + - [receive()](#Governor-receive--) - [supportsInterface(interfaceId)](#Governor-supportsInterface-bytes4-) - [name()](#Governor-name--) @@ -6618,25 +6732,33 @@ the same time. See [`AccessManager.schedule`](/contracts/5.x/api/access#AccessMa - [quorum(timepoint)](#Governor-quorum-uint256-) - [BALLOT_TYPEHASH()](#Governor-BALLOT_TYPEHASH-bytes32) - [EXTENDED_BALLOT_TYPEHASH()](#Governor-EXTENDED_BALLOT_TYPEHASH-bytes32) -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] + +
+
+IGovernor + - [COUNTING_MODE()](#IGovernor-COUNTING_MODE--) - [hasVoted(proposalId, account)](#IGovernor-hasVoted-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### EIP712 [!toc] + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -6645,23 +6767,23 @@ the same time. See [`AccessManager.schedule`](/contracts/5.x/api/access#AccessMa
- [BaseDelaySet(oldBaseDelaySeconds, newBaseDelaySeconds)](#GovernorTimelockAccess-BaseDelaySet-uint32-uint32-) - [AccessManagerIgnoredSet(target, selector, ignored)](#GovernorTimelockAccess-AccessManagerIgnoredSet-address-bytes4-bool-) -#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [ProposalCreated(proposalId, proposer, targets, values, signatures, calldatas, voteStart, voteEnd, description)](#IGovernor-ProposalCreated-uint256-address-address---uint256---string---bytes---uint256-uint256-string-) - [ProposalQueued(proposalId, etaSeconds)](#IGovernor-ProposalQueued-uint256-uint256-) - [ProposalExecuted(proposalId)](#IGovernor-ProposalExecuted-uint256-) - [ProposalCanceled(proposalId)](#IGovernor-ProposalCanceled-uint256-) - [VoteCast(voter, proposalId, support, weight, reason)](#IGovernor-VoteCast-address-uint256-uint8-uint256-string-) - [VoteCastWithParams(voter, proposalId, support, weight, reason, params)](#IGovernor-VoteCastWithParams-address-uint256-uint8-uint256-string-bytes-) -#### IERC6372 [!toc] -#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
+
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -6671,10 +6793,9 @@ the same time. See [`AccessManager.schedule`](/contracts/5.x/api/access#AccessMa - [GovernorUnmetDelay(proposalId, neededTimestamp)](#GovernorTimelockAccess-GovernorUnmetDelay-uint256-uint256-) - [GovernorMismatchedNonce(proposalId, expectedNonce, actualNonce)](#GovernorTimelockAccess-GovernorMismatchedNonce-uint256-uint256-uint256-) - [GovernorLockedIgnore()](#GovernorTimelockAccess-GovernorLockedIgnore--) -#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [GovernorInvalidProposalLength(targets, calldatas, values)](#IGovernor-GovernorInvalidProposalLength-uint256-uint256-uint256-) - [GovernorAlreadyCastVote(voter)](#IGovernor-GovernorAlreadyCastVote-address-) - [GovernorDisabledDeposit()](#IGovernor-GovernorDisabledDeposit--) @@ -6690,13 +6811,14 @@ the same time. See [`AccessManager.schedule`](/contracts/5.x/api/access#AccessMa - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -7069,7 +7191,9 @@ inaccessible from a proposal, unless executed via [`Governor.relay`](#Governor-r - [_executor()](#GovernorTimelockCompound-_executor--) - [__acceptAdmin()](#GovernorTimelockCompound-__acceptAdmin--) - [updateTimelock(newTimelock)](#GovernorTimelockCompound-updateTimelock-contract-ICompoundTimelock-) -#### Governor [!toc] +
+Governor + - [receive()](#Governor-receive--) - [supportsInterface(interfaceId)](#Governor-supportsInterface-bytes4-) - [name()](#Governor-name--) @@ -7119,25 +7243,33 @@ inaccessible from a proposal, unless executed via [`Governor.relay`](#Governor-r - [quorum(timepoint)](#Governor-quorum-uint256-) - [BALLOT_TYPEHASH()](#Governor-BALLOT_TYPEHASH-bytes32) - [EXTENDED_BALLOT_TYPEHASH()](#Governor-EXTENDED_BALLOT_TYPEHASH-bytes32) -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] + +
+
+IGovernor + - [COUNTING_MODE()](#IGovernor-COUNTING_MODE--) - [hasVoted(proposalId, account)](#IGovernor-hasVoted-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### EIP712 [!toc] + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -7145,33 +7277,32 @@ inaccessible from a proposal, unless executed via [`Governor.relay`](#Governor-r

Events

- [TimelockChange(oldTimelock, newTimelock)](#GovernorTimelockCompound-TimelockChange-address-address-) -#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [ProposalCreated(proposalId, proposer, targets, values, signatures, calldatas, voteStart, voteEnd, description)](#IGovernor-ProposalCreated-uint256-address-address---uint256---string---bytes---uint256-uint256-string-) - [ProposalQueued(proposalId, etaSeconds)](#IGovernor-ProposalQueued-uint256-uint256-) - [ProposalExecuted(proposalId)](#IGovernor-ProposalExecuted-uint256-) - [ProposalCanceled(proposalId)](#IGovernor-ProposalCanceled-uint256-) - [VoteCast(voter, proposalId, support, weight, reason)](#IGovernor-VoteCast-address-uint256-uint8-uint256-string-) - [VoteCastWithParams(voter, proposalId, support, weight, reason, params)](#IGovernor-VoteCastWithParams-address-uint256-uint8-uint256-string-bytes-) -#### IERC6372 [!toc] -#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
+
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [GovernorInvalidProposalLength(targets, calldatas, values)](#IGovernor-GovernorInvalidProposalLength-uint256-uint256-uint256-) - [GovernorAlreadyCastVote(voter)](#IGovernor-GovernorAlreadyCastVote-address-) - [GovernorDisabledDeposit()](#IGovernor-GovernorDisabledDeposit--) @@ -7187,13 +7318,14 @@ inaccessible from a proposal, unless executed via [`Governor.relay`](#Governor-r - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -7440,7 +7572,9 @@ proposals that have been approved by the voters, effectively executing a Denial - [_cancel(targets, values, calldatas, descriptionHash)](#GovernorTimelockControl-_cancel-address---uint256---bytes---bytes32-) - [_executor()](#GovernorTimelockControl-_executor--) - [updateTimelock(newTimelock)](#GovernorTimelockControl-updateTimelock-contract-TimelockController-) -#### Governor [!toc] +
+Governor + - [receive()](#Governor-receive--) - [supportsInterface(interfaceId)](#Governor-supportsInterface-bytes4-) - [name()](#Governor-name--) @@ -7490,25 +7624,33 @@ proposals that have been approved by the voters, effectively executing a Denial - [quorum(timepoint)](#Governor-quorum-uint256-) - [BALLOT_TYPEHASH()](#Governor-BALLOT_TYPEHASH-bytes32) - [EXTENDED_BALLOT_TYPEHASH()](#Governor-EXTENDED_BALLOT_TYPEHASH-bytes32) -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] + +
+
+IGovernor + - [COUNTING_MODE()](#IGovernor-COUNTING_MODE--) - [hasVoted(proposalId, account)](#IGovernor-hasVoted-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### EIP712 [!toc] + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -7516,33 +7658,32 @@ proposals that have been approved by the voters, effectively executing a Denial

Events

- [TimelockChange(oldTimelock, newTimelock)](#GovernorTimelockControl-TimelockChange-address-address-) -#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [ProposalCreated(proposalId, proposer, targets, values, signatures, calldatas, voteStart, voteEnd, description)](#IGovernor-ProposalCreated-uint256-address-address---uint256---string---bytes---uint256-uint256-string-) - [ProposalQueued(proposalId, etaSeconds)](#IGovernor-ProposalQueued-uint256-uint256-) - [ProposalExecuted(proposalId)](#IGovernor-ProposalExecuted-uint256-) - [ProposalCanceled(proposalId)](#IGovernor-ProposalCanceled-uint256-) - [VoteCast(voter, proposalId, support, weight, reason)](#IGovernor-VoteCast-address-uint256-uint8-uint256-string-) - [VoteCastWithParams(voter, proposalId, support, weight, reason, params)](#IGovernor-VoteCastWithParams-address-uint256-uint8-uint256-string-bytes-) -#### IERC6372 [!toc] -#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
+
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [GovernorInvalidProposalLength(targets, calldatas, values)](#IGovernor-GovernorInvalidProposalLength-uint256-uint256-uint256-) - [GovernorAlreadyCastVote(voter)](#IGovernor-GovernorAlreadyCastVote-address-) - [GovernorDisabledDeposit()](#IGovernor-GovernorDisabledDeposit--) @@ -7558,13 +7699,14 @@ proposals that have been approved by the voters, effectively executing a Denial - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -7771,7 +7913,9 @@ token. - [clock()](#GovernorVotes-clock--) - [CLOCK_MODE()](#GovernorVotes-CLOCK_MODE--) - [_getVotes(account, timepoint, )](#GovernorVotes-_getVotes-address-uint256-bytes-) -#### Governor [!toc] +
+Governor + - [receive()](#Governor-receive--) - [supportsInterface(interfaceId)](#Governor-supportsInterface-bytes4-) - [name()](#Governor-name--) @@ -7824,58 +7968,65 @@ token. - [quorum(timepoint)](#Governor-quorum-uint256-) - [BALLOT_TYPEHASH()](#Governor-BALLOT_TYPEHASH-bytes32) - [EXTENDED_BALLOT_TYPEHASH()](#Governor-EXTENDED_BALLOT_TYPEHASH-bytes32) -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] + +
+
+IGovernor + - [COUNTING_MODE()](#IGovernor-COUNTING_MODE--) - [hasVoted(proposalId, account)](#IGovernor-hasVoted-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### EIP712 [!toc] + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Events

-#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [ProposalCreated(proposalId, proposer, targets, values, signatures, calldatas, voteStart, voteEnd, description)](#IGovernor-ProposalCreated-uint256-address-address---uint256---string---bytes---uint256-uint256-string-) - [ProposalQueued(proposalId, etaSeconds)](#IGovernor-ProposalQueued-uint256-uint256-) - [ProposalExecuted(proposalId)](#IGovernor-ProposalExecuted-uint256-) - [ProposalCanceled(proposalId)](#IGovernor-ProposalCanceled-uint256-) - [VoteCast(voter, proposalId, support, weight, reason)](#IGovernor-VoteCast-address-uint256-uint8-uint256-string-) - [VoteCastWithParams(voter, proposalId, support, weight, reason, params)](#IGovernor-VoteCastWithParams-address-uint256-uint8-uint256-string-bytes-) -#### IERC6372 [!toc] -#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
+
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [GovernorInvalidProposalLength(targets, calldatas, values)](#IGovernor-GovernorInvalidProposalLength-uint256-uint256-uint256-) - [GovernorAlreadyCastVote(voter)](#IGovernor-GovernorAlreadyCastVote-address-) - [GovernorDisabledDeposit()](#IGovernor-GovernorDisabledDeposit--) @@ -7891,13 +8042,14 @@ token. - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -8013,12 +8165,18 @@ fraction of the total supply. - [updateQuorumNumerator(newQuorumNumerator)](#GovernorVotesQuorumFraction-updateQuorumNumerator-uint256-) - [_updateQuorumNumerator(newQuorumNumerator)](#GovernorVotesQuorumFraction-_updateQuorumNumerator-uint256-) - [_optimisticUpperLookupRecent(ckpts, timepoint)](#GovernorVotesQuorumFraction-_optimisticUpperLookupRecent-struct-Checkpoints-Trace208-uint256-) -#### GovernorVotes [!toc] +
+GovernorVotes + - [token()](#GovernorVotes-token--) - [clock()](#GovernorVotes-clock--) - [CLOCK_MODE()](#GovernorVotes-CLOCK_MODE--) - [_getVotes(account, timepoint, )](#GovernorVotes-_getVotes-address-uint256-bytes-) -#### Governor [!toc] + +
+
+Governor + - [receive()](#Governor-receive--) - [supportsInterface(interfaceId)](#Governor-supportsInterface-bytes4-) - [name()](#Governor-name--) @@ -8070,25 +8228,33 @@ fraction of the total supply. - [votingPeriod()](#Governor-votingPeriod--) - [BALLOT_TYPEHASH()](#Governor-BALLOT_TYPEHASH-bytes32) - [EXTENDED_BALLOT_TYPEHASH()](#Governor-EXTENDED_BALLOT_TYPEHASH-bytes32) -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] + +
+
+IGovernor + - [COUNTING_MODE()](#IGovernor-COUNTING_MODE--) - [hasVoted(proposalId, account)](#IGovernor-hasVoted-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### EIP712 [!toc] + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -8096,24 +8262,23 @@ fraction of the total supply.

Events

- [QuorumNumeratorUpdated(oldQuorumNumerator, newQuorumNumerator)](#GovernorVotesQuorumFraction-QuorumNumeratorUpdated-uint256-uint256-) -#### GovernorVotes [!toc] -#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [ProposalCreated(proposalId, proposer, targets, values, signatures, calldatas, voteStart, voteEnd, description)](#IGovernor-ProposalCreated-uint256-address-address---uint256---string---bytes---uint256-uint256-string-) - [ProposalQueued(proposalId, etaSeconds)](#IGovernor-ProposalQueued-uint256-uint256-) - [ProposalExecuted(proposalId)](#IGovernor-ProposalExecuted-uint256-) - [ProposalCanceled(proposalId)](#IGovernor-ProposalCanceled-uint256-) - [VoteCast(voter, proposalId, support, weight, reason)](#IGovernor-VoteCast-address-uint256-uint8-uint256-string-) - [VoteCastWithParams(voter, proposalId, support, weight, reason, params)](#IGovernor-VoteCastWithParams-address-uint256-uint8-uint256-string-bytes-) -#### IERC6372 [!toc] -#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
+
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -8121,11 +8286,9 @@ fraction of the total supply.

Errors

- [GovernorInvalidQuorumFraction(quorumNumerator, quorumDenominator)](#GovernorVotesQuorumFraction-GovernorInvalidQuorumFraction-uint256-uint256-) -#### GovernorVotes [!toc] -#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] +
+IGovernor + - [GovernorInvalidProposalLength(targets, calldatas, values)](#IGovernor-GovernorInvalidProposalLength-uint256-uint256-uint256-) - [GovernorAlreadyCastVote(voter)](#IGovernor-GovernorAlreadyCastVote-address-) - [GovernorDisabledDeposit()](#IGovernor-GovernorDisabledDeposit--) @@ -8141,13 +8304,14 @@ fraction of the total supply. - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -8368,21 +8532,35 @@ the `Succeeded` state before the proposal deadline. - [_updateSuperQuorumNumerator(newSuperQuorumNumerator)](#GovernorVotesSuperQuorumFraction-_updateSuperQuorumNumerator-uint256-) - [_updateQuorumNumerator(newQuorumNumerator)](#GovernorVotesSuperQuorumFraction-_updateQuorumNumerator-uint256-) - [state(proposalId)](#GovernorVotesSuperQuorumFraction-state-uint256-) -#### GovernorSuperQuorum [!toc] +
+GovernorSuperQuorum + - [proposalVotes(proposalId)](#GovernorSuperQuorum-proposalVotes-uint256-) -#### GovernorVotesQuorumFraction [!toc] + +
+
+GovernorVotesQuorumFraction + - [quorumNumerator()](#GovernorVotesQuorumFraction-quorumNumerator--) - [quorumNumerator(timepoint)](#GovernorVotesQuorumFraction-quorumNumerator-uint256-) - [quorumDenominator()](#GovernorVotesQuorumFraction-quorumDenominator--) - [quorum(timepoint)](#GovernorVotesQuorumFraction-quorum-uint256-) - [updateQuorumNumerator(newQuorumNumerator)](#GovernorVotesQuorumFraction-updateQuorumNumerator-uint256-) - [_optimisticUpperLookupRecent(ckpts, timepoint)](#GovernorVotesQuorumFraction-_optimisticUpperLookupRecent-struct-Checkpoints-Trace208-uint256-) -#### GovernorVotes [!toc] + +
+
+GovernorVotes + - [token()](#GovernorVotes-token--) - [clock()](#GovernorVotes-clock--) - [CLOCK_MODE()](#GovernorVotes-CLOCK_MODE--) - [_getVotes(account, timepoint, )](#GovernorVotes-_getVotes-address-uint256-bytes-) -#### Governor [!toc] + +
+
+Governor + - [receive()](#Governor-receive--) - [supportsInterface(interfaceId)](#Governor-supportsInterface-bytes4-) - [name()](#Governor-name--) @@ -8433,25 +8611,33 @@ the `Succeeded` state before the proposal deadline. - [votingPeriod()](#Governor-votingPeriod--) - [BALLOT_TYPEHASH()](#Governor-BALLOT_TYPEHASH-bytes32) - [EXTENDED_BALLOT_TYPEHASH()](#Governor-EXTENDED_BALLOT_TYPEHASH-bytes32) -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] + +
+
+IGovernor + - [COUNTING_MODE()](#IGovernor-COUNTING_MODE--) - [hasVoted(proposalId, account)](#IGovernor-hasVoted-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### EIP712 [!toc] + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -8459,27 +8645,29 @@ the `Succeeded` state before the proposal deadline.

Events

- [SuperQuorumNumeratorUpdated(oldSuperQuorumNumerator, newSuperQuorumNumerator)](#GovernorVotesSuperQuorumFraction-SuperQuorumNumeratorUpdated-uint256-uint256-) -#### GovernorSuperQuorum [!toc] -#### GovernorVotesQuorumFraction [!toc] +
+GovernorVotesQuorumFraction + - [QuorumNumeratorUpdated(oldQuorumNumerator, newQuorumNumerator)](#GovernorVotesQuorumFraction-QuorumNumeratorUpdated-uint256-uint256-) -#### GovernorVotes [!toc] -#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] + +
+
+IGovernor + - [ProposalCreated(proposalId, proposer, targets, values, signatures, calldatas, voteStart, voteEnd, description)](#IGovernor-ProposalCreated-uint256-address-address---uint256---string---bytes---uint256-uint256-string-) - [ProposalQueued(proposalId, etaSeconds)](#IGovernor-ProposalQueued-uint256-uint256-) - [ProposalExecuted(proposalId)](#IGovernor-ProposalExecuted-uint256-) - [ProposalCanceled(proposalId)](#IGovernor-ProposalCanceled-uint256-) - [VoteCast(voter, proposalId, support, weight, reason)](#IGovernor-VoteCast-address-uint256-uint8-uint256-string-) - [VoteCastWithParams(voter, proposalId, support, weight, reason, params)](#IGovernor-VoteCastWithParams-address-uint256-uint8-uint256-string-bytes-) -#### IERC6372 [!toc] -#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
+
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -8489,14 +8677,15 @@ the `Succeeded` state before the proposal deadline. - [GovernorInvalidSuperQuorumFraction(superQuorumNumerator, denominator)](#GovernorVotesSuperQuorumFraction-GovernorInvalidSuperQuorumFraction-uint256-uint256-) - [GovernorInvalidSuperQuorumTooSmall(superQuorumNumerator, quorumNumerator)](#GovernorVotesSuperQuorumFraction-GovernorInvalidSuperQuorumTooSmall-uint256-uint256-) - [GovernorInvalidQuorumTooLarge(quorumNumerator, superQuorumNumerator)](#GovernorVotesSuperQuorumFraction-GovernorInvalidQuorumTooLarge-uint256-uint256-) -#### GovernorSuperQuorum [!toc] -#### GovernorVotesQuorumFraction [!toc] +
+GovernorVotesQuorumFraction + - [GovernorInvalidQuorumFraction(quorumNumerator, quorumDenominator)](#GovernorVotesQuorumFraction-GovernorInvalidQuorumFraction-uint256-uint256-) -#### GovernorVotes [!toc] -#### Governor [!toc] -#### IERC1155Receiver [!toc] -#### IERC721Receiver [!toc] -#### IGovernor [!toc] + +
+
+IGovernor + - [GovernorInvalidProposalLength(targets, calldatas, values)](#IGovernor-GovernorInvalidProposalLength-uint256-uint256-uint256-) - [GovernorAlreadyCastVote(voter)](#IGovernor-GovernorAlreadyCastVote-address-) - [GovernorDisabledDeposit()](#IGovernor-GovernorDisabledDeposit--) @@ -8512,13 +8701,14 @@ the `Succeeded` state before the proposal deadline. - [GovernorAlreadyQueuedProposal(proposalId)](#IGovernor-GovernorAlreadyQueuedProposal-uint256-) - [GovernorInvalidSignature(voter)](#IGovernor-GovernorInvalidSignature-address-) - [GovernorUnableToCancel(proposalId, account)](#IGovernor-GovernorUnableToCancel-uint256-address-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -9014,35 +9204,43 @@ previous example, it would be included in [`ERC721._update`](/contracts/5.x/api/ - [_numCheckpoints(account)](#Votes-_numCheckpoints-address-) - [_checkpoints(account, pos)](#Votes-_checkpoints-address-uint32-) - [_getVotingUnits()](#Votes-_getVotingUnits-address-) -#### IERC5805 [!toc] -#### IVotes [!toc] -#### IERC6372 [!toc] -#### Nonces [!toc] +
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### EIP712 [!toc] + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] + +

Events

-#### IERC5805 [!toc] -#### IVotes [!toc] +
+IVotes + - [DelegateChanged(delegator, fromDelegate, toDelegate)](#IVotes-DelegateChanged-address-address-address-) - [DelegateVotesChanged(delegate, previousVotes, newVotes)](#IVotes-DelegateVotesChanged-address-uint256-uint256-) -#### IERC6372 [!toc] -#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
+
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) + +
@@ -9051,14 +9249,18 @@ previous example, it would be included in [`ERC721._update`](/contracts/5.x/api/
- [ERC6372InconsistentClock()](#Votes-ERC6372InconsistentClock--) - [ERC5805FutureLookup(timepoint, clock)](#Votes-ERC5805FutureLookup-uint256-uint48-) -#### IERC5805 [!toc] -#### IVotes [!toc] +
+IVotes + - [VotesExpiredSignature(expiry)](#IVotes-VotesExpiredSignature-uint256-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
@@ -9437,7 +9639,9 @@ contract VotingToken is Token, VotesExtended { - [getPastBalanceOf(account, timepoint)](#VotesExtended-getPastBalanceOf-address-uint256-) - [_delegate(account, delegatee)](#VotesExtended-_delegate-address-address-) - [_transferVotingUnits(from, to, amount)](#VotesExtended-_transferVotingUnits-address-address-uint256-) -#### Votes [!toc] +
+Votes + - [clock()](#Votes-clock--) - [CLOCK_MODE()](#Votes-CLOCK_MODE--) - [_validateTimepoint(timepoint)](#Votes-_validateTimepoint-uint256-) @@ -9452,53 +9656,70 @@ contract VotingToken is Token, VotesExtended { - [_numCheckpoints(account)](#Votes-_numCheckpoints-address-) - [_checkpoints(account, pos)](#Votes-_checkpoints-address-uint32-) - [_getVotingUnits()](#Votes-_getVotingUnits-address-) -#### IERC5805 [!toc] -#### IVotes [!toc] -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### EIP712 [!toc] + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] + +

Events

-#### Votes [!toc] -#### IERC5805 [!toc] -#### IVotes [!toc] +
+IVotes + - [DelegateChanged(delegator, fromDelegate, toDelegate)](#IVotes-DelegateChanged-address-address-address-) - [DelegateVotesChanged(delegate, previousVotes, newVotes)](#IVotes-DelegateVotesChanged-address-uint256-uint256-) -#### IERC6372 [!toc] -#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
+
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) + +

Errors

-#### Votes [!toc] +
+Votes + - [ERC6372InconsistentClock()](#Votes-ERC6372InconsistentClock--) - [ERC5805FutureLookup(timepoint, clock)](#Votes-ERC5805FutureLookup-uint256-uint48-) -#### IERC5805 [!toc] -#### IVotes [!toc] + +
+
+IVotes + - [VotesExpiredSignature(expiry)](#IVotes-VotesExpiredSignature-uint256-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
diff --git a/content/contracts/5.x/api/interfaces.mdx b/content/contracts/5.x/api/interfaces.mdx index 00fcd245..e1643571 100644 --- a/content/contracts/5.x/api/interfaces.mdx +++ b/content/contracts/5.x/api/interfaces.mdx @@ -210,25 +210,36 @@ after `transfer` or `transferFrom`, or code on a spender contract after `approve - [transferFromAndCall(from, to, value, data)](#IERC1363-transferFromAndCall-address-address-uint256-bytes-) - [approveAndCall(spender, value)](#IERC1363-approveAndCall-address-uint256-) - [approveAndCall(spender, value, data)](#IERC1363-approveAndCall-address-uint256-bytes-) -#### IERC165 [!toc] +
+IERC165 + - [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) -#### IERC20 [!toc] + +
+
+IERC20 + - [totalSupply()](#IERC20-totalSupply--) - [balanceOf(account)](#IERC20-balanceOf-address-) - [transfer(to, value)](#IERC20-transfer-address-uint256-) - [allowance(owner, spender)](#IERC20-allowance-address-address-) - [approve(spender, value)](#IERC20-approve-address-uint256-) - [transferFrom(from, to, value)](#IERC20-transferFrom-address-address-uint256-) + +

Events

-#### IERC165 [!toc] -#### IERC20 [!toc] +
+IERC20 + - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +
@@ -487,8 +498,12 @@ support for royalty payments across all NFT marketplaces and ecosystem participa

Functions

- [royaltyInfo(tokenId, salePrice)](#IERC2981-royaltyInfo-uint256-uint256-) -#### IERC165 [!toc] +
+IERC165 + - [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) + +
@@ -675,17 +690,25 @@ Interface of the ERC-4626 "Tokenized Vault Standard", as defined in - [maxRedeem(owner)](#IERC4626-maxRedeem-address-) - [previewRedeem(shares)](#IERC4626-previewRedeem-uint256-) - [redeem(shares, receiver, owner)](#IERC4626-redeem-uint256-address-address-) -#### IERC20Metadata [!toc] +
+IERC20Metadata + - [name()](#IERC20Metadata-name--) - [symbol()](#IERC20Metadata-symbol--) - [decimals()](#IERC20Metadata-decimals--) -#### IERC20 [!toc] + +
+
+IERC20 + - [totalSupply()](#IERC20-totalSupply--) - [balanceOf(account)](#IERC20-balanceOf-address-) - [transfer(to, value)](#IERC20-transfer-address-uint256-) - [allowance(owner, spender)](#IERC20-allowance-address-address-) - [approve(spender, value)](#IERC20-approve-address-uint256-) - [transferFrom(from, to, value)](#IERC20-transferFrom-address-address-uint256-) + +
@@ -694,10 +717,13 @@ Interface of the ERC-4626 "Tokenized Vault Standard", as defined in
- [Deposit(sender, owner, assets, shares)](#IERC4626-Deposit-address-address-uint256-uint256-) - [Withdraw(sender, receiver, owner, assets, shares)](#IERC4626-Withdraw-address-address-address-uint256-uint256-) -#### IERC20Metadata [!toc] -#### IERC20 [!toc] +
+IERC20 + - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +
@@ -1168,7 +1194,9 @@ import "@openzeppelin/contracts/interfaces/IERC4906.sol";

Functions

-#### IERC721 [!toc] +
+IERC721 + - [balanceOf(owner)](#IERC721-balanceOf-address-) - [ownerOf(tokenId)](#IERC721-ownerOf-uint256-) - [safeTransferFrom(from, to, tokenId, data)](#IERC721-safeTransferFrom-address-address-uint256-bytes-) @@ -1178,8 +1206,14 @@ import "@openzeppelin/contracts/interfaces/IERC4906.sol"; - [setApprovalForAll(operator, approved)](#IERC721-setApprovalForAll-address-bool-) - [getApproved(tokenId)](#IERC721-getApproved-uint256-) - [isApprovedForAll(owner, operator)](#IERC721-isApprovedForAll-address-address-) -#### IERC165 [!toc] + +
+
+IERC165 + - [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) + +
@@ -1188,11 +1222,14 @@ import "@openzeppelin/contracts/interfaces/IERC4906.sol";
- [MetadataUpdate(_tokenId)](#IERC4906-MetadataUpdate-uint256-) - [BatchMetadataUpdate(_fromTokenId, _toTokenId)](#IERC4906-BatchMetadataUpdate-uint256-uint256-) -#### IERC721 [!toc] +
+IERC721 + - [Transfer(from, to, tokenId)](#IERC721-Transfer-address-address-uint256-) - [Approval(owner, approved, tokenId)](#IERC721-Approval-address-address-uint256-) - [ApprovalForAll(owner, operator, approved)](#IERC721-ApprovalForAll-address-address-bool-) -#### IERC165 [!toc] + +
@@ -1364,35 +1401,49 @@ import "@openzeppelin/contracts/interfaces/IERC5805.sol";

Functions

-#### IVotes [!toc] +
+IVotes + - [getVotes(account)](#IVotes-getVotes-address-) - [getPastVotes(account, timepoint)](#IVotes-getPastVotes-address-uint256-) - [getPastTotalSupply(timepoint)](#IVotes-getPastTotalSupply-uint256-) - [delegates(account)](#IVotes-delegates-address-) - [delegate(delegatee)](#IVotes-delegate-address-) - [delegateBySig(delegatee, nonce, expiry, v, r, s)](#IVotes-delegateBySig-address-uint256-uint256-uint8-bytes32-bytes32-) -#### IERC6372 [!toc] + +
+
+IERC6372 + - [clock()](#IERC6372-clock--) - [CLOCK_MODE()](#IERC6372-CLOCK_MODE--) + +

Events

-#### IVotes [!toc] +
+IVotes + - [DelegateChanged(delegator, fromDelegate, toDelegate)](#IVotes-DelegateChanged-address-address-address-) - [DelegateVotesChanged(delegate, previousVotes, newVotes)](#IVotes-DelegateVotesChanged-address-uint256-uint256-) -#### IERC6372 [!toc] + +

Errors

-#### IVotes [!toc] +
+IVotes + - [VotesExpiredSignature(expiry)](#IVotes-VotesExpiredSignature-uint256-) -#### IERC6372 [!toc] + +
@@ -1483,8 +1534,12 @@ Required interface of an ERC-6909 compliant contract, as defined in the - [setOperator(spender, approved)](#IERC6909-setOperator-address-bool-) - [transfer(receiver, id, amount)](#IERC6909-transfer-address-uint256-uint256-) - [transferFrom(sender, receiver, id, amount)](#IERC6909-transferFrom-address-address-uint256-uint256-) -#### IERC165 [!toc] +
+IERC165 + - [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) + +
@@ -1494,7 +1549,6 @@ Required interface of an ERC-6909 compliant contract, as defined in the - [Approval(owner, spender, id, amount)](#IERC6909-Approval-address-address-uint256-uint256-) - [OperatorSet(owner, spender, approved)](#IERC6909-OperatorSet-address-address-bool-) - [Transfer(caller, sender, receiver, id, amount)](#IERC6909-Transfer-address-address-address-uint256-uint256-) -#### IERC165 [!toc] @@ -1707,7 +1761,9 @@ Optional extension of [`IERC6909`](#IERC6909) that adds metadata functions. - [name(id)](#IERC6909Metadata-name-uint256-) - [symbol(id)](#IERC6909Metadata-symbol-uint256-) - [decimals(id)](#IERC6909Metadata-decimals-uint256-) -#### IERC6909 [!toc] +
+IERC6909 + - [balanceOf(owner, id)](#IERC6909-balanceOf-address-uint256-) - [allowance(owner, spender, id)](#IERC6909-allowance-address-address-uint256-) - [isOperator(owner, spender)](#IERC6909-isOperator-address-address-) @@ -1715,19 +1771,28 @@ Optional extension of [`IERC6909`](#IERC6909) that adds metadata functions. - [setOperator(spender, approved)](#IERC6909-setOperator-address-bool-) - [transfer(receiver, id, amount)](#IERC6909-transfer-address-uint256-uint256-) - [transferFrom(sender, receiver, id, amount)](#IERC6909-transferFrom-address-address-uint256-uint256-) -#### IERC165 [!toc] + +
+
+IERC165 + - [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) + +

Events

-#### IERC6909 [!toc] +
+IERC6909 + - [Approval(owner, spender, id, amount)](#IERC6909-Approval-address-address-uint256-uint256-) - [OperatorSet(owner, spender, approved)](#IERC6909-OperatorSet-address-address-bool-) - [Transfer(caller, sender, receiver, id, amount)](#IERC6909-Transfer-address-address-address-uint256-uint256-) -#### IERC165 [!toc] + +
@@ -1805,7 +1870,9 @@ Optional extension of [`IERC6909`](#IERC6909) that adds content URI functions.
- [contractURI()](#IERC6909ContentURI-contractURI--) - [tokenURI(id)](#IERC6909ContentURI-tokenURI-uint256-) -#### IERC6909 [!toc] +
+IERC6909 + - [balanceOf(owner, id)](#IERC6909-balanceOf-address-uint256-) - [allowance(owner, spender, id)](#IERC6909-allowance-address-address-uint256-) - [isOperator(owner, spender)](#IERC6909-isOperator-address-address-) @@ -1813,19 +1880,28 @@ Optional extension of [`IERC6909`](#IERC6909) that adds content URI functions. - [setOperator(spender, approved)](#IERC6909-setOperator-address-bool-) - [transfer(receiver, id, amount)](#IERC6909-transfer-address-uint256-uint256-) - [transferFrom(sender, receiver, id, amount)](#IERC6909-transferFrom-address-address-uint256-uint256-) -#### IERC165 [!toc] + +
+
+IERC165 + - [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) + +

Events

-#### IERC6909 [!toc] +
+IERC6909 + - [Approval(owner, spender, id, amount)](#IERC6909-Approval-address-address-uint256-uint256-) - [OperatorSet(owner, spender, approved)](#IERC6909-OperatorSet-address-address-bool-) - [Transfer(caller, sender, receiver, id, amount)](#IERC6909-Transfer-address-address-address-uint256-uint256-) -#### IERC165 [!toc] + +
@@ -1885,7 +1961,9 @@ Optional extension of [`IERC6909`](#IERC6909) that adds a token supply function.

Functions

- [totalSupply(id)](#IERC6909TokenSupply-totalSupply-uint256-) -#### IERC6909 [!toc] +
+IERC6909 + - [balanceOf(owner, id)](#IERC6909-balanceOf-address-uint256-) - [allowance(owner, spender, id)](#IERC6909-allowance-address-address-uint256-) - [isOperator(owner, spender)](#IERC6909-isOperator-address-address-) @@ -1893,19 +1971,28 @@ Optional extension of [`IERC6909`](#IERC6909) that adds a token supply function. - [setOperator(spender, approved)](#IERC6909-setOperator-address-bool-) - [transfer(receiver, id, amount)](#IERC6909-transfer-address-uint256-uint256-) - [transferFrom(sender, receiver, id, amount)](#IERC6909-transferFrom-address-address-uint256-uint256-) -#### IERC165 [!toc] + +
+
+IERC165 + - [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) + +

Events

-#### IERC6909 [!toc] +
+IERC6909 + - [Approval(owner, spender, id, amount)](#IERC6909-Approval-address-address-uint256-uint256-) - [OperatorSet(owner, spender, approved)](#IERC6909-OperatorSet-address-address-bool-) - [Transfer(caller, sender, receiver, id, amount)](#IERC6909-Transfer-address-address-address-uint256-uint256-) -#### IERC165 [!toc] + +
@@ -2369,15 +2456,23 @@ User operations are validated and executed by this contract.
- [handleOps(ops, beneficiary)](#IEntryPoint-handleOps-struct-PackedUserOperation---address-payable-) - [handleAggregatedOps(opsPerAggregator, beneficiary)](#IEntryPoint-handleAggregatedOps-struct-IEntryPoint-UserOpsPerAggregator---address-payable-) -#### IEntryPointStake [!toc] +
+IEntryPointStake + - [balanceOf(account)](#IEntryPointStake-balanceOf-address-) - [depositTo(account)](#IEntryPointStake-depositTo-address-) - [withdrawTo(withdrawAddress, withdrawAmount)](#IEntryPointStake-withdrawTo-address-payable-uint256-) - [addStake(unstakeDelaySec)](#IEntryPointStake-addStake-uint32-) - [unlockStake()](#IEntryPointStake-unlockStake--) - [withdrawStake(withdrawAddress)](#IEntryPointStake-withdrawStake-address-payable-) -#### IEntryPointNonces [!toc] + +
+
+IEntryPointNonces + - [getNonce(sender, key)](#IEntryPointNonces-getNonce-address-uint192-) + +
@@ -2386,8 +2481,6 @@ User operations are validated and executed by this contract.
- [FailedOp(opIndex, reason)](#IEntryPoint-FailedOp-uint256-string-) - [FailedOpWithRevert(opIndex, reason, inner)](#IEntryPoint-FailedOpWithRevert-uint256-string-bytes-) -#### IEntryPointStake [!toc] -#### IEntryPointNonces [!toc]
@@ -3279,10 +3372,14 @@ A module that implements logic to validate user operations and signatures.
- [validateUserOp(userOp, userOpHash)](#IERC7579Validator-validateUserOp-struct-PackedUserOperation-bytes32-) - [isValidSignatureWithSender(sender, hash, signature)](#IERC7579Validator-isValidSignatureWithSender-address-bytes32-bytes-) -#### IERC7579Module [!toc] +
+IERC7579Module + - [onInstall(data)](#IERC7579Module-onInstall-bytes-) - [onUninstall(data)](#IERC7579Module-onUninstall-bytes-) - [isModuleType(moduleTypeId)](#IERC7579Module-isModuleType-uint256-) + +
@@ -3346,10 +3443,14 @@ either individually or batched.
- [preCheck(msgSender, value, msgData)](#IERC7579Hook-preCheck-address-uint256-bytes-) - [postCheck(hookData)](#IERC7579Hook-postCheck-bytes-) -#### IERC7579Module [!toc] +
+IERC7579Module + - [onInstall(data)](#IERC7579Module-onInstall-bytes-) - [onUninstall(data)](#IERC7579Module-onUninstall-bytes-) - [isModuleType(moduleTypeId)](#IERC7579Module-isModuleType-uint256-) + +
@@ -3687,22 +3788,30 @@ Temporary Approval Extension for ERC-20 ([ERC-7674](https://github.com/ethereum/

Functions

- [temporaryApprove(spender, value)](#IERC7674-temporaryApprove-address-uint256-) -#### IERC20 [!toc] +
+IERC20 + - [totalSupply()](#IERC20-totalSupply--) - [balanceOf(account)](#IERC20-balanceOf-address-) - [transfer(to, value)](#IERC20-transfer-address-uint256-) - [allowance(owner, spender)](#IERC20-allowance-address-address-) - [approve(spender, value)](#IERC20-approve-address-uint256-) - [transferFrom(from, to, value)](#IERC20-transferFrom-address-address-uint256-) + +

Events

-#### IERC20 [!toc] +
+IERC20 + - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +
@@ -3910,8 +4019,12 @@ import "@openzeppelin/contracts/interfaces/draft-IERC7802.sol";
- [crosschainMint(_to, _amount)](#IERC7802-crosschainMint-address-uint256-) - [crosschainBurn(_from, _amount)](#IERC7802-crosschainBurn-address-uint256-) -#### IERC165 [!toc] +
+IERC165 + - [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) + +
@@ -3920,7 +4033,6 @@ import "@openzeppelin/contracts/interfaces/draft-IERC7802.sol";
- [CrosschainMint(to, amount, sender)](#IERC7802-CrosschainMint-address-uint256-address-) - [CrosschainBurn(from, amount, sender)](#IERC7802-CrosschainBurn-address-uint256-address-) -#### IERC165 [!toc]
@@ -4486,10 +4598,14 @@ import "@openzeppelin/contracts/interfaces/IERC2612.sol";

Functions

-#### IERC20Permit [!toc] +
+IERC20Permit + - [permit(owner, spender, value, deadline, v, r, s)](#IERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) - [nonces(owner)](#IERC20Permit-nonces-address-) - [DOMAIN_SEPARATOR()](#IERC20Permit-DOMAIN_SEPARATOR--) + +
diff --git a/content/contracts/5.x/api/metatx.mdx b/content/contracts/5.x/api/metatx.mdx index 966c6b41..72afa69a 100644 --- a/content/contracts/5.x/api/metatx.mdx +++ b/content/contracts/5.x/api/metatx.mdx @@ -230,17 +230,24 @@ used to execute arbitrary code. - [_recoverForwardRequestSigner(request)](#ERC2771Forwarder-_recoverForwardRequestSigner-struct-ERC2771Forwarder-ForwardRequestData-) - [_execute(request, requireValidRequest)](#ERC2771Forwarder-_execute-struct-ERC2771Forwarder-ForwardRequestData-bool-) - [_isTrustedByTarget(target)](#ERC2771Forwarder-_isTrustedByTarget-address-) -#### Nonces [!toc] +
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### EIP712 [!toc] + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] + +
@@ -248,10 +255,12 @@ used to execute arbitrary code.

Events

- [ExecutedForwardRequest(signer, nonce, success)](#ERC2771Forwarder-ExecutedForwardRequest-address-uint256-bool-) -#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] +
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) + +
@@ -263,10 +272,12 @@ used to execute arbitrary code. - [ERC2771ForwarderMismatchedValue(requestedValue, msgValue)](#ERC2771Forwarder-ERC2771ForwarderMismatchedValue-uint256-uint256-) - [ERC2771ForwarderExpiredRequest(deadline)](#ERC2771Forwarder-ERC2771ForwarderExpiredRequest-uint48-) - [ERC2771UntrustfulTarget(target, forwarder)](#ERC2771Forwarder-ERC2771UntrustfulTarget-address-address-) -#### Nonces [!toc] +
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
diff --git a/content/contracts/5.x/api/proxy.mdx b/content/contracts/5.x/api/proxy.mdx index 9be54050..7e79550b 100644 --- a/content/contracts/5.x/api/proxy.mdx +++ b/content/contracts/5.x/api/proxy.mdx @@ -497,10 +497,14 @@ implementation behind the proxy. - [constructor(implementation, _data)](#ERC1967Proxy-constructor-address-bytes-) - [_implementation()](#ERC1967Proxy-_implementation--) - [_unsafeAllowUninitialized()](#ERC1967Proxy-_unsafeAllowUninitialized--) -#### Proxy [!toc] +
+Proxy + - [_delegate(implementation)](#Proxy-_delegate-address-) - [_fallback()](#Proxy-_fallback--) - [fallback()](#Proxy-fallback--) + +
@@ -508,7 +512,6 @@ implementation behind the proxy.

Errors

- [ERC1967ProxyUninitialized()](#ERC1967Proxy-ERC1967ProxyUninitialized--) -#### Proxy [!toc]
@@ -982,10 +985,14 @@ an inconsistent state where the beacon storage slot does not match the beacon ad - [constructor(beacon, data)](#BeaconProxy-constructor-address-bytes-) - [_implementation()](#BeaconProxy-_implementation--) - [_getBeacon()](#BeaconProxy-_getBeacon--) -#### Proxy [!toc] +
+Proxy + - [_delegate(implementation)](#Proxy-_delegate-address-) - [_fallback()](#Proxy-_fallback--) - [fallback()](#Proxy-fallback--) + +
@@ -1118,29 +1125,41 @@ explanation of why you would want to use this see the documentation for [`Transp - [constructor(initialOwner)](#ProxyAdmin-constructor-address-) - [upgradeAndCall(proxy, implementation, data)](#ProxyAdmin-upgradeAndCall-contract-ITransparentUpgradeableProxy-address-bytes-) - [UPGRADE_INTERFACE_VERSION()](#ProxyAdmin-UPGRADE_INTERFACE_VERSION-string) -#### Ownable [!toc] +
+Ownable + - [owner()](#Ownable-owner--) - [_checkOwner()](#Ownable-_checkOwner--) - [renounceOwnership()](#Ownable-renounceOwnership--) - [transferOwnership(newOwner)](#Ownable-transferOwnership-address-) - [_transferOwnership(newOwner)](#Ownable-_transferOwnership-address-) + +

Events

-#### Ownable [!toc] +
+Ownable + - [OwnershipTransferred(previousOwner, newOwner)](#Ownable-OwnershipTransferred-address-address-) + +

Errors

-#### Ownable [!toc] +
+Ownable + - [OwnableUnauthorizedAccount(account)](#Ownable-OwnableUnauthorizedAccount-address-) - [OwnableInvalidOwner(owner)](#Ownable-OwnableInvalidOwner-address-) + +
@@ -1231,17 +1250,20 @@ include them in the ABI so this interface must be used to interact with it.

Functions

- [upgradeToAndCall(newImplementation, data)](#ITransparentUpgradeableProxy-upgradeToAndCall-address-bytes-) -#### IERC1967 [!toc]

Events

-#### IERC1967 [!toc] +
+IERC1967 + - [Upgraded(implementation)](#IERC1967-Upgraded-address-) - [AdminChanged(previousAdmin, newAdmin)](#IERC1967-AdminChanged-address-address-) - [BeaconUpgraded(beacon)](#IERC1967-BeaconUpgraded-address-) + +
@@ -1331,12 +1353,20 @@ could render the `upgradeToAndCall` function inaccessible, preventing upgradeabi - [constructor(_logic, initialOwner, _data)](#TransparentUpgradeableProxy-constructor-address-address-bytes-) - [_proxyAdmin()](#TransparentUpgradeableProxy-_proxyAdmin--) - [_fallback()](#TransparentUpgradeableProxy-_fallback--) -#### ERC1967Proxy [!toc] +
+ERC1967Proxy + - [_implementation()](#ERC1967Proxy-_implementation--) - [_unsafeAllowUninitialized()](#ERC1967Proxy-_unsafeAllowUninitialized--) -#### Proxy [!toc] + +
+
+Proxy + - [_delegate(implementation)](#Proxy-_delegate-address-) - [fallback()](#Proxy-fallback--) + +
@@ -1344,9 +1374,12 @@ could render the `upgradeToAndCall` function inaccessible, preventing upgradeabi

Errors

- [ProxyDeniedAdminAccess()](#TransparentUpgradeableProxy-ProxyDeniedAdminAccess--) -#### ERC1967Proxy [!toc] +
+ERC1967Proxy + - [ERC1967ProxyUninitialized()](#ERC1967Proxy-ERC1967ProxyUninitialized--) -#### Proxy [!toc] + +
@@ -1464,7 +1497,6 @@ The [`UUPSUpgradeable._authorizeUpgrade`](#UUPSUpgradeable-_authorizeUpgrade-add - [_checkNotDelegated()](#UUPSUpgradeable-_checkNotDelegated--) - [_authorizeUpgrade(newImplementation)](#UUPSUpgradeable-_authorizeUpgrade-address-) - [UPGRADE_INTERFACE_VERSION()](#UUPSUpgradeable-UPGRADE_INTERFACE_VERSION-string) -#### IERC1822Proxiable [!toc] @@ -1473,7 +1505,6 @@ The [`UUPSUpgradeable._authorizeUpgrade`](#UUPSUpgradeable-_authorizeUpgrade-add
- [UUPSUnauthorizedCallContext()](#UUPSUpgradeable-UUPSUnauthorizedCallContext--) - [UUPSUnsupportedProxiableUUID(slot)](#UUPSUpgradeable-UUPSUnsupportedProxiableUUID-bytes32-) -#### IERC1822Proxiable [!toc]
@@ -1707,13 +1738,16 @@ An owner is able to change the implementation the beacon points to, thus upgradi - [constructor(implementation_, initialOwner)](#UpgradeableBeacon-constructor-address-address-) - [implementation()](#UpgradeableBeacon-implementation--) - [upgradeTo(newImplementation)](#UpgradeableBeacon-upgradeTo-address-) -#### Ownable [!toc] +
+Ownable + - [owner()](#Ownable-owner--) - [_checkOwner()](#Ownable-_checkOwner--) - [renounceOwnership()](#Ownable-renounceOwnership--) - [transferOwnership(newOwner)](#Ownable-transferOwnership-address-) - [_transferOwnership(newOwner)](#Ownable-_transferOwnership-address-) -#### IBeacon [!toc] + +
@@ -1721,9 +1755,12 @@ An owner is able to change the implementation the beacon points to, thus upgradi

Events

- [Upgraded(implementation)](#UpgradeableBeacon-Upgraded-address-) -#### Ownable [!toc] +
+Ownable + - [OwnershipTransferred(previousOwner, newOwner)](#Ownable-OwnershipTransferred-address-address-) -#### IBeacon [!toc] + +
@@ -1731,10 +1768,13 @@ An owner is able to change the implementation the beacon points to, thus upgradi

Errors

- [BeaconInvalidImplementation(implementation)](#UpgradeableBeacon-BeaconInvalidImplementation-address-) -#### Ownable [!toc] +
+Ownable + - [OwnableUnauthorizedAccount(account)](#Ownable-OwnableUnauthorizedAccount-address-) - [OwnableInvalidOwner(owner)](#Ownable-OwnableInvalidOwner-address-) -#### IBeacon [!toc] + +
diff --git a/content/contracts/5.x/api/token/ERC1155.mdx b/content/contracts/5.x/api/token/ERC1155.mdx index acdcbe2b..d9dfdbbe 100644 --- a/content/contracts/5.x/api/token/ERC1155.mdx +++ b/content/contracts/5.x/api/token/ERC1155.mdx @@ -91,33 +91,30 @@ Originally based on code by Enjin: https://github.com/enjin/erc-1155 - [_burn(from, id, value)](#ERC1155-_burn-address-uint256-uint256-) - [_burnBatch(from, ids, values)](#ERC1155-_burnBatch-address-uint256---uint256---) - [_setApprovalForAll(owner, operator, approved)](#ERC1155-_setApprovalForAll-address-address-bool-) -#### IERC1155Errors [!toc] -#### IERC1155MetadataURI [!toc] -#### IERC1155 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc]

Events

-#### IERC1155Errors [!toc] -#### IERC1155MetadataURI [!toc] -#### IERC1155 [!toc] +
+IERC1155 + - [TransferSingle(operator, from, to, id, value)](#IERC1155-TransferSingle-address-address-address-uint256-uint256-) - [TransferBatch(operator, from, to, ids, values)](#IERC1155-TransferBatch-address-address-address-uint256---uint256---) - [ApprovalForAll(account, operator, approved)](#IERC1155-ApprovalForAll-address-address-bool-) - [URI(value, id)](#IERC1155-URI-string-uint256-) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### IERC1155Errors [!toc] +
+IERC1155Errors + - [ERC1155InsufficientBalance(sender, balance, needed, tokenId)](#IERC1155Errors-ERC1155InsufficientBalance-address-uint256-uint256-uint256-) - [ERC1155InvalidSender(sender)](#IERC1155Errors-ERC1155InvalidSender-address-) - [ERC1155InvalidReceiver(receiver)](#IERC1155Errors-ERC1155InvalidReceiver-address-) @@ -125,10 +122,8 @@ Originally based on code by Enjin: https://github.com/enjin/erc-1155 - [ERC1155InvalidApprover(approver)](#IERC1155Errors-ERC1155InvalidApprover-address-) - [ERC1155InvalidOperator(operator)](#IERC1155Errors-ERC1155InvalidOperator-address-) - [ERC1155InvalidArrayLength(idsLength, valuesLength)](#IERC1155Errors-ERC1155InvalidArrayLength-uint256-uint256-) -#### IERC1155MetadataURI [!toc] -#### IERC1155 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -679,8 +674,12 @@ Required interface of an ERC-1155 compliant contract, as defined in the - [isApprovedForAll(account, operator)](#IERC1155-isApprovedForAll-address-address-) - [safeTransferFrom(from, to, id, value, data)](#IERC1155-safeTransferFrom-address-address-uint256-uint256-bytes-) - [safeBatchTransferFrom(from, to, ids, values, data)](#IERC1155-safeBatchTransferFrom-address-address-uint256---uint256---bytes-) -#### IERC165 [!toc] +
+IERC165 + - [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) + +
@@ -691,7 +690,6 @@ Required interface of an ERC-1155 compliant contract, as defined in the - [TransferBatch(operator, from, to, ids, values)](#IERC1155-TransferBatch-address-address-address-uint256---uint256---) - [ApprovalForAll(account, operator, approved)](#IERC1155-ApprovalForAll-address-address-bool-) - [URI(value, id)](#IERC1155-URI-string-uint256-) -#### IERC165 [!toc] @@ -940,8 +938,12 @@ ERC-1155 token transfers.
- [onERC1155Received(operator, from, id, value, data)](#IERC1155Receiver-onERC1155Received-address-address-uint256-uint256-bytes-) - [onERC1155BatchReceived(operator, from, ids, values, data)](#IERC1155Receiver-onERC1155BatchReceived-address-address-uint256---uint256---bytes-) -#### IERC165 [!toc] +
+IERC165 + - [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) + +
@@ -1018,7 +1020,9 @@ own tokens and those that they have been approved to use.
- [burn(account, id, value)](#ERC1155Burnable-burn-address-uint256-uint256-) - [burnBatch(account, ids, values)](#ERC1155Burnable-burnBatch-address-uint256---uint256---) -#### ERC1155 [!toc] +
+ERC1155 + - [supportsInterface(interfaceId)](#ERC1155-supportsInterface-bytes4-) - [uri()](#ERC1155-uri-uint256-) - [balanceOf(account, id)](#ERC1155-balanceOf-address-uint256-) @@ -1039,35 +1043,32 @@ own tokens and those that they have been approved to use. - [_burn(from, id, value)](#ERC1155-_burn-address-uint256-uint256-) - [_burnBatch(from, ids, values)](#ERC1155-_burnBatch-address-uint256---uint256---) - [_setApprovalForAll(owner, operator, approved)](#ERC1155-_setApprovalForAll-address-address-bool-) -#### IERC1155Errors [!toc] -#### IERC1155MetadataURI [!toc] -#### IERC1155 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Events

-#### ERC1155 [!toc] -#### IERC1155Errors [!toc] -#### IERC1155MetadataURI [!toc] -#### IERC1155 [!toc] +
+IERC1155 + - [TransferSingle(operator, from, to, id, value)](#IERC1155-TransferSingle-address-address-address-uint256-uint256-) - [TransferBatch(operator, from, to, ids, values)](#IERC1155-TransferBatch-address-address-address-uint256---uint256---) - [ApprovalForAll(account, operator, approved)](#IERC1155-ApprovalForAll-address-address-bool-) - [URI(value, id)](#IERC1155-URI-string-uint256-) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### ERC1155 [!toc] -#### IERC1155Errors [!toc] +
+IERC1155Errors + - [ERC1155InsufficientBalance(sender, balance, needed, tokenId)](#IERC1155Errors-ERC1155InsufficientBalance-address-uint256-uint256-uint256-) - [ERC1155InvalidSender(sender)](#IERC1155Errors-ERC1155InvalidSender-address-) - [ERC1155InvalidReceiver(receiver)](#IERC1155Errors-ERC1155InvalidReceiver-address-) @@ -1075,10 +1076,8 @@ own tokens and those that they have been approved to use. - [ERC1155InvalidApprover(approver)](#IERC1155Errors-ERC1155InvalidApprover-address-) - [ERC1155InvalidOperator(operator)](#IERC1155Errors-ERC1155InvalidOperator-address-) - [ERC1155InvalidArrayLength(idsLength, valuesLength)](#IERC1155Errors-ERC1155InvalidArrayLength-uint256-uint256-) -#### IERC1155MetadataURI [!toc] -#### IERC1155 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -1141,18 +1140,31 @@ This extension makes the token compatible with: - [crosschainTransferFrom(from, to, ids, values)](#ERC1155Crosschain-crosschainTransferFrom-address-bytes-uint256---uint256---) - [_onSend(from, ids, values)](#ERC1155Crosschain-_onSend-address-uint256---uint256---) - [_onReceive(to, ids, values)](#ERC1155Crosschain-_onReceive-address-uint256---uint256---) -#### BridgeMultiToken [!toc] +
+BridgeMultiToken + - [_crosschainTransfer(from, to, ids, values)](#BridgeMultiToken-_crosschainTransfer-address-bytes-uint256---uint256---) - [_processMessage(, receiveId, , payload)](#BridgeMultiToken-_processMessage-address-bytes32-bytes-bytes-) -#### CrosschainLinked [!toc] + +
+
+CrosschainLinked + - [getLink(chain)](#CrosschainLinked-getLink-bytes-) - [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) - [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) - [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) -#### ERC7786Recipient [!toc] + +
+
+ERC7786Recipient + - [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) -#### IERC7786Recipient [!toc] -#### ERC1155 [!toc] + +
+
+ERC1155 + - [supportsInterface(interfaceId)](#ERC1155-supportsInterface-bytes4-) - [uri()](#ERC1155-uri-uint256-) - [balanceOf(account, id)](#ERC1155-balanceOf-address-uint256-) @@ -1173,48 +1185,57 @@ This extension makes the token compatible with: - [_burn(from, id, value)](#ERC1155-_burn-address-uint256-uint256-) - [_burnBatch(from, ids, values)](#ERC1155-_burnBatch-address-uint256---uint256---) - [_setApprovalForAll(owner, operator, approved)](#ERC1155-_setApprovalForAll-address-address-bool-) -#### IERC1155Errors [!toc] -#### IERC1155MetadataURI [!toc] -#### IERC1155 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Events

-#### BridgeMultiToken [!toc] +
+BridgeMultiToken + - [CrosschainMultiTokenTransferSent(sendId, from, to, ids, values)](#BridgeMultiToken-CrosschainMultiTokenTransferSent-bytes32-address-bytes-uint256---uint256---) - [CrosschainMultiTokenTransferReceived(receiveId, from, to, ids, values)](#BridgeMultiToken-CrosschainMultiTokenTransferReceived-bytes32-bytes-address-uint256---uint256---) -#### CrosschainLinked [!toc] + +
+
+CrosschainLinked + - [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) -#### ERC7786Recipient [!toc] -#### IERC7786Recipient [!toc] -#### ERC1155 [!toc] -#### IERC1155Errors [!toc] -#### IERC1155MetadataURI [!toc] -#### IERC1155 [!toc] + +
+
+IERC1155 + - [TransferSingle(operator, from, to, id, value)](#IERC1155-TransferSingle-address-address-address-uint256-uint256-) - [TransferBatch(operator, from, to, ids, values)](#IERC1155-TransferBatch-address-address-address-uint256---uint256---) - [ApprovalForAll(account, operator, approved)](#IERC1155-ApprovalForAll-address-address-bool-) - [URI(value, id)](#IERC1155-URI-string-uint256-) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### BridgeMultiToken [!toc] -#### CrosschainLinked [!toc] +
+CrosschainLinked + - [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) -#### ERC7786Recipient [!toc] + +
+
+ERC7786Recipient + - [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) -#### IERC7786Recipient [!toc] -#### ERC1155 [!toc] -#### IERC1155Errors [!toc] + +
+
+IERC1155Errors + - [ERC1155InsufficientBalance(sender, balance, needed, tokenId)](#IERC1155Errors-ERC1155InsufficientBalance-address-uint256-uint256-uint256-) - [ERC1155InvalidSender(sender)](#IERC1155Errors-ERC1155InvalidSender-address-) - [ERC1155InvalidReceiver(receiver)](#IERC1155Errors-ERC1155InvalidReceiver-address-) @@ -1222,10 +1243,8 @@ This extension makes the token compatible with: - [ERC1155InvalidApprover(approver)](#IERC1155Errors-ERC1155InvalidApprover-address-) - [ERC1155InvalidOperator(operator)](#IERC1155Errors-ERC1155InvalidOperator-address-) - [ERC1155InvalidArrayLength(idsLength, valuesLength)](#IERC1155Errors-ERC1155InvalidArrayLength-uint256-uint256-) -#### IERC1155MetadataURI [!toc] -#### IERC1155 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -1331,13 +1350,19 @@ make the contract pause mechanism of the contract unreachable, and thus unusable

Functions

- [_update(from, to, ids, values)](#ERC1155Pausable-_update-address-address-uint256---uint256---) -#### Pausable [!toc] +
+Pausable + - [paused()](#Pausable-paused--) - [_requireNotPaused()](#Pausable-_requireNotPaused--) - [_requirePaused()](#Pausable-_requirePaused--) - [_pause()](#Pausable-_pause--) - [_unpause()](#Pausable-_unpause--) -#### ERC1155 [!toc] + +
+
+ERC1155 + - [supportsInterface(interfaceId)](#ERC1155-supportsInterface-bytes4-) - [uri()](#ERC1155-uri-uint256-) - [balanceOf(account, id)](#ERC1155-balanceOf-address-uint256-) @@ -1357,41 +1382,46 @@ make the contract pause mechanism of the contract unreachable, and thus unusable - [_burn(from, id, value)](#ERC1155-_burn-address-uint256-uint256-) - [_burnBatch(from, ids, values)](#ERC1155-_burnBatch-address-uint256---uint256---) - [_setApprovalForAll(owner, operator, approved)](#ERC1155-_setApprovalForAll-address-address-bool-) -#### IERC1155Errors [!toc] -#### IERC1155MetadataURI [!toc] -#### IERC1155 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Events

-#### Pausable [!toc] +
+Pausable + - [Paused(account)](#Pausable-Paused-address-) - [Unpaused(account)](#Pausable-Unpaused-address-) -#### ERC1155 [!toc] -#### IERC1155Errors [!toc] -#### IERC1155MetadataURI [!toc] -#### IERC1155 [!toc] + +
+
+IERC1155 + - [TransferSingle(operator, from, to, id, value)](#IERC1155-TransferSingle-address-address-address-uint256-uint256-) - [TransferBatch(operator, from, to, ids, values)](#IERC1155-TransferBatch-address-address-address-uint256---uint256---) - [ApprovalForAll(account, operator, approved)](#IERC1155-ApprovalForAll-address-address-bool-) - [URI(value, id)](#IERC1155-URI-string-uint256-) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### Pausable [!toc] +
+Pausable + - [EnforcedPause()](#Pausable-EnforcedPause--) - [ExpectedPause()](#Pausable-ExpectedPause--) -#### ERC1155 [!toc] -#### IERC1155Errors [!toc] + +
+
+IERC1155Errors + - [ERC1155InsufficientBalance(sender, balance, needed, tokenId)](#IERC1155Errors-ERC1155InsufficientBalance-address-uint256-uint256-uint256-) - [ERC1155InvalidSender(sender)](#IERC1155Errors-ERC1155InvalidSender-address-) - [ERC1155InvalidReceiver(receiver)](#IERC1155Errors-ERC1155InvalidReceiver-address-) @@ -1399,10 +1429,8 @@ make the contract pause mechanism of the contract unreachable, and thus unusable - [ERC1155InvalidApprover(approver)](#IERC1155Errors-ERC1155InvalidApprover-address-) - [ERC1155InvalidOperator(operator)](#IERC1155Errors-ERC1155InvalidOperator-address-) - [ERC1155InvalidArrayLength(idsLength, valuesLength)](#IERC1155Errors-ERC1155InvalidArrayLength-uint256-uint256-) -#### IERC1155MetadataURI [!toc] -#### IERC1155 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -1466,7 +1494,9 @@ This extension should not be added in an upgrade to an already deployed contract - [totalSupply()](#ERC1155Supply-totalSupply--) - [exists(id)](#ERC1155Supply-exists-uint256-) - [_update(from, to, ids, values)](#ERC1155Supply-_update-address-address-uint256---uint256---) -#### ERC1155 [!toc] +
+ERC1155 + - [supportsInterface(interfaceId)](#ERC1155-supportsInterface-bytes4-) - [uri()](#ERC1155-uri-uint256-) - [balanceOf(account, id)](#ERC1155-balanceOf-address-uint256-) @@ -1486,35 +1516,32 @@ This extension should not be added in an upgrade to an already deployed contract - [_burn(from, id, value)](#ERC1155-_burn-address-uint256-uint256-) - [_burnBatch(from, ids, values)](#ERC1155-_burnBatch-address-uint256---uint256---) - [_setApprovalForAll(owner, operator, approved)](#ERC1155-_setApprovalForAll-address-address-bool-) -#### IERC1155Errors [!toc] -#### IERC1155MetadataURI [!toc] -#### IERC1155 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Events

-#### ERC1155 [!toc] -#### IERC1155Errors [!toc] -#### IERC1155MetadataURI [!toc] -#### IERC1155 [!toc] +
+IERC1155 + - [TransferSingle(operator, from, to, id, value)](#IERC1155-TransferSingle-address-address-address-uint256-uint256-) - [TransferBatch(operator, from, to, ids, values)](#IERC1155-TransferBatch-address-address-address-uint256---uint256---) - [ApprovalForAll(account, operator, approved)](#IERC1155-ApprovalForAll-address-address-bool-) - [URI(value, id)](#IERC1155-URI-string-uint256-) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### ERC1155 [!toc] -#### IERC1155Errors [!toc] +
+IERC1155Errors + - [ERC1155InsufficientBalance(sender, balance, needed, tokenId)](#IERC1155Errors-ERC1155InsufficientBalance-address-uint256-uint256-uint256-) - [ERC1155InvalidSender(sender)](#IERC1155Errors-ERC1155InvalidSender-address-) - [ERC1155InvalidReceiver(receiver)](#IERC1155Errors-ERC1155InvalidReceiver-address-) @@ -1522,10 +1549,8 @@ This extension should not be added in an upgrade to an already deployed contract - [ERC1155InvalidApprover(approver)](#IERC1155Errors-ERC1155InvalidApprover-address-) - [ERC1155InvalidOperator(operator)](#IERC1155Errors-ERC1155InvalidOperator-address-) - [ERC1155InvalidArrayLength(idsLength, valuesLength)](#IERC1155Errors-ERC1155InvalidArrayLength-uint256-uint256-) -#### IERC1155MetadataURI [!toc] -#### IERC1155 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -1635,7 +1660,9 @@ Inspired by the [`ERC721URIStorage`](/contracts/5.x/api/token/ERC721#ERC721URISt - [uri(tokenId)](#ERC1155URIStorage-uri-uint256-) - [_setURI(tokenId, tokenURI)](#ERC1155URIStorage-_setURI-uint256-string-) - [_setBaseURI(baseURI)](#ERC1155URIStorage-_setBaseURI-string-) -#### ERC1155 [!toc] +
+ERC1155 + - [supportsInterface(interfaceId)](#ERC1155-supportsInterface-bytes4-) - [balanceOf(account, id)](#ERC1155-balanceOf-address-uint256-) - [balanceOfBatch(accounts, ids)](#ERC1155-balanceOfBatch-address---uint256---) @@ -1655,35 +1682,32 @@ Inspired by the [`ERC721URIStorage`](/contracts/5.x/api/token/ERC721#ERC721URISt - [_burn(from, id, value)](#ERC1155-_burn-address-uint256-uint256-) - [_burnBatch(from, ids, values)](#ERC1155-_burnBatch-address-uint256---uint256---) - [_setApprovalForAll(owner, operator, approved)](#ERC1155-_setApprovalForAll-address-address-bool-) -#### IERC1155Errors [!toc] -#### IERC1155MetadataURI [!toc] -#### IERC1155 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Events

-#### ERC1155 [!toc] -#### IERC1155Errors [!toc] -#### IERC1155MetadataURI [!toc] -#### IERC1155 [!toc] +
+IERC1155 + - [TransferSingle(operator, from, to, id, value)](#IERC1155-TransferSingle-address-address-address-uint256-uint256-) - [TransferBatch(operator, from, to, ids, values)](#IERC1155-TransferBatch-address-address-address-uint256---uint256---) - [ApprovalForAll(account, operator, approved)](#IERC1155-ApprovalForAll-address-address-bool-) - [URI(value, id)](#IERC1155-URI-string-uint256-) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### ERC1155 [!toc] -#### IERC1155Errors [!toc] +
+IERC1155Errors + - [ERC1155InsufficientBalance(sender, balance, needed, tokenId)](#IERC1155Errors-ERC1155InsufficientBalance-address-uint256-uint256-uint256-) - [ERC1155InvalidSender(sender)](#IERC1155Errors-ERC1155InvalidSender-address-) - [ERC1155InvalidReceiver(receiver)](#IERC1155Errors-ERC1155InvalidReceiver-address-) @@ -1691,10 +1715,8 @@ Inspired by the [`ERC721URIStorage`](/contracts/5.x/api/token/ERC721#ERC721URISt - [ERC1155InvalidApprover(approver)](#IERC1155Errors-ERC1155InvalidApprover-address-) - [ERC1155InvalidOperator(operator)](#IERC1155Errors-ERC1155InvalidOperator-address-) - [ERC1155InvalidArrayLength(idsLength, valuesLength)](#IERC1155Errors-ERC1155InvalidArrayLength-uint256-uint256-) -#### IERC1155MetadataURI [!toc] -#### IERC1155 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -1787,27 +1809,38 @@ in the [ERC](https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions).

Functions

- [uri(id)](#IERC1155MetadataURI-uri-uint256-) -#### IERC1155 [!toc] +
+IERC1155 + - [balanceOf(account, id)](#IERC1155-balanceOf-address-uint256-) - [balanceOfBatch(accounts, ids)](#IERC1155-balanceOfBatch-address---uint256---) - [setApprovalForAll(operator, approved)](#IERC1155-setApprovalForAll-address-bool-) - [isApprovedForAll(account, operator)](#IERC1155-isApprovedForAll-address-address-) - [safeTransferFrom(from, to, id, value, data)](#IERC1155-safeTransferFrom-address-address-uint256-uint256-bytes-) - [safeBatchTransferFrom(from, to, ids, values, data)](#IERC1155-safeBatchTransferFrom-address-address-uint256---uint256---bytes-) -#### IERC165 [!toc] + +
+
+IERC165 + - [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) + +

Events

-#### IERC1155 [!toc] +
+IERC1155 + - [TransferSingle(operator, from, to, id, value)](#IERC1155-TransferSingle-address-address-address-uint256-uint256-) - [TransferBatch(operator, from, to, ids, values)](#IERC1155-TransferBatch-address-address-address-uint256---uint256---) - [ApprovalForAll(account, operator, approved)](#IERC1155-ApprovalForAll-address-address-bool-) - [URI(value, id)](#IERC1155-URI-string-uint256-) -#### IERC165 [!toc] + +
@@ -1862,9 +1895,6 @@ stuck. - [supportsInterface(interfaceId)](#ERC1155Holder-supportsInterface-bytes4-) - [onERC1155Received(, , , , )](#ERC1155Holder-onERC1155Received-address-address-uint256-uint256-bytes-) - [onERC1155BatchReceived(, , , , )](#ERC1155Holder-onERC1155BatchReceived-address-address-uint256---uint256---bytes-) -#### IERC1155Receiver [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] diff --git a/content/contracts/5.x/api/token/ERC20.mdx b/content/contracts/5.x/api/token/ERC20.mdx index 272a596c..92bb6555 100644 --- a/content/contracts/5.x/api/token/ERC20.mdx +++ b/content/contracts/5.x/api/token/ERC20.mdx @@ -139,35 +139,36 @@ applications. - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc]

Events

-#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] +
+IERC20 + - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +

Errors

-#### IERC20Errors [!toc] +
+IERC20Errors + - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) - [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) - [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) - [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) - [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) - [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
@@ -808,19 +809,32 @@ that: - [crosschainTransferFrom(from, to, amount)](#ERC20Crosschain-crosschainTransferFrom-address-bytes-uint256-) - [_onSend(from, amount)](#ERC20Crosschain-_onSend-address-uint256-) - [_onReceive(to, amount)](#ERC20Crosschain-_onReceive-address-uint256-) -#### BridgeFungible [!toc] +
+BridgeFungible + - [crosschainTransfer(to, amount)](#BridgeFungible-crosschainTransfer-bytes-uint256-) - [_crosschainTransfer(from, to, amount)](#BridgeFungible-_crosschainTransfer-address-bytes-uint256-) - [_processMessage(, receiveId, , payload)](#BridgeFungible-_processMessage-address-bytes32-bytes-bytes-) -#### CrosschainLinked [!toc] + +
+
+CrosschainLinked + - [getLink(chain)](#CrosschainLinked-getLink-bytes-) - [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) - [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) - [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) -#### ERC7786Recipient [!toc] + +
+
+ERC7786Recipient + - [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) -#### IERC7786Recipient [!toc] -#### ERC20 [!toc] + +
+
+ERC20 + - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) - [decimals()](#ERC20-decimals--) @@ -837,50 +851,63 @@ that: - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +

Events

-#### BridgeFungible [!toc] +
+BridgeFungible + - [CrosschainFungibleTransferSent(sendId, from, to, amount)](#BridgeFungible-CrosschainFungibleTransferSent-bytes32-address-bytes-uint256-) - [CrosschainFungibleTransferReceived(receiveId, from, to, amount)](#BridgeFungible-CrosschainFungibleTransferReceived-bytes32-bytes-address-uint256-) -#### CrosschainLinked [!toc] + +
+
+CrosschainLinked + - [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) -#### ERC7786Recipient [!toc] -#### IERC7786Recipient [!toc] -#### ERC20 [!toc] -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
+
+IERC20 + - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +

Errors

-#### BridgeFungible [!toc] -#### CrosschainLinked [!toc] +
+CrosschainLinked + - [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) -#### ERC7786Recipient [!toc] + +
+
+ERC7786Recipient + - [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) -#### IERC7786Recipient [!toc] -#### ERC20 [!toc] -#### IERC20Errors [!toc] + +
+
+IERC20Errors + - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) - [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) - [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) - [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) - [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) - [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
@@ -971,8 +998,9 @@ overriding [`ERC20FlashMint.maxFlashLoan`](#ERC20FlashMint-maxFlashLoan-address- - [_flashFee(, )](#ERC20FlashMint-_flashFee-address-uint256-) - [_flashFeeReceiver()](#ERC20FlashMint-_flashFeeReceiver--) - [flashLoan(receiver, token, value, data)](#ERC20FlashMint-flashLoan-contract-IERC3156FlashBorrower-address-uint256-bytes-) -#### IERC3156FlashLender [!toc] -#### ERC20 [!toc] +
+ERC20 + - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) - [decimals()](#ERC20-decimals--) @@ -989,22 +1017,21 @@ overriding [`ERC20FlashMint.maxFlashLoan`](#ERC20FlashMint-maxFlashLoan-address- - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +

Events

-#### IERC3156FlashLender [!toc] -#### ERC20 [!toc] -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] +
+IERC20 + - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +
@@ -1014,17 +1041,17 @@ overriding [`ERC20FlashMint.maxFlashLoan`](#ERC20FlashMint-maxFlashLoan-address- - [ERC3156UnsupportedToken(token)](#ERC20FlashMint-ERC3156UnsupportedToken-address-) - [ERC3156ExceededMaxLoan(maxLoan)](#ERC20FlashMint-ERC3156ExceededMaxLoan-uint256-) - [ERC3156InvalidReceiver(receiver)](#ERC20FlashMint-ERC3156InvalidReceiver-address-) -#### IERC3156FlashLender [!toc] -#### ERC20 [!toc] -#### IERC20Errors [!toc] +
+IERC20Errors + - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) - [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) - [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) - [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) - [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) - [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
@@ -1210,18 +1237,26 @@ need to send a transaction, and thus is not required to hold Ether at all. - [permit(owner, spender, value, deadline, v, r, s)](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) - [nonces(owner)](#ERC20Permit-nonces-address-) - [DOMAIN_SEPARATOR()](#ERC20Permit-DOMAIN_SEPARATOR--) -#### Nonces [!toc] +
+Nonces + - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### EIP712 [!toc] + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### IERC20Permit [!toc] -#### ERC20 [!toc] + +
+
+ERC20 + - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) - [decimals()](#ERC20-decimals--) @@ -1238,26 +1273,27 @@ need to send a transaction, and thus is not required to hold Ether at all. - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +

Events

-#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] +
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### IERC20Permit [!toc] -#### ERC20 [!toc] -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
+
+IERC20 + - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +
@@ -1266,21 +1302,23 @@ need to send a transaction, and thus is not required to hold Ether at all.
- [ERC2612ExpiredSignature(deadline)](#ERC20Permit-ERC2612ExpiredSignature-uint256-) - [ERC2612InvalidSigner(signer, owner)](#ERC20Permit-ERC2612InvalidSigner-address-address-) -#### Nonces [!toc] +
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### IERC20Permit [!toc] -#### ERC20 [!toc] -#### IERC20Errors [!toc] + +
+
+IERC20Errors + - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) - [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) - [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) - [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) - [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) - [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
@@ -1454,7 +1492,9 @@ requires users to delegate to themselves in order to activate checkpoints and ha - [_getVotingUnits(account)](#ERC20Votes-_getVotingUnits-address-) - [numCheckpoints(account)](#ERC20Votes-numCheckpoints-address-) - [checkpoints(account, pos)](#ERC20Votes-checkpoints-address-uint32-) -#### Votes [!toc] +
+Votes + - [clock()](#Votes-clock--) - [CLOCK_MODE()](#Votes-CLOCK_MODE--) - [_validateTimepoint(timepoint)](#Votes-_validateTimepoint-uint256-) @@ -1470,21 +1510,29 @@ requires users to delegate to themselves in order to activate checkpoints and ha - [_moveDelegateVotes(from, to, amount)](#Votes-_moveDelegateVotes-address-address-uint256-) - [_numCheckpoints(account)](#Votes-_numCheckpoints-address-) - [_checkpoints(account, pos)](#Votes-_checkpoints-address-uint32-) -#### IERC5805 [!toc] -#### IVotes [!toc] -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### EIP712 [!toc] + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### ERC20 [!toc] + +
+
+ERC20 + - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) - [decimals()](#ERC20-decimals--) @@ -1500,31 +1548,34 @@ requires users to delegate to themselves in order to activate checkpoints and ha - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +

Events

-#### Votes [!toc] -#### IERC5805 [!toc] -#### IVotes [!toc] +
+IVotes + - [DelegateChanged(delegator, fromDelegate, toDelegate)](#IVotes-DelegateChanged-address-address-address-) - [DelegateVotesChanged(delegate, previousVotes, newVotes)](#IVotes-DelegateVotesChanged-address-uint256-uint256-) -#### IERC6372 [!toc] -#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
+
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### ERC20 [!toc] -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
+
+IERC20 + - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +
@@ -1532,27 +1583,36 @@ requires users to delegate to themselves in order to activate checkpoints and ha

Errors

- [ERC20ExceededSafeSupply(increasedSupply, cap)](#ERC20Votes-ERC20ExceededSafeSupply-uint256-uint256-) -#### Votes [!toc] +
+Votes + - [ERC6372InconsistentClock()](#Votes-ERC6372InconsistentClock--) - [ERC5805FutureLookup(timepoint, clock)](#Votes-ERC5805FutureLookup-uint256-uint48-) -#### IERC5805 [!toc] -#### IVotes [!toc] + +
+
+IVotes + - [VotesExpiredSignature(expiry)](#IVotes-VotesExpiredSignature-uint256-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### ERC20 [!toc] -#### IERC20Errors [!toc] + +
+
+IERC20Errors + - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) - [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) - [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) - [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) - [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) - [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
@@ -1710,7 +1770,9 @@ for recovering value accrued to the wrapper. - [depositFor(account, value)](#ERC20Wrapper-depositFor-address-uint256-) - [withdrawTo(account, value)](#ERC20Wrapper-withdrawTo-address-uint256-) - [_recover(account)](#ERC20Wrapper-_recover-address-) -#### ERC20 [!toc] +
+ERC20 + - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) - [totalSupply()](#ERC20-totalSupply--) @@ -1726,21 +1788,21 @@ for recovering value accrued to the wrapper. - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +

Events

-#### ERC20 [!toc] -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] +
+IERC20 + - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +
@@ -1748,16 +1810,17 @@ for recovering value accrued to the wrapper.

Errors

- [ERC20InvalidUnderlying(token)](#ERC20Wrapper-ERC20InvalidUnderlying-address-) -#### ERC20 [!toc] -#### IERC20Errors [!toc] +
+IERC20Errors + - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) - [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) - [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) - [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) - [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) - [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
@@ -1972,8 +2035,9 @@ always return successfully. - [_transferIn(from, assets)](#ERC4626-_transferIn-address-uint256-) - [_transferOut(to, assets)](#ERC4626-_transferOut-address-uint256-) - [_decimalsOffset()](#ERC4626-_decimalsOffset--) -#### IERC4626 [!toc] -#### ERC20 [!toc] +
+ERC20 + - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) - [totalSupply()](#ERC20-totalSupply--) @@ -1989,24 +2053,28 @@ always return successfully. - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +

Events

-#### IERC4626 [!toc] +
+IERC4626 + - [Deposit(sender, owner, assets, shares)](#IERC4626-Deposit-address-address-uint256-uint256-) - [Withdraw(sender, receiver, owner, assets, shares)](#IERC4626-Withdraw-address-address-address-uint256-uint256-) -#### ERC20 [!toc] -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
+
+IERC20 + - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +
@@ -2017,17 +2085,17 @@ always return successfully. - [ERC4626ExceededMaxMint(receiver, shares, max)](#ERC4626-ERC4626ExceededMaxMint-address-uint256-uint256-) - [ERC4626ExceededMaxWithdraw(owner, assets, max)](#ERC4626-ERC4626ExceededMaxWithdraw-address-uint256-uint256-) - [ERC4626ExceededMaxRedeem(owner, shares, max)](#ERC4626-ERC4626ExceededMaxRedeem-address-uint256-uint256-) -#### IERC4626 [!toc] -#### ERC20 [!toc] -#### IERC20Errors [!toc] +
+IERC20Errors + - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) - [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) - [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) - [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) - [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) - [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
@@ -2695,22 +2763,30 @@ Interface for the optional metadata functions from the ERC-20 standard. - [name()](#IERC20Metadata-name--) - [symbol()](#IERC20Metadata-symbol--) - [decimals()](#IERC20Metadata-decimals--) -#### IERC20 [!toc] +
+IERC20 + - [totalSupply()](#IERC20-totalSupply--) - [balanceOf(account)](#IERC20-balanceOf-address-) - [transfer(to, value)](#IERC20-transfer-address-uint256-) - [allowance(owner, spender)](#IERC20-allowance-address-address-) - [approve(spender, value)](#IERC20-approve-address-uint256-) - [transferFrom(from, to, value)](#IERC20-transferFrom-address-address-uint256-) + +

Events

-#### IERC20 [!toc] +
+IERC20 + - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +
@@ -2936,8 +3012,9 @@ _Available since v5.1._ - [temporaryApprove(spender, value)](#ERC20TemporaryApproval-temporaryApprove-address-uint256-) - [_temporaryApprove(owner, spender, value)](#ERC20TemporaryApproval-_temporaryApprove-address-address-uint256-) - [_spendAllowance(owner, spender, value)](#ERC20TemporaryApproval-_spendAllowance-address-address-uint256-) -#### IERC7674 [!toc] -#### ERC20 [!toc] +
+ERC20 + - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) - [decimals()](#ERC20-decimals--) @@ -2952,39 +3029,38 @@ _Available since v5.1._ - [_burn(account, value)](#ERC20-_burn-address-uint256-) - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +

Events

-#### IERC7674 [!toc] -#### ERC20 [!toc] -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] +
+IERC20 + - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +

Errors

-#### IERC7674 [!toc] -#### ERC20 [!toc] -#### IERC20Errors [!toc] +
+IERC20Errors + - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) - [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) - [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) - [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) - [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) - [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
@@ -3423,10 +3499,9 @@ _Available since v5.1._ - [transferFromAndCall(from, to, value, data)](#ERC1363-transferFromAndCall-address-address-uint256-bytes-) - [approveAndCall(spender, value)](#ERC1363-approveAndCall-address-uint256-) - [approveAndCall(spender, value, data)](#ERC1363-approveAndCall-address-uint256-bytes-) -#### IERC1363 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] -#### ERC20 [!toc] +
+ERC20 + - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) - [decimals()](#ERC20-decimals--) @@ -3443,24 +3518,21 @@ _Available since v5.1._ - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +

Events

-#### IERC1363 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] -#### ERC20 [!toc] -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] +
+IERC20 + - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +
@@ -3470,19 +3542,17 @@ _Available since v5.1._ - [ERC1363TransferFailed(receiver, value)](#ERC1363-ERC1363TransferFailed-address-uint256-) - [ERC1363TransferFromFailed(sender, receiver, value)](#ERC1363-ERC1363TransferFromFailed-address-address-uint256-) - [ERC1363ApproveFailed(spender, value)](#ERC1363-ERC1363ApproveFailed-address-uint256-) -#### IERC1363 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] -#### ERC20 [!toc] -#### IERC20Errors [!toc] +
+IERC20Errors + - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) - [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) - [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) - [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) - [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) - [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
@@ -3716,7 +3786,9 @@ recognized off-chain (via event analysis).
- [burn(value)](#ERC20Burnable-burn-uint256-) - [burnFrom(account, value)](#ERC20Burnable-burnFrom-address-uint256-) -#### ERC20 [!toc] +
+ERC20 + - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) - [decimals()](#ERC20-decimals--) @@ -3733,37 +3805,38 @@ recognized off-chain (via event analysis). - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +

Events

-#### ERC20 [!toc] -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] +
+IERC20 + - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +

Errors

-#### ERC20 [!toc] -#### IERC20Errors [!toc] +
+IERC20Errors + - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) - [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) - [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) - [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) - [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) - [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
@@ -3835,7 +3908,9 @@ Extension of [`ERC20`](#ERC20) that adds a cap to the supply of tokens. - [constructor(cap_)](#ERC20Capped-constructor-uint256-) - [cap()](#ERC20Capped-cap--) - [_update(from, to, value)](#ERC20Capped-_update-address-address-uint256-) -#### ERC20 [!toc] +
+ERC20 + - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) - [decimals()](#ERC20-decimals--) @@ -3851,21 +3926,21 @@ Extension of [`ERC20`](#ERC20) that adds a cap to the supply of tokens. - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +

Events

-#### ERC20 [!toc] -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] +
+IERC20 + - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +
@@ -3874,16 +3949,17 @@ Extension of [`ERC20`](#ERC20) that adds a cap to the supply of tokens.
- [ERC20ExceededCap(increasedSupply, cap)](#ERC20Capped-ERC20ExceededCap-uint256-uint256-) - [ERC20InvalidCap(cap)](#ERC20Capped-ERC20InvalidCap-uint256-) -#### ERC20 [!toc] -#### IERC20Errors [!toc] +
+IERC20Errors + - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) - [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) - [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) - [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) - [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) - [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
@@ -4011,13 +4087,19 @@ make the contract pause mechanism of the contract unreachable, and thus unusable

Functions

- [_update(from, to, value)](#ERC20Pausable-_update-address-address-uint256-) -#### Pausable [!toc] +
+Pausable + - [paused()](#Pausable-paused--) - [_requireNotPaused()](#Pausable-_requireNotPaused--) - [_requirePaused()](#Pausable-_requirePaused--) - [_pause()](#Pausable-_pause--) - [_unpause()](#Pausable-_unpause--) -#### ERC20 [!toc] + +
+
+ERC20 + - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) - [decimals()](#ERC20-decimals--) @@ -4033,43 +4115,52 @@ make the contract pause mechanism of the contract unreachable, and thus unusable - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +

Events

-#### Pausable [!toc] +
+Pausable + - [Paused(account)](#Pausable-Paused-address-) - [Unpaused(account)](#Pausable-Unpaused-address-) -#### ERC20 [!toc] -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
+
+IERC20 + - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +

Errors

-#### Pausable [!toc] +
+Pausable + - [EnforcedPause()](#Pausable-EnforcedPause--) - [ExpectedPause()](#Pausable-ExpectedPause--) -#### ERC20 [!toc] -#### IERC20Errors [!toc] + +
+
+IERC20Errors + - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) - [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) - [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) - [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) - [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) - [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
@@ -4127,10 +4218,9 @@ ERC20 extension that implements the standard token interface according to - [crosschainMint(to, value)](#ERC20Bridgeable-crosschainMint-address-uint256-) - [crosschainBurn(from, value)](#ERC20Bridgeable-crosschainBurn-address-uint256-) - [_checkTokenBridge(caller)](#ERC20Bridgeable-_checkTokenBridge-address-) -#### IERC7802 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] -#### ERC20 [!toc] +
+ERC20 + - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) - [decimals()](#ERC20-decimals--) @@ -4147,45 +4237,45 @@ ERC20 extension that implements the standard token interface according to - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) - [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +

Events

-#### IERC7802 [!toc] +
+IERC7802 + - [CrosschainMint(to, amount, sender)](#IERC7802-CrosschainMint-address-uint256-address-) - [CrosschainBurn(from, amount, sender)](#IERC7802-CrosschainBurn-address-uint256-address-) -#### ERC165 [!toc] -#### IERC165 [!toc] -#### ERC20 [!toc] -#### IERC20Errors [!toc] -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
+
+IERC20 + - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) - [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +

Errors

-#### IERC7802 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] -#### ERC20 [!toc] -#### IERC20Errors [!toc] +
+IERC20Errors + - [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) - [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) - [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) - [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) - [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) - [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) -#### IERC20Metadata [!toc] -#### IERC20 [!toc] + +
diff --git a/content/contracts/5.x/api/token/ERC6909.mdx b/content/contracts/5.x/api/token/ERC6909.mdx index c0272555..cb2ebfa5 100644 --- a/content/contracts/5.x/api/token/ERC6909.mdx +++ b/content/contracts/5.x/api/token/ERC6909.mdx @@ -63,21 +63,20 @@ See https://eips.ethereum.org/EIPS/eip-6909 - [_approve(owner, spender, id, amount)](#ERC6909-_approve-address-address-uint256-uint256-) - [_setOperator(owner, spender, approved)](#ERC6909-_setOperator-address-address-bool-) - [_spendAllowance(owner, spender, id, amount)](#ERC6909-_spendAllowance-address-address-uint256-uint256-) -#### IERC6909 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc]

Events

-#### IERC6909 [!toc] +
+IERC6909 + - [Approval(owner, spender, id, amount)](#IERC6909-Approval-address-address-uint256-uint256-) - [OperatorSet(owner, spender, approved)](#IERC6909-OperatorSet-address-address-bool-) - [Transfer(caller, sender, receiver, id, amount)](#IERC6909-Transfer-address-address-address-uint256-uint256-) -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -90,9 +89,6 @@ See https://eips.ethereum.org/EIPS/eip-6909 - [ERC6909InvalidReceiver(receiver)](#ERC6909-ERC6909InvalidReceiver-address-) - [ERC6909InvalidSender(sender)](#ERC6909-ERC6909InvalidSender-address-) - [ERC6909InvalidSpender(spender)](#ERC6909-ERC6909InvalidSpender-address-) -#### IERC6909 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] @@ -536,8 +532,9 @@ Implementation of the Content URI extension defined in ERC6909. - [tokenURI(id)](#ERC6909ContentURI-tokenURI-uint256-) - [_setContractURI(newContractURI)](#ERC6909ContentURI-_setContractURI-string-) - [_setTokenURI(id, newTokenURI)](#ERC6909ContentURI-_setTokenURI-uint256-string-) -#### IERC6909ContentURI [!toc] -#### ERC6909 [!toc] +
+ERC6909 + - [balanceOf(owner, id)](#ERC6909-balanceOf-address-uint256-) - [allowance(owner, spender, id)](#ERC6909-allowance-address-address-uint256-) - [isOperator(owner, spender)](#ERC6909-isOperator-address-address-) @@ -552,9 +549,8 @@ Implementation of the Content URI extension defined in ERC6909. - [_approve(owner, spender, id, amount)](#ERC6909-_approve-address-address-uint256-uint256-) - [_setOperator(owner, spender, approved)](#ERC6909-_setOperator-address-address-bool-) - [_spendAllowance(owner, spender, id, amount)](#ERC6909-_spendAllowance-address-address-uint256-uint256-) -#### IERC6909 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -563,31 +559,31 @@ Implementation of the Content URI extension defined in ERC6909.
- [ContractURIUpdated()](#ERC6909ContentURI-ContractURIUpdated--) - [URI(value, id)](#ERC6909ContentURI-URI-string-uint256-) -#### IERC6909ContentURI [!toc] -#### ERC6909 [!toc] -#### IERC6909 [!toc] +
+IERC6909 + - [Approval(owner, spender, id, amount)](#IERC6909-Approval-address-address-uint256-uint256-) - [OperatorSet(owner, spender, approved)](#IERC6909-OperatorSet-address-address-bool-) - [Transfer(caller, sender, receiver, id, amount)](#IERC6909-Transfer-address-address-address-uint256-uint256-) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### IERC6909ContentURI [!toc] -#### ERC6909 [!toc] +
+ERC6909 + - [ERC6909InsufficientBalance(sender, balance, needed, id)](#ERC6909-ERC6909InsufficientBalance-address-uint256-uint256-uint256-) - [ERC6909InsufficientAllowance(spender, allowance, needed, id)](#ERC6909-ERC6909InsufficientAllowance-address-uint256-uint256-uint256-) - [ERC6909InvalidApprover(approver)](#ERC6909-ERC6909InvalidApprover-address-) - [ERC6909InvalidReceiver(receiver)](#ERC6909-ERC6909InvalidReceiver-address-) - [ERC6909InvalidSender(sender)](#ERC6909-ERC6909InvalidSender-address-) - [ERC6909InvalidSpender(spender)](#ERC6909-ERC6909InvalidSpender-address-) -#### IERC6909 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -748,8 +744,9 @@ Implementation of the Metadata extension defined in ERC6909. Exposes the name, s - [_setName(id, newName)](#ERC6909Metadata-_setName-uint256-string-) - [_setSymbol(id, newSymbol)](#ERC6909Metadata-_setSymbol-uint256-string-) - [_setDecimals(id, newDecimals)](#ERC6909Metadata-_setDecimals-uint256-uint8-) -#### IERC6909Metadata [!toc] -#### ERC6909 [!toc] +
+ERC6909 + - [balanceOf(owner, id)](#ERC6909-balanceOf-address-uint256-) - [allowance(owner, spender, id)](#ERC6909-allowance-address-address-uint256-) - [isOperator(owner, spender)](#ERC6909-isOperator-address-address-) @@ -764,9 +761,8 @@ Implementation of the Metadata extension defined in ERC6909. Exposes the name, s - [_approve(owner, spender, id, amount)](#ERC6909-_approve-address-address-uint256-uint256-) - [_setOperator(owner, spender, approved)](#ERC6909-_setOperator-address-address-bool-) - [_spendAllowance(owner, spender, id, amount)](#ERC6909-_spendAllowance-address-address-uint256-uint256-) -#### IERC6909 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -776,31 +772,31 @@ Implementation of the Metadata extension defined in ERC6909. Exposes the name, s - [ERC6909NameUpdated(id, newName)](#ERC6909Metadata-ERC6909NameUpdated-uint256-string-) - [ERC6909SymbolUpdated(id, newSymbol)](#ERC6909Metadata-ERC6909SymbolUpdated-uint256-string-) - [ERC6909DecimalsUpdated(id, newDecimals)](#ERC6909Metadata-ERC6909DecimalsUpdated-uint256-uint8-) -#### IERC6909Metadata [!toc] -#### ERC6909 [!toc] -#### IERC6909 [!toc] +
+IERC6909 + - [Approval(owner, spender, id, amount)](#IERC6909-Approval-address-address-uint256-uint256-) - [OperatorSet(owner, spender, approved)](#IERC6909-OperatorSet-address-address-bool-) - [Transfer(caller, sender, receiver, id, amount)](#IERC6909-Transfer-address-address-address-uint256-uint256-) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### IERC6909Metadata [!toc] -#### ERC6909 [!toc] +
+ERC6909 + - [ERC6909InsufficientBalance(sender, balance, needed, id)](#ERC6909-ERC6909InsufficientBalance-address-uint256-uint256-uint256-) - [ERC6909InsufficientAllowance(spender, allowance, needed, id)](#ERC6909-ERC6909InsufficientAllowance-address-uint256-uint256-uint256-) - [ERC6909InvalidApprover(approver)](#ERC6909-ERC6909InvalidApprover-address-) - [ERC6909InvalidReceiver(receiver)](#ERC6909-ERC6909InvalidReceiver-address-) - [ERC6909InvalidSender(sender)](#ERC6909-ERC6909InvalidSender-address-) - [ERC6909InvalidSpender(spender)](#ERC6909-ERC6909InvalidSpender-address-) -#### IERC6909 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -1011,8 +1007,9 @@ Tracks the total supply of each token id individually. - [totalSupply(id)](#ERC6909TokenSupply-totalSupply-uint256-) - [supportsInterface(interfaceId)](#ERC6909TokenSupply-supportsInterface-bytes4-) - [_update(from, to, id, amount)](#ERC6909TokenSupply-_update-address-address-uint256-uint256-) -#### IERC6909TokenSupply [!toc] -#### ERC6909 [!toc] +
+ERC6909 + - [balanceOf(owner, id)](#ERC6909-balanceOf-address-uint256-) - [allowance(owner, spender, id)](#ERC6909-allowance-address-address-uint256-) - [isOperator(owner, spender)](#ERC6909-isOperator-address-address-) @@ -1026,40 +1023,39 @@ Tracks the total supply of each token id individually. - [_approve(owner, spender, id, amount)](#ERC6909-_approve-address-address-uint256-uint256-) - [_setOperator(owner, spender, approved)](#ERC6909-_setOperator-address-address-bool-) - [_spendAllowance(owner, spender, id, amount)](#ERC6909-_spendAllowance-address-address-uint256-uint256-) -#### IERC6909 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Events

-#### IERC6909TokenSupply [!toc] -#### ERC6909 [!toc] -#### IERC6909 [!toc] +
+IERC6909 + - [Approval(owner, spender, id, amount)](#IERC6909-Approval-address-address-uint256-uint256-) - [OperatorSet(owner, spender, approved)](#IERC6909-OperatorSet-address-address-bool-) - [Transfer(caller, sender, receiver, id, amount)](#IERC6909-Transfer-address-address-address-uint256-uint256-) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### IERC6909TokenSupply [!toc] -#### ERC6909 [!toc] +
+ERC6909 + - [ERC6909InsufficientBalance(sender, balance, needed, id)](#ERC6909-ERC6909InsufficientBalance-address-uint256-uint256-uint256-) - [ERC6909InsufficientAllowance(spender, allowance, needed, id)](#ERC6909-ERC6909InsufficientAllowance-address-uint256-uint256-uint256-) - [ERC6909InvalidApprover(approver)](#ERC6909-ERC6909InvalidApprover-address-) - [ERC6909InvalidReceiver(receiver)](#ERC6909-ERC6909InvalidReceiver-address-) - [ERC6909InvalidSender(sender)](#ERC6909-ERC6909InvalidSender-address-) - [ERC6909InvalidSpender(spender)](#ERC6909-ERC6909InvalidSpender-address-) -#### IERC6909 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
diff --git a/content/contracts/5.x/api/token/ERC721.mdx b/content/contracts/5.x/api/token/ERC721.mdx index feb48797..9d62fa92 100644 --- a/content/contracts/5.x/api/token/ERC721.mdx +++ b/content/contracts/5.x/api/token/ERC721.mdx @@ -130,32 +130,29 @@ the Metadata extension, but not including the Enumerable extension, which is ava - [_approve(to, tokenId, auth, emitEvent)](#ERC721-_approve-address-uint256-address-bool-) - [_setApprovalForAll(owner, operator, approved)](#ERC721-_setApprovalForAll-address-address-bool-) - [_requireOwned(tokenId)](#ERC721-_requireOwned-uint256-) -#### IERC721Errors [!toc] -#### IERC721Metadata [!toc] -#### IERC721 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc]

Events

-#### IERC721Errors [!toc] -#### IERC721Metadata [!toc] -#### IERC721 [!toc] +
+IERC721 + - [Transfer(from, to, tokenId)](#IERC721-Transfer-address-address-uint256-) - [Approval(owner, approved, tokenId)](#IERC721-Approval-address-address-uint256-) - [ApprovalForAll(owner, operator, approved)](#IERC721-ApprovalForAll-address-address-bool-) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### IERC721Errors [!toc] +
+IERC721Errors + - [ERC721InvalidOwner(owner)](#IERC721Errors-ERC721InvalidOwner-address-) - [ERC721NonexistentToken(tokenId)](#IERC721Errors-ERC721NonexistentToken-uint256-) - [ERC721IncorrectOwner(sender, tokenId, owner)](#IERC721Errors-ERC721IncorrectOwner-address-uint256-address-) @@ -164,10 +161,8 @@ the Metadata extension, but not including the Enumerable extension, which is ava - [ERC721InsufficientApproval(operator, tokenId)](#IERC721Errors-ERC721InsufficientApproval-address-uint256-) - [ERC721InvalidApprover(approver)](#IERC721Errors-ERC721InvalidApprover-address-) - [ERC721InvalidOperator(operator)](#IERC721Errors-ERC721InvalidOperator-address-) -#### IERC721Metadata [!toc] -#### IERC721 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -928,8 +923,12 @@ Required interface of an ERC-721 compliant contract. - [setApprovalForAll(operator, approved)](#IERC721-setApprovalForAll-address-bool-) - [getApproved(tokenId)](#IERC721-getApproved-uint256-) - [isApprovedForAll(owner, operator)](#IERC721-isApprovedForAll-address-address-) -#### IERC165 [!toc] +
+IERC165 + - [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) + +
@@ -939,7 +938,6 @@ Required interface of an ERC-721 compliant contract. - [Transfer(from, to, tokenId)](#IERC721-Transfer-address-address-uint256-) - [Approval(owner, approved, tokenId)](#IERC721-Approval-address-address-uint256-) - [ApprovalForAll(owner, operator, approved)](#IERC721-ApprovalForAll-address-address-bool-) -#### IERC165 [!toc] @@ -1286,7 +1284,9 @@ ERC-721 Token that can be burned (destroyed).

Functions

- [burn(tokenId)](#ERC721Burnable-burn-uint256-) -#### ERC721 [!toc] +
+ERC721 + - [supportsInterface(interfaceId)](#ERC721-supportsInterface-bytes4-) - [balanceOf(owner)](#ERC721-balanceOf-address-) - [ownerOf(tokenId)](#ERC721-ownerOf-uint256-) @@ -1318,34 +1318,31 @@ ERC-721 Token that can be burned (destroyed). - [_approve(to, tokenId, auth, emitEvent)](#ERC721-_approve-address-uint256-address-bool-) - [_setApprovalForAll(owner, operator, approved)](#ERC721-_setApprovalForAll-address-address-bool-) - [_requireOwned(tokenId)](#ERC721-_requireOwned-uint256-) -#### IERC721Errors [!toc] -#### IERC721Metadata [!toc] -#### IERC721 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Events

-#### ERC721 [!toc] -#### IERC721Errors [!toc] -#### IERC721Metadata [!toc] -#### IERC721 [!toc] +
+IERC721 + - [Transfer(from, to, tokenId)](#IERC721-Transfer-address-address-uint256-) - [Approval(owner, approved, tokenId)](#IERC721-Approval-address-address-uint256-) - [ApprovalForAll(owner, operator, approved)](#IERC721-ApprovalForAll-address-address-bool-) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### ERC721 [!toc] -#### IERC721Errors [!toc] +
+IERC721Errors + - [ERC721InvalidOwner(owner)](#IERC721Errors-ERC721InvalidOwner-address-) - [ERC721NonexistentToken(tokenId)](#IERC721Errors-ERC721NonexistentToken-uint256-) - [ERC721IncorrectOwner(sender, tokenId, owner)](#IERC721Errors-ERC721IncorrectOwner-address-uint256-address-) @@ -1354,10 +1351,8 @@ ERC-721 Token that can be burned (destroyed). - [ERC721InsufficientApproval(operator, tokenId)](#IERC721Errors-ERC721InsufficientApproval-address-uint256-) - [ERC721InvalidApprover(approver)](#IERC721Errors-ERC721InvalidApprover-address-) - [ERC721InvalidOperator(operator)](#IERC721Errors-ERC721InvalidOperator-address-) -#### IERC721Metadata [!toc] -#### IERC721 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -1428,7 +1423,9 @@ super call before your custom logic. - [_mintConsecutive(to, batchSize)](#ERC721Consecutive-_mintConsecutive-address-uint96-) - [_update(to, tokenId, auth)](#ERC721Consecutive-_update-address-uint256-address-) - [_firstConsecutiveId()](#ERC721Consecutive-_firstConsecutiveId--) -#### ERC721 [!toc] +
+ERC721 + - [supportsInterface(interfaceId)](#ERC721-supportsInterface-bytes4-) - [balanceOf(owner)](#ERC721-balanceOf-address-) - [ownerOf(tokenId)](#ERC721-ownerOf-uint256-) @@ -1458,29 +1455,28 @@ super call before your custom logic. - [_approve(to, tokenId, auth, emitEvent)](#ERC721-_approve-address-uint256-address-bool-) - [_setApprovalForAll(owner, operator, approved)](#ERC721-_setApprovalForAll-address-address-bool-) - [_requireOwned(tokenId)](#ERC721-_requireOwned-uint256-) -#### IERC721Errors [!toc] -#### IERC721Metadata [!toc] -#### IERC721 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] -#### IERC2309 [!toc] + +

Events

-#### ERC721 [!toc] -#### IERC721Errors [!toc] -#### IERC721Metadata [!toc] -#### IERC721 [!toc] +
+IERC721 + - [Transfer(from, to, tokenId)](#IERC721-Transfer-address-address-uint256-) - [Approval(owner, approved, tokenId)](#IERC721-Approval-address-address-uint256-) - [ApprovalForAll(owner, operator, approved)](#IERC721-ApprovalForAll-address-address-bool-) -#### ERC165 [!toc] -#### IERC165 [!toc] -#### IERC2309 [!toc] + +
+
+IERC2309 + - [ConsecutiveTransfer(fromTokenId, toTokenId, fromAddress, toAddress)](#IERC2309-ConsecutiveTransfer-uint256-uint256-address-address-) + +
@@ -1491,8 +1487,9 @@ super call before your custom logic. - [ERC721ExceededMaxBatchMint(batchSize, maxBatch)](#ERC721Consecutive-ERC721ExceededMaxBatchMint-uint256-uint256-) - [ERC721ForbiddenMint()](#ERC721Consecutive-ERC721ForbiddenMint--) - [ERC721ForbiddenBatchBurn()](#ERC721Consecutive-ERC721ForbiddenBatchBurn--) -#### ERC721 [!toc] -#### IERC721Errors [!toc] +
+IERC721Errors + - [ERC721InvalidOwner(owner)](#IERC721Errors-ERC721InvalidOwner-address-) - [ERC721NonexistentToken(tokenId)](#IERC721Errors-ERC721NonexistentToken-uint256-) - [ERC721IncorrectOwner(sender, tokenId, owner)](#IERC721Errors-ERC721IncorrectOwner-address-uint256-address-) @@ -1501,11 +1498,8 @@ super call before your custom logic. - [ERC721InsufficientApproval(operator, tokenId)](#IERC721Errors-ERC721InsufficientApproval-address-uint256-) - [ERC721InvalidApprover(approver)](#IERC721Errors-ERC721InvalidApprover-address-) - [ERC721InvalidOperator(operator)](#IERC721Errors-ERC721InvalidOperator-address-) -#### IERC721Metadata [!toc] -#### IERC721 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] -#### IERC2309 [!toc] + +
@@ -1722,18 +1716,31 @@ This extension makes the token compatible with: - [crosschainTransferFrom(from, to, tokenId)](#ERC721Crosschain-crosschainTransferFrom-address-bytes-uint256-) - [_onSend(from, tokenId)](#ERC721Crosschain-_onSend-address-uint256-) - [_onReceive(to, tokenId)](#ERC721Crosschain-_onReceive-address-uint256-) -#### BridgeNonFungible [!toc] +
+BridgeNonFungible + - [_crosschainTransfer(from, to, tokenId)](#BridgeNonFungible-_crosschainTransfer-address-bytes-uint256-) - [_processMessage(, receiveId, , payload)](#BridgeNonFungible-_processMessage-address-bytes32-bytes-bytes-) -#### CrosschainLinked [!toc] + +
+
+CrosschainLinked + - [getLink(chain)](#CrosschainLinked-getLink-bytes-) - [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) - [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) - [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) -#### ERC7786Recipient [!toc] + +
+
+ERC7786Recipient + - [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) -#### IERC7786Recipient [!toc] -#### ERC721 [!toc] + +
+
+ERC721 + - [supportsInterface(interfaceId)](#ERC721-supportsInterface-bytes4-) - [balanceOf(owner)](#ERC721-balanceOf-address-) - [ownerOf(tokenId)](#ERC721-ownerOf-uint256-) @@ -1765,47 +1772,56 @@ This extension makes the token compatible with: - [_approve(to, tokenId, auth, emitEvent)](#ERC721-_approve-address-uint256-address-bool-) - [_setApprovalForAll(owner, operator, approved)](#ERC721-_setApprovalForAll-address-address-bool-) - [_requireOwned(tokenId)](#ERC721-_requireOwned-uint256-) -#### IERC721Errors [!toc] -#### IERC721Metadata [!toc] -#### IERC721 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Events

-#### BridgeNonFungible [!toc] +
+BridgeNonFungible + - [CrosschainNonFungibleTransferSent(sendId, from, to, tokenId)](#BridgeNonFungible-CrosschainNonFungibleTransferSent-bytes32-address-bytes-uint256-) - [CrosschainNonFungibleTransferReceived(receiveId, from, to, tokenId)](#BridgeNonFungible-CrosschainNonFungibleTransferReceived-bytes32-bytes-address-uint256-) -#### CrosschainLinked [!toc] + +
+
+CrosschainLinked + - [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) -#### ERC7786Recipient [!toc] -#### IERC7786Recipient [!toc] -#### ERC721 [!toc] -#### IERC721Errors [!toc] -#### IERC721Metadata [!toc] -#### IERC721 [!toc] + +
+
+IERC721 + - [Transfer(from, to, tokenId)](#IERC721-Transfer-address-address-uint256-) - [Approval(owner, approved, tokenId)](#IERC721-Approval-address-address-uint256-) - [ApprovalForAll(owner, operator, approved)](#IERC721-ApprovalForAll-address-address-bool-) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### BridgeNonFungible [!toc] -#### CrosschainLinked [!toc] +
+CrosschainLinked + - [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) -#### ERC7786Recipient [!toc] + +
+
+ERC7786Recipient + - [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) -#### IERC7786Recipient [!toc] -#### ERC721 [!toc] -#### IERC721Errors [!toc] + +
+
+IERC721Errors + - [ERC721InvalidOwner(owner)](#IERC721Errors-ERC721InvalidOwner-address-) - [ERC721NonexistentToken(tokenId)](#IERC721Errors-ERC721NonexistentToken-uint256-) - [ERC721IncorrectOwner(sender, tokenId, owner)](#IERC721Errors-ERC721IncorrectOwner-address-uint256-address-) @@ -1814,10 +1830,8 @@ This extension makes the token compatible with: - [ERC721InsufficientApproval(operator, tokenId)](#IERC721Errors-ERC721InsufficientApproval-address-uint256-) - [ERC721InvalidApprover(approver)](#IERC721Errors-ERC721InvalidApprover-address-) - [ERC721InvalidOperator(operator)](#IERC721Errors-ERC721InvalidOperator-address-) -#### IERC721Metadata [!toc] -#### IERC721 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -1905,8 +1919,9 @@ interfere with enumerability and should not be used together with [`ERC721Enumer - [tokenByIndex(index)](#ERC721Enumerable-tokenByIndex-uint256-) - [_update(to, tokenId, auth)](#ERC721Enumerable-_update-address-uint256-address-) - [_increaseBalance(account, amount)](#ERC721Enumerable-_increaseBalance-address-uint128-) -#### IERC721Enumerable [!toc] -#### ERC721 [!toc] +
+ERC721 + - [balanceOf(owner)](#ERC721-balanceOf-address-) - [ownerOf(tokenId)](#ERC721-ownerOf-uint256-) - [name()](#ERC721-name--) @@ -1935,27 +1950,22 @@ interfere with enumerability and should not be used together with [`ERC721Enumer - [_approve(to, tokenId, auth, emitEvent)](#ERC721-_approve-address-uint256-address-bool-) - [_setApprovalForAll(owner, operator, approved)](#ERC721-_setApprovalForAll-address-address-bool-) - [_requireOwned(tokenId)](#ERC721-_requireOwned-uint256-) -#### IERC721Errors [!toc] -#### IERC721Metadata [!toc] -#### IERC721 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Events

-#### IERC721Enumerable [!toc] -#### ERC721 [!toc] -#### IERC721Errors [!toc] -#### IERC721Metadata [!toc] -#### IERC721 [!toc] +
+IERC721 + - [Transfer(from, to, tokenId)](#IERC721-Transfer-address-address-uint256-) - [Approval(owner, approved, tokenId)](#IERC721-Approval-address-address-uint256-) - [ApprovalForAll(owner, operator, approved)](#IERC721-ApprovalForAll-address-address-bool-) -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -1964,9 +1974,9 @@ interfere with enumerability and should not be used together with [`ERC721Enumer
- [ERC721OutOfBoundsIndex(owner, index)](#ERC721Enumerable-ERC721OutOfBoundsIndex-address-uint256-) - [ERC721EnumerableForbiddenBatchMint()](#ERC721Enumerable-ERC721EnumerableForbiddenBatchMint--) -#### IERC721Enumerable [!toc] -#### ERC721 [!toc] -#### IERC721Errors [!toc] +
+IERC721Errors + - [ERC721InvalidOwner(owner)](#IERC721Errors-ERC721InvalidOwner-address-) - [ERC721NonexistentToken(tokenId)](#IERC721Errors-ERC721NonexistentToken-uint256-) - [ERC721IncorrectOwner(sender, tokenId, owner)](#IERC721Errors-ERC721IncorrectOwner-address-uint256-address-) @@ -1975,10 +1985,8 @@ interfere with enumerability and should not be used together with [`ERC721Enumer - [ERC721InsufficientApproval(operator, tokenId)](#IERC721Errors-ERC721InsufficientApproval-address-uint256-) - [ERC721InvalidApprover(approver)](#IERC721Errors-ERC721InvalidApprover-address-) - [ERC721InvalidOperator(operator)](#IERC721Errors-ERC721InvalidOperator-address-) -#### IERC721Metadata [!toc] -#### IERC721 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -2171,13 +2179,19 @@ make the contract pause mechanism of the contract unreachable, and thus unusable

Functions

- [_update(to, tokenId, auth)](#ERC721Pausable-_update-address-uint256-address-) -#### Pausable [!toc] +
+Pausable + - [paused()](#Pausable-paused--) - [_requireNotPaused()](#Pausable-_requireNotPaused--) - [_requirePaused()](#Pausable-_requirePaused--) - [_pause()](#Pausable-_pause--) - [_unpause()](#Pausable-_unpause--) -#### ERC721 [!toc] + +
+
+ERC721 + - [supportsInterface(interfaceId)](#ERC721-supportsInterface-bytes4-) - [balanceOf(owner)](#ERC721-balanceOf-address-) - [ownerOf(tokenId)](#ERC721-ownerOf-uint256-) @@ -2208,40 +2222,45 @@ make the contract pause mechanism of the contract unreachable, and thus unusable - [_approve(to, tokenId, auth, emitEvent)](#ERC721-_approve-address-uint256-address-bool-) - [_setApprovalForAll(owner, operator, approved)](#ERC721-_setApprovalForAll-address-address-bool-) - [_requireOwned(tokenId)](#ERC721-_requireOwned-uint256-) -#### IERC721Errors [!toc] -#### IERC721Metadata [!toc] -#### IERC721 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Events

-#### Pausable [!toc] +
+Pausable + - [Paused(account)](#Pausable-Paused-address-) - [Unpaused(account)](#Pausable-Unpaused-address-) -#### ERC721 [!toc] -#### IERC721Errors [!toc] -#### IERC721Metadata [!toc] -#### IERC721 [!toc] + +
+
+IERC721 + - [Transfer(from, to, tokenId)](#IERC721-Transfer-address-address-uint256-) - [Approval(owner, approved, tokenId)](#IERC721-Approval-address-address-uint256-) - [ApprovalForAll(owner, operator, approved)](#IERC721-ApprovalForAll-address-address-bool-) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### Pausable [!toc] +
+Pausable + - [EnforcedPause()](#Pausable-EnforcedPause--) - [ExpectedPause()](#Pausable-ExpectedPause--) -#### ERC721 [!toc] -#### IERC721Errors [!toc] + +
+
+IERC721Errors + - [ERC721InvalidOwner(owner)](#IERC721Errors-ERC721InvalidOwner-address-) - [ERC721NonexistentToken(tokenId)](#IERC721Errors-ERC721NonexistentToken-uint256-) - [ERC721IncorrectOwner(sender, tokenId, owner)](#IERC721Errors-ERC721IncorrectOwner-address-uint256-address-) @@ -2250,10 +2269,8 @@ make the contract pause mechanism of the contract unreachable, and thus unusable - [ERC721InsufficientApproval(operator, tokenId)](#IERC721Errors-ERC721InsufficientApproval-address-uint256-) - [ERC721InvalidApprover(approver)](#IERC721Errors-ERC721InvalidApprover-address-) - [ERC721InvalidOperator(operator)](#IERC721Errors-ERC721InvalidOperator-address-) -#### IERC721Metadata [!toc] -#### IERC721 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -2310,7 +2327,9 @@ voluntarily pay royalties together with sales, but note that this standard is no

Functions

- [supportsInterface(interfaceId)](#ERC721Royalty-supportsInterface-bytes4-) -#### ERC721 [!toc] +
+ERC721 + - [balanceOf(owner)](#ERC721-balanceOf-address-) - [ownerOf(tokenId)](#ERC721-ownerOf-uint256-) - [name()](#ERC721-name--) @@ -2341,44 +2360,42 @@ voluntarily pay royalties together with sales, but note that this standard is no - [_approve(to, tokenId, auth, emitEvent)](#ERC721-_approve-address-uint256-address-bool-) - [_setApprovalForAll(owner, operator, approved)](#ERC721-_setApprovalForAll-address-address-bool-) - [_requireOwned(tokenId)](#ERC721-_requireOwned-uint256-) -#### IERC721Errors [!toc] -#### IERC721Metadata [!toc] -#### IERC721 [!toc] -#### ERC2981 [!toc] + +
+
+ERC2981 + - [royaltyInfo(tokenId, salePrice)](#ERC2981-royaltyInfo-uint256-uint256-) - [_feeDenominator()](#ERC2981-_feeDenominator--) - [_setDefaultRoyalty(receiver, feeNumerator)](#ERC2981-_setDefaultRoyalty-address-uint96-) - [_deleteDefaultRoyalty()](#ERC2981-_deleteDefaultRoyalty--) - [_setTokenRoyalty(tokenId, receiver, feeNumerator)](#ERC2981-_setTokenRoyalty-uint256-address-uint96-) - [_resetTokenRoyalty(tokenId)](#ERC2981-_resetTokenRoyalty-uint256-) -#### ERC165 [!toc] -#### IERC2981 [!toc] -#### IERC165 [!toc] + +

Events

-#### ERC721 [!toc] -#### IERC721Errors [!toc] -#### IERC721Metadata [!toc] -#### IERC721 [!toc] +
+IERC721 + - [Transfer(from, to, tokenId)](#IERC721-Transfer-address-address-uint256-) - [Approval(owner, approved, tokenId)](#IERC721-Approval-address-address-uint256-) - [ApprovalForAll(owner, operator, approved)](#IERC721-ApprovalForAll-address-address-bool-) -#### ERC2981 [!toc] -#### ERC165 [!toc] -#### IERC2981 [!toc] -#### IERC165 [!toc] + +

Errors

-#### ERC721 [!toc] -#### IERC721Errors [!toc] +
+IERC721Errors + - [ERC721InvalidOwner(owner)](#IERC721Errors-ERC721InvalidOwner-address-) - [ERC721NonexistentToken(tokenId)](#IERC721Errors-ERC721NonexistentToken-uint256-) - [ERC721IncorrectOwner(sender, tokenId, owner)](#IERC721Errors-ERC721IncorrectOwner-address-uint256-address-) @@ -2387,16 +2404,17 @@ voluntarily pay royalties together with sales, but note that this standard is no - [ERC721InsufficientApproval(operator, tokenId)](#IERC721Errors-ERC721InsufficientApproval-address-uint256-) - [ERC721InvalidApprover(approver)](#IERC721Errors-ERC721InvalidApprover-address-) - [ERC721InvalidOperator(operator)](#IERC721Errors-ERC721InvalidOperator-address-) -#### IERC721Metadata [!toc] -#### IERC721 [!toc] -#### ERC2981 [!toc] + +
+
+ERC2981 + - [ERC2981InvalidDefaultRoyalty(numerator, denominator)](#ERC2981-ERC2981InvalidDefaultRoyalty-uint256-uint256-) - [ERC2981InvalidDefaultRoyaltyReceiver(receiver)](#ERC2981-ERC2981InvalidDefaultRoyaltyReceiver-address-) - [ERC2981InvalidTokenRoyalty(tokenId, numerator, denominator)](#ERC2981-ERC2981InvalidTokenRoyalty-uint256-uint256-uint256-) - [ERC2981InvalidTokenRoyaltyReceiver(tokenId, receiver)](#ERC2981-ERC2981InvalidTokenRoyaltyReceiver-uint256-address-) -#### ERC165 [!toc] -#### IERC2981 [!toc] -#### IERC165 [!toc] + +
@@ -2440,7 +2458,9 @@ ERC-721 token with storage based token URI management. - [tokenURI(tokenId)](#ERC721URIStorage-tokenURI-uint256-) - [_setTokenURI(tokenId, _tokenURI)](#ERC721URIStorage-_setTokenURI-uint256-string-) - [_suffixURI(tokenId)](#ERC721URIStorage-_suffixURI-uint256-) -#### ERC721 [!toc] +
+ERC721 + - [balanceOf(owner)](#ERC721-balanceOf-address-) - [ownerOf(tokenId)](#ERC721-ownerOf-uint256-) - [name()](#ERC721-name--) @@ -2470,38 +2490,38 @@ ERC-721 token with storage based token URI management. - [_approve(to, tokenId, auth, emitEvent)](#ERC721-_approve-address-uint256-address-bool-) - [_setApprovalForAll(owner, operator, approved)](#ERC721-_setApprovalForAll-address-address-bool-) - [_requireOwned(tokenId)](#ERC721-_requireOwned-uint256-) -#### IERC721Errors [!toc] -#### IERC721Metadata [!toc] -#### IERC4906 [!toc] -#### IERC721 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Events

-#### ERC721 [!toc] -#### IERC721Errors [!toc] -#### IERC721Metadata [!toc] -#### IERC4906 [!toc] +
+IERC4906 + - [MetadataUpdate(_tokenId)](#IERC4906-MetadataUpdate-uint256-) - [BatchMetadataUpdate(_fromTokenId, _toTokenId)](#IERC4906-BatchMetadataUpdate-uint256-uint256-) -#### IERC721 [!toc] + +
+
+IERC721 + - [Transfer(from, to, tokenId)](#IERC721-Transfer-address-address-uint256-) - [Approval(owner, approved, tokenId)](#IERC721-Approval-address-address-uint256-) - [ApprovalForAll(owner, operator, approved)](#IERC721-ApprovalForAll-address-address-bool-) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### ERC721 [!toc] -#### IERC721Errors [!toc] +
+IERC721Errors + - [ERC721InvalidOwner(owner)](#IERC721Errors-ERC721InvalidOwner-address-) - [ERC721NonexistentToken(tokenId)](#IERC721Errors-ERC721NonexistentToken-uint256-) - [ERC721IncorrectOwner(sender, tokenId, owner)](#IERC721Errors-ERC721IncorrectOwner-address-uint256-address-) @@ -2510,11 +2530,8 @@ ERC-721 token with storage based token URI management. - [ERC721InsufficientApproval(operator, tokenId)](#IERC721Errors-ERC721InsufficientApproval-address-uint256-) - [ERC721InvalidApprover(approver)](#IERC721Errors-ERC721InvalidApprover-address-) - [ERC721InvalidOperator(operator)](#IERC721Errors-ERC721InvalidOperator-address-) -#### IERC721Metadata [!toc] -#### IERC4906 [!toc] -#### IERC721 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -2620,7 +2637,9 @@ the votes in governance decisions, or they can delegate to themselves to be thei - [_update(to, tokenId, auth)](#ERC721Votes-_update-address-uint256-address-) - [_getVotingUnits(account)](#ERC721Votes-_getVotingUnits-address-) - [_increaseBalance(account, amount)](#ERC721Votes-_increaseBalance-address-uint128-) -#### Votes [!toc] +
+Votes + - [clock()](#Votes-clock--) - [CLOCK_MODE()](#Votes-CLOCK_MODE--) - [_validateTimepoint(timepoint)](#Votes-_validateTimepoint-uint256-) @@ -2636,21 +2655,29 @@ the votes in governance decisions, or they can delegate to themselves to be thei - [_moveDelegateVotes(from, to, amount)](#Votes-_moveDelegateVotes-address-address-uint256-) - [_numCheckpoints(account)](#Votes-_numCheckpoints-address-) - [_checkpoints(account, pos)](#Votes-_checkpoints-address-uint32-) -#### IERC5805 [!toc] -#### IVotes [!toc] -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### EIP712 [!toc] + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### ERC721 [!toc] + +
+
+ERC721 + - [supportsInterface(interfaceId)](#ERC721-supportsInterface-bytes4-) - [balanceOf(owner)](#ERC721-balanceOf-address-) - [ownerOf(tokenId)](#ERC721-ownerOf-uint256-) @@ -2680,55 +2707,63 @@ the votes in governance decisions, or they can delegate to themselves to be thei - [_approve(to, tokenId, auth, emitEvent)](#ERC721-_approve-address-uint256-address-bool-) - [_setApprovalForAll(owner, operator, approved)](#ERC721-_setApprovalForAll-address-address-bool-) - [_requireOwned(tokenId)](#ERC721-_requireOwned-uint256-) -#### IERC721Errors [!toc] -#### IERC721Metadata [!toc] -#### IERC721 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Events

-#### Votes [!toc] -#### IERC5805 [!toc] -#### IVotes [!toc] +
+IVotes + - [DelegateChanged(delegator, fromDelegate, toDelegate)](#IVotes-DelegateChanged-address-address-address-) - [DelegateVotesChanged(delegate, previousVotes, newVotes)](#IVotes-DelegateVotesChanged-address-uint256-uint256-) -#### IERC6372 [!toc] -#### Nonces [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
+
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### ERC721 [!toc] -#### IERC721Errors [!toc] -#### IERC721Metadata [!toc] -#### IERC721 [!toc] + +
+
+IERC721 + - [Transfer(from, to, tokenId)](#IERC721-Transfer-address-address-uint256-) - [Approval(owner, approved, tokenId)](#IERC721-Approval-address-address-uint256-) - [ApprovalForAll(owner, operator, approved)](#IERC721-ApprovalForAll-address-address-bool-) -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Errors

-#### Votes [!toc] +
+Votes + - [ERC6372InconsistentClock()](#Votes-ERC6372InconsistentClock--) - [ERC5805FutureLookup(timepoint, clock)](#Votes-ERC5805FutureLookup-uint256-uint48-) -#### IERC5805 [!toc] -#### IVotes [!toc] + +
+
+IVotes + - [VotesExpiredSignature(expiry)](#IVotes-VotesExpiredSignature-uint256-) -#### IERC6372 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### ERC721 [!toc] -#### IERC721Errors [!toc] + +
+
+IERC721Errors + - [ERC721InvalidOwner(owner)](#IERC721Errors-ERC721InvalidOwner-address-) - [ERC721NonexistentToken(tokenId)](#IERC721Errors-ERC721NonexistentToken-uint256-) - [ERC721IncorrectOwner(sender, tokenId, owner)](#IERC721Errors-ERC721IncorrectOwner-address-uint256-address-) @@ -2737,10 +2772,8 @@ the votes in governance decisions, or they can delegate to themselves to be thei - [ERC721InsufficientApproval(operator, tokenId)](#IERC721Errors-ERC721InsufficientApproval-address-uint256-) - [ERC721InvalidApprover(approver)](#IERC721Errors-ERC721InvalidApprover-address-) - [ERC721InvalidOperator(operator)](#IERC721Errors-ERC721InvalidOperator-address-) -#### IERC721Metadata [!toc] -#### IERC721 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -2832,8 +2865,9 @@ the wrapping of an existing "basic" ERC-721 into a governance token. - [onERC721Received(, from, tokenId, )](#ERC721Wrapper-onERC721Received-address-address-uint256-bytes-) - [_recover(account, tokenId)](#ERC721Wrapper-_recover-address-uint256-) - [underlying()](#ERC721Wrapper-underlying--) -#### IERC721Receiver [!toc] -#### ERC721 [!toc] +
+ERC721 + - [supportsInterface(interfaceId)](#ERC721-supportsInterface-bytes4-) - [balanceOf(owner)](#ERC721-balanceOf-address-) - [ownerOf(tokenId)](#ERC721-ownerOf-uint256-) @@ -2865,27 +2899,22 @@ the wrapping of an existing "basic" ERC-721 into a governance token. - [_approve(to, tokenId, auth, emitEvent)](#ERC721-_approve-address-uint256-address-bool-) - [_setApprovalForAll(owner, operator, approved)](#ERC721-_setApprovalForAll-address-address-bool-) - [_requireOwned(tokenId)](#ERC721-_requireOwned-uint256-) -#### IERC721Errors [!toc] -#### IERC721Metadata [!toc] -#### IERC721 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +

Events

-#### IERC721Receiver [!toc] -#### ERC721 [!toc] -#### IERC721Errors [!toc] -#### IERC721Metadata [!toc] -#### IERC721 [!toc] +
+IERC721 + - [Transfer(from, to, tokenId)](#IERC721-Transfer-address-address-uint256-) - [Approval(owner, approved, tokenId)](#IERC721-Approval-address-address-uint256-) - [ApprovalForAll(owner, operator, approved)](#IERC721-ApprovalForAll-address-address-bool-) -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -2893,9 +2922,9 @@ the wrapping of an existing "basic" ERC-721 into a governance token.

Errors

- [ERC721UnsupportedToken(token)](#ERC721Wrapper-ERC721UnsupportedToken-address-) -#### IERC721Receiver [!toc] -#### ERC721 [!toc] -#### IERC721Errors [!toc] +
+IERC721Errors + - [ERC721InvalidOwner(owner)](#IERC721Errors-ERC721InvalidOwner-address-) - [ERC721NonexistentToken(tokenId)](#IERC721Errors-ERC721NonexistentToken-uint256-) - [ERC721IncorrectOwner(sender, tokenId, owner)](#IERC721Errors-ERC721IncorrectOwner-address-uint256-address-) @@ -2904,10 +2933,8 @@ the wrapping of an existing "basic" ERC-721 into a governance token. - [ERC721InsufficientApproval(operator, tokenId)](#IERC721Errors-ERC721InsufficientApproval-address-uint256-) - [ERC721InvalidApprover(approver)](#IERC721Errors-ERC721InvalidApprover-address-) - [ERC721InvalidOperator(operator)](#IERC721Errors-ERC721InvalidOperator-address-) -#### IERC721Metadata [!toc] -#### IERC721 [!toc] -#### ERC165 [!toc] -#### IERC165 [!toc] + +
@@ -3062,7 +3089,9 @@ See https://eips.ethereum.org/EIPS/eip-721 - [totalSupply()](#IERC721Enumerable-totalSupply--) - [tokenOfOwnerByIndex(owner, index)](#IERC721Enumerable-tokenOfOwnerByIndex-address-uint256-) - [tokenByIndex(index)](#IERC721Enumerable-tokenByIndex-uint256-) -#### IERC721 [!toc] +
+IERC721 + - [balanceOf(owner)](#IERC721-balanceOf-address-) - [ownerOf(tokenId)](#IERC721-ownerOf-uint256-) - [safeTransferFrom(from, to, tokenId, data)](#IERC721-safeTransferFrom-address-address-uint256-bytes-) @@ -3072,19 +3101,28 @@ See https://eips.ethereum.org/EIPS/eip-721 - [setApprovalForAll(operator, approved)](#IERC721-setApprovalForAll-address-bool-) - [getApproved(tokenId)](#IERC721-getApproved-uint256-) - [isApprovedForAll(owner, operator)](#IERC721-isApprovedForAll-address-address-) -#### IERC165 [!toc] + +
+
+IERC165 + - [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) + +

Events

-#### IERC721 [!toc] +
+IERC721 + - [Transfer(from, to, tokenId)](#IERC721-Transfer-address-address-uint256-) - [Approval(owner, approved, tokenId)](#IERC721-Approval-address-address-uint256-) - [ApprovalForAll(owner, operator, approved)](#IERC721-ApprovalForAll-address-address-bool-) -#### IERC165 [!toc] + +
@@ -3165,7 +3203,9 @@ See https://eips.ethereum.org/EIPS/eip-721 - [name()](#IERC721Metadata-name--) - [symbol()](#IERC721Metadata-symbol--) - [tokenURI(tokenId)](#IERC721Metadata-tokenURI-uint256-) -#### IERC721 [!toc] +
+IERC721 + - [balanceOf(owner)](#IERC721-balanceOf-address-) - [ownerOf(tokenId)](#IERC721-ownerOf-uint256-) - [safeTransferFrom(from, to, tokenId, data)](#IERC721-safeTransferFrom-address-address-uint256-bytes-) @@ -3175,19 +3215,28 @@ See https://eips.ethereum.org/EIPS/eip-721 - [setApprovalForAll(operator, approved)](#IERC721-setApprovalForAll-address-bool-) - [getApproved(tokenId)](#IERC721-getApproved-uint256-) - [isApprovedForAll(owner, operator)](#IERC721-isApprovedForAll-address-address-) -#### IERC165 [!toc] + +
+
+IERC165 + - [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) + +

Events

-#### IERC721 [!toc] +
+IERC721 + - [Transfer(from, to, tokenId)](#IERC721-Transfer-address-address-uint256-) - [Approval(owner, approved, tokenId)](#IERC721-Approval-address-address-uint256-) - [ApprovalForAll(owner, operator, approved)](#IERC721-ApprovalForAll-address-address-bool-) -#### IERC165 [!toc] + +
@@ -3270,7 +3319,6 @@ Make sure the contract is able to use its token with [`IERC721.safeTransferFrom`

Functions

- [onERC721Received(, , , )](#ERC721Holder-onERC721Received-address-address-uint256-bytes-) -#### IERC721Receiver [!toc]
diff --git a/content/contracts/5.x/api/token/common.mdx b/content/contracts/5.x/api/token/common.mdx index 5985aff5..1f1b5644 100644 --- a/content/contracts/5.x/api/token/common.mdx +++ b/content/contracts/5.x/api/token/common.mdx @@ -52,9 +52,6 @@ voluntarily pay royalties together with sales, but note that this standard is no - [_deleteDefaultRoyalty()](#ERC2981-_deleteDefaultRoyalty--) - [_setTokenRoyalty(tokenId, receiver, feeNumerator)](#ERC2981-_setTokenRoyalty-uint256-address-uint96-) - [_resetTokenRoyalty(tokenId)](#ERC2981-_resetTokenRoyalty-uint256-) -#### ERC165 [!toc] -#### IERC2981 [!toc] -#### IERC165 [!toc] @@ -65,9 +62,6 @@ voluntarily pay royalties together with sales, but note that this standard is no - [ERC2981InvalidDefaultRoyaltyReceiver(receiver)](#ERC2981-ERC2981InvalidDefaultRoyaltyReceiver-address-) - [ERC2981InvalidTokenRoyalty(tokenId, numerator, denominator)](#ERC2981-ERC2981InvalidTokenRoyalty-uint256-uint256-uint256-) - [ERC2981InvalidTokenRoyaltyReceiver(tokenId, receiver)](#ERC2981-ERC2981InvalidTokenRoyaltyReceiver-uint256-address-) -#### ERC165 [!toc] -#### IERC2981 [!toc] -#### IERC165 [!toc] diff --git a/content/contracts/5.x/api/utils.mdx b/content/contracts/5.x/api/utils.mdx index 00dc1578..5f8fe667 100644 --- a/content/contracts/5.x/api/utils.mdx +++ b/content/contracts/5.x/api/utils.mdx @@ -3463,17 +3463,25 @@ Doing so will NOT reset the current state of nonces, avoiding replay attacks whe - [_useNonce(owner, key)](#NoncesKeyed-_useNonce-address-uint192-) - [_useCheckedNonce(owner, keyNonce)](#NoncesKeyed-_useCheckedNonce-address-uint256-) - [_useCheckedNonce(owner, key, nonce)](#NoncesKeyed-_useCheckedNonce-address-uint192-uint64-) -#### Nonces [!toc] +
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) + +

Errors

-#### Nonces [!toc] +
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) + +
@@ -10207,7 +10215,6 @@ function supportsInterface(bytes4 interfaceId) public view virtual override retu

Functions

- [supportsInterface(interfaceId)](#ERC165-supportsInterface-bytes4-) -#### IERC165 [!toc]
diff --git a/content/contracts/5.x/api/utils/cryptography.mdx b/content/contracts/5.x/api/utils/cryptography.mdx index 0f812237..0f496a59 100644 --- a/content/contracts/5.x/api/utils/cryptography.mdx +++ b/content/contracts/5.x/api/utils/cryptography.mdx @@ -448,15 +448,18 @@ separator from the immutable values, which is cheaper than accessing a cached ve - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc]

Events

-#### IERC5267 [!toc] +
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) + +
@@ -2373,7 +2376,6 @@ either front-runnable or unusable. - [_rawSignatureValidation(hash, signature)](#MultiSignerERC7913-_rawSignatureValidation-bytes32-bytes-) - [_validateSignatures(hash, signers, signatures)](#MultiSignerERC7913-_validateSignatures-bytes32-bytes---bytes---) - [_validateThreshold(validatingSigners)](#MultiSignerERC7913-_validateThreshold-bytes---) -#### AbstractSigner [!toc] @@ -2383,7 +2385,6 @@ either front-runnable or unusable. - [ERC7913SignerAdded(signers)](#MultiSignerERC7913-ERC7913SignerAdded-bytes-) - [ERC7913SignerRemoved(signers)](#MultiSignerERC7913-ERC7913SignerRemoved-bytes-) - [ERC7913ThresholdSet(threshold)](#MultiSignerERC7913-ERC7913ThresholdSet-uint64-) -#### AbstractSigner [!toc] @@ -2395,7 +2396,6 @@ either front-runnable or unusable. - [MultiSignerERC7913InvalidSigner(signer)](#MultiSignerERC7913-MultiSignerERC7913InvalidSigner-bytes-) - [MultiSignerERC7913ZeroThreshold()](#MultiSignerERC7913-MultiSignerERC7913ZeroThreshold--) - [MultiSignerERC7913UnreachableThreshold(signers, threshold)](#MultiSignerERC7913-MultiSignerERC7913UnreachableThreshold-uint64-uint64-) -#### AbstractSigner [!toc] @@ -2884,7 +2884,9 @@ least two signers (e.g., one with weight 1 and one with weight 3). See [`MultiSi - [_removeSigners(signers)](#MultiSignerERC7913Weighted-_removeSigners-bytes---) - [_validateReachableThreshold()](#MultiSignerERC7913Weighted-_validateReachableThreshold--) - [_validateThreshold(signers)](#MultiSignerERC7913Weighted-_validateThreshold-bytes---) -#### MultiSignerERC7913 [!toc] +
+MultiSignerERC7913 + - [getSigners(start, end)](#MultiSignerERC7913-getSigners-uint64-uint64-) - [getSignerCount()](#MultiSignerERC7913-getSignerCount--) - [isSigner(signer)](#MultiSignerERC7913-isSigner-bytes-) @@ -2892,7 +2894,8 @@ least two signers (e.g., one with weight 1 and one with weight 3). See [`MultiSi - [_setThreshold(newThreshold)](#MultiSignerERC7913-_setThreshold-uint64-) - [_rawSignatureValidation(hash, signature)](#MultiSignerERC7913-_rawSignatureValidation-bytes32-bytes-) - [_validateSignatures(hash, signers, signatures)](#MultiSignerERC7913-_validateSignatures-bytes32-bytes---bytes---) -#### AbstractSigner [!toc] + +
@@ -2900,11 +2903,14 @@ least two signers (e.g., one with weight 1 and one with weight 3). See [`MultiSi

Events

- [ERC7913SignerWeightChanged(signer, weight)](#MultiSignerERC7913Weighted-ERC7913SignerWeightChanged-bytes-uint64-) -#### MultiSignerERC7913 [!toc] +
+MultiSignerERC7913 + - [ERC7913SignerAdded(signers)](#MultiSignerERC7913-ERC7913SignerAdded-bytes-) - [ERC7913SignerRemoved(signers)](#MultiSignerERC7913-ERC7913SignerRemoved-bytes-) - [ERC7913ThresholdSet(threshold)](#MultiSignerERC7913-ERC7913ThresholdSet-uint64-) -#### AbstractSigner [!toc] + +
@@ -2913,13 +2919,16 @@ least two signers (e.g., one with weight 1 and one with weight 3). See [`MultiSi
- [MultiSignerERC7913WeightedInvalidWeight(signer, weight)](#MultiSignerERC7913Weighted-MultiSignerERC7913WeightedInvalidWeight-bytes-uint64-) - [MultiSignerERC7913WeightedMismatchedLength()](#MultiSignerERC7913Weighted-MultiSignerERC7913WeightedMismatchedLength--) -#### MultiSignerERC7913 [!toc] +
+MultiSignerERC7913 + - [MultiSignerERC7913AlreadyExists(signer)](#MultiSignerERC7913-MultiSignerERC7913AlreadyExists-bytes-) - [MultiSignerERC7913NonexistentSigner(signer)](#MultiSignerERC7913-MultiSignerERC7913NonexistentSigner-bytes-) - [MultiSignerERC7913InvalidSigner(signer)](#MultiSignerERC7913-MultiSignerERC7913InvalidSigner-bytes-) - [MultiSignerERC7913ZeroThreshold()](#MultiSignerERC7913-MultiSignerERC7913ZeroThreshold--) - [MultiSignerERC7913UnreachableThreshold(signers, threshold)](#MultiSignerERC7913-MultiSignerERC7913UnreachableThreshold-uint64-uint64-) -#### AbstractSigner [!toc] + +
@@ -3191,7 +3200,6 @@ or during initialization (if used as a clone) may leave the signer either front- - [_setSigner(signerAddr)](#SignerECDSA-_setSigner-address-) - [signer()](#SignerECDSA-signer--) - [_rawSignatureValidation(hash, signature)](#SignerECDSA-_rawSignatureValidation-bytes32-bytes-) -#### AbstractSigner [!toc] @@ -3293,7 +3301,6 @@ Implementation of [`AbstractSigner`](#AbstractSigner) for implementation for an

Functions

- [_rawSignatureValidation(hash, signature)](#SignerEIP7702-_rawSignatureValidation-bytes32-bytes-) -#### AbstractSigner [!toc]
@@ -3364,7 +3371,6 @@ or during initialization (if used as a clone) may leave the signer either front- - [signer()](#SignerERC7913-signer--) - [_setSigner(signer_)](#SignerERC7913-_setSigner-bytes-) - [_rawSignatureValidation(hash, signature)](#SignerERC7913-_rawSignatureValidation-bytes32-bytes-) -#### AbstractSigner [!toc] @@ -3478,7 +3484,6 @@ or during initialization (if used as a clone) may leave the signer either front- - [_setSigner(qx, qy)](#SignerP256-_setSigner-bytes32-bytes32-) - [signer()](#SignerP256-signer--) - [_rawSignatureValidation(hash, signature)](#SignerP256-_rawSignatureValidation-bytes32-bytes-) -#### AbstractSigner [!toc] @@ -3486,7 +3491,6 @@ or during initialization (if used as a clone) may leave the signer either front-

Errors

- [SignerP256InvalidPublicKey(qx, qy)](#SignerP256-SignerP256InvalidPublicKey-bytes32-bytes32-) -#### AbstractSigner [!toc]
@@ -3622,7 +3626,6 @@ or during initialization (if used as a clone) may leave the signer either front- - [_setSigner(e, n)](#SignerRSA-_setSigner-bytes-bytes-) - [signer()](#SignerRSA-signer--) - [_rawSignatureValidation(hash, signature)](#SignerRSA-_rawSignatureValidation-bytes32-bytes-) -#### AbstractSigner [!toc] @@ -3743,19 +3746,25 @@ or during initialization (if used as a clone) may leave the signer either front-

Functions

- [_rawSignatureValidation(hash, signature)](#SignerWebAuthn-_rawSignatureValidation-bytes32-bytes-) -#### SignerP256 [!toc] +
+SignerP256 + - [_setSigner(qx, qy)](#SignerP256-_setSigner-bytes32-bytes32-) - [signer()](#SignerP256-signer--) -#### AbstractSigner [!toc] + +

Errors

-#### SignerP256 [!toc] +
+SignerP256 + - [SignerP256InvalidPublicKey(qx, qy)](#SignerP256-SignerP256InvalidPublicKey-bytes32-bytes32-) -#### AbstractSigner [!toc] + +
@@ -3813,27 +3822,34 @@ which may limit the ability of the signer to be used within the ERC-4337 validat

Functions

- [isValidSignature(hash, signature)](#ERC7739-isValidSignature-bytes32-bytes-) -#### IERC1271 [!toc] -#### EIP712 [!toc] +
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### AbstractSigner [!toc] + +
+
+AbstractSigner + - [_rawSignatureValidation(hash, signature)](#AbstractSigner-_rawSignatureValidation-bytes32-bytes-) + +

Events

-#### IERC1271 [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] +
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### AbstractSigner [!toc] + +
@@ -3883,7 +3899,6 @@ ERC-7913 signature verifier that support P256 (secp256r1) keys.

Functions

- [verify(key, hash, signature)](#ERC7913P256Verifier-verify-bytes-bytes32-bytes-) -#### IERC7913SignatureVerifier [!toc]
@@ -3932,7 +3947,6 @@ ERC-7913 signature verifier that support RSA keys.

Functions

- [verify(key, hash, signature)](#ERC7913RSAVerifier-verify-bytes-bytes32-bytes-) -#### IERC7913SignatureVerifier [!toc]
@@ -3992,7 +4006,6 @@ Wallets that may require default P256 validation may install a P256 verifier sep

Functions

- [verify(key, hash, signature)](#ERC7913WebAuthnVerifier-verify-bytes-bytes32-bytes-) -#### IERC7913SignatureVerifier [!toc]
diff --git a/docgen/templates-md/contract.hbs b/docgen/templates-md/contract.hbs index 7ba72057..1e5112b8 100644 --- a/docgen/templates-md/contract.hbs +++ b/docgen/templates-md/contract.hbs @@ -33,12 +33,22 @@ import "@openzeppelin/{{__item_context.file.absolutePath}}";

Functions

{{#each inherited-functions}} -{{#unless @first}} -#### {{contract.name}} [!toc] -{{/unless}} +{{#if @first}} {{#each functions}} - [{{{name}}}({{names params}})](#{{anchor}}) {{/each}} +{{else}} +{{#if functions}} +
+{{contract.name}} + +{{#each functions}} +- [{{{name}}}({{names params}})](#{{anchor}}) +{{/each}} + +
+{{/if}} +{{/if}} {{/each}}
@@ -49,12 +59,22 @@ import "@openzeppelin/{{__item_context.file.absolutePath}}";

Events

{{#each inheritance}} -{{#unless @first}} -#### {{name}} [!toc] -{{/unless}} +{{#if @first}} {{#each events}} - [{{{name}}}({{names params}})](#{{anchor}}) {{/each}} +{{else}} +{{#if events}} +
+{{name}} + +{{#each events}} +- [{{{name}}}({{names params}})](#{{anchor}}) +{{/each}} + +
+{{/if}} +{{/if}} {{/each}}
@@ -65,12 +85,22 @@ import "@openzeppelin/{{__item_context.file.absolutePath}}";

Errors

{{#each inheritance}} -{{#unless @first}} -#### {{name}} [!toc] -{{/unless}} +{{#if @first}} +{{#each errors}} +- [{{{name}}}({{names params}})](#{{anchor}}) +{{/each}} +{{else}} +{{#if errors}} +
+{{name}} + {{#each errors}} - [{{{name}}}({{names params}})](#{{anchor}}) {{/each}} + +
+{{/if}} +{{/if}} {{/each}}
From c14adacc73dda21d142a79920a1399ae2570bbe3 Mon Sep 17 00:00:00 2001 From: stevep0z <255929980+stevep0z@users.noreply.github.com> Date: Thu, 2 Apr 2026 14:27:51 -0500 Subject: [PATCH 04/11] feat: add template injection to generate-api-docs.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The script now injects canonical MDX templates from docgen/templates-md/ into the cloned source repo before running docgen. This means source repos don't need to have MDX templates committed — the docs monorepo is the single source of truth. - Copies templates-md/ and config-md.js into cloned repo - Customizes API_DOCS_PATH, GitHub link, and import path per source repo - Patches hardhat config to use config-md - Overwrites config.js so prepare-docs.sh scripts still work - Handles local paths, broken symlinks, both .js and .ts hardhat configs - Adds --skip-template-inject flag for repos that already have MDX templates --- scripts/generate-api-docs.js | 202 +++++++++++++++++++++++++++-------- 1 file changed, 158 insertions(+), 44 deletions(-) diff --git a/scripts/generate-api-docs.js b/scripts/generate-api-docs.js index d7c41c62..60ea22a2 100755 --- a/scripts/generate-api-docs.js +++ b/scripts/generate-api-docs.js @@ -3,17 +3,23 @@ import { promises as fs } from "node:fs"; import path from "node:path"; import { execSync } from "node:child_process"; +import { fileURLToPath } from "node:url"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const DOCGEN_DIR = path.join(__dirname, "..", "docgen"); // Parse command line arguments function parseArgs() { const args = process.argv.slice(2); const options = { contractsRepo: - "https://github.com/stevedylandev/openzeppelin-contracts.git", + "https://github.com/OpenZeppelin/openzeppelin-contracts.git", contractsBranch: "master", tempDir: "temp-contracts", apiOutputDir: "content/contracts/5.x/api", examplesOutputDir: "examples", + skipTemplateInject: false, }; for (let i = 0; i < args.length; i++) { @@ -44,6 +50,9 @@ function parseArgs() { case "-e": options.examplesOutputDir = args[++i]; break; + case "--skip-template-inject": + options.skipTemplateInject = true; + break; default: console.error(`Unknown option: ${arg}`); showHelp(); @@ -61,20 +70,134 @@ Generate OpenZeppelin Contracts API documentation Usage: node generate-api-docs.js [options] Options: - -r, --repo Contracts repository URL (default: https://github.com/OpenZeppelin/openzeppelin-contracts.git) + -r, --repo Contracts repository URL or local path -b, --branch Contracts repository branch (default: master) -t, --temp-dir Temporary directory for cloning (default: temp-contracts) - -a, --api-output API documentation output directory (default: content/contracts/v5.x/api) + -a, --api-output API documentation output directory (default: content/contracts/5.x/api) -e, --examples-output Examples output directory (default: examples) + --skip-template-inject Skip injecting canonical templates (use source repo's own) -h, --help Show this help message Examples: - node generate-api-docs.js - node generate-api-docs.js --repo https://github.com/myorg/contracts.git --branch v4.0 - node generate-api-docs.js --api-output content/contracts/v4.x/api --examples-output examples-v4 + node generate-api-docs.js --repo https://github.com/OpenZeppelin/openzeppelin-contracts.git --branch master + node generate-api-docs.js --repo /path/to/local/repo --api-output content/community-contracts/api `); } +// Extract GitHub org/repo from a repo URL or path +function extractRepoInfo(repoPath) { + // Handle GitHub URLs + const githubMatch = repoPath.match( + /github\.com\/([^/]+)\/([^/.]+)/, + ); + if (githubMatch) { + return { org: githubMatch[1], repo: githubMatch[2] }; + } + // Handle local paths - extract from directory name + const dirName = path.basename(repoPath.replace(/\/+$/, "")); + return { org: "OpenZeppelin", repo: dirName }; +} + +// Derive the npm package name from the repo name +function derivePackageName(repoName) { + // openzeppelin-contracts -> @openzeppelin/contracts + // openzeppelin-community-contracts -> @openzeppelin/community-contracts + // openzeppelin-confidential-contracts -> @openzeppelin/confidential-contracts + const withoutPrefix = repoName.replace(/^openzeppelin-/, ""); + return withoutPrefix; +} + +async function injectTemplates(tempDir, options) { + const { contractsRepo, apiOutputDir } = options; + const repoInfo = extractRepoInfo(contractsRepo); + const packageName = derivePackageName(repoInfo.repo); + + console.log("📋 Injecting canonical MDX templates..."); + + const templatesTarget = path.join(tempDir, "docs", "templates-md"); + const configTarget = path.join(tempDir, "docs", "config-md.js"); + + // Copy canonical templates + await fs.mkdir(templatesTarget, { recursive: true }); + await copyDirRecursive( + path.join(DOCGEN_DIR, "templates-md"), + templatesTarget, + ); + + // Copy canonical config (as config-md.js and also overwrite config.js + // so prepare-docs.sh scripts that read config.js directly still work) + await fs.copyFile(path.join(DOCGEN_DIR, "config-md.js"), configTarget); + const configJsTarget = path.join(tempDir, "docs", "config.js"); + await fs.copyFile(path.join(DOCGEN_DIR, "config-md.js"), configJsTarget); + + // Customize API_DOCS_PATH in helpers.js + // API_DOCS_PATH is the URL path (strip content/ prefix from the file path) + const apiDocsPath = apiOutputDir.replace(/^content\//, ""); + const helpersPath = path.join(templatesTarget, "helpers.js"); + let helpers = await fs.readFile(helpersPath, "utf8"); + helpers = helpers.replace( + /const API_DOCS_PATH = '[^']+'/, + `const API_DOCS_PATH = '${apiDocsPath}'`, + ); + await fs.writeFile(helpersPath, helpers, "utf8"); + console.log(` ✓ API_DOCS_PATH set to '${apiDocsPath}'`); + + // Customize GitHub link and import path in contract.hbs + const contractPath = path.join(templatesTarget, "contract.hbs"); + let contract = await fs.readFile(contractPath, "utf8"); + + // Update GitHub link: just replace the org/repo part, keep v{{oz-version}} for versioned repos + contract = contract.replace( + /OpenZeppelin\/openzeppelin-contracts/g, + `${repoInfo.org}/${repoInfo.repo}`, + ); + + // Update import path: the canonical template has @openzeppelin/{{absolutePath}} + // where absolutePath starts with "contracts/...". For the main contracts repo + // this produces @openzeppelin/contracts/token/... which is correct. + // For community-contracts, we need @openzeppelin/community-contracts/contracts/token/... + // So only patch if the package name isn't just "contracts" + if (packageName !== "contracts") { + contract = contract.replace( + /import "@openzeppelin\/\{\{/, + `import "@openzeppelin/${packageName}/{{`, + ); + } + await fs.writeFile(contractPath, contract, "utf8"); + console.log( + ` ✓ GitHub link set to ${repoInfo.org}/${repoInfo.repo}`, + ); + console.log( + ` ✓ Import path set to @openzeppelin/${packageName}/`, + ); + + // Patch hardhat config to use config-md + const hardhatConfigPaths = [ + path.join(tempDir, "hardhat.config.js"), + path.join(tempDir, "hardhat.config.ts"), + ]; + + for (const configPath of hardhatConfigPaths) { + try { + let config = await fs.readFile(configPath, "utf8"); + if (config.includes("require('./docs/config')")) { + config = config.replace( + "require('./docs/config')", + "require('./docs/config-md')", + ); + await fs.writeFile(configPath, config, "utf8"); + console.log(` ✓ Patched ${path.basename(configPath)} to use config-md`); + } else if (config.includes("require('./docs/config-md')")) { + console.log( + ` ✓ ${path.basename(configPath)} already uses config-md`, + ); + } + } catch { + // Config file doesn't exist, skip + } + } +} + async function generateApiDocs(options) { const { contractsRepo, @@ -82,6 +205,7 @@ async function generateApiDocs(options) { tempDir, apiOutputDir, examplesOutputDir, + skipTemplateInject, } = options; console.log("🔄 Generating OpenZeppelin Contracts API documentation..."); @@ -109,15 +233,20 @@ async function generateApiDocs(options) { // Create output directory await fs.mkdir(apiOutputDir, { recursive: true }); - // Clone the contracts repository + // Clone the contracts repository (works for both URLs and local paths) console.log("📦 Cloning contracts repository..."); execSync( - `git clone --depth 1 --revision "${contractsBranch}" --recurse-submodules "${contractsRepo}" "${tempDir}"`, + `git clone --depth 1 --branch "${contractsBranch}" --recurse-submodules "${contractsRepo}" "${tempDir}"`, { stdio: "inherit", }, ); + // Inject canonical templates if not skipped + if (!skipTemplateInject) { + await injectTemplates(tempDir, options); + } + // Navigate to contracts directory and install dependencies console.log("📚 Installing dependencies..."); const originalDir = process.cwd(); @@ -126,11 +255,11 @@ async function generateApiDocs(options) { try { execSync("npm install --silent", { stdio: "inherit" }); - // Generate markdown documentation - console.log("🏗️ Generating clean markdown documentation..."); + // Generate MDX documentation + console.log("🏗️ Generating MDX documentation..."); execSync("npm run prepare-docs", { stdio: "inherit" }); - // Copy generated markdown files + // Copy generated files console.log("📋 Copying generated documentation..."); const docsPath = path.join("docs", "modules", "api", "pages"); @@ -143,7 +272,7 @@ async function generateApiDocs(options) { console.log(`✅ API documentation copied to ${apiOutputDir}`); } catch (error) { console.log( - "❌ Error: Markdown documentation not found at expected location", + "❌ Error: Documentation not found at expected location", ); process.exit(1); } @@ -164,32 +293,6 @@ async function generateApiDocs(options) { ); console.log(`✅ Examples copied to ${examplesOutputDir}`); } - - // Get version for index file - let version = "latest"; - try { - const packageJson = JSON.parse( - await fs.readFile("package.json", "utf8"), - ); - version = packageJson.version || version; - } catch (error) { - console.log("⚠️ Could not read package.json for version info"); - } - - // Generate index file - // console.log("📝 Generating API index..."); - // const indexContent = `--- - // title: API Reference - // --- - - // # API Reference - // `; - - // await fs.writeFile( - // path.join(originalDir, apiOutputDir, "index.mdx"), - // indexContent, - // "utf8", - // ); } finally { // Go back to original directory process.chdir(originalDir); @@ -207,10 +310,6 @@ async function generateApiDocs(options) { console.log("🎉 API documentation generation complete!"); console.log(`📂 Documentation available in: ${apiOutputDir}`); - console.log(""); - console.log("Next steps:"); - console.log(` - Review generated markdown files in ${apiOutputDir}`); - console.log(" - Update the api/index.mdx file with your TOC"); } catch (error) { console.error("❌ Error generating API documentation:", error.message); process.exit(1); @@ -218,14 +317,29 @@ async function generateApiDocs(options) { } async function copyDirRecursive(src, dest) { + await fs.mkdir(dest, { recursive: true }); const entries = await fs.readdir(src, { withFileTypes: true }); for (const entry of entries) { const srcPath = path.join(src, entry.name); const destPath = path.join(dest, entry.name); - if (entry.isDirectory()) { - await fs.mkdir(destPath, { recursive: true }); + if (entry.isSymbolicLink()) { + // Resolve symlink and copy the target; skip broken symlinks + try { + const realPath = await fs.realpath(srcPath); + const stat = await fs.stat(realPath); + if (stat.isDirectory()) { + await copyDirRecursive(realPath, destPath); + } else { + await fs.copyFile(realPath, destPath); + } + } catch { + // Broken symlink, skip + } + } else if (entry.isDirectory()) { + // Skip node_modules and .git when copying local repos + if (entry.name === "node_modules" || entry.name === ".git") continue; await copyDirRecursive(srcPath, destPath); } else { await fs.copyFile(srcPath, destPath); From 5ac92e2c1756ec2702b756201f5776e1c160aaf4 Mon Sep 17 00:00:00 2001 From: stevep0z <255929980+stevep0z@users.noreply.github.com> Date: Thu, 2 Apr 2026 15:08:06 -0500 Subject: [PATCH 05/11] docs: regenerate all API references using updated script Regenerated via generate-api-docs.js with template injection for: - openzeppelin-contracts (master) -> content/contracts/5.x/api/ - openzeppelin-community-contracts (master) -> content/community-contracts/api/ - openzeppelin-confidential-contracts (master) -> content/confidential-contracts/api/ All repos: 0 link errors, clean build. --- content/community-contracts/api/access.mdx | 6 +- content/community-contracts/api/account.mdx | 142 +- .../community-contracts/api/crosschain.mdx | 24 +- .../community-contracts/api/governance.mdx | 10 +- .../community-contracts/api/interfaces.mdx | 24 +- content/community-contracts/api/proxy.mdx | 10 +- content/community-contracts/api/token.mdx | 54 +- content/community-contracts/api/utils.mdx | 34 +- .../api/utils/cryptography.mdx | 32 +- .../confidential-contracts/api/finance.mdx | 943 +++- .../confidential-contracts/api/governance.mdx | 59 +- .../confidential-contracts/api/interfaces.mdx | 299 +- content/confidential-contracts/api/token.mdx | 813 ++- content/confidential-contracts/api/utils.mdx | 742 +-- content/contracts/5.x/api/access.mdx | 328 +- content/contracts/5.x/api/crosschain.mdx | 205 - content/contracts/5.x/api/interfaces.mdx | 4810 ++++++++--------- content/contracts/5.x/api/proxy.mdx | 834 +-- content/contracts/5.x/api/token/ERC20.mdx | 3476 ++++++------ content/contracts/5.x/api/utils.mdx | 1636 +++--- examples/AccessManagerEnumerable.sol | 161 + examples/ERC4626Fees.sol | 4 +- examples/account/MyAccountEIP7702.sol | 20 + examples/account/MyFactoryAccount.sol | 22 +- .../crosschain/MyERC7786GatewaySource.sol | 2 +- 25 files changed, 7669 insertions(+), 7021 deletions(-) create mode 100644 examples/AccessManagerEnumerable.sol create mode 100644 examples/account/MyAccountEIP7702.sol diff --git a/content/community-contracts/api/access.mdx b/content/community-contracts/api/access.mdx index 4594dfc6..3280f887 100644 --- a/content/community-contracts/api/access.mdx +++ b/content/community-contracts/api/access.mdx @@ -5,7 +5,7 @@ description: "Smart contract access utilities and implementations" This directory contains utility contracts to restrict access control in smart contracts. These include: -- [`AccessManagerLight`](#AccessManagerLight): A simpler version of an AccessManager that uses `bytes8` roles to allow function calls identified by their 4-bytes selector. +* [`AccessManagerLight`](#AccessManagerLight): A simpler version of an AccessManager that uses `bytes8` roles to allow function calls identified by their 4-bytes selector. ## AccessManager @@ -17,14 +17,14 @@ This directory contains utility contracts to restrict access control in smart co ## `AccessManagerLight` - + ```solidity -import "@openzeppelin/contracts/access/manager/AccessManagerLight.sol"; +import "@openzeppelin/community-contracts/contracts/access/manager/AccessManagerLight.sol"; ``` Light version of an AccessManager contract that defines `bytes8` roles diff --git a/content/community-contracts/api/account.mdx b/content/community-contracts/api/account.mdx index 3d969298..bc1f6c66 100644 --- a/content/community-contracts/api/account.mdx +++ b/content/community-contracts/api/account.mdx @@ -5,20 +5,20 @@ description: "Smart contract account utilities and implementations" This directory includes contracts to build accounts for ERC-4337. These include: -- [`ERC7579Executor`](#ERC7579Executor): An executor module that enables executing calls from accounts where the it's installed. -- [`ERC7579DelayedExecutor`](#ERC7579DelayedExecutor): An executor module that adds a delay before executing an account operation. -- [`ERC7579SelectorExecutor`](#ERC7579SelectorExecutor): An executor module that restricts execution to specific function selectors. -- [`ERC7579Validator`](#ERC7579Validator): Abstract validator module for ERC-7579 accounts that provides base implementation for signature validation. -- [`ERC7579Signature`](#ERC7579Signature): Implementation of [`ERC7579Validator`](#ERC7579Validator) using ERC-7913 signature verification for address-less cryptographic keys and account signatures. -- [`ERC7579Multisig`](#ERC7579Multisig): An extension of [`ERC7579Validator`](#ERC7579Validator) that enables validation using ERC-7913 signer keys. -- [`ERC7579MultisigWeighted`](#ERC7579MultisigWeighted): An extension of [`ERC7579Multisig`](#ERC7579Multisig) that allows different weights to be assigned to signers. -- [`ERC7579MultisigConfirmation`](#ERC7579MultisigConfirmation): An extension of [`ERC7579Multisig`](#ERC7579Multisig) that requires each signer to provide a confirmation signature. -- [`ERC7579MultisigStorage`](#ERC7579MultisigStorage): An extension of [`ERC7579Multisig`](#ERC7579Multisig) that allows storing presigned approvals in storage. -- [`PaymasterCore`](#PaymasterCore): An ERC-4337 paymaster implementation that includes the core logic to validate and pay for user operations. -- [`PaymasterERC20`](#PaymasterERC20): A paymaster that allows users to pay for user operations using ERC-20 tokens. -- [`PaymasterERC20Guarantor`](#PaymasterERC20Guarantor): A paymaster that enables third parties to guarantee user operations by pre-funding gas costs, with the option for users to repay or for guarantors to absorb the cost. -- [`PaymasterERC721Owner`](#PaymasterERC721Owner): A paymaster that allows users to pay for user operations based on ERC-721 ownership. -- [`PaymasterSigner`](#PaymasterSigner): A paymaster that allows users to pay for user operations using an authorized signature. +* [`ERC7579Executor`](#ERC7579Executor): An executor module that enables executing calls from accounts where the it’s installed. +* [`ERC7579DelayedExecutor`](#ERC7579DelayedExecutor): An executor module that adds a delay before executing an account operation. +* [`ERC7579SelectorExecutor`](#ERC7579SelectorExecutor): An executor module that restricts execution to specific function selectors. +* [`ERC7579Validator`](#ERC7579Validator): Abstract validator module for ERC-7579 accounts that provides base implementation for signature validation. +* [`ERC7579Signature`](#ERC7579Signature): Implementation of [`ERC7579Validator`](#ERC7579Validator) using ERC-7913 signature verification for address-less cryptographic keys and account signatures. +* [`ERC7579Multisig`](#ERC7579Multisig): An extension of [`ERC7579Validator`](#ERC7579Validator) that enables validation using ERC-7913 signer keys. +* [`ERC7579MultisigWeighted`](#ERC7579MultisigWeighted): An extension of [`ERC7579Multisig`](#ERC7579Multisig) that allows different weights to be assigned to signers. +* [`ERC7579MultisigConfirmation`](#ERC7579MultisigConfirmation): An extension of [`ERC7579Multisig`](#ERC7579Multisig) that requires each signer to provide a confirmation signature. +* [`ERC7579MultisigStorage`](#ERC7579MultisigStorage): An extension of [`ERC7579Multisig`](#ERC7579Multisig) that allows storing presigned approvals in storage. +* [`PaymasterCore`](#PaymasterCore): An ERC-4337 paymaster implementation that includes the core logic to validate and pay for user operations. +* [`PaymasterERC20`](#PaymasterERC20): A paymaster that allows users to pay for user operations using ERC-20 tokens. +* [`PaymasterERC20Guarantor`](#PaymasterERC20Guarantor): A paymaster that enables third parties to guarantee user operations by pre-funding gas costs, with the option for users to repay or for guarantors to absorb the cost. +* [`PaymasterERC721Owner`](#PaymasterERC721Owner): A paymaster that allows users to pay for user operations based on ERC-721 ownership. +* [`PaymasterSigner`](#PaymasterSigner): A paymaster that allows users to pay for user operations using an authorized signature. ## Modules @@ -62,14 +62,14 @@ This directory includes contracts to build accounts for ERC-4337. These include: ## `ERC7579DelayedExecutor` - + ```solidity -import "@openzeppelin/contracts/account/modules/ERC7579DelayedExecutor.sol"; +import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579DelayedExecutor.sol"; ``` Extension of [`ERC7579Executor`](#ERC7579Executor) that allows scheduling and executing delayed operations @@ -106,8 +106,8 @@ authorization logic, such as requiring specific signers or roles. Use [`ERC7579DelayedExecutor._scheduleAt`](#ERC7579DelayedExecutor-_scheduleAt-address-bytes32-bytes32-bytes-uint48-uint32-) to schedule operations at a specific points in time. This is - useful to pre-schedule operations for non-deployed accounts (e.g. subscriptions). +

Functions

@@ -446,16 +446,16 @@ and respecting the previous delay and expiration values. This function does not clean up scheduled operations. This means operations - could potentially be re-executed if the module is reinstalled later. This is a deliberate design choice for efficiency, but module implementations may want to override this behavior to clear scheduled operations during uninstallation for their specific use cases. + Calling this function directly will remove the expiration ([`ERC7579DelayedExecutor.getExpiration`](#ERC7579DelayedExecutor-getExpiration-address-)) value and - will schedule a reset of the delay ([`ERC7579DelayedExecutor.getDelay`](#ERC7579DelayedExecutor-getDelay-address-)) to `0` for the account. Reinstalling the module will not immediately reset the delay if the delay reset hasn't taken effect yet. +
@@ -476,9 +476,9 @@ Returns `data` as the execution calldata. See [`ERC7579Executor._execute`](#ERC7 This function relies on the operation state validation in [`ERC7579DelayedExecutor._execute`](#ERC7579DelayedExecutor-_execute-address-bytes32-bytes32-bytes-) for - authorization. Extensions of this module should override this function to implement additional validation logic if needed. + @@ -801,14 +801,14 @@ The module is not installed on the account. ## `ERC7579Executor` - + ```solidity -import "@openzeppelin/contracts/account/modules/ERC7579Executor.sol"; +import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579Executor.sol"; ``` Basic implementation for ERC-7579 executor modules that provides execution functionality @@ -821,9 +821,9 @@ derived contracts. This is a simplified executor that directly executes operations without delay or expiration - mechanisms. For a more advanced implementation with time-delayed execution patterns and security features, see [`ERC7579DelayedExecutor`](#ERC7579DelayedExecutor). +

Functions

@@ -915,9 +915,9 @@ Example extension: Pack extra data in the `data` arguments (e.g. a signature) to be used in the - validation process. Calldata can be sliced to extract it and return only the execution calldata. +
@@ -967,14 +967,14 @@ Emitted when an operation is executed. ## `ERC7579Multisig` - + ```solidity -import "@openzeppelin/contracts/account/modules/ERC7579Multisig.sol"; +import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579Multisig.sol"; ``` Implementation of an [`ERC7579Validator`](#ERC7579Validator) that uses ERC-7913 signers for multisignature @@ -1063,8 +1063,8 @@ disabled until they are added later. An account can only call onInstall once. If called directly by the account, - the signer will be set to the provided data. Future installations will behave as a no-op. + @@ -1088,8 +1088,8 @@ See [`ERC7579DelayedExecutor.onUninstall`](#ERC7579DelayedExecutor-onUninstall-b This function has unbounded gas costs and may become uncallable if the set grows too large. - See `EnumerableSet-clear`. + @@ -1112,9 +1112,9 @@ Using `start = 0` and `end = type(uint64).max` will return the entire set of sig 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. + @@ -1537,14 +1537,14 @@ The `threshold` is unreachable given the number of `signers`. ## `ERC7579MultisigConfirmation` - + ```solidity -import "@openzeppelin/contracts/account/modules/ERC7579MultisigConfirmation.sol"; +import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579MultisigConfirmation.sol"; ``` Extension of [`ERC7579Multisig`](#ERC7579Multisig) that requires explicit confirmation signatures @@ -1556,8 +1556,8 @@ consent to be added. Each signer must sign an EIP-712 message to confirm their a Use this module to ensure that all guardians in a social recovery or multisig setup have - explicitly agreed to their roles. +

Functions

@@ -1728,14 +1728,14 @@ Error thrown when a confirmation signature has expired ## `ERC7579MultisigStorage` - +
```solidity -import "@openzeppelin/contracts/account/modules/ERC7579MultisigStorage.sol"; +import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579MultisigStorage.sol"; ``` Extension of [`ERC7579Multisig`](#ERC7579Multisig) that allows storing presigned approvals in storage. @@ -1853,8 +1853,8 @@ signed, otherwise acts as a no-op. Does not check if the signer is authorized for the account. Valid signatures from - invalid signers won't be executable. See [`ERC7579Multisig._validateSignatures`](#ERC7579Multisig-_validateSignatures-address-bytes32-bytes---bytes---) for more details. + @@ -1903,14 +1903,14 @@ Emitted when a signer signs a hash ## `ERC7579MultisigWeighted` - + ```solidity -import "@openzeppelin/contracts/account/modules/ERC7579MultisigWeighted.sol"; +import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579MultisigWeighted.sol"; ``` Extension of [`ERC7579Multisig`](#ERC7579Multisig) that supports weighted signatures. @@ -1928,9 +1928,9 @@ after the time delay has passed. 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 signatures with a total weight of at least 4 (e.g., one with weight 1 and one with weight 3). +

Functions

@@ -2027,8 +2027,8 @@ If weights are not provided but signers are, all signers default to weight 1. An account can only call onInstall once. If called directly by the account, - the signer will be set to the provided data. Future installations will behave as a no-op. +
@@ -2189,10 +2189,10 @@ Override to validate threshold against total weight instead of signer count. 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. + @@ -2214,8 +2214,8 @@ Overrides the base implementation to use weights instead of count. This function intentionally does not call `super._validateThreshold` because the base implementation - assumes each signer has a weight of 1, which is incompatible with this weighted implementation. + @@ -2237,8 +2237,8 @@ Emitted when a signer's weight is changed. Not emitted in [`ERC7579Multisig._addSigners`](#ERC7579Multisig-_addSigners-address-bytes---) or [`ERC7579Multisig._removeSigners`](#ERC7579Multisig-_removeSigners-address-bytes---). Indexers must rely on [`ERC7579Multisig.ERC7913SignerAdded`](#ERC7579Multisig-ERC7913SignerAdded-address-bytes-) - and [`ERC7579Multisig.ERC7913SignerRemoved`](#ERC7579Multisig-ERC7913SignerRemoved-address-bytes-) to index a default weight of 1. See [`ERC7579MultisigWeighted.signerWeight`](#ERC7579MultisigWeighted-signerWeight-address-bytes-). + @@ -2283,14 +2283,14 @@ Thrown when the arrays lengths don't match. ## `ERC7579SelectorExecutor` - + ```solidity -import "@openzeppelin/contracts/account/modules/ERC7579SelectorExecutor.sol"; +import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579SelectorExecutor.sol"; ``` Implementation of an [`ERC7579Executor`](#ERC7579Executor) that allows authorizing specific function selectors @@ -2375,8 +2375,8 @@ Returns the set of authorized selectors for the specified account. This operation copies the entire selectors set to memory, which - can be expensive or may result in unbounded computation. + @@ -2416,8 +2416,8 @@ Clears all selectors. This function has unbounded gas costs and may become uncallable if the set grows too large. - See [`EnumerableSetExtended.clear`](/community-contracts/api/utils#EnumerableSetExtended-clear-struct-EnumerableSetExtended-Bytes32x2Set-). + @@ -2566,14 +2566,14 @@ Error thrown when attempting to execute a non-authorized selector ## `ERC7579Signature` - + ```solidity -import "@openzeppelin/contracts/account/modules/ERC7579Signature.sol"; +import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579Signature.sol"; ``` Implementation of [`ERC7579Validator`](#ERC7579Validator) module using ERC-7913 signature verification. @@ -2654,8 +2654,8 @@ See `IERC7579Module-onInstall`. An account can only call onInstall once. If called directly by the account, - the signer will be set to the provided data. Future installations will behave as a no-op. + @@ -2676,9 +2676,9 @@ See `IERC7579Module-onUninstall`. The signer's key will be removed if the account calls this function, potentially - making the account unusable. As an account operator, make sure to uninstall to a predefined path in your account that properly handles side effects of uninstallation. See `AccountERC7579-uninstallModule`. + @@ -2781,14 +2781,14 @@ Thrown when the signer length is less than 20 bytes. ## `ERC7579Validator` - + ```solidity -import "@openzeppelin/contracts/account/modules/ERC7579Validator.sol"; +import "@openzeppelin/community-contracts/contracts/account/modules/ERC7579Validator.sol"; ``` Abstract validator module for ERC-7579 accounts. @@ -2923,8 +2923,8 @@ Validation algorithm. Validation is a critical security function. Implementations must carefully - handle cryptographic verification to prevent unauthorized access. + @@ -2935,14 +2935,14 @@ handle cryptographic verification to prevent unauthorized access. ## `PaymasterCore` - + ```solidity -import "@openzeppelin/contracts/account/paymaster/PaymasterCore.sol"; +import "@openzeppelin/community-contracts/contracts/account/paymaster/PaymasterCore.sol"; ``` A simple ERC4337 paymaster implementation. This base implementation only includes the minimal logic to validate @@ -2959,8 +2959,8 @@ through the internal functions [`PaymasterCore.deposit`](#PaymasterCore-deposit- See [Paymaster's unstaked reputation rules](https://eips.ethereum.org/EIPS/eip-7562#unstaked-paymasters-reputation-rules) -  for more details on the paymaster's storage access limitations. +

Modifiers

@@ -3126,8 +3126,8 @@ is returned by [`PaymasterCore.validatePaymasterUserOp`](#PaymasterCore-validate The `actualUserOpFeePerGas` is not `tx.gasprice`. A user operation can be bundled with other transactions - making the gas price of the user operation to differ. +
@@ -3281,14 +3281,14 @@ Unauthorized call to the paymaster. ## `PaymasterERC20` - + ```solidity -import "@openzeppelin/contracts/account/paymaster/PaymasterERC20.sol"; +import "@openzeppelin/community-contracts/contracts/account/paymaster/PaymasterERC20.sol"; ``` Extension of [`PaymasterCore`](#PaymasterCore) that enables users to pay gas with ERC-20 tokens. @@ -3402,9 +3402,9 @@ Returns a `prefundContext` that's passed to the [`PaymasterCore._postOp`](#Payma Consider not reverting if the prefund fails when overriding this function. This is to avoid reverting - during the validation phase of the user operation, which may penalize the paymaster's reputation according to ERC-7562 validation rules. + @@ -3427,9 +3427,9 @@ Reverts with [`PaymasterERC20.PaymasterERC20FailedRefund`](#PaymasterERC20-Payma This function may revert after the user operation has been executed without - reverting the user operation itself. Consider implementing a mechanism to handle this case gracefully. + @@ -3601,14 +3601,14 @@ and the `actualAmount` of `token`. ## `PaymasterERC20Guarantor` - + ```solidity -import "@openzeppelin/contracts/account/paymaster/PaymasterERC20Guarantor.sol"; +import "@openzeppelin/community-contracts/contracts/account/paymaster/PaymasterERC20Guarantor.sol"; ``` Extension of [`PaymasterERC20`](#PaymasterERC20) that enables third parties to guarantee user operations. @@ -3737,8 +3737,8 @@ Otherwise, fallback to [`PaymasterERC20._refund`](#PaymasterERC20-_refund-contra For guaranteed user operations where the user paid the `actualGasCost` back, this function - doesn't call `super._refund`. Consider whether there are side effects in the parent contract that need to be executed. + @@ -3759,8 +3759,8 @@ Fetches the guarantor address and validation data from the user operation. Return `address(0)` to disable the guarantor feature. If supported, ensure - explicit consent (e.g., signature verification) to prevent unauthorized use. + @@ -3806,14 +3806,14 @@ Emitted when a user operation identified by `userOpHash` is guaranteed by a `gua ## `PaymasterERC721Owner` - + ```solidity -import "@openzeppelin/contracts/account/paymaster/PaymasterERC721Owner.sol"; +import "@openzeppelin/community-contracts/contracts/account/paymaster/PaymasterERC721Owner.sol"; ``` Extension of [`PaymasterCore`](#PaymasterCore) that supports account based on ownership of an ERC-721 token. @@ -3932,8 +3932,8 @@ Returns the context to be passed to postOp and the validation data. The default `context` is `bytes(0)`. Developers that add a context when overriding this function MUST - also override [`PaymasterCore._postOp`](#PaymasterCore-_postOp-enum-IPaymaster-PostOpMode-bytes-uint256-uint256-) to process the context passed along. + @@ -3962,14 +3962,14 @@ Emitted when the paymaster token is set. ## `PaymasterSigner` - + ```solidity -import "@openzeppelin/contracts/account/paymaster/PaymasterSigner.sol"; +import "@openzeppelin/community-contracts/contracts/account/paymaster/PaymasterSigner.sol"; ``` Extension of [`PaymasterCore`](#PaymasterCore) that adds signature validation. See `SignerECDSA`, `SignerP256` or `SignerRSA`. @@ -4083,8 +4083,8 @@ Returns the context to be passed to postOp and the validation data. The `context` returned is `bytes(0)`. Developers overriding this function MUST - override [`PaymasterCore._postOp`](#PaymasterCore-_postOp-enum-IPaymaster-PostOpMode-bytes-uint256-uint256-) to process the context passed along. + diff --git a/content/community-contracts/api/crosschain.mdx b/content/community-contracts/api/crosschain.mdx index 9bf23c6b..fe69d513 100644 --- a/content/community-contracts/api/crosschain.mdx +++ b/content/community-contracts/api/crosschain.mdx @@ -5,11 +5,11 @@ description: "Smart contract crosschain utilities and implementations" Gateways are contracts that enable cross-chain communication. These can either be a message source or a destination according to ERC-7786. -- [`ERC7786OpenBridge`](#ERC7786OpenBridge): ERC-7786 "N out of M" gateway. Sends a message through M gateways and executes on the destination if N received it. +* [`ERC7786OpenBridge`](#ERC7786OpenBridge): ERC-7786 "N out of M" gateway. Sends a message through M gateways and executes on the destination if N received it. Developers can access interoperability protocols through gateway adapters. The library includes the following gateway adapters: -- [`AxelarGatewayAdapter`](#AxelarGatewayAdapter): ERC-7786 gateway adapter for Axelar. +* [`AxelarGatewayAdapter`](#AxelarGatewayAdapter): ERC-7786 gateway adapter for Axelar. ## Gateways @@ -27,14 +27,14 @@ Developers can access interoperability protocols through gateway adapters. The l ## `ERC7786OpenBridge` - + ```solidity -import "@openzeppelin/contracts/crosschain/ERC7786OpenBridge.sol"; +import "@openzeppelin/community-contracts/contracts/crosschain/ERC7786OpenBridge.sol"; ``` N of M gateway: Sends your message through M independent gateways. It will be delivered to the recipient by an @@ -251,9 +251,9 @@ This function emits: interface requires this function to be payable. Even if we don't expect any value, a gateway may pass - some value for unknown reason. In that case we want to register this gateway having delivered the message and not revert. Any value accrued that way can be recovered by the admin using the [`ERC7786OpenBridge.sweep`](#ERC7786OpenBridge-sweep-address-payable-) function. + @@ -747,14 +747,14 @@ Recovery method in case value is ever received through [`ERC7786OpenBridge.recei ## `AxelarGatewayAdapter` - + ```solidity -import "@openzeppelin/contracts/crosschain/axelar/AxelarGatewayAdapter.sol"; +import "@openzeppelin/community-contracts/contracts/crosschain/axelar/AxelarGatewayAdapter.sol"; ``` Implementation of an ERC-7786 gateway destination adapter for the Axelar Network in dual mode. @@ -764,11 +764,11 @@ workflow into the standard ERC-7786. While both ERC-7786 and Axelar do support non-evm chains, this adaptor does not. This limitation comes from - the translation of the ERC-7930 interoperable address (binary objects -- bytes) to strings. This is necessary because Axelar uses string to represent addresses. For EVM network, this adapter uses a checksum hex string representation. Other networks would require a different encoding. Ideally we would have a single encoding for all networks (could be base58, base64, ...) but Axelar doesn't support that. +

Functions

@@ -1237,14 +1237,14 @@ A chain equivalence has been registered. ## `ERC7786Attributes` - +
```solidity -import "@openzeppelin/contracts/crosschain/utils/ERC7786Attributes.sol"; +import "@openzeppelin/community-contracts/contracts/crosschain/utils/ERC7786Attributes.sol"; ``` Library of helper to parse/process ERC-7786 attributes @@ -1279,14 +1279,14 @@ Parse the `requestRelay(uint256,uint256,address)` (0x4cbb573a) attribute into it ## `WormholeGatewayAdapter` - + ```solidity -import "@openzeppelin/contracts/crosschain/wormhole/WormholeGatewayAdapter.sol"; +import "@openzeppelin/community-contracts/contracts/crosschain/wormhole/WormholeGatewayAdapter.sol"; ``` An ERC-7786 compliant adapter to send and receive messages via Wormhole. diff --git a/content/community-contracts/api/governance.mdx b/content/community-contracts/api/governance.mdx index c8f9ab83..8e5bbda8 100644 --- a/content/community-contracts/api/governance.mdx +++ b/content/community-contracts/api/governance.mdx @@ -5,7 +5,7 @@ description: "Smart contract governance utilities and implementations" This directory includes extensions and utilities for on-chain governance. -* [`TimelockControllerEnumerable`](#TimelockControllerEnumerable): Extension of OpenZeppelin's TimelockController with enumerable operations support. +* [`TimelockControllerEnumerable`](#TimelockControllerEnumerable): Extension of OpenZeppelin’s TimelockController with enumerable operations support. ## Timelock @@ -17,14 +17,14 @@ This directory includes extensions and utilities for on-chain governance. ## `TimelockControllerEnumerable` - + ```solidity -import "@openzeppelin/contracts/governance/TimelockControllerEnumerable.sol"; +import "@openzeppelin/community-contracts/contracts/governance/TimelockControllerEnumerable.sol"; ``` Extends the TimelockController to allow for enumerable operations @@ -235,8 +235,8 @@ Requirements: Return all scheduled operations This is designed for view accessors queried without gas fees. Using it in state-changing - functions may become uncallable if the list grows too large. + @@ -324,8 +324,8 @@ Return the operation with the given id Return all scheduled operation batches This is designed for view accessors queried without gas fees. Using it in state-changing - functions may become uncallable if the list grows too large. + diff --git a/content/community-contracts/api/interfaces.mdx b/content/community-contracts/api/interfaces.mdx index e5f34825..7e85e3d4 100644 --- a/content/community-contracts/api/interfaces.mdx +++ b/content/community-contracts/api/interfaces.mdx @@ -7,8 +7,8 @@ description: "Smart contract interfaces utilities and implementations" These interfaces are available as `.sol` files. These are useful to interact with third party contracts that implement them. -- `IERC7913SignatureVerifier` -- `IERC7943` +* `IERC7913SignatureVerifier` +* `IERC7943` ## Detailed ABI @@ -22,14 +22,14 @@ These interfaces are available as `.sol` files. These are useful to interact wit ## `IERC7786Attributes` - + ```solidity -import "@openzeppelin/contracts/interfaces/IERC7786Attributes.sol"; +import "@openzeppelin/community-contracts/contracts/interfaces/IERC7786Attributes.sol"; ``` Standard attributes for ERC-7786. These attributes may be standardized in different ERCs. @@ -62,14 +62,14 @@ Standard attributes for ERC-7786. These attributes may be standardized in differ ## `IERC7943Fungible` - + ```solidity -import "@openzeppelin/contracts/interfaces/IERC7943.sol"; +import "@openzeppelin/community-contracts/contracts/interfaces/IERC7943.sol"; ```
@@ -273,14 +273,14 @@ This can involve checks like allowlists, blocklists, transfer limits and other p ## `IERC7943NonFungible` - +
```solidity -import "@openzeppelin/contracts/interfaces/IERC7943.sol"; +import "@openzeppelin/community-contracts/contracts/interfaces/IERC7943.sol"; ```
@@ -484,14 +484,14 @@ This can involve checks like allowlists, blocklists, transfer limits and other p ## `IERC7943MultiToken` - +
```solidity -import "@openzeppelin/contracts/interfaces/IERC7943.sol"; +import "@openzeppelin/community-contracts/contracts/interfaces/IERC7943.sol"; ```
@@ -695,14 +695,14 @@ This can involve checks like allowlists, blocklists, transfer limits and other p ## `IDKIMRegistry` - +
```solidity -import "@openzeppelin/contracts/interfaces/IERC7969.sol"; +import "@openzeppelin/community-contracts/contracts/interfaces/IERC7969.sol"; ``` This interface provides a standard way to register and validate DKIM public key hashes onchain diff --git a/content/community-contracts/api/proxy.mdx b/content/community-contracts/api/proxy.mdx index c0d7864b..1cb68017 100644 --- a/content/community-contracts/api/proxy.mdx +++ b/content/community-contracts/api/proxy.mdx @@ -5,7 +5,7 @@ description: "Smart contract proxy utilities and implementations" Variants of proxy patterns, which are contracts that allow to forward a call to an implementation contract by using `delegatecall`. This contracts include: -- [`HybridProxy`](#HybridProxy): An ERC-1967 proxy that uses the implementation slot as a beacon in a way that a user can upgrade to an implementation of their choice. +* [`HybridProxy`](#HybridProxy): An ERC-1967 proxy that uses the implementation slot as a beacon in a way that a user can upgrade to an implementation of their choice. ## General @@ -17,14 +17,14 @@ Variants of proxy patterns, which are contracts that allow to forward a call to ## `HybridProxy` - + ```solidity -import "@openzeppelin/contracts/proxy/HybridProxy.sol"; +import "@openzeppelin/community-contracts/contracts/proxy/HybridProxy.sol"; ``` A version of an ERC-1967 proxy that uses the address stored in the implementation slot as a beacon. @@ -36,9 +36,9 @@ checks that are not compatible with this proxy design. The fallback mechanism relies on the implementation not to define the `IBeacon-implementation` function. - Consider that if your implementation has this function, it'll be assumed as the beacon address, meaning that the returned address will be used as this proxy's implementation. +

Functions

@@ -90,9 +90,9 @@ Returns the current implementation address according to ERC-1967's implementatio The way this function identifies whether the implementation is a beacon, is by checking - if it implements the `IBeacon-implementation` function. Consider that an actual implementation could define this function, mistakenly identifying it as a beacon. +
diff --git a/content/community-contracts/api/token.mdx b/content/community-contracts/api/token.mdx index 5e4e7a87..bb76aa70 100644 --- a/content/community-contracts/api/token.mdx +++ b/content/community-contracts/api/token.mdx @@ -5,12 +5,12 @@ description: "Smart contract token utilities and implementations" Set of extensions and utilities for tokens (e.g ERC-20, ERC-721, ERC-1155) and derivated ERCs (e.g. ERC-4626, ERC-1363). -- [`OnTokenTransferAdapter`](#OnTokenTransferAdapter): Adapter of the ERC-1363 receiver interface to comply with Chainlink's 667 interface. -- [`ERC20Allowlist`](#ERC20Allowlist): Extension of ERC20 with transfers and approvals that require users to be registered into an allowlist. -- [`ERC20Blocklist`](#ERC20Blocklist): Extension of ERC20 with transfers and approvals that can be disabled by adding users into a blocklist. -- [`ERC20Collateral`](#ERC20Collateral): Oracle-agnostic extension of ERC20 that limits the total supply based on a collateral amount. -- [`ERC20Custodian`](#ERC20Custodian): Extension of ERC20 that implements an access-control agnostic approach to define a custodian that can freeze user's transfers and approvals. -- [`ERC4626Fees`](#ERC4626Fees): ERC4626 vault with fees on entry (deposit/mint) or exit (withdraw/redeem). +* [`OnTokenTransferAdapter`](#OnTokenTransferAdapter): Adapter of the ERC-1363 receiver interface to comply with Chainlink’s 667 interface. +* [`ERC20Allowlist`](#ERC20Allowlist): Extension of ERC20 with transfers and approvals that require users to be registered into an allowlist. +* [`ERC20Blocklist`](#ERC20Blocklist): Extension of ERC20 with transfers and approvals that can be disabled by adding users into a blocklist. +* [`ERC20Collateral`](#ERC20Collateral): Oracle-agnostic extension of ERC20 that limits the total supply based on a collateral amount. +* [`ERC20Custodian`](#ERC20Custodian): Extension of ERC20 that implements an access-control agnostic approach to define a custodian that can freeze user’s transfers and approvals. +* [`ERC4626Fees`](#ERC4626Fees): ERC4626 vault with fees on entry (deposit/mint) or exit (withdraw/redeem). ## General @@ -34,14 +34,14 @@ Set of extensions and utilities for tokens (e.g ERC-20, ERC-721, ERC-1155) and d ## `ERC20Allowlist` - + ```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Allowlist.sol"; +import "@openzeppelin/community-contracts/contracts/token/ERC20/extensions/ERC20Allowlist.sol"; ``` Extension of `ERC20` that allows to implement an allowlist @@ -265,14 +265,14 @@ The operation failed because the user is not allowed. ## `ERC20Blocklist` - + ```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Blocklist.sol"; +import "@openzeppelin/community-contracts/contracts/token/ERC20/extensions/ERC20Blocklist.sol"; ``` Extension of `ERC20` that allows to implement a blocklist @@ -496,14 +496,14 @@ The operation failed because the user is blocked. ## `ERC20Collateral` - + ```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Collateral.sol"; +import "@openzeppelin/community-contracts/contracts/token/ERC20/extensions/ERC20Collateral.sol"; ``` Extension of `ERC20` that limits the supply of tokens based @@ -719,14 +719,14 @@ Collateral amount has expired. ## `ERC20Custodian` - + ```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Custodian.sol"; +import "@openzeppelin/community-contracts/contracts/token/ERC20/extensions/ERC20Custodian.sol"; ``` Extension of `ERC20` that allows to implement a custodian @@ -1017,14 +1017,14 @@ Error thrown when a non-custodian account attempts to perform a custodian-only o ## `ERC20Freezable` - + ```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Freezable.sol"; +import "@openzeppelin/community-contracts/contracts/token/ERC20/extensions/ERC20Freezable.sol"; ``` Extension of `ERC20` that allows to implement a freezing @@ -1192,14 +1192,14 @@ The operation failed because the account has insufficient unfrozen balance. ## `ERC20Restricted` - + ```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Restricted.sol"; +import "@openzeppelin/community-contracts/contracts/token/ERC20/extensions/ERC20Restricted.sol"; ``` Extension of `ERC20` that allows to implement user account transfer restrictions @@ -1467,14 +1467,14 @@ The operation failed because the user account is restricted. ## `ERC20uRWA` - + ```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC20uRWA.sol"; +import "@openzeppelin/community-contracts/contracts/token/ERC20/extensions/ERC20uRWA.sol"; ``` Extension of `ERC20` according to [EIP-7943](https://eips.ethereum.org/EIPS/eip-7943). @@ -1666,8 +1666,8 @@ See [`IERC7943Fungible.canTransfer`](/community-contracts/api/interfaces#IERC794 This function is only meant for external use. Overriding it will not apply the new checks to - the internal [`ERC20Allowlist._update`](#ERC20Allowlist-_update-address-address-uint256-) function. Consider overriding [`ERC20Allowlist._update`](#ERC20Allowlist-_update-address-address-uint256-) accordingly to keep both functions in sync. + @@ -1705,8 +1705,8 @@ See [`IERC7943Fungible.setFrozenTokens`](/community-contracts/api/interfaces#IER The `amount` is capped to the balance of the `account` to ensure the [`IERC7943Fungible.Frozen`](/community-contracts/api/interfaces#IERC7943Fungible-Frozen-address-uint256-) event - emits values that consistently reflect the actual amount of tokens that are frozen. + @@ -1730,10 +1730,10 @@ to the new balance after the transfer. This function uses [`ERC20Allowlist._update`](#ERC20Allowlist-_update-address-address-uint256-) to perform the transfer, ensuring all standard ERC20 - side effects (such as balance updates and events) are preserved. If you override [`ERC20Allowlist._update`](#ERC20Allowlist-_update-address-address-uint256-) to add additional restrictions or logic, those changes will also apply here. Consider overriding this function to bypass newer restrictions if needed. + @@ -1811,14 +1811,14 @@ function _checkFreezer(address account, uint256 amount) internal view override o ## `ERC4626Fees` - + ```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC4626Fees.sol"; +import "@openzeppelin/community-contracts/contracts/token/ERC20/extensions/ERC4626Fees.sol"; ``` ERC-4626 vault with entry/exit fees expressed in [basis point (bp)](https://en.wikipedia.org/wiki/Basis_point). @@ -2096,14 +2096,14 @@ Send exit fee to [`ERC4626Fees._exitFeeRecipient`](#ERC4626Fees-_exitFeeRecipien ## `OnTokenTransferAdapter` - + ```solidity -import "@openzeppelin/contracts/token/OnTokenTransferAdapter.sol"; +import "@openzeppelin/community-contracts/contracts/token/OnTokenTransferAdapter.sol"; ``` This contract exposes the 667 `onTokenTransfer` hook on top of `IERC1363Receiver-onTransferReceived`. diff --git a/content/community-contracts/api/utils.mdx b/content/community-contracts/api/utils.mdx index 8993dc5e..4897ad49 100644 --- a/content/community-contracts/api/utils.mdx +++ b/content/community-contracts/api/utils.mdx @@ -5,8 +5,8 @@ description: "Smart contract utils utilities and implementations" Miscellaneous contracts and libraries containing utility functions you can use to improve security, work with new data types, or safely use low-level primitives. -- [`EnumerableSetExtended`](#EnumerableSetExtended) and [`EnumerableMapExtended`](#EnumerableMapExtended): Extensions of the `EnumerableSet` and `EnumerableMap` libraries with more types, including non-value types. -- [`Masks`](#Masks): Library to handle `bytes32` masks. +* [`EnumerableSetExtended`](#EnumerableSetExtended) and [`EnumerableMapExtended`](#EnumerableMapExtended): Extensions of the `EnumerableSet` and `EnumerableMap` libraries with more types, including non-value types. +* [`Masks`](#Masks): Library to handle `bytes32` masks. ## Structs @@ -24,14 +24,14 @@ Miscellaneous contracts and libraries containing utility functions you can use t ## `Masks` - + ```solidity -import "@openzeppelin/contracts/utils/Masks.sol"; +import "@openzeppelin/community-contracts/contracts/utils/Masks.sol"; ``` Library for handling bit masks @@ -210,14 +210,14 @@ Returns the symmetric difference (∆) of two masks, also known as disjunctive u ## `EnumerableMapExtended` - + ```solidity -import "@openzeppelin/contracts/utils/structs/EnumerableMapExtended.sol"; +import "@openzeppelin/community-contracts/contracts/utils/structs/EnumerableMapExtended.sol"; ``` Library for managing an enumerable variant of Solidity's @@ -345,8 +345,8 @@ Removes all the entries from a map. O(n). 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. + @@ -464,10 +464,10 @@ Returns an array containing all the keys 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. + @@ -488,10 +488,10 @@ Returns an array containing a slice of the keys 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. + @@ -552,8 +552,8 @@ Removes all the entries from a map. O(n). 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. + @@ -671,10 +671,10 @@ Returns an array containing all the keys 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. + @@ -695,10 +695,10 @@ Returns an array containing a slice of the keys 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. + @@ -743,14 +743,14 @@ Query for a nonexistent map key. ## `EnumerableSetExtended` - + ```solidity -import "@openzeppelin/contracts/utils/structs/EnumerableSetExtended.sol"; +import "@openzeppelin/community-contracts/contracts/utils/structs/EnumerableSetExtended.sol"; ``` Library for managing @@ -856,8 +856,8 @@ Removes all the values from a set. O(n). 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. + @@ -936,10 +936,10 @@ Return the entire set in an array 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. + @@ -960,10 +960,10 @@ Return a slice of the set in an array 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. + diff --git a/content/community-contracts/api/utils/cryptography.mdx b/content/community-contracts/api/utils/cryptography.mdx index 30a523fa..5847fc69 100644 --- a/content/community-contracts/api/utils/cryptography.mdx +++ b/content/community-contracts/api/utils/cryptography.mdx @@ -5,10 +5,10 @@ description: "Smart contract cryptography utilities and implementations" A collection of contracts and libraries that implement various signature validation schemes and cryptographic primitives. These utilities enable secure authentication, multisignature operations, and advanced cryptographic operations in smart contracts. -- [`ZKEmailUtils`](#ZKEmailUtils): Library for ZKEmail signature validation utilities, enabling email-based authentication through zero-knowledge proofs. -- [`DKIMRegistry`](#DKIMRegistry): Implementation of [ERC-7969](https://eips.ethereum.org/EIPS/eip-7969) to enable onchain verification of DomainKeys Identified Mail (DKIM) signatures. -- [`SignerZKEmail`](#SignerZKEmail): Implementation of an [AbstractSigner](https://docs.openzeppelin.com/contracts/5.x/api/utils/cryptography#AbstractSigner) that enables email-based authentication through zero-knowledge proofs. -- [`ERC7913ZKEmailVerifier`](#ERC7913ZKEmailVerifier): Ready to use ERC-7913 signature verifiers for ZKEmail. +* [`ZKEmailUtils`](#ZKEmailUtils): Library for ZKEmail signature validation utilities, enabling email-based authentication through zero-knowledge proofs. +* [`DKIMRegistry`](#DKIMRegistry): Implementation of [ERC-7969](https://eips.ethereum.org/EIPS/eip-7969) to enable onchain verification of DomainKeys Identified Mail (DKIM) signatures. +* [`SignerZKEmail`](#SignerZKEmail): Implementation of an [AbstractSigner](https://docs.openzeppelin.com/contracts/5.x/api/utils/cryptography#AbstractSigner) that enables email-based authentication through zero-knowledge proofs. +* [`ERC7913ZKEmailVerifier`](#ERC7913ZKEmailVerifier): Ready to use ERC-7913 signature verifiers for ZKEmail. ## Utils @@ -30,14 +30,14 @@ A collection of contracts and libraries that implement various signature validat ## `DKIMRegistry` - + ```solidity -import "@openzeppelin/contracts/utils/cryptography/DKIMRegistry.sol"; +import "@openzeppelin/community-contracts/contracts/utils/cryptography/DKIMRegistry.sol"; ``` Implementation of the [ERC-7969](https://eips.ethereum.org/EIPS/eip-7969) interface for registering @@ -128,8 +128,8 @@ Emits a [`IDKIMRegistry.KeyHashRegistered`](/community-contracts/api/interfaces# This function does not validate that keyHash is non-zero. Consider adding - validation in derived contracts if needed. + @@ -153,8 +153,8 @@ Emits a [`IDKIMRegistry.KeyHashRegistered`](/community-contracts/api/interfaces# This function does not validate that the keyHashes array is non-empty. - Consider adding validation in derived contracts if needed. + @@ -185,14 +185,14 @@ Emits a [`IDKIMRegistry.KeyHashRevoked`](/community-contracts/api/interfaces#IDK ## `ZKEmailUtils` - + ```solidity -import "@openzeppelin/contracts/utils/cryptography/ZKEmailUtils.sol"; +import "@openzeppelin/community-contracts/contracts/utils/cryptography/ZKEmailUtils.sol"; ``` Library for [ZKEmail](https://docs.zk.email) Groth16 proof validation utilities. @@ -300,8 +300,8 @@ returns true and the calldata view at the object. Otherwise, returns false and a The returned `emailProof` object should not be accessed if `success` is false. Trying to access the data may - cause revert/panic. + @@ -332,14 +332,14 @@ into a uint256 array in the order expected by the verifier circuit. ## `SignerZKEmail` - + ```solidity -import "@openzeppelin/contracts/utils/cryptography/signers/SignerZKEmail.sol"; +import "@openzeppelin/community-contracts/contracts/utils/cryptography/signers/SignerZKEmail.sol"; ``` Implementation of `AbstractSigner` using [ZKEmail](https://docs.zk.email) signatures. @@ -376,9 +376,9 @@ contract MyAccountZKEmail is Account, SignerZKEmail, Initializable { Failing to call [`SignerZKEmail._setAccountSalt`](#SignerZKEmail-_setAccountSalt-bytes32-), [`SignerZKEmail._setDKIMRegistry`](#SignerZKEmail-_setDKIMRegistry-contract-IDKIMRegistry-), and [`SignerZKEmail._setVerifier`](#SignerZKEmail-_setVerifier-contract-IGroth16Verifier-) - either during construction (if used standalone) or during initialization (if used as a clone) may leave the signer either front-runnable or unusable. +

Functions

@@ -561,14 +561,14 @@ Proof verification error. ## `ERC7913ZKEmailVerifier` - +
```solidity -import "@openzeppelin/contracts/utils/cryptography/verifiers/ERC7913ZKEmailVerifier.sol"; +import "@openzeppelin/community-contracts/contracts/utils/cryptography/verifiers/ERC7913ZKEmailVerifier.sol"; ``` ERC-7913 signature verifier that supports ZKEmail accounts. diff --git a/content/confidential-contracts/api/finance.mdx b/content/confidential-contracts/api/finance.mdx index 8d0ec00b..8653cfa3 100644 --- a/content/confidential-contracts/api/finance.mdx +++ b/content/confidential-contracts/api/finance.mdx @@ -7,6 +7,7 @@ This directory includes primitives for on-chain confidential financial systems: * [`VestingWalletConfidential`](#VestingWalletConfidential): Handles the vesting of confidential tokens for a given beneficiary. Custody of multiple tokens can be given to this contract, which will release the token to the beneficiary following a given, customizable, vesting schedule. * [`VestingWalletCliffConfidential`](#VestingWalletCliffConfidential): Variant of [`VestingWalletConfidential`](#VestingWalletConfidential) which adds a cliff period to the vesting schedule. +* [`BatcherConfidential`](#BatcherConfidential): A batching primitive that enables routing between two [`ERC7984ERC20Wrapper`](/confidential-contracts/api/token#ERC7984ERC20Wrapper) contracts via a non-confidential route. For convenience, this directory also includes: @@ -16,21 +17,773 @@ For convenience, this directory also includes: [`VestingWalletConfidential`](#VestingWalletConfidential) [`VestingWalletCliffConfidential`](#VestingWalletCliffConfidential) [`VestingWalletConfidentialFactory`](#VestingWalletConfidentialFactory) +[`BatcherConfidential`](#BatcherConfidential) + + + +
+ +## `BatcherConfidential` + + + + + +
+ +```solidity +import "@openzeppelin/confidential-contracts/contracts/finance/BatcherConfidential.sol"; +``` + +`BatcherConfidential` is a batching primitive that enables routing between two [`ERC7984ERC20Wrapper`](/confidential-contracts/api/token#ERC7984ERC20Wrapper) contracts +via a non-confidential route. Users deposit [`BatcherConfidential.fromToken`](#BatcherConfidential-fromToken--) into the batcher and receive [`BatcherConfidential.toToken`](#BatcherConfidential-toToken--) in exchange. Deposits are +made by using `ERC7984` transfer and call functions such as [`ERC7984.confidentialTransferAndCall`](/confidential-contracts/api/token#ERC7984-confidentialTransferAndCall-address-euint64-bytes-). + +Developers must implement the virtual function [`BatcherConfidential._executeRoute`](#BatcherConfidential-_executeRoute-uint256-uint256-) to perform the batch's route. This function is called +once the batch deposits are unwrapped into the underlying tokens. The function should swap the underlying [`BatcherConfidential.fromToken`](#BatcherConfidential-fromToken--) for +underlying [`BatcherConfidential.toToken`](#BatcherConfidential-toToken--). If an issue is encountered, the function should return `ExecuteOutcome.Cancel` to cancel the batch. + +Developers must also implement the virtual function [`BatcherConfidential.routeDescription`](#BatcherConfidential-routeDescription--) to provide a human readable description of the batch's route. + +Claim outputs are rounded down. This may result in small deposits being rounded down to 0 if the exchange rate is less than 1:1. +[`BatcherConfidential.toToken`](#BatcherConfidential-toToken--) dust from rounding down will accumulate in the batcher over time. + + +The batcher does not support [`ERC7984ERC20Wrapper`](/confidential-contracts/api/token#ERC7984ERC20Wrapper) contracts prior to v0.4.0. + + + +The batcher could be used to maintain confidentiality of deposits--by default there are no confidentiality guarantees. +If desired, developers should consider restricting certain functions to increase confidentiality. + + + +The [`BatcherConfidential.toToken`](#BatcherConfidential-toToken--) and [`BatcherConfidential.fromToken`](#BatcherConfidential-fromToken--) must be carefully inspected to ensure proper capacity is maintained. If [`BatcherConfidential.toToken`](#BatcherConfidential-toToken--) or +[`BatcherConfidential.fromToken`](#BatcherConfidential-fromToken--) are filled--resulting in denial of service--batches could get bricked. The batcher would be unable to wrap +underlying tokens into [`BatcherConfidential.toToken`](#BatcherConfidential-toToken--). Further, if [`BatcherConfidential.fromToken`](#BatcherConfidential-fromToken--) is also filled, cancellation would also fail on rewrap. + + +
+

Functions

+
+- [constructor(fromToken_, toToken_)](#BatcherConfidential-constructor-contract-IERC7984ERC20Wrapper-contract-IERC7984ERC20Wrapper-) +- [claim(batchId, account)](#BatcherConfidential-claim-uint256-address-) +- [quit(batchId)](#BatcherConfidential-quit-uint256-) +- [dispatchBatch()](#BatcherConfidential-dispatchBatch--) +- [dispatchBatchCallback(batchId, unwrapAmountCleartext, decryptionProof)](#BatcherConfidential-dispatchBatchCallback-uint256-uint64-bytes-) +- [onConfidentialTransferReceived(, from, amount, )](#BatcherConfidential-onConfidentialTransferReceived-address-address-euint64-bytes-) +- [fromToken()](#BatcherConfidential-fromToken--) +- [toToken()](#BatcherConfidential-toToken--) +- [currentBatchId()](#BatcherConfidential-currentBatchId--) +- [unwrapRequestId(batchId)](#BatcherConfidential-unwrapRequestId-uint256-) +- [totalDeposits(batchId)](#BatcherConfidential-totalDeposits-uint256-) +- [deposits(batchId, account)](#BatcherConfidential-deposits-uint256-address-) +- [exchangeRate(batchId)](#BatcherConfidential-exchangeRate-uint256-) +- [exchangeRateDecimals()](#BatcherConfidential-exchangeRateDecimals--) +- [routeDescription()](#BatcherConfidential-routeDescription--) +- [batchState(batchId)](#BatcherConfidential-batchState-uint256-) +- [_claim(batchId, account)](#BatcherConfidential-_claim-uint256-address-) +- [_join(to, amount)](#BatcherConfidential-_join-address-euint64-) +- [_executeRoute(batchId, amount)](#BatcherConfidential-_executeRoute-uint256-uint256-) +- [_validateStateBitmap(batchId, allowedStates)](#BatcherConfidential-_validateStateBitmap-uint256-bytes32-) +- [_getAndIncreaseBatchId()](#BatcherConfidential-_getAndIncreaseBatchId--) +- [_encodeStateBitmap(batchState_)](#BatcherConfidential-_encodeStateBitmap-enum-BatcherConfidential-BatchState-) +
+ReentrancyGuardTransient + +- [_reentrancyGuardEntered()](#ReentrancyGuardTransient-_reentrancyGuardEntered--) +- [_reentrancyGuardStorageSlot()](#ReentrancyGuardTransient-_reentrancyGuardStorageSlot--) + +
+
+
+ +
+

Events

+
+- [BatchDispatched(batchId)](#BatcherConfidential-BatchDispatched-uint256-) +- [BatchCanceled(batchId)](#BatcherConfidential-BatchCanceled-uint256-) +- [BatchFinalized(batchId, exchangeRate)](#BatcherConfidential-BatchFinalized-uint256-uint64-) +- [Joined(batchId, account, amount)](#BatcherConfidential-Joined-uint256-address-euint64-) +- [Claimed(batchId, account, amount)](#BatcherConfidential-Claimed-uint256-address-euint64-) +- [Quit(batchId, account, amount)](#BatcherConfidential-Quit-uint256-address-euint64-) +
+
+ +
+

Errors

+
+- [BatchNonexistent(batchId)](#BatcherConfidential-BatchNonexistent-uint256-) +- [ZeroDeposits(batchId, account)](#BatcherConfidential-ZeroDeposits-uint256-address-) +- [BatchUnexpectedState(batchId, current, expectedStates)](#BatcherConfidential-BatchUnexpectedState-uint256-enum-BatcherConfidential-BatchState-bytes32-) +- [InvalidExchangeRate(batchId, totalDeposits, exchangeRate)](#BatcherConfidential-InvalidExchangeRate-uint256-uint256-uint64-) +- [Unauthorized()](#BatcherConfidential-Unauthorized--) +- [InvalidWrapperToken(token)](#BatcherConfidential-InvalidWrapperToken-address-) +
+ReentrancyGuardTransient + +- [ReentrancyGuardReentrantCall()](#ReentrancyGuardTransient-ReentrancyGuardReentrantCall--) + +
+
+
+ + + +
+
+

constructor(contract IERC7984ERC20Wrapper fromToken_, contract IERC7984ERC20Wrapper toToken_)

+
+

internal

+# +
+
+
+ +
+
+ + + +
+
+

claim(uint256 batchId, address account) → euint64

+
+

public

+# +
+
+
+ +Claim the `toToken` corresponding to `account`'s deposit in batch with id `batchId`. + + +This function is not gated and can be called by anyone. Claims could be frontrun. + + +
+
+ + + +
+
+

quit(uint256 batchId) → euint64

+
+

public

+# +
+
+
+ +Quit the batch with id `batchId`. Entire deposit is returned to the user. +This can only be called if the batch has not yet been dispatched or if the batch was canceled. + + +Developers should consider adding additional restrictions to this function +if maintaining confidentiality of deposits is critical to the application. + + + +[`BatcherConfidential.dispatchBatch`](#BatcherConfidential-dispatchBatch--) may fail if an incompatible version of [`ERC7984ERC20Wrapper`](/confidential-contracts/api/token#ERC7984ERC20Wrapper) is used. +This function must be unrestricted in cases where batch dispatching fails. + + +
+
+ + + +
+
+

dispatchBatch()

+
+

public

+# +
+
+
+ +Permissionless function to dispatch the current batch. Increments the [`BatcherConfidential.currentBatchId`](#BatcherConfidential-currentBatchId--). + + +Developers should consider adding additional restrictions to this function +if maintaining confidentiality of deposits is critical to the application. + + +
+
+ + + +
+
+

dispatchBatchCallback(uint256 batchId, uint64 unwrapAmountCleartext, bytes decryptionProof)

+
+

public

+# +
+
+
+ +Dispatch batch callback callable by anyone. This function finalizes the unwrap of [`BatcherConfidential.fromToken`](#BatcherConfidential-fromToken--) +and calls [`BatcherConfidential._executeRoute`](#BatcherConfidential-_executeRoute-uint256-uint256-) to perform the batch's route. If `_executeRoute` returns `ExecuteOutcome.Partial`, +this function should be called again with the same `batchId`, `unwrapAmountCleartext`, and `decryptionProof`. + +
+
+ + + +
+
+

onConfidentialTransferReceived(address, address from, euint64 amount, bytes) → ebool

+
+

external

+# +
+
+
+ +See [`IERC7984Receiver.onConfidentialTransferReceived`](/confidential-contracts/api/interfaces#IERC7984Receiver-onConfidentialTransferReceived-address-address-euint64-bytes-). + +Deposit [`BatcherConfidential.fromToken`](#BatcherConfidential-fromToken--) into the current batch. + + +See [`BatcherConfidential._claim`](#BatcherConfidential-_claim-uint256-address-) to understand how the [`BatcherConfidential.toToken`](#BatcherConfidential-toToken--) amount is calculated. Claim amounts are rounded down. Small +deposits may be rounded down to 0 if the exchange rate is less than 1:1. + + +
+
+ + + +
+
+

fromToken() → contract IERC7984ERC20Wrapper

+
+

public

+# +
+
+
+ +Batcher from token. Users deposit this token in exchange for [`BatcherConfidential.toToken`](#BatcherConfidential-toToken--). + +
+
+ + + +
+
+

toToken() → contract IERC7984ERC20Wrapper

+
+

public

+# +
+
+
+ +Batcher to token. Users receive this token in exchange for their [`BatcherConfidential.fromToken`](#BatcherConfidential-fromToken--) deposits. + +
+
+ + + +
+
+

currentBatchId() → uint256

+
+

public

+# +
+
+
+ +The ongoing batch id. New deposits join this batch. + +
+
+ + + +
+
+

unwrapRequestId(uint256 batchId) → bytes32

+
+

public

+# +
+
+
+ +The unwrap request id for a batch with id `batchId`. + +
+
+ + + +
+
+

totalDeposits(uint256 batchId) → euint64

+
+

public

+# +
+
+
+ +The total deposits made in batch with id `batchId`. + +
+
+ + + +
+
+

deposits(uint256 batchId, address account) → euint64

+
+

public

+# +
+
+
+ +The deposits made by `account` in batch with id `batchId`. + +
+
+ + + +
+
+

exchangeRate(uint256 batchId) → uint64

+
+

public

+# +
+
+
+ +The exchange rate set for batch with id `batchId`. + +
+
+ + + +
+
+

exchangeRateDecimals() → uint8

+
+

public

+# +
+
+
+ +The number of decimals of precision for the exchange rate. + +
+
+ + + +
+
+

routeDescription() → string

+
+

public

+# +
+
+
+ +Human readable description of what the batcher does. + +
+
+ + + +
+
+

batchState(uint256 batchId) → enum BatcherConfidential.BatchState

+
+

public

+# +
+
+
+ +Returns the current state of a batch. Reverts if the batch does not exist. + +
+
+ + + +
+
+

_claim(uint256 batchId, address account) → euint64

+
+

internal

+# +
+
+
+ +Claims `toToken` for `account`'s deposit in batch with id `batchId`. Tokens are always +sent to `account`, enabling third-party relayers to claim on behalf of depositors. + +
+
+ + + +
+
+

_join(address to, euint64 amount) → euint64

+
+

internal

+# +
+
+
+ +Joins a batch with amount `amount` on behalf of `to`. Does not do any transfers in. +Returns the amount joined with. + +
+
+ + + +
+
+

_executeRoute(uint256 batchId, uint256 amount) → enum BatcherConfidential.ExecuteOutcome

+
+

internal

+# +
+
+
+ +Function which is executed by [`BatcherConfidential.dispatchBatchCallback`](#BatcherConfidential-dispatchBatchCallback-uint256-uint64-bytes-) after validation and unwrap finalization. The parameter +`amount` is the plaintext amount of the `fromToken` which were unwrapped--to attain the underlying tokens received, +evaluate `amount * fromToken().rate()`. This function should swap the underlying [`BatcherConfidential.fromToken`](#BatcherConfidential-fromToken--) for underlying [`BatcherConfidential.toToken`](#BatcherConfidential-toToken--). + +This function returns an [`BatcherConfidential.ExecuteOutcome`](#BatcherConfidential-ExecuteOutcome) enum indicating the new state of the batch. If the route execution is complete, +the balance of the underlying [`BatcherConfidential.toToken`](#BatcherConfidential-toToken--) is wrapped and the exchange rate is set. + + +[`BatcherConfidential.dispatchBatchCallback`](#BatcherConfidential-dispatchBatchCallback-uint256-uint64-bytes-) (and in turn [`BatcherConfidential._executeRoute`](#BatcherConfidential-_executeRoute-uint256-uint256-)) can be repeatedly called until the route execution is complete. +If a multi-step route is necessary, intermediate steps should return `ExecuteOutcome.Partial`. Intermediate steps *must* not +result in underlying [`BatcherConfidential.toToken`](#BatcherConfidential-toToken--) being transferred into the batcher. + + +[WARNING] +#### This function must eventually return `ExecuteOutcome.Complete` or `ExecuteOutcome.Cancel`. Failure to do so results +in user deposits being locked indefinitely. + +Additionally, the following must hold: + +- `swappedAmount >= ceil(unwrapAmountCleartext / 10 ** exchangeRateDecimals()) * toToken().rate()` (the exchange rate must not be 0) +- `swappedAmount \<= type(uint64).max * toToken().rate()` (the wrapped amount of [`BatcherConfidential.toToken`](#BatcherConfidential-toToken--) must fit in `uint64`) + +
+
+ + + +
+
+

_validateStateBitmap(uint256 batchId, bytes32 allowedStates) → enum BatcherConfidential.BatchState

+
+

internal

+# +
+
+
+ +Check that the current state of a batch matches the requirements described by the `allowedStates` bitmap. +This bitmap should be built using `_encodeStateBitmap`. + +If requirements are not met, reverts with a [`BatcherConfidential.BatchUnexpectedState`](#BatcherConfidential-BatchUnexpectedState-uint256-enum-BatcherConfidential-BatchState-bytes32-) error. + +
+
+ + + +
+
+

_getAndIncreaseBatchId() → uint256

+
+

internal

+# +
+
+
+ +Gets the current batch id and increments it. + +
+
+ + + +
+
+

_encodeStateBitmap(enum BatcherConfidential.BatchState batchState_) → bytes32

+
+

internal

+# +
+
+
+ +Encodes a `BatchState` into a `bytes32` representation where each bit enabled corresponds to +the underlying position in the `BatchState` enum. For example: + +0x000...1000 + ^--- Canceled + ^-- Finalized + ^- Dispatched + ^ Pending + +
+
+ + + +
+
+

BatchDispatched(uint256 indexed batchId)

+
+

event

+# +
+
+ +
+ +Emitted when a batch with id `batchId` is dispatched via [`BatcherConfidential.dispatchBatch`](#BatcherConfidential-dispatchBatch--). + +
+
+ + +
+
+

BatchCanceled(uint256 indexed batchId)

+
+

event

+# +
+
+ +
+ +Emitted when a batch with id `batchId` is canceled. + +
+
+ + +
+
+

BatchFinalized(uint256 indexed batchId, uint64 exchangeRate)

+
+

event

+# +
+
+ +
+ +Emitted when a batch with id `batchId` is finalized with an exchange rate of `exchangeRate`. + +
+
+ + +
+
+

Joined(uint256 indexed batchId, address indexed account, euint64 amount)

+
+

event

+# +
+
+ +
+ +Emitted when an `account` joins a batch with id `batchId` with a deposit of `amount`. + +
+
+ + +
+
+

Claimed(uint256 indexed batchId, address indexed account, euint64 amount)

+
+

event

+# +
+
+ +
+ +Emitted when an `account` claims their `amount` from batch with id `batchId`. + +
+
+ + +
+
+

Quit(uint256 indexed batchId, address indexed account, euint64 amount)

+
+

event

+# +
+
+ +
+ +Emitted when an `account` quits a batch with id `batchId`. + +
+
+ + + +
+
+

BatchNonexistent(uint256 batchId)

+
+

error

+# +
+
+
+ +The `batchId` does not exist. Batch IDs start at 1 and must be less than or equal to [`BatcherConfidential.currentBatchId`](#BatcherConfidential-currentBatchId--). + +
+
+ + + +
+
+

ZeroDeposits(uint256 batchId, address account)

+
+

error

+# +
+
+
+ +The `account` has a zero deposits in batch `batchId`. + +
+
+ + + +
+
+

BatchUnexpectedState(uint256 batchId, enum BatcherConfidential.BatchState current, bytes32 expectedStates)

+
+

error

+# +
+
+
+ +The batch `batchId` is in the state `current`, which is invalid for the operation. +The `expectedStates` is a bitmap encoding the expected/allowed states for the operation. + +See [`BatcherConfidential._encodeStateBitmap`](#BatcherConfidential-_encodeStateBitmap-enum-BatcherConfidential-BatchState-). + +
+
+ + + +
+
+

InvalidExchangeRate(uint256 batchId, uint256 totalDeposits, uint64 exchangeRate)

+
+

error

+# +
+
+
+ +Thrown when the given exchange rate is invalid. The exchange rate must be non-zero and the wrapped +amount of [`BatcherConfidential.toToken`](#BatcherConfidential-toToken--) must be less than or equal to `type(uint64).max`. + +
+
+ + + +
+
+

Unauthorized()

+
+

error

+# +
+
+
+ +The caller is not authorized to call this function. + +
+
+ + + +
+
+

InvalidWrapperToken(address token)

+
+

error

+# +
+
+
+ +The given `token` does not support `IERC7984ERC20Wrapper` via `ERC165`. + +
+
-## `ERC7821WithExecutor` +## `ERC7821WithExecutor` - +
```solidity -import "@openzeppelin/confidential-contracts/finance/ERC7821WithExecutor.sol"; +import "@openzeppelin/confidential-contracts/contracts/finance/ERC7821WithExecutor.sol"; ``` Extension of `ERC7821` that adds an [`ERC7821WithExecutor.executor`](#ERC7821WithExecutor-executor--) address that is able to execute arbitrary calls via `ERC7821.execute`. @@ -41,38 +794,54 @@ Extension of `ERC7821` that adds an [`ERC7821WithExecutor.executor`](#ERC7821Wit - [executor()](#ERC7821WithExecutor-executor--) - [__ERC7821WithExecutor_init(executor_)](#ERC7821WithExecutor-__ERC7821WithExecutor_init-address-) - [_erc7821AuthorizedExecutor(caller, mode, executionData)](#ERC7821WithExecutor-_erc7821AuthorizedExecutor-address-bytes32-bytes-) -#### ERC7821 [!toc] +
+ERC7821 + - [execute(mode, executionData)](#ERC7821-execute-bytes32-bytes-) - [supportsExecutionMode(mode)](#ERC7821-supportsExecutionMode-bytes32-) -#### IERC7821 [!toc] -#### Initializable [!toc] + +
+
+Initializable + - [_checkInitializing()](#Initializable-_checkInitializing--) - [_disableInitializers()](#Initializable-_disableInitializers--) - [_getInitializedVersion()](#Initializable-_getInitializedVersion--) - [_isInitializing()](#Initializable-_isInitializing--) - [_initializableStorageSlot()](#Initializable-_initializableStorageSlot--) + +

Events

-#### ERC7821 [!toc] -#### IERC7821 [!toc] -#### Initializable [!toc] +
+Initializable + - [Initialized(version)](#Initializable-Initialized-uint64-) + +

Errors

-#### ERC7821 [!toc] +
+ERC7821 + - [UnsupportedExecutionMode()](#ERC7821-UnsupportedExecutionMode--) -#### IERC7821 [!toc] -#### Initializable [!toc] + +
+
+Initializable + - [InvalidInitialization()](#Initializable-InvalidInitialization--) - [NotInitializing()](#Initializable-NotInitializing--) + +
@@ -143,16 +912,16 @@ function _erc7821AuthorizedExecutor(
-## `VestingWalletCliffConfidential` +## `VestingWalletCliffConfidential` - +
```solidity -import "@openzeppelin/confidential-contracts/finance/VestingWalletCliffConfidential.sol"; +import "@openzeppelin/confidential-contracts/contracts/finance/VestingWalletCliffConfidential.sol"; ``` An extension of [`VestingWalletConfidential`](#VestingWalletConfidential) that adds a cliff to the vesting schedule. The cliff is `cliffSeconds` long and @@ -165,7 +934,9 @@ starts at the vesting start timestamp (see [`VestingWalletConfidential`](#Vestin - [__VestingWalletCliffConfidential_init(beneficiary, startTimestamp, durationSeconds, cliffSeconds)](#VestingWalletCliffConfidential-__VestingWalletCliffConfidential_init-address-uint48-uint48-uint48-) - [__VestingWalletCliffConfidential_init_unchained(cliffSeconds)](#VestingWalletCliffConfidential-__VestingWalletCliffConfidential_init_unchained-uint48-) - [_vestingSchedule(totalAllocation, timestamp)](#VestingWalletCliffConfidential-_vestingSchedule-euint128-uint48-) -#### VestingWalletConfidential [!toc] +
+VestingWalletConfidential + - [start()](#VestingWalletConfidential-start--) - [duration()](#VestingWalletConfidential-duration--) - [end()](#VestingWalletConfidential-end--) @@ -175,9 +946,18 @@ starts at the vesting start timestamp (see [`VestingWalletConfidential`](#Vestin - [vestedAmount(token, timestamp)](#VestingWalletConfidential-vestedAmount-address-uint48-) - [__VestingWalletConfidential_init(beneficiary, startTimestamp, durationSeconds)](#VestingWalletConfidential-__VestingWalletConfidential_init-address-uint48-uint48-) - [__VestingWalletConfidential_init_unchained(startTimestamp, durationSeconds)](#VestingWalletConfidential-__VestingWalletConfidential_init_unchained-uint48-uint48-) -#### ReentrancyGuardTransient [!toc] + +
+
+ReentrancyGuardTransient + - [_reentrancyGuardEntered()](#ReentrancyGuardTransient-_reentrancyGuardEntered--) -#### OwnableUpgradeable [!toc] +- [_reentrancyGuardStorageSlot()](#ReentrancyGuardTransient-_reentrancyGuardStorageSlot--) + +
+
+OwnableUpgradeable + - [__Ownable_init(initialOwner)](#OwnableUpgradeable-__Ownable_init-address-) - [__Ownable_init_unchained(initialOwner)](#OwnableUpgradeable-__Ownable_init_unchained-address-) - [owner()](#OwnableUpgradeable-owner--) @@ -185,32 +965,52 @@ starts at the vesting start timestamp (see [`VestingWalletConfidential`](#Vestin - [renounceOwnership()](#OwnableUpgradeable-renounceOwnership--) - [transferOwnership(newOwner)](#OwnableUpgradeable-transferOwnership-address-) - [_transferOwnership(newOwner)](#OwnableUpgradeable-_transferOwnership-address-) -#### ContextUpgradeable [!toc] + +
+
+ContextUpgradeable + - [__Context_init()](#ContextUpgradeable-__Context_init--) - [__Context_init_unchained()](#ContextUpgradeable-__Context_init_unchained--) - [_msgSender()](#ContextUpgradeable-_msgSender--) - [_msgData()](#ContextUpgradeable-_msgData--) - [_contextSuffixLength()](#ContextUpgradeable-_contextSuffixLength--) -#### Initializable [!toc] + +
+
+Initializable + - [_checkInitializing()](#Initializable-_checkInitializing--) - [_disableInitializers()](#Initializable-_disableInitializers--) - [_getInitializedVersion()](#Initializable-_getInitializedVersion--) - [_isInitializing()](#Initializable-_isInitializing--) - [_initializableStorageSlot()](#Initializable-_initializableStorageSlot--) + +

Events

-#### VestingWalletConfidential [!toc] +
+VestingWalletConfidential + - [VestingWalletConfidentialTokenReleased(token, amount)](#VestingWalletConfidential-VestingWalletConfidentialTokenReleased-address-euint64-) -#### ReentrancyGuardTransient [!toc] -#### OwnableUpgradeable [!toc] + +
+
+OwnableUpgradeable + - [OwnershipTransferred(previousOwner, newOwner)](#OwnableUpgradeable-OwnershipTransferred-address-address-) -#### ContextUpgradeable [!toc] -#### Initializable [!toc] + +
+
+Initializable + - [Initialized(version)](#Initializable-Initialized-uint64-) + +
@@ -218,16 +1018,26 @@ starts at the vesting start timestamp (see [`VestingWalletConfidential`](#Vestin

Errors

- [VestingWalletCliffConfidentialInvalidCliffDuration(cliffSeconds, durationSeconds)](#VestingWalletCliffConfidential-VestingWalletCliffConfidentialInvalidCliffDuration-uint64-uint64-) -#### VestingWalletConfidential [!toc] -#### ReentrancyGuardTransient [!toc] +
+ReentrancyGuardTransient + - [ReentrancyGuardReentrantCall()](#ReentrancyGuardTransient-ReentrancyGuardReentrantCall--) -#### OwnableUpgradeable [!toc] + +
+
+OwnableUpgradeable + - [OwnableUnauthorizedAccount(account)](#OwnableUpgradeable-OwnableUnauthorizedAccount-address-) - [OwnableInvalidOwner(owner)](#OwnableUpgradeable-OwnableInvalidOwner-address-) -#### ContextUpgradeable [!toc] -#### Initializable [!toc] + +
+
+Initializable + - [InvalidInitialization()](#Initializable-InvalidInitialization--) - [NotInitializing()](#Initializable-NotInitializing--) + +
@@ -326,16 +1136,16 @@ The specified cliff duration is larger than the vesting duration.
-## `VestingWalletConfidential` +## `VestingWalletConfidential` - +
```solidity -import "@openzeppelin/confidential-contracts/finance/VestingWalletConfidential.sol"; +import "@openzeppelin/confidential-contracts/contracts/finance/VestingWalletConfidential.sol"; ``` A vesting wallet is an ownable contract that can receive ERC7984 tokens, and release these @@ -354,7 +1164,7 @@ Since the wallet is `Ownable`, and ownership can be transferred, it is possible 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. +sure to account for the supply/balance adjustment in the vesting schedule to ensure the vested amount is as intended. Confidential vesting wallet contracts can be deployed (as clones) using the [`VestingWalletConfidentialFactory`](#VestingWalletConfidentialFactory). @@ -372,9 +1182,16 @@ Confidential vesting wallet contracts can be deployed (as clones) using the [`Ve - [__VestingWalletConfidential_init(beneficiary, startTimestamp, durationSeconds)](#VestingWalletConfidential-__VestingWalletConfidential_init-address-uint48-uint48-) - [__VestingWalletConfidential_init_unchained(startTimestamp, durationSeconds)](#VestingWalletConfidential-__VestingWalletConfidential_init_unchained-uint48-uint48-) - [_vestingSchedule(totalAllocation, timestamp)](#VestingWalletConfidential-_vestingSchedule-euint128-uint48-) -#### ReentrancyGuardTransient [!toc] +
+ReentrancyGuardTransient + - [_reentrancyGuardEntered()](#ReentrancyGuardTransient-_reentrancyGuardEntered--) -#### OwnableUpgradeable [!toc] +- [_reentrancyGuardStorageSlot()](#ReentrancyGuardTransient-_reentrancyGuardStorageSlot--) + +
+
+OwnableUpgradeable + - [__Ownable_init(initialOwner)](#OwnableUpgradeable-__Ownable_init-address-) - [__Ownable_init_unchained(initialOwner)](#OwnableUpgradeable-__Ownable_init_unchained-address-) - [owner()](#OwnableUpgradeable-owner--) @@ -382,18 +1199,28 @@ Confidential vesting wallet contracts can be deployed (as clones) using the [`Ve - [renounceOwnership()](#OwnableUpgradeable-renounceOwnership--) - [transferOwnership(newOwner)](#OwnableUpgradeable-transferOwnership-address-) - [_transferOwnership(newOwner)](#OwnableUpgradeable-_transferOwnership-address-) -#### ContextUpgradeable [!toc] + +
+
+ContextUpgradeable + - [__Context_init()](#ContextUpgradeable-__Context_init--) - [__Context_init_unchained()](#ContextUpgradeable-__Context_init_unchained--) - [_msgSender()](#ContextUpgradeable-_msgSender--) - [_msgData()](#ContextUpgradeable-_msgData--) - [_contextSuffixLength()](#ContextUpgradeable-_contextSuffixLength--) -#### Initializable [!toc] + +
+
+Initializable + - [_checkInitializing()](#Initializable-_checkInitializing--) - [_disableInitializers()](#Initializable-_disableInitializers--) - [_getInitializedVersion()](#Initializable-_getInitializedVersion--) - [_isInitializing()](#Initializable-_isInitializing--) - [_initializableStorageSlot()](#Initializable-_initializableStorageSlot--) + +
@@ -401,27 +1228,44 @@ Confidential vesting wallet contracts can be deployed (as clones) using the [`Ve

Events

- [VestingWalletConfidentialTokenReleased(token, amount)](#VestingWalletConfidential-VestingWalletConfidentialTokenReleased-address-euint64-) -#### ReentrancyGuardTransient [!toc] -#### OwnableUpgradeable [!toc] +
+OwnableUpgradeable + - [OwnershipTransferred(previousOwner, newOwner)](#OwnableUpgradeable-OwnershipTransferred-address-address-) -#### ContextUpgradeable [!toc] -#### Initializable [!toc] + +
+
+Initializable + - [Initialized(version)](#Initializable-Initialized-uint64-) + +

Errors

-#### ReentrancyGuardTransient [!toc] +
+ReentrancyGuardTransient + - [ReentrancyGuardReentrantCall()](#ReentrancyGuardTransient-ReentrancyGuardReentrantCall--) -#### OwnableUpgradeable [!toc] + +
+
+OwnableUpgradeable + - [OwnableUnauthorizedAccount(account)](#OwnableUpgradeable-OwnableUnauthorizedAccount-address-) - [OwnableInvalidOwner(owner)](#OwnableUpgradeable-OwnableInvalidOwner-address-) -#### ContextUpgradeable [!toc] -#### Initializable [!toc] + +
+
+Initializable + - [InvalidInitialization()](#Initializable-InvalidInitialization--) - [NotInitializing()](#Initializable-NotInitializing--) + +
@@ -620,16 +1464,16 @@ Emitted when releasable vested tokens are released.
-## `VestingWalletConfidentialFactory` +## `VestingWalletConfidentialFactory` - +
```solidity -import "@openzeppelin/confidential-contracts/finance/VestingWalletConfidentialFactory.sol"; +import "@openzeppelin/confidential-contracts/contracts/finance/VestingWalletConfidentialFactory.sol"; ``` A factory which enables batch funding of vesting wallets. @@ -836,3 +1680,4 @@ Emitted when a vesting wallet is deployed. + diff --git a/content/confidential-contracts/api/governance.mdx b/content/confidential-contracts/api/governance.mdx index 4089b3d4..1eec5652 100644 --- a/content/confidential-contracts/api/governance.mdx +++ b/content/confidential-contracts/api/governance.mdx @@ -14,20 +14,20 @@ This directory includes primitives for on-chain confidential governance.
-## `VotesConfidential` +## `VotesConfidential` - +
```solidity -import "@openzeppelin/confidential-contracts/governance/utils/VotesConfidential.sol"; +import "@openzeppelin/confidential-contracts/contracts/governance/utils/VotesConfidential.sol"; ``` A confidential votes contract tracking confidential voting power of accounts over time. -It features vote delegation to delegators. +It features vote delegation to delegatees. This contract keeps a history (checkpoints) of each account's confidential vote power. Confidential voting power can be delegated either by calling the [`VotesConfidential.delegate`](#VotesConfidential-delegate-address-) function directly, or by providing @@ -36,7 +36,7 @@ through the public accessors [`VotesConfidential.getVotes`](#VotesConfidential-g allowed to access them. Ensure that [`HandleAccessManager._validateHandleAllowance`](/confidential-contracts/api/utils#HandleAccessManager-_validateHandleAllowance-bytes32-) is implemented properly, allowing all necessary addresses to access voting power handles. -By default, voting units does not account for voting power. This makes transfers of underlying +By default, transfer of voting units does not account for voting power. This makes transfers of voting units cheaper. The downside is that it requires users to delegate to themselves in order to activate checkpoints and have their voting power tracked. @@ -57,21 +57,31 @@ to activate checkpoints and have their voting power tracked. - [_moveDelegateVotes(from, to, amount)](#VotesConfidential-_moveDelegateVotes-address-address-euint64-) - [_validateTimepoint(timepoint)](#VotesConfidential-_validateTimepoint-uint256-) - [_getVotingUnits()](#VotesConfidential-_getVotingUnits-address-) -#### HandleAccessManager [!toc] +
+HandleAccessManager + - [getHandleAllowance(handle, account, persistent)](#HandleAccessManager-getHandleAllowance-bytes32-address-bool-) -- [_validateHandleAllowance(handle)](#HandleAccessManager-_validateHandleAllowance-bytes32-) -#### IERC6372 [!toc] -#### EIP712 [!toc] +- [_validateHandleAllowance()](#HandleAccessManager-_validateHandleAllowance-bytes32-) + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) + +
@@ -80,12 +90,12 @@ to activate checkpoints and have their voting power tracked.
- [DelegateVotesChanged(delegate, previousVotes, newVotes)](#VotesConfidential-DelegateVotesChanged-address-euint64-euint64-) - [DelegateChanged(delegator, fromDelegate, toDelegate)](#VotesConfidential-DelegateChanged-address-address-address-) -#### HandleAccessManager [!toc] -#### IERC6372 [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] +
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### Nonces [!toc] + +
@@ -95,12 +105,18 @@ to activate checkpoints and have their voting power tracked. - [VotesExpiredSignature(expiry)](#VotesConfidential-VotesExpiredSignature-uint256-) - [ERC6372InconsistentClock()](#VotesConfidential-ERC6372InconsistentClock--) - [ERC5805FutureLookup(timepoint, clock)](#VotesConfidential-ERC5805FutureLookup-uint256-uint48-) -#### HandleAccessManager [!toc] -#### IERC6372 [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### Nonces [!toc] +
+HandleAccessManager + +- [HandleAccessManagerNotAllowed(handle, account)](#HandleAccessManager-HandleAccessManagerNotAllowed-bytes32-address-) + +
+
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) + +
@@ -452,3 +468,4 @@ Lookup to future votes is not available. + diff --git a/content/confidential-contracts/api/interfaces.mdx b/content/confidential-contracts/api/interfaces.mdx index 9f30b727..7d2437cc 100644 --- a/content/confidential-contracts/api/interfaces.mdx +++ b/content/confidential-contracts/api/interfaces.mdx @@ -7,25 +7,30 @@ These interfaces are available as `.sol` files and are useful to interact with t * [`IERC7984`](#IERC7984) * [`IERC7984Receiver`](#IERC7984Receiver) +* [`IERC7984Rwa`](#IERC7984Rwa) ## Core [`IERC7984`](#IERC7984) [`IERC7984Receiver`](#IERC7984Receiver) +## Extensions +[`IERC7984Rwa`](#IERC7984Rwa) +[`IERC7984ERC20Wrapper`](#IERC7984ERC20Wrapper) +
-## `IERC7984` +## `IERC7984` - +
```solidity -import "@openzeppelin/confidential-contracts/interfaces/IERC7984.sol"; +import "@openzeppelin/confidential-contracts/contracts/interfaces/IERC7984.sol"; ``` Draft interface for a confidential fungible token standard utilizing the Zama FHE library. @@ -49,8 +54,12 @@ Draft interface for a confidential fungible token standard utilizing the Zama FH - [confidentialTransferAndCall(to, amount, data)](#IERC7984-confidentialTransferAndCall-address-euint64-bytes-) - [confidentialTransferFromAndCall(from, to, encryptedAmount, inputProof, data)](#IERC7984-confidentialTransferFromAndCall-address-address-externalEuint64-bytes-bytes-) - [confidentialTransferFromAndCall(from, to, amount, data)](#IERC7984-confidentialTransferFromAndCall-address-address-euint64-bytes-) -#### IERC165 [!toc] +
+IERC165 + - [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) + +
@@ -60,7 +69,6 @@ Draft interface for a confidential fungible token standard utilizing the Zama FH - [OperatorSet(holder, operator, until)](#IERC7984-OperatorSet-address-address-uint48-) - [ConfidentialTransfer(from, to, amount)](#IERC7984-ConfidentialTransfer-address-address-euint64-) - [AmountDisclosed(encryptedAmount, amount)](#IERC7984-AmountDisclosed-euint64-uint64-) -#### IERC165 [!toc] @@ -235,7 +243,7 @@ Returns the encrypted amount that was actually transferred.
-Similar to #IERC7984-confidentialTransfer-address-externalEuint64-bytes- but without an input proof. The caller +Similar to `confidentialTransfer-address-externalEuint64-bytes` but without an input proof. The caller *must* already be allowed by ACL for the given `amount`.
@@ -273,7 +281,7 @@ Returns the encrypted amount that was actually transferred.
-Similar to #IERC7984-confidentialTransferFrom-address-address-externalEuint64-bytes- but without an input proof. +Similar to `confidentialTransferFrom-address-address-externalEuint64-bytes` but without an input proof. The caller *must* be already allowed by ACL for the given `amount`.
@@ -291,7 +299,7 @@ The caller *must* be already allowed by ACL for the given `amount`.
-Similar to #IERC7984-confidentialTransfer-address-externalEuint64-bytes- but with a callback to `to` after +Similar to `confidentialTransfer-address-externalEuint64-bytes` but with a callback to `to` after the transfer. The callback is made to the [`IERC7984Receiver.onConfidentialTransferReceived`](#IERC7984Receiver-onConfidentialTransferReceived-address-address-euint64-bytes-) function on the @@ -313,7 +321,7 @@ data `data`.
-Similar to #IERC7984-confidentialTransfer-address-euint64- but with a callback to `to` after the transfer. +Similar to `confidentialTransfer-address-euint64` but with a callback to `to` after the transfer.
@@ -330,7 +338,7 @@ Similar to #IERC7984-confidentialTransfer-address-euint64- but with a callback t
-Similar to #IERC7984-confidentialTransferFrom-address-address-externalEuint64-bytes- but with a callback to `to` +Similar to `confidentialTransferFrom-address-address-externalEuint64-bytes` but with a callback to `to` after the transfer.
@@ -348,7 +356,7 @@ after the transfer.
-Similar to #IERC7984-confidentialTransferFrom-address-address-euint64- but with a callback to `to` +Similar to `confidentialTransferFrom-address-address-euint64` but with a callback to `to` after the transfer.
@@ -410,20 +418,240 @@ should be able to disclose the amount. This functionality is implementation spec + + +
+ +## `IERC7984ERC20Wrapper` + + + + + +
+ +```solidity +import "@openzeppelin/confidential-contracts/contracts/interfaces/IERC7984ERC20Wrapper.sol"; +``` + +Interface for ERC7984ERC20Wrapper contract. + +
+

Functions

+
+- [wrap(to, amount)](#IERC7984ERC20Wrapper-wrap-address-uint256-) +- [unwrap(from, to, encryptedAmount, inputProof)](#IERC7984ERC20Wrapper-unwrap-address-address-externalEuint64-bytes-) +- [underlying()](#IERC7984ERC20Wrapper-underlying--) +- [finalizeUnwrap(unwrapRequestId, unwrapAmountCleartext, decryptionProof)](#IERC7984ERC20Wrapper-finalizeUnwrap-bytes32-uint64-bytes-) +- [rate()](#IERC7984ERC20Wrapper-rate--) +- [unwrapAmount(unwrapRequestId)](#IERC7984ERC20Wrapper-unwrapAmount-bytes32-) +
+IERC7984 + +- [name()](#IERC7984-name--) +- [symbol()](#IERC7984-symbol--) +- [decimals()](#IERC7984-decimals--) +- [contractURI()](#IERC7984-contractURI--) +- [confidentialTotalSupply()](#IERC7984-confidentialTotalSupply--) +- [confidentialBalanceOf(account)](#IERC7984-confidentialBalanceOf-address-) +- [isOperator(holder, spender)](#IERC7984-isOperator-address-address-) +- [setOperator(operator, until)](#IERC7984-setOperator-address-uint48-) +- [confidentialTransfer(to, encryptedAmount, inputProof)](#IERC7984-confidentialTransfer-address-externalEuint64-bytes-) +- [confidentialTransfer(to, amount)](#IERC7984-confidentialTransfer-address-euint64-) +- [confidentialTransferFrom(from, to, encryptedAmount, inputProof)](#IERC7984-confidentialTransferFrom-address-address-externalEuint64-bytes-) +- [confidentialTransferFrom(from, to, amount)](#IERC7984-confidentialTransferFrom-address-address-euint64-) +- [confidentialTransferAndCall(to, encryptedAmount, inputProof, data)](#IERC7984-confidentialTransferAndCall-address-externalEuint64-bytes-bytes-) +- [confidentialTransferAndCall(to, amount, data)](#IERC7984-confidentialTransferAndCall-address-euint64-bytes-) +- [confidentialTransferFromAndCall(from, to, encryptedAmount, inputProof, data)](#IERC7984-confidentialTransferFromAndCall-address-address-externalEuint64-bytes-bytes-) +- [confidentialTransferFromAndCall(from, to, amount, data)](#IERC7984-confidentialTransferFromAndCall-address-address-euint64-bytes-) + +
+
+IERC165 + +- [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) + +
+
+
+ +
+

Events

+
+- [UnwrapRequested(receiver, unwrapRequestId, amount)](#IERC7984ERC20Wrapper-UnwrapRequested-address-bytes32-euint64-) +- [UnwrapFinalized(receiver, unwrapRequestId, encryptedAmount, cleartextAmount)](#IERC7984ERC20Wrapper-UnwrapFinalized-address-bytes32-euint64-uint64-) +
+IERC7984 + +- [OperatorSet(holder, operator, until)](#IERC7984-OperatorSet-address-address-uint48-) +- [ConfidentialTransfer(from, to, amount)](#IERC7984-ConfidentialTransfer-address-address-euint64-) +- [AmountDisclosed(encryptedAmount, amount)](#IERC7984-AmountDisclosed-euint64-uint64-) + +
+
+
+ + + +
+
+

wrap(address to, uint256 amount) → euint64

+
+

external

+# +
+
+
+ +Wraps `amount` of the underlying token into a confidential token and sends it to `to`. + +Returns amount of wrapped token sent. + +
+
+ + + +
+
+

unwrap(address from, address to, externalEuint64 encryptedAmount, bytes inputProof) → bytes32

+
+

external

+# +
+
+
+ +Unwraps tokens from `from` and sends the underlying tokens to `to`. The caller must be `from` +or be an approved operator for `from`. + +Returns the unwrap request id. + + +The returned unwrap request id must never be zero. + + +
+
+ + + +
+
+

underlying() → address

+
+

external

+# +
+
+
+ +Returns the address of the underlying ERC-20 token that is being wrapped. + +
+
+ + + +
+
+

finalizeUnwrap(bytes32 unwrapRequestId, uint64 unwrapAmountCleartext, bytes decryptionProof)

+
+

external

+# +
+
+
+ +Finalizes an unwrap request identified by `unwrapRequestId` with the given `unwrapAmountCleartext` and `decryptionProof`. + +
+
+ + + +
+
+

rate() → uint256

+
+

external

+# +
+
+
+ +Returns the rate at which the underlying token is converted to the wrapped token. +For example, if the `rate` is 1000, then 1000 units of the underlying token equal 1 unit of the wrapped token. + +
+
+ + + +
+
+

unwrapAmount(bytes32 unwrapRequestId) → euint64

+
+

external

+# +
+
+
+ +Returns the amount of wrapper tokens that were unwrapped for a given `unwrapRequestId`. + +
+
+ + + +
+
+

UnwrapRequested(address indexed receiver, bytes32 indexed unwrapRequestId, euint64 amount)

+
+

event

+# +
+
+ +
+ +Emitted when an unwrap request is made for a given `receiver`, `unwrapRequestId`, and `amount`. + +
+
+ + +
+
+

UnwrapFinalized(address indexed receiver, bytes32 indexed unwrapRequestId, euint64 encryptedAmount, uint64 cleartextAmount)

+
+

event

+# +
+
+ +
+ +Emitted when an unwrap request is finalized for a given `receiver`, `unwrapRequestId`, `encryptedAmount`, and `cleartextAmount`. + +
+
+
-## `IERC7984Receiver` +## `IERC7984Receiver` - +
```solidity -import "@openzeppelin/confidential-contracts/interfaces/IERC7984Receiver.sol"; +import "@openzeppelin/confidential-contracts/contracts/interfaces/IERC7984Receiver.sol"; ``` Interface for contracts that can receive ERC7984 transfers with a callback. @@ -448,7 +676,15 @@ Interface for contracts that can receive ERC7984 transfers with a callback.
Called upon receiving a confidential token transfer. Returns an encrypted boolean indicating success -of the callback. If false is returned, the transfer must be reversed. +of the callback. If false is returned, the token contract will attempt to refund the transfer. + + +The calling contract (token) must be granted ACL allowance to read the confidential return value. + + + +Do not manually refund the transfer AND return false, as this can lead to double refunds. +
@@ -457,16 +693,16 @@ of the callback. If false is returned, the transfer must be reversed.
-## `IERC7984Rwa` +## `IERC7984Rwa` - +
```solidity -import "@openzeppelin/confidential-contracts/interfaces/IERC7984Rwa.sol"; +import "@openzeppelin/confidential-contracts/contracts/interfaces/IERC7984Rwa.sol"; ``` Interface for confidential RWA contracts. @@ -475,7 +711,7 @@ Interface for confidential RWA contracts.

Functions

- [paused()](#IERC7984Rwa-paused--) -- [isUserAllowed(account)](#IERC7984Rwa-isUserAllowed-address-) +- [canTransact(account)](#IERC7984Rwa-canTransact-address-) - [confidentialFrozen(account)](#IERC7984Rwa-confidentialFrozen-address-) - [confidentialAvailable(account)](#IERC7984Rwa-confidentialAvailable-address-) - [pause()](#IERC7984Rwa-pause--) @@ -490,7 +726,9 @@ Interface for confidential RWA contracts. - [confidentialBurn(account, encryptedAmount)](#IERC7984Rwa-confidentialBurn-address-euint64-) - [forceConfidentialTransferFrom(from, to, encryptedAmount, inputProof)](#IERC7984Rwa-forceConfidentialTransferFrom-address-address-externalEuint64-bytes-) - [forceConfidentialTransferFrom(from, to, encryptedAmount)](#IERC7984Rwa-forceConfidentialTransferFrom-address-address-euint64-) -#### IERC7984 [!toc] +
+IERC7984 + - [name()](#IERC7984-name--) - [symbol()](#IERC7984-symbol--) - [decimals()](#IERC7984-decimals--) @@ -507,19 +745,28 @@ Interface for confidential RWA contracts. - [confidentialTransferAndCall(to, amount, data)](#IERC7984-confidentialTransferAndCall-address-euint64-bytes-) - [confidentialTransferFromAndCall(from, to, encryptedAmount, inputProof, data)](#IERC7984-confidentialTransferFromAndCall-address-address-externalEuint64-bytes-bytes-) - [confidentialTransferFromAndCall(from, to, amount, data)](#IERC7984-confidentialTransferFromAndCall-address-address-euint64-bytes-) -#### IERC165 [!toc] + +
+
+IERC165 + - [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) + +

Events

-#### IERC7984 [!toc] +
+IERC7984 + - [OperatorSet(holder, operator, until)](#IERC7984-OperatorSet-address-address-uint48-) - [ConfidentialTransfer(from, to, amount)](#IERC7984-ConfidentialTransfer-address-address-euint64-) - [AmountDisclosed(encryptedAmount, amount)](#IERC7984-AmountDisclosed-euint64-uint64-) -#### IERC165 [!toc] + +
@@ -540,14 +787,14 @@ Returns true if the contract is paused, false otherwise. - +
-

isUserAllowed(address account) → bool

+

canTransact(address account) → bool

external

-# +#
diff --git a/content/confidential-contracts/api/token.mdx b/content/confidential-contracts/api/token.mdx index c1cb0ba9..e5215b12 100644 --- a/content/confidential-contracts/api/token.mdx +++ b/content/confidential-contracts/api/token.mdx @@ -12,6 +12,7 @@ This set of interfaces, contracts, and utilities are all related to `ERC7984`, a * [`ERC7984Restricted`](#ERC7984Restricted): An extension of [`ERC7984`](#ERC7984) that implements user account transfer restrictions. * [`ERC7984Omnibus`](#ERC7984Omnibus): An extension of [`ERC7984`](#ERC7984) that emits additional events for omnibus transfers, which contain encrypted addresses for the sub-account sender and recipient. * [`ERC7984Rwa`](#ERC7984Rwa): Extension of [`ERC7984`](#ERC7984) that supports confidential Real World Assets (RWAs) by providing compliance checks, transfer controls and enforcement actions. +* [`ERC7984Votes`](#ERC7984Votes): An extension of [`ERC7984`](#ERC7984) that supports confidential vote tracking and delegation via [`VotesConfidential`](/confidential-contracts/api/governance#VotesConfidential). * [`ERC7984Utils`](#ERC7984Utils): A library that provides the on-transfer callback check used by [`ERC7984`](#ERC7984). ## Core @@ -24,6 +25,7 @@ This set of interfaces, contracts, and utilities are all related to `ERC7984`, a [`ERC7984Restricted`](#ERC7984Restricted) [`ERC7984Omnibus`](#ERC7984Omnibus) [`ERC7984Rwa`](#ERC7984Rwa) +[`ERC7984Votes`](#ERC7984Votes) ## Utilities [`ERC7984Utils`](#ERC7984Utils) @@ -32,16 +34,16 @@ This set of interfaces, contracts, and utilities are all related to `ERC7984`, a
-## `ERC7984` +## `ERC7984` - +
```solidity -import "@openzeppelin/confidential-contracts/token/ERC7984/ERC7984.sol"; +import "@openzeppelin/confidential-contracts/contracts/token/ERC7984/ERC7984.sol"; ``` Reference implementation for [`IERC7984`](/confidential-contracts/api/interfaces#IERC7984). @@ -87,9 +89,6 @@ Key features: - [_transfer(from, to, amount)](#ERC7984-_transfer-address-address-euint64-) - [_transferAndCall(from, to, amount, data)](#ERC7984-_transferAndCall-address-address-euint64-bytes-) - [_update(from, to, amount)](#ERC7984-_update-address-address-euint64-) -#### ERC165 [!toc] -#### IERC7984 [!toc] -#### IERC165 [!toc]
@@ -97,12 +96,14 @@ Key features:

Events

- [AmountDiscloseRequested(encryptedAmount, requester)](#ERC7984-AmountDiscloseRequested-euint64-address-) -#### ERC165 [!toc] -#### IERC7984 [!toc] +
+IERC7984 + - [OperatorSet(holder, operator, until)](#IERC7984-OperatorSet-address-address-uint48-) - [ConfidentialTransfer(from, to, amount)](#IERC7984-ConfidentialTransfer-address-address-euint64-) - [AmountDisclosed(encryptedAmount, amount)](#IERC7984-AmountDisclosed-euint64-uint64-) -#### IERC165 [!toc] + +
@@ -115,10 +116,6 @@ Key features: - [ERC7984ZeroBalance(holder)](#ERC7984-ERC7984ZeroBalance-address-) - [ERC7984UnauthorizedUseOfEncryptedAmount(amount, user)](#ERC7984-ERC7984UnauthorizedUseOfEncryptedAmount-euint64-address-) - [ERC7984UnauthorizedCaller(caller)](#ERC7984-ERC7984UnauthorizedCaller-address-) -- [ERC7984InvalidGatewayRequest(requestId)](#ERC7984-ERC7984InvalidGatewayRequest-uint256-) -#### ERC165 [!toc] -#### IERC7984 [!toc] -#### IERC165 [!toc] @@ -330,7 +327,7 @@ Returns the encrypted amount that was actually transferred.
-Similar to interfaces#IERC7984-confidentialTransfer-address-externalEuint64-bytes- but without an input proof. The caller +Similar to `confidentialTransfer-address-externalEuint64-bytes` but without an input proof. The caller *must* already be allowed by ACL for the given `amount`.
@@ -368,7 +365,7 @@ Returns the encrypted amount that was actually transferred.
-Similar to interfaces#IERC7984-confidentialTransferFrom-address-address-externalEuint64-bytes- but without an input proof. +Similar to `confidentialTransferFrom-address-address-externalEuint64-bytes` but without an input proof. The caller *must* be already allowed by ACL for the given `amount`.
@@ -386,7 +383,7 @@ The caller *must* be already allowed by ACL for the given `amount`.
-Similar to interfaces#IERC7984-confidentialTransfer-address-externalEuint64-bytes- but with a callback to `to` after +Similar to `confidentialTransfer-address-externalEuint64-bytes` but with a callback to `to` after the transfer. The callback is made to the [`IERC7984Receiver.onConfidentialTransferReceived`](/confidential-contracts/api/interfaces#IERC7984Receiver-onConfidentialTransferReceived-address-address-euint64-bytes-) function on the @@ -408,7 +405,7 @@ data `data`.
-Similar to interfaces#IERC7984-confidentialTransfer-address-euint64- but with a callback to `to` after the transfer. +Similar to `confidentialTransfer-address-euint64` but with a callback to `to` after the transfer.
@@ -425,7 +422,7 @@ Similar to interfaces#IERC7984-confidentialTransfer-address-euint64- but with a
-Similar to interfaces#IERC7984-confidentialTransferFrom-address-address-externalEuint64-bytes- but with a callback to `to` +Similar to `confidentialTransferFrom-address-address-externalEuint64-bytes` but with a callback to `to` after the transfer.
@@ -443,7 +440,7 @@ after the transfer.
-Similar to interfaces#IERC7984-confidentialTransferFrom-address-address-euint64- but with a callback to `to` +Similar to `confidentialTransferFrom-address-address-euint64` but with a callback to `to` after the transfer.
@@ -707,37 +704,20 @@ The given caller `caller` is not authorized for the current operation. - - -
-
-

ERC7984InvalidGatewayRequest(uint256 requestId)

-
-

error

-# -
-
-
- -The given gateway request ID `requestId` is invalid. - -
-
-
-## `ERC7984ERC20Wrapper` +## `ERC7984ERC20Wrapper` - +
```solidity -import "@openzeppelin/confidential-contracts/token/ERC7984/extensions/ERC7984ERC20Wrapper.sol"; +import "@openzeppelin/confidential-contracts/contracts/token/ERC7984/extensions/ERC7984ERC20Wrapper.sol"; ``` A wrapper contract built on top of [`ERC7984`](#ERC7984) that allows wrapping an `ERC20` token @@ -753,20 +733,27 @@ tokens such as fee-on-transfer or other deflationary-type tokens are not support

Functions

- [constructor(underlying_)](#ERC7984ERC20Wrapper-constructor-contract-IERC20-) -- [decimals()](#ERC7984ERC20Wrapper-decimals--) -- [rate()](#ERC7984ERC20Wrapper-rate--) -- [underlying()](#ERC7984ERC20Wrapper-underlying--) - [onTransferReceived(, from, amount, data)](#ERC7984ERC20Wrapper-onTransferReceived-address-address-uint256-bytes-) - [wrap(to, amount)](#ERC7984ERC20Wrapper-wrap-address-uint256-) - [unwrap(from, to, amount)](#ERC7984ERC20Wrapper-unwrap-address-address-euint64-) - [unwrap(from, to, encryptedAmount, inputProof)](#ERC7984ERC20Wrapper-unwrap-address-address-externalEuint64-bytes-) -- [finalizeUnwrap(burntAmount, burntAmountCleartext, decryptionProof)](#ERC7984ERC20Wrapper-finalizeUnwrap-euint64-uint64-bytes-) +- [finalizeUnwrap(unwrapRequestId, unwrapAmountCleartext, decryptionProof)](#ERC7984ERC20Wrapper-finalizeUnwrap-bytes32-uint64-bytes-) +- [decimals()](#ERC7984ERC20Wrapper-decimals--) +- [rate()](#ERC7984ERC20Wrapper-rate--) +- [underlying()](#ERC7984ERC20Wrapper-underlying--) +- [unwrapAmount(unwrapRequestId)](#ERC7984ERC20Wrapper-unwrapAmount-bytes32-) +- [supportsInterface(interfaceId)](#ERC7984ERC20Wrapper-supportsInterface-bytes4-) +- [inferredTotalSupply()](#ERC7984ERC20Wrapper-inferredTotalSupply--) +- [maxTotalSupply()](#ERC7984ERC20Wrapper-maxTotalSupply--) +- [unwrapRequester(unwrapRequestId)](#ERC7984ERC20Wrapper-unwrapRequester-bytes32-) +- [_checkConfidentialTotalSupply()](#ERC7984ERC20Wrapper-_checkConfidentialTotalSupply--) +- [_update(from, to, amount)](#ERC7984ERC20Wrapper-_update-address-address-euint64-) - [_unwrap(from, to, amount)](#ERC7984ERC20Wrapper-_unwrap-address-address-euint64-) - [_fallbackUnderlyingDecimals()](#ERC7984ERC20Wrapper-_fallbackUnderlyingDecimals--) - [_maxDecimals()](#ERC7984ERC20Wrapper-_maxDecimals--) -#### IERC1363Receiver [!toc] -#### ERC7984 [!toc] -- [supportsInterface(interfaceId)](#ERC7984-supportsInterface-bytes4-) +
+ERC7984 + - [name()](#ERC7984-name--) - [symbol()](#ERC7984-symbol--) - [contractURI()](#ERC7984-contractURI--) @@ -789,46 +776,54 @@ tokens such as fee-on-transfer or other deflationary-type tokens are not support - [_burn(from, amount)](#ERC7984-_burn-address-euint64-) - [_transfer(from, to, amount)](#ERC7984-_transfer-address-address-euint64-) - [_transferAndCall(from, to, amount, data)](#ERC7984-_transferAndCall-address-address-euint64-bytes-) -- [_update(from, to, amount)](#ERC7984-_update-address-address-euint64-) -#### ERC165 [!toc] -#### IERC7984 [!toc] -#### IERC165 [!toc] + +

Events

-- [UnwrapRequested(receiver, amount)](#ERC7984ERC20Wrapper-UnwrapRequested-address-euint64-) -- [UnwrapFinalized(receiver, encryptedAmount, cleartextAmount)](#ERC7984ERC20Wrapper-UnwrapFinalized-address-euint64-uint64-) -#### IERC1363Receiver [!toc] -#### ERC7984 [!toc] +
+IERC7984ERC20Wrapper + +- [UnwrapRequested(receiver, unwrapRequestId, amount)](#IERC7984ERC20Wrapper-UnwrapRequested-address-bytes32-euint64-) +- [UnwrapFinalized(receiver, unwrapRequestId, encryptedAmount, cleartextAmount)](#IERC7984ERC20Wrapper-UnwrapFinalized-address-bytes32-euint64-uint64-) + +
+
+ERC7984 + - [AmountDiscloseRequested(encryptedAmount, requester)](#ERC7984-AmountDiscloseRequested-euint64-address-) -#### ERC165 [!toc] -#### IERC7984 [!toc] + +
+
+IERC7984 + - [OperatorSet(holder, operator, until)](#IERC7984-OperatorSet-address-address-uint48-) - [ConfidentialTransfer(from, to, amount)](#IERC7984-ConfidentialTransfer-address-address-euint64-) - [AmountDisclosed(encryptedAmount, amount)](#IERC7984-AmountDisclosed-euint64-uint64-) -#### IERC165 [!toc] + +

Errors

-- [InvalidUnwrapRequest(amount)](#ERC7984ERC20Wrapper-InvalidUnwrapRequest-euint64-) -#### IERC1363Receiver [!toc] -#### ERC7984 [!toc] +- [InvalidUnwrapRequest(unwrapRequestId)](#ERC7984ERC20Wrapper-InvalidUnwrapRequest-bytes32-) +- [ERC7984TotalSupplyOverflow()](#ERC7984ERC20Wrapper-ERC7984TotalSupplyOverflow--) +
+ERC7984 + - [ERC7984InvalidReceiver(receiver)](#ERC7984-ERC7984InvalidReceiver-address-) - [ERC7984InvalidSender(sender)](#ERC7984-ERC7984InvalidSender-address-) - [ERC7984UnauthorizedSpender(holder, spender)](#ERC7984-ERC7984UnauthorizedSpender-address-address-) - [ERC7984ZeroBalance(holder)](#ERC7984-ERC7984ZeroBalance-address-) - [ERC7984UnauthorizedUseOfEncryptedAmount(amount, user)](#ERC7984-ERC7984UnauthorizedUseOfEncryptedAmount-euint64-address-) - [ERC7984UnauthorizedCaller(caller)](#ERC7984-ERC7984UnauthorizedCaller-address-) -- [ERC7984InvalidGatewayRequest(requestId)](#ERC7984-ERC7984InvalidGatewayRequest-uint256-) -#### ERC165 [!toc] -#### IERC7984 [!toc] -#### IERC165 [!toc] + +
@@ -847,6 +842,101 @@ tokens such as fee-on-transfer or other deflationary-type tokens are not support + + +
+
+

onTransferReceived(address, address from, uint256 amount, bytes data) → bytes4

+
+

public

+# +
+
+
+ +`ERC1363` callback function which wraps tokens to the address specified in `data` or +the address `from` (if no address is specified in `data`). This function refunds any excess tokens +sent beyond the nearest multiple of [`ERC7984ERC20Wrapper.rate`](#ERC7984ERC20Wrapper-rate--) to `from`. See [`ERC7984ERC20Wrapper.wrap`](#ERC7984ERC20Wrapper-wrap-address-uint256-) for more details on wrapping tokens. + +
+
+ + + +
+
+

wrap(address to, uint256 amount) → euint64

+
+

public

+# +
+
+
+ +See [`IERC7984ERC20Wrapper.wrap`](/confidential-contracts/api/interfaces#IERC7984ERC20Wrapper-wrap-address-uint256-). Tokens are exchanged at a fixed rate specified by [`ERC7984ERC20Wrapper.rate`](#ERC7984ERC20Wrapper-rate--) such that +`amount / rate()` confidential tokens are sent. The amount transferred in is rounded down to the nearest +multiple of [`ERC7984ERC20Wrapper.rate`](#ERC7984ERC20Wrapper-rate--). + +Returns the amount of wrapped token sent. + +
+
+ + + +
+
+

unwrap(address from, address to, euint64 amount) → bytes32

+
+

public

+# +
+
+
+ +Unwrap without passing an input proof. See `unwrap-address-address-bytes32-bytes` for more details. + +
+
+ + + +
+
+

unwrap(address from, address to, externalEuint64 encryptedAmount, bytes inputProof) → bytes32

+
+

public

+# +
+
+
+ +See [`IERC7984ERC20Wrapper.unwrap`](/confidential-contracts/api/interfaces#IERC7984ERC20Wrapper-unwrap-address-address-externalEuint64-bytes-). `amount * rate()` underlying tokens are sent to `to`. + + +The unwrap request created by this function must be finalized by calling [`ERC7984ERC20Wrapper.finalizeUnwrap`](#ERC7984ERC20Wrapper-finalizeUnwrap-bytes32-uint64-bytes-). + + +
+
+ + + +
+
+

finalizeUnwrap(bytes32 unwrapRequestId, uint64 unwrapAmountCleartext, bytes decryptionProof)

+
+

public

+# +
+
+
+ +Finalizes an unwrap request identified by `unwrapRequestId` with the given `unwrapAmountCleartext` and `decryptionProof`. + +
+
+
@@ -886,7 +976,7 @@ For example, if the `rate` is 1000, then 1000 units of the underlying token equa
-

underlying() → contract IERC20

+

underlying() → address

public

# @@ -899,100 +989,138 @@ Returns the address of the underlying ERC-20 token that is being wrapped.
- +
-

onTransferReceived(address, address from, uint256 amount, bytes data) → bytes4

+

unwrapAmount(bytes32 unwrapRequestId) → euint64

public

-# +#
-`ERC1363` callback function which wraps tokens to the address specified in `data` or -the address `from` (if no address is specified in `data`). This function refunds any excess tokens -sent beyond the nearest multiple of [`ERC7984ERC20Wrapper.rate`](#ERC7984ERC20Wrapper-rate--). See [`ERC7984ERC20Wrapper.wrap`](#ERC7984ERC20Wrapper-wrap-address-uint256-) from more details on wrapping tokens. +Returns the amount of wrapper tokens that were unwrapped for a given `unwrapRequestId`.
- +
-

wrap(address to, uint256 amount)

+

supportsInterface(bytes4 interfaceId) → bool

public

-# +#
-Wraps amount `amount` of the underlying token into a confidential token and sends it to -`to`. Tokens are exchanged at a fixed rate specified by [`ERC7984ERC20Wrapper.rate`](#ERC7984ERC20Wrapper-rate--) such that `amount / rate()` confidential -tokens are sent. Amount transferred in is rounded down to the nearest multiple of [`ERC7984ERC20Wrapper.rate`](#ERC7984ERC20Wrapper-rate--). +Returns true if this contract implements the interface defined by +`interfaceId`. See the corresponding +[ERC section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) +to learn more about how these ids are created. + +This function call must use less than 30 000 gas.
- +
-

unwrap(address from, address to, euint64 amount)

+

inferredTotalSupply() → uint256

public

-# +#
-Unwraps tokens from `from` and sends the underlying tokens to `to`. The caller must be `from` -or be an approved operator for `from`. `amount * rate()` underlying tokens are sent to `to`. +Returns the underlying balance divided by the [`ERC7984ERC20Wrapper.rate`](#ERC7984ERC20Wrapper-rate--), a value greater or equal to the actual +[`ERC7984.confidentialTotalSupply`](#ERC7984-confidentialTotalSupply--). -The unwrap request created by this function must be finalized by calling [`ERC7984ERC20Wrapper.finalizeUnwrap`](#ERC7984ERC20Wrapper-finalizeUnwrap-euint64-uint64-bytes-). - - -The caller *must* already be approved by ACL for the given `amount`. +The return value of this function can be inflated by directly sending underlying tokens to the wrapper contract. +Reductions will lag compared to [`ERC7984.confidentialTotalSupply`](#ERC7984-confidentialTotalSupply--) since it is updated on [`ERC7984ERC20Wrapper.unwrap`](#ERC7984ERC20Wrapper-unwrap-address-address-externalEuint64-bytes-) while this function updates +on [`ERC7984ERC20Wrapper.finalizeUnwrap`](#ERC7984ERC20Wrapper-finalizeUnwrap-bytes32-uint64-bytes-).
- +
-

unwrap(address from, address to, externalEuint64 encryptedAmount, bytes inputProof)

+

maxTotalSupply() → uint256

public

-# +#
-Variant of [`ERC7984ERC20Wrapper.unwrap`](#ERC7984ERC20Wrapper-unwrap-address-address-externalEuint64-bytes-) that passes an `inputProof` which approves the caller for the `encryptedAmount` -in the ACL. +Returns the maximum total supply of wrapped tokens supported by the encrypted datatype.
- +
-

finalizeUnwrap(euint64 burntAmount, uint64 burntAmountCleartext, bytes decryptionProof)

+

unwrapRequester(bytes32 unwrapRequestId) → address

public

-# +# +
+
+
+ +Gets the address that will receive the ERC-20 tokens associated with a pending unwrap request identified by +`unwrapRequestId`. Returns `address(0)` if there is no pending unwrap request with id `unwrapRequestId`. + +
+
+ + + +
+
+

_checkConfidentialTotalSupply()

+
+

internal

+#
-Fills an unwrap request for a given cipher-text `burntAmount` with the `cleartextAmount` and `decryptionProof`. +This function must revert if the new [`ERC7984.confidentialTotalSupply`](#ERC7984-confidentialTotalSupply--) is invalid (overflow occurred). + + +Overflow can be detected here since the wrapper holdings are non-confidential. In other cases, it may be impossible +to infer total supply overflow synchronously. This function may revert even if the [`ERC7984.confidentialTotalSupply`](#ERC7984-confidentialTotalSupply--) did +not overflow. + + +
+
+ + + +
+
+

_update(address from, address to, euint64 amount) → euint64

+
+

internal

+# +
+
+
@@ -1001,7 +1129,7 @@ Fills an unwrap request for a given cipher-text `burntAmount` with the `cleartex
-

_unwrap(address from, address to, euint64 amount)

+

_unwrap(address from, address to, euint64 amount) → bytes32

internal

# @@ -1009,6 +1137,8 @@ Fills an unwrap request for a given cipher-text `burntAmount` with the `cleartex
+Internal logic for handling the creation of unwrap requests. Returns the unwrap request id. +
@@ -1043,50 +1173,34 @@ ERC-20 token.
-Returns the maximum number that will be used for [`IERC7984.decimals`](/confidential-contracts/api/interfaces#IERC7984-decimals--) by the wrapper. +Returns the maximum number that will be used for [`ERC7984.decimals`](#ERC7984-decimals--) by the wrapper.
- +
-

UnwrapRequested(address indexed receiver, euint64 amount)

+

InvalidUnwrapRequest(bytes32 unwrapRequestId)

-

event

-# -
-
- -
- -
-
- - -
-
-

UnwrapFinalized(address indexed receiver, euint64 encryptedAmount, uint64 cleartextAmount)

-
-

event

-# +

error

+#
-
- +
-

InvalidUnwrapRequest(euint64 amount)

+

ERC7984TotalSupplyOverflow()

error

-# +#
@@ -1098,24 +1212,23 @@ Returns the maximum number that will be used for [`IERC7984.decimals`](/confiden
-## `ERC7984Freezable` +## `ERC7984Freezable` - +
```solidity -import "@openzeppelin/confidential-contracts/token/ERC7984/extensions/ERC7984Freezable.sol"; +import "@openzeppelin/confidential-contracts/contracts/token/ERC7984/extensions/ERC7984Freezable.sol"; ``` Extension of [`ERC7984`](#ERC7984) that implements a confidential -freezing mechanism that can be managed by an authorized account with -[`IERC7984Rwa.setConfidentialFrozen`](/confidential-contracts/api/interfaces#IERC7984Rwa-setConfidentialFrozen-address-euint64-) functions. +freezing mechanism that can be managed by calling the internal function +[`ERC7984Freezable._setConfidentialFrozen`](#ERC7984Freezable-_setConfidentialFrozen-address-euint64-) by an inheriting contract. -The freezing mechanism provides the guarantee to the contract owner -(e.g. a DAO or a well-configured multisig) that a specific confidential +The freezing mechanism provides the guarantee that a specific confidential amount of tokens held by an account won't be transferable until those tokens are unfrozen. @@ -1129,7 +1242,9 @@ Inspired by https://github.com/OpenZeppelin/openzeppelin-community-contracts/blo - [_confidentialAvailable(account)](#ERC7984Freezable-_confidentialAvailable-address-) - [_setConfidentialFrozen(account, encryptedAmount)](#ERC7984Freezable-_setConfidentialFrozen-address-euint64-) - [_update(from, to, encryptedAmount)](#ERC7984Freezable-_update-address-address-euint64-) -#### ERC7984 [!toc] +
+ERC7984 + - [supportsInterface(interfaceId)](#ERC7984-supportsInterface-bytes4-) - [name()](#ERC7984-name--) - [symbol()](#ERC7984-symbol--) @@ -1154,9 +1269,8 @@ Inspired by https://github.com/OpenZeppelin/openzeppelin-community-contracts/blo - [_burn(from, amount)](#ERC7984-_burn-address-euint64-) - [_transfer(from, to, amount)](#ERC7984-_transfer-address-address-euint64-) - [_transferAndCall(from, to, amount, data)](#ERC7984-_transferAndCall-address-address-euint64-bytes-) -#### ERC165 [!toc] -#### IERC7984 [!toc] -#### IERC165 [!toc] + +
@@ -1164,31 +1278,37 @@ Inspired by https://github.com/OpenZeppelin/openzeppelin-community-contracts/blo

Events

- [TokensFrozen(account, encryptedAmount)](#ERC7984Freezable-TokensFrozen-address-euint64-) -#### ERC7984 [!toc] +
+ERC7984 + - [AmountDiscloseRequested(encryptedAmount, requester)](#ERC7984-AmountDiscloseRequested-euint64-address-) -#### ERC165 [!toc] -#### IERC7984 [!toc] + +
+
+IERC7984 + - [OperatorSet(holder, operator, until)](#IERC7984-OperatorSet-address-address-uint48-) - [ConfidentialTransfer(from, to, amount)](#IERC7984-ConfidentialTransfer-address-address-euint64-) - [AmountDisclosed(encryptedAmount, amount)](#IERC7984-AmountDisclosed-euint64-uint64-) -#### IERC165 [!toc] + +

Errors

-#### ERC7984 [!toc] +
+ERC7984 + - [ERC7984InvalidReceiver(receiver)](#ERC7984-ERC7984InvalidReceiver-address-) - [ERC7984InvalidSender(sender)](#ERC7984-ERC7984InvalidSender-address-) - [ERC7984UnauthorizedSpender(holder, spender)](#ERC7984-ERC7984UnauthorizedSpender-address-address-) - [ERC7984ZeroBalance(holder)](#ERC7984-ERC7984ZeroBalance-address-) - [ERC7984UnauthorizedUseOfEncryptedAmount(amount, user)](#ERC7984-ERC7984UnauthorizedUseOfEncryptedAmount-euint64-address-) - [ERC7984UnauthorizedCaller(caller)](#ERC7984-ERC7984UnauthorizedCaller-address-) -- [ERC7984InvalidGatewayRequest(requestId)](#ERC7984-ERC7984InvalidGatewayRequest-uint256-) -#### ERC165 [!toc] -#### IERC7984 [!toc] -#### IERC165 [!toc] + +
@@ -1305,20 +1425,20 @@ Emitted when a confidential amount of token is frozen for an account
-## `ERC7984ObserverAccess` +## `ERC7984ObserverAccess` - +
```solidity -import "@openzeppelin/confidential-contracts/token/ERC7984/extensions/ERC7984ObserverAccess.sol"; +import "@openzeppelin/confidential-contracts/contracts/token/ERC7984/extensions/ERC7984ObserverAccess.sol"; ``` -Extension of [`ERC7984`](#ERC7984) that allows each account to add a observer who is given -permanent ACL access to its transfer and balance amounts. A observer can be added or removed at any point in time. +Extension of [`ERC7984`](#ERC7984) that allows each account to add an observer who is given +permanent ACL access to its transfer and balance amounts. An observer can be added or removed at any point in time.

Functions

@@ -1326,7 +1446,9 @@ permanent ACL access to its transfer and balance amounts. A observer can be adde - [setObserver(account, newObserver)](#ERC7984ObserverAccess-setObserver-address-address-) - [observer(account)](#ERC7984ObserverAccess-observer-address-) - [_update(from, to, amount)](#ERC7984ObserverAccess-_update-address-address-euint64-) -#### ERC7984 [!toc] +
+ERC7984 + - [supportsInterface(interfaceId)](#ERC7984-supportsInterface-bytes4-) - [name()](#ERC7984-name--) - [symbol()](#ERC7984-symbol--) @@ -1351,9 +1473,8 @@ permanent ACL access to its transfer and balance amounts. A observer can be adde - [_burn(from, amount)](#ERC7984-_burn-address-euint64-) - [_transfer(from, to, amount)](#ERC7984-_transfer-address-address-euint64-) - [_transferAndCall(from, to, amount, data)](#ERC7984-_transferAndCall-address-address-euint64-bytes-) -#### ERC165 [!toc] -#### IERC7984 [!toc] -#### IERC165 [!toc] + +
@@ -1361,14 +1482,20 @@ permanent ACL access to its transfer and balance amounts. A observer can be adde

Events

- [ERC7984ObserverAccessObserverSet(account, oldObserver, newObserver)](#ERC7984ObserverAccess-ERC7984ObserverAccessObserverSet-address-address-address-) -#### ERC7984 [!toc] +
+ERC7984 + - [AmountDiscloseRequested(encryptedAmount, requester)](#ERC7984-AmountDiscloseRequested-euint64-address-) -#### ERC165 [!toc] -#### IERC7984 [!toc] + +
+
+IERC7984 + - [OperatorSet(holder, operator, until)](#IERC7984-OperatorSet-address-address-uint48-) - [ConfidentialTransfer(from, to, amount)](#IERC7984-ConfidentialTransfer-address-address-euint64-) - [AmountDisclosed(encryptedAmount, amount)](#IERC7984-AmountDisclosed-euint64-uint64-) -#### IERC165 [!toc] + +
@@ -1376,17 +1503,17 @@ permanent ACL access to its transfer and balance amounts. A observer can be adde

Errors

- [Unauthorized()](#ERC7984ObserverAccess-Unauthorized--) -#### ERC7984 [!toc] +
+ERC7984 + - [ERC7984InvalidReceiver(receiver)](#ERC7984-ERC7984InvalidReceiver-address-) - [ERC7984InvalidSender(sender)](#ERC7984-ERC7984InvalidSender-address-) - [ERC7984UnauthorizedSpender(holder, spender)](#ERC7984-ERC7984UnauthorizedSpender-address-address-) - [ERC7984ZeroBalance(holder)](#ERC7984-ERC7984ZeroBalance-address-) - [ERC7984UnauthorizedUseOfEncryptedAmount(amount, user)](#ERC7984-ERC7984UnauthorizedUseOfEncryptedAmount-euint64-address-) - [ERC7984UnauthorizedCaller(caller)](#ERC7984-ERC7984UnauthorizedCaller-address-) -- [ERC7984InvalidGatewayRequest(requestId)](#ERC7984-ERC7984InvalidGatewayRequest-uint256-) -#### ERC165 [!toc] -#### IERC7984 [!toc] -#### IERC165 [!toc] + +
@@ -1479,16 +1606,16 @@ Thrown when an account tries to set a `newObserver` for a given `account` withou
-## `ERC7984Omnibus` +## `ERC7984Omnibus` - +
```solidity -import "@openzeppelin/confidential-contracts/token/ERC7984/extensions/ERC7984Omnibus.sol"; +import "@openzeppelin/confidential-contracts/contracts/token/ERC7984/extensions/ERC7984Omnibus.sol"; ``` Extension of [`ERC7984`](#ERC7984) that emits additional events for omnibus transfers. @@ -1512,7 +1639,9 @@ balances externally. - [confidentialTransferFromAndCallOmnibus(omnibusFrom, omnibusTo, sender, recipient, amount, data)](#ERC7984Omnibus-confidentialTransferFromAndCallOmnibus-address-address-eaddress-eaddress-euint64-bytes-) - [_confidentialTransferFromOmnibus(omnibusFrom, omnibusTo, sender, recipient, amount)](#ERC7984Omnibus-_confidentialTransferFromOmnibus-address-address-eaddress-eaddress-euint64-) - [_confidentialTransferFromAndCallOmnibus(omnibusFrom, omnibusTo, sender, recipient, amount, data)](#ERC7984Omnibus-_confidentialTransferFromAndCallOmnibus-address-address-eaddress-eaddress-euint64-bytes-) -#### ERC7984 [!toc] +
+ERC7984 + - [supportsInterface(interfaceId)](#ERC7984-supportsInterface-bytes4-) - [name()](#ERC7984-name--) - [symbol()](#ERC7984-symbol--) @@ -1538,9 +1667,8 @@ balances externally. - [_transfer(from, to, amount)](#ERC7984-_transfer-address-address-euint64-) - [_transferAndCall(from, to, amount, data)](#ERC7984-_transferAndCall-address-address-euint64-bytes-) - [_update(from, to, amount)](#ERC7984-_update-address-address-euint64-) -#### ERC165 [!toc] -#### IERC7984 [!toc] -#### IERC165 [!toc] + +
@@ -1548,14 +1676,20 @@ balances externally.

Events

- [OmnibusConfidentialTransfer(omnibusFrom, omnibusTo, sender, recipient, amount)](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) -#### ERC7984 [!toc] +
+ERC7984 + - [AmountDiscloseRequested(encryptedAmount, requester)](#ERC7984-AmountDiscloseRequested-euint64-address-) -#### ERC165 [!toc] -#### IERC7984 [!toc] + +
+
+IERC7984 + - [OperatorSet(holder, operator, until)](#IERC7984-OperatorSet-address-address-uint48-) - [ConfidentialTransfer(from, to, amount)](#IERC7984-ConfidentialTransfer-address-address-euint64-) - [AmountDisclosed(encryptedAmount, amount)](#IERC7984-AmountDisclosed-euint64-uint64-) -#### IERC165 [!toc] + +
@@ -1563,17 +1697,17 @@ balances externally.

Errors

- [ERC7984UnauthorizedUseOfEncryptedAddress(addr, user)](#ERC7984Omnibus-ERC7984UnauthorizedUseOfEncryptedAddress-eaddress-address-) -#### ERC7984 [!toc] +
+ERC7984 + - [ERC7984InvalidReceiver(receiver)](#ERC7984-ERC7984InvalidReceiver-address-) - [ERC7984InvalidSender(sender)](#ERC7984-ERC7984InvalidSender-address-) - [ERC7984UnauthorizedSpender(holder, spender)](#ERC7984-ERC7984UnauthorizedSpender-address-address-) - [ERC7984ZeroBalance(holder)](#ERC7984-ERC7984ZeroBalance-address-) - [ERC7984UnauthorizedUseOfEncryptedAmount(amount, user)](#ERC7984-ERC7984UnauthorizedUseOfEncryptedAmount-euint64-address-) - [ERC7984UnauthorizedCaller(caller)](#ERC7984-ERC7984UnauthorizedCaller-address-) -- [ERC7984InvalidGatewayRequest(requestId)](#ERC7984-ERC7984InvalidGatewayRequest-uint256-) -#### ERC165 [!toc] -#### IERC7984 [!toc] -#### IERC165 [!toc] + +
@@ -1589,7 +1723,7 @@ balances externally.
-Wraps the interfaces#IERC7984-confidentialTransfer-address-externalEuint64-bytes- function and emits the [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) event. +Wraps the `confidentialTransfer-address-externalEuint64-bytes` function and emits the [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) event.
@@ -1606,7 +1740,7 @@ Wraps the interfaces#IERC7984-confidentialTransfer-address-externalEuint64-bytes
-Wraps the interfaces#IERC7984-confidentialTransfer-address-euint64- function and emits the [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) event. +Wraps the `confidentialTransfer-address-euint64` function and emits the [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) event.
@@ -1623,7 +1757,7 @@ Wraps the interfaces#IERC7984-confidentialTransfer-address-euint64- function and
-Wraps the interfaces#IERC7984-confidentialTransferFrom-address-address-externalEuint64-bytes- function and emits the [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) event. +Wraps the `confidentialTransferFrom-address-address-externalEuint64-bytes` function and emits the [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) event.
@@ -1640,7 +1774,7 @@ Wraps the interfaces#IERC7984-confidentialTransferFrom-address-address-externalE
-Wraps the interfaces#IERC7984-confidentialTransferFrom-address-address-euint64- function and emits the [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) event. +Wraps the `confidentialTransferFrom-address-address-euint64` function and emits the [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) event.
@@ -1657,7 +1791,7 @@ Wraps the interfaces#IERC7984-confidentialTransferFrom-address-address-euint64-
-Wraps the interfaces#IERC7984-confidentialTransferAndCall-address-externalEuint64-bytes-bytes- function and emits the [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) event. +Wraps the `confidentialTransferAndCall-address-externalEuint64-bytes-bytes` function and emits the [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) event.
@@ -1674,7 +1808,7 @@ Wraps the interfaces#IERC7984-confidentialTransferAndCall-address-externalEuint6
-Wraps the interfaces#IERC7984-confidentialTransferAndCall-address-euint64-bytes- function and emits the [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) event. +Wraps the `confidentialTransferAndCall-address-euint64-bytes` function and emits the [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) event.
@@ -1691,7 +1825,7 @@ Wraps the interfaces#IERC7984-confidentialTransferAndCall-address-euint64-bytes-
-Wraps the interfaces#IERC7984-confidentialTransferFromAndCall-address-address-externalEuint64-bytes-bytes- function and emits the [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) event. +Wraps the `confidentialTransferFromAndCall-address-address-externalEuint64-bytes-bytes` function and emits the [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) event.
@@ -1708,7 +1842,7 @@ Wraps the interfaces#IERC7984-confidentialTransferFromAndCall-address-address-ex
-Wraps the interfaces#IERC7984-confidentialTransferFromAndCall-address-address-euint64-bytes- function and emits the [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) event. +Wraps the `confidentialTransferFromAndCall-address-address-euint64-bytes` function and emits the [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) event.
@@ -1796,31 +1930,31 @@ Try using the equivalent transfer function with an input proof.
-## `ERC7984Restricted` +## `ERC7984Restricted` - +
```solidity -import "@openzeppelin/confidential-contracts/token/ERC7984/extensions/ERC7984Restricted.sol"; +import "@openzeppelin/confidential-contracts/contracts/token/ERC7984/extensions/ERC7984Restricted.sol"; ``` Extension of [`ERC7984`](#ERC7984) that implements user account transfer restrictions through the -[`IERC7984Rwa.isUserAllowed`](/confidential-contracts/api/interfaces#IERC7984Rwa-isUserAllowed-address-) function. Inspired by +[`ERC7984Restricted.canTransact`](#ERC7984Restricted-canTransact-address-) function. Inspired by https://github.com/OpenZeppelin/openzeppelin-community-contracts/blob/master/contracts/token/ERC20/extensions/ERC20Restricted.sol. -By default, each account has no explicit restriction. The [`IERC7984Rwa.isUserAllowed`](/confidential-contracts/api/interfaces#IERC7984Rwa-isUserAllowed-address-) function acts as -a blocklist. Developers can override [`IERC7984Rwa.isUserAllowed`](/confidential-contracts/api/interfaces#IERC7984Rwa-isUserAllowed-address-) to check that `restriction == ALLOWED` +By default, each account has no explicit restriction. The [`ERC7984Restricted.canTransact`](#ERC7984Restricted-canTransact-address-) function acts as +a blocklist. Developers can override [`ERC7984Restricted.canTransact`](#ERC7984Restricted-canTransact-address-) to check that `restriction == ALLOWED` to implement an allowlist.

Functions

- [getRestriction(account)](#ERC7984Restricted-getRestriction-address-) -- [isUserAllowed(account)](#ERC7984Restricted-isUserAllowed-address-) +- [canTransact(account)](#ERC7984Restricted-canTransact-address-) - [_update(from, to, value)](#ERC7984Restricted-_update-address-address-euint64-) - [_setRestriction(account, restriction)](#ERC7984Restricted-_setRestriction-address-enum-ERC7984Restricted-Restriction-) - [_blockUser(account)](#ERC7984Restricted-_blockUser-address-) @@ -1829,7 +1963,9 @@ to implement an allowlist. - [_checkRestriction(account)](#ERC7984Restricted-_checkRestriction-address-) - [_checkSenderRestriction(account)](#ERC7984Restricted-_checkSenderRestriction-address-) - [_checkRecipientRestriction(account)](#ERC7984Restricted-_checkRecipientRestriction-address-) -#### ERC7984 [!toc] +
+ERC7984 + - [supportsInterface(interfaceId)](#ERC7984-supportsInterface-bytes4-) - [name()](#ERC7984-name--) - [symbol()](#ERC7984-symbol--) @@ -1854,9 +1990,8 @@ to implement an allowlist. - [_burn(from, amount)](#ERC7984-_burn-address-euint64-) - [_transfer(from, to, amount)](#ERC7984-_transfer-address-address-euint64-) - [_transferAndCall(from, to, amount, data)](#ERC7984-_transferAndCall-address-address-euint64-bytes-) -#### ERC165 [!toc] -#### IERC7984 [!toc] -#### IERC165 [!toc] + +
@@ -1864,14 +1999,20 @@ to implement an allowlist.

Events

- [UserRestrictionUpdated(account, restriction)](#ERC7984Restricted-UserRestrictionUpdated-address-enum-ERC7984Restricted-Restriction-) -#### ERC7984 [!toc] +
+ERC7984 + - [AmountDiscloseRequested(encryptedAmount, requester)](#ERC7984-AmountDiscloseRequested-euint64-address-) -#### ERC165 [!toc] -#### IERC7984 [!toc] + +
+
+IERC7984 + - [OperatorSet(holder, operator, until)](#IERC7984-OperatorSet-address-address-uint48-) - [ConfidentialTransfer(from, to, amount)](#IERC7984-ConfidentialTransfer-address-address-euint64-) - [AmountDisclosed(encryptedAmount, amount)](#IERC7984-AmountDisclosed-euint64-uint64-) -#### IERC165 [!toc] + +
@@ -1879,17 +2020,17 @@ to implement an allowlist.

Errors

- [UserRestricted(account)](#ERC7984Restricted-UserRestricted-address-) -#### ERC7984 [!toc] +
+ERC7984 + - [ERC7984InvalidReceiver(receiver)](#ERC7984-ERC7984InvalidReceiver-address-) - [ERC7984InvalidSender(sender)](#ERC7984-ERC7984InvalidSender-address-) - [ERC7984UnauthorizedSpender(holder, spender)](#ERC7984-ERC7984UnauthorizedSpender-address-address-) - [ERC7984ZeroBalance(holder)](#ERC7984-ERC7984ZeroBalance-address-) - [ERC7984UnauthorizedUseOfEncryptedAmount(amount, user)](#ERC7984-ERC7984UnauthorizedUseOfEncryptedAmount-euint64-address-) - [ERC7984UnauthorizedCaller(caller)](#ERC7984-ERC7984UnauthorizedCaller-address-) -- [ERC7984InvalidGatewayRequest(requestId)](#ERC7984-ERC7984InvalidGatewayRequest-uint256-) -#### ERC165 [!toc] -#### IERC7984 [!toc] -#### IERC165 [!toc] + +
@@ -1910,14 +2051,14 @@ Returns the restriction of a user account. - +
-

isUserAllowed(address account) → bool

+

canTransact(address account) → bool

public

-# +#
@@ -1945,8 +2086,8 @@ See [`ERC7984._update`](#ERC7984-_update-address-address-euint64-). Enforces tra Requirements: -* `from` must be allowed to transfer tokens (see [`IERC7984Rwa.isUserAllowed`](/confidential-contracts/api/interfaces#IERC7984Rwa-isUserAllowed-address-)). -* `to` must be allowed to receive tokens (see [`IERC7984Rwa.isUserAllowed`](/confidential-contracts/api/interfaces#IERC7984Rwa-isUserAllowed-address-)). +* `from` must be allowed to transfer tokens (see [`ERC7984Restricted.canTransact`](#ERC7984Restricted-canTransact-address-)). +* `to` must be allowed to receive tokens (see [`ERC7984Restricted.canTransact`](#ERC7984Restricted-canTransact-address-)). The default restriction behavior can be changed (for a pass-through for instance) by overriding [`ERC7984Restricted._checkSenderRestriction`](#ERC7984Restricted-_checkSenderRestriction-address-) and/or [`ERC7984Restricted._checkRecipientRestriction`](#ERC7984Restricted-_checkRecipientRestriction-address-). @@ -2114,16 +2255,16 @@ The operation failed because the user account is restricted.
-## `ERC7984Rwa` +## `ERC7984Rwa` - +
```solidity -import "@openzeppelin/confidential-contracts/token/ERC7984/extensions/ERC7984Rwa.sol"; +import "@openzeppelin/confidential-contracts/contracts/token/ERC7984/extensions/ERC7984Rwa.sol"; ``` Extension of [`ERC7984`](#ERC7984) that supports confidential Real World Assets (RWAs). @@ -2161,12 +2302,14 @@ This interface provides compliance checks, transfer controls and enforcement act - [confidentialAvailable(account)](#ERC7984Rwa-confidentialAvailable-address-) - [confidentialFrozen(account)](#ERC7984Rwa-confidentialFrozen-address-) - [paused()](#ERC7984Rwa-paused--) -- [isUserAllowed(account)](#ERC7984Rwa-isUserAllowed-address-) +- [canTransact(account)](#ERC7984Rwa-canTransact-address-) - [_update(from, to, encryptedAmount)](#ERC7984Rwa-_update-address-address-euint64-) - [_forceUpdate(from, to, encryptedAmount)](#ERC7984Rwa-_forceUpdate-address-address-euint64-) - [_checkSenderRestriction(account)](#ERC7984Rwa-_checkSenderRestriction-address-) - [AGENT_ROLE()](#ERC7984Rwa-AGENT_ROLE-bytes32) -#### AccessControl [!toc] +
+AccessControl + - [hasRole(role, account)](#AccessControl-hasRole-bytes32-address-) - [_checkRole(role)](#AccessControl-_checkRole-bytes32-) - [_checkRole(role, account)](#AccessControl-_checkRole-bytes32-address-) @@ -2178,14 +2321,26 @@ This interface provides compliance checks, transfer controls and enforcement act - [_grantRole(role, account)](#AccessControl-_grantRole-bytes32-address-) - [_revokeRole(role, account)](#AccessControl-_revokeRole-bytes32-address-) - [DEFAULT_ADMIN_ROLE()](#AccessControl-DEFAULT_ADMIN_ROLE-bytes32) -#### Multicall [!toc] + +
+
+Multicall + - [multicall(data)](#Multicall-multicall-bytes---) -#### Pausable [!toc] + +
+
+Pausable + - [_requireNotPaused()](#Pausable-_requireNotPaused--) - [_requirePaused()](#Pausable-_requirePaused--) - [_pause()](#Pausable-_pause--) - [_unpause()](#Pausable-_unpause--) -#### ERC7984Restricted [!toc] + +
+
+ERC7984Restricted + - [getRestriction(account)](#ERC7984Restricted-getRestriction-address-) - [_setRestriction(account, restriction)](#ERC7984Restricted-_setRestriction-address-enum-ERC7984Restricted-Restriction-) - [_blockUser(account)](#ERC7984Restricted-_blockUser-address-) @@ -2193,10 +2348,18 @@ This interface provides compliance checks, transfer controls and enforcement act - [_resetUser(account)](#ERC7984Restricted-_resetUser-address-) - [_checkRestriction(account)](#ERC7984Restricted-_checkRestriction-address-) - [_checkRecipientRestriction(account)](#ERC7984Restricted-_checkRecipientRestriction-address-) -#### ERC7984Freezable [!toc] + +
+
+ERC7984Freezable + - [_confidentialAvailable(account)](#ERC7984Freezable-_confidentialAvailable-address-) - [_setConfidentialFrozen(account, encryptedAmount)](#ERC7984Freezable-_setConfidentialFrozen-address-euint64-) -#### ERC7984 [!toc] + +
+
+ERC7984 + - [name()](#ERC7984-name--) - [symbol()](#ERC7984-symbol--) - [decimals()](#ERC7984-decimals--) @@ -2220,68 +2383,92 @@ This interface provides compliance checks, transfer controls and enforcement act - [_burn(from, amount)](#ERC7984-_burn-address-euint64-) - [_transfer(from, to, amount)](#ERC7984-_transfer-address-address-euint64-) - [_transferAndCall(from, to, amount, data)](#ERC7984-_transferAndCall-address-address-euint64-bytes-) -#### ERC165 [!toc] -#### IERC7984Rwa [!toc] -#### IERC7984 [!toc] -#### IERC165 [!toc] -#### IAccessControl [!toc] + +

Events

-#### AccessControl [!toc] -#### Multicall [!toc] -#### Pausable [!toc] +
+Pausable + - [Paused(account)](#Pausable-Paused-address-) - [Unpaused(account)](#Pausable-Unpaused-address-) -#### ERC7984Restricted [!toc] + +
+
+ERC7984Restricted + - [UserRestrictionUpdated(account, restriction)](#ERC7984Restricted-UserRestrictionUpdated-address-enum-ERC7984Restricted-Restriction-) -#### ERC7984Freezable [!toc] + +
+
+ERC7984Freezable + - [TokensFrozen(account, encryptedAmount)](#ERC7984Freezable-TokensFrozen-address-euint64-) -#### ERC7984 [!toc] + +
+
+ERC7984 + - [AmountDiscloseRequested(encryptedAmount, requester)](#ERC7984-AmountDiscloseRequested-euint64-address-) -#### ERC165 [!toc] -#### IERC7984Rwa [!toc] -#### IERC7984 [!toc] + +
+
+IERC7984 + - [OperatorSet(holder, operator, until)](#IERC7984-OperatorSet-address-address-uint48-) - [ConfidentialTransfer(from, to, amount)](#IERC7984-ConfidentialTransfer-address-address-euint64-) - [AmountDisclosed(encryptedAmount, amount)](#IERC7984-AmountDisclosed-euint64-uint64-) -#### IERC165 [!toc] -#### IAccessControl [!toc] + +
+
+IAccessControl + - [RoleAdminChanged(role, previousAdminRole, newAdminRole)](#IAccessControl-RoleAdminChanged-bytes32-bytes32-bytes32-) - [RoleGranted(role, account, sender)](#IAccessControl-RoleGranted-bytes32-address-address-) - [RoleRevoked(role, account, sender)](#IAccessControl-RoleRevoked-bytes32-address-address-) + +

Errors

-#### AccessControl [!toc] -#### Multicall [!toc] -#### Pausable [!toc] +
+Pausable + - [EnforcedPause()](#Pausable-EnforcedPause--) - [ExpectedPause()](#Pausable-ExpectedPause--) -#### ERC7984Restricted [!toc] + +
+
+ERC7984Restricted + - [UserRestricted(account)](#ERC7984Restricted-UserRestricted-address-) -#### ERC7984Freezable [!toc] -#### ERC7984 [!toc] + +
+
+ERC7984 + - [ERC7984InvalidReceiver(receiver)](#ERC7984-ERC7984InvalidReceiver-address-) - [ERC7984InvalidSender(sender)](#ERC7984-ERC7984InvalidSender-address-) - [ERC7984UnauthorizedSpender(holder, spender)](#ERC7984-ERC7984UnauthorizedSpender-address-address-) - [ERC7984ZeroBalance(holder)](#ERC7984-ERC7984ZeroBalance-address-) - [ERC7984UnauthorizedUseOfEncryptedAmount(amount, user)](#ERC7984-ERC7984UnauthorizedUseOfEncryptedAmount-euint64-address-) - [ERC7984UnauthorizedCaller(caller)](#ERC7984-ERC7984UnauthorizedCaller-address-) -- [ERC7984InvalidGatewayRequest(requestId)](#ERC7984-ERC7984InvalidGatewayRequest-uint256-) -#### ERC165 [!toc] -#### IERC7984Rwa [!toc] -#### IERC7984 [!toc] -#### IERC165 [!toc] -#### IAccessControl [!toc] + +
+
+IAccessControl + - [AccessControlUnauthorizedAccount(account, neededRole)](#IAccessControl-AccessControlUnauthorizedAccount-address-bytes32-) - [AccessControlBadConfirmation()](#IAccessControl-AccessControlBadConfirmation--) + +
@@ -2601,7 +2788,7 @@ Burns confidential amount of tokens from account.
-Variant of interfaces#IERC7984Rwa-forceConfidentialTransferFrom-address-address-euint64- with an input proof. +Variant of `forceConfidentialTransferFrom-address-address-euint64` with an input proof.
@@ -2676,14 +2863,14 @@ Returns true if the contract is paused, and false otherwise. - +
-

isUserAllowed(address account) → bool

+

canTransact(address account) → bool

public

-# +#
@@ -2741,7 +2928,7 @@ Internal function which forces transfer of confidential amount of tokens from ac
-Bypasses the `from` restriction check when performing a [`IERC7984Rwa.forceConfidentialTransferFrom`](/confidential-contracts/api/interfaces#IERC7984Rwa-forceConfidentialTransferFrom-address-address-euint64-). +Bypasses the `from` restriction check when performing a [`ERC7984Rwa.forceConfidentialTransferFrom`](#ERC7984Rwa-forceConfidentialTransferFrom-address-address-euint64-).
@@ -2760,12 +2947,12 @@ Bypasses the `from` restriction check when performing a [`IERC7984Rwa.forceConfi Accounts granted the agent role have the following permissioned abilities: -- Mint/Burn to/from a given address (does not require permission) -- Force transfer from a given address (does not require permission) - - Bypasses pause and restriction checks (not frozen) -- Pause/Unpause the contract -- Block/Unblock a given account -- Set frozen amount of tokens for a given account. +* Mint/Burn to/from a given address (does not require permission) +* Force transfer from a given address (does not require permission) +** Bypasses pause and restriction checks (not frozen) +* Pause/Unpause the contract +* Block/Unblock a given account +* Set frozen amount of tokens for a given account. @@ -2774,22 +2961,22 @@ Accounts granted the agent role have the following permissioned abilities:
-## `ERC7984Votes` +## `ERC7984Votes` - +
```solidity -import "@openzeppelin/confidential-contracts/token/ERC7984/extensions/ERC7984Votes.sol"; +import "@openzeppelin/confidential-contracts/contracts/token/ERC7984/extensions/ERC7984Votes.sol"; ``` Extension of [`ERC7984`](#ERC7984) supporting confidential votes tracking and delegation. The amount of confidential voting units an account has is equal to the balance of -that account. Voing power is taken into account when an account delegates votes to itself or to another +that account. Voting power is taken into account when an account delegates votes to itself or to another account.
@@ -2798,7 +2985,9 @@ account. - [confidentialTotalSupply()](#ERC7984Votes-confidentialTotalSupply--) - [_update(from, to, amount)](#ERC7984Votes-_update-address-address-euint64-) - [_getVotingUnits(account)](#ERC7984Votes-_getVotingUnits-address-) -#### VotesConfidential [!toc] +
+VotesConfidential + - [clock()](#VotesConfidential-clock--) - [CLOCK_MODE()](#VotesConfidential-CLOCK_MODE--) - [getVotes(account)](#VotesConfidential-getVotes-address-) @@ -2811,22 +3000,36 @@ account. - [_transferVotingUnits(from, to, amount)](#VotesConfidential-_transferVotingUnits-address-address-euint64-) - [_moveDelegateVotes(from, to, amount)](#VotesConfidential-_moveDelegateVotes-address-address-euint64-) - [_validateTimepoint(timepoint)](#VotesConfidential-_validateTimepoint-uint256-) -#### HandleAccessManager [!toc] + +
+
+HandleAccessManager + - [getHandleAllowance(handle, account, persistent)](#HandleAccessManager-getHandleAllowance-bytes32-address-bool-) -- [_validateHandleAllowance(handle)](#HandleAccessManager-_validateHandleAllowance-bytes32-) -#### IERC6372 [!toc] -#### EIP712 [!toc] +- [_validateHandleAllowance()](#HandleAccessManager-_validateHandleAllowance-bytes32-) + +
+
+EIP712 + - [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) - [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) - [eip712Domain()](#EIP712-eip712Domain--) - [_EIP712Name()](#EIP712-_EIP712Name--) - [_EIP712Version()](#EIP712-_EIP712Version--) -#### IERC5267 [!toc] -#### Nonces [!toc] + +
+
+Nonces + - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### ERC7984 [!toc] + +
+
+ERC7984 + - [supportsInterface(interfaceId)](#ERC7984-supportsInterface-bytes4-) - [name()](#ERC7984-name--) - [symbol()](#ERC7984-symbol--) @@ -2850,59 +3053,78 @@ account. - [_burn(from, amount)](#ERC7984-_burn-address-euint64-) - [_transfer(from, to, amount)](#ERC7984-_transfer-address-address-euint64-) - [_transferAndCall(from, to, amount, data)](#ERC7984-_transferAndCall-address-address-euint64-bytes-) -#### ERC165 [!toc] -#### IERC7984 [!toc] -#### IERC165 [!toc] + +

Events

-#### VotesConfidential [!toc] +
+VotesConfidential + - [DelegateVotesChanged(delegate, previousVotes, newVotes)](#VotesConfidential-DelegateVotesChanged-address-euint64-euint64-) - [DelegateChanged(delegator, fromDelegate, toDelegate)](#VotesConfidential-DelegateChanged-address-address-address-) -#### HandleAccessManager [!toc] -#### IERC6372 [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] + +
+
+IERC5267 + - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) -#### Nonces [!toc] -#### ERC7984 [!toc] + +
+
+ERC7984 + - [AmountDiscloseRequested(encryptedAmount, requester)](#ERC7984-AmountDiscloseRequested-euint64-address-) -#### ERC165 [!toc] -#### IERC7984 [!toc] + +
+
+IERC7984 + - [OperatorSet(holder, operator, until)](#IERC7984-OperatorSet-address-address-uint48-) - [ConfidentialTransfer(from, to, amount)](#IERC7984-ConfidentialTransfer-address-address-euint64-) - [AmountDisclosed(encryptedAmount, amount)](#IERC7984-AmountDisclosed-euint64-uint64-) -#### IERC165 [!toc] + +

Errors

-#### VotesConfidential [!toc] +
+VotesConfidential + - [VotesExpiredSignature(expiry)](#VotesConfidential-VotesExpiredSignature-uint256-) - [ERC6372InconsistentClock()](#VotesConfidential-ERC6372InconsistentClock--) - [ERC5805FutureLookup(timepoint, clock)](#VotesConfidential-ERC5805FutureLookup-uint256-uint48-) -#### HandleAccessManager [!toc] -#### IERC6372 [!toc] -#### EIP712 [!toc] -#### IERC5267 [!toc] -#### Nonces [!toc] + +
+
+HandleAccessManager + +- [HandleAccessManagerNotAllowed(handle, account)](#HandleAccessManager-HandleAccessManagerNotAllowed-bytes32-address-) + +
+
+Nonces + - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### ERC7984 [!toc] + +
+
+ERC7984 + - [ERC7984InvalidReceiver(receiver)](#ERC7984-ERC7984InvalidReceiver-address-) - [ERC7984InvalidSender(sender)](#ERC7984-ERC7984InvalidSender-address-) - [ERC7984UnauthorizedSpender(holder, spender)](#ERC7984-ERC7984UnauthorizedSpender-address-address-) - [ERC7984ZeroBalance(holder)](#ERC7984-ERC7984ZeroBalance-address-) - [ERC7984UnauthorizedUseOfEncryptedAmount(amount, user)](#ERC7984-ERC7984UnauthorizedUseOfEncryptedAmount-euint64-address-) - [ERC7984UnauthorizedCaller(caller)](#ERC7984-ERC7984UnauthorizedCaller-address-) -- [ERC7984InvalidGatewayRequest(requestId)](#ERC7984-ERC7984InvalidGatewayRequest-uint256-) -#### ERC165 [!toc] -#### IERC7984 [!toc] -#### IERC165 [!toc] + +
@@ -2957,16 +3179,16 @@ Returns the confidential total supply of the token.
-## `ERC7984Utils` +## `ERC7984Utils` - +
```solidity -import "@openzeppelin/confidential-contracts/token/ERC7984/utils/ERC7984Utils.sol"; +import "@openzeppelin/confidential-contracts/contracts/token/ERC7984/utils/ERC7984Utils.sol"; ``` Library that provides common [`ERC7984`](#ERC7984) utility functions. @@ -3001,3 +3223,4 @@ should try to refund the `from` address. + diff --git a/content/confidential-contracts/api/utils.mdx b/content/confidential-contracts/api/utils.mdx index 2a378b76..0e491fcc 100644 --- a/content/confidential-contracts/api/utils.mdx +++ b/content/confidential-contracts/api/utils.mdx @@ -24,16 +24,16 @@ Miscellaneous contracts and libraries containing utility functions you can use t
-## `FHESafeMath` +## `FHESafeMath` - +
```solidity -import "@openzeppelin/confidential-contracts/utils/FHESafeMath.sol"; +import "@openzeppelin/confidential-contracts/contracts/utils/FHESafeMath.sol"; ``` Library providing safe arithmetic operations for encrypted values @@ -41,7 +41,7 @@ to handle potential overflows in FHE operations. An uninitialized `euint64` value (equivalent to euint64.wrap(bytes32(0))) is evaluated as 0. -This library will may return an uninitialized value if all inputs are uninitialized. +This library may return an uninitialized value if all inputs are uninitialized.
@@ -132,23 +132,30 @@ will be `a - b`. Otherwise, `success` will be false, and `res` will be 0.
-## `HandleAccessManager` +## `HandleAccessManager` - +
```solidity -import "@openzeppelin/confidential-contracts/utils/HandleAccessManager.sol"; +import "@openzeppelin/confidential-contracts/contracts/utils/HandleAccessManager.sol"; ```

Functions

- [getHandleAllowance(handle, account, persistent)](#HandleAccessManager-getHandleAllowance-bytes32-address-bool-) -- [_validateHandleAllowance(handle)](#HandleAccessManager-_validateHandleAllowance-bytes32-) +- [_validateHandleAllowance()](#HandleAccessManager-_validateHandleAllowance-bytes32-) +
+
+ +
+

Errors

+
+- [HandleAccessManagerNotAllowed(handle, account)](#HandleAccessManager-HandleAccessManagerNotAllowed-bytes32-address-)
@@ -168,8 +175,7 @@ Get handle access for the given handle `handle`. Access will be given to the account `account` with the given persistence flag. -This function call is gated by `msg.sender` and validated by the -[`HandleAccessManager._validateHandleAllowance`](#HandleAccessManager-_validateHandleAllowance-bytes32-) function. +This function call is validated by [`HandleAccessManager._validateHandleAllowance`](#HandleAccessManager-_validateHandleAllowance-bytes32-).
@@ -179,7 +185,7 @@ This function call is gated by `msg.sender` and validated by the
-

_validateHandleAllowance(bytes32 handle)

+

_validateHandleAllowance(bytes32) → bool

internal

# @@ -187,26 +193,41 @@ This function call is gated by `msg.sender` and validated by the
-Unimplemented function that must revert if the message sender is not allowed to call +Validation function that must return true if the message sender is allowed to call [`HandleAccessManager.getHandleAllowance`](#HandleAccessManager-getHandleAllowance-bytes32-address-bool-) for the given handle.
+ + +
+
+

HandleAccessManagerNotAllowed(bytes32 handle, address account)

+
+

error

+# +
+
+
+ +
+
+
-## `CheckpointsConfidential` +## `CheckpointsConfidential` - +
```solidity -import "@openzeppelin/confidential-contracts/utils/structs/CheckpointsConfidential.sol"; +import "@openzeppelin/confidential-contracts/contracts/utils/structs/CheckpointsConfidential.sol"; ``` This library defines the `Trace*` struct, for checkpointing values as they change at different points in @@ -541,694 +562,3 @@ Returns checkpoint at given position.
- - -
- -## `Checkpoints` - - - - - -
- -```solidity -import "@openzeppelin/confidential-contracts/utils/structs/temporary-Checkpoints.sol"; -``` - -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 [`VotesConfidential`](/confidential-contracts/api/governance#VotesConfidential) 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 [`CheckpointsConfidential.push`](#CheckpointsConfidential-push-struct-CheckpointsConfidential-TraceEuint64-uint256-euint64-) function. - -
-

Functions

-
-- [push(self, key, value)](#Checkpoints-push-struct-Checkpoints-Trace256-uint256-uint256-) -- [lowerLookup(self, key)](#Checkpoints-lowerLookup-struct-Checkpoints-Trace256-uint256-) -- [upperLookup(self, key)](#Checkpoints-upperLookup-struct-Checkpoints-Trace256-uint256-) -- [upperLookupRecent(self, key)](#Checkpoints-upperLookupRecent-struct-Checkpoints-Trace256-uint256-) -- [latest(self)](#Checkpoints-latest-struct-Checkpoints-Trace256-) -- [latestCheckpoint(self)](#Checkpoints-latestCheckpoint-struct-Checkpoints-Trace256-) -- [length(self)](#Checkpoints-length-struct-Checkpoints-Trace256-) -- [at(self, pos)](#Checkpoints-at-struct-Checkpoints-Trace256-uint32-) -- [push(self, key, value)](#Checkpoints-push-struct-Checkpoints-Trace224-uint32-uint224-) -- [lowerLookup(self, key)](#Checkpoints-lowerLookup-struct-Checkpoints-Trace224-uint32-) -- [upperLookup(self, key)](#Checkpoints-upperLookup-struct-Checkpoints-Trace224-uint32-) -- [upperLookupRecent(self, key)](#Checkpoints-upperLookupRecent-struct-Checkpoints-Trace224-uint32-) -- [latest(self)](#Checkpoints-latest-struct-Checkpoints-Trace224-) -- [latestCheckpoint(self)](#Checkpoints-latestCheckpoint-struct-Checkpoints-Trace224-) -- [length(self)](#Checkpoints-length-struct-Checkpoints-Trace224-) -- [at(self, pos)](#Checkpoints-at-struct-Checkpoints-Trace224-uint32-) -- [push(self, key, value)](#Checkpoints-push-struct-Checkpoints-Trace208-uint48-uint208-) -- [lowerLookup(self, key)](#Checkpoints-lowerLookup-struct-Checkpoints-Trace208-uint48-) -- [upperLookup(self, key)](#Checkpoints-upperLookup-struct-Checkpoints-Trace208-uint48-) -- [upperLookupRecent(self, key)](#Checkpoints-upperLookupRecent-struct-Checkpoints-Trace208-uint48-) -- [latest(self)](#Checkpoints-latest-struct-Checkpoints-Trace208-) -- [latestCheckpoint(self)](#Checkpoints-latestCheckpoint-struct-Checkpoints-Trace208-) -- [length(self)](#Checkpoints-length-struct-Checkpoints-Trace208-) -- [at(self, pos)](#Checkpoints-at-struct-Checkpoints-Trace208-uint32-) -- [push(self, key, value)](#Checkpoints-push-struct-Checkpoints-Trace160-uint96-uint160-) -- [lowerLookup(self, key)](#Checkpoints-lowerLookup-struct-Checkpoints-Trace160-uint96-) -- [upperLookup(self, key)](#Checkpoints-upperLookup-struct-Checkpoints-Trace160-uint96-) -- [upperLookupRecent(self, key)](#Checkpoints-upperLookupRecent-struct-Checkpoints-Trace160-uint96-) -- [latest(self)](#Checkpoints-latest-struct-Checkpoints-Trace160-) -- [latestCheckpoint(self)](#Checkpoints-latestCheckpoint-struct-Checkpoints-Trace160-) -- [length(self)](#Checkpoints-length-struct-Checkpoints-Trace160-) -- [at(self, pos)](#Checkpoints-at-struct-Checkpoints-Trace160-uint32-) -
-
- -
-

Errors

-
-- [CheckpointUnorderedInsertion()](#Checkpoints-CheckpointUnorderedInsertion--) -
-
- - - -
-
-

push(struct Checkpoints.Trace256 self, uint256 key, uint256 value) → uint256 oldValue, uint256 newValue

-
-

internal

-# -
-
-
- -Pushes a (`key`, `value`) pair into a Trace256 so that it is stored as the checkpoint. - -Returns previous value and new value. - - -Never accept `key` as a user input, since an arbitrary `type(uint256).max` key set will disable the -library. - - -
-
- - - -
-
-

lowerLookup(struct Checkpoints.Trace256 self, uint256 key) → uint256

-
-

internal

-# -
-
-
- -Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if -there is none. - -
-
- - - -
-
-

upperLookup(struct Checkpoints.Trace256 self, uint256 key) → uint256

-
-

internal

-# -
-
-
- -Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero -if there is none. - -
-
- - - -
-
-

upperLookupRecent(struct Checkpoints.Trace256 self, uint256 key) → uint256

-
-

internal

-# -
-
-
- -Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero -if there is none. - - -This is a variant of [`CheckpointsConfidential.upperLookup`](#CheckpointsConfidential-upperLookup-struct-CheckpointsConfidential-TraceEuint64-uint256-) that is optimized to find "recent" checkpoint (checkpoints with high -keys). - - -
-
- - - -
-
-

latest(struct Checkpoints.Trace256 self) → uint256

-
-

internal

-# -
-
-
- -Returns the value in the most recent checkpoint, or zero if there are no checkpoints. - -
-
- - - -
-
-

latestCheckpoint(struct Checkpoints.Trace256 self) → bool exists, uint256 _key, uint256 _value

-
-

internal

-# -
-
-
- -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. - -
-
- - - -
-
-

length(struct Checkpoints.Trace256 self) → uint256

-
-

internal

-# -
-
-
- -Returns the number of checkpoints. - -
-
- - - -
-
-

at(struct Checkpoints.Trace256 self, uint32 pos) → struct Checkpoints.Checkpoint256

-
-

internal

-# -
-
-
- -Returns checkpoint at given position. - -
-
- - - -
-
-

push(struct Checkpoints.Trace224 self, uint32 key, uint224 value) → uint224 oldValue, uint224 newValue

-
-

internal

-# -
-
-
- -Pushes a (`key`, `value`) pair into a Trace224 so that it is stored as the checkpoint. - -Returns previous value and new value. - - -Never accept `key` as a user input, since an arbitrary `type(uint32).max` key set will disable the -library. - - -
-
- - - -
-
-

lowerLookup(struct Checkpoints.Trace224 self, uint32 key) → uint224

-
-

internal

-# -
-
-
- -Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if -there is none. - -
-
- - - -
-
-

upperLookup(struct Checkpoints.Trace224 self, uint32 key) → uint224

-
-

internal

-# -
-
-
- -Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero -if there is none. - -
-
- - - -
-
-

upperLookupRecent(struct Checkpoints.Trace224 self, uint32 key) → uint224

-
-

internal

-# -
-
-
- -Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero -if there is none. - - -This is a variant of [`CheckpointsConfidential.upperLookup`](#CheckpointsConfidential-upperLookup-struct-CheckpointsConfidential-TraceEuint64-uint256-) that is optimized to find "recent" checkpoint (checkpoints with high -keys). - - -
-
- - - -
-
-

latest(struct Checkpoints.Trace224 self) → uint224

-
-

internal

-# -
-
-
- -Returns the value in the most recent checkpoint, or zero if there are no checkpoints. - -
-
- - - -
-
-

latestCheckpoint(struct Checkpoints.Trace224 self) → bool exists, uint32 _key, uint224 _value

-
-

internal

-# -
-
-
- -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. - -
-
- - - -
-
-

length(struct Checkpoints.Trace224 self) → uint256

-
-

internal

-# -
-
-
- -Returns the number of checkpoints. - -
-
- - - -
-
-

at(struct Checkpoints.Trace224 self, uint32 pos) → struct Checkpoints.Checkpoint224

-
-

internal

-# -
-
-
- -Returns checkpoint at given position. - -
-
- - - -
-
-

push(struct Checkpoints.Trace208 self, uint48 key, uint208 value) → uint208 oldValue, uint208 newValue

-
-

internal

-# -
-
-
- -Pushes a (`key`, `value`) pair into a Trace208 so that it is stored as the checkpoint. - -Returns previous value and new value. - - -Never accept `key` as a user input, since an arbitrary `type(uint48).max` key set will disable the -library. - - -
-
- - - -
-
-

lowerLookup(struct Checkpoints.Trace208 self, uint48 key) → uint208

-
-

internal

-# -
-
-
- -Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if -there is none. - -
-
- - - -
-
-

upperLookup(struct Checkpoints.Trace208 self, uint48 key) → uint208

-
-

internal

-# -
-
-
- -Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero -if there is none. - -
-
- - - -
-
-

upperLookupRecent(struct Checkpoints.Trace208 self, uint48 key) → uint208

-
-

internal

-# -
-
-
- -Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero -if there is none. - - -This is a variant of [`CheckpointsConfidential.upperLookup`](#CheckpointsConfidential-upperLookup-struct-CheckpointsConfidential-TraceEuint64-uint256-) that is optimized to find "recent" checkpoint (checkpoints with high -keys). - - -
-
- - - -
-
-

latest(struct Checkpoints.Trace208 self) → uint208

-
-

internal

-# -
-
-
- -Returns the value in the most recent checkpoint, or zero if there are no checkpoints. - -
-
- - - -
-
-

latestCheckpoint(struct Checkpoints.Trace208 self) → bool exists, uint48 _key, uint208 _value

-
-

internal

-# -
-
-
- -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. - -
-
- - - -
-
-

length(struct Checkpoints.Trace208 self) → uint256

-
-

internal

-# -
-
-
- -Returns the number of checkpoints. - -
-
- - - -
-
-

at(struct Checkpoints.Trace208 self, uint32 pos) → struct Checkpoints.Checkpoint208

-
-

internal

-# -
-
-
- -Returns checkpoint at given position. - -
-
- - - -
-
-

push(struct Checkpoints.Trace160 self, uint96 key, uint160 value) → uint160 oldValue, uint160 newValue

-
-

internal

-# -
-
-
- -Pushes a (`key`, `value`) pair into a Trace160 so that it is stored as the checkpoint. - -Returns previous value and new value. - - -Never accept `key` as a user input, since an arbitrary `type(uint96).max` key set will disable the -library. - - -
-
- - - -
-
-

lowerLookup(struct Checkpoints.Trace160 self, uint96 key) → uint160

-
-

internal

-# -
-
-
- -Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if -there is none. - -
-
- - - -
-
-

upperLookup(struct Checkpoints.Trace160 self, uint96 key) → uint160

-
-

internal

-# -
-
-
- -Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero -if there is none. - -
-
- - - -
-
-

upperLookupRecent(struct Checkpoints.Trace160 self, uint96 key) → uint160

-
-

internal

-# -
-
-
- -Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero -if there is none. - - -This is a variant of [`CheckpointsConfidential.upperLookup`](#CheckpointsConfidential-upperLookup-struct-CheckpointsConfidential-TraceEuint64-uint256-) that is optimized to find "recent" checkpoint (checkpoints with high -keys). - - -
-
- - - -
-
-

latest(struct Checkpoints.Trace160 self) → uint160

-
-

internal

-# -
-
-
- -Returns the value in the most recent checkpoint, or zero if there are no checkpoints. - -
-
- - - -
-
-

latestCheckpoint(struct Checkpoints.Trace160 self) → bool exists, uint96 _key, uint160 _value

-
-

internal

-# -
-
-
- -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. - -
-
- - - -
-
-

length(struct Checkpoints.Trace160 self) → uint256

-
-

internal

-# -
-
-
- -Returns the number of checkpoints. - -
-
- - - -
-
-

at(struct Checkpoints.Trace160 self, uint32 pos) → struct Checkpoints.Checkpoint160

-
-

internal

-# -
-
-
- -Returns checkpoint at given position. - -
-
- - - -
-
-

CheckpointUnorderedInsertion()

-
-

error

-# -
-
-
- -A value was attempted to be inserted on a past checkpoint. - -
-
diff --git a/content/contracts/5.x/api/access.mdx b/content/contracts/5.x/api/access.mdx index a81c684f..1a8f9e6a 100644 --- a/content/contracts/5.x/api/access.mdx +++ b/content/contracts/5.x/api/access.mdx @@ -920,6 +920,170 @@ The owner is not a valid owner account. (eg. `address(0)`) + + +
+ +## `Ownable2Step` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/access/Ownable2Step.sol"; +``` + +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`](#Ownable) contract includes a two-step mechanism to transfer +ownership, where the new owner must call [`Ownable2Step.acceptOwnership`](#Ownable2Step-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 [`Ownable.transferOwnership`](#Ownable-transferOwnership-address-) and [`Ownable2Step.acceptOwnership`](#Ownable2Step-acceptOwnership--). + +This module is used through inheritance. It will make available all functions +from parent (Ownable). + +
+

Functions

+
+- [pendingOwner()](#Ownable2Step-pendingOwner--) +- [transferOwnership(newOwner)](#Ownable2Step-transferOwnership-address-) +- [_transferOwnership(newOwner)](#Ownable2Step-_transferOwnership-address-) +- [acceptOwnership()](#Ownable2Step-acceptOwnership--) +
+Ownable + +- [owner()](#Ownable-owner--) +- [_checkOwner()](#Ownable-_checkOwner--) +- [renounceOwnership()](#Ownable-renounceOwnership--) + +
+
+
+ +
+

Events

+
+- [OwnershipTransferStarted(previousOwner, newOwner)](#Ownable2Step-OwnershipTransferStarted-address-address-) +
+Ownable + +- [OwnershipTransferred(previousOwner, newOwner)](#Ownable-OwnershipTransferred-address-address-) + +
+
+
+ +
+

Errors

+
+
+Ownable + +- [OwnableUnauthorizedAccount(account)](#Ownable-OwnableUnauthorizedAccount-address-) +- [OwnableInvalidOwner(owner)](#Ownable-OwnableInvalidOwner-address-) + +
+
+
+ + + +
+
+

pendingOwner() → address

+
+

public

+# +
+
+
+ +Returns the address of the pending owner. + +
+
+ + + +
+
+

transferOwnership(address newOwner)

+
+

public

+# +
+
+
+ +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. + +
+
+ + + +
+
+

_transferOwnership(address newOwner)

+
+

internal

+# +
+
+
+ +Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner. +Internal function without access restriction. + +
+
+ + + +
+
+

acceptOwnership()

+
+

public

+# +
+
+
+ +The new owner accepts the ownership transfer. + +
+
+ + + +
+
+

OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner)

+
+

event

+# +
+
+ +
+ +
+
+
@@ -5054,167 +5218,3 @@ Returns true if the caller can invoke on a target the function identified by a f
- - -
- -## `Ownable2Step` - - - - - -
- -```solidity -import "@openzeppelin/contracts/access/Ownable2Step.sol"; -``` - -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`](#Ownable) contract includes a two-step mechanism to transfer -ownership, where the new owner must call [`Ownable2Step.acceptOwnership`](#Ownable2Step-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 [`Ownable.transferOwnership`](#Ownable-transferOwnership-address-) and [`Ownable2Step.acceptOwnership`](#Ownable2Step-acceptOwnership--). - -This module is used through inheritance. It will make available all functions -from parent (Ownable). - -
-

Functions

-
-- [pendingOwner()](#Ownable2Step-pendingOwner--) -- [transferOwnership(newOwner)](#Ownable2Step-transferOwnership-address-) -- [_transferOwnership(newOwner)](#Ownable2Step-_transferOwnership-address-) -- [acceptOwnership()](#Ownable2Step-acceptOwnership--) -
-Ownable - -- [owner()](#Ownable-owner--) -- [_checkOwner()](#Ownable-_checkOwner--) -- [renounceOwnership()](#Ownable-renounceOwnership--) - -
-
-
- -
-

Events

-
-- [OwnershipTransferStarted(previousOwner, newOwner)](#Ownable2Step-OwnershipTransferStarted-address-address-) -
-Ownable - -- [OwnershipTransferred(previousOwner, newOwner)](#Ownable-OwnershipTransferred-address-address-) - -
-
-
- -
-

Errors

-
-
-Ownable - -- [OwnableUnauthorizedAccount(account)](#Ownable-OwnableUnauthorizedAccount-address-) -- [OwnableInvalidOwner(owner)](#Ownable-OwnableInvalidOwner-address-) - -
-
-
- - - -
-
-

pendingOwner() → address

-
-

public

-# -
-
-
- -Returns the address of the pending owner. - -
-
- - - -
-
-

transferOwnership(address newOwner)

-
-

public

-# -
-
-
- -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. - -
-
- - - -
-
-

_transferOwnership(address newOwner)

-
-

internal

-# -
-
-
- -Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner. -Internal function without access restriction. - -
-
- - - -
-
-

acceptOwnership()

-
-

public

-# -
-
-
- -The new owner accepts the ownership transfer. - -
-
- - - -
-
-

OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner)

-
-

event

-# -
-
- -
- -
-
- diff --git a/content/contracts/5.x/api/crosschain.mdx b/content/contracts/5.x/api/crosschain.mdx index 5972c391..0e1d7b30 100644 --- a/content/contracts/5.x/api/crosschain.mdx +++ b/content/contracts/5.x/api/crosschain.mdx @@ -1904,208 +1904,3 @@ Emitted when a crosschain ERC-721 transfer is received. - - -
- -## `BridgeERC20Core` - - - - - -
- -```solidity -import "@openzeppelin/contracts/crosschain/bridges/BridgeERC20Core.sol"; -``` - -Base contract for bridging ERC-20 between chains using an ERC-7786 gateway. - -In order to use this contract, two functions must be implemented to link it to the token: -* [`BridgeERC1155._onSend`](#BridgeERC1155-_onSend-address-uint256---uint256---): called when a crosschain transfer is going out. Must take the sender tokens or revert. -* [`BridgeERC1155._onReceive`](#BridgeERC1155-_onReceive-address-uint256---uint256---): called when a crosschain transfer is coming in. Must give tokens to the receiver. - -This base contract is used by the [`BridgeERC20`](#BridgeERC20), which interfaces with legacy ERC-20 tokens, and [`BridgeERC7802`](#BridgeERC7802), -which interface with ERC-7802 to provide an approve-free user experience. It is also used by the [`ERC20Crosschain`](/contracts/5.x/api/token/ERC20#ERC20Crosschain) -extension, which embeds the bridge logic directly in the token contract. - -
-

Functions

-
-- [crosschainTransfer(to, amount)](#BridgeERC20Core-crosschainTransfer-bytes-uint256-) -- [_crosschainTransfer(from, to, amount)](#BridgeERC20Core-_crosschainTransfer-address-bytes-uint256-) -- [_processMessage(, receiveId, , payload)](#BridgeERC20Core-_processMessage-address-bytes32-bytes-bytes-) -- [_onSend(from, amount)](#BridgeERC20Core-_onSend-address-uint256-) -- [_onReceive(to, amount)](#BridgeERC20Core-_onReceive-address-uint256-) -
-CrosschainLinked - -- [getLink(chain)](#CrosschainLinked-getLink-bytes-) -- [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) -- [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) -- [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) - -
-
-ERC7786Recipient - -- [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) - -
-
-
- -
-

Events

-
-- [CrosschainERC20TransferSent(sendId, from, to, amount)](#BridgeERC20Core-CrosschainERC20TransferSent-bytes32-address-bytes-uint256-) -- [CrosschainERC20TransferReceived(receiveId, from, to, amount)](#BridgeERC20Core-CrosschainERC20TransferReceived-bytes32-bytes-address-uint256-) -
-CrosschainLinked - -- [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) - -
-
-
- -
-

Errors

-
-
-CrosschainLinked - -- [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) - -
-
-ERC7786Recipient - -- [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) -- [ERC7786RecipientMessageAlreadyProcessed(gateway, receiveId)](#ERC7786Recipient-ERC7786RecipientMessageAlreadyProcessed-address-bytes32-) - -
-
-
- - - -
-
-

crosschainTransfer(bytes to, uint256 amount) → bytes32

-
-

public

-# -
-
-
- -Transfer `amount` tokens to a crosschain receiver. - -Note: The `to` parameter is the full InteroperableAddress (chain ref + address). - -
-
- - - -
-
-

_crosschainTransfer(address from, bytes to, uint256 amount) → bytes32

-
-

internal

-# -
-
-
- -Internal crosschain transfer function. - -Note: The `to` parameter is the full InteroperableAddress (chain ref + address). - -
-
- - - -
-
-

_processMessage(address, bytes32 receiveId, bytes, bytes payload)

-
-

internal

-# -
-
-
- -Virtual function that should contain the logic to execute when a cross-chain message is received. - -
-
- - - -
-
-

_onSend(address from, uint256 amount)

-
-

internal

-# -
-
-
- -Virtual function: implementation is required to handle token being burnt or locked on the source chain. - -
-
- - - -
-
-

_onReceive(address to, uint256 amount)

-
-

internal

-# -
-
-
- -Virtual function: implementation is required to handle token being minted or unlocked on the destination chain. - -
-
- - - -
-
-

CrosschainERC20TransferSent(bytes32 indexed sendId, address indexed from, bytes to, uint256 amount)

-
-

event

-# -
-
- -
- -
-
- - -
-
-

CrosschainERC20TransferReceived(bytes32 indexed receiveId, bytes from, address indexed to, uint256 amount)

-
-

event

-# -
-
- -
- -
-
- diff --git a/content/contracts/5.x/api/interfaces.mdx b/content/contracts/5.x/api/interfaces.mdx index e1643571..6fde47a5 100644 --- a/content/contracts/5.x/api/interfaces.mdx +++ b/content/contracts/5.x/api/interfaces.mdx @@ -351,867 +351,789 @@ caller's tokens and then calls [`IERC1363Spender.onApprovalReceived`](#IERC1363S - +
-## `IERC1967` +## `IERC1363Receiver` - +
```solidity -import "@openzeppelin/contracts/interfaces/IERC1967.sol"; +import "@openzeppelin/contracts/interfaces/IERC1363Receiver.sol"; ``` -ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC. +Interface for any contract that wants to support `transferAndCall` or `transferFromAndCall` +from ERC-1363 token contracts.
-

Events

+

Functions

-- [Upgraded(implementation)](#IERC1967-Upgraded-address-) -- [AdminChanged(previousAdmin, newAdmin)](#IERC1967-AdminChanged-address-address-) -- [BeaconUpgraded(beacon)](#IERC1967-BeaconUpgraded-address-) -
-
- - - -
-
-

Upgraded(address indexed implementation)

-
-

event

-# +- [onTransferReceived(operator, from, value, data)](#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-)
-
- -Emitted when the implementation is upgraded. - -
-
- +
-

AdminChanged(address previousAdmin, address newAdmin)

+

onTransferReceived(address operator, address from, uint256 value, bytes data) → bytes4

-

event

-# +

external

+#
-
-Emitted when the admin account has changed. - -
-
- - -
-
-

BeaconUpgraded(address indexed beacon)

-
-

event

-# -
-
- -
+Whenever ERC-1363 tokens are transferred to this contract via `transferAndCall` or `transferFromAndCall` +by `operator` from `from`, this function is called. -Emitted when the beacon is changed. + +To accept the transfer, this must return +`bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))` +(i.e. 0x88a7ca5c, or its own function selector). +
- +
-## `IERC2309` +## `IERC1363Spender` - +
```solidity -import "@openzeppelin/contracts/interfaces/IERC2309.sol"; +import "@openzeppelin/contracts/interfaces/IERC1363Spender.sol"; ``` -ERC-2309: ERC-721 Consecutive Transfer Extension. +Interface for any contract that wants to support `approveAndCall` +from ERC-1363 token contracts.
-

Events

+

Functions

-- [ConsecutiveTransfer(fromTokenId, toTokenId, fromAddress, toAddress)](#IERC2309-ConsecutiveTransfer-uint256-uint256-address-address-) +- [onApprovalReceived(owner, value, data)](#IERC1363Spender-onApprovalReceived-address-uint256-bytes-)
- +
-

ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed fromAddress, address indexed toAddress)

+

onApprovalReceived(address owner, uint256 value, bytes data) → bytes4

-

event

-# +

external

+#
-
-Emitted when the tokens from `fromTokenId` to `toTokenId` are transferred from `fromAddress` to `toAddress`. +Whenever an ERC-1363 token `owner` approves this contract via `approveAndCall` +to spend their tokens, this function is called. + + +To accept the approval, this must return +`bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))` +(i.e. 0x7b04a2d0, or its own function selector). +
- +
-## `IERC2981` +## `IERC1820Implementer` - +
```solidity -import "@openzeppelin/contracts/interfaces/IERC2981.sol"; +import "@openzeppelin/contracts/interfaces/IERC1820Implementer.sol"; ``` -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. +Interface for an ERC-1820 implementer, as defined in the +[ERC](https://eips.ethereum.org/EIPS/eip-1820#interface-implementation-erc1820implementerinterface). +Used by contracts that will be registered as implementers in the +[`IERC1820Registry`](#IERC1820Registry).

Functions

-- [royaltyInfo(tokenId, salePrice)](#IERC2981-royaltyInfo-uint256-uint256-) -
-IERC165 - -- [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) - -
+- [canImplementInterfaceForAddress(interfaceHash, account)](#IERC1820Implementer-canImplementInterfaceForAddress-bytes32-address-)
- +
-

royaltyInfo(uint256 tokenId, uint256 salePrice) → address receiver, uint256 royaltyAmount

+

canImplementInterfaceForAddress(bytes32 interfaceHash, address account) → bytes32

external

-# +#
-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. +Returns a special value (`ERC1820_ACCEPT_MAGIC`) if this contract +implements `interfaceHash` for `account`. - -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. - +See [`IERC1820Registry.setInterfaceImplementer`](#IERC1820Registry-setInterfaceImplementer-address-bytes32-address-).
- +
-## `IERC3156FlashBorrower` +## `IERC1820Registry` - +
```solidity -import "@openzeppelin/contracts/interfaces/IERC3156FlashBorrower.sol"; +import "@openzeppelin/contracts/interfaces/IERC1820Registry.sol"; ``` -Interface of the ERC-3156 FlashBorrower, as defined in -[ERC-3156](https://eips.ethereum.org/EIPS/eip-3156). +Interface of the global ERC-1820 Registry, as defined in the +[ERC](https://eips.ethereum.org/EIPS/eip-1820). 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`](/contracts/5.x/api/utils#IERC165) interfaces can also be queried via the registry. + +For an in-depth explanation and source code analysis, see the ERC text.

Functions

-- [onFlashLoan(initiator, token, amount, fee, data)](#IERC3156FlashBorrower-onFlashLoan-address-address-uint256-uint256-bytes-) +- [setManager(account, newManager)](#IERC1820Registry-setManager-address-address-) +- [getManager(account)](#IERC1820Registry-getManager-address-) +- [setInterfaceImplementer(account, _interfaceHash, implementer)](#IERC1820Registry-setInterfaceImplementer-address-bytes32-address-) +- [getInterfaceImplementer(account, _interfaceHash)](#IERC1820Registry-getInterfaceImplementer-address-bytes32-) +- [interfaceHash(interfaceName)](#IERC1820Registry-interfaceHash-string-) +- [updateERC165Cache(account, interfaceId)](#IERC1820Registry-updateERC165Cache-address-bytes4-) +- [implementsERC165Interface(account, interfaceId)](#IERC1820Registry-implementsERC165Interface-address-bytes4-) +- [implementsERC165InterfaceNoCache(account, interfaceId)](#IERC1820Registry-implementsERC165InterfaceNoCache-address-bytes4-)
- +
+

Events

+
+- [InterfaceImplementerSet(account, interfaceHash, implementer)](#IERC1820Registry-InterfaceImplementerSet-address-bytes32-address-) +- [ManagerChanged(account, newManager)](#IERC1820Registry-ManagerChanged-address-address-) +
+
+ +
-

onFlashLoan(address initiator, address token, uint256 amount, uint256 fee, bytes data) → bytes32

+

setManager(address account, address newManager)

external

-# +#
-Receive a flash loan. - -
-
- - - -
- -## `IERC3156FlashLender` +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 [`IERC1820Registry.ManagerChanged`](#IERC1820Registry-ManagerChanged-address-address-) event. -```solidity -import "@openzeppelin/contracts/interfaces/IERC3156FlashLender.sol"; -``` +Requirements: -Interface of the ERC-3156 FlashLender, as defined in -[ERC-3156](https://eips.ethereum.org/EIPS/eip-3156). +- the caller must be the current manager for `account`. -
-

Functions

-
-- [maxFlashLoan(token)](#IERC3156FlashLender-maxFlashLoan-address-) -- [flashFee(token, amount)](#IERC3156FlashLender-flashFee-address-uint256-) -- [flashLoan(receiver, token, amount, data)](#IERC3156FlashLender-flashLoan-contract-IERC3156FlashBorrower-address-uint256-bytes-)
- +
-

maxFlashLoan(address token) → uint256

+

getManager(address account) → address

external

-# +#
-The amount of currency available to be lent. +Returns the manager for `account`. + +See [`IERC1820Registry.setManager`](#IERC1820Registry-setManager-address-address-).
- +
-

flashFee(address token, uint256 amount) → uint256

+

setInterfaceImplementer(address account, bytes32 _interfaceHash, address implementer)

external

-# +#
-The fee to be charged for a given loan. +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 [`IERC1820Registry.interfaceHash`](#IERC1820Registry-interfaceHash-string-) to learn how these are created. + +Emits an [`IERC1820Registry.InterfaceImplementerSet`](#IERC1820Registry-InterfaceImplementerSet-address-bytes32-address-) event. + +Requirements: + +- the caller must be the current manager for `account`. +- `interfaceHash` must not be an [`IERC165`](/contracts/5.x/api/utils#IERC165) interface id (i.e. it must not +end in 28 zeroes). +- `implementer` must implement [`IERC1820Implementer`](#IERC1820Implementer) and return true when +queried for support, unless `implementer` is the caller. See +[`IERC1820Implementer.canImplementInterfaceForAddress`](#IERC1820Implementer-canImplementInterfaceForAddress-bytes32-address-).
- +
-

flashLoan(contract IERC3156FlashBorrower receiver, address token, uint256 amount, bytes data) → bool

+

getInterfaceImplementer(address account, bytes32 _interfaceHash) → address

external

-# +#
-Initiate a flash loan. - -
-
- - - -
- -## `IERC4626` - - - - - -
- -```solidity -import "@openzeppelin/contracts/interfaces/IERC4626.sol"; -``` - -Interface of the ERC-4626 "Tokenized Vault Standard", as defined in -[ERC-4626](https://eips.ethereum.org/EIPS/eip-4626). - -
-

Functions

-
-- [asset()](#IERC4626-asset--) -- [totalAssets()](#IERC4626-totalAssets--) -- [convertToShares(assets)](#IERC4626-convertToShares-uint256-) -- [convertToAssets(shares)](#IERC4626-convertToAssets-uint256-) -- [maxDeposit(receiver)](#IERC4626-maxDeposit-address-) -- [previewDeposit(assets)](#IERC4626-previewDeposit-uint256-) -- [deposit(assets, receiver)](#IERC4626-deposit-uint256-address-) -- [maxMint(receiver)](#IERC4626-maxMint-address-) -- [previewMint(shares)](#IERC4626-previewMint-uint256-) -- [mint(shares, receiver)](#IERC4626-mint-uint256-address-) -- [maxWithdraw(owner)](#IERC4626-maxWithdraw-address-) -- [previewWithdraw(assets)](#IERC4626-previewWithdraw-uint256-) -- [withdraw(assets, receiver, owner)](#IERC4626-withdraw-uint256-address-address-) -- [maxRedeem(owner)](#IERC4626-maxRedeem-address-) -- [previewRedeem(shares)](#IERC4626-previewRedeem-uint256-) -- [redeem(shares, receiver, owner)](#IERC4626-redeem-uint256-address-address-) -
-IERC20Metadata - -- [name()](#IERC20Metadata-name--) -- [symbol()](#IERC20Metadata-symbol--) -- [decimals()](#IERC20Metadata-decimals--) - -
-
-IERC20 - -- [totalSupply()](#IERC20-totalSupply--) -- [balanceOf(account)](#IERC20-balanceOf-address-) -- [transfer(to, value)](#IERC20-transfer-address-uint256-) -- [allowance(owner, spender)](#IERC20-allowance-address-address-) -- [approve(spender, value)](#IERC20-approve-address-uint256-) -- [transferFrom(from, to, value)](#IERC20-transferFrom-address-address-uint256-) - -
-
-
+Returns the implementer of `interfaceHash` for `account`. If no such +implementer is registered, returns the zero address. -
-

Events

-
-- [Deposit(sender, owner, assets, shares)](#IERC4626-Deposit-address-address-uint256-uint256-) -- [Withdraw(sender, receiver, owner, assets, shares)](#IERC4626-Withdraw-address-address-address-uint256-uint256-) -
-IERC20 +If `interfaceHash` is an [`IERC165`](/contracts/5.x/api/utils#IERC165) interface id (i.e. it ends with 28 +zeroes), `account` will be queried for support of it. -- [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) -- [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) +`account` being the zero address is an alias for the caller's address. -
- +
-

asset() → address assetTokenAddress

+

interfaceHash(string interfaceName) → bytes32

external

-# +#
-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. +Returns the interface hash for an `interfaceName`, as defined in the +corresponding +[section of the ERC](https://eips.ethereum.org/EIPS/eip-1820#interface-name).
- +
-

totalAssets() → uint256 totalManagedAssets

+

updateERC165Cache(address account, bytes4 interfaceId)

external

-# +#
-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. -
- +
-

convertToShares(uint256 assets) → uint256 shares

+

implementsERC165Interface(address account, bytes4 interfaceId) → bool

external

-# +#
-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. - - -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. - -
- +
-

convertToAssets(uint256 shares) → uint256 assets

+

implementsERC165InterfaceNoCache(address account, bytes4 interfaceId) → bool

external

-# +#
-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. - - -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. - -
- +
-

maxDeposit(address receiver) → uint256 maxAssets

+

InterfaceImplementerSet(address indexed account, bytes32 indexed interfaceHash, address indexed implementer)

-

external

-# +

event

+#
-
- -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. +
- - +
-

previewDeposit(uint256 assets) → uint256 shares

+

ManagerChanged(address indexed account, address indexed newManager)

-

external

-# +

event

+#
+
-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. + - -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. - +
+ +## `IERC1967` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/interfaces/IERC1967.sol"; +``` +ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC. + +
+

Events

+
+- [Upgraded(implementation)](#IERC1967-Upgraded-address-) +- [AdminChanged(previousAdmin, newAdmin)](#IERC1967-AdminChanged-address-address-) +- [BeaconUpgraded(beacon)](#IERC1967-BeaconUpgraded-address-)
- +
-

deposit(uint256 assets, address receiver) → uint256 shares

+

Upgraded(address indexed implementation)

-

external

-# +

event

+#
-
- -Deposit `assets` underlying tokens and send the corresponding number of vault shares (`shares`) to `receiver`. -- 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). +
- -most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. - +Emitted when the implementation is upgraded.
- - +
-

maxMint(address receiver) → uint256 maxShares

+

AdminChanged(address previousAdmin, address newAdmin)

-

external

-# +

event

+#
+
-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. +Emitted when the admin account has changed.
- - +
-

previewMint(uint256 shares) → uint256 assets

+

BeaconUpgraded(address indexed beacon)

-

external

-# +

event

+#
+
-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. - - -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. - - -
-
- - +Emitted when the beacon is changed. -
-
-

mint(uint256 shares, address receiver) → uint256 assets

-
-

external

-#
-
- -Mints exactly `shares` vault shares to `receiver` in exchange for `assets` 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). + - -most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. - +
-
-
+## `IERC2309` - + + + -
-
-

maxWithdraw(address owner) → uint256 maxAssets

-
-

external

-# -
-
-Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the -Vault, through a withdraw call. +```solidity +import "@openzeppelin/contracts/interfaces/IERC2309.sol"; +``` -- MUST return a limited value if owner is subject to some withdrawal limit or timelock. -- MUST NOT revert. +ERC-2309: ERC-721 Consecutive Transfer Extension. +
+

Events

+
+- [ConsecutiveTransfer(fromTokenId, toTokenId, fromAddress, toAddress)](#IERC2309-ConsecutiveTransfer-uint256-uint256-address-address-)
- +
-

previewWithdraw(uint256 assets) → uint256 shares

+

ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed fromAddress, address indexed toAddress)

-

external

-# +

event

+#
-
- -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. +
- -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. - +Emitted when the tokens from `fromTokenId` to `toTokenId` are transferred from `fromAddress` to `toAddress`.
- + + +
+ +## `IERC2612` + + + + -
-
-

withdraw(uint256 assets, address receiver, address owner) → uint256 shares

-
-

external

-# -
-
-Burns shares from owner and sends exactly assets of underlying tokens to receiver. +```solidity +import "@openzeppelin/contracts/interfaces/IERC2612.sol"; +``` -- 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). +
+

Functions

+
+
+IERC20Permit -Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed. -Those methods should be performed separately. +- [permit(owner, spender, value, deadline, v, r, s)](#IERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) +- [nonces(owner)](#IERC20Permit-nonces-address-) +- [DOMAIN_SEPARATOR()](#IERC20Permit-DOMAIN_SEPARATOR--) +
- + -
-
-

maxRedeem(address owner) → uint256 maxShares

-
-

external

-# -
-
-
+
-Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, -through a redeem call. +## `IERC2981` -- 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. + + + -
- +```solidity +import "@openzeppelin/contracts/interfaces/IERC2981.sol"; +``` -
-
-

previewRedeem(uint256 shares) → uint256 assets

-
-

external

-# -
-
-
+Interface for the NFT Royalty Standard. -Allows an on-chain or off-chain user to simulate the effects of their redemption at the current block, -given current on-chain conditions. +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. -- 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. +
+

Functions

+
+- [royaltyInfo(tokenId, salePrice)](#IERC2981-royaltyInfo-uint256-uint256-) +
+IERC165 - -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. - +- [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) +
- +
-

redeem(uint256 shares, address receiver, address owner) → uint256 assets

+

royaltyInfo(uint256 tokenId, uint256 salePrice) → address receiver, uint256 royaltyAmount

external

-# +#
-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). +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. -some implementations will require pre-requesting to the Vault before a withdrawal may be performed. -Those methods should be performed separately. +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.
- + + +
+ +## `IERC3156FlashBorrower` + + + + -
-
-

Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares)

-
-

event

-# -
-
+```solidity +import "@openzeppelin/contracts/interfaces/IERC3156FlashBorrower.sol"; +``` +Interface of the ERC-3156 FlashBorrower, as defined in +[ERC-3156](https://eips.ethereum.org/EIPS/eip-3156). + +
+

Functions

+
+- [onFlashLoan(initiator, token, amount, fee, data)](#IERC3156FlashBorrower-onFlashLoan-address-address-uint256-uint256-bytes-)
- + +
-

Withdraw(address indexed sender, address indexed receiver, address indexed owner, uint256 assets, uint256 shares)

+

onFlashLoan(address initiator, address token, uint256 amount, uint256 fee, bytes data) → bytes32

-

event

-# +

external

+#
-
+Receive a flash loan. +
- +
-## `IERC4906` +## `IERC3156FlashLender` - +
```solidity -import "@openzeppelin/contracts/interfaces/IERC4906.sol"; +import "@openzeppelin/contracts/interfaces/IERC3156FlashLender.sol"; ``` -
+Interface of the ERC-3156 FlashLender, as defined in +[ERC-3156](https://eips.ethereum.org/EIPS/eip-3156). + +

Functions

+- [maxFlashLoan(token)](#IERC3156FlashLender-maxFlashLoan-address-) +- [flashFee(token, amount)](#IERC3156FlashLender-flashFee-address-uint256-) +- [flashLoan(receiver, token, amount, data)](#IERC3156FlashLender-flashLoan-contract-IERC3156FlashBorrower-address-uint256-bytes-) +
+
+ + + +
+
+

maxFlashLoan(address token) → uint256

+
+

external

+# +
+
+
+ +The amount of currency available to be lent. + +
+
+ + + +
+
+

flashFee(address token, uint256 amount) → uint256

+
+

external

+# +
+
+
+ +The fee to be charged for a given loan. + +
+
+ + + +
+
+

flashLoan(contract IERC3156FlashBorrower receiver, address token, uint256 amount, bytes data) → bool

+
+

external

+# +
+
+
+ +Initiate a flash loan. + +
+
+ + + +
+ +## `IERC4626` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/interfaces/IERC4626.sol"; +``` + +Interface of the ERC-4626 "Tokenized Vault Standard", as defined in +[ERC-4626](https://eips.ethereum.org/EIPS/eip-4626). + +
+

Functions

+
+- [asset()](#IERC4626-asset--) +- [totalAssets()](#IERC4626-totalAssets--) +- [convertToShares(assets)](#IERC4626-convertToShares-uint256-) +- [convertToAssets(shares)](#IERC4626-convertToAssets-uint256-) +- [maxDeposit(receiver)](#IERC4626-maxDeposit-address-) +- [previewDeposit(assets)](#IERC4626-previewDeposit-uint256-) +- [deposit(assets, receiver)](#IERC4626-deposit-uint256-address-) +- [maxMint(receiver)](#IERC4626-maxMint-address-) +- [previewMint(shares)](#IERC4626-previewMint-uint256-) +- [mint(shares, receiver)](#IERC4626-mint-uint256-address-) +- [maxWithdraw(owner)](#IERC4626-maxWithdraw-address-) +- [previewWithdraw(assets)](#IERC4626-previewWithdraw-uint256-) +- [withdraw(assets, receiver, owner)](#IERC4626-withdraw-uint256-address-address-) +- [maxRedeem(owner)](#IERC4626-maxRedeem-address-) +- [previewRedeem(shares)](#IERC4626-previewRedeem-uint256-) +- [redeem(shares, receiver, owner)](#IERC4626-redeem-uint256-address-address-)
-IERC721 +IERC20Metadata -- [balanceOf(owner)](#IERC721-balanceOf-address-) -- [ownerOf(tokenId)](#IERC721-ownerOf-uint256-) -- [safeTransferFrom(from, to, tokenId, data)](#IERC721-safeTransferFrom-address-address-uint256-bytes-) -- [safeTransferFrom(from, to, tokenId)](#IERC721-safeTransferFrom-address-address-uint256-) -- [transferFrom(from, to, tokenId)](#IERC721-transferFrom-address-address-uint256-) -- [approve(to, tokenId)](#IERC721-approve-address-uint256-) -- [setApprovalForAll(operator, approved)](#IERC721-setApprovalForAll-address-bool-) -- [getApproved(tokenId)](#IERC721-getApproved-uint256-) -- [isApprovedForAll(owner, operator)](#IERC721-isApprovedForAll-address-address-) +- [name()](#IERC20Metadata-name--) +- [symbol()](#IERC20Metadata-symbol--) +- [decimals()](#IERC20Metadata-decimals--)
-IERC165 +IERC20 -- [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) +- [totalSupply()](#IERC20-totalSupply--) +- [balanceOf(account)](#IERC20-balanceOf-address-) +- [transfer(to, value)](#IERC20-transfer-address-uint256-) +- [allowance(owner, spender)](#IERC20-allowance-address-address-) +- [approve(spender, value)](#IERC20-approve-address-uint256-) +- [transferFrom(from, to, value)](#IERC20-transferFrom-address-address-uint256-)
@@ -1220,320 +1142,499 @@ import "@openzeppelin/contracts/interfaces/IERC4906.sol";

Events

-- [MetadataUpdate(_tokenId)](#IERC4906-MetadataUpdate-uint256-) -- [BatchMetadataUpdate(_fromTokenId, _toTokenId)](#IERC4906-BatchMetadataUpdate-uint256-uint256-) +- [Deposit(sender, owner, assets, shares)](#IERC4626-Deposit-address-address-uint256-uint256-) +- [Withdraw(sender, receiver, owner, assets, shares)](#IERC4626-Withdraw-address-address-address-uint256-uint256-)
-IERC721 +IERC20 -- [Transfer(from, to, tokenId)](#IERC721-Transfer-address-address-uint256-) -- [Approval(owner, approved, tokenId)](#IERC721-Approval-address-address-uint256-) -- [ApprovalForAll(owner, operator, approved)](#IERC721-ApprovalForAll-address-address-bool-) +- [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) +- [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-)
- +
-

MetadataUpdate(uint256 _tokenId)

+

asset() → address assetTokenAddress

-

event

-# +

external

+#
-
-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. +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.
- + +
-

BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId)

+

totalAssets() → uint256 totalManagedAssets

-

event

-# +

external

+#
-
-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. +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.
- + -
+
+
+

convertToShares(uint256 assets) → uint256 shares

+
+

external

+# +
+
+
-## `IERC5267` +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. + + +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. + +
-```solidity -import "@openzeppelin/contracts/interfaces/IERC5267.sol"; -``` + -
-

Functions

-
-- [eip712Domain()](#IERC5267-eip712Domain--) +
+
+

convertToAssets(uint256 shares) → uint256 assets

+
+

external

+#
+
+ +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. + + +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. + -
-

Events

-
-- [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--)
- +
-

eip712Domain() → bytes1 fields, string name, string version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] extensions

+

maxDeposit(address receiver) → uint256 maxAssets

external

-# +#
-returns the fields and values that describe the domain separator used by this contract for EIP-712 -signature. +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.
- +
-

EIP712DomainChanged()

+

previewDeposit(uint256 assets) → uint256 shares

-

event

-# +

external

+# +
+
+
+ +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. + + +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. + +
+ + +
+
+

deposit(uint256 assets, address receiver) → uint256 shares

+
+

external

+# +
+
-MAY be emitted to signal that the domain could have changed. +Deposit `assets` underlying tokens and send the corresponding number of vault shares (`shares`) to `receiver`. + +- 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). + + +most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. +
- + -
+
+
+

maxMint(address receiver) → uint256 maxShares

+
+

external

+# +
+
+
-## `IERC5313` +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. - - - +
+
+ + +
+
+

previewMint(uint256 shares) → uint256 assets

+
+

external

+#
+
+
-```solidity -import "@openzeppelin/contracts/interfaces/IERC5313.sol"; -``` +Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given +current on-chain conditions. -Interface for the Light Contract Ownership Standard. +- 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. -A standardized minimal interface required to identify an account that controls a contract + +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. + -
-

Functions

-
-- [owner()](#IERC5313-owner--)
- +
-

owner() → address

+

mint(uint256 shares, address receiver) → uint256 assets

external

-# +#
-Gets the address of the owner. +Mints exactly `shares` vault shares to `receiver` in exchange for `assets` 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). + + +most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. +
- + -
+
+
+

maxWithdraw(address owner) → uint256 maxAssets

+
+

external

+# +
+
+
-## `IERC5805` +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. +
-```solidity -import "@openzeppelin/contracts/interfaces/IERC5805.sol"; -``` + -
-

Functions

-
-
-IVotes +
+
+

previewWithdraw(uint256 assets) → uint256 shares

+
+

external

+# +
+
+
-- [getVotes(account)](#IVotes-getVotes-address-) -- [getPastVotes(account, timepoint)](#IVotes-getPastVotes-address-uint256-) -- [getPastTotalSupply(timepoint)](#IVotes-getPastTotalSupply-uint256-) -- [delegates(account)](#IVotes-delegates-address-) -- [delegate(delegatee)](#IVotes-delegate-address-) -- [delegateBySig(delegatee, nonce, expiry, v, r, s)](#IVotes-delegateBySig-address-uint256-uint256-uint8-bytes32-bytes32-) +Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block, +given current on-chain conditions. -
-
-IERC6372 +- 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. -- [clock()](#IERC6372-clock--) -- [CLOCK_MODE()](#IERC6372-CLOCK_MODE--) + +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. + -
-
-

Events

-
-
-IVotes + -- [DelegateChanged(delegator, fromDelegate, toDelegate)](#IVotes-DelegateChanged-address-address-address-) -- [DelegateVotesChanged(delegate, previousVotes, newVotes)](#IVotes-DelegateVotesChanged-address-uint256-uint256-) +
+
+

withdraw(uint256 assets, address receiver, address owner) → uint256 shares

+
+

external

+# +
+
+
+ +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. -
-
-

Errors

-
-
-IVotes - -- [VotesExpiredSignature(expiry)](#IVotes-VotesExpiredSignature-uint256-) + -
+
+
+

maxRedeem(address owner) → uint256 maxShares

+
+

external

+#
+
- +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. -## `IERC6372` +
+
- - - + +
+
+

previewRedeem(uint256 shares) → uint256 assets

+
+

external

+# +
+
-```solidity -import "@openzeppelin/contracts/interfaces/IERC6372.sol"; -``` +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. + + +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. + -
-

Functions

-
-- [clock()](#IERC6372-clock--) -- [CLOCK_MODE()](#IERC6372-CLOCK_MODE--)
- +
-

clock() → uint48

+

redeem(uint256 shares, address receiver, address owner) → uint256 assets

external

-# +#
-Clock used for flagging checkpoints. Can be overridden to implement timestamp based checkpoints (and voting). +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). + + +some implementations will require pre-requesting to the Vault before a withdrawal may be performed. +Those methods should be performed separately. +
- +
-

CLOCK_MODE() → string

+

Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares)

-

external

-# +

event

+#
+
-Description of the clock +
+
+ + +
+
+

Withdraw(address indexed sender, address indexed receiver, address indexed owner, uint256 assets, uint256 shares)

+
+

event

+# +
+
+ +
- +
-## `IERC6909` +## `IERC4906` - +
```solidity -import "@openzeppelin/contracts/interfaces/IERC6909.sol"; +import "@openzeppelin/contracts/interfaces/IERC4906.sol"; ``` -Required interface of an ERC-6909 compliant contract, as defined in the -[ERC](https://eips.ethereum.org/EIPS/eip-6909). -

Functions

-- [balanceOf(owner, id)](#IERC6909-balanceOf-address-uint256-) -- [allowance(owner, spender, id)](#IERC6909-allowance-address-address-uint256-) -- [isOperator(owner, spender)](#IERC6909-isOperator-address-address-) -- [approve(spender, id, amount)](#IERC6909-approve-address-uint256-uint256-) -- [setOperator(spender, approved)](#IERC6909-setOperator-address-bool-) -- [transfer(receiver, id, amount)](#IERC6909-transfer-address-uint256-uint256-) -- [transferFrom(sender, receiver, id, amount)](#IERC6909-transferFrom-address-address-uint256-uint256-) +
+IERC721 + +- [balanceOf(owner)](#IERC721-balanceOf-address-) +- [ownerOf(tokenId)](#IERC721-ownerOf-uint256-) +- [safeTransferFrom(from, to, tokenId, data)](#IERC721-safeTransferFrom-address-address-uint256-bytes-) +- [safeTransferFrom(from, to, tokenId)](#IERC721-safeTransferFrom-address-address-uint256-) +- [transferFrom(from, to, tokenId)](#IERC721-transferFrom-address-address-uint256-) +- [approve(to, tokenId)](#IERC721-approve-address-uint256-) +- [setApprovalForAll(operator, approved)](#IERC721-setApprovalForAll-address-bool-) +- [getApproved(tokenId)](#IERC721-getApproved-uint256-) +- [isApprovedForAll(owner, operator)](#IERC721-isApprovedForAll-address-address-) + +
IERC165 @@ -1546,237 +1647,203 @@ Required interface of an ERC-6909 compliant contract, as defined in the

Events

-- [Approval(owner, spender, id, amount)](#IERC6909-Approval-address-address-uint256-uint256-) -- [OperatorSet(owner, spender, approved)](#IERC6909-OperatorSet-address-address-bool-) -- [Transfer(caller, sender, receiver, id, amount)](#IERC6909-Transfer-address-address-address-uint256-uint256-) -
-
- - - -
-
-

balanceOf(address owner, uint256 id) → uint256

-
-

external

-# -
-
-
+- [MetadataUpdate(_tokenId)](#IERC4906-MetadataUpdate-uint256-) +- [BatchMetadataUpdate(_fromTokenId, _toTokenId)](#IERC4906-BatchMetadataUpdate-uint256-uint256-) +
+IERC721 -Returns the amount of tokens of type `id` owned by `owner`. +- [Transfer(from, to, tokenId)](#IERC721-Transfer-address-address-uint256-) +- [Approval(owner, approved, tokenId)](#IERC721-Approval-address-address-uint256-) +- [ApprovalForAll(owner, operator, approved)](#IERC721-ApprovalForAll-address-address-bool-) +
- +
-

allowance(address owner, address spender, uint256 id) → uint256

+

MetadataUpdate(uint256 _tokenId)

-

external

-# -
-
-
- -Returns the amount of tokens of type `id` that `spender` is allowed to spend on behalf of `owner`. - - -Does not include operator allowances. - - +

event

+#
- - -
-
-

isOperator(address owner, address spender) → bool

-
-

external

-# -
-
-Returns true if `spender` is set as an operator for `owner`. +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.
- - +
-

approve(address spender, uint256 id, uint256 amount) → bool

+

BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId)

-

external

-# +

event

+#
-
-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. +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.
- + -
-
-

setOperator(address spender, bool approved) → bool

-
-

external

-# -
-
-
+
-Grants or revokes unlimited transfer permission of any token id to `spender` for the caller's tokens. +## `IERC5267` -Must return true. + + + -
- +```solidity +import "@openzeppelin/contracts/interfaces/IERC5267.sol"; +``` -
-
-

transfer(address receiver, uint256 id, uint256 amount) → bool

-
-

external

-# +
+

Functions

+
+- [eip712Domain()](#IERC5267-eip712Domain--)
-
- -Transfers `amount` of token type `id` from the caller's account to `receiver`. - -Must return true. +
+

Events

+
+- [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--)
- +
-

transferFrom(address sender, address receiver, uint256 id, uint256 amount) → bool

+

eip712Domain() → bytes1 fields, string name, string version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] extensions

external

-# +#
-Transfers `amount` of token type `id` from `sender` to `receiver`. - -Must return true. +returns the fields and values that describe the domain separator used by this contract for EIP-712 +signature.
- +
-

Approval(address indexed owner, address indexed spender, uint256 indexed id, uint256 amount)

+

EIP712DomainChanged()

event

-# +#
-Emitted when the allowance of a `spender` for an `owner` is set for a token of type `id`. -The new allowance is `amount`. +MAY be emitted to signal that the domain could have changed.
- -
-
-

OperatorSet(address indexed owner, address indexed spender, bool approved)

-
-

event

-# -
+ + +
+ +## `IERC5313` + + + + +
-
+```solidity +import "@openzeppelin/contracts/interfaces/IERC5313.sol"; +``` -Emitted when `owner` grants or revokes operator status for a `spender`. +Interface for the Light Contract Ownership Standard. + +A standardized minimal interface required to identify an account that controls a contract +
+

Functions

+
+- [owner()](#IERC5313-owner--)
- + +
-

Transfer(address caller, address indexed sender, address indexed receiver, uint256 indexed id, uint256 amount)

+

owner() → address

-

event

-# +

external

+#
-
-Emitted when `amount` tokens of type `id` are moved from `sender` to `receiver` initiated by `caller`. +Gets the address of the owner.
- +
-## `IERC6909Metadata` +## `IERC5805` - +
```solidity -import "@openzeppelin/contracts/interfaces/IERC6909.sol"; +import "@openzeppelin/contracts/interfaces/IERC5805.sol"; ``` -Optional extension of [`IERC6909`](#IERC6909) that adds metadata functions. -

Functions

-- [name(id)](#IERC6909Metadata-name-uint256-) -- [symbol(id)](#IERC6909Metadata-symbol-uint256-) -- [decimals(id)](#IERC6909Metadata-decimals-uint256-)
-IERC6909 +IVotes -- [balanceOf(owner, id)](#IERC6909-balanceOf-address-uint256-) -- [allowance(owner, spender, id)](#IERC6909-allowance-address-address-uint256-) -- [isOperator(owner, spender)](#IERC6909-isOperator-address-address-) -- [approve(spender, id, amount)](#IERC6909-approve-address-uint256-uint256-) -- [setOperator(spender, approved)](#IERC6909-setOperator-address-bool-) -- [transfer(receiver, id, amount)](#IERC6909-transfer-address-uint256-uint256-) -- [transferFrom(sender, receiver, id, amount)](#IERC6909-transferFrom-address-address-uint256-uint256-) +- [getVotes(account)](#IVotes-getVotes-address-) +- [getPastVotes(account, timepoint)](#IVotes-getPastVotes-address-uint256-) +- [getPastTotalSupply(timepoint)](#IVotes-getPastTotalSupply-uint256-) +- [delegates(account)](#IVotes-delegates-address-) +- [delegate(delegatee)](#IVotes-delegate-address-) +- [delegateBySig(delegatee, nonce, expiry, v, r, s)](#IVotes-delegateBySig-address-uint256-uint256-uint8-bytes32-bytes32-)
-IERC165 +IERC6372 -- [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) +- [clock()](#IERC6372-clock--) +- [CLOCK_MODE()](#IERC6372-CLOCK_MODE--)
@@ -1786,72 +1853,90 @@ Optional extension of [`IERC6909`](#IERC6909) that adds metadata functions.

Events

-IERC6909 +IVotes -- [Approval(owner, spender, id, amount)](#IERC6909-Approval-address-address-uint256-uint256-) -- [OperatorSet(owner, spender, approved)](#IERC6909-OperatorSet-address-address-bool-) -- [Transfer(caller, sender, receiver, id, amount)](#IERC6909-Transfer-address-address-address-uint256-uint256-) +- [DelegateChanged(delegator, fromDelegate, toDelegate)](#IVotes-DelegateChanged-address-address-address-) +- [DelegateVotesChanged(delegate, previousVotes, newVotes)](#IVotes-DelegateVotesChanged-address-uint256-uint256-)
- +
+

Errors

+
+
+IVotes -
-
-

name(uint256 id) → string

-
-

external

-# +- [VotesExpiredSignature(expiry)](#IVotes-VotesExpiredSignature-uint256-) + +
-
-Returns the name of the token of type `id`. + + +
+ +## `IERC6372` + + + + + +
+```solidity +import "@openzeppelin/contracts/interfaces/IERC6372.sol"; +``` + +
+

Functions

+
+- [clock()](#IERC6372-clock--) +- [CLOCK_MODE()](#IERC6372-CLOCK_MODE--)
- +
-

symbol(uint256 id) → string

+

clock() → uint48

external

-# +#
-Returns the ticker symbol of the token of type `id`. +Clock used for flagging checkpoints. Can be overridden to implement timestamp based checkpoints (and voting).
- +
-

decimals(uint256 id) → uint8

+

CLOCK_MODE() → string

external

-# +#
-Returns the number of decimals for the token of type `id`. +Description of the clock
- +
-## `IERC6909ContentURI` +## `IERC6909` @@ -1863,16 +1948,12 @@ Returns the number of decimals for the token of type `id`. import "@openzeppelin/contracts/interfaces/IERC6909.sol"; ``` -Optional extension of [`IERC6909`](#IERC6909) that adds content URI functions. +Required interface of an ERC-6909 compliant contract, as defined in the +[ERC](https://eips.ethereum.org/EIPS/eip-6909).

Functions

-- [contractURI()](#IERC6909ContentURI-contractURI--) -- [tokenURI(id)](#IERC6909ContentURI-tokenURI-uint256-) -
-IERC6909 - - [balanceOf(owner, id)](#IERC6909-balanceOf-address-uint256-) - [allowance(owner, spender, id)](#IERC6909-allowance-address-address-uint256-) - [isOperator(owner, spender)](#IERC6909-isOperator-address-address-) @@ -1880,8 +1961,6 @@ Optional extension of [`IERC6909`](#IERC6909) that adds content URI functions. - [setOperator(spender, approved)](#IERC6909-setOperator-address-bool-) - [transfer(receiver, id, amount)](#IERC6909-transfer-address-uint256-uint256-) - [transferFrom(sender, receiver, id, amount)](#IERC6909-transferFrom-address-address-uint256-uint256-) - -
IERC165 @@ -1894,3198 +1973,3146 @@ Optional extension of [`IERC6909`](#IERC6909) that adds content URI functions.

Events

-
-IERC6909 - - [Approval(owner, spender, id, amount)](#IERC6909-Approval-address-address-uint256-uint256-) - [OperatorSet(owner, spender, approved)](#IERC6909-OperatorSet-address-address-bool-) - [Transfer(caller, sender, receiver, id, amount)](#IERC6909-Transfer-address-address-address-uint256-uint256-) - -
-
+
-

contractURI() → string

+

balanceOf(address owner, uint256 id) → uint256

external

-# +#
-Returns URI for the contract. +Returns the amount of tokens of type `id` owned by `owner`.
- +
-

tokenURI(uint256 id) → string

+

allowance(address owner, address spender, uint256 id) → uint256

external

-# +#
-Returns the URI for the token of type `id`. +Returns the amount of tokens of type `id` that `spender` is allowed to spend on behalf of `owner`. + + +Does not include operator allowances. +
- - -
- -## `IERC6909TokenSupply` - - - - + +
+
+

isOperator(address owner, address spender) → bool

+
+

external

+#
+
+
-```solidity -import "@openzeppelin/contracts/interfaces/IERC6909.sol"; -``` - -Optional extension of [`IERC6909`](#IERC6909) that adds a token supply function. - -
-

Functions

-
-- [totalSupply(id)](#IERC6909TokenSupply-totalSupply-uint256-) -
-IERC6909 - -- [balanceOf(owner, id)](#IERC6909-balanceOf-address-uint256-) -- [allowance(owner, spender, id)](#IERC6909-allowance-address-address-uint256-) -- [isOperator(owner, spender)](#IERC6909-isOperator-address-address-) -- [approve(spender, id, amount)](#IERC6909-approve-address-uint256-uint256-) -- [setOperator(spender, approved)](#IERC6909-setOperator-address-bool-) -- [transfer(receiver, id, amount)](#IERC6909-transfer-address-uint256-uint256-) -- [transferFrom(sender, receiver, id, amount)](#IERC6909-transferFrom-address-address-uint256-uint256-) +Returns true if `spender` is set as an operator for `owner`. -
-
-IERC165 +
+
-- [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) + -
+
+
+

approve(address spender, uint256 id, uint256 amount) → bool

+
+

external

+#
+
-
-

Events

-
-
-IERC6909 +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. -- [Approval(owner, spender, id, amount)](#IERC6909-Approval-address-address-uint256-uint256-) -- [OperatorSet(owner, spender, approved)](#IERC6909-OperatorSet-address-address-bool-) -- [Transfer(caller, sender, receiver, id, amount)](#IERC6909-Transfer-address-address-address-uint256-uint256-) +Must return true. -
- +
-

totalSupply(uint256 id) → uint256

+

setOperator(address spender, bool approved) → bool

external

-# +#
-Returns the total supply of the token of type `id`. +Grants or revokes unlimited transfer permission of any token id to `spender` for the caller's tokens. + +Must return true.
- - -
- -## `IERC7913SignatureVerifier` - - - - + +
+
+

transfer(address receiver, uint256 id, uint256 amount) → bool

+
+

external

+#
+
+
-```solidity -import "@openzeppelin/contracts/interfaces/IERC7913.sol"; -``` +Transfers `amount` of token type `id` from the caller's account to `receiver`. -Signature verifier interface. +Must return true. -
-

Functions

-
-- [verify(key, hash, signature)](#IERC7913SignatureVerifier-verify-bytes-bytes32-bytes-)
- +
-

verify(bytes key, bytes32 hash, bytes signature) → bytes4

+

transferFrom(address sender, address receiver, uint256 id, uint256 amount) → bool

external

-# +#
-Verifies `signature` as a valid signature of `hash` by `key`. +Transfers `amount` of token type `id` from `sender` to `receiver`. -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 +Must return true.
- - -
- -## `IERC1822Proxiable` - - - - + +
+
+

Approval(address indexed owner, address indexed spender, uint256 indexed id, uint256 amount)

+
+

event

+# +
-```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC1822.sol"; -``` +
-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. +Emitted when the allowance of a `spender` for an `owner` is set for a token of type `id`. +The new allowance is `amount`. -
-

Functions

-
-- [proxiableUUID()](#IERC1822Proxiable-proxiableUUID--)
- - +
-

proxiableUUID() → bytes32

+

OperatorSet(address indexed owner, address indexed spender, bool approved)

-

external

-# +

event

+#
-
-Returns the storage slot that the proxiable contract assumes is being used to store the implementation -address. +
- -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. - +Emitted when `owner` grants or revokes operator status for a `spender`.
+ - - -
- -## `PackedUserOperation` - - - - - +
+
+

Transfer(address caller, address indexed sender, address indexed receiver, uint256 indexed id, uint256 amount)

+
+

event

+# +
-```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; -``` +
-A [user operation](https://github.com/ethereum/ercs/blob/master/ERCS/erc-4337.md#useroperation) is composed of the following elements: -- `sender` (`address`): The account making the operation -- `nonce` (`uint256`): Anti-replay parameter (see “Semi-abstracted Nonce Support” ) -- `factory` (`address`): account factory, only for new accounts -- `factoryData` (`bytes`): data for account factory (only if account factory exists) -- `callData` (`bytes`): The data to pass to the sender during the main execution call -- `callGasLimit` (`uint256`): The amount of gas to allocate the main execution call -- `verificationGasLimit` (`uint256`): The amount of gas to allocate for the verification step -- `preVerificationGas` (`uint256`): Extra gas to pay the bundler -- `maxFeePerGas` (`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 code -- `paymasterPostOpGasLimit` (`uint256`): The amount of gas to allocate for the paymaster post-operation code -- `paymasterData` (`bytes`): Data for paymaster (only if paymaster exists) -- `signature` (`bytes`): Data passed into the account to verify authorization +Emitted when `amount` tokens of type `id` are moved from `sender` to `receiver` initiated by `caller`. -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) - For EntryPoint v0.9+, may optionally include `paymasterSignature` at the end: - `paymaster || paymasterVerificationGasLimit || paymasterPostOpGasLimit || paymasterData || paymasterSignature || paymasterSignatureSize || PAYMASTER_SIG_MAGIC` -- `signature` (`bytes`) +
+
- +
-## `IAggregator` +## `IERC6909Metadata` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; +import "@openzeppelin/contracts/interfaces/IERC6909.sol"; ``` -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 [ERC-7766](https://eips.ethereum.org/EIPS/eip-7766) +Optional extension of [`IERC6909`](#IERC6909) that adds metadata functions.

Functions

-- [validateUserOpSignature(userOp)](#IAggregator-validateUserOpSignature-struct-PackedUserOperation-) -- [aggregateSignatures(userOps)](#IAggregator-aggregateSignatures-struct-PackedUserOperation---) -- [validateSignatures(userOps, signature)](#IAggregator-validateSignatures-struct-PackedUserOperation---bytes-) -
-
+- [name(id)](#IERC6909Metadata-name-uint256-) +- [symbol(id)](#IERC6909Metadata-symbol-uint256-) +- [decimals(id)](#IERC6909Metadata-decimals-uint256-) +
+IERC6909 - +- [balanceOf(owner, id)](#IERC6909-balanceOf-address-uint256-) +- [allowance(owner, spender, id)](#IERC6909-allowance-address-address-uint256-) +- [isOperator(owner, spender)](#IERC6909-isOperator-address-address-) +- [approve(spender, id, amount)](#IERC6909-approve-address-uint256-uint256-) +- [setOperator(spender, approved)](#IERC6909-setOperator-address-bool-) +- [transfer(receiver, id, amount)](#IERC6909-transfer-address-uint256-uint256-) +- [transferFrom(sender, receiver, id, amount)](#IERC6909-transferFrom-address-address-uint256-uint256-) -
-
-

validateUserOpSignature(struct PackedUserOperation userOp) → bytes sigForUserOp

-
-

external

-# -
-
-
+
+
+IERC165 -Validates the signature for a user operation. -Returns an alternative signature that should be used during bundling. +- [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) +
- - -
-
-

aggregateSignatures(struct PackedUserOperation[] userOps) → bytes aggregatesSignature

-
-

external

-# -
-
-
+
+

Events

+
+
+IERC6909 -Returns an aggregated signature for a batch of user operation's signatures. +- [Approval(owner, spender, id, amount)](#IERC6909-Approval-address-address-uint256-uint256-) +- [OperatorSet(owner, spender, approved)](#IERC6909-OperatorSet-address-address-bool-) +- [Transfer(caller, sender, receiver, id, amount)](#IERC6909-Transfer-address-address-address-uint256-uint256-) +
- +
-

validateSignatures(struct PackedUserOperation[] userOps, bytes signature)

+

name(uint256 id) → string

external

-# +#
-Validates that the aggregated signature is valid for the user operations. - -Requirements: - -- The aggregated signature MUST match the given list of operations. - -
-
- - - -
- -## `IEntryPointNonces` - - - - - -
- -```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; -``` +Returns the name of the token of type `id`. -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 [ERC-4337 semi-abstracted nonce support](https://eips.ethereum.org/EIPS/eip-4337#semi-abstracted-nonce-support). +
+
+

symbol(uint256 id) → string

+
+

external

+# +
+
+
+ +Returns the ticker symbol of the token of type `id`. -
-

Functions

-
-- [getNonce(sender, key)](#IEntryPointNonces-getNonce-address-uint192-)
- +
-

getNonce(address sender, uint192 key) → uint256 nonce

+

decimals(uint256 id) → uint8

external

-# +#
-Returns the nonce for a `sender` account and a `key`. - -Nonces for a certain `key` are always increasing. +Returns the number of decimals for the token of type `id`.
- +
-## `IEntryPointStake` +## `IERC6909ContentURI` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; +import "@openzeppelin/contracts/interfaces/IERC6909.sol"; ``` -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 [reputation, throttling and banning.](https://eips.ethereum.org/EIPS/eip-4337#reputation-scoring-and-throttlingbanning-for-global-entities)) +Optional extension of [`IERC6909`](#IERC6909) that adds content URI functions.

Functions

-- [balanceOf(account)](#IEntryPointStake-balanceOf-address-) -- [depositTo(account)](#IEntryPointStake-depositTo-address-) -- [withdrawTo(withdrawAddress, withdrawAmount)](#IEntryPointStake-withdrawTo-address-payable-uint256-) -- [addStake(unstakeDelaySec)](#IEntryPointStake-addStake-uint32-) -- [unlockStake()](#IEntryPointStake-unlockStake--) -- [withdrawStake(withdrawAddress)](#IEntryPointStake-withdrawStake-address-payable-) +- [contractURI()](#IERC6909ContentURI-contractURI--) +- [tokenURI(id)](#IERC6909ContentURI-tokenURI-uint256-) +
+IERC6909 + +- [balanceOf(owner, id)](#IERC6909-balanceOf-address-uint256-) +- [allowance(owner, spender, id)](#IERC6909-allowance-address-address-uint256-) +- [isOperator(owner, spender)](#IERC6909-isOperator-address-address-) +- [approve(spender, id, amount)](#IERC6909-approve-address-uint256-uint256-) +- [setOperator(spender, approved)](#IERC6909-setOperator-address-bool-) +- [transfer(receiver, id, amount)](#IERC6909-transfer-address-uint256-uint256-) +- [transferFrom(sender, receiver, id, amount)](#IERC6909-transferFrom-address-address-uint256-uint256-) + +
+
+IERC165 + +- [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) + +
- +
+

Events

+
+
+IERC6909 + +- [Approval(owner, spender, id, amount)](#IERC6909-Approval-address-address-uint256-uint256-) +- [OperatorSet(owner, spender, approved)](#IERC6909-OperatorSet-address-address-bool-) +- [Transfer(caller, sender, receiver, id, amount)](#IERC6909-Transfer-address-address-address-uint256-uint256-) + +
+
+
+ +
-

balanceOf(address account) → uint256

+

contractURI() → string

external

-# +#
-Returns the balance of the account. +Returns URI for the contract.
- +
-

depositTo(address account)

+

tokenURI(uint256 id) → string

external

-# +#
-Deposits `msg.value` to the account. +Returns the URI for the token of type `id`.
- + -
-
-

withdrawTo(address payable withdrawAddress, uint256 withdrawAmount)

-
-

external

-# +
+ +## `IERC6909TokenSupply` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/interfaces/IERC6909.sol"; +``` + +Optional extension of [`IERC6909`](#IERC6909) that adds a token supply function. + +
+

Functions

+
+- [totalSupply(id)](#IERC6909TokenSupply-totalSupply-uint256-) +
+IERC6909 + +- [balanceOf(owner, id)](#IERC6909-balanceOf-address-uint256-) +- [allowance(owner, spender, id)](#IERC6909-allowance-address-address-uint256-) +- [isOperator(owner, spender)](#IERC6909-isOperator-address-address-) +- [approve(spender, id, amount)](#IERC6909-approve-address-uint256-uint256-) +- [setOperator(spender, approved)](#IERC6909-setOperator-address-bool-) +- [transfer(receiver, id, amount)](#IERC6909-transfer-address-uint256-uint256-) +- [transferFrom(sender, receiver, id, amount)](#IERC6909-transferFrom-address-address-uint256-uint256-) + +
+
+IERC165 + +- [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) + +
-
-Withdraws `withdrawAmount` from the account to `withdrawAddress`. +
+

Events

+
+
+IERC6909 + +- [Approval(owner, spender, id, amount)](#IERC6909-Approval-address-address-uint256-uint256-) +- [OperatorSet(owner, spender, approved)](#IERC6909-OperatorSet-address-address-bool-) +- [Transfer(caller, sender, receiver, id, amount)](#IERC6909-Transfer-address-address-address-uint256-uint256-) +
- +
-

addStake(uint32 unstakeDelaySec)

+

totalSupply(uint256 id) → uint256

external

-# +#
-Adds stake to the account with an unstake delay of `unstakeDelaySec`. +Returns the total supply of the token of type `id`.
- + + +
+ +## `IERC7751` + + + + -
-
-

unlockStake()

-
-

external

-# -
-
-Unlocks the stake of the account. +```solidity +import "@openzeppelin/contracts/interfaces/IERC7751.sol"; +``` + +Wrapping of bubbled up reverts +Interface of the [ERC-7751](https://eips.ethereum.org/EIPS/eip-7751) wrapping of bubbled up reverts. +
+

Errors

+
+- [WrappedError(target, selector, reason, details)](#IERC7751-WrappedError-address-bytes4-bytes-bytes-)
- +
-

withdrawStake(address payable withdrawAddress)

+

WrappedError(address target, bytes4 selector, bytes reason, bytes details)

-

external

-# +

error

+#
-Withdraws the stake of the account to `withdrawAddress`. -
- +
-## `IEntryPoint` +## `IERC777` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; +import "@openzeppelin/contracts/interfaces/IERC777.sol"; ``` -Entry point for user operations. +Interface of the ERC-777 Token standard as defined in the ERC. -User operations are validated and executed by this contract. +This contract uses the +[ERC-1820 registry standard](https://eips.ethereum.org/EIPS/eip-1820) to let +token holders and recipients react to token movements by using setting implementers +for the associated interfaces in said registry. See [`IERC1820Registry`](#IERC1820Registry) and +[`IERC1820Implementer`](#IERC1820Implementer).

Functions

-- [handleOps(ops, beneficiary)](#IEntryPoint-handleOps-struct-PackedUserOperation---address-payable-) -- [handleAggregatedOps(opsPerAggregator, beneficiary)](#IEntryPoint-handleAggregatedOps-struct-IEntryPoint-UserOpsPerAggregator---address-payable-) -
-IEntryPointStake - -- [balanceOf(account)](#IEntryPointStake-balanceOf-address-) -- [depositTo(account)](#IEntryPointStake-depositTo-address-) -- [withdrawTo(withdrawAddress, withdrawAmount)](#IEntryPointStake-withdrawTo-address-payable-uint256-) -- [addStake(unstakeDelaySec)](#IEntryPointStake-addStake-uint32-) -- [unlockStake()](#IEntryPointStake-unlockStake--) -- [withdrawStake(withdrawAddress)](#IEntryPointStake-withdrawStake-address-payable-) - -
-
-IEntryPointNonces - -- [getNonce(sender, key)](#IEntryPointNonces-getNonce-address-uint192-) - -
+- [name()](#IERC777-name--) +- [symbol()](#IERC777-symbol--) +- [granularity()](#IERC777-granularity--) +- [totalSupply()](#IERC777-totalSupply--) +- [balanceOf(owner)](#IERC777-balanceOf-address-) +- [send(recipient, amount, data)](#IERC777-send-address-uint256-bytes-) +- [burn(amount, data)](#IERC777-burn-uint256-bytes-) +- [isOperatorFor(operator, tokenHolder)](#IERC777-isOperatorFor-address-address-) +- [authorizeOperator(operator)](#IERC777-authorizeOperator-address-) +- [revokeOperator(operator)](#IERC777-revokeOperator-address-) +- [defaultOperators()](#IERC777-defaultOperators--) +- [operatorSend(sender, recipient, amount, data, operatorData)](#IERC777-operatorSend-address-address-uint256-bytes-bytes-) +- [operatorBurn(account, amount, data, operatorData)](#IERC777-operatorBurn-address-uint256-bytes-bytes-)
-

Errors

+

Events

-- [FailedOp(opIndex, reason)](#IEntryPoint-FailedOp-uint256-string-) -- [FailedOpWithRevert(opIndex, reason, inner)](#IEntryPoint-FailedOpWithRevert-uint256-string-bytes-) +- [Minted(operator, to, amount, data, operatorData)](#IERC777-Minted-address-address-uint256-bytes-bytes-) +- [Burned(operator, from, amount, data, operatorData)](#IERC777-Burned-address-address-uint256-bytes-bytes-) +- [AuthorizedOperator(operator, tokenHolder)](#IERC777-AuthorizedOperator-address-address-) +- [RevokedOperator(operator, tokenHolder)](#IERC777-RevokedOperator-address-address-) +- [Sent(operator, from, to, amount, data, operatorData)](#IERC777-Sent-address-address-address-uint256-bytes-bytes-)
- +
-

handleOps(struct PackedUserOperation[] ops, address payable beneficiary)

+

name() → string

external

-# +#
-Executes a batch of user operations. +Returns the name of the token.
- +
-

handleAggregatedOps(struct IEntryPoint.UserOpsPerAggregator[] opsPerAggregator, address payable beneficiary)

+

symbol() → string

external

-# +#
-Executes a batch of aggregated user operations per aggregator. +Returns the symbol of the token, usually a shorter version of the +name.
- +
-

FailedOp(uint256 opIndex, string reason)

+

granularity() → uint256

-

error

-# +

external

+#
-A user operation at `opIndex` failed with `reason`. +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.
- +
-

FailedOpWithRevert(uint256 opIndex, string reason, bytes inner)

+

totalSupply() → uint256

-

error

-# +

external

+#
-A user operation at `opIndex` failed with `reason` and `inner` returned data. +Returns the amount of tokens in existence.
- - -
- -## `IAccount` - - - - + +
+
+

balanceOf(address owner) → uint256

+
+

external

+#
+
+
-```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; -``` - -Base interface for an ERC-4337 account. +Returns the amount of tokens owned by an account (`owner`). -
-

Functions

-
-- [validateUserOp(userOp, userOpHash, missingAccountFunds)](#IAccount-validateUserOp-struct-PackedUserOperation-bytes32-uint256-)
- +
-

validateUserOp(struct PackedUserOperation userOp, bytes32 userOpHash, uint256 missingAccountFunds) → uint256 validationData

+

send(address recipient, uint256 amount, bytes data)

external

-# +#
-Validates a user operation. +Moves `amount` tokens from the caller's account to `recipient`. -* 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) +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`](#IERC777Sender) and [`IERC777Recipient`](#IERC777Recipient). -Returns an encoded packed validation data that is composed of the following elements: +Emits a [`IERC777.Sent`](#IERC777-Sent-address-address-address-uint256-bytes-bytes-) event. -- `authorizer` (`address`): 0 for success, 1 for failure, otherwise the address of an authorizer contract -- `validUntil` (`uint48`): The UserOp is valid only up to this time. Zero for “infinite”. -- `validAfter` (`uint48`): The UserOp is valid only after this time. +Requirements + +- the caller must have at least `amount` tokens. +- `recipient` cannot be the zero address. +- if `recipient` is a contract, it must implement the [`IERC777Recipient`](#IERC777Recipient) +interface.
- + -
+
+
+

burn(uint256 amount, bytes data)

+
+

external

+# +
+
+
-## `IAccountExecute` +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`](#IERC777Sender). -
+Emits a [`IERC777.Burned`](#IERC777-Burned-address-address-uint256-bytes-bytes-) event. -```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; -``` +Requirements -Support for executing user operations by prepending the [`IAccountExecute.executeUserOp`](#IAccountExecute-executeUserOp-struct-PackedUserOperation-bytes32-) function selector -to the UserOperation's `callData`. +- the caller must have at least `amount` tokens. -
-

Functions

-
-- [executeUserOp(userOp, userOpHash)](#IAccountExecute-executeUserOp-struct-PackedUserOperation-bytes32-)
- +
-

executeUserOp(struct PackedUserOperation userOp, bytes32 userOpHash)

+

isOperatorFor(address operator, address tokenHolder) → bool

external

-# +#
-Executes a user operation. +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 [`IERC777.operatorSend`](#IERC777-operatorSend-address-address-uint256-bytes-bytes-) and [`IERC777.operatorBurn`](#IERC777-operatorBurn-address-uint256-bytes-bytes-).
- - -
+ -## `IPaymaster` +
+
+

authorizeOperator(address operator)

+
+

external

+# +
+
+
- - - +Make an account an operator of the caller. -
+See [`IERC777.isOperatorFor`](#IERC777-isOperatorFor-address-address-). -```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; -``` +Emits an [`IERC777.AuthorizedOperator`](#IERC777-AuthorizedOperator-address-address-) event. -Interface for a paymaster contract that agrees to pay for the gas costs of a user operation. +Requirements - -A paymaster must hold a stake to cover the required entrypoint stake and also the gas for the transaction. - +- `operator` cannot be calling address. -
-

Functions

-
-- [validatePaymasterUserOp(userOp, userOpHash, maxCost)](#IPaymaster-validatePaymasterUserOp-struct-PackedUserOperation-bytes32-uint256-) -- [postOp(mode, context, actualGasCost, actualUserOpFeePerGas)](#IPaymaster-postOp-enum-IPaymaster-PostOpMode-bytes-uint256-uint256-)
- +
-

validatePaymasterUserOp(struct PackedUserOperation userOp, bytes32 userOpHash, uint256 maxCost) → bytes context, uint256 validationData

+

revokeOperator(address operator)

external

-# +#
-Validates whether the paymaster is willing to pay for the user operation. See -[`IAccount.validateUserOp`](#IAccount-validateUserOp-struct-PackedUserOperation-bytes32-uint256-) for additional information on the return value. +Revoke an account's operator status for the caller. - -Bundlers will reject this method if it modifies the state, unless it's whitelisted. - +See [`IERC777.isOperatorFor`](#IERC777-isOperatorFor-address-address-) and [`IERC777.defaultOperators`](#IERC777-defaultOperators--). + +Emits a [`IERC777.RevokedOperator`](#IERC777-RevokedOperator-address-address-) event. + +Requirements + +- `operator` cannot be calling address.
- +
-

postOp(enum IPaymaster.PostOpMode mode, bytes context, uint256 actualGasCost, uint256 actualUserOpFeePerGas)

+

defaultOperators() → address[]

external

-# +#
-Verifies the sender is the entrypoint. +Returns the list of default operators. These accounts are operators +for all token holders, even if [`IERC777.authorizeOperator`](#IERC777-authorizeOperator-address-) was never called on +them. + +This list is immutable, but individual holders may revoke these via +[`IERC777.revokeOperator`](#IERC777-revokeOperator-address-), in which case [`IERC777.isOperatorFor`](#IERC777-isOperatorFor-address-address-) will return false.
- - -
+ -## `IERC20Errors` +
+
+

operatorSend(address sender, address recipient, uint256 amount, bytes data, bytes operatorData)

+
+

external

+# +
+
+
- - - +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`](#IERC777Sender) and [`IERC777Recipient`](#IERC777Recipient). -```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC6093.sol"; -``` +Emits a [`IERC777.Sent`](#IERC777-Sent-address-address-address-uint256-bytes-bytes-) event. -Standard ERC-20 Errors -Interface of the [ERC-6093](https://eips.ethereum.org/EIPS/eip-6093) custom errors for ERC-20 tokens. +Requirements + +- `sender` cannot be the zero address. +- `sender` must have at least `amount` tokens. +- the caller must be an operator for `sender`. +- `recipient` cannot be the zero address. +- if `recipient` is a contract, it must implement the [`IERC777Recipient`](#IERC777Recipient) +interface. -
-

Errors

-
-- [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) -- [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) -- [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) -- [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) -- [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) -- [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-)
- +
-

ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed)

+

operatorBurn(address account, uint256 amount, bytes data, bytes operatorData)

-

error

-# +

external

+#
-Indicates an error related to the current `balance` of a `sender`. Used in transfers. +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`](#IERC777Sender). + +Emits a [`IERC777.Burned`](#IERC777-Burned-address-address-uint256-bytes-bytes-) event. + +Requirements + +- `account` cannot be the zero address. +- `account` must have at least `amount` tokens. +- the caller must be an operator for `account`.
- +
-

ERC20InvalidSender(address sender)

+

Minted(address indexed operator, address indexed to, uint256 amount, bytes data, bytes operatorData)

-

error

-# +

event

+#
+
-Indicates a failure with the token `sender`. Used in transfers. +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.
- - +
-

ERC20InvalidReceiver(address receiver)

+

Burned(address indexed operator, address indexed from, uint256 amount, bytes data, bytes operatorData)

-

error

-# +

event

+#
+
-Indicates a failure with the token `receiver`. Used in transfers. +Emitted when `operator` destroys `amount` tokens from `account`. + +Note that some additional user `data` and `operatorData` can be logged in the event.
- - +
-

ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed)

+

AuthorizedOperator(address indexed operator, address indexed tokenHolder)

-

error

-# +

event

+#
+
-Indicates a failure with the `spender`’s `allowance`. Used in transfers. +Emitted when `operator` is made operator for `tokenHolder`.
- - +
-

ERC20InvalidApprover(address approver)

+

RevokedOperator(address indexed operator, address indexed tokenHolder)

-

error

-# +

event

+#
+
-Indicates a failure with the `approver` of a token to be approved. Used in approvals. +Emitted when `operator` is revoked its operator status for `tokenHolder`.
- - +
-

ERC20InvalidSpender(address spender)

+

Sent(address indexed operator, address indexed from, address indexed to, uint256 amount, bytes data, bytes operatorData)

-

error

-# +

event

+#
-
-Indicates a failure with the `spender` to be approved. Used in approvals. +
- +
-## `IERC721Errors` +## `IERC777Recipient` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC6093.sol"; +import "@openzeppelin/contracts/interfaces/IERC777Recipient.sol"; ``` -Standard ERC-721 Errors -Interface of the [ERC-6093](https://eips.ethereum.org/EIPS/eip-6093) custom errors for ERC-721 tokens. +Interface of the ERC-777 Tokens Recipient standard as defined in the ERC. + +Accounts can be notified of [`IERC777`](#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 +[ERC-1820 global registry](https://eips.ethereum.org/EIPS/eip-1820). + +See [`IERC1820Registry`](#IERC1820Registry) and [`IERC1820Implementer`](#IERC1820Implementer).
-

Errors

+

Functions

-- [ERC721InvalidOwner(owner)](#IERC721Errors-ERC721InvalidOwner-address-) -- [ERC721NonexistentToken(tokenId)](#IERC721Errors-ERC721NonexistentToken-uint256-) -- [ERC721IncorrectOwner(sender, tokenId, owner)](#IERC721Errors-ERC721IncorrectOwner-address-uint256-address-) -- [ERC721InvalidSender(sender)](#IERC721Errors-ERC721InvalidSender-address-) -- [ERC721InvalidReceiver(receiver)](#IERC721Errors-ERC721InvalidReceiver-address-) -- [ERC721InsufficientApproval(operator, tokenId)](#IERC721Errors-ERC721InsufficientApproval-address-uint256-) -- [ERC721InvalidApprover(approver)](#IERC721Errors-ERC721InvalidApprover-address-) -- [ERC721InvalidOperator(operator)](#IERC721Errors-ERC721InvalidOperator-address-) +- [tokensReceived(operator, from, to, amount, userData, operatorData)](#IERC777Recipient-tokensReceived-address-address-address-uint256-bytes-bytes-)
- +
-

ERC721InvalidOwner(address owner)

+

tokensReceived(address operator, address from, address to, uint256 amount, bytes userData, bytes operatorData)

-

error

-# +

external

+#
-Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-721. -Used in balance queries. +Called by an [`IERC777`](#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`](#IERC777-balanceOf-address-), etc., can be used to query the post-operation state. - +This function may revert to prevent the operation from being executed. -
-
-

ERC721NonexistentToken(uint256 tokenId)

-
-

error

-#
-
- -Indicates a `tokenId` whose `owner` is the zero address. -
-
+ - +
-
-
-

ERC721IncorrectOwner(address sender, uint256 tokenId, address owner)

-
-

error

-# -
-
-
+## `IERC777Sender` -Indicates an error related to the ownership over a particular token. Used in transfers. + + + -
- +```solidity +import "@openzeppelin/contracts/interfaces/IERC777Sender.sol"; +``` -
-
-

ERC721InvalidSender(address sender)

-
-

error

-# -
-
-
+Interface of the ERC-777 Tokens Sender standard as defined in the ERC. -Indicates a failure with the token `sender`. Used in transfers. +[`IERC777`](#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 +[ERC-1820 global registry](https://eips.ethereum.org/EIPS/eip-1820). +See [`IERC1820Registry`](#IERC1820Registry) and [`IERC1820Implementer`](#IERC1820Implementer). + +
+

Functions

+
+- [tokensToSend(operator, from, to, amount, userData, operatorData)](#IERC777Sender-tokensToSend-address-address-address-uint256-bytes-bytes-)
- +
-

ERC721InvalidReceiver(address receiver)

+

tokensToSend(address operator, address from, address to, uint256 amount, bytes userData, bytes operatorData)

-

error

-# +

external

+#
-Indicates a failure with the token `receiver`. Used in transfers. +Called by an [`IERC777`](#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`](#IERC777-balanceOf-address-), etc., can be used to query the pre-operation state. - +This function may revert to prevent the operation from being executed. -
-
-

ERC721InsufficientApproval(address operator, uint256 tokenId)

-
-

error

-#
-
-Indicates a failure with the `operator`’s approval. Used in transfers. + -
-
+
- +## `IERC7913SignatureVerifier` + + + + -
-
-

ERC721InvalidApprover(address approver)

-
-

error

-# -
-
-Indicates a failure with the `approver` of a token to be approved. Used in approvals. +```solidity +import "@openzeppelin/contracts/interfaces/IERC7913.sol"; +``` + +Signature verifier interface. +
+

Functions

+
+- [verify(key, hash, signature)](#IERC7913SignatureVerifier-verify-bytes-bytes32-bytes-)
- +
-

ERC721InvalidOperator(address operator)

+

verify(bytes key, bytes32 hash, bytes signature) → bytes4

-

error

-# +

external

+#
-Indicates a failure with the `operator` to be approved. Used in approvals. +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
- +
-## `IERC1155Errors` +## `IERC1822Proxiable` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC6093.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC1822.sol"; ``` -Standard ERC-1155 Errors -Interface of the [ERC-6093](https://eips.ethereum.org/EIPS/eip-6093) custom errors for ERC-1155 tokens. +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.
-

Errors

+

Functions

-- [ERC1155InsufficientBalance(sender, balance, needed, tokenId)](#IERC1155Errors-ERC1155InsufficientBalance-address-uint256-uint256-uint256-) -- [ERC1155InvalidSender(sender)](#IERC1155Errors-ERC1155InvalidSender-address-) -- [ERC1155InvalidReceiver(receiver)](#IERC1155Errors-ERC1155InvalidReceiver-address-) -- [ERC1155MissingApprovalForAll(operator, owner)](#IERC1155Errors-ERC1155MissingApprovalForAll-address-address-) -- [ERC1155InvalidApprover(approver)](#IERC1155Errors-ERC1155InvalidApprover-address-) -- [ERC1155InvalidOperator(operator)](#IERC1155Errors-ERC1155InvalidOperator-address-) -- [ERC1155InvalidArrayLength(idsLength, valuesLength)](#IERC1155Errors-ERC1155InvalidArrayLength-uint256-uint256-) +- [proxiableUUID()](#IERC1822Proxiable-proxiableUUID--)
- +
-

ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId)

+

proxiableUUID() → bytes32

-

error

-# +

external

+#
-Indicates an error related to the current `balance` of a `sender`. Used in transfers. +Returns the storage slot that the proxiable contract assumes is being used to store the implementation +address. + + +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. +
- + -
-
-

ERC1155InvalidSender(address sender)

-
-

error

-# -
-
-
+
-Indicates a failure with the token `sender`. Used in transfers. +## `PackedUserOperation` + + + + -
- +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; +``` -
-
-

ERC1155InvalidReceiver(address receiver)

-
-

error

-# -
-
-
+A [user operation](https://github.com/ethereum/ercs/blob/master/ERCS/erc-4337.md#useroperation) is composed of the following elements: +- `sender` (`address`): The account making the operation +- `nonce` (`uint256`): Anti-replay parameter (see “Semi-abstracted Nonce Support” ) +- `factory` (`address`): account factory, only for new accounts +- `factoryData` (`bytes`): data for account factory (only if account factory exists) +- `callData` (`bytes`): The data to pass to the sender during the main execution call +- `callGasLimit` (`uint256`): The amount of gas to allocate the main execution call +- `verificationGasLimit` (`uint256`): The amount of gas to allocate for the verification step +- `preVerificationGas` (`uint256`): Extra gas to pay the bundler +- `maxFeePerGas` (`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 code +- `paymasterPostOpGasLimit` (`uint256`): The amount of gas to allocate for the paymaster post-operation code +- `paymasterData` (`bytes`): Data for paymaster (only if paymaster exists) +- `signature` (`bytes`): Data passed into the account to verify authorization -Indicates a failure with the token `receiver`. Used in transfers. +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) + For EntryPoint v0.9+, may optionally include `paymasterSignature` at the end: + `paymaster || paymasterVerificationGasLimit || paymasterPostOpGasLimit || paymasterData || paymasterSignature || paymasterSignatureSize || PAYMASTER_SIG_MAGIC` +- `signature` (`bytes`) -
-
+ - +
+ +## `IAggregator` + + + + -
-
-

ERC1155MissingApprovalForAll(address operator, address owner)

-
-

error

-# -
-
-Indicates a failure with the `operator`’s approval. Used in transfers. +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; +``` + +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 [ERC-7766](https://eips.ethereum.org/EIPS/eip-7766) + +
+

Functions

+
+- [validateUserOpSignature(userOp)](#IAggregator-validateUserOpSignature-struct-PackedUserOperation-) +- [aggregateSignatures(userOps)](#IAggregator-aggregateSignatures-struct-PackedUserOperation---) +- [validateSignatures(userOps, signature)](#IAggregator-validateSignatures-struct-PackedUserOperation---bytes-)
- +
-

ERC1155InvalidApprover(address approver)

+

validateUserOpSignature(struct PackedUserOperation userOp) → bytes sigForUserOp

-

error

-# +

external

+#
-Indicates a failure with the `approver` of a token to be approved. Used in approvals. +Validates the signature for a user operation. +Returns an alternative signature that should be used during bundling.
- +
-

ERC1155InvalidOperator(address operator)

+

aggregateSignatures(struct PackedUserOperation[] userOps) → bytes aggregatesSignature

-

error

-# +

external

+#
-Indicates a failure with the `operator` to be approved. Used in approvals. +Returns an aggregated signature for a batch of user operation's signatures.
- +
-

ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength)

+

validateSignatures(struct PackedUserOperation[] userOps, bytes signature)

-

error

-# +

external

+#
-Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. -Used in batch transfers. - -
-
- - - -
+Validates that the aggregated signature is valid for the user operations. -## `VALIDATION_SUCCESS` +Requirements: - - - +- The aggregated signature MUST match the given list of operations.
- -```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; -``` - - - -
- -## `VALIDATION_FAILED` - - - - -
-```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; -``` - - +
-## `MODULE_TYPE_VALIDATOR` +## `IEntryPointNonces` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; ``` - - -
+Handle nonce management for accounts. -## `MODULE_TYPE_EXECUTOR` +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 [ERC-4337 semi-abstracted nonce support](https://eips.ethereum.org/EIPS/eip-4337#semi-abstracted-nonce-support). +
+

Functions

+
+- [getNonce(sender, key)](#IEntryPointNonces-getNonce-address-uint192-)
- -```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; -``` - - - -
- -## `MODULE_TYPE_FALLBACK` - - - - -
-```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; -``` - - + -
+
+
+

getNonce(address sender, uint192 key) → uint256 nonce

+
+

external

+# +
+
+
-## `MODULE_TYPE_HOOK` +Returns the nonce for a `sender` account and a `key`. - - - +Nonces for a certain `key` are always increasing. +
-```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; -``` - - +
-## `IERC7579Module` +## `IEntryPointStake` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; ``` -Minimal configuration interface for ERC-7579 modules +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 [reputation, throttling and banning.](https://eips.ethereum.org/EIPS/eip-4337#reputation-scoring-and-throttlingbanning-for-global-entities))

Functions

-- [onInstall(data)](#IERC7579Module-onInstall-bytes-) -- [onUninstall(data)](#IERC7579Module-onUninstall-bytes-) -- [isModuleType(moduleTypeId)](#IERC7579Module-isModuleType-uint256-) +- [balanceOf(account)](#IEntryPointStake-balanceOf-address-) +- [depositTo(account)](#IEntryPointStake-depositTo-address-) +- [withdrawTo(withdrawAddress, withdrawAmount)](#IEntryPointStake-withdrawTo-address-payable-uint256-) +- [addStake(unstakeDelaySec)](#IEntryPointStake-addStake-uint32-) +- [unlockStake()](#IEntryPointStake-unlockStake--) +- [withdrawStake(withdrawAddress)](#IEntryPointStake-withdrawStake-address-payable-)
- +
-

onInstall(bytes data)

+

balanceOf(address account) → uint256

external

-# +#
-This function is called by the smart account during installation of the module +Returns the balance of the account.
- +
-

onUninstall(bytes data)

+

depositTo(address account)

external

-# +#
-This function is called by the smart account during uninstallation of the module +Deposits `msg.value` to the account.
- +
-

isModuleType(uint256 moduleTypeId) → bool

+

withdrawTo(address payable withdrawAddress, uint256 withdrawAmount)

external

-# +#
-Returns boolean value if module is a certain type +Withdraws `withdrawAmount` from the account to `withdrawAddress`.
- - -
- -## `IERC7579Validator` - - - - + +
+
+

addStake(uint32 unstakeDelaySec)

+
+

external

+#
+
+
-```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; -``` - -ERC-7579 Validation module (type 1). - -A module that implements logic to validate user operations and signatures. - -
-

Functions

-
-- [validateUserOp(userOp, userOpHash)](#IERC7579Validator-validateUserOp-struct-PackedUserOperation-bytes32-) -- [isValidSignatureWithSender(sender, hash, signature)](#IERC7579Validator-isValidSignatureWithSender-address-bytes32-bytes-) -
-IERC7579Module - -- [onInstall(data)](#IERC7579Module-onInstall-bytes-) -- [onUninstall(data)](#IERC7579Module-onUninstall-bytes-) -- [isModuleType(moduleTypeId)](#IERC7579Module-isModuleType-uint256-) +Adds stake to the account with an unstake delay of `unstakeDelaySec`. -
- +
-

validateUserOp(struct PackedUserOperation userOp, bytes32 userOpHash) → uint256

+

unlockStake()

external

-# +#
-Validates a UserOperation +Unlocks the stake of the account.
- +
-

isValidSignatureWithSender(address sender, bytes32 hash, bytes signature) → bytes4

+

withdrawStake(address payable withdrawAddress)

external

-# +#
-Validates a signature using ERC-1271 +Withdraws the stake of the account to `withdrawAddress`.
- +
-## `IERC7579Hook` +## `IEntryPoint` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; ``` -ERC-7579 Hooks module (type 4). +Entry point for user operations. -A module that implements logic to execute before and after the account executes a user operation, -either individually or batched. +User operations are validated and executed by this contract.

Functions

-- [preCheck(msgSender, value, msgData)](#IERC7579Hook-preCheck-address-uint256-bytes-) -- [postCheck(hookData)](#IERC7579Hook-postCheck-bytes-) +- [handleOps(ops, beneficiary)](#IEntryPoint-handleOps-struct-PackedUserOperation---address-payable-) +- [handleAggregatedOps(opsPerAggregator, beneficiary)](#IEntryPoint-handleAggregatedOps-struct-IEntryPoint-UserOpsPerAggregator---address-payable-)
-IERC7579Module +IEntryPointStake -- [onInstall(data)](#IERC7579Module-onInstall-bytes-) -- [onUninstall(data)](#IERC7579Module-onUninstall-bytes-) -- [isModuleType(moduleTypeId)](#IERC7579Module-isModuleType-uint256-) +- [balanceOf(account)](#IEntryPointStake-balanceOf-address-) +- [depositTo(account)](#IEntryPointStake-depositTo-address-) +- [withdrawTo(withdrawAddress, withdrawAmount)](#IEntryPointStake-withdrawTo-address-payable-uint256-) +- [addStake(unstakeDelaySec)](#IEntryPointStake-addStake-uint32-) +- [unlockStake()](#IEntryPointStake-unlockStake--) +- [withdrawStake(withdrawAddress)](#IEntryPointStake-withdrawStake-address-payable-) + +
+
+IEntryPointNonces + +- [getNonce(sender, key)](#IEntryPointNonces-getNonce-address-uint192-)
- +
+

Errors

+
+- [FailedOp(opIndex, reason)](#IEntryPoint-FailedOp-uint256-string-) +- [FailedOpWithRevert(opIndex, reason, inner)](#IEntryPoint-FailedOpWithRevert-uint256-string-bytes-) +
+
+ +
-

preCheck(address msgSender, uint256 value, bytes msgData) → bytes hookData

+

handleOps(struct PackedUserOperation[] ops, address payable beneficiary)

external

-# +#
-Called by the smart account before execution +Executes a batch of user operations.
- +
-

postCheck(bytes hookData)

+

handleAggregatedOps(struct IEntryPoint.UserOpsPerAggregator[] opsPerAggregator, address payable beneficiary)

external

-# +#
-Called by the smart account after execution +Executes a batch of aggregated user operations per aggregator.
- + + +
+
+

FailedOp(uint256 opIndex, string reason)

+
+

error

+# +
+
+
+ +A user operation at `opIndex` failed with `reason`. + +
+
+ + + +
+
+

FailedOpWithRevert(uint256 opIndex, string reason, bytes inner)

+
+

error

+# +
+
+
+ +A user operation at `opIndex` failed with `reason` and `inner` returned data. + +
+
+ +
-## `Execution` +## `IAccount` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; +``` + +Base interface for an ERC-4337 account. + +
+

Functions

+
+- [validateUserOp(userOp, userOpHash, missingAccountFunds)](#IAccount-validateUserOp-struct-PackedUserOperation-bytes32-uint256-) +
+
+ + + +
+
+

validateUserOp(struct PackedUserOperation userOp, bytes32 userOpHash, uint256 missingAccountFunds) → uint256 validationData

+
+

external

+# +
+
+
+ +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 contract +- `validUntil` (`uint48`): The UserOp is valid only up to this time. Zero for “infinite”. +- `validAfter` (`uint48`): The UserOp is valid only after this time. +
-```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; -``` - - +
-## `IERC7579Execution` +## `IAccountExecute` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; ``` -ERC-7579 Execution. - -Accounts should implement this interface so that the Entrypoint and ERC-7579 modules can execute operations. +Support for executing user operations by prepending the [`IAccountExecute.executeUserOp`](#IAccountExecute-executeUserOp-struct-PackedUserOperation-bytes32-) function selector +to the UserOperation's `callData`.

Functions

-- [execute(mode, executionCalldata)](#IERC7579Execution-execute-bytes32-bytes-) -- [executeFromExecutor(mode, executionCalldata)](#IERC7579Execution-executeFromExecutor-bytes32-bytes-) -
-
- - - -
-
-

execute(bytes32 mode, bytes executionCalldata)

-
-

external

-# -
-
-
- -Executes a transaction on behalf of the account. - +- [executeUserOp(userOp, userOpHash)](#IAccountExecute-executeUserOp-struct-PackedUserOperation-bytes32-)
- +
-

executeFromExecutor(bytes32 mode, bytes executionCalldata) → bytes[] returnData

+

executeUserOp(struct PackedUserOperation userOp, bytes32 userOpHash)

external

-# +#
-Executes a transaction on behalf of the account. - This function is intended to be called by Executor Modules +Executes a user operation.
- +
-## `IERC7579AccountConfig` +## `IPaymaster` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC4337.sol"; ``` -ERC-7579 Account Config. +Interface for a paymaster contract that agrees to pay for the gas costs of a user operation. -Accounts should implement this interface to expose information that identifies the account, supported modules and capabilities. + +A paymaster must hold a stake to cover the required entrypoint stake and also the gas for the transaction. +

Functions

-- [accountId()](#IERC7579AccountConfig-accountId--) -- [supportsExecutionMode(encodedMode)](#IERC7579AccountConfig-supportsExecutionMode-bytes32-) -- [supportsModule(moduleTypeId)](#IERC7579AccountConfig-supportsModule-uint256-) +- [validatePaymasterUserOp(userOp, userOpHash, maxCost)](#IPaymaster-validatePaymasterUserOp-struct-PackedUserOperation-bytes32-uint256-) +- [postOp(mode, context, actualGasCost, actualUserOpFeePerGas)](#IPaymaster-postOp-enum-IPaymaster-PostOpMode-bytes-uint256-uint256-)
- +
-

accountId() → string accountImplementationId

+

validatePaymasterUserOp(struct PackedUserOperation userOp, bytes32 userOpHash, uint256 maxCost) → bytes context, uint256 validationData

external

-# +#
-Returns the account id of the smart account - -
-
- - - -
-
-

supportsExecutionMode(bytes32 encodedMode) → bool

-
-

external

-# -
-
-
+Validates whether the paymaster is willing to pay for the user operation. See +[`IAccount.validateUserOp`](#IAccount-validateUserOp-struct-PackedUserOperation-bytes32-uint256-) for additional information on the return value. -Function to check if the account supports a certain execution mode (see above) + +Bundlers will reject this method if it modifies the state, unless it's whitelisted. +
- +
-

supportsModule(uint256 moduleTypeId) → bool

+

postOp(enum IPaymaster.PostOpMode mode, bytes context, uint256 actualGasCost, uint256 actualUserOpFeePerGas)

external

-# +#
-Function to check if the account supports a certain module typeId +Verifies the sender is the entrypoint.
- +
-## `IERC7579ModuleConfig` +## `IERC20Errors` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC6093.sol"; ``` -ERC-7579 Module Config. - -Accounts should implement this interface to allow installing and uninstalling modules. - -
-

Functions

-
-- [installModule(moduleTypeId, module, initData)](#IERC7579ModuleConfig-installModule-uint256-address-bytes-) -- [uninstallModule(moduleTypeId, module, deInitData)](#IERC7579ModuleConfig-uninstallModule-uint256-address-bytes-) -- [isModuleInstalled(moduleTypeId, module, additionalContext)](#IERC7579ModuleConfig-isModuleInstalled-uint256-address-bytes-) -
-
+Standard ERC-20 Errors +Interface of the [ERC-6093](https://eips.ethereum.org/EIPS/eip-6093) custom errors for ERC-20 tokens.
-

Events

+

Errors

-- [ModuleInstalled(moduleTypeId, module)](#IERC7579ModuleConfig-ModuleInstalled-uint256-address-) -- [ModuleUninstalled(moduleTypeId, module)](#IERC7579ModuleConfig-ModuleUninstalled-uint256-address-) +- [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) +- [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) +- [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) +- [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) +- [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) +- [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-)
- +
-

installModule(uint256 moduleTypeId, address module, bytes initData)

+

ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed)

-

external

-# +

error

+#
-Installs a Module of a certain type on the smart account +Indicates an error related to the current `balance` of a `sender`. Used in transfers.
- +
-

uninstallModule(uint256 moduleTypeId, address module, bytes deInitData)

+

ERC20InvalidSender(address sender)

-

external

-# +

error

+#
-Uninstalls a Module of a certain type on the smart account +Indicates a failure with the token `sender`. Used in transfers.
- +
-

isModuleInstalled(uint256 moduleTypeId, address module, bytes additionalContext) → bool

+

ERC20InvalidReceiver(address receiver)

-

external

-# +

error

+#
-Returns whether a module is installed on the smart account +Indicates a failure with the token `receiver`. Used in transfers.
- +
-

ModuleInstalled(uint256 moduleTypeId, address module)

+

ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed)

-

event

-# +

error

+#
-
+Indicates a failure with the `spender`’s `allowance`. Used in transfers. +
- + +
-

ModuleUninstalled(uint256 moduleTypeId, address module)

+

ERC20InvalidApprover(address approver)

-

event

-# +

error

+#
-
-
-
- - - -
- -## `IERC7674` - - - - - -
- -```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7674.sol"; -``` - -Temporary Approval Extension for ERC-20 ([ERC-7674](https://github.com/ethereum/ERCs/pull/358)) - -
-

Functions

-
-- [temporaryApprove(spender, value)](#IERC7674-temporaryApprove-address-uint256-) -
-IERC20 - -- [totalSupply()](#IERC20-totalSupply--) -- [balanceOf(account)](#IERC20-balanceOf-address-) -- [transfer(to, value)](#IERC20-transfer-address-uint256-) -- [allowance(owner, spender)](#IERC20-allowance-address-address-) -- [approve(spender, value)](#IERC20-approve-address-uint256-) -- [transferFrom(from, to, value)](#IERC20-transferFrom-address-address-uint256-) - -
-
-
- -
-

Events

-
-
-IERC20 - -- [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) -- [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) +Indicates a failure with the `approver` of a token to be approved. Used in approvals. -
- +
-

temporaryApprove(address spender, uint256 value) → bool success

+

ERC20InvalidSpender(address spender)

-

external

-# +

error

+#
-Set the temporary allowance, allowing `spender` to withdraw (within the same transaction) assets -held by the caller. +Indicates a failure with the `spender` to be approved. Used in approvals.
- +
-## `IERC7786GatewaySource` +## `IERC721Errors` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7786.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC6093.sol"; ``` -Interface for ERC-7786 source gateways. - -See ERC-7786 for more details +Standard ERC-721 Errors +Interface of the [ERC-6093](https://eips.ethereum.org/EIPS/eip-6093) custom errors for ERC-721 tokens.
-

Functions

+

Errors

-- [supportsAttribute(selector)](#IERC7786GatewaySource-supportsAttribute-bytes4-) -- [sendMessage(recipient, payload, attributes)](#IERC7786GatewaySource-sendMessage-bytes-bytes-bytes---) +- [ERC721InvalidOwner(owner)](#IERC721Errors-ERC721InvalidOwner-address-) +- [ERC721NonexistentToken(tokenId)](#IERC721Errors-ERC721NonexistentToken-uint256-) +- [ERC721IncorrectOwner(sender, tokenId, owner)](#IERC721Errors-ERC721IncorrectOwner-address-uint256-address-) +- [ERC721InvalidSender(sender)](#IERC721Errors-ERC721InvalidSender-address-) +- [ERC721InvalidReceiver(receiver)](#IERC721Errors-ERC721InvalidReceiver-address-) +- [ERC721InsufficientApproval(operator, tokenId)](#IERC721Errors-ERC721InsufficientApproval-address-uint256-) +- [ERC721InvalidApprover(approver)](#IERC721Errors-ERC721InvalidApprover-address-) +- [ERC721InvalidOperator(operator)](#IERC721Errors-ERC721InvalidOperator-address-)
-
-

Events

-
-- [MessageSent(sendId, sender, recipient, payload, value, attributes)](#IERC7786GatewaySource-MessageSent-bytes32-bytes-bytes-bytes-uint256-bytes---) + + +
+
+

ERC721InvalidOwner(address owner)

+
+

error

+#
+
+ +Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-721. +Used in balance queries. -
-

Errors

-
-- [UnsupportedAttribute(selector)](#IERC7786GatewaySource-UnsupportedAttribute-bytes4-)
- +
-

supportsAttribute(bytes4 selector) → bool

+

ERC721NonexistentToken(uint256 tokenId)

-

external

-# +

error

+#
-Getter to check whether an attribute is supported or not. +Indicates a `tokenId` whose `owner` is the zero address.
- +
-

sendMessage(bytes recipient, bytes payload, bytes[] attributes) → bytes32 sendId

+

ERC721IncorrectOwner(address sender, uint256 tokenId, address owner)

-

external

-# +

error

+#
-Endpoint for creating a new message. If the message requires further (gateway specific) processing before -it can be sent to the destination chain, then a non-zero `sendId` must be returned. Otherwise, the -message MUST be sent and this function must return 0. - -* MUST emit a [`IERC7786GatewaySource.MessageSent`](#IERC7786GatewaySource-MessageSent-bytes32-bytes-bytes-bytes-uint256-bytes---) event. - -If any of the `attributes` is not supported, this function SHOULD revert with an [`IERC7786GatewaySource.UnsupportedAttribute`](#IERC7786GatewaySource-UnsupportedAttribute-bytes4-) error. -Other errors SHOULD revert with errors not specified in ERC-7786. +Indicates an error related to the ownership over a particular token. Used in transfers.
- +
-

MessageSent(bytes32 indexed sendId, bytes sender, bytes recipient, bytes payload, uint256 value, bytes[] attributes)

+

ERC721InvalidSender(address sender)

-

event

-# +

error

+#
-
-Event emitted when a message is created. If `sendId` is zero, no further processing is necessary. If -`sendId` is not zero, then further (gateway specific, and non-standardized) action is required. +Indicates a failure with the token `sender`. Used in transfers.
- +
-

UnsupportedAttribute(bytes4 selector)

+

ERC721InvalidReceiver(address receiver)

error

-# +#
-This error is thrown when a message creation fails because of an unsupported attribute being specified. +Indicates a failure with the token `receiver`. Used in transfers.
- - -
+ -## `IERC7786Recipient` +
+
+

ERC721InsufficientApproval(address operator, uint256 tokenId)

+
+

error

+# +
+
+
- - - +Indicates a failure with the `operator`’s approval. Used in transfers. +
-```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7786.sol"; -``` + -Interface for the ERC-7786 client contract (receiver). +
+
+

ERC721InvalidApprover(address approver)

+
+

error

+# +
+
+
-See ERC-7786 for more details +Indicates a failure with the `approver` of a token to be approved. Used in approvals. -
-

Functions

-
-- [receiveMessage(receiveId, sender, payload)](#IERC7786Recipient-receiveMessage-bytes32-bytes-bytes-)
- +
-

receiveMessage(bytes32 receiveId, bytes sender, bytes payload) → bytes4

+

ERC721InvalidOperator(address operator)

-

external

-# +

error

+#
-Endpoint for receiving cross-chain message. - -This function may be called directly by the gateway. +Indicates a failure with the `operator` to be approved. Used in approvals.
- +
-## `IERC7802` +## `IERC1155Errors` - +
```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7802.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC6093.sol"; ``` -
-

Functions

-
-- [crosschainMint(_to, _amount)](#IERC7802-crosschainMint-address-uint256-) -- [crosschainBurn(_from, _amount)](#IERC7802-crosschainBurn-address-uint256-) -
-IERC165 - -- [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) - -
-
-
+Standard ERC-1155 Errors +Interface of the [ERC-6093](https://eips.ethereum.org/EIPS/eip-6093) custom errors for ERC-1155 tokens.
-

Events

+

Errors

-- [CrosschainMint(to, amount, sender)](#IERC7802-CrosschainMint-address-uint256-address-) -- [CrosschainBurn(from, amount, sender)](#IERC7802-CrosschainBurn-address-uint256-address-) +- [ERC1155InsufficientBalance(sender, balance, needed, tokenId)](#IERC1155Errors-ERC1155InsufficientBalance-address-uint256-uint256-uint256-) +- [ERC1155InvalidSender(sender)](#IERC1155Errors-ERC1155InvalidSender-address-) +- [ERC1155InvalidReceiver(receiver)](#IERC1155Errors-ERC1155InvalidReceiver-address-) +- [ERC1155MissingApprovalForAll(operator, owner)](#IERC1155Errors-ERC1155MissingApprovalForAll-address-address-) +- [ERC1155InvalidApprover(approver)](#IERC1155Errors-ERC1155InvalidApprover-address-) +- [ERC1155InvalidOperator(operator)](#IERC1155Errors-ERC1155InvalidOperator-address-) +- [ERC1155InvalidArrayLength(idsLength, valuesLength)](#IERC1155Errors-ERC1155InvalidArrayLength-uint256-uint256-)
- +
-

crosschainMint(address _to, uint256 _amount)

+

ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId)

-

external

-# +

error

+#
+Indicates an error related to the current `balance` of a `sender`. Used in transfers. +
- +
-

crosschainBurn(address _from, uint256 _amount)

+

ERC1155InvalidSender(address sender)

-

external

-# +

error

+#
+Indicates a failure with the token `sender`. Used in transfers. +
- +
-

CrosschainMint(address indexed to, uint256 amount, address indexed sender)

+

ERC1155InvalidReceiver(address receiver)

-

event

-# +

error

+#
-
+Indicates a failure with the token `receiver`. Used in transfers. +
- + +
-

CrosschainBurn(address indexed from, uint256 amount, address indexed sender)

+

ERC1155MissingApprovalForAll(address operator, address owner)

-

event

-# +

error

+#
-
-
-
- - - -
- -## `IERC7821` - - - - - -
- -```solidity -import "@openzeppelin/contracts/interfaces/draft-IERC7821.sol"; -``` - -Interface for minimal batch executor. +Indicates a failure with the `operator`’s approval. Used in transfers. -
-

Functions

-
-- [execute(mode, executionData)](#IERC7821-execute-bytes32-bytes-) -- [supportsExecutionMode(mode)](#IERC7821-supportsExecutionMode-bytes32-)
- +
-

execute(bytes32 mode, bytes executionData)

+

ERC1155InvalidApprover(address approver)

-

external

-# +

error

+#
-Executes the calls in `executionData`. -Reverts and bubbles up error if any call fails. - -`executionData` encoding: -- If `opData` is empty, `executionData` is simply `abi.encode(calls)`. -- Else, `executionData` is `abi.encode(calls, opData)`. - See: https://eips.ethereum.org/EIPS/eip-7579 - -Supported modes: -- `bytes32(0x01000000000000000000...)`: does not support optional `opData`. -- `bytes32(0x01000000000078210001...)`: supports optional `opData`. +Indicates a failure with the `approver` of a token to be approved. Used in approvals. -Authorization checks: -- If `opData` is empty, the implementation SHOULD require that - `msg.sender == address(this)`. -- If `opData` is not empty, the implementation SHOULD use the signature - encoded in `opData` to determine if the caller can perform the execution. +
+
-`opData` may be used to store additional data for authentication, -paymaster data, gas limits, etc. + -For calldata compression efficiency, if a Call.to is `address(0)`, -it will be replaced with `address(this)`. +
+
+

ERC1155InvalidOperator(address operator)

+
+

error

+# +
+
+
+ +Indicates a failure with the `operator` to be approved. Used in approvals.
- +
-

supportsExecutionMode(bytes32 mode) → bool

+

ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength)

-

external

-# +

error

+#
-This function is provided for frontends to detect support. -Only returns true for: -- `bytes32(0x01000000000000000000...)`: does not support optional `opData`. -- `bytes32(0x01000000000078210001...)`: supports optional `opData`. +Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. +Used in batch transfers.
- +
-## `IERC1363Receiver` +## `VALIDATION_SUCCESS` - +
```solidity -import "@openzeppelin/contracts/interfaces/IERC1363Receiver.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; ``` -Interface for any contract that wants to support `transferAndCall` or `transferFromAndCall` -from ERC-1363 token contracts. + -
-

Functions

-
-- [onTransferReceived(operator, from, value, data)](#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) -
-
+
- +## `VALIDATION_FAILED` + + + + -
-
-

onTransferReceived(address operator, address from, uint256 value, bytes data) → bytes4

-
-

external

-# -
-
-Whenever ERC-1363 tokens are transferred to this contract via `transferAndCall` or `transferFromAndCall` -by `operator` from `from`, this function is called. +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +``` - -To accept the transfer, this must return -`bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))` -(i.e. 0x88a7ca5c, or its own function selector). - + + +
+ +## `MODULE_TYPE_VALIDATOR` + + + + -
- +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +``` + +
-## `IERC1363Spender` +## `MODULE_TYPE_EXECUTOR` - +
```solidity -import "@openzeppelin/contracts/interfaces/IERC1363Spender.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; ``` -Interface for any contract that wants to support `approveAndCall` -from ERC-1363 token contracts. + -
-

Functions

-
-- [onApprovalReceived(owner, value, data)](#IERC1363Spender-onApprovalReceived-address-uint256-bytes-) -
-
+
- +## `MODULE_TYPE_FALLBACK` + + + + -
-
-

onApprovalReceived(address owner, uint256 value, bytes data) → bytes4

-
-

external

-# -
-
-Whenever an ERC-1363 token `owner` approves this contract via `approveAndCall` -to spend their tokens, this function is called. +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +``` - -To accept the approval, this must return -`bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))` -(i.e. 0x7b04a2d0, or its own function selector). - + + +
+ +## `MODULE_TYPE_HOOK` + + + + -
- +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +``` + +
-## `IERC1820Implementer` +## `IERC7579Module` - +
```solidity -import "@openzeppelin/contracts/interfaces/IERC1820Implementer.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; ``` -Interface for an ERC-1820 implementer, as defined in the -[ERC](https://eips.ethereum.org/EIPS/eip-1820#interface-implementation-erc1820implementerinterface). -Used by contracts that will be registered as implementers in the -[`IERC1820Registry`](#IERC1820Registry). +Minimal configuration interface for ERC-7579 modules

Functions

-- [canImplementInterfaceForAddress(interfaceHash, account)](#IERC1820Implementer-canImplementInterfaceForAddress-bytes32-address-) +- [onInstall(data)](#IERC7579Module-onInstall-bytes-) +- [onUninstall(data)](#IERC7579Module-onUninstall-bytes-) +- [isModuleType(moduleTypeId)](#IERC7579Module-isModuleType-uint256-)
- +
-

canImplementInterfaceForAddress(bytes32 interfaceHash, address account) → bytes32

+

onInstall(bytes data)

external

-# +#
-Returns a special value (`ERC1820_ACCEPT_MAGIC`) if this contract -implements `interfaceHash` for `account`. - -See [`IERC1820Registry.setInterfaceImplementer`](#IERC1820Registry-setInterfaceImplementer-address-bytes32-address-). +This function is called by the smart account during installation of the module
- - -
- -## `IERC1820Registry` - - - - - -
- -```solidity -import "@openzeppelin/contracts/interfaces/IERC1820Registry.sol"; -``` - -Interface of the global ERC-1820 Registry, as defined in the -[ERC](https://eips.ethereum.org/EIPS/eip-1820). 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`](/contracts/5.x/api/utils#IERC165) interfaces can also be queried via the registry. - -For an in-depth explanation and source code analysis, see the ERC text. + -
-

Functions

-
-- [setManager(account, newManager)](#IERC1820Registry-setManager-address-address-) -- [getManager(account)](#IERC1820Registry-getManager-address-) -- [setInterfaceImplementer(account, _interfaceHash, implementer)](#IERC1820Registry-setInterfaceImplementer-address-bytes32-address-) -- [getInterfaceImplementer(account, _interfaceHash)](#IERC1820Registry-getInterfaceImplementer-address-bytes32-) -- [interfaceHash(interfaceName)](#IERC1820Registry-interfaceHash-string-) -- [updateERC165Cache(account, interfaceId)](#IERC1820Registry-updateERC165Cache-address-bytes4-) -- [implementsERC165Interface(account, interfaceId)](#IERC1820Registry-implementsERC165Interface-address-bytes4-) -- [implementsERC165InterfaceNoCache(account, interfaceId)](#IERC1820Registry-implementsERC165InterfaceNoCache-address-bytes4-) +
+
+

onUninstall(bytes data)

+
+

external

+#
+
+ +This function is called by the smart account during uninstallation of the module -
-

Events

-
-- [InterfaceImplementerSet(account, interfaceHash, implementer)](#IERC1820Registry-InterfaceImplementerSet-address-bytes32-address-) -- [ManagerChanged(account, newManager)](#IERC1820Registry-ManagerChanged-address-address-)
- +
-

setManager(address account, address newManager)

+

isModuleType(uint256 moduleTypeId) → bool

external

-# +# +
+
+
+ +Returns boolean value if module is a certain type + +
+ + + +
+ +## `IERC7579Validator` + + + + +
-
-Sets `newManager` as the manager for `account`. A manager of an -account is able to set interface implementers for it. +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +``` -By default, each account is its own manager. Passing a value of `0x0` in -`newManager` will reset the manager to this initial state. +ERC-7579 Validation module (type 1). -Emits a [`IERC1820Registry.ManagerChanged`](#IERC1820Registry-ManagerChanged-address-address-) event. +A module that implements logic to validate user operations and signatures. -Requirements: +
+

Functions

+
+- [validateUserOp(userOp, userOpHash)](#IERC7579Validator-validateUserOp-struct-PackedUserOperation-bytes32-) +- [isValidSignatureWithSender(sender, hash, signature)](#IERC7579Validator-isValidSignatureWithSender-address-bytes32-bytes-) +
+IERC7579Module -- the caller must be the current manager for `account`. +- [onInstall(data)](#IERC7579Module-onInstall-bytes-) +- [onUninstall(data)](#IERC7579Module-onUninstall-bytes-) +- [isModuleType(moduleTypeId)](#IERC7579Module-isModuleType-uint256-) +
- +
-

getManager(address account) → address

+

validateUserOp(struct PackedUserOperation userOp, bytes32 userOpHash) → uint256

external

-# +#
-Returns the manager for `account`. - -See [`IERC1820Registry.setManager`](#IERC1820Registry-setManager-address-address-). +Validates a UserOperation
- +
-

setInterfaceImplementer(address account, bytes32 _interfaceHash, address implementer)

+

isValidSignatureWithSender(address sender, bytes32 hash, bytes signature) → bytes4

external

-# +#
-Sets the `implementer` contract as ``account``'s implementer for -`interfaceHash`. +Validates a signature using ERC-1271 -`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 [`IERC1820Registry.interfaceHash`](#IERC1820Registry-interfaceHash-string-) to learn how these are created. + -Emits an [`IERC1820Registry.InterfaceImplementerSet`](#IERC1820Registry-InterfaceImplementerSet-address-bytes32-address-) event. +
-Requirements: +## `IERC7579Hook` -- the caller must be the current manager for `account`. -- `interfaceHash` must not be an [`IERC165`](/contracts/5.x/api/utils#IERC165) interface id (i.e. it must not -end in 28 zeroes). -- `implementer` must implement [`IERC1820Implementer`](#IERC1820Implementer) and return true when -queried for support, unless `implementer` is the caller. See -[`IERC1820Implementer.canImplementInterfaceForAddress`](#IERC1820Implementer-canImplementInterfaceForAddress-bytes32-address-). + + + -
- +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +``` -
-
-

getInterfaceImplementer(address account, bytes32 _interfaceHash) → address

-
-

external

-# -
-
-
+ERC-7579 Hooks module (type 4). -Returns the implementer of `interfaceHash` for `account`. If no such -implementer is registered, returns the zero address. +A module that implements logic to execute before and after the account executes a user operation, +either individually or batched. -If `interfaceHash` is an [`IERC165`](/contracts/5.x/api/utils#IERC165) interface id (i.e. it ends with 28 -zeroes), `account` will be queried for support of it. +
+

Functions

+
+- [preCheck(msgSender, value, msgData)](#IERC7579Hook-preCheck-address-uint256-bytes-) +- [postCheck(hookData)](#IERC7579Hook-postCheck-bytes-) +
+IERC7579Module -`account` being the zero address is an alias for the caller's address. +- [onInstall(data)](#IERC7579Module-onInstall-bytes-) +- [onUninstall(data)](#IERC7579Module-onUninstall-bytes-) +- [isModuleType(moduleTypeId)](#IERC7579Module-isModuleType-uint256-) +
- +
-

interfaceHash(string interfaceName) → bytes32

+

preCheck(address msgSender, uint256 value, bytes msgData) → bytes hookData

external

-# +#
-Returns the interface hash for an `interfaceName`, as defined in the -corresponding -[section of the ERC](https://eips.ethereum.org/EIPS/eip-1820#interface-name). +Called by the smart account before execution
- +
-

updateERC165Cache(address account, bytes4 interfaceId)

+

postCheck(bytes hookData)

external

-# +#
+Called by the smart account after execution +
- + -
-
-

implementsERC165Interface(address account, bytes4 interfaceId) → bool

-
-

external

-# -
-
-
+
-
-
+## `Execution` - + + + -
-
-

implementsERC165InterfaceNoCache(address account, bytes4 interfaceId) → bool

-
-

external

-#
+ +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +``` + + + +
+ +## `IERC7579Execution` + + + + +
-
+```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; +``` + +ERC-7579 Execution. + +Accounts should implement this interface so that the Entrypoint and ERC-7579 modules can execute operations. + +
+

Functions

+
+- [execute(mode, executionCalldata)](#IERC7579Execution-execute-bytes32-bytes-) +- [executeFromExecutor(mode, executionCalldata)](#IERC7579Execution-executeFromExecutor-bytes32-bytes-)
- +
-

InterfaceImplementerSet(address indexed account, bytes32 indexed interfaceHash, address indexed implementer)

+

execute(bytes32 mode, bytes executionCalldata)

-

event

-# +

external

+#
-
+Executes a transaction on behalf of the account. +
- + +
-

ManagerChanged(address indexed account, address indexed newManager)

+

executeFromExecutor(bytes32 mode, bytes executionCalldata) → bytes[] returnData

-

event

-# +

external

+#
-
+Executes a transaction on behalf of the account. + This function is intended to be called by Executor Modules +
- +
-## `IERC2612` +## `IERC7579AccountConfig` - +
```solidity -import "@openzeppelin/contracts/interfaces/IERC2612.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; ``` +ERC-7579 Account Config. + +Accounts should implement this interface to expose information that identifies the account, supported modules and capabilities. +

Functions

-
-IERC20Permit - -- [permit(owner, spender, value, deadline, v, r, s)](#IERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) -- [nonces(owner)](#IERC20Permit-nonces-address-) -- [DOMAIN_SEPARATOR()](#IERC20Permit-DOMAIN_SEPARATOR--) - -
+- [accountId()](#IERC7579AccountConfig-accountId--) +- [supportsExecutionMode(encodedMode)](#IERC7579AccountConfig-supportsExecutionMode-bytes32-) +- [supportsModule(moduleTypeId)](#IERC7579AccountConfig-supportsModule-uint256-)
- - -
+ -## `IERC7751` +
+
+

accountId() → string accountImplementationId

+
+

external

+# +
+
+
- - - +Returns the account id of the smart account +
-```solidity -import "@openzeppelin/contracts/interfaces/IERC7751.sol"; -``` + -Wrapping of bubbled up reverts -Interface of the [ERC-7751](https://eips.ethereum.org/EIPS/eip-7751) wrapping of bubbled up reverts. +
+
+

supportsExecutionMode(bytes32 encodedMode) → bool

+
+

external

+# +
+
+
+ +Function to check if the account supports a certain execution mode (see above) -
-

Errors

-
-- [WrappedError(target, selector, reason, details)](#IERC7751-WrappedError-address-bytes4-bytes-bytes-)
- +
-

WrappedError(address target, bytes4 selector, bytes reason, bytes details)

+

supportsModule(uint256 moduleTypeId) → bool

-

error

-# +

external

+#
+Function to check if the account supports a certain module typeId +
- +
-## `IERC777` +## `IERC7579ModuleConfig` - +
```solidity -import "@openzeppelin/contracts/interfaces/IERC777.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; ``` -Interface of the ERC-777 Token standard as defined in the ERC. +ERC-7579 Module Config. -This contract uses the -[ERC-1820 registry standard](https://eips.ethereum.org/EIPS/eip-1820) to let -token holders and recipients react to token movements by using setting implementers -for the associated interfaces in said registry. See [`IERC1820Registry`](#IERC1820Registry) and -[`IERC1820Implementer`](#IERC1820Implementer). +Accounts should implement this interface to allow installing and uninstalling modules.

Functions

-- [name()](#IERC777-name--) -- [symbol()](#IERC777-symbol--) -- [granularity()](#IERC777-granularity--) -- [totalSupply()](#IERC777-totalSupply--) -- [balanceOf(owner)](#IERC777-balanceOf-address-) -- [send(recipient, amount, data)](#IERC777-send-address-uint256-bytes-) -- [burn(amount, data)](#IERC777-burn-uint256-bytes-) -- [isOperatorFor(operator, tokenHolder)](#IERC777-isOperatorFor-address-address-) -- [authorizeOperator(operator)](#IERC777-authorizeOperator-address-) -- [revokeOperator(operator)](#IERC777-revokeOperator-address-) -- [defaultOperators()](#IERC777-defaultOperators--) -- [operatorSend(sender, recipient, amount, data, operatorData)](#IERC777-operatorSend-address-address-uint256-bytes-bytes-) -- [operatorBurn(account, amount, data, operatorData)](#IERC777-operatorBurn-address-uint256-bytes-bytes-) +- [installModule(moduleTypeId, module, initData)](#IERC7579ModuleConfig-installModule-uint256-address-bytes-) +- [uninstallModule(moduleTypeId, module, deInitData)](#IERC7579ModuleConfig-uninstallModule-uint256-address-bytes-) +- [isModuleInstalled(moduleTypeId, module, additionalContext)](#IERC7579ModuleConfig-isModuleInstalled-uint256-address-bytes-)

Events

-- [Minted(operator, to, amount, data, operatorData)](#IERC777-Minted-address-address-uint256-bytes-bytes-) -- [Burned(operator, from, amount, data, operatorData)](#IERC777-Burned-address-address-uint256-bytes-bytes-) -- [AuthorizedOperator(operator, tokenHolder)](#IERC777-AuthorizedOperator-address-address-) -- [RevokedOperator(operator, tokenHolder)](#IERC777-RevokedOperator-address-address-) -- [Sent(operator, from, to, amount, data, operatorData)](#IERC777-Sent-address-address-address-uint256-bytes-bytes-) +- [ModuleInstalled(moduleTypeId, module)](#IERC7579ModuleConfig-ModuleInstalled-uint256-address-) +- [ModuleUninstalled(moduleTypeId, module)](#IERC7579ModuleConfig-ModuleUninstalled-uint256-address-)
- +
-

name() → string

+

installModule(uint256 moduleTypeId, address module, bytes initData)

external

-# +#
-Returns the name of the token. +Installs a Module of a certain type on the smart account
- +
-

symbol() → string

+

uninstallModule(uint256 moduleTypeId, address module, bytes deInitData)

external

-# +#
-Returns the symbol of the token, usually a shorter version of the -name. +Uninstalls a Module of a certain type on the smart account
- +
-

granularity() → uint256

+

isModuleInstalled(uint256 moduleTypeId, address module, bytes additionalContext) → bool

external

-# +#
-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. +Returns whether a module is installed on the smart account
- +
-

totalSupply() → uint256

+

ModuleInstalled(uint256 moduleTypeId, address module)

-

external

-# +

event

+#
-
-Returns the amount of tokens in existence. +
- - +
-

balanceOf(address owner) → uint256

+

ModuleUninstalled(uint256 moduleTypeId, address module)

-

external

-# +

event

+#
-
-Returns the amount of tokens owned by an account (`owner`). +
- + + +
+ +## `IERC7674` + + + + -
-
-

send(address recipient, uint256 amount, bytes data)

-
-

external

-# -
-
-Moves `amount` tokens from the caller's account to `recipient`. +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC7674.sol"; +``` -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`](#IERC777Sender) and [`IERC777Recipient`](#IERC777Recipient). +Temporary Approval Extension for ERC-20 ([ERC-7674](https://github.com/ethereum/ERCs/pull/358)) -Emits a [`IERC777.Sent`](#IERC777-Sent-address-address-address-uint256-bytes-bytes-) event. +
+

Functions

+
+- [temporaryApprove(spender, value)](#IERC7674-temporaryApprove-address-uint256-) +
+IERC20 -Requirements +- [totalSupply()](#IERC20-totalSupply--) +- [balanceOf(account)](#IERC20-balanceOf-address-) +- [transfer(to, value)](#IERC20-transfer-address-uint256-) +- [allowance(owner, spender)](#IERC20-allowance-address-address-) +- [approve(spender, value)](#IERC20-approve-address-uint256-) +- [transferFrom(from, to, value)](#IERC20-transferFrom-address-address-uint256-) -- the caller must have at least `amount` tokens. -- `recipient` cannot be the zero address. -- if `recipient` is a contract, it must implement the [`IERC777Recipient`](#IERC777Recipient) -interface. +
+
+
+ +
+

Events

+
+
+IERC20 + +- [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) +- [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) +
- +
-

burn(uint256 amount, bytes data)

+

temporaryApprove(address spender, uint256 value) → bool success

external

-# +#
-Destroys `amount` tokens from the caller's account, reducing the -total supply. +Set the temporary allowance, allowing `spender` to withdraw (within the same transaction) assets +held by the caller. -If a send hook is registered for the caller, the corresponding function -will be called with `data` and empty `operatorData`. See [`IERC777Sender`](#IERC777Sender). +
+
-Emits a [`IERC777.Burned`](#IERC777-Burned-address-address-uint256-bytes-bytes-) event. + -Requirements +
-- the caller must have at least `amount` tokens. +## `IERC7786GatewaySource` + + + + -
- +```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC7786.sol"; +``` -
-
-

isOperatorFor(address operator, address tokenHolder) → bool

-
-

external

-# +Interface for ERC-7786 source gateways. + +See ERC-7786 for more details + +
+

Functions

+
+- [supportsAttribute(selector)](#IERC7786GatewaySource-supportsAttribute-bytes4-) +- [sendMessage(recipient, payload, attributes)](#IERC7786GatewaySource-sendMessage-bytes-bytes-bytes---)
-
- -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 [`IERC777.operatorSend`](#IERC777-operatorSend-address-address-uint256-bytes-bytes-) and [`IERC777.operatorBurn`](#IERC777-operatorBurn-address-uint256-bytes-bytes-). +
+

Events

+
+- [MessageSent(sendId, sender, recipient, payload, value, attributes)](#IERC7786GatewaySource-MessageSent-bytes32-bytes-bytes-bytes-uint256-bytes---) +
+
+
+

Errors

+
+- [UnsupportedAttribute(selector)](#IERC7786GatewaySource-UnsupportedAttribute-bytes4-)
- +
-

authorizeOperator(address operator)

+

supportsAttribute(bytes4 selector) → bool

external

-# +#
-Make an account an operator of the caller. - -See [`IERC777.isOperatorFor`](#IERC777-isOperatorFor-address-address-). - -Emits an [`IERC777.AuthorizedOperator`](#IERC777-AuthorizedOperator-address-address-) event. - -Requirements - -- `operator` cannot be calling address. +Getter to check whether an attribute is supported or not.
- +
-

revokeOperator(address operator)

+

sendMessage(bytes recipient, bytes payload, bytes[] attributes) → bytes32 sendId

external

-# +#
-Revoke an account's operator status for the caller. - -See [`IERC777.isOperatorFor`](#IERC777-isOperatorFor-address-address-) and [`IERC777.defaultOperators`](#IERC777-defaultOperators--). - -Emits a [`IERC777.RevokedOperator`](#IERC777-RevokedOperator-address-address-) event. +Endpoint for creating a new message. If the message requires further (gateway specific) processing before +it can be sent to the destination chain, then a non-zero `sendId` must be returned. Otherwise, the +message MUST be sent and this function must return 0. -Requirements +* MUST emit a [`IERC7786GatewaySource.MessageSent`](#IERC7786GatewaySource-MessageSent-bytes32-bytes-bytes-bytes-uint256-bytes---) event. -- `operator` cannot be calling address. +If any of the `attributes` is not supported, this function SHOULD revert with an [`IERC7786GatewaySource.UnsupportedAttribute`](#IERC7786GatewaySource-UnsupportedAttribute-bytes4-) error. +Other errors SHOULD revert with errors not specified in ERC-7786.
- +
-

defaultOperators() → address[]

+

MessageSent(bytes32 indexed sendId, bytes sender, bytes recipient, bytes payload, uint256 value, bytes[] attributes)

-

external

-# +

event

+#
-
-Returns the list of default operators. These accounts are operators -for all token holders, even if [`IERC777.authorizeOperator`](#IERC777-authorizeOperator-address-) was never called on -them. +
-This list is immutable, but individual holders may revoke these via -[`IERC777.revokeOperator`](#IERC777-revokeOperator-address-), in which case [`IERC777.isOperatorFor`](#IERC777-isOperatorFor-address-address-) will return false. +Event emitted when a message is created. If `sendId` is zero, no further processing is necessary. If +`sendId` is not zero, then further (gateway specific, and non-standardized) action is required.
- +
-

operatorSend(address sender, address recipient, uint256 amount, bytes data, bytes operatorData)

+

UnsupportedAttribute(bytes4 selector)

-

external

-# +

error

+#
-Moves `amount` tokens from `sender` to `recipient`. The caller must -be an operator of `sender`. +This error is thrown when a message creation fails because of an unsupported attribute being specified. -If send or receive hooks are registered for `sender` and `recipient`, -the corresponding functions will be called with `data` and -`operatorData`. See [`IERC777Sender`](#IERC777Sender) and [`IERC777Recipient`](#IERC777Recipient). +
+
-Emits a [`IERC777.Sent`](#IERC777-Sent-address-address-address-uint256-bytes-bytes-) event. + -Requirements +
-- `sender` cannot be the zero address. -- `sender` must have at least `amount` tokens. -- the caller must be an operator for `sender`. -- `recipient` cannot be the zero address. -- if `recipient` is a contract, it must implement the [`IERC777Recipient`](#IERC777Recipient) -interface. +## `IERC7786Recipient` + + + + + +
+```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC7786.sol"; +``` + +Interface for the ERC-7786 client contract (receiver). + +See ERC-7786 for more details + +
+

Functions

+
+- [receiveMessage(receiveId, sender, payload)](#IERC7786Recipient-receiveMessage-bytes32-bytes-bytes-)
- +
-

operatorBurn(address account, uint256 amount, bytes data, bytes operatorData)

+

receiveMessage(bytes32 receiveId, bytes sender, bytes payload) → bytes4

external

-# +#
-Destroys `amount` tokens from `account`, reducing the total supply. -The caller must be an operator of `account`. +Endpoint for receiving cross-chain message. -If a send hook is registered for `account`, the corresponding function -will be called with `data` and `operatorData`. See [`IERC777Sender`](#IERC777Sender). +This function may be called directly by the gateway. -Emits a [`IERC777.Burned`](#IERC777-Burned-address-address-uint256-bytes-bytes-) event. +
+
-Requirements + -- `account` cannot be the zero address. -- `account` must have at least `amount` tokens. -- the caller must be an operator for `account`. +
-
-
+## `IERC7802` - + + + -
-
-

Minted(address indexed operator, address indexed to, uint256 amount, bytes data, bytes operatorData)

-
-

event

-# -
-
+```solidity +import "@openzeppelin/contracts/interfaces/draft-IERC7802.sol"; +``` -Emitted when `amount` tokens are created by `operator` and assigned to `to`. +
+

Functions

+
+- [crosschainMint(_to, _amount)](#IERC7802-crosschainMint-address-uint256-) +- [crosschainBurn(_from, _amount)](#IERC7802-crosschainBurn-address-uint256-) +
+IERC165 -Note that some additional user `data` and `operatorData` can be logged in the event. +- [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) +
- + +
+

Events

+
+- [CrosschainMint(to, amount, sender)](#IERC7802-CrosschainMint-address-uint256-address-) +- [CrosschainBurn(from, amount, sender)](#IERC7802-CrosschainBurn-address-uint256-address-) +
+
+ +
-

Burned(address indexed operator, address indexed from, uint256 amount, bytes data, bytes operatorData)

+

crosschainMint(address _to, uint256 _amount)

-

event

-# +

external

+#
-
-Emitted when `operator` destroys `amount` tokens from `account`. - -Note that some additional user `data` and `operatorData` can be logged in the event. -
- + +
-

AuthorizedOperator(address indexed operator, address indexed tokenHolder)

+

crosschainBurn(address _from, uint256 _amount)

-

event

-# +

external

+#
-
-Emitted when `operator` is made operator for `tokenHolder`. -
- + +
-

RevokedOperator(address indexed operator, address indexed tokenHolder)

+

CrosschainMint(address indexed to, uint256 amount, address indexed sender)

event

-# +#
-Emitted when `operator` is revoked its operator status for `tokenHolder`. -
- +
-

Sent(address indexed operator, address indexed from, address indexed to, uint256 amount, bytes data, bytes operatorData)

+

CrosschainBurn(address indexed from, uint256 amount, address indexed sender)

event

-# +#
@@ -5094,114 +5121,87 @@ Emitted when `operator` is revoked its operator status for `tokenHolder`.
- +
-## `IERC777Recipient` +## `IERC7821` - +
```solidity -import "@openzeppelin/contracts/interfaces/IERC777Recipient.sol"; +import "@openzeppelin/contracts/interfaces/draft-IERC7821.sol"; ``` -Interface of the ERC-777 Tokens Recipient standard as defined in the ERC. - -Accounts can be notified of [`IERC777`](#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 -[ERC-1820 global registry](https://eips.ethereum.org/EIPS/eip-1820). - -See [`IERC1820Registry`](#IERC1820Registry) and [`IERC1820Implementer`](#IERC1820Implementer). +Interface for minimal batch executor.

Functions

-- [tokensReceived(operator, from, to, amount, userData, operatorData)](#IERC777Recipient-tokensReceived-address-address-address-uint256-bytes-bytes-) +- [execute(mode, executionData)](#IERC7821-execute-bytes32-bytes-) +- [supportsExecutionMode(mode)](#IERC7821-supportsExecutionMode-bytes32-)
- +
-

tokensReceived(address operator, address from, address to, uint256 amount, bytes userData, bytes operatorData)

+

execute(bytes32 mode, bytes executionData)

external

-# +#
-Called by an [`IERC777`](#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`](#IERC777-balanceOf-address-), etc., can be used to query the post-operation state. - -This function may revert to prevent the operation from being executed. - -
-
- - - -
- -## `IERC777Sender` - - - - +Executes the calls in `executionData`. +Reverts and bubbles up error if any call fails. -
+`executionData` encoding: +- If `opData` is empty, `executionData` is simply `abi.encode(calls)`. +- Else, `executionData` is `abi.encode(calls, opData)`. + See: https://eips.ethereum.org/EIPS/eip-7579 -```solidity -import "@openzeppelin/contracts/interfaces/IERC777Sender.sol"; -``` +Supported modes: +- `bytes32(0x01000000000000000000...)`: does not support optional `opData`. +- `bytes32(0x01000000000078210001...)`: supports optional `opData`. -Interface of the ERC-777 Tokens Sender standard as defined in the ERC. +Authorization checks: +- If `opData` is empty, the implementation SHOULD require that + `msg.sender == address(this)`. +- If `opData` is not empty, the implementation SHOULD use the signature + encoded in `opData` to determine if the caller can perform the execution. -[`IERC777`](#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 -[ERC-1820 global registry](https://eips.ethereum.org/EIPS/eip-1820). +`opData` may be used to store additional data for authentication, +paymaster data, gas limits, etc. -See [`IERC1820Registry`](#IERC1820Registry) and [`IERC1820Implementer`](#IERC1820Implementer). +For calldata compression efficiency, if a Call.to is `address(0)`, +it will be replaced with `address(this)`. -
-

Functions

-
-- [tokensToSend(operator, from, to, amount, userData, operatorData)](#IERC777Sender-tokensToSend-address-address-address-uint256-bytes-bytes-)
- +
-

tokensToSend(address operator, address from, address to, uint256 amount, bytes userData, bytes operatorData)

+

supportsExecutionMode(bytes32 mode) → bool

external

-# +#
-Called by an [`IERC777`](#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`](#IERC777-balanceOf-address-), etc., can be used to query the pre-operation state. - -This function may revert to prevent the operation from being executed. +This function is provided for frontends to detect support. +Only returns true for: +- `bytes32(0x01000000000000000000...)`: does not support optional `opData`. +- `bytes32(0x01000000000078210001...)`: supports optional `opData`.
diff --git a/content/contracts/5.x/api/proxy.mdx b/content/contracts/5.x/api/proxy.mdx index 7e79550b..8f7d0d77 100644 --- a/content/contracts/5.x/api/proxy.mdx +++ b/content/contracts/5.x/api/proxy.mdx @@ -1100,6 +1100,166 @@ Must return an address that can be used as a delegate call target.
+ + +
+ +## `UpgradeableBeacon` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; +``` + +This contract is used in conjunction with one or more instances of [`BeaconProxy`](#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. + +
+

Functions

+
+- [constructor(implementation_, initialOwner)](#UpgradeableBeacon-constructor-address-address-) +- [implementation()](#UpgradeableBeacon-implementation--) +- [upgradeTo(newImplementation)](#UpgradeableBeacon-upgradeTo-address-) +
+Ownable + +- [owner()](#Ownable-owner--) +- [_checkOwner()](#Ownable-_checkOwner--) +- [renounceOwnership()](#Ownable-renounceOwnership--) +- [transferOwnership(newOwner)](#Ownable-transferOwnership-address-) +- [_transferOwnership(newOwner)](#Ownable-_transferOwnership-address-) + +
+
+
+ +
+

Events

+
+- [Upgraded(implementation)](#UpgradeableBeacon-Upgraded-address-) +
+Ownable + +- [OwnershipTransferred(previousOwner, newOwner)](#Ownable-OwnershipTransferred-address-address-) + +
+
+
+ +
+

Errors

+
+- [BeaconInvalidImplementation(implementation)](#UpgradeableBeacon-BeaconInvalidImplementation-address-) +
+Ownable + +- [OwnableUnauthorizedAccount(account)](#Ownable-OwnableUnauthorizedAccount-address-) +- [OwnableInvalidOwner(owner)](#Ownable-OwnableInvalidOwner-address-) + +
+
+
+ + + +
+
+

constructor(address implementation_, address initialOwner)

+
+

public

+# +
+
+
+ +Sets the address of the initial implementation, and the initial owner who can upgrade the beacon. + +
+
+ + + +
+
+

implementation() → address

+
+

public

+# +
+
+
+ +Returns the current implementation address. + +
+
+ + + +
+
+

upgradeTo(address newImplementation)

+
+

public

+# +
+
+
+ +Upgrades the beacon to a new implementation. + +Emits an [`UpgradeableBeacon.Upgraded`](#UpgradeableBeacon-Upgraded-address-) event. + +Requirements: + +- msg.sender must be the owner of the contract. +- `newImplementation` must be a contract. + +
+
+ + + +
+
+

Upgraded(address indexed implementation)

+
+

event

+# +
+
+ +
+ +Emitted when the implementation returned by the beacon is changed. + +
+
+ + + +
+
+

BeaconInvalidImplementation(address implementation)

+
+

error

+# +
+
+
+ +The `implementation` of the beacon is invalid. + +
+
+
@@ -1453,747 +1613,587 @@ The proxy caller is the current admin, and can't fallback to the proxy target.
- +
-## `UUPSUpgradeable` +## `Initializable` - +
```solidity -import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol"; +import "@openzeppelin/contracts/proxy/utils/Initializable.sol"; ``` -An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an -[`ERC1967Proxy`](#ERC1967Proxy), when this contract is set as the implementation behind such a proxy. +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 [`Initializable.initializer`](#Initializable-initializer--) modifier provided by this contract will have this effect. -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 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. -The [`UUPSUpgradeable._authorizeUpgrade`](#UUPSUpgradeable-_authorizeUpgrade-address-) function must be overridden to include access restriction to the upgrade mechanism. +For example: -@custom:stateless +[.hljs-theme-light.nopadding] +```solidity +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"); + } +} +``` + + +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`](#ERC1967Proxy-constructor-address-bytes-). + + + +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 [`Initializable._disableInitializers`](#Initializable-_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(); +} +```

Modifiers

-- [onlyProxy()](#UUPSUpgradeable-onlyProxy--) -- [notDelegated()](#UUPSUpgradeable-notDelegated--) +- [initializer()](#Initializable-initializer--) +- [reinitializer(version)](#Initializable-reinitializer-uint64-) +- [onlyInitializing()](#Initializable-onlyInitializing--)

Functions

-- [proxiableUUID()](#UUPSUpgradeable-proxiableUUID--) -- [upgradeToAndCall(newImplementation, data)](#UUPSUpgradeable-upgradeToAndCall-address-bytes-) -- [_checkProxy()](#UUPSUpgradeable-_checkProxy--) -- [_checkNotDelegated()](#UUPSUpgradeable-_checkNotDelegated--) -- [_authorizeUpgrade(newImplementation)](#UUPSUpgradeable-_authorizeUpgrade-address-) -- [UPGRADE_INTERFACE_VERSION()](#UUPSUpgradeable-UPGRADE_INTERFACE_VERSION-string) +- [_checkInitializing()](#Initializable-_checkInitializing--) +- [_disableInitializers()](#Initializable-_disableInitializers--) +- [_getInitializedVersion()](#Initializable-_getInitializedVersion--) +- [_isInitializing()](#Initializable-_isInitializing--) +- [_initializableStorageSlot()](#Initializable-_initializableStorageSlot--) +
+
+ +
+

Events

+
+- [Initialized(version)](#Initializable-Initialized-uint64-)

Errors

-- [UUPSUnauthorizedCallContext()](#UUPSUpgradeable-UUPSUnauthorizedCallContext--) -- [UUPSUnsupportedProxiableUUID(slot)](#UUPSUpgradeable-UUPSUnsupportedProxiableUUID-bytes32-) +- [InvalidInitialization()](#Initializable-InvalidInitialization--) +- [NotInitializing()](#Initializable-NotInitializing--)
- +
-

onlyProxy()

+

initializer()

internal

-# +#
-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. +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 [`Initializable.Initialized`](#Initializable-Initialized-uint64-) event.
- +
-

notDelegated()

+

reinitializer(uint64 version)

internal

-# +#
-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. +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. + + +Setting the version to 2**64 - 1 will prevent any future reinitialization. + + +Emits an [`Initializable.Initialized`](#Initializable-Initialized-uint64-) event.
- +
-

proxiableUUID() → bytes32

+

onlyInitializing()

-

external

-# +

internal

+#
-
-Implementation of the ERC-1822 [`UUPSUpgradeable.proxiableUUID`](#UUPSUpgradeable-proxiableUUID--) function. This returns the storage slot used by the -implementation. It is used to validate the implementation's compatibility when performing an upgrade. +
- -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. - +Modifier to protect an initialization function so that it can only be invoked by functions with the +[`Initializable.initializer`](#Initializable-initializer--) and [`Initializable.reinitializer`](#Initializable-reinitializer-uint64-) modifiers, directly or indirectly.
- +
-

upgradeToAndCall(address newImplementation, bytes data)

+

_checkInitializing()

-

public

-# +

internal

+#
-Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call -encoded in `data`. +Reverts if the contract is not in an initializing state. See [`Initializable.onlyInitializing`](#Initializable-onlyInitializing--). -Calls [`UUPSUpgradeable._authorizeUpgrade`](#UUPSUpgradeable-_authorizeUpgrade-address-). +
+
-Emits an [`UpgradeableBeacon.Upgraded`](#UpgradeableBeacon-Upgraded-address-) event. + + +
+
+

_disableInitializers()

+
+

internal

+# +
+
+
+ +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 [`Initializable.Initialized`](#Initializable-Initialized-uint64-) event the first time it is successfully executed.
- +
-

_checkProxy()

+

_getInitializedVersion() → uint64

internal

-# +#
-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. +Returns the highest version that has been initialized. See [`Initializable.reinitializer`](#Initializable-reinitializer-uint64-).
- +
-

_checkNotDelegated()

+

_isInitializing() → bool

internal

-# +#
-Reverts if the execution is performed via delegatecall. -See [`UUPSUpgradeable.notDelegated`](#UUPSUpgradeable-notDelegated--). +Returns `true` if the contract is currently initializing. See [`Initializable.onlyInitializing`](#Initializable-onlyInitializing--).
- +
-

_authorizeUpgrade(address newImplementation)

+

_initializableStorageSlot() → bytes32

internal

-# +#
-Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by -[`ERC1967Utils.upgradeToAndCall`](#ERC1967Utils-upgradeToAndCall-address-bytes-). - -Normally, this function will use an [access control](/contracts/5.x/api/access) modifier such as [`Ownable.onlyOwner`](/contracts/5.x/api/access#Ownable-onlyOwner--). +Pointer to storage slot. Allows integrators to override it with a custom storage location. -```solidity -function _authorizeUpgrade(address) internal onlyOwner {} -``` + +Consider following the ERC-7201 formula to derive storage locations. +
- +
-

UPGRADE_INTERFACE_VERSION() → string

+

Initialized(uint64 version)

-

public

-# +

event

+#
+
-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. +Triggered when the contract has been initialized or reinitialized.
- +
-

UUPSUnauthorizedCallContext()

+

InvalidInitialization()

error

-# +#
-The call is from an unauthorized context. +The contract is already initialized.
- +
-

UUPSUnsupportedProxiableUUID(bytes32 slot)

+

NotInitializing()

error

-# +#
-The storage `slot` is unsupported as a UUID. +The contract is not initializing.
- +
-## `UpgradeableBeacon` +## `UUPSUpgradeable` - +
```solidity -import "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; +import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol"; ``` -This contract is used in conjunction with one or more instances of [`BeaconProxy`](#BeaconProxy) to determine their -implementation contract, which is where they will delegate all function calls. +An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an +[`ERC1967Proxy`](#ERC1967Proxy), when this contract is set as the implementation behind such a proxy. -An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon. +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. -
-

Functions

-
-- [constructor(implementation_, initialOwner)](#UpgradeableBeacon-constructor-address-address-) -- [implementation()](#UpgradeableBeacon-implementation--) -- [upgradeTo(newImplementation)](#UpgradeableBeacon-upgradeTo-address-) -
-Ownable +The [`UUPSUpgradeable._authorizeUpgrade`](#UUPSUpgradeable-_authorizeUpgrade-address-) function must be overridden to include access restriction to the upgrade mechanism. -- [owner()](#Ownable-owner--) -- [_checkOwner()](#Ownable-_checkOwner--) -- [renounceOwnership()](#Ownable-renounceOwnership--) -- [transferOwnership(newOwner)](#Ownable-transferOwnership-address-) -- [_transferOwnership(newOwner)](#Ownable-_transferOwnership-address-) +@custom:stateless -
+
+

Modifiers

+
+- [onlyProxy()](#UUPSUpgradeable-onlyProxy--) +- [notDelegated()](#UUPSUpgradeable-notDelegated--)
-

Events

+

Functions

-- [Upgraded(implementation)](#UpgradeableBeacon-Upgraded-address-) -
-Ownable - -- [OwnershipTransferred(previousOwner, newOwner)](#Ownable-OwnershipTransferred-address-address-) - -
+- [proxiableUUID()](#UUPSUpgradeable-proxiableUUID--) +- [upgradeToAndCall(newImplementation, data)](#UUPSUpgradeable-upgradeToAndCall-address-bytes-) +- [_checkProxy()](#UUPSUpgradeable-_checkProxy--) +- [_checkNotDelegated()](#UUPSUpgradeable-_checkNotDelegated--) +- [_authorizeUpgrade(newImplementation)](#UUPSUpgradeable-_authorizeUpgrade-address-) +- [UPGRADE_INTERFACE_VERSION()](#UUPSUpgradeable-UPGRADE_INTERFACE_VERSION-string)

Errors

-- [BeaconInvalidImplementation(implementation)](#UpgradeableBeacon-BeaconInvalidImplementation-address-) -
-Ownable - -- [OwnableUnauthorizedAccount(account)](#Ownable-OwnableUnauthorizedAccount-address-) -- [OwnableInvalidOwner(owner)](#Ownable-OwnableInvalidOwner-address-) - -
+- [UUPSUnauthorizedCallContext()](#UUPSUpgradeable-UUPSUnauthorizedCallContext--) +- [UUPSUnsupportedProxiableUUID(slot)](#UUPSUpgradeable-UUPSUnsupportedProxiableUUID-bytes32-)
- +
-

constructor(address implementation_, address initialOwner)

+

onlyProxy()

-

public

-# +

internal

+#
+
-Sets the address of the initial implementation, and the initial owner who can upgrade the beacon. +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.
- +
-

implementation() → address

+

notDelegated()

-

public

-# +

internal

+#
+
-Returns the current implementation address. +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.
- +
-

upgradeTo(address newImplementation)

+

proxiableUUID() → bytes32

-

public

-# +

external

+#
-Upgrades the beacon to a new implementation. - -Emits an [`UpgradeableBeacon.Upgraded`](#UpgradeableBeacon-Upgraded-address-) event. - -Requirements: - -- msg.sender must be the owner of the contract. -- `newImplementation` must be a contract. - -
-
- - - -
-
-

Upgraded(address indexed implementation)

-
-

event

-# -
-
- -
- -Emitted when the implementation returned by the beacon is changed. - -
-
- - - -
-
-

BeaconInvalidImplementation(address implementation)

-
-

error

-# -
-
-
- -The `implementation` of the beacon is invalid. - -
-
- - - -
- -## `Initializable` - - - - - -
- -```solidity -import "@openzeppelin/contracts/proxy/utils/Initializable.sol"; -``` - -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 [`Initializable.initializer`](#Initializable-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] -```solidity -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"); - } -} -``` - - -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`](#ERC1967Proxy-constructor-address-bytes-). - - - -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 [`Initializable._disableInitializers`](#Initializable-_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(); -} -``` - -
-

Modifiers

-
-- [initializer()](#Initializable-initializer--) -- [reinitializer(version)](#Initializable-reinitializer-uint64-) -- [onlyInitializing()](#Initializable-onlyInitializing--) -
-
- -
-

Functions

-
-- [_checkInitializing()](#Initializable-_checkInitializing--) -- [_disableInitializers()](#Initializable-_disableInitializers--) -- [_getInitializedVersion()](#Initializable-_getInitializedVersion--) -- [_isInitializing()](#Initializable-_isInitializing--) -- [_initializableStorageSlot()](#Initializable-_initializableStorageSlot--) -
-
- -
-

Events

-
-- [Initialized(version)](#Initializable-Initialized-uint64-) -
-
- -
-

Errors

-
-- [InvalidInitialization()](#Initializable-InvalidInitialization--) -- [NotInitializing()](#Initializable-NotInitializing--) -
-
- - - -
-
-

initializer()

-
-

internal

-# -
-
- -
- -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 [`Initializable.Initialized`](#Initializable-Initialized-uint64-) event. - -
-
- - - -
-
-

reinitializer(uint64 version)

-
-

internal

-# -
-
- -
- -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. +Implementation of the ERC-1822 [`UUPSUpgradeable.proxiableUUID`](#UUPSUpgradeable-proxiableUUID--) function. This returns the storage slot used by the +implementation. It is used to validate the implementation's compatibility when performing an upgrade. -Setting the version to 2**64 - 1 will prevent any future reinitialization. +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. -Emits an [`Initializable.Initialized`](#Initializable-Initialized-uint64-) event. -
- +
-

onlyInitializing()

+

upgradeToAndCall(address newImplementation, bytes data)

-

internal

-# +

public

+#
-
-Modifier to protect an initialization function so that it can only be invoked by functions with the -[`Initializable.initializer`](#Initializable-initializer--) and [`Initializable.reinitializer`](#Initializable-reinitializer-uint64-) modifiers, directly or indirectly. - -
-
- - +Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call +encoded in `data`. -
-
-

_checkInitializing()

-
-

internal

-# -
-
-
+Calls [`UUPSUpgradeable._authorizeUpgrade`](#UUPSUpgradeable-_authorizeUpgrade-address-). -Reverts if the contract is not in an initializing state. See [`Initializable.onlyInitializing`](#Initializable-onlyInitializing--). +Emits an [`UpgradeableBeacon.Upgraded`](#UpgradeableBeacon-Upgraded-address-) event.
- +
-

_disableInitializers()

+

_checkProxy()

internal

-# +#
-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 [`Initializable.Initialized`](#Initializable-Initialized-uint64-) event the first time it is successfully executed. +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.
- +
-

_getInitializedVersion() → uint64

+

_checkNotDelegated()

internal

-# +#
-Returns the highest version that has been initialized. See [`Initializable.reinitializer`](#Initializable-reinitializer-uint64-). +Reverts if the execution is performed via delegatecall. +See [`UUPSUpgradeable.notDelegated`](#UUPSUpgradeable-notDelegated--).
- +
-

_isInitializing() → bool

+

_authorizeUpgrade(address newImplementation)

internal

-# +#
-Returns `true` if the contract is currently initializing. See [`Initializable.onlyInitializing`](#Initializable-onlyInitializing--). - -
-
- - - -
-
-

_initializableStorageSlot() → bytes32

-
-

internal

-# -
-
-
+Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by +[`ERC1967Utils.upgradeToAndCall`](#ERC1967Utils-upgradeToAndCall-address-bytes-). -Pointer to storage slot. Allows integrators to override it with a custom storage location. +Normally, this function will use an [access control](/contracts/5.x/api/access) modifier such as [`Ownable.onlyOwner`](/contracts/5.x/api/access#Ownable-onlyOwner--). - -Consider following the ERC-7201 formula to derive storage locations. - +```solidity +function _authorizeUpgrade(address) internal onlyOwner {} +```
- +
-

Initialized(uint64 version)

+

UPGRADE_INTERFACE_VERSION() → string

-

event

-# +

public

+#
-
-Triggered when the contract has been initialized or reinitialized. +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.
- +
-

InvalidInitialization()

+

UUPSUnauthorizedCallContext()

error

-# +#
-The contract is already initialized. +The call is from an unauthorized context.
- +
-

NotInitializing()

+

UUPSUnsupportedProxiableUUID(bytes32 slot)

error

-# +#
-The contract is not initializing. +The storage `slot` is unsupported as a UUID.
diff --git a/content/contracts/5.x/api/token/ERC20.mdx b/content/contracts/5.x/api/token/ERC20.mdx index 92bb6555..4c9d8b45 100644 --- a/content/contracts/5.x/api/token/ERC20.mdx +++ b/content/contracts/5.x/api/token/ERC20.mdx @@ -775,63 +775,38 @@ a call to [`ERC20.approve`](#ERC20-approve-address-uint256-). `value` is the new
- +
-## `ERC20Crosschain` +## `ERC1363` - +
```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Crosschain.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/ERC1363.sol"; ``` -Extension of [`ERC20`](#ERC20) that makes it natively cross-chain using the ERC-7786 based [`BridgeFungible`](/contracts/5.x/api/crosschain#BridgeFungible). - -This extension makes the token compatible with counterparts on other chains, which can be: -* [`ERC20Crosschain`](#ERC20Crosschain) instances, -* [`ERC20`](#ERC20) instances that are bridged using [`BridgeERC20`](/contracts/5.x/api/crosschain#BridgeERC20), -* [`ERC20Bridgeable`](#ERC20Bridgeable) instances that are bridged using [`BridgeERC7802`](/contracts/5.x/api/crosschain#BridgeERC7802). +Extension of [`ERC20`](#ERC20) tokens that adds support for code execution after transfers and approvals +on recipient contracts. Calls after transfers are enabled through the [`ERC1363.transferAndCall`](#ERC1363-transferAndCall-address-uint256-bytes-) and +[`ERC1363.transferFromAndCall`](#ERC1363-transferFromAndCall-address-address-uint256-bytes-) methods while calls after approvals can be made with [`ERC1363.approveAndCall`](#ERC1363-approveAndCall-address-uint256-bytes-) -It is mostly equivalent to inheriting from both [`ERC20Bridgeable`](#ERC20Bridgeable) and [`BridgeERC7802`](/contracts/5.x/api/crosschain#BridgeERC7802), and configuring them such -that: -* `token` (on the [`BridgeERC7802`](/contracts/5.x/api/crosschain#BridgeERC7802) side) is `address(this)`, -* `_checkTokenBridge` (on the [`ERC20Bridgeable`](#ERC20Bridgeable) side) is implemented such that it only accepts self-calls. +_Available since v5.1._

Functions

-- [crosschainTransferFrom(from, to, amount)](#ERC20Crosschain-crosschainTransferFrom-address-bytes-uint256-) -- [_onSend(from, amount)](#ERC20Crosschain-_onSend-address-uint256-) -- [_onReceive(to, amount)](#ERC20Crosschain-_onReceive-address-uint256-) -
-BridgeFungible - -- [crosschainTransfer(to, amount)](#BridgeFungible-crosschainTransfer-bytes-uint256-) -- [_crosschainTransfer(from, to, amount)](#BridgeFungible-_crosschainTransfer-address-bytes-uint256-) -- [_processMessage(, receiveId, , payload)](#BridgeFungible-_processMessage-address-bytes32-bytes-bytes-) - -
-
-CrosschainLinked - -- [getLink(chain)](#CrosschainLinked-getLink-bytes-) -- [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) -- [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) -- [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-) - -
-
-ERC7786Recipient - -- [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-) - -
+- [supportsInterface(interfaceId)](#ERC1363-supportsInterface-bytes4-) +- [transferAndCall(to, value)](#ERC1363-transferAndCall-address-uint256-) +- [transferAndCall(to, value, data)](#ERC1363-transferAndCall-address-uint256-bytes-) +- [transferFromAndCall(from, to, value)](#ERC1363-transferFromAndCall-address-address-uint256-) +- [transferFromAndCall(from, to, value, data)](#ERC1363-transferFromAndCall-address-address-uint256-bytes-) +- [approveAndCall(spender, value)](#ERC1363-approveAndCall-address-uint256-) +- [approveAndCall(spender, value, data)](#ERC1363-approveAndCall-address-uint256-bytes-)
ERC20 @@ -860,19 +835,6 @@ that:

Events

-BridgeFungible - -- [CrosschainFungibleTransferSent(sendId, from, to, amount)](#BridgeFungible-CrosschainFungibleTransferSent-bytes32-address-bytes-uint256-) -- [CrosschainFungibleTransferReceived(receiveId, from, to, amount)](#BridgeFungible-CrosschainFungibleTransferReceived-bytes32-bytes-address-uint256-) - -
-
-CrosschainLinked - -- [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-) - -
-
IERC20 - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) @@ -885,18 +847,9 @@ that:

Errors

-
-CrosschainLinked - -- [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-) - -
-
-ERC7786Recipient - -- [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-) - -
+- [ERC1363TransferFailed(receiver, value)](#ERC1363-ERC1363TransferFailed-address-uint256-) +- [ERC1363TransferFromFailed(sender, receiver, value)](#ERC1363-ERC1363TransferFromFailed-address-address-uint256-) +- [ERC1363ApproveFailed(spender, value)](#ERC1363-ERC1363ApproveFailed-address-uint256-)
IERC20Errors @@ -911,349 +864,358 @@ that:
- +
-

crosschainTransferFrom(address from, bytes to, uint256 amount) → bytes32

+

supportsInterface(bytes4 interfaceId) → bool

public

-# +#
-Variant of [`BridgeFungible.crosschainTransfer`](/contracts/5.x/api/crosschain#BridgeFungible-crosschainTransfer-bytes-uint256-) that allows an authorized account (using ERC20 allowance) to operate on `from`'s assets. +Returns true if this contract implements the interface defined by +`interfaceId`. See the corresponding +[ERC section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) +to learn more about how these ids are created. + +This function call must use less than 30 000 gas.
- +
-

_onSend(address from, uint256 amount)

+

transferAndCall(address to, uint256 value) → bool

-

internal

-# +

public

+#
-"Locking" tokens is achieved through burning +Moves a `value` amount of tokens from the caller's account to `to` +and then calls [`IERC1363Receiver.onTransferReceived`](/contracts/5.x/api/interfaces#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) on `to`. Returns a flag that indicates +if the call succeeded. + +Requirements: + +- The target has code (i.e. is a contract). +- The target `to` must implement the [`IERC1363Receiver`](/contracts/5.x/api/interfaces#IERC1363Receiver) interface. +- The target must return the [`IERC1363Receiver.onTransferReceived`](/contracts/5.x/api/interfaces#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) selector to accept the transfer. +- The internal [`ERC20.transfer`](#ERC20-transfer-address-uint256-) must succeed (returned `true`).
- +
-

_onReceive(address to, uint256 amount)

+

transferAndCall(address to, uint256 value, bytes data) → bool

-

internal

-# +

public

+#
-"Unlocking" tokens is achieved through minting +Variant of [`ERC1363.transferAndCall`](#ERC1363-transferAndCall-address-uint256-bytes-) that accepts an additional `data` parameter with +no specified format.
- - -
- -## `ERC20FlashMint` - - - - + +
+
+

transferFromAndCall(address from, address to, uint256 value) → bool

+
+

public

+#
+
+
-```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC20FlashMint.sol"; -``` - -Implementation of the ERC-3156 Flash loans extension, as defined in -[ERC-3156](https://eips.ethereum.org/EIPS/eip-3156). - -Adds the [`ERC20FlashMint.flashLoan`](#ERC20FlashMint-flashLoan-contract-IERC3156FlashBorrower-address-uint256-bytes-) method, which provides flash loan support at the token -level. By default there is no fee, but this can be changed by overriding [`ERC20FlashMint.flashFee`](#ERC20FlashMint-flashFee-address-uint256-). - - -When this extension is used along with the [`ERC20Capped`](#ERC20Capped) or [`ERC20Votes`](#ERC20Votes) extensions, -[`ERC20FlashMint.maxFlashLoan`](#ERC20FlashMint-maxFlashLoan-address-) will not correctly reflect the maximum that can be flash minted. We recommend -overriding [`ERC20FlashMint.maxFlashLoan`](#ERC20FlashMint-maxFlashLoan-address-) so that it correctly reflects the supply cap. - +Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism +and then calls [`IERC1363Receiver.onTransferReceived`](/contracts/5.x/api/interfaces#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) on `to`. Returns a flag that indicates +if the call succeeded. -
-

Functions

-
-- [maxFlashLoan(token)](#ERC20FlashMint-maxFlashLoan-address-) -- [flashFee(token, value)](#ERC20FlashMint-flashFee-address-uint256-) -- [_flashFee(, )](#ERC20FlashMint-_flashFee-address-uint256-) -- [_flashFeeReceiver()](#ERC20FlashMint-_flashFeeReceiver--) -- [flashLoan(receiver, token, value, data)](#ERC20FlashMint-flashLoan-contract-IERC3156FlashBorrower-address-uint256-bytes-) -
-ERC20 +Requirements: -- [name()](#ERC20-name--) -- [symbol()](#ERC20-symbol--) -- [decimals()](#ERC20-decimals--) -- [totalSupply()](#ERC20-totalSupply--) -- [balanceOf(account)](#ERC20-balanceOf-address-) -- [transfer(to, value)](#ERC20-transfer-address-uint256-) -- [allowance(owner, spender)](#ERC20-allowance-address-address-) -- [approve(spender, value)](#ERC20-approve-address-uint256-) -- [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) -- [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) -- [_update(from, to, value)](#ERC20-_update-address-address-uint256-) -- [_mint(account, value)](#ERC20-_mint-address-uint256-) -- [_burn(account, value)](#ERC20-_burn-address-uint256-) -- [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) -- [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) -- [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) +- The target has code (i.e. is a contract). +- The target `to` must implement the [`IERC1363Receiver`](/contracts/5.x/api/interfaces#IERC1363Receiver) interface. +- The target must return the [`IERC1363Receiver.onTransferReceived`](/contracts/5.x/api/interfaces#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) selector to accept the transfer. +- The internal [`ERC20.transferFrom`](#ERC20-transferFrom-address-address-uint256-) must succeed (returned `true`). -
-
-

Events

-
-
-IERC20 - -- [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) -- [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + -
+
+
+

transferFromAndCall(address from, address to, uint256 value, bytes data) → bool

+
+

public

+#
+
-
-

Errors

-
-- [ERC3156UnsupportedToken(token)](#ERC20FlashMint-ERC3156UnsupportedToken-address-) -- [ERC3156ExceededMaxLoan(maxLoan)](#ERC20FlashMint-ERC3156ExceededMaxLoan-uint256-) -- [ERC3156InvalidReceiver(receiver)](#ERC20FlashMint-ERC3156InvalidReceiver-address-) -
-IERC20Errors - -- [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) -- [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) -- [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) -- [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) -- [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) -- [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) +Variant of [`ERC1363.transferFromAndCall`](#ERC1363-transferFromAndCall-address-address-uint256-bytes-) that accepts an additional `data` parameter with +no specified format. -
- +
-

maxFlashLoan(address token) → uint256

+

approveAndCall(address spender, uint256 value) → bool

public

-# +#
-Returns the maximum amount of tokens available for loan. +Sets a `value` amount of tokens as the allowance of `spender` over the +caller's tokens and then calls [`IERC1363Spender.onApprovalReceived`](/contracts/5.x/api/interfaces#IERC1363Spender-onApprovalReceived-address-uint256-bytes-) on `spender`. +Returns a flag that indicates if the call succeeded. - -This function will not automatically detect any supply cap -added by other extensions, such as [`ERC20Capped`](#ERC20Capped). If necessary, -override this function to take a supply cap into account. - +Requirements: + +- The target has code (i.e. is a contract). +- The target `spender` must implement the [`IERC1363Spender`](/contracts/5.x/api/interfaces#IERC1363Spender) interface. +- The target must return the [`IERC1363Spender.onApprovalReceived`](/contracts/5.x/api/interfaces#IERC1363Spender-onApprovalReceived-address-uint256-bytes-) selector to accept the approval. +- The internal [`ERC20.approve`](#ERC20-approve-address-uint256-) must succeed (returned `true`).
- +
-

flashFee(address token, uint256 value) → uint256

+

approveAndCall(address spender, uint256 value, bytes data) → bool

public

-# +#
-Returns the fee applied when doing flash loans. This function calls -the [`ERC20FlashMint._flashFee`](#ERC20FlashMint-_flashFee-address-uint256-) function which returns the fee applied when doing flash -loans. +Variant of [`ERC1363.approveAndCall`](#ERC1363-approveAndCall-address-uint256-bytes-) that accepts an additional `data` parameter with +no specified format.
- +
-

_flashFee(address, uint256) → uint256

+

ERC1363TransferFailed(address receiver, uint256 value)

-

internal

-# +

error

+#
-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. +Indicates a failure within the [`ERC20.transfer`](#ERC20-transfer-address-uint256-) part of a transferAndCall operation.
- +
-

_flashFeeReceiver() → address

+

ERC1363TransferFromFailed(address sender, address receiver, uint256 value)

-

internal

-# +

error

+#
-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. +Indicates a failure within the [`ERC20.transferFrom`](#ERC20-transferFrom-address-address-uint256-) part of a transferFromAndCall operation.
- +
-

flashLoan(contract IERC3156FlashBorrower receiver, address token, uint256 value, bytes data) → bool

+

ERC1363ApproveFailed(address spender, uint256 value)

-

public

-# +

error

+#
-Performs a flash loan. New tokens are minted and sent to the -`receiver`, who is required to implement the [`IERC3156FlashBorrower`](/contracts/5.x/api/interfaces#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. +Indicates a failure within the [`ERC20.approve`](#ERC20-approve-address-uint256-) part of a approveAndCall operation.
- + -
-
-

ERC3156UnsupportedToken(address token)

-
-

error

-# +
+ +## `ERC20Burnable` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; +``` + +Extension of [`ERC20`](#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(value)](#ERC20Burnable-burn-uint256-) +- [burnFrom(account, value)](#ERC20Burnable-burnFrom-address-uint256-) +
+ERC20 + +- [name()](#ERC20-name--) +- [symbol()](#ERC20-symbol--) +- [decimals()](#ERC20-decimals--) +- [totalSupply()](#ERC20-totalSupply--) +- [balanceOf(account)](#ERC20-balanceOf-address-) +- [transfer(to, value)](#ERC20-transfer-address-uint256-) +- [allowance(owner, spender)](#ERC20-allowance-address-address-) +- [approve(spender, value)](#ERC20-approve-address-uint256-) +- [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) +- [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) +- [_update(from, to, value)](#ERC20-_update-address-address-uint256-) +- [_mint(account, value)](#ERC20-_mint-address-uint256-) +- [_burn(account, value)](#ERC20-_burn-address-uint256-) +- [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) +- [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) +- [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) + +
-
-The loan token is not valid. +
+

Events

+
+
+IERC20 + +- [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) +- [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) +
- +
+

Errors

+
+
+IERC20Errors + +- [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) +- [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) +- [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) +- [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) +- [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) +- [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) + +
+
+
+ +
-

ERC3156ExceededMaxLoan(uint256 maxLoan)

+

burn(uint256 value)

-

error

-# +

public

+#
-The requested loan exceeds the max loan value for `token`. +Destroys a `value` amount of tokens from the caller. + +See [`ERC20._burn`](#ERC20-_burn-address-uint256-).
- +
-

ERC3156InvalidReceiver(address receiver)

+

burnFrom(address account, uint256 value)

-

error

-# +

public

+#
-The receiver of a flashloan is not a valid [`IERC3156FlashBorrower.onFlashLoan`](/contracts/5.x/api/interfaces#IERC3156FlashBorrower-onFlashLoan-address-address-uint256-uint256-bytes-) implementer. +Destroys a `value` amount of tokens from `account`, deducting from +the caller's allowance. + +See [`ERC20._burn`](#ERC20-_burn-address-uint256-) and [`ERC20.allowance`](#ERC20-allowance-address-address-). + +Requirements: + +- the caller must have allowance for ``accounts``'s tokens of at least +`value`.
- +
-## `ERC20Permit` +## `ERC20Capped` - +
```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol"; ``` -Implementation of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in -[ERC-2612](https://eips.ethereum.org/EIPS/eip-2612). - -Adds the [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) method, which can be used to change an account's ERC-20 allowance (see [`IERC20.allowance`](#IERC20-allowance-address-address-)) by -presenting a message signed by the account. By not relying on `[`IERC20.approve`](#IERC20-approve-address-uint256-)`, the token holder account doesn't -need to send a transaction, and thus is not required to hold Ether at all. +Extension of [`ERC20`](#ERC20) that adds a cap to the supply of tokens.

Functions

-- [constructor(name)](#ERC20Permit-constructor-string-) -- [permit(owner, spender, value, deadline, v, r, s)](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) -- [nonces(owner)](#ERC20Permit-nonces-address-) -- [DOMAIN_SEPARATOR()](#ERC20Permit-DOMAIN_SEPARATOR--) -
-Nonces - -- [_useNonce(owner)](#Nonces-_useNonce-address-) -- [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) - -
-
-EIP712 - -- [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) -- [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) -- [eip712Domain()](#EIP712-eip712Domain--) -- [_EIP712Name()](#EIP712-_EIP712Name--) -- [_EIP712Version()](#EIP712-_EIP712Version--) - -
+- [constructor(cap_)](#ERC20Capped-constructor-uint256-) +- [cap()](#ERC20Capped-cap--) +- [_update(from, to, value)](#ERC20Capped-_update-address-address-uint256-)
ERC20 @@ -1267,7 +1229,6 @@ need to send a transaction, and thus is not required to hold Ether at all. - [approve(spender, value)](#ERC20-approve-address-uint256-) - [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) - [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) -- [_update(from, to, value)](#ERC20-_update-address-address-uint256-) - [_mint(account, value)](#ERC20-_mint-address-uint256-) - [_burn(account, value)](#ERC20-_burn-address-uint256-) - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) @@ -1282,12 +1243,6 @@ need to send a transaction, and thus is not required to hold Ether at all.

Events

-IERC5267 - -- [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) - -
-
IERC20 - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) @@ -1300,14 +1255,8 @@ need to send a transaction, and thus is not required to hold Ether at all.

Errors

-- [ERC2612ExpiredSignature(deadline)](#ERC20Permit-ERC2612ExpiredSignature-uint256-) -- [ERC2612InvalidSigner(signer, owner)](#ERC20Permit-ERC2612InvalidSigner-address-address-) -
-Nonces - -- [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) - -
+- [ERC20ExceededCap(increasedSupply, cap)](#ERC20Capped-ERC20ExceededCap-uint256-uint256-) +- [ERC20InvalidCap(cap)](#ERC20Capped-ERC20InvalidCap-uint256-)
IERC20Errors @@ -1322,212 +1271,151 @@ need to send a transaction, and thus is not required to hold Ether at all.
- +
-

constructor(string name)

+

constructor(uint256 cap_)

internal

-# +#
-Initializes the [`EIP712`](/contracts/5.x/api/utils/cryptography#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. +Sets the value of the `cap`. This value is immutable, it can only be +set once during construction.
- +
-

permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)

+

cap() → uint256

public

-# +#
-Sets `value` as the allowance of `spender` over ``owner``'s tokens, -given ``owner``'s signed approval. - - -The same issues [`IERC20.approve`](#IERC20-approve-address-uint256-) has related to transaction -ordering also applies here. - - -Emits an [`IERC20.Approval`](#IERC20-Approval-address-address-uint256-) event. - -Requirements: - -- `spender` cannot be the zero address. -- `deadline` must be a timestamp in the future. -- `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` -over the EIP712-formatted function arguments. -- the signature must use ``owner``'s current nonce (see [`ERC20Permit.nonces`](#ERC20Permit-nonces-address-)). - -For more information on the signature format, see the -[relevant EIP -section](https://eips.ethereum.org/EIPS/eip-2612#specification). - - -See Security Considerations above. - +Returns the cap on the token's total supply.
- +
-

nonces(address owner) → uint256

+

_update(address from, address to, uint256 value)

-

public

-# +

internal

+#
-Returns the current nonce for `owner`. This value must be -included whenever a signature is generated for [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-). - -Every successful call to [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) increases ``owner``'s nonce by one. This -prevents a signature from being used multiple times. - -
-
- - - -
-
-

DOMAIN_SEPARATOR() → bytes32

-
-

external

-# -
-
-
+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. -Returns the domain separator used in the encoding of the signature for [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-), as defined by [`EIP712`](/contracts/5.x/api/utils/cryptography#EIP712). +Emits a [`IERC20.Transfer`](#IERC20-Transfer-address-address-uint256-) event.
- +
-

ERC2612ExpiredSignature(uint256 deadline)

+

ERC20ExceededCap(uint256 increasedSupply, uint256 cap)

error

-# +#
-Permit deadline has expired. +Total supply cap has been exceeded.
- +
-

ERC2612InvalidSigner(address signer, address owner)

+

ERC20InvalidCap(uint256 cap)

error

-# +#
-Mismatched signature. +The supplied cap is not a valid cap.
- +
-## `ERC20Votes` +## `ERC20Crosschain` - +
```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Crosschain.sol"; ``` -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. - - -This contract does not provide interface compatibility with Compound's COMP token. - +Extension of [`ERC20`](#ERC20) that makes it natively cross-chain using the ERC-7786 based [`BridgeFungible`](/contracts/5.x/api/crosschain#BridgeFungible). -This extension keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either -by calling the [`Votes.delegate`](/contracts/5.x/api/governance#Votes-delegate-address-) function directly, or by providing a signature to be used with [`Votes.delegateBySig`](/contracts/5.x/api/governance#Votes-delegateBySig-address-uint256-uint256-uint8-bytes32-bytes32-). Voting -power can be queried through the public accessors [`Votes.getVotes`](/contracts/5.x/api/governance#Votes-getVotes-address-) and [`Votes.getPastVotes`](/contracts/5.x/api/governance#Votes-getPastVotes-address-uint256-). +This extension makes the token compatible with counterparts on other chains, which can be: +* [`ERC20Crosschain`](#ERC20Crosschain) instances, +* [`ERC20`](#ERC20) instances that are bridged using [`BridgeERC20`](/contracts/5.x/api/crosschain#BridgeERC20), +* [`ERC20Bridgeable`](#ERC20Bridgeable) instances that are bridged using [`BridgeERC7802`](/contracts/5.x/api/crosschain#BridgeERC7802). -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. +It is mostly equivalent to inheriting from both [`ERC20Bridgeable`](#ERC20Bridgeable) and [`BridgeERC7802`](/contracts/5.x/api/crosschain#BridgeERC7802), and configuring them such +that: +* `token` (on the [`BridgeERC7802`](/contracts/5.x/api/crosschain#BridgeERC7802) side) is `address(this)`, +* `_checkTokenBridge` (on the [`ERC20Bridgeable`](#ERC20Bridgeable) side) is implemented such that it only accepts self-calls.

Functions

-- [_maxSupply()](#ERC20Votes-_maxSupply--) -- [_update(from, to, value)](#ERC20Votes-_update-address-address-uint256-) -- [_getVotingUnits(account)](#ERC20Votes-_getVotingUnits-address-) -- [numCheckpoints(account)](#ERC20Votes-numCheckpoints-address-) -- [checkpoints(account, pos)](#ERC20Votes-checkpoints-address-uint32-) +- [crosschainTransferFrom(from, to, amount)](#ERC20Crosschain-crosschainTransferFrom-address-bytes-uint256-) +- [_onSend(from, amount)](#ERC20Crosschain-_onSend-address-uint256-) +- [_onReceive(to, amount)](#ERC20Crosschain-_onReceive-address-uint256-)
-Votes +BridgeFungible -- [clock()](#Votes-clock--) -- [CLOCK_MODE()](#Votes-CLOCK_MODE--) -- [_validateTimepoint(timepoint)](#Votes-_validateTimepoint-uint256-) -- [getVotes(account)](#Votes-getVotes-address-) -- [getPastVotes(account, timepoint)](#Votes-getPastVotes-address-uint256-) -- [getPastTotalSupply(timepoint)](#Votes-getPastTotalSupply-uint256-) -- [_getTotalSupply()](#Votes-_getTotalSupply--) -- [delegates(account)](#Votes-delegates-address-) -- [delegate(delegatee)](#Votes-delegate-address-) -- [delegateBySig(delegatee, nonce, expiry, v, r, s)](#Votes-delegateBySig-address-uint256-uint256-uint8-bytes32-bytes32-) -- [_delegate(account, delegatee)](#Votes-_delegate-address-address-) -- [_transferVotingUnits(from, to, amount)](#Votes-_transferVotingUnits-address-address-uint256-) -- [_moveDelegateVotes(from, to, amount)](#Votes-_moveDelegateVotes-address-address-uint256-) -- [_numCheckpoints(account)](#Votes-_numCheckpoints-address-) -- [_checkpoints(account, pos)](#Votes-_checkpoints-address-uint32-) +- [crosschainTransfer(to, amount)](#BridgeFungible-crosschainTransfer-bytes-uint256-) +- [_crosschainTransfer(from, to, amount)](#BridgeFungible-_crosschainTransfer-address-bytes-uint256-) +- [_processMessage(, receiveId, , payload)](#BridgeFungible-_processMessage-address-bytes32-bytes-bytes-)
-Nonces +CrosschainLinked -- [nonces(owner)](#Nonces-nonces-address-) -- [_useNonce(owner)](#Nonces-_useNonce-address-) -- [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) +- [getLink(chain)](#CrosschainLinked-getLink-bytes-) +- [_setLink(gateway, counterpart, allowOverride)](#CrosschainLinked-_setLink-address-bytes-bool-) +- [_sendMessageToCounterpart(chain, payload, attributes)](#CrosschainLinked-_sendMessageToCounterpart-bytes-bytes-bytes---) +- [_isAuthorizedGateway(instance, sender)](#CrosschainLinked-_isAuthorizedGateway-address-bytes-)
-EIP712 +ERC7786Recipient -- [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) -- [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) -- [eip712Domain()](#EIP712-eip712Domain--) -- [_EIP712Name()](#EIP712-_EIP712Name--) -- [_EIP712Version()](#EIP712-_EIP712Version--) +- [receiveMessage(receiveId, sender, payload)](#ERC7786Recipient-receiveMessage-bytes32-bytes-bytes-)
@@ -1543,6 +1431,7 @@ requires users to delegate to themselves in order to activate checkpoints and ha - [approve(spender, value)](#ERC20-approve-address-uint256-) - [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) - [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) +- [_update(from, to, value)](#ERC20-_update-address-address-uint256-) - [_mint(account, value)](#ERC20-_mint-address-uint256-) - [_burn(account, value)](#ERC20-_burn-address-uint256-) - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) @@ -1557,16 +1446,16 @@ requires users to delegate to themselves in order to activate checkpoints and ha

Events

-IVotes +BridgeFungible -- [DelegateChanged(delegator, fromDelegate, toDelegate)](#IVotes-DelegateChanged-address-address-address-) -- [DelegateVotesChanged(delegate, previousVotes, newVotes)](#IVotes-DelegateVotesChanged-address-uint256-uint256-) +- [CrosschainFungibleTransferSent(sendId, from, to, amount)](#BridgeFungible-CrosschainFungibleTransferSent-bytes32-address-bytes-uint256-) +- [CrosschainFungibleTransferReceived(receiveId, from, to, amount)](#BridgeFungible-CrosschainFungibleTransferReceived-bytes32-bytes-address-uint256-)
-IERC5267 +CrosschainLinked -- [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) +- [LinkRegistered(gateway, counterpart)](#CrosschainLinked-LinkRegistered-address-bytes-)
@@ -1582,24 +1471,16 @@ requires users to delegate to themselves in order to activate checkpoints and ha

Errors

-- [ERC20ExceededSafeSupply(increasedSupply, cap)](#ERC20Votes-ERC20ExceededSafeSupply-uint256-uint256-) -
-Votes - -- [ERC6372InconsistentClock()](#Votes-ERC6372InconsistentClock--) -- [ERC5805FutureLookup(timepoint, clock)](#Votes-ERC5805FutureLookup-uint256-uint48-) - -
-IVotes +CrosschainLinked -- [VotesExpiredSignature(expiry)](#IVotes-VotesExpiredSignature-uint256-) +- [LinkAlreadyRegistered(chain)](#CrosschainLinked-LinkAlreadyRegistered-bytes-)
-Nonces +ERC7786Recipient -- [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) +- [ERC7786RecipientUnauthorizedGateway(gateway, sender)](#ERC7786Recipient-ERC7786RecipientUnauthorizedGateway-address-bytes-)
@@ -1616,165 +1497,99 @@ requires users to delegate to themselves in order to activate checkpoints and ha
- +
-

_maxSupply() → uint256

+

crosschainTransferFrom(address from, bytes to, uint256 amount) → bytes32

-

internal

-# +

public

+#
-Maximum token supply. Defaults to `type(uint208).max` (2^208^ - 1). - -This maximum is enforced in [`ERC20._update`](#ERC20-_update-address-address-uint256-). 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`](/contracts/5.x/api/governance#Votes). Increasing this value will not -remove the underlying limitation, and will cause [`ERC20._update`](#ERC20-_update-address-address-uint256-) to fail because of a math overflow in -[`Votes._transferVotingUnits`](/contracts/5.x/api/governance#Votes-_transferVotingUnits-address-address-uint256-). 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. +Variant of [`BridgeFungible.crosschainTransfer`](/contracts/5.x/api/crosschain#BridgeFungible-crosschainTransfer-bytes-uint256-) that allows an authorized account (using ERC20 allowance) to operate on `from`'s assets.
- +
-

_update(address from, address to, uint256 value)

+

_onSend(address from, uint256 amount)

internal

-# +#
-Move voting power when tokens are transferred. - -Emits a [`IVotes.DelegateVotesChanged`](/contracts/5.x/api/governance#IVotes-DelegateVotesChanged-address-uint256-uint256-) event. +"Locking" tokens is achieved through burning
- +
-

_getVotingUnits(address account) → uint256

+

_onReceive(address to, uint256 amount)

internal

-# -
-
-
- -Returns the voting units of an `account`. - - -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. - - -
-
- - - -
-
-

numCheckpoints(address account) → uint32

-
-

public

-# -
-
-
- -Get number of checkpoints for `account`. - -
-
- - - -
-
-

checkpoints(address account, uint32 pos) → struct Checkpoints.Checkpoint208

-
-

public

-# -
-
-
- -Get the `pos`-th checkpoint for `account`. - -
-
- - - -
-
-

ERC20ExceededSafeSupply(uint256 increasedSupply, uint256 cap)

-
-

error

-# +#
-Total supply cap has been exceeded, introducing a risk of votes overflowing. +"Unlocking" tokens is achieved through minting
- +
-## `ERC20Wrapper` +## `ERC20FlashMint` - +
```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Wrapper.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/ERC20FlashMint.sol"; ``` -Extension of the ERC-20 token contract to support token wrapping. +Implementation of the ERC-3156 Flash loans extension, as defined in +[ERC-3156](https://eips.ethereum.org/EIPS/eip-3156). -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`](#ERC20Votes) will allow the -wrapping of an existing "basic" ERC-20 into a governance token. +Adds the [`ERC20FlashMint.flashLoan`](#ERC20FlashMint-flashLoan-contract-IERC3156FlashBorrower-address-uint256-bytes-) method, which provides flash loan support at the token +level. By default there is no fee, but this can be changed by overriding [`ERC20FlashMint.flashFee`](#ERC20FlashMint-flashFee-address-uint256-). - -Any mechanism in which the underlying token changes the [`ERC20.balanceOf`](#ERC20-balanceOf-address-) 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 [`ERC20Wrapper._recover`](#ERC20Wrapper-_recover-address-) -for recovering value accrued to the wrapper. + +When this extension is used along with the [`ERC20Capped`](#ERC20Capped) or [`ERC20Votes`](#ERC20Votes) extensions, +[`ERC20FlashMint.maxFlashLoan`](#ERC20FlashMint-maxFlashLoan-address-) will not correctly reflect the maximum that can be flash minted. We recommend +overriding [`ERC20FlashMint.maxFlashLoan`](#ERC20FlashMint-maxFlashLoan-address-) so that it correctly reflects the supply cap.

Functions

-- [constructor(underlyingToken)](#ERC20Wrapper-constructor-contract-IERC20-) -- [decimals()](#ERC20Wrapper-decimals--) -- [underlying()](#ERC20Wrapper-underlying--) -- [depositFor(account, value)](#ERC20Wrapper-depositFor-address-uint256-) -- [withdrawTo(account, value)](#ERC20Wrapper-withdrawTo-address-uint256-) -- [_recover(account)](#ERC20Wrapper-_recover-address-) +- [maxFlashLoan(token)](#ERC20FlashMint-maxFlashLoan-address-) +- [flashFee(token, value)](#ERC20FlashMint-flashFee-address-uint256-) +- [_flashFee(, )](#ERC20FlashMint-_flashFee-address-uint256-) +- [_flashFeeReceiver()](#ERC20FlashMint-_flashFeeReceiver--) +- [flashLoan(receiver, token, value, data)](#ERC20FlashMint-flashLoan-contract-IERC3156FlashBorrower-address-uint256-bytes-)
ERC20 - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) +- [decimals()](#ERC20-decimals--) - [totalSupply()](#ERC20-totalSupply--) - [balanceOf(account)](#ERC20-balanceOf-address-) - [transfer(to, value)](#ERC20-transfer-address-uint256-) @@ -1809,7 +1624,9 @@ for recovering value accrued to the wrapper.

Errors

-- [ERC20InvalidUnderlying(token)](#ERC20Wrapper-ERC20InvalidUnderlying-address-) +- [ERC3156UnsupportedToken(token)](#ERC20FlashMint-ERC3156UnsupportedToken-address-) +- [ERC3156ExceededMaxLoan(maxLoan)](#ERC20FlashMint-ERC3156ExceededMaxLoan-uint256-) +- [ERC3156InvalidReceiver(receiver)](#ERC20FlashMint-ERC3156InvalidReceiver-address-)
IERC20Errors @@ -1824,222 +1641,208 @@ for recovering value accrued to the wrapper.
- +
-

constructor(contract IERC20 underlyingToken)

+

maxFlashLoan(address token) → uint256

-

internal

-# +

public

+#
+Returns the maximum amount of tokens available for loan. + + +This function will not automatically detect any supply cap +added by other extensions, such as [`ERC20Capped`](#ERC20Capped). If necessary, +override this function to take a supply cap into account. + +
- +
-

decimals() → uint8

+

flashFee(address token, uint256 value) → uint256

public

-# +#
+Returns the fee applied when doing flash loans. This function calls +the [`ERC20FlashMint._flashFee`](#ERC20FlashMint-_flashFee-address-uint256-) function which returns the fee applied when doing flash +loans. +
- +
-

underlying() → contract IERC20

+

_flashFee(address, uint256) → uint256

-

public

-# +

internal

+#
-Returns the address of the underlying ERC-20 token that is being wrapped. +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.
- +
-

depositFor(address account, uint256 value) → bool

+

_flashFeeReceiver() → address

-

public

-# +

internal

+#
-Allow a user to deposit underlying tokens and mint the corresponding number of wrapped tokens. +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.
- +
-

withdrawTo(address account, uint256 value) → bool

+

flashLoan(contract IERC3156FlashBorrower receiver, address token, uint256 value, bytes data) → bool

public

-# +#
-Allow a user to burn a number of wrapped tokens and withdraw the corresponding number of underlying tokens. +Performs a flash loan. New tokens are minted and sent to the +`receiver`, who is required to implement the [`IERC3156FlashBorrower`](/contracts/5.x/api/interfaces#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.
- +
-

_recover(address account) → uint256

+

ERC3156UnsupportedToken(address token)

-

internal

-# +

error

+#
-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. +The loan token is not valid.
- +
-

ERC20InvalidUnderlying(address token)

+

ERC3156ExceededMaxLoan(uint256 maxLoan)

error

-# +#
-The underlying token couldn't be wrapped. +The requested loan exceeds the max loan value for `token`.
- + + +
+
+

ERC3156InvalidReceiver(address receiver)

+
+

error

+# +
+
+
+ +The receiver of a flashloan is not a valid [`IERC3156FlashBorrower.onFlashLoan`](/contracts/5.x/api/interfaces#IERC3156FlashBorrower-onFlashLoan-address-address-uint256-uint256-bytes-) implementer. + +
+
+ +
-## `ERC4626` +## `ERC20Pausable` - +
```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol"; ``` -Implementation of the ERC-4626 "Tokenized Vault Standard" as defined in -[ERC-4626](https://eips.ethereum.org/EIPS/eip-4626). - -This extension allows the minting and burning of "shares" (represented using the ERC-20 inheritance) in exchange for -underlying "assets" through standardized [`ERC4626.deposit`](#ERC4626-deposit-uint256-address-), [`ERC4626.mint`](#ERC4626-mint-uint256-address-), [`ERC4626.redeem`](#ERC4626-redeem-uint256-address-address-) and [`ERC20Burnable.burn`](#ERC20Burnable-burn-uint256-) 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 -[ERC4626Router](https://github.com/fei-protocol/ERC4626#erc4626router-and-base). - -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 [here](/contracts/5.x/erc4626#inflation-attack). - -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 [ERC-4626 guide](/contracts/5.x/erc4626). -#### [NOTE] -#### When overriding this contract, some elements must be considered: - -* When overriding the behavior of the deposit or withdraw mechanisms, it is recommended to override the internal -functions. Overriding [`ERC4626._deposit`](#ERC4626-_deposit-address-address-uint256-uint256-) automatically affects both [`ERC4626.deposit`](#ERC4626-deposit-uint256-address-) and [`ERC4626.mint`](#ERC4626-mint-uint256-address-). Similarly, overriding [`ERC4626._withdraw`](#ERC4626-_withdraw-address-address-address-uint256-uint256-) -automatically affects both [`ERC4626.withdraw`](#ERC4626-withdraw-uint256-address-address-) and [`ERC4626.redeem`](#ERC4626-redeem-uint256-address-address-). Overall it is not recommended to override the public facing -functions since that could lead to inconsistent behaviors between the [`ERC4626.deposit`](#ERC4626-deposit-uint256-address-) and [`ERC4626.mint`](#ERC4626-mint-uint256-address-) or between [`ERC4626.withdraw`](#ERC4626-withdraw-uint256-address-address-) and -[`ERC4626.redeem`](#ERC4626-redeem-uint256-address-address-), which is documented to have led to loss of funds. - -* Overrides to the deposit or withdraw mechanism must be reflected in the preview functions as well. +ERC-20 token with pausable token transfers, minting and burning. -* [`ERC4626.maxWithdraw`](#ERC4626-maxWithdraw-address-) depends on [`ERC4626.maxRedeem`](#ERC4626-maxRedeem-address-). Therefore, overriding [`ERC4626.maxRedeem`](#ERC4626-maxRedeem-address-) only is enough. On the other hand, -overriding [`ERC4626.maxWithdraw`](#ERC4626-maxWithdraw-address-) only would have no effect on [`ERC4626.maxRedeem`](#ERC4626-maxRedeem-address-), and could create an inconsistency between the two -functions. +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. -* If [`ERC4626.previewRedeem`](#ERC4626-previewRedeem-uint256-) is overridden to revert, [`ERC4626.maxWithdraw`](#ERC4626-maxWithdraw-address-) must be overridden as necessary to ensure it -always return successfully. + +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`](/contracts/5.x/api/utils#Pausable-_pause--) and [`Pausable._unpause`](/contracts/5.x/api/utils#Pausable-_unpause--) internal functions, with appropriate +access control, e.g. using [`AccessControl`](/contracts/5.x/api/access#AccessControl) or [`Ownable`](/contracts/5.x/api/access#Ownable). Not doing so will +make the contract pause mechanism of the contract unreachable, and thus unusable. +

Functions

-- [constructor(asset_)](#ERC4626-constructor-contract-IERC20-) -- [decimals()](#ERC4626-decimals--) -- [asset()](#ERC4626-asset--) -- [totalAssets()](#ERC4626-totalAssets--) -- [convertToShares(assets)](#ERC4626-convertToShares-uint256-) -- [convertToAssets(shares)](#ERC4626-convertToAssets-uint256-) -- [maxDeposit()](#ERC4626-maxDeposit-address-) -- [maxMint()](#ERC4626-maxMint-address-) -- [maxWithdraw(owner)](#ERC4626-maxWithdraw-address-) -- [maxRedeem(owner)](#ERC4626-maxRedeem-address-) -- [previewDeposit(assets)](#ERC4626-previewDeposit-uint256-) -- [previewMint(shares)](#ERC4626-previewMint-uint256-) -- [previewWithdraw(assets)](#ERC4626-previewWithdraw-uint256-) -- [previewRedeem(shares)](#ERC4626-previewRedeem-uint256-) -- [deposit(assets, receiver)](#ERC4626-deposit-uint256-address-) -- [mint(shares, receiver)](#ERC4626-mint-uint256-address-) -- [withdraw(assets, receiver, owner)](#ERC4626-withdraw-uint256-address-address-) -- [redeem(shares, receiver, owner)](#ERC4626-redeem-uint256-address-address-) -- [_convertToShares(assets, rounding)](#ERC4626-_convertToShares-uint256-enum-Math-Rounding-) -- [_convertToAssets(shares, rounding)](#ERC4626-_convertToAssets-uint256-enum-Math-Rounding-) -- [_deposit(caller, receiver, assets, shares)](#ERC4626-_deposit-address-address-uint256-uint256-) -- [_withdraw(caller, receiver, owner, assets, shares)](#ERC4626-_withdraw-address-address-address-uint256-uint256-) -- [_transferIn(from, assets)](#ERC4626-_transferIn-address-uint256-) -- [_transferOut(to, assets)](#ERC4626-_transferOut-address-uint256-) -- [_decimalsOffset()](#ERC4626-_decimalsOffset--) +- [_update(from, to, value)](#ERC20Pausable-_update-address-address-uint256-) +
+Pausable + +- [paused()](#Pausable-paused--) +- [_requireNotPaused()](#Pausable-_requireNotPaused--) +- [_requirePaused()](#Pausable-_requirePaused--) +- [_pause()](#Pausable-_pause--) +- [_unpause()](#Pausable-_unpause--) + +
ERC20 - [name()](#ERC20-name--) - [symbol()](#ERC20-symbol--) +- [decimals()](#ERC20-decimals--) - [totalSupply()](#ERC20-totalSupply--) - [balanceOf(account)](#ERC20-balanceOf-address-) - [transfer(to, value)](#ERC20-transfer-address-uint256-) @@ -2047,7 +1850,6 @@ always return successfully. - [approve(spender, value)](#ERC20-approve-address-uint256-) - [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) - [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) -- [_update(from, to, value)](#ERC20-_update-address-address-uint256-) - [_mint(account, value)](#ERC20-_mint-address-uint256-) - [_burn(account, value)](#ERC20-_burn-address-uint256-) - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) @@ -2062,10 +1864,10 @@ always return successfully.

Events

-IERC4626 +Pausable -- [Deposit(sender, owner, assets, shares)](#IERC4626-Deposit-address-address-uint256-uint256-) -- [Withdraw(sender, receiver, owner, assets, shares)](#IERC4626-Withdraw-address-address-address-uint256-uint256-) +- [Paused(account)](#Pausable-Paused-address-) +- [Unpaused(account)](#Pausable-Unpaused-address-)
@@ -2081,10 +1883,13 @@ always return successfully.

Errors

-- [ERC4626ExceededMaxDeposit(receiver, assets, max)](#ERC4626-ERC4626ExceededMaxDeposit-address-uint256-uint256-) -- [ERC4626ExceededMaxMint(receiver, shares, max)](#ERC4626-ERC4626ExceededMaxMint-address-uint256-uint256-) -- [ERC4626ExceededMaxWithdraw(owner, assets, max)](#ERC4626-ERC4626ExceededMaxWithdraw-address-uint256-uint256-) -- [ERC4626ExceededMaxRedeem(owner, shares, max)](#ERC4626-ERC4626ExceededMaxRedeem-address-uint256-uint256-) +
+Pausable + +- [EnforcedPause()](#Pausable-EnforcedPause--) +- [ExpectedPause()](#Pausable-ExpectedPause--) + +
IERC20Errors @@ -2099,679 +1904,873 @@ always return successfully.
- +
-

constructor(contract IERC20 asset_)

+

_update(address from, address to, uint256 value)

internal

-# +#
-Set the underlying asset contract. This must be an ERC20-compatible contract (ERC-20 or ERC-777). +See [`ERC20._update`](#ERC20-_update-address-address-uint256-). + +Requirements: + +- the contract must not be paused.
- + -
-
-

decimals() → uint8

-
-

public

-# -
-
-
+
-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. +## `ERC20Permit` -See [`IERC20Metadata.decimals`](#IERC20Metadata-decimals--). + + + -
- +```solidity +import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol"; +``` -
-
-

asset() → address

-
-

public

-# -
-
-
+Implementation of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in +[ERC-2612](https://eips.ethereum.org/EIPS/eip-2612). -Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing. +Adds the [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) method, which can be used to change an account's ERC-20 allowance (see [`IERC20.allowance`](#IERC20-allowance-address-address-)) by +presenting a message signed by the account. By not relying on `[`IERC20.approve`](#IERC20-approve-address-uint256-)`, the token holder account doesn't +need to send a transaction, and thus is not required to hold Ether at all. -- MUST be an ERC-20 token contract. -- MUST NOT revert. +
+

Functions

+
+- [constructor(name)](#ERC20Permit-constructor-string-) +- [permit(owner, spender, value, deadline, v, r, s)](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) +- [nonces(owner)](#ERC20Permit-nonces-address-) +- [DOMAIN_SEPARATOR()](#ERC20Permit-DOMAIN_SEPARATOR--) +
+Nonces + +- [_useNonce(owner)](#Nonces-_useNonce-address-) +- [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) + +
+
+EIP712 + +- [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) +- [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) +- [eip712Domain()](#EIP712-eip712Domain--) +- [_EIP712Name()](#EIP712-_EIP712Name--) +- [_EIP712Version()](#EIP712-_EIP712Version--) + +
+
+ERC20 + +- [name()](#ERC20-name--) +- [symbol()](#ERC20-symbol--) +- [decimals()](#ERC20-decimals--) +- [totalSupply()](#ERC20-totalSupply--) +- [balanceOf(account)](#ERC20-balanceOf-address-) +- [transfer(to, value)](#ERC20-transfer-address-uint256-) +- [allowance(owner, spender)](#ERC20-allowance-address-address-) +- [approve(spender, value)](#ERC20-approve-address-uint256-) +- [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) +- [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) +- [_update(from, to, value)](#ERC20-_update-address-address-uint256-) +- [_mint(account, value)](#ERC20-_mint-address-uint256-) +- [_burn(account, value)](#ERC20-_burn-address-uint256-) +- [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) +- [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) +- [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) +
- +
+

Events

+
+
+IERC5267 -
-
-

totalAssets() → uint256

-
-

public

-# +- [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) + +
+
+IERC20 + +- [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) +- [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +
-
-Returns the total amount of the underlying asset that is “managed” by Vault. +
+

Errors

+
+- [ERC2612ExpiredSignature(deadline)](#ERC20Permit-ERC2612ExpiredSignature-uint256-) +- [ERC2612InvalidSigner(signer, owner)](#ERC20Permit-ERC2612InvalidSigner-address-address-) +
+Nonces -- 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. +- [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) + +
+
+IERC20Errors + +- [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) +- [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) +- [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) +- [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) +- [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) +- [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) +
- +
-

convertToShares(uint256 assets) → uint256

+

constructor(string name)

-

public

-# +

internal

+#
-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. +Initializes the [`EIP712`](/contracts/5.x/api/utils/cryptography#EIP712) domain separator using the `name` parameter, and setting `version` to `"1"`. - -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. - +It's a good idea to use the same `name` that is defined as the ERC-20 token name.
- +
-

convertToAssets(uint256 shares) → uint256

+

permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)

public

-# +#
-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. +Sets `value` as the allowance of `spender` over ``owner``'s tokens, +given ``owner``'s signed approval. -- 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. + +The same issues [`IERC20.approve`](#IERC20-approve-address-uint256-) has related to transaction +ordering also applies here. + - -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. +Emits an [`IERC20.Approval`](#IERC20-Approval-address-address-uint256-) event. + +Requirements: + +- `spender` cannot be the zero address. +- `deadline` must be a timestamp in the future. +- `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` +over the EIP712-formatted function arguments. +- the signature must use ``owner``'s current nonce (see [`ERC20Permit.nonces`](#ERC20Permit-nonces-address-)). + +For more information on the signature format, see the +[relevant EIP +section](https://eips.ethereum.org/EIPS/eip-2612#specification). + + +See Security Considerations above.
- +
-

maxDeposit(address) → uint256

+

nonces(address owner) → uint256

public

-# +#
-Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver, -through a deposit call. +Returns the current nonce for `owner`. This value must be +included whenever a signature is generated for [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-). -- 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. +Every successful call to [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) increases ``owner``'s nonce by one. This +prevents a signature from being used multiple times.
- +
-

maxMint(address) → uint256

+

DOMAIN_SEPARATOR() → bytes32

-

public

-# +

external

+#
-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. +Returns the domain separator used in the encoding of the signature for [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-), as defined by [`EIP712`](/contracts/5.x/api/utils/cryptography#EIP712).
- +
-

maxWithdraw(address owner) → uint256

+

ERC2612ExpiredSignature(uint256 deadline)

-

public

-# +

error

+#
-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. +Permit deadline has expired.
- +
-

maxRedeem(address owner) → uint256

+

ERC2612InvalidSigner(address signer, address owner)

-

public

-# +

error

+#
-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. +Mismatched signature.
- + + +
+ +## `ERC20Votes` + + + + -
-
-

previewDeposit(uint256 assets) → uint256

-
-

public

-# -
-
-Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given -current on-chain conditions. +```solidity +import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol"; +``` -- 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. +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. -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. +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`](/contracts/5.x/api/governance#Votes-delegate-address-) function directly, or by providing a signature to be used with [`Votes.delegateBySig`](/contracts/5.x/api/governance#Votes-delegateBySig-address-uint256-uint256-uint8-bytes32-bytes32-). Voting +power can be queried through the public accessors [`Votes.getVotes`](/contracts/5.x/api/governance#Votes-getVotes-address-) and [`Votes.getPastVotes`](/contracts/5.x/api/governance#Votes-getPastVotes-address-uint256-). - +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. -
-
-

previewMint(uint256 shares) → uint256

-
-

public

-# -
-
-
+
+

Functions

+
+- [_maxSupply()](#ERC20Votes-_maxSupply--) +- [_update(from, to, value)](#ERC20Votes-_update-address-address-uint256-) +- [_getVotingUnits(account)](#ERC20Votes-_getVotingUnits-address-) +- [numCheckpoints(account)](#ERC20Votes-numCheckpoints-address-) +- [checkpoints(account, pos)](#ERC20Votes-checkpoints-address-uint32-) +
+Votes -Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given -current on-chain conditions. +- [clock()](#Votes-clock--) +- [CLOCK_MODE()](#Votes-CLOCK_MODE--) +- [_validateTimepoint(timepoint)](#Votes-_validateTimepoint-uint256-) +- [getVotes(account)](#Votes-getVotes-address-) +- [getPastVotes(account, timepoint)](#Votes-getPastVotes-address-uint256-) +- [getPastTotalSupply(timepoint)](#Votes-getPastTotalSupply-uint256-) +- [_getTotalSupply()](#Votes-_getTotalSupply--) +- [delegates(account)](#Votes-delegates-address-) +- [delegate(delegatee)](#Votes-delegate-address-) +- [delegateBySig(delegatee, nonce, expiry, v, r, s)](#Votes-delegateBySig-address-uint256-uint256-uint8-bytes32-bytes32-) +- [_delegate(account, delegatee)](#Votes-_delegate-address-address-) +- [_transferVotingUnits(from, to, amount)](#Votes-_transferVotingUnits-address-address-uint256-) +- [_moveDelegateVotes(from, to, amount)](#Votes-_moveDelegateVotes-address-address-uint256-) +- [_numCheckpoints(account)](#Votes-_numCheckpoints-address-) +- [_checkpoints(account, pos)](#Votes-_checkpoints-address-uint32-) -- 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. +
+
+Nonces - -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. - +- [nonces(owner)](#Nonces-nonces-address-) +- [_useNonce(owner)](#Nonces-_useNonce-address-) +- [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -
-
+
+
+EIP712 - +- [_domainSeparatorV4()](#EIP712-_domainSeparatorV4--) +- [_hashTypedDataV4(structHash)](#EIP712-_hashTypedDataV4-bytes32-) +- [eip712Domain()](#EIP712-eip712Domain--) +- [_EIP712Name()](#EIP712-_EIP712Name--) +- [_EIP712Version()](#EIP712-_EIP712Version--) -
-
-

previewWithdraw(uint256 assets) → uint256

-
-

public

-# +
+
+ERC20 + +- [name()](#ERC20-name--) +- [symbol()](#ERC20-symbol--) +- [decimals()](#ERC20-decimals--) +- [totalSupply()](#ERC20-totalSupply--) +- [balanceOf(account)](#ERC20-balanceOf-address-) +- [transfer(to, value)](#ERC20-transfer-address-uint256-) +- [allowance(owner, spender)](#ERC20-allowance-address-address-) +- [approve(spender, value)](#ERC20-approve-address-uint256-) +- [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) +- [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) +- [_mint(account, value)](#ERC20-_mint-address-uint256-) +- [_burn(account, value)](#ERC20-_burn-address-uint256-) +- [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) +- [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) +- [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) + +
-
-Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block, -given current on-chain conditions. +
+

Events

+
+
+IVotes -- 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. +- [DelegateChanged(delegator, fromDelegate, toDelegate)](#IVotes-DelegateChanged-address-address-address-) +- [DelegateVotesChanged(delegate, previousVotes, newVotes)](#IVotes-DelegateVotesChanged-address-uint256-uint256-) - -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. - +
+
+IERC5267 -
-
+- [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) - +
+
+IERC20 -
-
-

previewRedeem(uint256 shares) → uint256

-
-

public

-# +- [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) +- [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +
-
-Allows an on-chain or off-chain user to simulate the effects of their redemption at the current block, -given current on-chain conditions. +
+

Errors

+
+- [ERC20ExceededSafeSupply(increasedSupply, cap)](#ERC20Votes-ERC20ExceededSafeSupply-uint256-uint256-) +
+Votes -- 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. +- [ERC6372InconsistentClock()](#Votes-ERC6372InconsistentClock--) +- [ERC5805FutureLookup(timepoint, clock)](#Votes-ERC5805FutureLookup-uint256-uint48-) - -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. - +
+
+IVotes + +- [VotesExpiredSignature(expiry)](#IVotes-VotesExpiredSignature-uint256-) + +
+
+Nonces + +- [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) + +
+
+IERC20Errors +- [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) +- [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) +- [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) +- [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) +- [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) +- [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) + +
- +
-

deposit(uint256 assets, address receiver) → uint256

+

_maxSupply() → uint256

-

public

-# +

internal

+#
-Deposit `assets` underlying tokens and send the corresponding number of vault shares (`shares`) to `receiver`. - -- 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). +Maximum token supply. Defaults to `type(uint208).max` (2^208^ - 1). - -most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. - +This maximum is enforced in [`ERC20._update`](#ERC20-_update-address-address-uint256-). 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`](/contracts/5.x/api/governance#Votes). Increasing this value will not +remove the underlying limitation, and will cause [`ERC20._update`](#ERC20-_update-address-address-uint256-) to fail because of a math overflow in +[`Votes._transferVotingUnits`](/contracts/5.x/api/governance#Votes-_transferVotingUnits-address-address-uint256-). 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.
- +
-

mint(uint256 shares, address receiver) → uint256

+

_update(address from, address to, uint256 value)

-

public

-# +

internal

+#
-Mints exactly `shares` vault shares to `receiver` in exchange for `assets` 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). +Move voting power when tokens are transferred. - -most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. - +Emits a [`IVotes.DelegateVotesChanged`](/contracts/5.x/api/governance#IVotes-DelegateVotesChanged-address-uint256-uint256-) event.
- +
-

withdraw(uint256 assets, address receiver, address owner) → uint256

+

_getVotingUnits(address account) → uint256

-

public

-# +

internal

+#
-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). +Returns the voting units of an `account`. -Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed. -Those methods should be performed separately. + +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. +
- +
-

redeem(uint256 shares, address receiver, address owner) → uint256

+

numCheckpoints(address account) → uint32

public

-# +#
-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). - - -some implementations will require pre-requesting to the Vault before a withdrawal may be performed. -Those methods should be performed separately. - +Get number of checkpoints for `account`.
- +
-

_convertToShares(uint256 assets, enum Math.Rounding rounding) → uint256

+

checkpoints(address account, uint32 pos) → struct Checkpoints.Checkpoint208

-

internal

-# +

public

+#
-Internal conversion function (from assets to shares) with support for rounding direction. +Get the `pos`-th checkpoint for `account`.
- +
-

_convertToAssets(uint256 shares, enum Math.Rounding rounding) → uint256

+

ERC20ExceededSafeSupply(uint256 increasedSupply, uint256 cap)

-

internal

-# +

error

+#
-Internal conversion function (from shares to assets) with support for rounding direction. +Total supply cap has been exceeded, introducing a risk of votes overflowing.
- + + +
+ +## `ERC20Wrapper` + + + + -
-
-

_deposit(address caller, address receiver, uint256 assets, uint256 shares)

-
-

internal

-# -
-
-Deposit/mint common workflow. +```solidity +import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Wrapper.sol"; +``` + +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`](#ERC20Votes) will allow the +wrapping of an existing "basic" ERC-20 into a governance token. + + +Any mechanism in which the underlying token changes the [`ERC20.balanceOf`](#ERC20-balanceOf-address-) 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 [`ERC20Wrapper._recover`](#ERC20Wrapper-_recover-address-) +for recovering value accrued to the wrapper. + + +
+

Functions

+
+- [constructor(underlyingToken)](#ERC20Wrapper-constructor-contract-IERC20-) +- [decimals()](#ERC20Wrapper-decimals--) +- [underlying()](#ERC20Wrapper-underlying--) +- [depositFor(account, value)](#ERC20Wrapper-depositFor-address-uint256-) +- [withdrawTo(account, value)](#ERC20Wrapper-withdrawTo-address-uint256-) +- [_recover(account)](#ERC20Wrapper-_recover-address-) +
+ERC20 + +- [name()](#ERC20-name--) +- [symbol()](#ERC20-symbol--) +- [totalSupply()](#ERC20-totalSupply--) +- [balanceOf(account)](#ERC20-balanceOf-address-) +- [transfer(to, value)](#ERC20-transfer-address-uint256-) +- [allowance(owner, spender)](#ERC20-allowance-address-address-) +- [approve(spender, value)](#ERC20-approve-address-uint256-) +- [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) +- [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) +- [_update(from, to, value)](#ERC20-_update-address-address-uint256-) +- [_mint(account, value)](#ERC20-_mint-address-uint256-) +- [_burn(account, value)](#ERC20-_burn-address-uint256-) +- [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) +- [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) +- [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) + +
- +
+

Events

+
+
+IERC20 -
-
-

_withdraw(address caller, address receiver, address owner, uint256 assets, uint256 shares)

-
-

internal

-# +- [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) +- [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + +
-
-Withdraw/redeem common workflow. +
+

Errors

+
+- [ERC20InvalidUnderlying(token)](#ERC20Wrapper-ERC20InvalidUnderlying-address-) +
+IERC20Errors + +- [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) +- [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) +- [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) +- [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) +- [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) +- [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) +
- +
-

_transferIn(address from, uint256 assets)

+

constructor(contract IERC20 underlyingToken)

internal

-# +#
-Performs a transfer in of underlying assets. The default implementation uses `SafeERC20`. Used by [`ERC4626._deposit`](#ERC4626-_deposit-address-address-uint256-uint256-). -
- +
-

_transferOut(address to, uint256 assets)

+

decimals() → uint8

-

internal

-# +

public

+#
-Performs a transfer out of underlying assets. The default implementation uses `SafeERC20`. Used by [`ERC4626._withdraw`](#ERC4626-_withdraw-address-address-address-uint256-uint256-). -
- +
-

_decimalsOffset() → uint8

+

underlying() → contract IERC20

-

internal

-# +

public

+#
+Returns the address of the underlying ERC-20 token that is being wrapped. +
- +
-

ERC4626ExceededMaxDeposit(address receiver, uint256 assets, uint256 max)

+

depositFor(address account, uint256 value) → bool

-

error

-# +

public

+#
-Attempted to deposit more assets than the max amount for `receiver`. +Allow a user to deposit underlying tokens and mint the corresponding number of wrapped tokens.
- +
-

ERC4626ExceededMaxMint(address receiver, uint256 shares, uint256 max)

+

withdrawTo(address account, uint256 value) → bool

-

error

-# +

public

+#
-Attempted to mint more shares than the max amount for `receiver`. +Allow a user to burn a number of wrapped tokens and withdraw the corresponding number of underlying tokens.
- +
-

ERC4626ExceededMaxWithdraw(address owner, uint256 assets, uint256 max)

+

_recover(address account) → uint256

-

error

-# +

internal

+#
-Attempted to withdraw more assets than the max amount for `owner`. +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.
- +
-

ERC4626ExceededMaxRedeem(address owner, uint256 shares, uint256 max)

+

ERC20InvalidUnderlying(address token)

error

-# +#
-Attempted to redeem more shares than the max amount for `owner`. +The underlying token couldn't be wrapped.
- +
-## `IERC20Metadata` +## `ERC4626` - +
```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol"; ``` -Interface for the optional metadata functions from the ERC-20 standard. +Implementation of the ERC-4626 "Tokenized Vault Standard" as defined in +[ERC-4626](https://eips.ethereum.org/EIPS/eip-4626). + +This extension allows the minting and burning of "shares" (represented using the ERC-20 inheritance) in exchange for +underlying "assets" through standardized [`ERC4626.deposit`](#ERC4626-deposit-uint256-address-), [`ERC4626.mint`](#ERC4626-mint-uint256-address-), [`ERC4626.redeem`](#ERC4626-redeem-uint256-address-address-) and [`ERC20Burnable.burn`](#ERC20Burnable-burn-uint256-) 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 +[ERC4626Router](https://github.com/fei-protocol/ERC4626#erc4626router-and-base). + +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 [here](/contracts/5.x/erc4626#inflation-attack). + +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 [ERC-4626 guide](/contracts/5.x/erc4626). +#### [NOTE] +#### When overriding this contract, some elements must be considered: + +* When overriding the behavior of the deposit or withdraw mechanisms, it is recommended to override the internal +functions. Overriding [`ERC4626._deposit`](#ERC4626-_deposit-address-address-uint256-uint256-) automatically affects both [`ERC4626.deposit`](#ERC4626-deposit-uint256-address-) and [`ERC4626.mint`](#ERC4626-mint-uint256-address-). Similarly, overriding [`ERC4626._withdraw`](#ERC4626-_withdraw-address-address-address-uint256-uint256-) +automatically affects both [`ERC4626.withdraw`](#ERC4626-withdraw-uint256-address-address-) and [`ERC4626.redeem`](#ERC4626-redeem-uint256-address-address-). Overall it is not recommended to override the public facing +functions since that could lead to inconsistent behaviors between the [`ERC4626.deposit`](#ERC4626-deposit-uint256-address-) and [`ERC4626.mint`](#ERC4626-mint-uint256-address-) or between [`ERC4626.withdraw`](#ERC4626-withdraw-uint256-address-address-) and +[`ERC4626.redeem`](#ERC4626-redeem-uint256-address-address-), which is documented to have led to loss of funds. + +* Overrides to the deposit or withdraw mechanism must be reflected in the preview functions as well. + +* [`ERC4626.maxWithdraw`](#ERC4626-maxWithdraw-address-) depends on [`ERC4626.maxRedeem`](#ERC4626-maxRedeem-address-). Therefore, overriding [`ERC4626.maxRedeem`](#ERC4626-maxRedeem-address-) only is enough. On the other hand, +overriding [`ERC4626.maxWithdraw`](#ERC4626-maxWithdraw-address-) only would have no effect on [`ERC4626.maxRedeem`](#ERC4626-maxRedeem-address-), and could create an inconsistency between the two +functions. + +* If [`ERC4626.previewRedeem`](#ERC4626-previewRedeem-uint256-) is overridden to revert, [`ERC4626.maxWithdraw`](#ERC4626-maxWithdraw-address-) must be overridden as necessary to ensure it +always return successfully.

Functions

-- [name()](#IERC20Metadata-name--) -- [symbol()](#IERC20Metadata-symbol--) -- [decimals()](#IERC20Metadata-decimals--) +- [constructor(asset_)](#ERC4626-constructor-contract-IERC20-) +- [decimals()](#ERC4626-decimals--) +- [asset()](#ERC4626-asset--) +- [totalAssets()](#ERC4626-totalAssets--) +- [convertToShares(assets)](#ERC4626-convertToShares-uint256-) +- [convertToAssets(shares)](#ERC4626-convertToAssets-uint256-) +- [maxDeposit()](#ERC4626-maxDeposit-address-) +- [maxMint()](#ERC4626-maxMint-address-) +- [maxWithdraw(owner)](#ERC4626-maxWithdraw-address-) +- [maxRedeem(owner)](#ERC4626-maxRedeem-address-) +- [previewDeposit(assets)](#ERC4626-previewDeposit-uint256-) +- [previewMint(shares)](#ERC4626-previewMint-uint256-) +- [previewWithdraw(assets)](#ERC4626-previewWithdraw-uint256-) +- [previewRedeem(shares)](#ERC4626-previewRedeem-uint256-) +- [deposit(assets, receiver)](#ERC4626-deposit-uint256-address-) +- [mint(shares, receiver)](#ERC4626-mint-uint256-address-) +- [withdraw(assets, receiver, owner)](#ERC4626-withdraw-uint256-address-address-) +- [redeem(shares, receiver, owner)](#ERC4626-redeem-uint256-address-address-) +- [_convertToShares(assets, rounding)](#ERC4626-_convertToShares-uint256-enum-Math-Rounding-) +- [_convertToAssets(shares, rounding)](#ERC4626-_convertToAssets-uint256-enum-Math-Rounding-) +- [_deposit(caller, receiver, assets, shares)](#ERC4626-_deposit-address-address-uint256-uint256-) +- [_withdraw(caller, receiver, owner, assets, shares)](#ERC4626-_withdraw-address-address-address-uint256-uint256-) +- [_transferIn(from, assets)](#ERC4626-_transferIn-address-uint256-) +- [_transferOut(to, assets)](#ERC4626-_transferOut-address-uint256-) +- [_decimalsOffset()](#ERC4626-_decimalsOffset--)
-IERC20 +ERC20 -- [totalSupply()](#IERC20-totalSupply--) -- [balanceOf(account)](#IERC20-balanceOf-address-) -- [transfer(to, value)](#IERC20-transfer-address-uint256-) -- [allowance(owner, spender)](#IERC20-allowance-address-address-) -- [approve(spender, value)](#IERC20-approve-address-uint256-) -- [transferFrom(from, to, value)](#IERC20-transferFrom-address-address-uint256-) +- [name()](#ERC20-name--) +- [symbol()](#ERC20-symbol--) +- [totalSupply()](#ERC20-totalSupply--) +- [balanceOf(account)](#ERC20-balanceOf-address-) +- [transfer(to, value)](#ERC20-transfer-address-uint256-) +- [allowance(owner, spender)](#ERC20-allowance-address-address-) +- [approve(spender, value)](#ERC20-approve-address-uint256-) +- [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) +- [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) +- [_update(from, to, value)](#ERC20-_update-address-address-uint256-) +- [_mint(account, value)](#ERC20-_mint-address-uint256-) +- [_burn(account, value)](#ERC20-_burn-address-uint256-) +- [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) +- [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) +- [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-)
@@ -2781,6 +2780,13 @@ Interface for the optional metadata functions from the ERC-20 standard.

Events

+IERC4626 + +- [Deposit(sender, owner, assets, shares)](#IERC4626-Deposit-address-address-uint256-uint256-) +- [Withdraw(sender, receiver, owner, assets, shares)](#IERC4626-Withdraw-address-address-address-uint256-uint256-) + +
+
IERC20 - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) @@ -2790,734 +2796,700 @@ Interface for the optional metadata functions from the ERC-20 standard.
- +
+

Errors

+
+- [ERC4626ExceededMaxDeposit(receiver, assets, max)](#ERC4626-ERC4626ExceededMaxDeposit-address-uint256-uint256-) +- [ERC4626ExceededMaxMint(receiver, shares, max)](#ERC4626-ERC4626ExceededMaxMint-address-uint256-uint256-) +- [ERC4626ExceededMaxWithdraw(owner, assets, max)](#ERC4626-ERC4626ExceededMaxWithdraw-address-uint256-uint256-) +- [ERC4626ExceededMaxRedeem(owner, shares, max)](#ERC4626-ERC4626ExceededMaxRedeem-address-uint256-uint256-) +
+IERC20Errors + +- [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) +- [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) +- [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) +- [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) +- [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) +- [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) + +
+
+
+ +
-

name() → string

+

constructor(contract IERC20 asset_)

-

external

-# +

internal

+#
-Returns the name of the token. +Set the underlying asset contract. This must be an ERC20-compatible contract (ERC-20 or ERC-777).
- +
-

symbol() → string

+

decimals() → uint8

-

external

-# +

public

+# +
+
+
+ +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`](#IERC20Metadata-decimals--). + +
+
+ + + +
+
+

asset() → address

+
+

public

+#
-Returns the symbol of the token. +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.
- +
-

decimals() → uint8

+

totalAssets() → uint256

-

external

-# +

public

+#
-Returns the decimals places of the token. +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.
- - -
- -## `IERC20Permit` - - - - + +
+
+

convertToShares(uint256 assets) → uint256

+
+

public

+#
+
+
-```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol"; -``` - -Interface of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in -[ERC-2612](https://eips.ethereum.org/EIPS/eip-2612). - -Adds the [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) method, which can be used to change an account's ERC-20 allowance (see [`IERC20.allowance`](#IERC20-allowance-address-address-)) by -presenting a message signed by the account. By not relying on [`IERC20.approve`](#IERC20-approve-address-uint256-), 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: - -```solidity -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); - ... -} -``` +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. -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`](#SafeERC20-safeTransferFrom-contract-IERC20-address-address-uint256-)). +- 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. -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. + +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. + -
-

Functions

-
-- [permit(owner, spender, value, deadline, v, r, s)](#IERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) -- [nonces(owner)](#IERC20Permit-nonces-address-) -- [DOMAIN_SEPARATOR()](#IERC20Permit-DOMAIN_SEPARATOR--)
- +
-

permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)

+

convertToAssets(uint256 shares) → uint256

-

external

-# +

public

+#
-Sets `value` as the allowance of `spender` over ``owner``'s tokens, -given ``owner``'s signed approval. - - -The same issues [`IERC20.approve`](#IERC20-approve-address-uint256-) has related to transaction -ordering also applies here. - - -Emits an [`IERC20.Approval`](#IERC20-Approval-address-address-uint256-) event. - -Requirements: - -- `spender` cannot be the zero address. -- `deadline` must be a timestamp in the future. -- `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` -over the EIP712-formatted function arguments. -- the signature must use ``owner``'s current nonce (see [`ERC20Permit.nonces`](#ERC20Permit-nonces-address-)). +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. -For more information on the signature format, see the -[relevant EIP -section](https://eips.ethereum.org/EIPS/eip-2612#specification). +- 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. - -See Security Considerations above. + +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.
- +
-

nonces(address owner) → uint256

+

maxDeposit(address) → uint256

-

external

-# +

public

+#
-Returns the current nonce for `owner`. This value must be -included whenever a signature is generated for [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-). +Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver, +through a deposit call. -Every successful call to [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) increases ``owner``'s nonce by one. This -prevents a signature from being used multiple times. +- 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.
- +
-

DOMAIN_SEPARATOR() → bytes32

+

maxMint(address) → uint256

-

external

-# +

public

+#
-Returns the domain separator used in the encoding of the signature for [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-), as defined by [`EIP712`](/contracts/5.x/api/utils/cryptography#EIP712). +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.
- + -
+
+
+

maxWithdraw(address owner) → uint256

+
+

public

+# +
+
+
-## `ERC20TemporaryApproval` +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. +
-```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20TemporaryApproval.sol"; -``` - -Extension of [`ERC20`](#ERC20) that adds support for temporary allowances following ERC-7674. - - -This is a draft contract. The corresponding ERC is still subject to changes. - + -_Available since v5.1._ +
+
+

maxRedeem(address owner) → uint256

+
+

public

+# +
+
+
-
-

Functions

-
-- [allowance(owner, spender)](#ERC20TemporaryApproval-allowance-address-address-) -- [_temporaryAllowance(owner, spender)](#ERC20TemporaryApproval-_temporaryAllowance-address-address-) -- [temporaryApprove(spender, value)](#ERC20TemporaryApproval-temporaryApprove-address-uint256-) -- [_temporaryApprove(owner, spender, value)](#ERC20TemporaryApproval-_temporaryApprove-address-address-uint256-) -- [_spendAllowance(owner, spender, value)](#ERC20TemporaryApproval-_spendAllowance-address-address-uint256-) -
-ERC20 +Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, +through a redeem call. -- [name()](#ERC20-name--) -- [symbol()](#ERC20-symbol--) -- [decimals()](#ERC20-decimals--) -- [totalSupply()](#ERC20-totalSupply--) -- [balanceOf(account)](#ERC20-balanceOf-address-) -- [transfer(to, value)](#ERC20-transfer-address-uint256-) -- [approve(spender, value)](#ERC20-approve-address-uint256-) -- [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) -- [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) -- [_update(from, to, value)](#ERC20-_update-address-address-uint256-) -- [_mint(account, value)](#ERC20-_mint-address-uint256-) -- [_burn(account, value)](#ERC20-_burn-address-uint256-) -- [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) -- [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) +- 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. -
-
-

Events

-
-
-IERC20 - -- [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) -- [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + -
+
+
+

previewDeposit(uint256 assets) → uint256

+
+

public

+#
+
-
-

Errors

-
-
-IERC20Errors +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. -- [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) -- [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) -- [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) -- [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) -- [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) -- [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) + +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. + -
- +
-

allowance(address owner, address spender) → uint256

+

previewMint(uint256 shares) → uint256

public

-# +#
-[`ERC20.allowance`](#ERC20-allowance-address-address-) 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. +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. + + +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. +
- +
-

_temporaryAllowance(address owner, address spender) → uint256

+

previewWithdraw(uint256 assets) → uint256

-

internal

-# +

public

+#
-Internal getter for the current temporary allowance that `spender` has over `owner` tokens. +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. + + +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. +
- +
-

temporaryApprove(address spender, uint256 value) → bool

+

previewRedeem(uint256 shares) → uint256

public

-# +#
-Alternative to [`ERC20.approve`](#ERC20-approve-address-uint256-) 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. +Allows an on-chain or off-chain user to simulate the effects of their redemption at the current block, +given current on-chain conditions. -Requirements: -- `spender` cannot be the zero address. +- 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. -Does NOT emit an [`IERC20.Approval`](#IERC20-Approval-address-address-uint256-) event. + +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. +
- +
-

_temporaryApprove(address owner, address spender, uint256 value)

+

deposit(uint256 assets, address receiver) → uint256

-

internal

-# +

public

+#
-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. +Deposit `assets` underlying tokens and send the corresponding number of vault shares (`shares`) to `receiver`. -Requirements: -- `owner` cannot be the zero address. -- `spender` cannot be the zero address. +- 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). -Does NOT emit an [`IERC20.Approval`](#IERC20-Approval-address-address-uint256-) event. + +most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. +
- +
-

_spendAllowance(address owner, address spender, uint256 value)

+

mint(uint256 shares, address receiver) → uint256

-

internal

-# +

public

+#
-[`ERC20._spendAllowance`](#ERC20-_spendAllowance-address-address-uint256-) override that consumes the temporary allowance (if any) before eventually falling back -to consuming the persistent allowance. +Mints exactly `shares` vault shares to `receiver` in exchange for `assets` 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). + -This function skips calling `super._spendAllowance` if the temporary allowance -is enough to cover the spending. +most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
- - -
- -## `SafeERC20` - - - - + +
+
+

withdraw(uint256 assets, address receiver, address owner) → uint256

+
+

public

+#
+
+
-```solidity -import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; -``` +Burns shares from owner and sends exactly assets of underlying tokens to receiver. -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. +- 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). -
-

Functions

-
-- [safeTransfer(token, to, value)](#SafeERC20-safeTransfer-contract-IERC20-address-uint256-) -- [safeTransferFrom(token, from, to, value)](#SafeERC20-safeTransferFrom-contract-IERC20-address-address-uint256-) -- [trySafeTransfer(token, to, value)](#SafeERC20-trySafeTransfer-contract-IERC20-address-uint256-) -- [trySafeTransferFrom(token, from, to, value)](#SafeERC20-trySafeTransferFrom-contract-IERC20-address-address-uint256-) -- [safeIncreaseAllowance(token, spender, value)](#SafeERC20-safeIncreaseAllowance-contract-IERC20-address-uint256-) -- [safeDecreaseAllowance(token, spender, requestedDecrease)](#SafeERC20-safeDecreaseAllowance-contract-IERC20-address-uint256-) -- [forceApprove(token, spender, value)](#SafeERC20-forceApprove-contract-IERC20-address-uint256-) -- [transferAndCallRelaxed(token, to, value, data)](#SafeERC20-transferAndCallRelaxed-contract-IERC1363-address-uint256-bytes-) -- [transferFromAndCallRelaxed(token, from, to, value, data)](#SafeERC20-transferFromAndCallRelaxed-contract-IERC1363-address-address-uint256-bytes-) -- [approveAndCallRelaxed(token, to, value, data)](#SafeERC20-approveAndCallRelaxed-contract-IERC1363-address-uint256-bytes-) -
-
+Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed. +Those methods should be performed separately. -
-

Errors

-
-- [SafeERC20FailedOperation(token)](#SafeERC20-SafeERC20FailedOperation-address-) -- [SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease)](#SafeERC20-SafeERC20FailedDecreaseAllowance-address-uint256-uint256-)
- +
-

safeTransfer(contract IERC20 token, address to, uint256 value)

+

redeem(uint256 shares, address receiver, address owner) → uint256

-

internal

-# +

public

+#
-Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, -non-reverting calls are assumed to be successful. +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). + + +some implementations will require pre-requesting to the Vault before a withdrawal may be performed. +Those methods should be performed separately. +
- +
-

safeTransferFrom(contract IERC20 token, address from, address to, uint256 value)

+

_convertToShares(uint256 assets, enum Math.Rounding rounding) → uint256

internal

-# +#
-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. +Internal conversion function (from assets to shares) with support for rounding direction.
- +
-

trySafeTransfer(contract IERC20 token, address to, uint256 value) → bool

+

_convertToAssets(uint256 shares, enum Math.Rounding rounding) → uint256

internal

-# +#
-Variant of [`SafeERC20.safeTransfer`](#SafeERC20-safeTransfer-contract-IERC20-address-uint256-) that returns a bool instead of reverting if the operation is not successful. +Internal conversion function (from shares to assets) with support for rounding direction.
- +
-

trySafeTransferFrom(contract IERC20 token, address from, address to, uint256 value) → bool

+

_deposit(address caller, address receiver, uint256 assets, uint256 shares)

internal

-# +#
-Variant of [`SafeERC20.safeTransferFrom`](#SafeERC20-safeTransferFrom-contract-IERC20-address-address-uint256-) that returns a bool instead of reverting if the operation is not successful. +Deposit/mint common workflow.
- +
-

safeIncreaseAllowance(contract IERC20 token, address spender, uint256 value)

+

_withdraw(address caller, address receiver, address owner, uint256 assets, uint256 shares)

internal

-# -
-
-
- -Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, -non-reverting calls are assumed to be successful. - - -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 [`SafeERC20.safeIncreaseAllowance`](#SafeERC20-safeIncreaseAllowance-contract-IERC20-address-uint256-) or [`SafeERC20.safeDecreaseAllowance`](#SafeERC20-safeDecreaseAllowance-contract-IERC20-address-uint256-) operation on a token contract -that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior. - +# +
+
+
+ +Withdraw/redeem common workflow.
- +
-

safeDecreaseAllowance(contract IERC20 token, address spender, uint256 requestedDecrease)

+

_transferIn(address from, uint256 assets)

internal

-# +#
-Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no -value, non-reverting calls are assumed to be successful. - - -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 [`SafeERC20.safeIncreaseAllowance`](#SafeERC20-safeIncreaseAllowance-contract-IERC20-address-uint256-) or [`SafeERC20.safeDecreaseAllowance`](#SafeERC20-safeDecreaseAllowance-contract-IERC20-address-uint256-) operation on a token contract -that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior. - +Performs a transfer in of underlying assets. The default implementation uses `SafeERC20`. Used by [`ERC4626._deposit`](#ERC4626-_deposit-address-address-uint256-uint256-).
- +
-

forceApprove(contract IERC20 token, address spender, uint256 value)

+

_transferOut(address to, uint256 assets)

internal

-# +#
-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. - - -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. - +Performs a transfer out of underlying assets. The default implementation uses `SafeERC20`. Used by [`ERC4626._withdraw`](#ERC4626-_withdraw-address-address-address-uint256-uint256-).
- +
-

transferAndCallRelaxed(contract IERC1363 token, address to, uint256 value, bytes data)

+

_decimalsOffset() → uint8

internal

-# +#
-Performs an [`ERC1363`](#ERC1363) transferAndCall, with a fallback to the simple [`ERC20`](#ERC20) transfer if the target has no -code. This can be used to implement an [`ERC721`](/contracts/5.x/api/token/ERC721#ERC721)-like safe transfer that relies on [`ERC1363`](#ERC1363) checks when -targeting contracts. - -Reverts if the returned value is other than `true`. -
- +
-

transferFromAndCallRelaxed(contract IERC1363 token, address from, address to, uint256 value, bytes data)

+

ERC4626ExceededMaxDeposit(address receiver, uint256 assets, uint256 max)

-

internal

-# +

error

+#
-Performs an [`ERC1363`](#ERC1363) transferFromAndCall, with a fallback to the simple [`ERC20`](#ERC20) transferFrom if the target -has no code. This can be used to implement an [`ERC721`](/contracts/5.x/api/token/ERC721#ERC721)-like safe transfer that relies on [`ERC1363`](#ERC1363) checks when -targeting contracts. - -Reverts if the returned value is other than `true`. +Attempted to deposit more assets than the max amount for `receiver`.
- +
-

approveAndCallRelaxed(contract IERC1363 token, address to, uint256 value, bytes data)

+

ERC4626ExceededMaxMint(address receiver, uint256 shares, uint256 max)

-

internal

-# +

error

+#
-Performs an [`ERC1363`](#ERC1363) approveAndCall, with a fallback to the simple [`ERC20`](#ERC20) approve if the target has no -code. This can be used to implement an [`ERC721`](/contracts/5.x/api/token/ERC721#ERC721)-like safe transfer that rely on [`ERC1363`](#ERC1363) checks when -targeting contracts. - - -When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as [`SafeERC20.forceApprove`](#SafeERC20-forceApprove-contract-IERC20-address-uint256-). -Oppositely, when the recipient address (`to`) has code, this function only attempts to call [`ERC1363.approveAndCall`](#ERC1363-approveAndCall-address-uint256-bytes-) -once without retrying, and relies on the returned value to be true. - - -Reverts if the returned value is other than `true`. +Attempted to mint more shares than the max amount for `receiver`.
- +
-

SafeERC20FailedOperation(address token)

+

ERC4626ExceededMaxWithdraw(address owner, uint256 assets, uint256 max)

error

-# +#
-An operation with an ERC-20 token failed. +Attempted to withdraw more assets than the max amount for `owner`.
- +
-

SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease)

+

ERC4626ExceededMaxRedeem(address owner, uint256 shares, uint256 max)

error

-# +#
-Indicates a failed `decreaseAllowance` request. +Attempted to redeem more shares than the max amount for `owner`.
- +
-## `ERC1363` +## `IERC20Metadata` - +
```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC1363.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; ``` -Extension of [`ERC20`](#ERC20) tokens that adds support for code execution after transfers and approvals -on recipient contracts. Calls after transfers are enabled through the [`ERC1363.transferAndCall`](#ERC1363-transferAndCall-address-uint256-bytes-) and -[`ERC1363.transferFromAndCall`](#ERC1363-transferFromAndCall-address-address-uint256-bytes-) methods while calls after approvals can be made with [`ERC1363.approveAndCall`](#ERC1363-approveAndCall-address-uint256-bytes-) - -_Available since v5.1._ +Interface for the optional metadata functions from the ERC-20 standard.

Functions

-- [supportsInterface(interfaceId)](#ERC1363-supportsInterface-bytes4-) -- [transferAndCall(to, value)](#ERC1363-transferAndCall-address-uint256-) -- [transferAndCall(to, value, data)](#ERC1363-transferAndCall-address-uint256-bytes-) -- [transferFromAndCall(from, to, value)](#ERC1363-transferFromAndCall-address-address-uint256-) -- [transferFromAndCall(from, to, value, data)](#ERC1363-transferFromAndCall-address-address-uint256-bytes-) -- [approveAndCall(spender, value)](#ERC1363-approveAndCall-address-uint256-) -- [approveAndCall(spender, value, data)](#ERC1363-approveAndCall-address-uint256-bytes-) +- [name()](#IERC20Metadata-name--) +- [symbol()](#IERC20Metadata-symbol--) +- [decimals()](#IERC20Metadata-decimals--)
-ERC20 +IERC20 -- [name()](#ERC20-name--) -- [symbol()](#ERC20-symbol--) -- [decimals()](#ERC20-decimals--) -- [totalSupply()](#ERC20-totalSupply--) -- [balanceOf(account)](#ERC20-balanceOf-address-) -- [transfer(to, value)](#ERC20-transfer-address-uint256-) -- [allowance(owner, spender)](#ERC20-allowance-address-address-) -- [approve(spender, value)](#ERC20-approve-address-uint256-) -- [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) -- [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) -- [_update(from, to, value)](#ERC20-_update-address-address-uint256-) -- [_mint(account, value)](#ERC20-_mint-address-uint256-) -- [_burn(account, value)](#ERC20-_burn-address-uint256-) -- [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) -- [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) -- [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) +- [totalSupply()](#IERC20-totalSupply--) +- [balanceOf(account)](#IERC20-balanceOf-address-) +- [transfer(to, value)](#IERC20-transfer-address-uint256-) +- [allowance(owner, spender)](#IERC20-allowance-address-address-) +- [approve(spender, value)](#IERC20-approve-address-uint256-) +- [transferFrom(from, to, value)](#IERC20-transferFrom-address-address-uint256-)
@@ -3536,256 +3508,229 @@ _Available since v5.1._
-
-

Errors

-
-- [ERC1363TransferFailed(receiver, value)](#ERC1363-ERC1363TransferFailed-address-uint256-) -- [ERC1363TransferFromFailed(sender, receiver, value)](#ERC1363-ERC1363TransferFromFailed-address-address-uint256-) -- [ERC1363ApproveFailed(spender, value)](#ERC1363-ERC1363ApproveFailed-address-uint256-) -
-IERC20Errors - -- [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) -- [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) -- [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) -- [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) -- [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) -- [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) - -
-
-
- - +
-

supportsInterface(bytes4 interfaceId) → bool

+

name() → string

-

public

-# +

external

+#
-Returns true if this contract implements the interface defined by -`interfaceId`. See the corresponding -[ERC section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) -to learn more about how these ids are created. - -This function call must use less than 30 000 gas. +Returns the name of the token.
- +
-

transferAndCall(address to, uint256 value) → bool

+

symbol() → string

-

public

-# +

external

+#
-Moves a `value` amount of tokens from the caller's account to `to` -and then calls [`IERC1363Receiver.onTransferReceived`](/contracts/5.x/api/interfaces#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) on `to`. Returns a flag that indicates -if the call succeeded. - -Requirements: - -- The target has code (i.e. is a contract). -- The target `to` must implement the [`IERC1363Receiver`](/contracts/5.x/api/interfaces#IERC1363Receiver) interface. -- The target must return the [`IERC1363Receiver.onTransferReceived`](/contracts/5.x/api/interfaces#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) selector to accept the transfer. -- The internal [`ERC20.transfer`](#ERC20-transfer-address-uint256-) must succeed (returned `true`). +Returns the symbol of the token.
- +
-

transferAndCall(address to, uint256 value, bytes data) → bool

+

decimals() → uint8

-

public

-# +

external

+#
-Variant of [`ERC1363.transferAndCall`](#ERC1363-transferAndCall-address-uint256-bytes-) that accepts an additional `data` parameter with -no specified format. +Returns the decimals places of the token.
- - -
-
-

transferFromAndCall(address from, address to, uint256 value) → bool

-
-

public

-# -
-
-
+ -Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism -and then calls [`IERC1363Receiver.onTransferReceived`](/contracts/5.x/api/interfaces#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) on `to`. Returns a flag that indicates -if the call succeeded. +
-Requirements: +## `IERC20Permit` -- The target has code (i.e. is a contract). -- The target `to` must implement the [`IERC1363Receiver`](/contracts/5.x/api/interfaces#IERC1363Receiver) interface. -- The target must return the [`IERC1363Receiver.onTransferReceived`](/contracts/5.x/api/interfaces#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) selector to accept the transfer. -- The internal [`ERC20.transferFrom`](#ERC20-transferFrom-address-address-uint256-) must succeed (returned `true`). + + + -
- +```solidity +import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol"; +``` -
-
-

transferFromAndCall(address from, address to, uint256 value, bytes data) → bool

-
-

public

-# -
-
-
+Interface of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in +[ERC-2612](https://eips.ethereum.org/EIPS/eip-2612). -Variant of [`ERC1363.transferFromAndCall`](#ERC1363-transferFromAndCall-address-address-uint256-bytes-) that accepts an additional `data` parameter with -no specified format. +Adds the [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) method, which can be used to change an account's ERC-20 allowance (see [`IERC20.allowance`](#IERC20-allowance-address-address-)) by +presenting a message signed by the account. By not relying on [`IERC20.approve`](#IERC20-approve-address-uint256-), 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: -
-
-

approveAndCall(address spender, uint256 value) → bool

-
-

public

-# -
-
-
+```solidity +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); +} -Sets a `value` amount of tokens as the allowance of `spender` over the -caller's tokens and then calls [`IERC1363Spender.onApprovalReceived`](/contracts/5.x/api/interfaces#IERC1363Spender-onApprovalReceived-address-uint256-bytes-) on `spender`. -Returns a flag that indicates if the call succeeded. +function doThing(..., uint256 value) public { + token.safeTransferFrom(msg.sender, address(this), value); + ... +} +``` -Requirements: +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`](#SafeERC20-safeTransferFrom-contract-IERC20-address-address-uint256-)). -- The target has code (i.e. is a contract). -- The target `spender` must implement the [`IERC1363Spender`](/contracts/5.x/api/interfaces#IERC1363Spender) interface. -- The target must return the [`IERC1363Spender.onApprovalReceived`](/contracts/5.x/api/interfaces#IERC1363Spender-onApprovalReceived-address-uint256-bytes-) selector to accept the approval. -- The internal [`ERC20.approve`](#ERC20-approve-address-uint256-) must succeed (returned `true`). +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(owner, spender, value, deadline, v, r, s)](#IERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) +- [nonces(owner)](#IERC20Permit-nonces-address-) +- [DOMAIN_SEPARATOR()](#IERC20Permit-DOMAIN_SEPARATOR--)
- +
-

approveAndCall(address spender, uint256 value, bytes data) → bool

+

permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)

-

public

-# +

external

+#
-Variant of [`ERC1363.approveAndCall`](#ERC1363-approveAndCall-address-uint256-bytes-) that accepts an additional `data` parameter with -no specified format. +Sets `value` as the allowance of `spender` over ``owner``'s tokens, +given ``owner``'s signed approval. -
-
+ +The same issues [`IERC20.approve`](#IERC20-approve-address-uint256-) has related to transaction +ordering also applies here. + - +Emits an [`IERC20.Approval`](#IERC20-Approval-address-address-uint256-) event. -
-
-

ERC1363TransferFailed(address receiver, uint256 value)

-
-

error

-# -
-
-
+Requirements: -Indicates a failure within the [`ERC20.transfer`](#ERC20-transfer-address-uint256-) part of a transferAndCall operation. +- `spender` cannot be the zero address. +- `deadline` must be a timestamp in the future. +- `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` +over the EIP712-formatted function arguments. +- the signature must use ``owner``'s current nonce (see [`ERC20Permit.nonces`](#ERC20Permit-nonces-address-)). + +For more information on the signature format, see the +[relevant EIP +section](https://eips.ethereum.org/EIPS/eip-2612#specification). + + +See Security Considerations above. +
- +
-

ERC1363TransferFromFailed(address sender, address receiver, uint256 value)

+

nonces(address owner) → uint256

-

error

-# +

external

+#
-Indicates a failure within the [`ERC20.transferFrom`](#ERC20-transferFrom-address-address-uint256-) part of a transferFromAndCall operation. +Returns the current nonce for `owner`. This value must be +included whenever a signature is generated for [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-). + +Every successful call to [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-) increases ``owner``'s nonce by one. This +prevents a signature from being used multiple times.
- +
-

ERC1363ApproveFailed(address spender, uint256 value)

+

DOMAIN_SEPARATOR() → bytes32

-

error

-# +

external

+#
-Indicates a failure within the [`ERC20.approve`](#ERC20-approve-address-uint256-) part of a approveAndCall operation. +Returns the domain separator used in the encoding of the signature for [`ERC20Permit.permit`](#ERC20Permit-permit-address-address-uint256-uint256-uint8-bytes32-bytes32-), as defined by [`EIP712`](/contracts/5.x/api/utils/cryptography#EIP712).
- +
-## `ERC20Burnable` +## `ERC20Bridgeable` - +
```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Bridgeable.sol"; ``` -Extension of [`ERC20`](#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). +ERC20 extension that implements the standard token interface according to +[ERC-7802](https://eips.ethereum.org/EIPS/eip-7802). + +
+

Modifiers

+
+- [onlyTokenBridge()](#ERC20Bridgeable-onlyTokenBridge--) +
+

Functions

-- [burn(value)](#ERC20Burnable-burn-uint256-) -- [burnFrom(account, value)](#ERC20Burnable-burnFrom-address-uint256-) +- [supportsInterface(interfaceId)](#ERC20Bridgeable-supportsInterface-bytes4-) +- [crosschainMint(to, value)](#ERC20Bridgeable-crosschainMint-address-uint256-) +- [crosschainBurn(from, value)](#ERC20Bridgeable-crosschainBurn-address-uint256-) +- [_checkTokenBridge(caller)](#ERC20Bridgeable-_checkTokenBridge-address-)
ERC20 @@ -3814,6 +3759,13 @@ recognized off-chain (via event analysis).

Events

+IERC7802 + +- [CrosschainMint(to, amount, sender)](#IERC7802-CrosschainMint-address-uint256-address-) +- [CrosschainBurn(from, amount, sender)](#IERC7802-CrosschainBurn-address-uint256-address-) + +
+
IERC20 - [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) @@ -3840,74 +3792,132 @@ recognized off-chain (via event analysis).
- +
-

burn(uint256 value)

+

onlyTokenBridge()

+
+

internal

+# +
+
+ +
+ +Modifier to restrict access to the token bridge. + +
+
+ + + +
+
+

supportsInterface(bytes4 interfaceId) → bool

public

-# +#
-Destroys a `value` amount of tokens from the caller. +Returns true if this contract implements the interface defined by +`interfaceId`. See the corresponding +[ERC section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) +to learn more about how these ids are created. -See [`ERC20._burn`](#ERC20-_burn-address-uint256-). +This function call must use less than 30 000 gas.
- +
-

burnFrom(address account, uint256 value)

+

crosschainMint(address to, uint256 value)

public

-# +#
-Destroys a `value` amount of tokens from `account`, deducting from -the caller's allowance. +See [`IERC7802.crosschainMint`](/contracts/5.x/api/interfaces#IERC7802-crosschainMint-address-uint256-). Emits a [`IERC7802.CrosschainMint`](/contracts/5.x/api/interfaces#IERC7802-CrosschainMint-address-uint256-address-) event. -See [`ERC20._burn`](#ERC20-_burn-address-uint256-) and [`ERC20.allowance`](#ERC20-allowance-address-address-). +
+
-Requirements: + -- the caller must have allowance for ``accounts``'s tokens of at least -`value`. +
+
+

crosschainBurn(address from, uint256 value)

+
+

public

+# +
+
+
+ +See [`IERC7802.crosschainBurn`](/contracts/5.x/api/interfaces#IERC7802-crosschainBurn-address-uint256-). Emits a [`IERC7802.CrosschainBurn`](/contracts/5.x/api/interfaces#IERC7802-CrosschainBurn-address-uint256-address-) event.
- + + +
+
+

_checkTokenBridge(address caller)

+
+

internal

+# +
+
+
+ +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`](/contracts/5.x/api/access#AccessControl) or [`AccessManaged`](/contracts/5.x/api/access#AccessManaged). + +
+
+ +
-## `ERC20Capped` +## `ERC20TemporaryApproval` - +
```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol"; +import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20TemporaryApproval.sol"; ``` -Extension of [`ERC20`](#ERC20) that adds a cap to the supply of tokens. +Extension of [`ERC20`](#ERC20) that adds support for temporary allowances following ERC-7674. + + +This is a draft contract. The corresponding ERC is still subject to changes. + + +_Available since v5.1._

Functions

-- [constructor(cap_)](#ERC20Capped-constructor-uint256-) -- [cap()](#ERC20Capped-cap--) -- [_update(from, to, value)](#ERC20Capped-_update-address-address-uint256-) +- [allowance(owner, spender)](#ERC20TemporaryApproval-allowance-address-address-) +- [_temporaryAllowance(owner, spender)](#ERC20TemporaryApproval-_temporaryAllowance-address-address-) +- [temporaryApprove(spender, value)](#ERC20TemporaryApproval-temporaryApprove-address-uint256-) +- [_temporaryApprove(owner, spender, value)](#ERC20TemporaryApproval-_temporaryApprove-address-address-uint256-) +- [_spendAllowance(owner, spender, value)](#ERC20TemporaryApproval-_spendAllowance-address-address-uint256-)
ERC20 @@ -3917,15 +3927,14 @@ Extension of [`ERC20`](#ERC20) that adds a cap to the supply of tokens. - [totalSupply()](#ERC20-totalSupply--) - [balanceOf(account)](#ERC20-balanceOf-address-) - [transfer(to, value)](#ERC20-transfer-address-uint256-) -- [allowance(owner, spender)](#ERC20-allowance-address-address-) - [approve(spender, value)](#ERC20-approve-address-uint256-) - [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) - [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) +- [_update(from, to, value)](#ERC20-_update-address-address-uint256-) - [_mint(account, value)](#ERC20-_mint-address-uint256-) - [_burn(account, value)](#ERC20-_burn-address-uint256-) - [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) - [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) -- [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-)
@@ -3947,8 +3956,6 @@ Extension of [`ERC20`](#ERC20) that adds a cap to the supply of tokens.

Errors

-- [ERC20ExceededCap(increasedSupply, cap)](#ERC20Capped-ERC20ExceededCap-uint256-uint256-) -- [ERC20InvalidCap(cap)](#ERC20Capped-ERC20InvalidCap-uint256-)
IERC20Errors @@ -3963,528 +3970,521 @@ Extension of [`ERC20`](#ERC20) that adds a cap to the supply of tokens.
- +
-

constructor(uint256 cap_)

+

allowance(address owner, address spender) → uint256

-

internal

-# +

public

+#
-Sets the value of the `cap`. This value is immutable, it can only be -set once during construction. +[`ERC20.allowance`](#ERC20-allowance-address-address-) 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.
- +
-

cap() → uint256

+

_temporaryAllowance(address owner, address spender) → uint256

-

public

-# +

internal

+#
-Returns the cap on the token's total supply. +Internal getter for the current temporary allowance that `spender` has over `owner` tokens.
- +
-

_update(address from, address to, uint256 value)

+

temporaryApprove(address spender, uint256 value) → bool

-

internal

-# +

public

+#
-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. +Alternative to [`ERC20.approve`](#ERC20-approve-address-uint256-) that sets a `value` amount of tokens as the temporary allowance of `spender` over +the caller's tokens. -Emits a [`IERC20.Transfer`](#IERC20-Transfer-address-address-uint256-) event. +Returns a boolean value indicating whether the operation succeeded. + +Requirements: +- `spender` cannot be the zero address. + +Does NOT emit an [`IERC20.Approval`](#IERC20-Approval-address-address-uint256-) event.
- +
-

ERC20ExceededCap(uint256 increasedSupply, uint256 cap)

+

_temporaryApprove(address owner, address spender, uint256 value)

-

error

-# +

internal

+#
-Total supply cap has been exceeded. +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: +- `owner` cannot be the zero address. +- `spender` cannot be the zero address. + +Does NOT emit an [`IERC20.Approval`](#IERC20-Approval-address-address-uint256-) event.
- +
-

ERC20InvalidCap(uint256 cap)

+

_spendAllowance(address owner, address spender, uint256 value)

-

error

-# +

internal

+#
-The supplied cap is not a valid cap. +[`ERC20._spendAllowance`](#ERC20-_spendAllowance-address-address-uint256-) override that consumes the temporary allowance (if any) before eventually falling back +to consuming the persistent allowance. + +This function skips calling `super._spendAllowance` if the temporary allowance +is enough to cover the spending. +
- +
-## `ERC20Pausable` +## `ERC1363Utils` - +
```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol"; +import "@openzeppelin/contracts/token/ERC20/utils/ERC1363Utils.sol"; ``` -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. +Library that provides common ERC-1363 utility functions. - -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`](/contracts/5.x/api/utils#Pausable-_pause--) and [`Pausable._unpause`](/contracts/5.x/api/utils#Pausable-_unpause--) internal functions, with appropriate -access control, e.g. using [`AccessControl`](/contracts/5.x/api/access#AccessControl) or [`Ownable`](/contracts/5.x/api/access#Ownable). Not doing so will -make the contract pause mechanism of the contract unreachable, and thus unusable. - +See [ERC-1363](https://eips.ethereum.org/EIPS/eip-1363).

Functions

-- [_update(from, to, value)](#ERC20Pausable-_update-address-address-uint256-) -
-Pausable - -- [paused()](#Pausable-paused--) -- [_requireNotPaused()](#Pausable-_requireNotPaused--) -- [_requirePaused()](#Pausable-_requirePaused--) -- [_pause()](#Pausable-_pause--) -- [_unpause()](#Pausable-_unpause--) - -
-
-ERC20 - -- [name()](#ERC20-name--) -- [symbol()](#ERC20-symbol--) -- [decimals()](#ERC20-decimals--) -- [totalSupply()](#ERC20-totalSupply--) -- [balanceOf(account)](#ERC20-balanceOf-address-) -- [transfer(to, value)](#ERC20-transfer-address-uint256-) -- [allowance(owner, spender)](#ERC20-allowance-address-address-) -- [approve(spender, value)](#ERC20-approve-address-uint256-) -- [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) -- [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) -- [_mint(account, value)](#ERC20-_mint-address-uint256-) -- [_burn(account, value)](#ERC20-_burn-address-uint256-) -- [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) -- [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) -- [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) - -
+- [checkOnERC1363TransferReceived(operator, from, to, value, data)](#ERC1363Utils-checkOnERC1363TransferReceived-address-address-address-uint256-bytes-) +- [checkOnERC1363ApprovalReceived(operator, spender, value, data)](#ERC1363Utils-checkOnERC1363ApprovalReceived-address-address-uint256-bytes-)
-

Events

+

Errors

-
-Pausable - -- [Paused(account)](#Pausable-Paused-address-) -- [Unpaused(account)](#Pausable-Unpaused-address-) - -
-
-IERC20 +- [ERC1363InvalidReceiver(receiver)](#ERC1363Utils-ERC1363InvalidReceiver-address-) +- [ERC1363InvalidSpender(spender)](#ERC1363Utils-ERC1363InvalidSpender-address-) +
+
-- [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) -- [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + -
+
+
+

checkOnERC1363TransferReceived(address operator, address from, address to, uint256 value, bytes data)

+
+

internal

+#
+
-
-

Errors

-
-
-Pausable - -- [EnforcedPause()](#Pausable-EnforcedPause--) -- [ExpectedPause()](#Pausable-ExpectedPause--) +Performs a call to [`IERC1363Receiver.onTransferReceived`](/contracts/5.x/api/interfaces#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) on a target address. -
-
-IERC20Errors +Requirements: -- [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) -- [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) -- [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) -- [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) -- [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) -- [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) +- The target has code (i.e. is a contract). +- The target `to` must implement the [`IERC1363Receiver`](/contracts/5.x/api/interfaces#IERC1363Receiver) interface. +- The target must return the [`IERC1363Receiver.onTransferReceived`](/contracts/5.x/api/interfaces#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) selector to accept the transfer. -
- +
-

_update(address from, address to, uint256 value)

+

checkOnERC1363ApprovalReceived(address operator, address spender, uint256 value, bytes data)

internal

-# +#
-See [`ERC20._update`](#ERC20-_update-address-address-uint256-). +Performs a call to [`IERC1363Spender.onApprovalReceived`](/contracts/5.x/api/interfaces#IERC1363Spender-onApprovalReceived-address-uint256-bytes-) on a target address. Requirements: -- the contract must not be paused. +- The target has code (i.e. is a contract). +- The target `spender` must implement the [`IERC1363Spender`](/contracts/5.x/api/interfaces#IERC1363Spender) interface. +- The target must return the [`IERC1363Spender.onApprovalReceived`](/contracts/5.x/api/interfaces#IERC1363Spender-onApprovalReceived-address-uint256-bytes-) selector to accept the approval.
- - -
- -## `ERC20Bridgeable` - - - - + +
+
+

ERC1363InvalidReceiver(address receiver)

+
+

error

+#
+
+
-```solidity -import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Bridgeable.sol"; -``` - -ERC20 extension that implements the standard token interface according to -[ERC-7802](https://eips.ethereum.org/EIPS/eip-7802). +Indicates a failure with the token `receiver`. Used in transfers. -
-

Modifiers

-
-- [onlyTokenBridge()](#ERC20Bridgeable-onlyTokenBridge--)
-
-

Functions

-
-- [supportsInterface(interfaceId)](#ERC20Bridgeable-supportsInterface-bytes4-) -- [crosschainMint(to, value)](#ERC20Bridgeable-crosschainMint-address-uint256-) -- [crosschainBurn(from, value)](#ERC20Bridgeable-crosschainBurn-address-uint256-) -- [_checkTokenBridge(caller)](#ERC20Bridgeable-_checkTokenBridge-address-) -
-ERC20 + -- [name()](#ERC20-name--) -- [symbol()](#ERC20-symbol--) -- [decimals()](#ERC20-decimals--) -- [totalSupply()](#ERC20-totalSupply--) -- [balanceOf(account)](#ERC20-balanceOf-address-) -- [transfer(to, value)](#ERC20-transfer-address-uint256-) -- [allowance(owner, spender)](#ERC20-allowance-address-address-) -- [approve(spender, value)](#ERC20-approve-address-uint256-) -- [transferFrom(from, to, value)](#ERC20-transferFrom-address-address-uint256-) -- [_transfer(from, to, value)](#ERC20-_transfer-address-address-uint256-) -- [_update(from, to, value)](#ERC20-_update-address-address-uint256-) -- [_mint(account, value)](#ERC20-_mint-address-uint256-) -- [_burn(account, value)](#ERC20-_burn-address-uint256-) -- [_approve(owner, spender, value)](#ERC20-_approve-address-address-uint256-) -- [_approve(owner, spender, value, emitEvent)](#ERC20-_approve-address-address-uint256-bool-) -- [_spendAllowance(owner, spender, value)](#ERC20-_spendAllowance-address-address-uint256-) +
+
+

ERC1363InvalidSpender(address spender)

+
+

error

+# +
+
+
+ +Indicates a failure with the token `spender`. Used in approvals. -
-
-

Events

-
-
-IERC7802 + -- [CrosschainMint(to, amount, sender)](#IERC7802-CrosschainMint-address-uint256-address-) -- [CrosschainBurn(from, amount, sender)](#IERC7802-CrosschainBurn-address-uint256-address-) +
-
-
-IERC20 +## `SafeERC20` -- [Transfer(from, to, value)](#IERC20-Transfer-address-address-uint256-) -- [Approval(owner, spender, value)](#IERC20-Approval-address-address-uint256-) + + + -
+
+ +```solidity +import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; +``` + +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(token, to, value)](#SafeERC20-safeTransfer-contract-IERC20-address-uint256-) +- [safeTransferFrom(token, from, to, value)](#SafeERC20-safeTransferFrom-contract-IERC20-address-address-uint256-) +- [trySafeTransfer(token, to, value)](#SafeERC20-trySafeTransfer-contract-IERC20-address-uint256-) +- [trySafeTransferFrom(token, from, to, value)](#SafeERC20-trySafeTransferFrom-contract-IERC20-address-address-uint256-) +- [safeIncreaseAllowance(token, spender, value)](#SafeERC20-safeIncreaseAllowance-contract-IERC20-address-uint256-) +- [safeDecreaseAllowance(token, spender, requestedDecrease)](#SafeERC20-safeDecreaseAllowance-contract-IERC20-address-uint256-) +- [forceApprove(token, spender, value)](#SafeERC20-forceApprove-contract-IERC20-address-uint256-) +- [transferAndCallRelaxed(token, to, value, data)](#SafeERC20-transferAndCallRelaxed-contract-IERC1363-address-uint256-bytes-) +- [transferFromAndCallRelaxed(token, from, to, value, data)](#SafeERC20-transferFromAndCallRelaxed-contract-IERC1363-address-address-uint256-bytes-) +- [approveAndCallRelaxed(token, to, value, data)](#SafeERC20-approveAndCallRelaxed-contract-IERC1363-address-uint256-bytes-)

Errors

-
-IERC20Errors - -- [ERC20InsufficientBalance(sender, balance, needed)](#IERC20Errors-ERC20InsufficientBalance-address-uint256-uint256-) -- [ERC20InvalidSender(sender)](#IERC20Errors-ERC20InvalidSender-address-) -- [ERC20InvalidReceiver(receiver)](#IERC20Errors-ERC20InvalidReceiver-address-) -- [ERC20InsufficientAllowance(spender, allowance, needed)](#IERC20Errors-ERC20InsufficientAllowance-address-uint256-uint256-) -- [ERC20InvalidApprover(approver)](#IERC20Errors-ERC20InvalidApprover-address-) -- [ERC20InvalidSpender(spender)](#IERC20Errors-ERC20InvalidSpender-address-) - -
+- [SafeERC20FailedOperation(token)](#SafeERC20-SafeERC20FailedOperation-address-) +- [SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease)](#SafeERC20-SafeERC20FailedDecreaseAllowance-address-uint256-uint256-)
- +
-

onlyTokenBridge()

+

safeTransfer(contract IERC20 token, address to, uint256 value)

internal

-# +#
-
-Modifier to restrict access to the token bridge. +Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, +non-reverting calls are assumed to be successful.
- +
-

supportsInterface(bytes4 interfaceId) → bool

+

safeTransferFrom(contract IERC20 token, address from, address to, uint256 value)

-

public

-# +

internal

+#
-Returns true if this contract implements the interface defined by -`interfaceId`. See the corresponding -[ERC section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) -to learn more about how these ids are created. - -This function call must use less than 30 000 gas. +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.
- +
-

crosschainMint(address to, uint256 value)

+

trySafeTransfer(contract IERC20 token, address to, uint256 value) → bool

-

public

-# +

internal

+#
-See [`IERC7802.crosschainMint`](/contracts/5.x/api/interfaces#IERC7802-crosschainMint-address-uint256-). Emits a [`IERC7802.CrosschainMint`](/contracts/5.x/api/interfaces#IERC7802-CrosschainMint-address-uint256-address-) event. +Variant of [`SafeERC20.safeTransfer`](#SafeERC20-safeTransfer-contract-IERC20-address-uint256-) that returns a bool instead of reverting if the operation is not successful.
- +
-

crosschainBurn(address from, uint256 value)

+

trySafeTransferFrom(contract IERC20 token, address from, address to, uint256 value) → bool

-

public

-# +

internal

+#
-See [`IERC7802.crosschainBurn`](/contracts/5.x/api/interfaces#IERC7802-crosschainBurn-address-uint256-). Emits a [`IERC7802.CrosschainBurn`](/contracts/5.x/api/interfaces#IERC7802-CrosschainBurn-address-uint256-address-) event. +Variant of [`SafeERC20.safeTransferFrom`](#SafeERC20-safeTransferFrom-contract-IERC20-address-address-uint256-) that returns a bool instead of reverting if the operation is not successful.
- +
-

_checkTokenBridge(address caller)

+

safeIncreaseAllowance(contract IERC20 token, address spender, uint256 value)

internal

-# +#
-Checks if the caller is a trusted token bridge. MUST revert otherwise. +Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, +non-reverting calls are assumed to be successful. -Developers should implement this function using an access control mechanism that allows -customizing the list of allowed senders. Consider using [`AccessControl`](/contracts/5.x/api/access#AccessControl) or [`AccessManaged`](/contracts/5.x/api/access#AccessManaged). + +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 [`SafeERC20.safeIncreaseAllowance`](#SafeERC20-safeIncreaseAllowance-contract-IERC20-address-uint256-) or [`SafeERC20.safeDecreaseAllowance`](#SafeERC20-safeDecreaseAllowance-contract-IERC20-address-uint256-) operation on a token contract +that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior. +
- + -
+
+
+

safeDecreaseAllowance(contract IERC20 token, address spender, uint256 requestedDecrease)

+
+

internal

+# +
+
+
-## `ERC1363Utils` +Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no +value, non-reverting calls are assumed to be successful. - - - + +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 [`SafeERC20.safeIncreaseAllowance`](#SafeERC20-safeIncreaseAllowance-contract-IERC20-address-uint256-) or [`SafeERC20.safeDecreaseAllowance`](#SafeERC20-safeDecreaseAllowance-contract-IERC20-address-uint256-) operation on a token contract +that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior. + +
-```solidity -import "@openzeppelin/contracts/token/ERC20/utils/ERC1363Utils.sol"; -``` + -Library that provides common ERC-1363 utility functions. +
+
+

forceApprove(contract IERC20 token, address spender, uint256 value)

+
+

internal

+# +
+
+
-See [ERC-1363](https://eips.ethereum.org/EIPS/eip-1363). +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. + + +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. + -
-

Functions

-
-- [checkOnERC1363TransferReceived(operator, from, to, value, data)](#ERC1363Utils-checkOnERC1363TransferReceived-address-address-address-uint256-bytes-) -- [checkOnERC1363ApprovalReceived(operator, spender, value, data)](#ERC1363Utils-checkOnERC1363ApprovalReceived-address-address-uint256-bytes-)
-
-

Errors

-
-- [ERC1363InvalidReceiver(receiver)](#ERC1363Utils-ERC1363InvalidReceiver-address-) -- [ERC1363InvalidSpender(spender)](#ERC1363Utils-ERC1363InvalidSpender-address-) + + +
+
+

transferAndCallRelaxed(contract IERC1363 token, address to, uint256 value, bytes data)

+
+

internal

+#
+
- +Performs an [`ERC1363`](#ERC1363) transferAndCall, with a fallback to the simple [`ERC20`](#ERC20) transfer if the target has no +code. This can be used to implement an [`ERC721`](/contracts/5.x/api/token/ERC721#ERC721)-like safe transfer that relies on [`ERC1363`](#ERC1363) checks when +targeting contracts. + +Reverts if the returned value is other than `true`. + +
+
+ +
-

checkOnERC1363TransferReceived(address operator, address from, address to, uint256 value, bytes data)

+

transferFromAndCallRelaxed(contract IERC1363 token, address from, address to, uint256 value, bytes data)

internal

-# +#
-Performs a call to [`IERC1363Receiver.onTransferReceived`](/contracts/5.x/api/interfaces#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) on a target address. - -Requirements: +Performs an [`ERC1363`](#ERC1363) transferFromAndCall, with a fallback to the simple [`ERC20`](#ERC20) transferFrom if the target +has no code. This can be used to implement an [`ERC721`](/contracts/5.x/api/token/ERC721#ERC721)-like safe transfer that relies on [`ERC1363`](#ERC1363) checks when +targeting contracts. -- The target has code (i.e. is a contract). -- The target `to` must implement the [`IERC1363Receiver`](/contracts/5.x/api/interfaces#IERC1363Receiver) interface. -- The target must return the [`IERC1363Receiver.onTransferReceived`](/contracts/5.x/api/interfaces#IERC1363Receiver-onTransferReceived-address-address-uint256-bytes-) selector to accept the transfer. +Reverts if the returned value is other than `true`.
- +
-

checkOnERC1363ApprovalReceived(address operator, address spender, uint256 value, bytes data)

+

approveAndCallRelaxed(contract IERC1363 token, address to, uint256 value, bytes data)

internal

-# +#
-Performs a call to [`IERC1363Spender.onApprovalReceived`](/contracts/5.x/api/interfaces#IERC1363Spender-onApprovalReceived-address-uint256-bytes-) on a target address. +Performs an [`ERC1363`](#ERC1363) approveAndCall, with a fallback to the simple [`ERC20`](#ERC20) approve if the target has no +code. This can be used to implement an [`ERC721`](/contracts/5.x/api/token/ERC721#ERC721)-like safe transfer that rely on [`ERC1363`](#ERC1363) checks when +targeting contracts. -Requirements: + +When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as [`SafeERC20.forceApprove`](#SafeERC20-forceApprove-contract-IERC20-address-uint256-). +Oppositely, when the recipient address (`to`) has code, this function only attempts to call [`ERC1363.approveAndCall`](#ERC1363-approveAndCall-address-uint256-bytes-) +once without retrying, and relies on the returned value to be true. + -- The target has code (i.e. is a contract). -- The target `spender` must implement the [`IERC1363Spender`](/contracts/5.x/api/interfaces#IERC1363Spender) interface. -- The target must return the [`IERC1363Spender.onApprovalReceived`](/contracts/5.x/api/interfaces#IERC1363Spender-onApprovalReceived-address-uint256-bytes-) selector to accept the approval. +Reverts if the returned value is other than `true`.
- +
-

ERC1363InvalidReceiver(address receiver)

+

SafeERC20FailedOperation(address token)

error

-# +#
-Indicates a failure with the token `receiver`. Used in transfers. +An operation with an ERC-20 token failed.
- +
-

ERC1363InvalidSpender(address spender)

+

SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease)

error

-# +#
-Indicates a failure with the token `spender`. Used in approvals. +Indicates a failed `decreaseAllowance` request.
diff --git a/content/contracts/5.x/api/utils.mdx b/content/contracts/5.x/api/utils.mdx index 5f8fe667..de595447 100644 --- a/content/contracts/5.x/api/utils.mdx +++ b/content/contracts/5.x/api/utils.mdx @@ -8046,921 +8046,1248 @@ The item is not properly formatted and cannot be decoded.
- +
-## `RelayedCall` +## `ReentrancyGuard` - +
```solidity -import "@openzeppelin/contracts/utils/RelayedCall.sol"; +import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; ``` -Library for performing external calls through dynamically deployed relay contracts that hide the original -caller's address from the target contract. This pattern is used in ERC-4337's EntryPoint for account factory -calls and ERC-6942 for safe factory interactions. +Contract module that helps prevent reentrant calls to a function. -When privileged contracts need to make arbitrary external calls based on user input, calling the target directly -can be risky because the target sees the privileged contract as `msg.sender` and could exploit this trust -relationship. This library solves this by deploying minimal relay contracts that act as intermediaries, ensuring -the target only sees the unprivileged relay address as `msg.sender`. +Inheriting from `ReentrancyGuard` will make the [`ReentrancyGuard.nonReentrant`](#ReentrancyGuard-nonReentrant--) modifier +available, which can be applied to functions to make sure there are no nested +(reentrant) calls to them. -For example, instead of `target.call(data)` where the target sees this contract as `msg.sender`, use -[`RelayedCall.relayCall`](#RelayedCall-relayCall-address-uint256-bytes-bytes32-) where the target sees a relay address as `msg.sender`. +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. -This library uses the PUSH0 opcode that was introduced in the Shanghai hardfork. While this instruction is -now widely supported, developers using the library on exotic chains should verify that their target chain has -supports for EIP-3855. +If EIP-1153 (transient storage) is available on the chain you're deploying at, +consider using [`ReentrancyGuardTransient`](#ReentrancyGuardTransient) instead. + + + +If you would like to learn more about reentrancy and alternative ways +to protect against it, check out our blog post +[Reentrancy After Istanbul](https://blog.openzeppelin.com/reentrancy-after-istanbul/). + + + +Deprecated. This storage-based reentrancy guard will be removed and replaced +by the [`ReentrancyGuardTransient`](#ReentrancyGuardTransient) variant in v6.0. +@custom:stateless + +
+

Modifiers

+
+- [nonReentrant()](#ReentrancyGuard-nonReentrant--) +- [nonReentrantView()](#ReentrancyGuard-nonReentrantView--) +
+
+

Functions

-- [relayCall(target, data)](#RelayedCall-relayCall-address-bytes-) -- [relayCall(target, value, data)](#RelayedCall-relayCall-address-uint256-bytes-) -- [relayCall(target, data, salt)](#RelayedCall-relayCall-address-bytes-bytes32-) -- [relayCall(target, value, data, salt)](#RelayedCall-relayCall-address-uint256-bytes-bytes32-) -- [getRelayer()](#RelayedCall-getRelayer--) -- [getRelayer(salt)](#RelayedCall-getRelayer-bytes32-) +- [constructor()](#ReentrancyGuard-constructor--) +- [_reentrancyGuardEntered()](#ReentrancyGuard-_reentrancyGuardEntered--) +- [_reentrancyGuardStorageSlot()](#ReentrancyGuard-_reentrancyGuardStorageSlot--)
- +
+

Errors

+
+- [ReentrancyGuardReentrantCall()](#ReentrancyGuard-ReentrancyGuardReentrantCall--) +
+
+ +
-

relayCall(address target, bytes data) → bool success, bytes retData

+

nonReentrant()

internal

-# +#
+
-Relays a call to the target contract through a dynamically deployed relay contract. +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.
- +
-

relayCall(address target, uint256 value, bytes data) → bool success, bytes retData

+

nonReentrantView()

internal

-# +#
+
-Same as `relayCall-address-bytes` but with a value. +A `view` only version of [`ReentrancyGuard.nonReentrant`](#ReentrancyGuard-nonReentrant--). Use to block view functions +from being called, preventing reading from inconsistent contract state. + + +This is a "view" modifier and does not change the reentrancy +status. Use it only on view functions. For payable or non-payable functions, +use the standard [`ReentrancyGuard.nonReentrant`](#ReentrancyGuard-nonReentrant--) modifier instead. +
- +
-

relayCall(address target, bytes data, bytes32 salt) → bool success, bytes retData

+

constructor()

internal

-# +#
-Same as `relayCall-address-bytes` but with a salt. -
- +
-

relayCall(address target, uint256 value, bytes data, bytes32 salt) → bool success, bytes retData

+

_reentrancyGuardEntered() → bool

internal

-# +#
-Same as `relayCall-address-bytes` but with a salt and a value. +Returns true if the reentrancy guard is currently set to "entered", which indicates there is a +`nonReentrant` function in the call stack.
- +
-

getRelayer() → address

+

_reentrancyGuardStorageSlot() → bytes32

internal

-# +#
-Same as [`RelayedCall.getRelayer`](#RelayedCall-getRelayer-bytes32-) but with a `bytes32(0)` default salt. -
- +
-

getRelayer(bytes32 salt) → address relayer

+

ReentrancyGuardReentrantCall()

-

internal

-# +

error

+#
-Returns the relayer address for a given salt. +Unauthorized reentrant call.
- +
-## `ShortString` +## `ReentrancyGuardTransient` - +
```solidity -import "@openzeppelin/contracts/utils/ShortStrings.sol"; +import "@openzeppelin/contracts/utils/ReentrancyGuardTransient.sol"; ``` - +Variant of [`ReentrancyGuard`](#ReentrancyGuard) that uses transient storage. -
+ +This variant only works on networks where EIP-1153 is available. + -## `ShortStrings` +_Available since v5.1._ - - - +@custom:stateless +
+

Modifiers

+
+- [nonReentrant()](#ReentrancyGuardTransient-nonReentrant--) +- [nonReentrantView()](#ReentrancyGuardTransient-nonReentrantView--) +
- -```solidity -import "@openzeppelin/contracts/utils/ShortStrings.sol"; -``` - -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: - -```solidity -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); - } -} -```

Functions

-- [toShortString(str)](#ShortStrings-toShortString-string-) -- [toString(sstr)](#ShortStrings-toString-ShortString-) -- [byteLength(sstr)](#ShortStrings-byteLength-ShortString-) -- [toShortStringWithFallback(value, store)](#ShortStrings-toShortStringWithFallback-string-string-) -- [toStringWithFallback(value, store)](#ShortStrings-toStringWithFallback-ShortString-string-) -- [byteLengthWithFallback(value, store)](#ShortStrings-byteLengthWithFallback-ShortString-string-) +- [_reentrancyGuardEntered()](#ReentrancyGuardTransient-_reentrancyGuardEntered--) +- [_reentrancyGuardStorageSlot()](#ReentrancyGuardTransient-_reentrancyGuardStorageSlot--)

Errors

-- [StringTooLong(str)](#ShortStrings-StringTooLong-string-) -- [InvalidShortString()](#ShortStrings-InvalidShortString--) +- [ReentrancyGuardReentrantCall()](#ReentrancyGuardTransient-ReentrancyGuardReentrantCall--)
- +
-

toShortString(string str) → ShortString

+

nonReentrant()

internal

-# +#
-
-Encode a string of at most 31 chars into a `ShortString`. +
-This will trigger a `StringTooLong` error is the input string is too long. +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.
- +
-

toString(ShortString sstr) → string

+

nonReentrantView()

internal

-# +#
+
-Decode a `ShortString` back to a "normal" string. +A `view` only version of [`ReentrancyGuard.nonReentrant`](#ReentrancyGuard-nonReentrant--). Use to block view functions +from being called, preventing reading from inconsistent contract state. + + +This is a "view" modifier and does not change the reentrancy +status. Use it only on view functions. For payable or non-payable functions, +use the standard [`ReentrancyGuard.nonReentrant`](#ReentrancyGuard-nonReentrant--) modifier instead. +
- +
-

byteLength(ShortString sstr) → uint256

+

_reentrancyGuardEntered() → bool

internal

-# +#
-Return the length of a `ShortString`. +Returns true if the reentrancy guard is currently set to "entered", which indicates there is a +`nonReentrant` function in the call stack.
- +
-

toShortStringWithFallback(string value, string store) → ShortString

+

_reentrancyGuardStorageSlot() → bytes32

internal

-# +#
-Encode a string into a `ShortString`, or write it to storage if it is too long. -
- +
-

toStringWithFallback(ShortString value, string store) → string

+

ReentrancyGuardReentrantCall()

-

internal

-# +

error

+#
-Decode a string that was encoded to `ShortString` or written to storage using [`ShortStrings.toShortStringWithFallback`](#ShortStrings-toShortStringWithFallback-string-string-). +Unauthorized reentrant call.
- + + +
+ +## `RelayedCall` + + + + -
-
-

byteLengthWithFallback(ShortString value, string store) → uint256

-
-

internal

-# -
-
-Return the length of a string that was encoded to `ShortString` or written to storage using -[`ShortStrings.toShortStringWithFallback`](#ShortStrings-toShortStringWithFallback-string-string-). +```solidity +import "@openzeppelin/contracts/utils/RelayedCall.sol"; +``` - -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. +Library for performing external calls through dynamically deployed relay contracts that hide the original +caller's address from the target contract. This pattern is used in ERC-4337's EntryPoint for account factory +calls and ERC-6942 for safe factory interactions. + +When privileged contracts need to make arbitrary external calls based on user input, calling the target directly +can be risky because the target sees the privileged contract as `msg.sender` and could exploit this trust +relationship. This library solves this by deploying minimal relay contracts that act as intermediaries, ensuring +the target only sees the unprivileged relay address as `msg.sender`. + +For example, instead of `target.call(data)` where the target sees this contract as `msg.sender`, use +[`RelayedCall.relayCall`](#RelayedCall-relayCall-address-uint256-bytes-bytes32-) where the target sees a relay address as `msg.sender`. + + +This library uses the PUSH0 opcode that was introduced in the Shanghai hardfork. While this instruction is +now widely supported, developers using the library on exotic chains should verify that their target chain has +supports for EIP-3855. +
+

Functions

+
+- [relayCall(target, data)](#RelayedCall-relayCall-address-bytes-) +- [relayCall(target, value, data)](#RelayedCall-relayCall-address-uint256-bytes-) +- [relayCall(target, data, salt)](#RelayedCall-relayCall-address-bytes-bytes32-) +- [relayCall(target, value, data, salt)](#RelayedCall-relayCall-address-uint256-bytes-bytes32-) +- [getRelayer()](#RelayedCall-getRelayer--) +- [getRelayer(salt)](#RelayedCall-getRelayer-bytes32-)
- +
-

StringTooLong(string str)

+

relayCall(address target, bytes data) → bool success, bytes retData

-

error

-# +

internal

+#
+Relays a call to the target contract through a dynamically deployed relay contract. +
- +
-

InvalidShortString()

+

relayCall(address target, uint256 value, bytes data) → bool success, bytes retData

-

error

-# +

internal

+#
+Same as `relayCall-address-bytes` but with a value. +
- - -
- -## `SimulateCall` - - - - + +
+
+

relayCall(address target, bytes data, bytes32 salt) → bool success, bytes retData

+
+

internal

+#
+
+
-```solidity -import "@openzeppelin/contracts/utils/SimulateCall.sol"; -``` - -Library for simulating external calls and inspecting the result of the call while reverting any state changes -of events the call may have produced. - -This pattern is useful when you need to simulate the result of a call without actually executing it on-chain. Since -the address of the sender is preserved, this supports simulating calls that perform token swap that use the caller's -balance, or any operation that is restricted to the caller. +Same as `relayCall-address-bytes` but with a salt. -
-

Functions

-
-- [simulateCall(target, data)](#SimulateCall-simulateCall-address-bytes-) -- [simulateCall(target, value, data)](#SimulateCall-simulateCall-address-uint256-bytes-) -- [getSimulator()](#SimulateCall-getSimulator--)
- +
-

simulateCall(address target, bytes data) → bool success, bytes retData

+

relayCall(address target, uint256 value, bytes data, bytes32 salt) → bool success, bytes retData

internal

-# +#
-Simulates a call to the target contract through a dynamically deployed simulator. +Same as `relayCall-address-bytes` but with a salt and a value.
- +
-

simulateCall(address target, uint256 value, bytes data) → bool success, bytes retData

+

getRelayer() → address

internal

-# +#
-Same as `simulateCall-address-bytes` but with a value. +Same as [`RelayedCall.getRelayer`](#RelayedCall-getRelayer-bytes32-) but with a `bytes32(0)` default salt.
- +
-

getSimulator() → address instance

+

getRelayer(bytes32 salt) → address relayer

internal

-# +#
-Returns the simulator address. +Returns the relayer address for a given salt. -The simulator REVERTs on success and RETURNs on failure, preserving the return data in both cases. +
+
-* A failed target call returns the return data and succeeds in our context (no state changes). -* A successful target call causes a revert in our context (undoing all state changes) while still -capturing the return data. + + +
+ +## `ShortString` + + + + -
- +```solidity +import "@openzeppelin/contracts/utils/ShortStrings.sol"; +``` + +
-## `SlotDerivation` +## `ShortStrings` - +
```solidity -import "@openzeppelin/contracts/utils/SlotDerivation.sol"; +import "@openzeppelin/contracts/utils/ShortStrings.sol"; ``` -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. +This library provides functions to convert short memory strings +into a `ShortString` type that can be used as an immutable variable. -See [Solidity docs for mappings and dynamic arrays.](https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays). +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: -Example usage: ```solidity -contract Example { - // Add the library methods - using StorageSlot for bytes32; - using SlotDerivation for *; +contract Named { + using ShortStrings for *; - // Declare a namespace - string private constant _NAMESPACE = ""; // eg. OpenZeppelin.Slot + ShortString private immutable _name; + string private _nameFallback; - function setValueInNamespace(uint256 key, address newValue) internal { - _NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value = newValue; + constructor(string memory contractName) { + _name = contractName.toShortStringWithFallback(_nameFallback); } - function getValueInNamespace(uint256 key) internal view returns (address) { - return _NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value; + function name() external view returns (string memory) { + return _name.toStringWithFallback(_nameFallback); } } ``` - -Consider using this library along with [`StorageSlot`](#StorageSlot). - - - -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(namespace)](#SlotDerivation-erc7201Slot-string-) -- [offset(slot, pos)](#SlotDerivation-offset-bytes32-uint256-) -- [deriveArray(slot)](#SlotDerivation-deriveArray-bytes32-) -- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-address-) -- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-bool-) -- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-bytes32-) -- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-uint256-) -- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-int256-) -- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-string-) -- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-bytes-) +- [toShortString(str)](#ShortStrings-toShortString-string-) +- [toString(sstr)](#ShortStrings-toString-ShortString-) +- [byteLength(sstr)](#ShortStrings-byteLength-ShortString-) +- [toShortStringWithFallback(value, store)](#ShortStrings-toShortStringWithFallback-string-string-) +- [toStringWithFallback(value, store)](#ShortStrings-toStringWithFallback-ShortString-string-) +- [byteLengthWithFallback(value, store)](#ShortStrings-byteLengthWithFallback-ShortString-string-)
- +
+

Errors

+
+- [StringTooLong(str)](#ShortStrings-StringTooLong-string-) +- [InvalidShortString()](#ShortStrings-InvalidShortString--) +
+
+ +
-

erc7201Slot(string namespace) → bytes32 slot

+

toShortString(string str) → ShortString

internal

-# +#
-Derive an ERC-7201 slot from a string (namespace). +Encode a string of at most 31 chars into a `ShortString`. + +This will trigger a `StringTooLong` error is the input string is too long.
- +
-

offset(bytes32 slot, uint256 pos) → bytes32 result

+

toString(ShortString sstr) → string

internal

-# +#
-Add an offset to a slot to get the n-th element of a structure or an array. +Decode a `ShortString` back to a "normal" string.
- +
-

deriveArray(bytes32 slot) → bytes32 result

+

byteLength(ShortString sstr) → uint256

internal

-# +#
-Derive the location of the first element in an array from the slot where the length is stored. +Return the length of a `ShortString`.
- +
-

deriveMapping(bytes32 slot, address key) → bytes32 result

+

toShortStringWithFallback(string value, string store) → ShortString

internal

-# +#
-Derive the location of a mapping element from the key. +Encode a string into a `ShortString`, or write it to storage if it is too long.
- +
-

deriveMapping(bytes32 slot, bool key) → bytes32 result

+

toStringWithFallback(ShortString value, string store) → string

internal

-# +#
-Derive the location of a mapping element from the key. +Decode a string that was encoded to `ShortString` or written to storage using [`ShortStrings.toShortStringWithFallback`](#ShortStrings-toShortStringWithFallback-string-string-).
- +
-

deriveMapping(bytes32 slot, bytes32 key) → bytes32 result

+

byteLengthWithFallback(ShortString value, string store) → uint256

internal

-# +#
-Derive the location of a mapping element from the key. +Return the length of a string that was encoded to `ShortString` or written to storage using +[`ShortStrings.toShortStringWithFallback`](#ShortStrings-toShortStringWithFallback-string-string-). + + +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. +
- +
-

deriveMapping(bytes32 slot, uint256 key) → bytes32 result

+

StringTooLong(string str)

-

internal

-# +

error

+#
-Derive the location of a mapping element from the key. +
+
+ + +
+
+

InvalidShortString()

+
+

error

+#
+
- +
+
+ + + +
+ +## `SimulateCall` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/utils/SimulateCall.sol"; +``` + +Library for simulating external calls and inspecting the result of the call while reverting any state changes +of events the call may have produced. + +This pattern is useful when you need to simulate the result of a call without actually executing it on-chain. Since +the address of the sender is preserved, this supports simulating calls that perform token swap that use the caller's +balance, or any operation that is restricted to the caller. + +
+

Functions

+
+- [simulateCall(target, data)](#SimulateCall-simulateCall-address-bytes-) +- [simulateCall(target, value, data)](#SimulateCall-simulateCall-address-uint256-bytes-) +- [getSimulator()](#SimulateCall-getSimulator--) +
+
+ +
-

deriveMapping(bytes32 slot, int256 key) → bytes32 result

+

simulateCall(address target, bytes data) → bool success, bytes retData

internal

-# +#
-Derive the location of a mapping element from the key. +Simulates a call to the target contract through a dynamically deployed simulator.
- +
-

deriveMapping(bytes32 slot, string key) → bytes32 result

+

simulateCall(address target, uint256 value, bytes data) → bool success, bytes retData

internal

-# +#
-Derive the location of a mapping element from the key. +Same as `simulateCall-address-bytes` but with a value.
- +
-

deriveMapping(bytes32 slot, bytes key) → bytes32 result

+

getSimulator() → address instance

internal

-# +#
-Derive the location of a mapping element from the key. +Returns the simulator address. + +The simulator REVERTs on success and RETURNs on failure, preserving the return data in both cases. + +* A failed target call returns the return data and succeeds in our context (no state changes). +* A successful target call causes a revert in our context (undoing all state changes) while still +capturing the return data.
- +
-## `StorageSlot` +## `SlotDerivation` - +
```solidity -import "@openzeppelin/contracts/utils/StorageSlot.sol"; +import "@openzeppelin/contracts/utils/SlotDerivation.sol"; ``` -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. +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. -The functions in this library return Slot structs that contain a `value` member that can be used to read or write. +See [Solidity docs for mappings and dynamic arrays.](https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays). -Example usage to set ERC-1967 implementation slot: +Example usage: ```solidity -contract ERC1967 { - // Define the slot. Alternatively, use the SlotDerivation library to derive the slot. - bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; +contract Example { + // Add the library methods + using StorageSlot for bytes32; + using SlotDerivation for *; - function _getImplementation() internal view returns (address) { - return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; + // Declare a namespace + string private constant _NAMESPACE = ""; // eg. OpenZeppelin.Slot + + function setValueInNamespace(uint256 key, address newValue) internal { + _NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value = newValue; } - function _setImplementation(address newImplementation) internal { - require(newImplementation.code.length > 0); - StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; + function getValueInNamespace(uint256 key) internal view returns (address) { + return _NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value; } } ``` -Consider using this library along with [`SlotDerivation`](#SlotDerivation). +Consider using this library along with [`StorageSlot`](#StorageSlot). + + + +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

-- [getAddressSlot(slot)](#StorageSlot-getAddressSlot-bytes32-) -- [getBooleanSlot(slot)](#StorageSlot-getBooleanSlot-bytes32-) -- [getBytes32Slot(slot)](#StorageSlot-getBytes32Slot-bytes32-) -- [getUint256Slot(slot)](#StorageSlot-getUint256Slot-bytes32-) -- [getInt256Slot(slot)](#StorageSlot-getInt256Slot-bytes32-) -- [getStringSlot(slot)](#StorageSlot-getStringSlot-bytes32-) -- [getStringSlot(store)](#StorageSlot-getStringSlot-string-) -- [getBytesSlot(slot)](#StorageSlot-getBytesSlot-bytes32-) -- [getBytesSlot(store)](#StorageSlot-getBytesSlot-bytes-) +- [erc7201Slot(namespace)](#SlotDerivation-erc7201Slot-string-) +- [offset(slot, pos)](#SlotDerivation-offset-bytes32-uint256-) +- [deriveArray(slot)](#SlotDerivation-deriveArray-bytes32-) +- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-address-) +- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-bool-) +- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-bytes32-) +- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-uint256-) +- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-int256-) +- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-string-) +- [deriveMapping(slot, key)](#SlotDerivation-deriveMapping-bytes32-bytes-)
- +
-

getAddressSlot(bytes32 slot) → struct StorageSlot.AddressSlot r

+

erc7201Slot(string namespace) → bytes32 slot

internal

-# +#
-Returns an `AddressSlot` with member `value` located at `slot`. +Derive an ERC-7201 slot from a string (namespace).
- +
-

getBooleanSlot(bytes32 slot) → struct StorageSlot.BooleanSlot r

+

offset(bytes32 slot, uint256 pos) → bytes32 result

internal

-# +#
-Returns a `BooleanSlot` with member `value` located at `slot`. +Add an offset to a slot to get the n-th element of a structure or an array.
- +
-

getBytes32Slot(bytes32 slot) → struct StorageSlot.Bytes32Slot r

+

deriveArray(bytes32 slot) → bytes32 result

internal

-# +#
-Returns a `Bytes32Slot` with member `value` located at `slot`. +Derive the location of the first element in an array from the slot where the length is stored.
- +
-

getUint256Slot(bytes32 slot) → struct StorageSlot.Uint256Slot r

+

deriveMapping(bytes32 slot, address key) → bytes32 result

internal

-# +#
-Returns a `Uint256Slot` with member `value` located at `slot`. +Derive the location of a mapping element from the key.
- +
-

getInt256Slot(bytes32 slot) → struct StorageSlot.Int256Slot r

+

deriveMapping(bytes32 slot, bool key) → bytes32 result

internal

-# +#
-Returns a `Int256Slot` with member `value` located at `slot`. +Derive the location of a mapping element from the key.
- +
-

getStringSlot(bytes32 slot) → struct StorageSlot.StringSlot r

+

deriveMapping(bytes32 slot, bytes32 key) → bytes32 result

internal

-# +#
-Returns a `StringSlot` with member `value` located at `slot`. +Derive the location of a mapping element from the key.
- +
-

getStringSlot(string store) → struct StorageSlot.StringSlot r

+

deriveMapping(bytes32 slot, uint256 key) → bytes32 result

internal

-# +#
-Returns an `StringSlot` representation of the string storage pointer `store`. +Derive the location of a mapping element from the key.
- +
-

getBytesSlot(bytes32 slot) → struct StorageSlot.BytesSlot r

+

deriveMapping(bytes32 slot, int256 key) → bytes32 result

internal

-# +#
-Returns a `BytesSlot` with member `value` located at `slot`. +Derive the location of a mapping element from the key.
- +
-

getBytesSlot(bytes store) → struct StorageSlot.BytesSlot r

+

deriveMapping(bytes32 slot, string key) → bytes32 result

internal

-# +#
-Returns an `BytesSlot` representation of the bytes storage pointer `store`. +Derive the location of a mapping element from the key.
- - -
- -## `Strings` + - - +
+ +
+ +Derive the location of a mapping element from the key. + +
+
+ + + +
+ +## `StorageSlot` + + + + + +
+ +```solidity +import "@openzeppelin/contracts/utils/StorageSlot.sol"; +``` + +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: +```solidity +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; + } +} +``` + + +Consider using this library along with [`SlotDerivation`](#SlotDerivation). + + +
+

Functions

+
+- [getAddressSlot(slot)](#StorageSlot-getAddressSlot-bytes32-) +- [getBooleanSlot(slot)](#StorageSlot-getBooleanSlot-bytes32-) +- [getBytes32Slot(slot)](#StorageSlot-getBytes32Slot-bytes32-) +- [getUint256Slot(slot)](#StorageSlot-getUint256Slot-bytes32-) +- [getInt256Slot(slot)](#StorageSlot-getInt256Slot-bytes32-) +- [getStringSlot(slot)](#StorageSlot-getStringSlot-bytes32-) +- [getStringSlot(store)](#StorageSlot-getStringSlot-string-) +- [getBytesSlot(slot)](#StorageSlot-getBytesSlot-bytes32-) +- [getBytesSlot(store)](#StorageSlot-getBytesSlot-bytes-) +
+
+ + + +
+
+

getAddressSlot(bytes32 slot) → struct StorageSlot.AddressSlot r

+
+

internal

+# +
+
+
+ +Returns an `AddressSlot` with member `value` located at `slot`. + +
+
+ + + +
+
+

getBooleanSlot(bytes32 slot) → struct StorageSlot.BooleanSlot r

+
+

internal

+# +
+
+
+ +Returns a `BooleanSlot` with member `value` located at `slot`. + +
+
+ + + +
+
+

getBytes32Slot(bytes32 slot) → struct StorageSlot.Bytes32Slot r

+
+

internal

+# +
+
+
+ +Returns a `Bytes32Slot` with member `value` located at `slot`. + +
+
+ + + +
+
+

getUint256Slot(bytes32 slot) → struct StorageSlot.Uint256Slot r

+
+

internal

+# +
+
+
+ +Returns a `Uint256Slot` with member `value` located at `slot`. + +
+
+ + + +
+
+

getInt256Slot(bytes32 slot) → struct StorageSlot.Int256Slot r

+
+

internal

+# +
+
+
+ +Returns a `Int256Slot` with member `value` located at `slot`. + +
+
+ + + +
+
+

getStringSlot(bytes32 slot) → struct StorageSlot.StringSlot r

+
+

internal

+# +
+
+
+ +Returns a `StringSlot` with member `value` located at `slot`. + +
+
+ + + +
+
+

getStringSlot(string store) → struct StorageSlot.StringSlot r

+
+

internal

+# +
+
+
+ +Returns an `StringSlot` representation of the string storage pointer `store`. + +
+
+ + + +
+
+

getBytesSlot(bytes32 slot) → struct StorageSlot.BytesSlot r

+
+

internal

+# +
+
+
+ +Returns a `BytesSlot` with member `value` located at `slot`. + +
+
+ + + +
+
+

getBytesSlot(bytes store) → struct StorageSlot.BytesSlot r

+
+

internal

+# +
+
+
+ +Returns an `BytesSlot` representation of the bytes storage pointer `store`. + +
+
+ + + +
+ +## `Strings` + + +
@@ -18557,656 +18884,329 @@ follows the Solidity memory safety rules. Otherwise, it may lead to unexpected b

push(struct MerkleTree.Bytes32PushTree self, bytes32 leaf) → uint256 index, bytes32 newRoot

-
-

internal

-# -
-
-
- -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`](/contracts/5.x/api/utils/cryptography#Hashes-commutativeKeccak256-bytes32-bytes32-) 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 -[the default setup](#MerkleTree-setup-struct-MerkleTree-Bytes32PushTree-uint8-bytes32-) function). - -
-
- - - -
-
-

push(struct MerkleTree.Bytes32PushTree self, bytes32 leaf, function (bytes32,bytes32) view returns (bytes32) fnHash) → uint256 index, bytes32 newRoot

-
-

internal

-# -
-
-
- -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. - -
-
- - - -
-
-

update(struct MerkleTree.Bytes32PushTree self, uint256 index, bytes32 oldValue, bytes32 newValue, bytes32[] proof) → bytes32 oldRoot, bytes32 newRoot

-
-

internal

-# -
-
-
- -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 [`RLP.push`](#RLP-push-struct-RLP-Encoder-struct-RLP-Encoder-) or [`MerkleTree.update`](#MerkleTree-update-struct-MerkleTree-Bytes32PushTree-uint256-bytes32-bytes32-bytes32---function--bytes32-bytes32--view-returns--bytes32--) operation (that changes the root of the tree) would render -all "in flight" updates invalid. - -This variant uses [`Hashes.commutativeKeccak256`](/contracts/5.x/api/utils/cryptography#Hashes-commutativeKeccak256-bytes32-bytes32-) 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 -[the default setup](#MerkleTree-setup-struct-MerkleTree-Bytes32PushTree-uint8-bytes32-) function). - -
-
- - - -
-
-

update(struct MerkleTree.Bytes32PushTree self, uint256 index, bytes32 oldValue, bytes32 newValue, bytes32[] proof, function (bytes32,bytes32) view returns (bytes32) fnHash) → bytes32 oldRoot, bytes32 newRoot

-
-

internal

-# -
-
-
- -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 [`RLP.push`](#RLP-push-struct-RLP-Encoder-struct-RLP-Encoder-) or [`MerkleTree.update`](#MerkleTree-update-struct-MerkleTree-Bytes32PushTree-uint256-bytes32-bytes32-bytes32---function--bytes32-bytes32--view-returns--bytes32--) 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. - -
-
- - - -
-
-

depth(struct MerkleTree.Bytes32PushTree self) → uint256

-
-

internal

-# -
-
-
- -Tree's depth (set at initialization) - -
-
- - - -
-
-

MerkleTreeUpdateInvalidIndex(uint256 index, uint256 length)

-
-

error

-# -
-
-
- -Error emitted when trying to update a leaf that was not previously pushed. - -
-
- - - -
-
-

MerkleTreeUpdateInvalidProof()

-
-

error

-# -
-
-
- -Error emitted when the proof used during an update is invalid (could not reproduce the side). - -
-
- - - -
- -## `Time` - - - - - -
- -```solidity -import "@openzeppelin/contracts/utils/types/Time.sol"; -``` - -This library provides helpers for manipulating time-related objects. - -It uses the following types: -- `uint48` for timepoints -- `uint32` for durations - -While the library doesn't provide specific types for timepoints and duration, it does provide: -- a `Delay` type to represent duration that can be programmed to change value automatically at a given point -- additional helper functions - -
-

Functions

-
-- [timestamp()](#Time-timestamp--) -- [blockNumber()](#Time-blockNumber--) -- [toDelay(duration)](#Time-toDelay-uint32-) -- [getFull(self)](#Time-getFull-Time-Delay-) -- [get(self)](#Time-get-Time-Delay-) -- [withUpdate(self, newValue, minSetback)](#Time-withUpdate-Time-Delay-uint32-uint32-) -- [unpack(self)](#Time-unpack-Time-Delay-) -- [pack(valueBefore, valueAfter, effect)](#Time-pack-uint32-uint32-uint48-) -
-
- - - -
-
-

timestamp() → uint48

-
-

internal

-# -
-
-
- -Get the block timestamp as a Timepoint. - -
-
- - - -
-
-

blockNumber() → uint48

-
-

internal

-# -
-
-
- -Get the block number as a Timepoint. - -
-
- - - -
-
-

toDelay(uint32 duration) → Time.Delay

-
-

internal

-# -
-
-
- -Wrap a duration into a Delay to add the one-step "update in the future" feature - -
-
- - - -
-
-

getFull(Time.Delay self) → uint32 valueBefore, uint32 valueAfter, uint48 effect

-
-

internal

-# -
-
-
- -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. - -
-
- - - -
-
-

get(Time.Delay self) → uint32

-
-

internal

-# -
-
-
- -Get the current value. - -
-
- - - -
-
-

withUpdate(Time.Delay self, uint32 newValue, uint32 minSetback) → Time.Delay updatedDelay, uint48 effect

-
-

internal

-# -
-
-
- -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. - -
-
- - - -
-
-

unpack(Time.Delay self) → uint32 valueBefore, uint32 valueAfter, uint48 effect

-
-

internal

-# -
-
-
- -Split a delay into its components: valueBefore, valueAfter and effect (transition timepoint). - -
-
- - - -
-
-

pack(uint32 valueBefore, uint32 valueAfter, uint48 effect) → Time.Delay

-
-

internal

-# -
-
-
- -pack the components into a Delay object. - -
-
- - - -
- -## `ReentrancyGuard` - - - - - -
- -```solidity -import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; -``` - -Contract module that helps prevent reentrant calls to a function. - -Inheriting from `ReentrancyGuard` will make the [`ReentrancyGuard.nonReentrant`](#ReentrancyGuard-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. - - -If EIP-1153 (transient storage) is available on the chain you're deploying at, -consider using [`ReentrancyGuardTransient`](#ReentrancyGuardTransient) instead. - - - -If you would like to learn more about reentrancy and alternative ways -to protect against it, check out our blog post -[Reentrancy After Istanbul](https://blog.openzeppelin.com/reentrancy-after-istanbul/). - - - -Deprecated. This storage-based reentrancy guard will be removed and replaced -by the [`ReentrancyGuardTransient`](#ReentrancyGuardTransient) variant in v6.0. - - -@custom:stateless - -
-

Modifiers

-
-- [nonReentrant()](#ReentrancyGuard-nonReentrant--) -- [nonReentrantView()](#ReentrancyGuard-nonReentrantView--) +
+

internal

+#
+
-
-

Functions

-
-- [constructor()](#ReentrancyGuard-constructor--) -- [_reentrancyGuardEntered()](#ReentrancyGuard-_reentrancyGuardEntered--) -- [_reentrancyGuardStorageSlot()](#ReentrancyGuard-_reentrancyGuardStorageSlot--) -
-
+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`](/contracts/5.x/api/utils/cryptography#Hashes-commutativeKeccak256-bytes32-bytes32-) 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 +[the default setup](#MerkleTree-setup-struct-MerkleTree-Bytes32PushTree-uint8-bytes32-) function). -
-

Errors

-
-- [ReentrancyGuardReentrantCall()](#ReentrancyGuard-ReentrancyGuardReentrantCall--)
- +
-

nonReentrant()

+

push(struct MerkleTree.Bytes32PushTree self, bytes32 leaf, function (bytes32,bytes32) view returns (bytes32) fnHash) → uint256 index, bytes32 newRoot

internal

-# +#
-
-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. +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.
- +
-

nonReentrantView()

+

update(struct MerkleTree.Bytes32PushTree self, uint256 index, bytes32 oldValue, bytes32 newValue, bytes32[] proof) → bytes32 oldRoot, bytes32 newRoot

internal

-# +#
-
-A `view` only version of [`ReentrancyGuard.nonReentrant`](#ReentrancyGuard-nonReentrant--). Use to block view functions -from being called, preventing reading from inconsistent contract state. +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. - -This is a "view" modifier and does not change the reentrancy -status. Use it only on view functions. For payable or non-payable functions, -use the standard [`ReentrancyGuard.nonReentrant`](#ReentrancyGuard-nonReentrant--) modifier instead. - +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 [`RLP.push`](#RLP-push-struct-RLP-Encoder-struct-RLP-Encoder-) or [`MerkleTree.update`](#MerkleTree-update-struct-MerkleTree-Bytes32PushTree-uint256-bytes32-bytes32-bytes32---function--bytes32-bytes32--view-returns--bytes32--) operation (that changes the root of the tree) would render +all "in flight" updates invalid. + +This variant uses [`Hashes.commutativeKeccak256`](/contracts/5.x/api/utils/cryptography#Hashes-commutativeKeccak256-bytes32-bytes32-) 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 +[the default setup](#MerkleTree-setup-struct-MerkleTree-Bytes32PushTree-uint8-bytes32-) function).
- +
-

constructor()

+

update(struct MerkleTree.Bytes32PushTree self, uint256 index, bytes32 oldValue, bytes32 newValue, bytes32[] proof, function (bytes32,bytes32) view returns (bytes32) fnHash) → bytes32 oldRoot, bytes32 newRoot

internal

-# +#
+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 [`RLP.push`](#RLP-push-struct-RLP-Encoder-struct-RLP-Encoder-) or [`MerkleTree.update`](#MerkleTree-update-struct-MerkleTree-Bytes32PushTree-uint256-bytes32-bytes32-bytes32---function--bytes32-bytes32--view-returns--bytes32--) 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. +
- +
-

_reentrancyGuardEntered() → bool

+

depth(struct MerkleTree.Bytes32PushTree self) → uint256

internal

-# +#
-Returns true if the reentrancy guard is currently set to "entered", which indicates there is a -`nonReentrant` function in the call stack. +Tree's depth (set at initialization)
- +
-

_reentrancyGuardStorageSlot() → bytes32

+

MerkleTreeUpdateInvalidIndex(uint256 index, uint256 length)

-

internal

-# +

error

+#
+Error emitted when trying to update a leaf that was not previously pushed. +
- +
-

ReentrancyGuardReentrantCall()

+

MerkleTreeUpdateInvalidProof()

error

-# +#
-Unauthorized reentrant call. +Error emitted when the proof used during an update is invalid (could not reproduce the side).
- +
-## `ReentrancyGuardTransient` +## `Time` - +
```solidity -import "@openzeppelin/contracts/utils/ReentrancyGuardTransient.sol"; +import "@openzeppelin/contracts/utils/types/Time.sol"; ``` -Variant of [`ReentrancyGuard`](#ReentrancyGuard) that uses transient storage. - - -This variant only works on networks where EIP-1153 is available. - +This library provides helpers for manipulating time-related objects. -_Available since v5.1._ +It uses the following types: +- `uint48` for timepoints +- `uint32` for durations -@custom:stateless +While the library doesn't provide specific types for timepoints and duration, it does provide: +- a `Delay` type to represent duration that can be programmed to change value automatically at a given point +- additional helper functions
-

Modifiers

+

Functions

-- [nonReentrant()](#ReentrancyGuardTransient-nonReentrant--) -- [nonReentrantView()](#ReentrancyGuardTransient-nonReentrantView--) +- [timestamp()](#Time-timestamp--) +- [blockNumber()](#Time-blockNumber--) +- [toDelay(duration)](#Time-toDelay-uint32-) +- [getFull(self)](#Time-getFull-Time-Delay-) +- [get(self)](#Time-get-Time-Delay-) +- [withUpdate(self, newValue, minSetback)](#Time-withUpdate-Time-Delay-uint32-uint32-) +- [unpack(self)](#Time-unpack-Time-Delay-) +- [pack(valueBefore, valueAfter, effect)](#Time-pack-uint32-uint32-uint48-)
-
-

Functions

-
-- [_reentrancyGuardEntered()](#ReentrancyGuardTransient-_reentrancyGuardEntered--) -- [_reentrancyGuardStorageSlot()](#ReentrancyGuardTransient-_reentrancyGuardStorageSlot--) + + +
+
+

timestamp() → uint48

+
+

internal

+#
+
+ +Get the block timestamp as a Timepoint. -
-

Errors

-
-- [ReentrancyGuardReentrantCall()](#ReentrancyGuardTransient-ReentrancyGuardReentrantCall--)
- +
-

nonReentrant()

+

blockNumber() → uint48

internal

-# +#
-
-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. +Get the block number as a Timepoint.
- +
-

nonReentrantView()

+

toDelay(uint32 duration) → Time.Delay

internal

-# +# +
+
+
+ +Wrap a duration into a Delay to add the one-step "update in the future" feature +
+ + +
+
+

getFull(Time.Delay self) → uint32 valueBefore, uint32 valueAfter, uint48 effect

+
+

internal

+# +
+
-A `view` only version of [`ReentrancyGuard.nonReentrant`](#ReentrancyGuard-nonReentrant--). Use to block view functions -from being called, preventing reading from inconsistent contract state. +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. - -This is a "view" modifier and does not change the reentrancy -status. Use it only on view functions. For payable or non-payable functions, -use the standard [`ReentrancyGuard.nonReentrant`](#ReentrancyGuard-nonReentrant--) modifier instead. - +
+
+ + +
+
+

get(Time.Delay self) → uint32

+
+

internal

+#
+
- +Get the current value. + +
+
+ +
-

_reentrancyGuardEntered() → bool

+

withUpdate(Time.Delay self, uint32 newValue, uint32 minSetback) → Time.Delay updatedDelay, uint48 effect

internal

-# +#
-Returns true if the reentrancy guard is currently set to "entered", which indicates there is a -`nonReentrant` function in the call stack. +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.
- +
-

_reentrancyGuardStorageSlot() → bytes32

+

unpack(Time.Delay self) → uint32 valueBefore, uint32 valueAfter, uint48 effect

internal

-# +#
+Split a delay into its components: valueBefore, valueAfter and effect (transition timepoint). +
- +
-

ReentrancyGuardReentrantCall()

+

pack(uint32 valueBefore, uint32 valueAfter, uint48 effect) → Time.Delay

-

error

-# +

internal

+#
-Unauthorized reentrant call. +pack the components into a Delay object.
diff --git a/examples/AccessManagerEnumerable.sol b/examples/AccessManagerEnumerable.sol new file mode 100644 index 00000000..78640b4c --- /dev/null +++ b/examples/AccessManagerEnumerable.sol @@ -0,0 +1,161 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.24; + +import {AccessManager} from "@openzeppelin/contracts/access/manager/AccessManager.sol"; +import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; + +/** + * @dev Extension of {AccessManager} that allows enumerating the members of each role + * and the target functions each role is allowed to call. + * + * NOTE: Given {ADMIN_ROLE} is the default role for every restricted function, the + * {getRoleTargetFunctions} and {getRoleTargetFunctionCount} functions will return an empty array + * and 0 respectively. + */ +abstract contract AccessManagerEnumerable is AccessManager { + using EnumerableSet for EnumerableSet.AddressSet; + using EnumerableSet for EnumerableSet.Bytes4Set; + + mapping(uint64 roleId => EnumerableSet.AddressSet) private _roleMembers; + mapping(uint64 roleId => mapping(address target => EnumerableSet.Bytes4Set)) private _roleTargetFunctions; + + /** + * @dev Returns the number of accounts that have `roleId`. Can be used + * together with {getRoleMember} to enumerate all bearers of a role. + */ + function getRoleMemberCount(uint64 roleId) public view virtual returns (uint256) { + return _roleMembers[roleId].length(); + } + + /** + * @dev Returns one of the accounts that have `roleId`. `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(uint64 roleId, uint256 index) public view virtual returns (address) { + return _roleMembers[roleId].at(index); + } + + /** + * @dev Returns a range of accounts that have `roleId`. `start` and `end` define the range bounds. + * `start` is inclusive and `end` is exclusive. + * + * Role bearers are not sorted in any particular way, and their ordering may change at any point. + * + * It is not necessary to call {getRoleMemberCount} before calling this function. Using `start = 0` and + * `end = type(uint256).max` will return every member of `roleId`. + * + * 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(uint64 roleId, uint256 start, uint256 end) public view virtual returns (address[] memory) { + return _roleMembers[roleId].values(start, end); + } + + /** + * @dev Returns the number of target function selectors that require `roleId` for the given `target`. + * Can be used together with {getRoleTargetFunction} to enumerate all target functions for a role on a specific target. + * + * NOTE: Given {ADMIN_ROLE} is the default role for every restricted function, passing {ADMIN_ROLE} as `roleId` will + * return 0. See {_updateRoleTargetFunction} for more details. + */ + function getRoleTargetFunctionCount(uint64 roleId, address target) public view virtual returns (uint256) { + return _roleTargetFunctions[roleId][target].length(); + } + + /** + * @dev Returns one of the target function selectors that require `roleId` for the given `target`. + * `index` must be a value between 0 and {getRoleTargetFunctionCount}, non-inclusive. + * + * Target function selectors are not sorted in any particular way, and their ordering may change at any point. + * + * WARNING: When using {getRoleTargetFunction} and {getRoleTargetFunctionCount}, 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 getRoleTargetFunction(uint64 roleId, address target, uint256 index) public view virtual returns (bytes4) { + return _roleTargetFunctions[roleId][target].at(index); + } + + /** + * @dev Returns a range of target function selectors that require `roleId` for the given `target`. + * `start` and `end` define the range bounds. `start` is inclusive and `end` is exclusive. + * + * Target function selectors are not sorted in any particular way, and their ordering may change at any point. + * + * It is not necessary to call {getRoleTargetFunctionCount} before calling this function. Using `start = 0` and + * `end = type(uint256).max` will return every function selector that `roleId` is allowed to call on `target`. + * + * 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. + * + * NOTE: Given {ADMIN_ROLE} is the default role for every restricted function, passing {ADMIN_ROLE} as `roleId` will + * return an empty array. See {_updateRoleTargetFunction} for more details. + */ + function getRoleTargetFunctions( + uint64 roleId, + address target, + uint256 start, + uint256 end + ) public view virtual returns (bytes4[] memory) { + return _roleTargetFunctions[roleId][target].values(start, end); + } + + /// @dev See {AccessManager-_grantRole}. Adds the account to the role members set. + function _grantRole( + uint64 roleId, + address account, + uint32 grantDelay, + uint32 executionDelay + ) internal virtual override returns (bool) { + bool granted = super._grantRole(roleId, account, grantDelay, executionDelay); + if (granted) { + _roleMembers[roleId].add(account); + } + return granted; + } + + /// @dev See {AccessManager-_revokeRole}. Removes the account from the role members set. + function _revokeRole(uint64 roleId, address account) internal virtual override returns (bool) { + bool revoked = super._revokeRole(roleId, account); + if (revoked) { + _roleMembers[roleId].remove(account); + } + return revoked; + } + + /** + * @dev See {AccessManager-_setTargetFunctionRole}. Adds the selector to the role target functions set. + * + * NOTE: This function does not track function selectors for the {ADMIN_ROLE}, since exhaustively tracking + * all restricted/admin functions is impractical (by default, all restricted functions are assigned to {ADMIN_ROLE}). + * Therefore, roles assigned as {ADMIN_ROLE} will not have their selectors included in this extension's tracking. + */ + function _setTargetFunctionRole(address target, bytes4 selector, uint64 roleId) internal virtual override { + // cache old role ID + uint64 oldRoleId = getTargetFunctionRole(target, selector); + + // call super + super._setTargetFunctionRole(target, selector, roleId); + + // update enumerable sets + if (oldRoleId != ADMIN_ROLE) { + _roleTargetFunctions[oldRoleId][target].remove(selector); + } + if (roleId != ADMIN_ROLE) { + _roleTargetFunctions[roleId][target].add(selector); + } + } +} diff --git a/examples/ERC4626Fees.sol b/examples/ERC4626Fees.sol index 1c2f79ec..3be58174 100644 --- a/examples/ERC4626Fees.sol +++ b/examples/ERC4626Fees.sol @@ -45,7 +45,7 @@ abstract contract ERC4626Fees is ERC4626 { return assets - _feeOnTotal(assets, _exitFeeBasisPoints()); } - /// @dev Send entry fee to {_entryFeeRecipient}. See {IERC4626-_deposit}. + /// @dev Send entry fee to {_entryFeeRecipient}. See {ERC4626-_deposit}. function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual override { uint256 fee = _feeOnTotal(assets, _entryFeeBasisPoints()); address recipient = _entryFeeRecipient(); @@ -57,7 +57,7 @@ abstract contract ERC4626Fees is ERC4626 { } } - /// @dev Send exit fee to {_exitFeeRecipient}. See {IERC4626-_deposit}. + /// @dev Send exit fee to {_exitFeeRecipient}. See {ERC4626-_withdraw}. function _withdraw( address caller, address receiver, diff --git a/examples/account/MyAccountEIP7702.sol b/examples/account/MyAccountEIP7702.sol new file mode 100644 index 00000000..9e7893ef --- /dev/null +++ b/examples/account/MyAccountEIP7702.sol @@ -0,0 +1,20 @@ +// contracts/MyAccountEIP7702.sol +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.20; + +import {Account} from "@openzeppelin/contracts/account/Account.sol"; +import {ERC7821} from "@openzeppelin/contracts/account/extensions/draft-ERC7821.sol"; +import {SignerEIP7702} from "@openzeppelin/contracts/utils/cryptography/signers/SignerEIP7702.sol"; +import {ERC721Holder} from "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol"; +import {ERC1155Holder} from "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol"; + +contract MyAccountEIP7702 is Account, SignerEIP7702, ERC7821, ERC721Holder, ERC1155Holder { + /// @dev Allows the entry point as an authorized executor. + function _erc7821AuthorizedExecutor( + address caller, + bytes32 mode, + bytes calldata executionData + ) internal view virtual override returns (bool) { + return caller == address(entryPoint()) || super._erc7821AuthorizedExecutor(caller, mode, executionData); + } +} diff --git a/examples/account/MyFactoryAccount.sol b/examples/account/MyFactoryAccount.sol index d095260c..4f1fd736 100644 --- a/examples/account/MyFactoryAccount.sol +++ b/examples/account/MyFactoryAccount.sol @@ -16,22 +16,32 @@ contract MyFactoryAccount { address private immutable _impl; constructor(address impl_) { - require(impl_.code.length > 0); _impl = impl_; } /// @dev Predict the address of the account - function predictAddress(bytes calldata callData) public view returns (address) { - return _impl.predictDeterministicAddress(keccak256(callData), address(this)); + function predictAddress(bytes32 salt, bytes calldata callData) public view returns (address, bytes32) { + bytes32 calldataSalt = _saltedCallData(salt, callData); + return (_impl.predictDeterministicAddress(calldataSalt, address(this)), calldataSalt); } /// @dev Create clone accounts on demand - function cloneAndInitialize(bytes calldata callData) public returns (address) { - address predicted = predictAddress(callData); + function cloneAndInitialize(bytes32 salt, bytes calldata callData) public returns (address) { + return _cloneAndInitialize(salt, callData); + } + + /// @dev Create clone accounts on demand and return the address. Uses `callData` to initialize the clone. + function _cloneAndInitialize(bytes32 salt, bytes calldata callData) internal returns (address) { + (address predicted, bytes32 _calldataSalt) = predictAddress(salt, callData); if (predicted.code.length == 0) { - _impl.cloneDeterministic(keccak256(callData)); + _impl.cloneDeterministic(_calldataSalt); predicted.functionCall(callData); } return predicted; } + + function _saltedCallData(bytes32 salt, bytes calldata callData) internal pure returns (bytes32) { + // Scope salt to the callData to avoid front-running the salt with a different callData + return keccak256(abi.encodePacked(salt, callData)); + } } diff --git a/examples/crosschain/MyERC7786GatewaySource.sol b/examples/crosschain/MyERC7786GatewaySource.sol index 95f3127f..b643b4da 100644 --- a/examples/crosschain/MyERC7786GatewaySource.sol +++ b/examples/crosschain/MyERC7786GatewaySource.sol @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.24; -import {IERC7786GatewaySource} from "@openzeppelin/community-contracts/interfaces/IERC7786.sol"; +import {IERC7786GatewaySource} from "@openzeppelin/contracts/interfaces/draft-IERC7786.sol"; import {InteroperableAddress} from "@openzeppelin/contracts/utils/draft-InteroperableAddress.sol"; abstract contract MyERC7786GatewaySource is IERC7786GatewaySource { From 3fb6a628cba66b8d6c23dcc405afeb61d277e66e Mon Sep 17 00:00:00 2001 From: stevep0z <255929980+stevep0z@users.noreply.github.com> Date: Thu, 2 Apr 2026 15:40:46 -0500 Subject: [PATCH 06/11] feat: add receiver workflows for contracts and confidential-contracts New GitHub Actions receiver workflows for API doc generation: - generate-api-docs-contracts.yml: versioned paths (5.x/api), tag-based - generate-api-docs-confidential-contracts.yml: non-versioned (api/), tag-based Both include link validation step before PR creation. --- ...nerate-api-docs-confidential-contracts.yml | 161 +++++++++++++++++ .../workflows/generate-api-docs-contracts.yml | 162 ++++++++++++++++++ 2 files changed, 323 insertions(+) create mode 100644 .github/workflows/generate-api-docs-confidential-contracts.yml create mode 100644 .github/workflows/generate-api-docs-contracts.yml diff --git a/.github/workflows/generate-api-docs-confidential-contracts.yml b/.github/workflows/generate-api-docs-confidential-contracts.yml new file mode 100644 index 00000000..17da9fc1 --- /dev/null +++ b/.github/workflows/generate-api-docs-confidential-contracts.yml @@ -0,0 +1,161 @@ +# Docs Repository Receiver - Non-Versioned Paths +# Receives trigger from openzeppelin-confidential-contracts and generates API docs + +name: Generate API Docs - Confidential Contracts + +on: + workflow_dispatch: + inputs: + tag_name: + description: 'Tag name or commit SHA to generate docs from' + required: true + type: string + default: 'v0.4.0' + trigger_type: + description: 'Trigger type (tag or commit)' + required: false + type: string + default: 'tag' + +env: + SOURCE_REPO: 'OpenZeppelin/openzeppelin-confidential-contracts' + SOURCE_REPO_URL: 'https://github.com/OpenZeppelin/openzeppelin-confidential-contracts.git' + BASE_OUTPUT_PATH: 'content/confidential-contracts' + USE_VERSIONED_PATHS: 'false' + +jobs: + generate-docs: + runs-on: ubuntu-latest + + steps: + - name: Log trigger information + run: | + echo "🚀 API Documentation Generation Triggered" + echo "📦 Repository: ${{ env.SOURCE_REPO }}" + echo "🏷️ Tag/Ref: ${{ inputs.tag_name }}" + echo "📋 Trigger type: ${{ inputs.trigger_type }}" + + - name: Checkout docs repository + uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10.17.1 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Determine output directory + id: config + run: | + TAG_NAME="${{ inputs.tag_name }}" + TRIGGER_TYPE="${{ inputs.trigger_type }}" + BASE_PATH="${{ env.BASE_OUTPUT_PATH }}" + USE_VERSIONED="${{ env.USE_VERSIONED_PATHS }}" + + if [[ "$USE_VERSIONED" == "false" ]]; then + OUTPUT_DIR="${BASE_PATH}/api" + echo "📁 Using non-versioned path" + elif [[ "$TRIGGER_TYPE" == "commit" ]]; then + OUTPUT_DIR="${BASE_PATH}/latest/api" + echo "🔄 Using latest path for commit-based trigger" + else + if [[ "$TAG_NAME" =~ v([0-9]+) ]]; then + MAJOR_VERSION="${BASH_REMATCH[1]}" + OUTPUT_DIR="${BASE_PATH}/${MAJOR_VERSION}.x/api" + echo "📊 Detected version: ${MAJOR_VERSION}.x" + else + OUTPUT_DIR="${BASE_PATH}/latest/api" + echo "⚠️ Non-standard tag format, using latest" + fi + fi + + echo "📂 Output directory: $OUTPUT_DIR" + echo "output-dir=$OUTPUT_DIR" >> $GITHUB_OUTPUT + + - name: Generate API Documentation + run: | + echo "🔄 Generating API documentation..." + + node scripts/generate-api-docs.js \ + --repo "${{ env.SOURCE_REPO_URL }}" \ + --branch "${{ inputs.tag_name }}" \ + --api-output "${{ steps.config.outputs.output-dir }}" + + - name: Validate generated documentation + run: | + pnpm run postinstall + pnpm run lint:links + + - name: Create Pull Request for documentation changes + id: create_pr + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git config --local user.email "docs-automation@openzeppelin.com" + git config --local user.name "OpenZeppelin Docs Bot" + + if [ -n "$(git status --porcelain)" ]; then + echo "📝 Creating branch and committing documentation changes..." + + BRANCH_NAME="docs/api-update-${{ env.SOURCE_REPO }}-${{ inputs.tag_name }}" + BRANCH_NAME=$(echo "$BRANCH_NAME" | sed 's/\//-/g' | sed 's/OpenZeppelin-//g') + + git checkout -b "$BRANCH_NAME" + git add . + git commit -m "Update API docs for ${{ env.SOURCE_REPO }} ${{ inputs.tag_name }} + + - Repository: ${{ env.SOURCE_REPO }} + - Ref: ${{ inputs.tag_name }} + - Trigger: ${{ inputs.trigger_type }} + - Output: ${{ steps.config.outputs.output-dir }} + - Timestamp: $(date -u '+%Y-%m-%d %H:%M:%S UTC') + + Auto-generated via workflow_dispatch" + + git push origin "$BRANCH_NAME" + + gh pr create --title "[CI] Update API docs for ${{ env.SOURCE_REPO }} ${{ inputs.tag_name }}" \ + --body "## API Documentation Update + + This Pull Request updates the API documentation. + + ### Source Information + - **Repository:** ${{ env.SOURCE_REPO }} + - **Reference:** ${{ inputs.tag_name }} + - **Trigger Type:** ${{ inputs.trigger_type }} + - **Output Directory:** ${{ steps.config.outputs.output-dir }} + - **Timestamp:** $(date -u '+%Y-%m-%d %H:%M:%S UTC') + + Auto-generated via workflow_dispatch" \ + --base main \ + --head "$BRANCH_NAME" || echo "⚠️ Pull Request creation failed" + + echo "✅ Pull Request created successfully" + echo "pr-created=true" >> $GITHUB_OUTPUT + else + echo "ℹ️ No changes detected - documentation is up to date" + echo "pr-created=false" >> $GITHUB_OUTPUT + fi + + - name: Create job summary + run: | + echo "## 📚 API Documentation Generation Complete" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Source Information" >> $GITHUB_STEP_SUMMARY + echo "- **Repository:** ${{ env.SOURCE_REPO }}" >> $GITHUB_STEP_SUMMARY + echo "- **Reference:** ${{ inputs.tag_name }}" >> $GITHUB_STEP_SUMMARY + echo "- **Trigger Type:** ${{ inputs.trigger_type }}" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Output" >> $GITHUB_STEP_SUMMARY + echo "- **Directory:** ${{ steps.config.outputs.output-dir }}" >> $GITHUB_STEP_SUMMARY + echo "- **Status:** ✅ Complete" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/generate-api-docs-contracts.yml b/.github/workflows/generate-api-docs-contracts.yml new file mode 100644 index 00000000..666fd564 --- /dev/null +++ b/.github/workflows/generate-api-docs-contracts.yml @@ -0,0 +1,162 @@ +# Docs Repository Receiver - Versioned Paths +# Receives trigger from openzeppelin-contracts and generates API docs + +name: Generate API Docs - Contracts + +on: + workflow_dispatch: + inputs: + tag_name: + description: 'Tag name or commit SHA to generate docs from' + required: true + type: string + default: 'v5.6.1' + trigger_type: + description: 'Trigger type (tag or commit)' + required: false + type: string + default: 'tag' + +env: + SOURCE_REPO: 'OpenZeppelin/openzeppelin-contracts' + SOURCE_REPO_URL: 'https://github.com/OpenZeppelin/openzeppelin-contracts.git' + BASE_OUTPUT_PATH: 'content/contracts' + USE_VERSIONED_PATHS: 'true' + +jobs: + generate-docs: + runs-on: ubuntu-latest + + steps: + - name: Log trigger information + run: | + echo "🚀 API Documentation Generation Triggered" + echo "📦 Repository: ${{ env.SOURCE_REPO }}" + echo "🏷️ Tag/Ref: ${{ inputs.tag_name }}" + echo "📋 Trigger type: ${{ inputs.trigger_type }}" + + - name: Checkout docs repository + uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10.17.1 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Determine output directory + id: config + run: | + TAG_NAME="${{ inputs.tag_name }}" + TRIGGER_TYPE="${{ inputs.trigger_type }}" + BASE_PATH="${{ env.BASE_OUTPUT_PATH }}" + USE_VERSIONED="${{ env.USE_VERSIONED_PATHS }}" + + if [[ "$USE_VERSIONED" == "false" ]]; then + OUTPUT_DIR="${BASE_PATH}/api" + echo "📁 Using non-versioned path" + elif [[ "$TRIGGER_TYPE" == "commit" ]]; then + OUTPUT_DIR="${BASE_PATH}/latest/api" + echo "🔄 Using latest path for commit-based trigger" + else + # Extract major version from tag (v5.6.1 -> 5, v5.6.0 -> 5) + if [[ "$TAG_NAME" =~ v([0-9]+) ]]; then + MAJOR_VERSION="${BASH_REMATCH[1]}" + OUTPUT_DIR="${BASE_PATH}/${MAJOR_VERSION}.x/api" + echo "📊 Detected version: ${MAJOR_VERSION}.x" + else + OUTPUT_DIR="${BASE_PATH}/latest/api" + echo "⚠️ Non-standard tag format, using latest" + fi + fi + + echo "📂 Output directory: $OUTPUT_DIR" + echo "output-dir=$OUTPUT_DIR" >> $GITHUB_OUTPUT + + - name: Generate API Documentation + run: | + echo "🔄 Generating API documentation..." + + node scripts/generate-api-docs.js \ + --repo "${{ env.SOURCE_REPO_URL }}" \ + --branch "${{ inputs.tag_name }}" \ + --api-output "${{ steps.config.outputs.output-dir }}" + + - name: Validate generated documentation + run: | + pnpm run postinstall + pnpm run lint:links + + - name: Create Pull Request for documentation changes + id: create_pr + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git config --local user.email "docs-automation@openzeppelin.com" + git config --local user.name "OpenZeppelin Docs Bot" + + if [ -n "$(git status --porcelain)" ]; then + echo "📝 Creating branch and committing documentation changes..." + + BRANCH_NAME="docs/api-update-${{ env.SOURCE_REPO }}-${{ inputs.tag_name }}" + BRANCH_NAME=$(echo "$BRANCH_NAME" | sed 's/\//-/g' | sed 's/OpenZeppelin-//g') + + git checkout -b "$BRANCH_NAME" + git add . + git commit -m "Update API docs for ${{ env.SOURCE_REPO }} ${{ inputs.tag_name }} + + - Repository: ${{ env.SOURCE_REPO }} + - Ref: ${{ inputs.tag_name }} + - Trigger: ${{ inputs.trigger_type }} + - Output: ${{ steps.config.outputs.output-dir }} + - Timestamp: $(date -u '+%Y-%m-%d %H:%M:%S UTC') + + Auto-generated via workflow_dispatch" + + git push origin "$BRANCH_NAME" + + gh pr create --title "[CI] Update API docs for ${{ env.SOURCE_REPO }} ${{ inputs.tag_name }}" \ + --body "## API Documentation Update + + This Pull Request updates the API documentation. + + ### Source Information + - **Repository:** ${{ env.SOURCE_REPO }} + - **Reference:** ${{ inputs.tag_name }} + - **Trigger Type:** ${{ inputs.trigger_type }} + - **Output Directory:** ${{ steps.config.outputs.output-dir }} + - **Timestamp:** $(date -u '+%Y-%m-%d %H:%M:%S UTC') + + Auto-generated via workflow_dispatch" \ + --base main \ + --head "$BRANCH_NAME" || echo "⚠️ Pull Request creation failed" + + echo "✅ Pull Request created successfully" + echo "pr-created=true" >> $GITHUB_OUTPUT + else + echo "ℹ️ No changes detected - documentation is up to date" + echo "pr-created=false" >> $GITHUB_OUTPUT + fi + + - name: Create job summary + run: | + echo "## 📚 API Documentation Generation Complete" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Source Information" >> $GITHUB_STEP_SUMMARY + echo "- **Repository:** ${{ env.SOURCE_REPO }}" >> $GITHUB_STEP_SUMMARY + echo "- **Reference:** ${{ inputs.tag_name }}" >> $GITHUB_STEP_SUMMARY + echo "- **Trigger Type:** ${{ inputs.trigger_type }}" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Output" >> $GITHUB_STEP_SUMMARY + echo "- **Directory:** ${{ steps.config.outputs.output-dir }}" >> $GITHUB_STEP_SUMMARY + echo "- **Status:** ✅ Complete" >> $GITHUB_STEP_SUMMARY From 388812e4fd31b4d663caf5b129a404a791602259 Mon Sep 17 00:00:00 2001 From: stevep0z <255929980+stevep0z@users.noreply.github.com> Date: Thu, 2 Apr 2026 15:40:52 -0500 Subject: [PATCH 07/11] feat: add link validation to community-contracts receiver workflow Adds postinstall + lint:links step before PR creation to catch broken links in generated docs before they're merged. --- .github/workflows/generate-api-docs-community-contracts.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/generate-api-docs-community-contracts.yml b/.github/workflows/generate-api-docs-community-contracts.yml index 01f4fd5d..961a3d4a 100644 --- a/.github/workflows/generate-api-docs-community-contracts.yml +++ b/.github/workflows/generate-api-docs-community-contracts.yml @@ -105,6 +105,11 @@ jobs: --branch "${{ inputs.tag_name }}" \ --api-output "${{ steps.config.outputs.output-dir }}" + - name: Validate generated documentation + run: | + pnpm run postinstall + pnpm run lint:links + - name: Create Pull Request for documentation changes id: create_pr env: From 814a708009fa560f7105fd1be7eaf8f277c76ebb Mon Sep 17 00:00:00 2001 From: stevep0z <255929980+stevep0z@users.noreply.github.com> Date: Thu, 2 Apr 2026 15:41:00 -0500 Subject: [PATCH 08/11] chore: add temp-* to gitignore for generate-api-docs cleanup Prevents temp directories from showing in source control if a generate-api-docs.js run is interrupted before cleanup. --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index f6be50b5..aa877a79 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,9 @@ yarn-error.log* package-lock.json yarn.lock +# temp dirs from generate-api-docs.js +temp-*/ + # others .env*.local .vercel From bf31e1ba1d92bbb9525ddbd28274dcfad9079ccc Mon Sep 17 00:00:00 2001 From: stevep0z <255929980+stevep0z@users.noreply.github.com> Date: Thu, 2 Apr 2026 16:24:19 -0500 Subject: [PATCH 09/11] feat: add --pre-generated flag for non-Solidity source repos For repos using Move, Rust, Cairo, or other languages that generate MDX through their own tooling, the script can now skip template injection and docgen entirely and just copy pre-generated MDX files. Usage: node generate-api-docs.js --repo --api-output --pre-generated This keeps the workflow generator-agnostic: Solidity repos use the default injection mode, other repos use --pre-generated. --- scripts/generate-api-docs.js | 61 +++++++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 7 deletions(-) diff --git a/scripts/generate-api-docs.js b/scripts/generate-api-docs.js index 60ea22a2..f682aafb 100755 --- a/scripts/generate-api-docs.js +++ b/scripts/generate-api-docs.js @@ -20,6 +20,7 @@ function parseArgs() { apiOutputDir: "content/contracts/5.x/api", examplesOutputDir: "examples", skipTemplateInject: false, + preGenerated: null, }; for (let i = 0; i < args.length; i++) { @@ -53,6 +54,10 @@ function parseArgs() { case "--skip-template-inject": options.skipTemplateInject = true; break; + case "--pre-generated": + case "-p": + options.preGenerated = args[++i]; + break; default: console.error(`Unknown option: ${arg}`); showHelp(); @@ -75,12 +80,20 @@ Options: -t, --temp-dir Temporary directory for cloning (default: temp-contracts) -a, --api-output API documentation output directory (default: content/contracts/5.x/api) -e, --examples-output Examples output directory (default: examples) + -p, --pre-generated Path within repo containing pre-generated MDX files (skips docgen) --skip-template-inject Skip injecting canonical templates (use source repo's own) -h, --help Show this help message +Modes: + Default (Solidity repos): Injects canonical templates, runs hardhat docgen, copies output + --pre-generated (other): Skips docgen entirely, copies pre-generated MDX from source repo + Examples: - node generate-api-docs.js --repo https://github.com/OpenZeppelin/openzeppelin-contracts.git --branch master - node generate-api-docs.js --repo /path/to/local/repo --api-output content/community-contracts/api + # Solidity repo (injects templates, runs docgen): + node generate-api-docs.js --repo https://github.com/OpenZeppelin/openzeppelin-contracts.git --api-output content/contracts/5.x/api + + # Non-Solidity repo (copies pre-generated MDX): + node generate-api-docs.js --repo https://github.com/OpenZeppelin/cairo-contracts.git --api-output content/contracts-cairo/3.x/api --pre-generated docs/api `); } @@ -206,13 +219,18 @@ async function generateApiDocs(options) { apiOutputDir, examplesOutputDir, skipTemplateInject, + preGenerated, } = options; - console.log("🔄 Generating OpenZeppelin Contracts API documentation..."); + console.log("🔄 Generating OpenZeppelin API documentation..."); console.log(`📦 Repository: ${contractsRepo}`); console.log(`🌿 Branch: ${contractsBranch}`); console.log(`📂 API Output: ${apiOutputDir}`); - console.log(`📂 Examples Output: ${examplesOutputDir}`); + if (preGenerated) { + console.log(`📋 Mode: pre-generated (source path: ${preGenerated})`); + } else { + console.log(`📂 Examples Output: ${examplesOutputDir}`); + } try { // Back up index.mdx if it exists @@ -233,8 +251,8 @@ async function generateApiDocs(options) { // Create output directory await fs.mkdir(apiOutputDir, { recursive: true }); - // Clone the contracts repository (works for both URLs and local paths) - console.log("📦 Cloning contracts repository..."); + // Clone the repository (works for both URLs and local paths) + console.log("📦 Cloning repository..."); execSync( `git clone --depth 1 --branch "${contractsBranch}" --recurse-submodules "${contractsRepo}" "${tempDir}"`, { @@ -242,7 +260,36 @@ async function generateApiDocs(options) { }, ); - // Inject canonical templates if not skipped + // Pre-generated mode: just copy MDX files from source repo, skip docgen + if (preGenerated) { + const sourcePath = path.join(tempDir, preGenerated); + try { + await fs.access(sourcePath); + await copyDirRecursive(sourcePath, apiOutputDir); + console.log(`✅ Pre-generated docs copied from ${preGenerated}`); + } catch (error) { + console.log( + `❌ Error: Pre-generated docs not found at ${preGenerated}`, + ); + process.exit(1); + } + + // Restore index.mdx if backed up + if (indexBackup) { + console.log("♻️ Restoring index.mdx..."); + await fs.writeFile(indexPath, indexBackup, "utf8"); + } + + // Clean up + console.log("🧹 Cleaning up..."); + await fs.rm(tempDir, { recursive: true, force: true }); + + console.log("🎉 API documentation generation complete!"); + console.log(`📂 Documentation available in: ${apiOutputDir}`); + return; + } + + // Solidity docgen mode: inject templates and run generation if (!skipTemplateInject) { await injectTemplates(tempDir, options); } From 6692a23b9b8ee62f8dabbf876fa6f2f54f3d34b8 Mon Sep 17 00:00:00 2001 From: stevep0z <255929980+stevep0z@users.noreply.github.com> Date: Sat, 4 Apr 2026 20:41:37 -0500 Subject: [PATCH 10/11] docs: update README with API reference generation workflow Replace the old manual template-copy instructions with documentation for the template injection approach and automated GitHub workflow. Covers Solidity repos, non-Solidity repos (--pre-generated flag), canonical template locations, and versioning strategy. --- README.md | 93 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 66 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 6dcab4a1..84b491fb 100644 --- a/README.md +++ b/README.md @@ -61,49 +61,88 @@ docs/ For detailed information about the codebase structure, navigation system, and component architecture, see [CONTRIBUTING.md](CONTRIBUTING.md) -## Solidity Docgen +## API Reference Generation -Any library using Solidity Docgen can utilize the `docgen` templates and config file in their repo to generate markdown API references for the docs. To get started follow the instructions below: +API reference pages are auto-generated from source contract repositories and placed in the `content/` directory. The generation is handled by `scripts/generate-api-docs.js`, which supports two modes depending on the source repo's language. -### 1. Add the templates to your repo +### Solidity Repos -Inside this docs repo is the [`docgen`](https://github.com/OpenZeppelin/docs/tree/main/docgen) folder which contains [`templates-md`](https://github.com/OpenZeppelin/docs/tree/main/docgen/templates-md) and [`config-md.js`](https://github.com/OpenZeppelin/docs/blob/main/docgen/config-md.js). Copy both of these items into your `docs` folder in your repo. Once there open the [`templates-md/helpers.js`](https://github.com/OpenZeppelin/docs/blob/main/docgen/templates-md/helpers.js) file and update the `API_DOCS_PATH` constant to match your export path. Also open [`templates-md/contract.hbs`](https://github.com/OpenZeppelin/docs/blob/main/docgen/templates-md/contract.hbs) to modify the solidity import path and the github link. +For Solidity repos using [solidity-docgen](https://github.com/OpenZeppelin/solidity-docgen), the script **injects canonical MDX templates** from this repo's [`docgen/templates-md/`](https://github.com/OpenZeppelin/docs/tree/main/docgen/templates-md) into the cloned source repo before running docgen. Source repos do not need MDX templates committed. -```js -const API_DOCS_PATH = 'contracts/5.x/api'; -// const API_DOCS_PATH = 'community-contracts/api'; -// const API_DOCS_PATH = 'confidential-contracts/api'; -// const API_DOCS_PATH = 'uniswap-hooks/api'; -``` +The script automatically: +- Copies `docgen/templates-md/` and `docgen/config-md.js` into the source repo +- Sets `API_DOCS_PATH` based on the output directory +- Updates the GitHub source link and import path for the source repo +- Patches `hardhat.config.js` to use the MDX config +- Runs `npm run prepare-docs` to generate MDX files +- Copies the output to the specified `content/` directory -### 2. Update the `hardhat.config.js` file +**Run locally:** -With the `config-md.js` file now in the `docs` folder, update your `hardhat.config.js` to use the new config file. +```bash +# openzeppelin-contracts +node scripts/generate-api-docs.js \ + --repo https://github.com/OpenZeppelin/openzeppelin-contracts.git \ + --branch v5.6.1 \ + --api-output content/contracts/5.x/api -```js -{ - // other config options - docgen: require('./docs/config-md'), -} -``` +# community-contracts +node scripts/generate-api-docs.js \ + --repo https://github.com/OpenZeppelin/openzeppelin-community-contracts.git \ + --branch master \ + --api-output content/community-contracts/api -Once added make sure these are accessible in your branches going forward. If you are generating an API reference for previous branches you will need to repeat steps 1 and 2 for those branches. +# confidential-contracts +node scripts/generate-api-docs.js \ + --repo https://github.com/OpenZeppelin/openzeppelin-confidential-contracts.git \ + --branch v0.4.0 \ + --api-output content/confidential-contracts/api +``` -### 3. Run the `generate-api-docs.js` script +### Non-Solidity Repos -With your remote repo setup with the new template files you can run the `scripts/generate-api-docs.js` script. Be sure to pass in the correct arguements for your docs +For repos using other languages (Cairo, Move, Rust, etc.) that generate MDX through their own tooling, use the `--pre-generated` flag to skip docgen and copy pre-built MDX files directly: ```bash node scripts/generate-api-docs.js \ - --repo https://github.com/OpenZeppelin/openzeppelin-community-contracts.git \ - --branch release-v5.5 \ - --api-output content/contracts/5.x/api \ - --examples-output examples + --repo https://github.com/OpenZeppelin/cairo-contracts.git \ + --branch v3.0.0 \ + --api-output content/contracts-cairo/3.x/api \ + --pre-generated docs/api ``` -### Automated Setup +### Canonical Templates + +The MDX templates that control API reference output live in [`docgen/templates-md/`](https://github.com/OpenZeppelin/docs/tree/main/docgen/templates-md): + +- `helpers.js` - Reference resolution, link generation, callout processing, natspec handling +- `contract.hbs` - Contract page layout (heading, GitHub link, import, function/event/error cards) +- `page.hbs` - Page wrapper with frontmatter +- `properties.js` - Solidity AST property helpers (anchors, inheritance, function lists) +- `config-md.js` - Solidity docgen configuration + +Changes to these templates affect all source repos on the next generation run. + +### Automated Workflow + +The generation runs automatically via GitHub Actions: + +1. **Source repo** pushes a release tag (e.g., `v5.6.1`) or commits to a tracked branch +2. **Source trigger workflow** (`.github/workflows/docs.yml` in the source repo) calls this repo's receiver workflow via `gh workflow run` +3. **Receiver workflow** (`.github/workflows/generate-api-docs-{name}.yml`) runs `generate-api-docs.js`, validates links, and creates a PR + +Receiver workflows in this repo: +- `generate-api-docs-contracts.yml` - versioned paths (`content/contracts/{major}.x/api`) +- `generate-api-docs-community-contracts.yml` - non-versioned (`content/community-contracts/api`) +- `generate-api-docs-confidential-contracts.yml` - non-versioned (`content/confidential-contracts/api`) + +Source repos need a `DOCS_REPO_TOKEN` secret (GitHub PAT with `repo` + `workflow` scopes) for the trigger workflow to call this repo. + +### Versioning -In the case you want to setup an automated GitHub workflow to create these API docs visit the [docs-api-generation-workflows](https://github.com/OpenZeppelin/docs-api-generation-workflows) for more info. This repo (`OpenZeppelin/docs`) is the `Docs Receiver` side of the equation. +- Major version changes (e.g., 4.x to 5.x) create a new versioned directory +- Minor and patch releases within a major version regenerate the same directory +- Non-versioned repos (community-contracts, confidential-contracts) use a flat `api/` path ## Content Management From 80a979a8f1faba1a0296cb5a361007458573f3e9 Mon Sep 17 00:00:00 2001 From: stevep0z <255929980+stevep0z@users.noreply.github.com> Date: Sat, 4 Apr 2026 20:55:59 -0500 Subject: [PATCH 11/11] fix: address security scan findings in workflows and scripts - Use execFileSync for git clone to prevent command injection from CLI arguments (array args instead of shell string interpolation) - Add explicit permissions block to all receiver workflows to limit GITHUB_TOKEN scope to contents:write and pull-requests:write --- .../generate-api-docs-community-contracts.yml | 5 ++++- .../generate-api-docs-confidential-contracts.yml | 4 ++++ .github/workflows/generate-api-docs-contracts.yml | 4 ++++ scripts/generate-api-docs.js | 11 +++++------ 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/generate-api-docs-community-contracts.yml b/.github/workflows/generate-api-docs-community-contracts.yml index 961a3d4a..0e4de49a 100644 --- a/.github/workflows/generate-api-docs-community-contracts.yml +++ b/.github/workflows/generate-api-docs-community-contracts.yml @@ -26,7 +26,10 @@ on: type: string default: 'commit' # TODO: Update if using tags -# TODO: Configure these environment variables for your contract +permissions: + contents: write + pull-requests: write + env: SOURCE_REPO: 'OpenZeppelin/openzeppelin-community-contracts' SOURCE_REPO_URL: 'https://github.com/OpenZeppelin/openzeppelin-community-contracts.git' diff --git a/.github/workflows/generate-api-docs-confidential-contracts.yml b/.github/workflows/generate-api-docs-confidential-contracts.yml index 17da9fc1..c9f17c25 100644 --- a/.github/workflows/generate-api-docs-confidential-contracts.yml +++ b/.github/workflows/generate-api-docs-confidential-contracts.yml @@ -17,6 +17,10 @@ on: type: string default: 'tag' +permissions: + contents: write + pull-requests: write + env: SOURCE_REPO: 'OpenZeppelin/openzeppelin-confidential-contracts' SOURCE_REPO_URL: 'https://github.com/OpenZeppelin/openzeppelin-confidential-contracts.git' diff --git a/.github/workflows/generate-api-docs-contracts.yml b/.github/workflows/generate-api-docs-contracts.yml index 666fd564..c1d9ad57 100644 --- a/.github/workflows/generate-api-docs-contracts.yml +++ b/.github/workflows/generate-api-docs-contracts.yml @@ -17,6 +17,10 @@ on: type: string default: 'tag' +permissions: + contents: write + pull-requests: write + env: SOURCE_REPO: 'OpenZeppelin/openzeppelin-contracts' SOURCE_REPO_URL: 'https://github.com/OpenZeppelin/openzeppelin-contracts.git' diff --git a/scripts/generate-api-docs.js b/scripts/generate-api-docs.js index f682aafb..ad0b375c 100755 --- a/scripts/generate-api-docs.js +++ b/scripts/generate-api-docs.js @@ -2,7 +2,7 @@ import { promises as fs } from "node:fs"; import path from "node:path"; -import { execSync } from "node:child_process"; +import { execSync, execFileSync } from "node:child_process"; import { fileURLToPath } from "node:url"; const __filename = fileURLToPath(import.meta.url); @@ -253,11 +253,10 @@ async function generateApiDocs(options) { // Clone the repository (works for both URLs and local paths) console.log("📦 Cloning repository..."); - execSync( - `git clone --depth 1 --branch "${contractsBranch}" --recurse-submodules "${contractsRepo}" "${tempDir}"`, - { - stdio: "inherit", - }, + execFileSync( + "git", + ["clone", "--depth", "1", "--branch", contractsBranch, "--recurse-submodules", contractsRepo, tempDir], + { stdio: "inherit" }, ); // Pre-generated mode: just copy MDX files from source repo, skip docgen