diff --git a/content/confidential-contracts/api/finance.mdx b/content/confidential-contracts/api/finance.mdx index faa9990d..cc04cac5 100644 --- a/content/confidential-contracts/api/finance.mdx +++ b/content/confidential-contracts/api/finance.mdx @@ -23,7 +23,7 @@ For convenience, this directory also includes: ## `ERC7821WithExecutor` - + @@ -145,7 +145,7 @@ function _erc7821AuthorizedExecutor( ## `VestingWalletCliffConfidential` - + @@ -328,7 +328,7 @@ The specified cliff duration is larger than the vesting duration. ## `VestingWalletConfidential` - + @@ -338,7 +338,7 @@ The specified cliff duration is larger than the vesting duration. import "@openzeppelin/confidential-contracts/finance/VestingWalletConfidential.sol"; ``` -A vesting wallet is an ownable contract that can receive ConfidentialFungibleTokens, and release these +A vesting wallet is an ownable contract that can receive ERC7984 tokens, and release these assets to the wallet owner, also referred to as "beneficiary", according to a vesting schedule. Any assets transferred to this contract will follow the vesting schedule as if they were locked from the beginning. @@ -506,7 +506,7 @@ Amount of token already released
Getter for the amount of releasable `token` tokens. `token` should be the address of an -[`IConfidentialFungibleToken`](./interfaces#IConfidentialFungibleToken) contract. +[`IERC7984`](/confidential-contracts/api/interfaces#IERC7984) contract.
@@ -622,7 +622,7 @@ Emitted when releasable vested tokens are released. ## `VestingWalletConfidentialFactory` - + @@ -641,7 +641,7 @@ functions remain unimplemented to allow for custom implementations of the vestin

Functions

- [constructor()](#VestingWalletConfidentialFactory-constructor--) -- [batchFundVestingWalletConfidential(confidentialFungibleToken, vestingPlans, inputProof)](#VestingWalletConfidentialFactory-batchFundVestingWalletConfidential-address-struct-VestingWalletConfidentialFactory-VestingPlan---bytes-) +- [batchFundVestingWalletConfidential(token, vestingPlans, inputProof)](#VestingWalletConfidentialFactory-batchFundVestingWalletConfidential-address-struct-VestingWalletConfidentialFactory-VestingPlan---bytes-) - [createVestingWalletConfidential(initArgs)](#VestingWalletConfidentialFactory-createVestingWalletConfidential-bytes-) - [predictVestingWalletConfidential(initArgs)](#VestingWalletConfidentialFactory-predictVestingWalletConfidential-bytes-) - [_validateVestingWalletInitArgs(initArgs)](#VestingWalletConfidentialFactory-_validateVestingWalletInitArgs-bytes-) @@ -654,7 +654,7 @@ functions remain unimplemented to allow for custom implementations of the vestin

Events

-- [VestingWalletConfidentialFunded(vestingWalletConfidential, confidentialFungibleToken, transferredAmount, initArgs)](#VestingWalletConfidentialFactory-VestingWalletConfidentialFunded-address-address-euint64-bytes-) +- [VestingWalletConfidentialFunded(vestingWalletConfidential, token, transferredAmount, initArgs)](#VestingWalletConfidentialFactory-VestingWalletConfidentialFunded-address-address-euint64-bytes-) - [VestingWalletConfidentialCreated(vestingWalletConfidential, initArgs)](#VestingWalletConfidentialFactory-VestingWalletConfidentialCreated-address-bytes-)
@@ -678,7 +678,7 @@ functions remain unimplemented to allow for custom implementations of the vestin
-

batchFundVestingWalletConfidential(address confidentialFungibleToken, struct VestingWalletConfidentialFactory.VestingPlan[] vestingPlans, bytes inputProof)

+

batchFundVestingWalletConfidential(address token, struct VestingWalletConfidentialFactory.VestingPlan[] vestingPlans, bytes inputProof)

public

# @@ -806,7 +806,7 @@ Gets create2 salt for a confidential vesting wallet.
-

VestingWalletConfidentialFunded(address indexed vestingWalletConfidential, address indexed confidentialFungibleToken, euint64 transferredAmount, bytes initArgs)

+

VestingWalletConfidentialFunded(address indexed vestingWalletConfidential, address indexed token, euint64 transferredAmount, bytes initArgs)

event

# diff --git a/content/confidential-contracts/api/governance.mdx b/content/confidential-contracts/api/governance.mdx index d8607c00..3df0fd38 100644 --- a/content/confidential-contracts/api/governance.mdx +++ b/content/confidential-contracts/api/governance.mdx @@ -16,7 +16,7 @@ This directory includes primitives for on-chain confidential governance. ## `VotesConfidential` - + @@ -33,7 +33,7 @@ This contract keeps a history (checkpoints) of each account's confidential vote voting power can be delegated either by calling the [`VotesConfidential.delegate`](#VotesConfidential-delegate-address-) function directly, or by providing a signature to be used with [`VotesConfidential.delegateBySig`](#VotesConfidential-delegateBySig-address-uint256-uint256-uint8-bytes32-bytes32-). Confidential voting power handles can be queried through the public accessors [`VotesConfidential.getVotes`](#VotesConfidential-getVotes-address-) and [`VotesConfidential.getPastVotes`](#VotesConfidential-getPastVotes-address-uint256-) but can only be decrypted by accounts -allowed to access them. Ensure that [`HandleAccessManager._validateHandleAllowance`](./utils#HandleAccessManager-_validateHandleAllowance-bytes32-) is implemented properly, allowing all +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 diff --git a/content/confidential-contracts/api/index.mdx b/content/confidential-contracts/api/index.mdx index 2a562ff0..87f9575e 100644 --- a/content/confidential-contracts/api/index.mdx +++ b/content/confidential-contracts/api/index.mdx @@ -12,7 +12,8 @@ Smart contract token utilities and implementations for ERC7984, a confidential t - **[ERC7984Freezable](./api/token#ERC7984Freezable)** - Extension with freezing mechanism - **[ERC7984ObserverAccess](./api/token#ERC7984ObserverAccess)** - Extension allowing observers to access transfer amounts - **[ERC7984Restricted](./api/token#ERC7984Restricted)** - Extension implementing user account transfer restrictions -- **[ERC7984Votes](./api/token#ERC7984Votes)** - Extension supporting confidential votes tracking and delegation +- **[ERC7984Omnibus](./api/token#ERC7984Omnibus)** - Extension for omnibus transfers with encrypted sub-account addresses +- **[ERC7984Rwa](./api/token#ERC7984Rwa)** - Extension supporting confidential Real World Assets with compliance checks - **[ERC7984Utils](./api/token#ERC7984Utils)** - Utility library for ERC7984 functions ### [Finance](./api/finance) @@ -33,6 +34,7 @@ Core interfaces for interacting with confidential contracts. - **[IERC7984](./api/interfaces#IERC7984)** - Interface for confidential fungible token standard - **[IERC7984Receiver](./api/interfaces#IERC7984Receiver)** - Interface for contracts receiving ERC7984 transfers with callbacks +- **[IERC7984Rwa](./api/interfaces#IERC7984Rwa)** - Interface for confidential RWA contracts ### [Utils](./api/utils) Miscellaneous contracts and libraries with utility functions for confidential contracts. diff --git a/content/confidential-contracts/api/interfaces.mdx b/content/confidential-contracts/api/interfaces.mdx index cda9fb86..d706866a 100644 --- a/content/confidential-contracts/api/interfaces.mdx +++ b/content/confidential-contracts/api/interfaces.mdx @@ -5,27 +5,27 @@ description: "Smart contract interfaces utilities and implementations" These interfaces are available as `.sol` files and are useful to interact with third party contracts that implement them. -* [`IConfidentialFungibleToken`](#IConfidentialFungibleToken) -* [`IConfidentialFungibleTokenReceiver`](#IConfidentialFungibleTokenReceiver) +* [`IERC7984`](#IERC7984) +* [`IERC7984Receiver`](#IERC7984Receiver) ## Core -[`IConfidentialFungibleToken`](#IConfidentialFungibleToken) -[`IConfidentialFungibleTokenReceiver`](#IConfidentialFungibleTokenReceiver) +[`IERC7984`](#IERC7984) +[`IERC7984Receiver`](#IERC7984Receiver) - +
-## `IConfidentialFungibleToken` +## `IERC7984` - +
```solidity -import "@openzeppelin/confidential-contracts/interfaces/IConfidentialFungibleToken.sol"; +import "@openzeppelin/confidential-contracts/interfaces/IERC7984.sol"; ``` Draft interface for a confidential fungible token standard utilizing the Zama FHE library. @@ -33,42 +33,45 @@ Draft interface for a confidential fungible token standard utilizing the Zama FH

Functions

-- [name()](#IConfidentialFungibleToken-name--) -- [symbol()](#IConfidentialFungibleToken-symbol--) -- [decimals()](#IConfidentialFungibleToken-decimals--) -- [tokenURI()](#IConfidentialFungibleToken-tokenURI--) -- [confidentialTotalSupply()](#IConfidentialFungibleToken-confidentialTotalSupply--) -- [confidentialBalanceOf(account)](#IConfidentialFungibleToken-confidentialBalanceOf-address-) -- [isOperator(holder, spender)](#IConfidentialFungibleToken-isOperator-address-address-) -- [setOperator(operator, until)](#IConfidentialFungibleToken-setOperator-address-uint48-) -- [confidentialTransfer(to, encryptedAmount, inputProof)](#IConfidentialFungibleToken-confidentialTransfer-address-externalEuint64-bytes-) -- [confidentialTransfer(to, amount)](#IConfidentialFungibleToken-confidentialTransfer-address-euint64-) -- [confidentialTransferFrom(from, to, encryptedAmount, inputProof)](#IConfidentialFungibleToken-confidentialTransferFrom-address-address-externalEuint64-bytes-) -- [confidentialTransferFrom(from, to, amount)](#IConfidentialFungibleToken-confidentialTransferFrom-address-address-euint64-) -- [confidentialTransferAndCall(to, encryptedAmount, inputProof, data)](#IConfidentialFungibleToken-confidentialTransferAndCall-address-externalEuint64-bytes-bytes-) -- [confidentialTransferAndCall(to, amount, data)](#IConfidentialFungibleToken-confidentialTransferAndCall-address-euint64-bytes-) -- [confidentialTransferFromAndCall(from, to, encryptedAmount, inputProof, data)](#IConfidentialFungibleToken-confidentialTransferFromAndCall-address-address-externalEuint64-bytes-bytes-) -- [confidentialTransferFromAndCall(from, to, amount, data)](#IConfidentialFungibleToken-confidentialTransferFromAndCall-address-address-euint64-bytes-) +- [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 [!toc] +- [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-)

Events

-- [OperatorSet(holder, operator, until)](#IConfidentialFungibleToken-OperatorSet-address-address-uint48-) -- [ConfidentialTransfer(from, to, amount)](#IConfidentialFungibleToken-ConfidentialTransfer-address-address-euint64-) -- [AmountDisclosed(encryptedAmount, amount)](#IConfidentialFungibleToken-AmountDisclosed-euint64-uint64-) +- [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]
- +

name() → string

external

-# +#
@@ -78,14 +81,14 @@ Returns the name of the token.
- +

symbol() → string

external

-# +#
@@ -95,14 +98,14 @@ Returns the symbol of the token.
- +

decimals() → uint8

external

-# +#
@@ -112,31 +115,31 @@ Returns the number of decimals of the token. Recommended to be 6.
- +
-

tokenURI() → string

+

contractURI() → string

external

-# +#
-Returns the token URI. +Returns the contract URI. See [ERC-7572](https://eips.ethereum.org/EIPS/eip-7572) for details.
- +

confidentialTotalSupply() → euint64

external

-# +#
@@ -146,14 +149,14 @@ Returns the confidential total supply of the token.
- +

confidentialBalanceOf(address account) → euint64

external

-# +#
@@ -163,14 +166,14 @@ Returns the confidential balance of the account `account`.
- +

isOperator(address holder, address spender) → bool

external

-# +#
@@ -180,14 +183,14 @@ Returns true if `spender` is currently an operator for `holder`.
- +

setOperator(address operator, uint48 until)

external

-# +#
@@ -201,14 +204,14 @@ An operator may transfer any amount of tokens on behalf of a holder while approv
- +

confidentialTransfer(address to, externalEuint64 encryptedAmount, bytes inputProof) → euint64

external

-# +#
@@ -220,32 +223,32 @@ Returns the encrypted amount that was actually transferred.
- +

confidentialTransfer(address to, euint64 amount) → euint64 transferred

external

-# +#
-Similar to #IConfidentialFungibleToken-confidentialTransfer-address-externalEuint64-bytes- but without an input proof. The caller +Similar to #IERC7984-confidentialTransfer-address-externalEuint64-bytes- but without an input proof. The caller *must* already be allowed by ACL for the given `amount`.
- +

confidentialTransferFrom(address from, address to, externalEuint64 encryptedAmount, bytes inputProof) → euint64

external

-# +#
@@ -258,107 +261,107 @@ Returns the encrypted amount that was actually transferred.
- +

confidentialTransferFrom(address from, address to, euint64 amount) → euint64 transferred

external

-# +#
-Similar to #IConfidentialFungibleToken-confidentialTransferFrom-address-address-externalEuint64-bytes- but without an input proof. +Similar to #IERC7984-confidentialTransferFrom-address-address-externalEuint64-bytes- but without an input proof. The caller *must* be already allowed by ACL for the given `amount`.
- +

confidentialTransferAndCall(address to, externalEuint64 encryptedAmount, bytes inputProof, bytes data) → euint64 transferred

external

-# +#
-Similar to #IConfidentialFungibleToken-confidentialTransfer-address-externalEuint64-bytes- but with a callback to `to` after +Similar to #IERC7984-confidentialTransfer-address-externalEuint64-bytes- but with a callback to `to` after the transfer. -The callback is made to the [`IConfidentialFungibleTokenReceiver.onConfidentialTransferReceived`](#IConfidentialFungibleTokenReceiver-onConfidentialTransferReceived-address-address-euint64-bytes-) function on the +The callback is made to the [`IERC7984Receiver.onConfidentialTransferReceived`](#IERC7984Receiver-onConfidentialTransferReceived-address-address-euint64-bytes-) function on the to address with the actual transferred amount (may differ from the given `encryptedAmount`) and the given data `data`.
- +

confidentialTransferAndCall(address to, euint64 amount, bytes data) → euint64 transferred

external

-# +#
-Similar to #IConfidentialFungibleToken-confidentialTransfer-address-euint64- but with a callback to `to` after the transfer. +Similar to #IERC7984-confidentialTransfer-address-euint64- but with a callback to `to` after the transfer.
- +

confidentialTransferFromAndCall(address from, address to, externalEuint64 encryptedAmount, bytes inputProof, bytes data) → euint64 transferred

external

-# +#
-Similar to #IConfidentialFungibleToken-confidentialTransferFrom-address-address-externalEuint64-bytes- but with a callback to `to` +Similar to #IERC7984-confidentialTransferFrom-address-address-externalEuint64-bytes- but with a callback to `to` after the transfer.
- +

confidentialTransferFromAndCall(address from, address to, euint64 amount, bytes data) → euint64 transferred

external

-# +#
-Similar to #IConfidentialFungibleToken-confidentialTransferFrom-address-address-euint64- but with a callback to `to` +Similar to #IERC7984-confidentialTransferFrom-address-address-euint64- but with a callback to `to` after the transfer.
- +

OperatorSet(address indexed holder, address indexed operator, uint48 until)

event

-# +#
@@ -369,14 +372,14 @@ The operator may move any amount of tokens on behalf of the holder until the tim
- +

ConfidentialTransfer(address indexed from, address indexed to, euint64 indexed amount)

event

-# +#
@@ -386,14 +389,14 @@ Emitted when a confidential transfer is made from `from` to `to` of encrypted am
- +

AmountDisclosed(euint64 indexed encryptedAmount, uint64 amount)

event

-# +#
@@ -407,39 +410,39 @@ should be able to disclose the amount. This functionality is implementation spec
- +
-## `IConfidentialFungibleTokenReceiver` +## `IERC7984Receiver` - +
```solidity -import "@openzeppelin/confidential-contracts/interfaces/IConfidentialFungibleTokenReceiver.sol"; +import "@openzeppelin/confidential-contracts/interfaces/IERC7984Receiver.sol"; ``` -Interface for contracts that can receive confidential token transfers with a callback. +Interface for contracts that can receive ERC7984 transfers with a callback.

Functions

-- [onConfidentialTransferReceived(operator, from, amount, data)](#IConfidentialFungibleTokenReceiver-onConfidentialTransferReceived-address-address-euint64-bytes-) +- [onConfidentialTransferReceived(operator, from, amount, data)](#IERC7984Receiver-onConfidentialTransferReceived-address-address-euint64-bytes-)
- +

onConfidentialTransferReceived(address operator, address from, euint64 amount, bytes data) → ebool

external

-# +#
@@ -449,3 +452,346 @@ of the callback. If false is returned, the transfer must be reversed.
+ + + +
+ +## `IERC7984Rwa` + + + + + +
+ +```solidity +import "@openzeppelin/confidential-contracts/interfaces/IERC7984Rwa.sol"; +``` + +Interface for confidential RWA contracts. + +
+

Functions

+
+- [paused()](#IERC7984Rwa-paused--) +- [isUserAllowed(account)](#IERC7984Rwa-isUserAllowed-address-) +- [confidentialFrozen(account)](#IERC7984Rwa-confidentialFrozen-address-) +- [confidentialAvailable(account)](#IERC7984Rwa-confidentialAvailable-address-) +- [pause()](#IERC7984Rwa-pause--) +- [unpause()](#IERC7984Rwa-unpause--) +- [blockUser(account)](#IERC7984Rwa-blockUser-address-) +- [unblockUser(account)](#IERC7984Rwa-unblockUser-address-) +- [setConfidentialFrozen(account, encryptedAmount, inputProof)](#IERC7984Rwa-setConfidentialFrozen-address-externalEuint64-bytes-) +- [setConfidentialFrozen(account, encryptedAmount)](#IERC7984Rwa-setConfidentialFrozen-address-euint64-) +- [confidentialMint(to, encryptedAmount, inputProof)](#IERC7984Rwa-confidentialMint-address-externalEuint64-bytes-) +- [confidentialMint(to, encryptedAmount)](#IERC7984Rwa-confidentialMint-address-euint64-) +- [confidentialBurn(account, encryptedAmount, inputProof)](#IERC7984Rwa-confidentialBurn-address-externalEuint64-bytes-) +- [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] +- [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 [!toc] +- [supportsInterface(interfaceId)](#IERC165-supportsInterface-bytes4-) +
+
+ +
+

Events

+
+#### IERC7984 [!toc] +- [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] +
+
+ + + +
+
+

paused() → bool

+
+

external

+# +
+
+
+ +Returns true if the contract is paused, false otherwise. + +
+
+ + + +
+
+

isUserAllowed(address account) → bool

+
+

external

+# +
+
+
+ +Returns whether an account is allowed to interact with the token. + +
+
+ + + +
+
+

confidentialFrozen(address account) → euint64

+
+

external

+# +
+
+
+ +Returns the confidential frozen balance of an account. + +
+
+ + + +
+
+

confidentialAvailable(address account) → euint64

+
+

external

+# +
+
+
+ +Returns the confidential available (unfrozen) balance of an account. Up to [`IERC7984.confidentialBalanceOf`](#IERC7984-confidentialBalanceOf-address-). + +
+
+ + + +
+
+

pause()

+
+

external

+# +
+
+
+ +Pauses contract. + +
+
+ + + +
+
+

unpause()

+
+

external

+# +
+
+
+ +Unpauses contract. + +
+
+ + + +
+
+

blockUser(address account)

+
+

external

+# +
+
+
+ +Blocks a user account. + +
+
+ + + +
+
+

unblockUser(address account)

+
+

external

+# +
+
+
+ +Unblocks a user account. + +
+
+ + + +
+
+

setConfidentialFrozen(address account, externalEuint64 encryptedAmount, bytes inputProof)

+
+

external

+# +
+
+
+ +Sets confidential amount of token for an account as frozen with proof. + +
+
+ + + +
+
+

setConfidentialFrozen(address account, euint64 encryptedAmount)

+
+

external

+# +
+
+
+ +Sets confidential amount of token for an account as frozen. + +
+
+ + + +
+
+

confidentialMint(address to, externalEuint64 encryptedAmount, bytes inputProof) → euint64

+
+

external

+# +
+
+
+ +Mints confidential amount of tokens to account with proof. + +
+
+ + + +
+
+

confidentialMint(address to, euint64 encryptedAmount) → euint64

+
+

external

+# +
+
+
+ +Mints confidential amount of tokens to account. + +
+
+ + + +
+
+

confidentialBurn(address account, externalEuint64 encryptedAmount, bytes inputProof) → euint64

+
+

external

+# +
+
+
+ +Burns confidential amount of tokens from account with proof. + +
+
+ + + +
+
+

confidentialBurn(address account, euint64 encryptedAmount) → euint64

+
+

external

+# +
+
+
+ +Burns confidential amount of tokens from account. + +
+
+ + + +
+
+

forceConfidentialTransferFrom(address from, address to, externalEuint64 encryptedAmount, bytes inputProof) → euint64

+
+

external

+# +
+
+
+ +Forces transfer of confidential amount of tokens from account to account with proof by skipping compliance checks. + +
+
+ + + +
+
+

forceConfidentialTransferFrom(address from, address to, euint64 encryptedAmount) → euint64

+
+

external

+# +
+
+
+ +Forces transfer of confidential amount of tokens from account to account by skipping compliance checks. + +
+
+ diff --git a/content/confidential-contracts/api/token.mdx b/content/confidential-contracts/api/token.mdx index d747f38f..b234ac54 100644 --- a/content/confidential-contracts/api/token.mdx +++ b/content/confidential-contracts/api/token.mdx @@ -3,38 +3,48 @@ title: "Token" description: "Smart contract token utilities and implementations" --- -This set of interfaces, contracts, and utilities are all related to the evolving Confidential Token Standard. The standard utilizes the Zama fhEVM co-processor for manipulating FHE values. All amounts are stored on-chain as ciphertext handles (or pointers) to values stored on the co-processor. +This set of interfaces, contracts, and utilities are all related to `ERC7984`, an evolving confidential token standard. The standard utilizes the Zama fhEVM co-processor for manipulating FHE values. All amounts are stored on-chain as ciphertext handles (or pointers) to values stored on the co-processor. -* [`ConfidentialFungibleToken`](#ConfidentialFungibleToken): Implementation of [`IConfidentialFungibleToken`](./interfaces#IConfidentialFungibleToken). -* [`ConfidentialFungibleTokenERC20Wrapper`](#ConfidentialFungibleTokenERC20Wrapper): Extension of [`ConfidentialFungibleToken`](#ConfidentialFungibleToken) which wraps an `ERC20` into a confidential token. The wrapper allows for free conversion in both directions at a fixed rate. -* [`ConfidentialFungibleTokenUtils`](#ConfidentialFungibleTokenUtils): A library that provides the on-transfer callback check used by [`ConfidentialFungibleToken`](#ConfidentialFungibleToken). +* [`ERC7984`](#ERC7984): Implementation of [`IERC7984`](/confidential-contracts/api/interfaces#IERC7984). +* [`ERC7984ERC20Wrapper`](#ERC7984ERC20Wrapper): Extension of [`ERC7984`](#ERC7984) which wraps an `ERC20` into a confidential token. The wrapper allows for free conversion in both directions at a fixed rate. +* [`ERC7984Freezable`](#ERC7984Freezable): An extension of [`ERC7984`](#ERC7984), which allows accounts granted the "freezer" role to freeze and unfreeze tokens. +* [`ERC7984ObserverAccess`](#ERC7984ObserverAccess): An extension of [`ERC7984`](#ERC7984), which allows each account to add an observer who is given access to their transfer and balance amounts. +* [`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. +* [`ERC7984Utils`](#ERC7984Utils): A library that provides the on-transfer callback check used by [`ERC7984`](#ERC7984). ## Core -[`ConfidentialFungibleToken`](#ConfidentialFungibleToken) +[`ERC7984`](#ERC7984) ## Extensions -[`ConfidentialFungibleTokenERC20Wrapper`](#ConfidentialFungibleTokenERC20Wrapper) +[`ERC7984ERC20Wrapper`](#ERC7984ERC20Wrapper) +[`ERC7984Freezable`](#ERC7984Freezable) +[`ERC7984ObserverAccess`](#ERC7984ObserverAccess) +[`ERC7984Restricted`](#ERC7984Restricted) +[`ERC7984Omnibus`](#ERC7984Omnibus) +[`ERC7984Rwa`](#ERC7984Rwa) ## Utilities -[`ConfidentialFungibleTokenUtils`](#ConfidentialFungibleTokenUtils) +[`ERC7984Utils`](#ERC7984Utils) - +
-## `ConfidentialFungibleToken` +## `ERC7984` - +
```solidity -import "@openzeppelin/confidential-contracts/token/ConfidentialFungibleToken.sol"; +import "@openzeppelin/confidential-contracts/token/ERC7984/ERC7984.sol"; ``` -Reference implementation for [`IConfidentialFungibleToken`](./interfaces#IConfidentialFungibleToken). +Reference implementation for [`IERC7984`](/confidential-contracts/api/interfaces#IERC7984). This contract implements a fungible token where balances and transfers are encrypted using the Zama fhEVM, providing confidentiality to users. Token amounts are stored as encrypted, unsigned integers (`euint64`) @@ -51,67 +61,75 @@ Key features:

Functions

-- [constructor(name_, symbol_, tokenURI_)](#ConfidentialFungibleToken-constructor-string-string-string-) -- [name()](#ConfidentialFungibleToken-name--) -- [symbol()](#ConfidentialFungibleToken-symbol--) -- [decimals()](#ConfidentialFungibleToken-decimals--) -- [tokenURI()](#ConfidentialFungibleToken-tokenURI--) -- [confidentialTotalSupply()](#ConfidentialFungibleToken-confidentialTotalSupply--) -- [confidentialBalanceOf(account)](#ConfidentialFungibleToken-confidentialBalanceOf-address-) -- [isOperator(holder, spender)](#ConfidentialFungibleToken-isOperator-address-address-) -- [setOperator(operator, until)](#ConfidentialFungibleToken-setOperator-address-uint48-) -- [confidentialTransfer(to, encryptedAmount, inputProof)](#ConfidentialFungibleToken-confidentialTransfer-address-externalEuint64-bytes-) -- [confidentialTransfer(to, amount)](#ConfidentialFungibleToken-confidentialTransfer-address-euint64-) -- [confidentialTransferFrom(from, to, encryptedAmount, inputProof)](#ConfidentialFungibleToken-confidentialTransferFrom-address-address-externalEuint64-bytes-) -- [confidentialTransferFrom(from, to, amount)](#ConfidentialFungibleToken-confidentialTransferFrom-address-address-euint64-) -- [confidentialTransferAndCall(to, encryptedAmount, inputProof, data)](#ConfidentialFungibleToken-confidentialTransferAndCall-address-externalEuint64-bytes-bytes-) -- [confidentialTransferAndCall(to, amount, data)](#ConfidentialFungibleToken-confidentialTransferAndCall-address-euint64-bytes-) -- [confidentialTransferFromAndCall(from, to, encryptedAmount, inputProof, data)](#ConfidentialFungibleToken-confidentialTransferFromAndCall-address-address-externalEuint64-bytes-bytes-) -- [confidentialTransferFromAndCall(from, to, amount, data)](#ConfidentialFungibleToken-confidentialTransferFromAndCall-address-address-euint64-bytes-) -- [discloseEncryptedAmount(encryptedAmount)](#ConfidentialFungibleToken-discloseEncryptedAmount-euint64-) -- [finalizeDiscloseEncryptedAmount(requestId, amount, signatures)](#ConfidentialFungibleToken-finalizeDiscloseEncryptedAmount-uint256-uint64-bytes---) -- [_setOperator(holder, operator, until)](#ConfidentialFungibleToken-_setOperator-address-address-uint48-) -- [_mint(to, amount)](#ConfidentialFungibleToken-_mint-address-euint64-) -- [_burn(from, amount)](#ConfidentialFungibleToken-_burn-address-euint64-) -- [_transfer(from, to, amount)](#ConfidentialFungibleToken-_transfer-address-address-euint64-) -- [_transferAndCall(from, to, amount, data)](#ConfidentialFungibleToken-_transferAndCall-address-address-euint64-bytes-) -- [_update(from, to, amount)](#ConfidentialFungibleToken-_update-address-address-euint64-) -#### IConfidentialFungibleToken [!toc] +- [constructor(name_, symbol_, contractURI_)](#ERC7984-constructor-string-string-string-) +- [supportsInterface(interfaceId)](#ERC7984-supportsInterface-bytes4-) +- [name()](#ERC7984-name--) +- [symbol()](#ERC7984-symbol--) +- [decimals()](#ERC7984-decimals--) +- [contractURI()](#ERC7984-contractURI--) +- [confidentialTotalSupply()](#ERC7984-confidentialTotalSupply--) +- [confidentialBalanceOf(account)](#ERC7984-confidentialBalanceOf-address-) +- [isOperator(holder, spender)](#ERC7984-isOperator-address-address-) +- [setOperator(operator, until)](#ERC7984-setOperator-address-uint48-) +- [confidentialTransfer(to, encryptedAmount, inputProof)](#ERC7984-confidentialTransfer-address-externalEuint64-bytes-) +- [confidentialTransfer(to, amount)](#ERC7984-confidentialTransfer-address-euint64-) +- [confidentialTransferFrom(from, to, encryptedAmount, inputProof)](#ERC7984-confidentialTransferFrom-address-address-externalEuint64-bytes-) +- [confidentialTransferFrom(from, to, amount)](#ERC7984-confidentialTransferFrom-address-address-euint64-) +- [confidentialTransferAndCall(to, encryptedAmount, inputProof, data)](#ERC7984-confidentialTransferAndCall-address-externalEuint64-bytes-bytes-) +- [confidentialTransferAndCall(to, amount, data)](#ERC7984-confidentialTransferAndCall-address-euint64-bytes-) +- [confidentialTransferFromAndCall(from, to, encryptedAmount, inputProof, data)](#ERC7984-confidentialTransferFromAndCall-address-address-externalEuint64-bytes-bytes-) +- [confidentialTransferFromAndCall(from, to, amount, data)](#ERC7984-confidentialTransferFromAndCall-address-address-euint64-bytes-) +- [requestDiscloseEncryptedAmount(encryptedAmount)](#ERC7984-requestDiscloseEncryptedAmount-euint64-) +- [discloseEncryptedAmount(encryptedAmount, cleartextAmount, decryptionProof)](#ERC7984-discloseEncryptedAmount-euint64-uint64-bytes-) +- [_setOperator(holder, operator, until)](#ERC7984-_setOperator-address-address-uint48-) +- [_mint(to, amount)](#ERC7984-_mint-address-euint64-) +- [_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

-#### IConfidentialFungibleToken [!toc] -- [OperatorSet(holder, operator, until)](#IConfidentialFungibleToken-OperatorSet-address-address-uint48-) -- [ConfidentialTransfer(from, to, amount)](#IConfidentialFungibleToken-ConfidentialTransfer-address-address-euint64-) -- [AmountDisclosed(encryptedAmount, amount)](#IConfidentialFungibleToken-AmountDisclosed-euint64-uint64-) +- [AmountDiscloseRequested(encryptedAmount, requester)](#ERC7984-AmountDiscloseRequested-euint64-address-) +#### ERC165 [!toc] +#### IERC7984 [!toc] +- [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

-- [ConfidentialFungibleTokenInvalidReceiver(receiver)](#ConfidentialFungibleToken-ConfidentialFungibleTokenInvalidReceiver-address-) -- [ConfidentialFungibleTokenInvalidSender(sender)](#ConfidentialFungibleToken-ConfidentialFungibleTokenInvalidSender-address-) -- [ConfidentialFungibleTokenUnauthorizedSpender(holder, spender)](#ConfidentialFungibleToken-ConfidentialFungibleTokenUnauthorizedSpender-address-address-) -- [ConfidentialFungibleTokenZeroBalance(holder)](#ConfidentialFungibleToken-ConfidentialFungibleTokenZeroBalance-address-) -- [ConfidentialFungibleTokenUnauthorizedUseOfEncryptedAmount(amount, user)](#ConfidentialFungibleToken-ConfidentialFungibleTokenUnauthorizedUseOfEncryptedAmount-euint64-address-) -- [ConfidentialFungibleTokenUnauthorizedCaller(caller)](#ConfidentialFungibleToken-ConfidentialFungibleTokenUnauthorizedCaller-address-) -- [ConfidentialFungibleTokenInvalidGatewayRequest(requestId)](#ConfidentialFungibleToken-ConfidentialFungibleTokenInvalidGatewayRequest-uint256-) -#### IConfidentialFungibleToken [!toc] +- [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]
- +
-

constructor(string name_, string symbol_, string tokenURI_)

+

constructor(string name_, string symbol_, string contractURI_)

internal

-# +#
@@ -119,14 +137,36 @@ Key features:
- + + +
+
+

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

name() → string

public

-# +#
@@ -136,14 +176,14 @@ Returns the name of the token.
- +

symbol() → string

public

-# +#
@@ -153,14 +193,14 @@ Returns the symbol of the token.
- +

decimals() → uint8

public

-# +#
@@ -170,31 +210,31 @@ Returns the number of decimals of the token. Recommended to be 6.
- +
-

tokenURI() → string

+

contractURI() → string

public

-# +#
-Returns the token URI. +Returns the contract URI. See [ERC-7572](https://eips.ethereum.org/EIPS/eip-7572) for details.
- +

confidentialTotalSupply() → euint64

public

-# +#
@@ -204,14 +244,14 @@ Returns the confidential total supply of the token.
- +

confidentialBalanceOf(address account) → euint64

public

-# +#
@@ -221,14 +261,14 @@ Returns the confidential balance of the account `account`.
- +

isOperator(address holder, address spender) → bool

public

-# +#
@@ -238,14 +278,14 @@ Returns true if `spender` is currently an operator for `holder`.
- +

setOperator(address operator, uint48 until)

public

-# +#
@@ -259,14 +299,14 @@ An operator may transfer any amount of tokens on behalf of a holder while approv
- +

confidentialTransfer(address to, externalEuint64 encryptedAmount, bytes inputProof) → euint64

public

-# +#
@@ -278,32 +318,32 @@ Returns the encrypted amount that was actually transferred.
- +

confidentialTransfer(address to, euint64 amount) → euint64

public

-# +#
-Similar to interfaces#IConfidentialFungibleToken-confidentialTransfer-address-externalEuint64-bytes- but without an input proof. The caller +Similar to interfaces#IERC7984-confidentialTransfer-address-externalEuint64-bytes- but without an input proof. The caller *must* already be allowed by ACL for the given `amount`.
- +

confidentialTransferFrom(address from, address to, externalEuint64 encryptedAmount, bytes inputProof) → euint64 transferred

public

-# +#
@@ -316,147 +356,151 @@ Returns the encrypted amount that was actually transferred.
- +

confidentialTransferFrom(address from, address to, euint64 amount) → euint64 transferred

public

-# +#
-Similar to interfaces#IConfidentialFungibleToken-confidentialTransferFrom-address-address-externalEuint64-bytes- but without an input proof. +Similar to interfaces#IERC7984-confidentialTransferFrom-address-address-externalEuint64-bytes- but without an input proof. The caller *must* be already allowed by ACL for the given `amount`.
- +

confidentialTransferAndCall(address to, externalEuint64 encryptedAmount, bytes inputProof, bytes data) → euint64 transferred

public

-# +#
-Similar to interfaces#IConfidentialFungibleToken-confidentialTransfer-address-externalEuint64-bytes- but with a callback to `to` after +Similar to interfaces#IERC7984-confidentialTransfer-address-externalEuint64-bytes- but with a callback to `to` after the transfer. -The callback is made to the [`IConfidentialFungibleTokenReceiver.onConfidentialTransferReceived`](./interfaces#IConfidentialFungibleTokenReceiver-onConfidentialTransferReceived-address-address-euint64-bytes-) function on the +The callback is made to the [`IERC7984Receiver.onConfidentialTransferReceived`](/confidential-contracts/api/interfaces#IERC7984Receiver-onConfidentialTransferReceived-address-address-euint64-bytes-) function on the to address with the actual transferred amount (may differ from the given `encryptedAmount`) and the given data `data`.
- +

confidentialTransferAndCall(address to, euint64 amount, bytes data) → euint64 transferred

public

-# +#
-Similar to interfaces#IConfidentialFungibleToken-confidentialTransfer-address-euint64- but with a callback to `to` after the transfer. +Similar to interfaces#IERC7984-confidentialTransfer-address-euint64- but with a callback to `to` after the transfer.
- +

confidentialTransferFromAndCall(address from, address to, externalEuint64 encryptedAmount, bytes inputProof, bytes data) → euint64 transferred

public

-# +#
-Similar to interfaces#IConfidentialFungibleToken-confidentialTransferFrom-address-address-externalEuint64-bytes- but with a callback to `to` +Similar to interfaces#IERC7984-confidentialTransferFrom-address-address-externalEuint64-bytes- but with a callback to `to` after the transfer.
- +

confidentialTransferFromAndCall(address from, address to, euint64 amount, bytes data) → euint64 transferred

public

-# +#
-Similar to interfaces#IConfidentialFungibleToken-confidentialTransferFrom-address-address-euint64- but with a callback to `to` +Similar to interfaces#IERC7984-confidentialTransferFrom-address-address-euint64- but with a callback to `to` after the transfer.
- +
-

discloseEncryptedAmount(euint64 encryptedAmount)

+

requestDiscloseEncryptedAmount(euint64 encryptedAmount)

public

-# +#
-Discloses an encrypted amount `encryptedAmount` publicly via an [`IConfidentialFungibleToken.AmountDisclosed`](./interfaces#IConfidentialFungibleToken-AmountDisclosed-euint64-uint64-) -event. The caller and this contract must be authorized to use the encrypted amount on the ACL. +Starts the process to disclose an encrypted amount `encryptedAmount` publicly by making it +publicly decryptable. Emits the [`ERC7984.AmountDiscloseRequested`](#ERC7984-AmountDiscloseRequested-euint64-address-) event. -This is an asynchronous operation where the actual decryption happens off-chain and -[`ConfidentialFungibleToken.finalizeDiscloseEncryptedAmount`](#ConfidentialFungibleToken-finalizeDiscloseEncryptedAmount-uint256-uint64-bytes---) is called with the result. +Both `msg.sender` and `address(this)` must have permission to access the encrypted amount +`encryptedAmount` to request disclosure of the encrypted amount `encryptedAmount`.
- +
-

finalizeDiscloseEncryptedAmount(uint256 requestId, uint64 amount, bytes[] signatures)

+

discloseEncryptedAmount(euint64 encryptedAmount, uint64 cleartextAmount, bytes decryptionProof)

public

-# +#
-Finalizes a disclose encrypted amount request. +Publicly discloses an encrypted value with a given decryption proof. Emits the [`IERC7984.AmountDisclosed`](/confidential-contracts/api/interfaces#IERC7984-AmountDisclosed-euint64-uint64-) event. + + +May not be tied to a prior request via [`ERC7984.requestDiscloseEncryptedAmount`](#ERC7984-requestDiscloseEncryptedAmount-euint64-). +
- +

_setOperator(address holder, address operator, uint48 until)

internal

-# +#
@@ -464,14 +508,14 @@ Finalizes a disclose encrypted amount request.
- +

_mint(address to, euint64 amount) → euint64 transferred

internal

-# +#
@@ -479,14 +523,14 @@ Finalizes a disclose encrypted amount request.
- +

_burn(address from, euint64 amount) → euint64 transferred

internal

-# +#
@@ -494,14 +538,14 @@ Finalizes a disclose encrypted amount request.
- +

_transfer(address from, address to, euint64 amount) → euint64 transferred

internal

-# +#
@@ -509,14 +553,14 @@ Finalizes a disclose encrypted amount request.
- +

_transferAndCall(address from, address to, euint64 amount, bytes data) → euint64 transferred

internal

-# +#
@@ -524,29 +568,47 @@ Finalizes a disclose encrypted amount request.
- +

_update(address from, address to, euint64 amount) → euint64 transferred

internal

-# +# +
+
+
+ +
+
+ + + +
+
+

AmountDiscloseRequested(euint64 indexed encryptedAmount, address indexed requester)

+
+

event

+#
+
+Emitted when an encrypted amount `encryptedAmount` is requested for disclosure by `requester`. +
- +
-

ConfidentialFungibleTokenInvalidReceiver(address receiver)

+

ERC7984InvalidReceiver(address receiver)

error

-# +#
@@ -556,14 +618,14 @@ The given receiver `receiver` is invalid for transfers.
- +
-

ConfidentialFungibleTokenInvalidSender(address sender)

+

ERC7984InvalidSender(address sender)

error

-# +#
@@ -573,14 +635,14 @@ The given sender `sender` is invalid for transfers.
- +
-

ConfidentialFungibleTokenUnauthorizedSpender(address holder, address spender)

+

ERC7984UnauthorizedSpender(address holder, address spender)

error

-# +#
@@ -590,14 +652,14 @@ The given holder `holder` is not authorized to spend on behalf of `spender`.
- +
-

ConfidentialFungibleTokenZeroBalance(address holder)

+

ERC7984ZeroBalance(address holder)

error

-# +#
@@ -607,14 +669,14 @@ The holder `holder` is trying to send tokens but has a balance of 0.
- +
-

ConfidentialFungibleTokenUnauthorizedUseOfEncryptedAmount(euint64 amount, address user)

+

ERC7984UnauthorizedUseOfEncryptedAmount(euint64 amount, address user)

error

-# +#
@@ -628,14 +690,14 @@ Try using the equivalent transfer function with an input proof.
- +
-

ConfidentialFungibleTokenUnauthorizedCaller(address caller)

+

ERC7984UnauthorizedCaller(address caller)

error

-# +#
@@ -645,14 +707,14 @@ The given caller `caller` is not authorized for the current operation.
- +
-

ConfidentialFungibleTokenInvalidGatewayRequest(uint256 requestId)

+

ERC7984InvalidGatewayRequest(uint256 requestId)

error

-# +#
@@ -662,24 +724,24 @@ The given gateway request ID `requestId` is invalid.
- +
-## `ConfidentialFungibleTokenERC20Wrapper` +## `ERC7984ERC20Wrapper` - +
```solidity -import "@openzeppelin/confidential-contracts/token/extensions/ConfidentialFungibleTokenERC20Wrapper.sol"; +import "@openzeppelin/confidential-contracts/token/ERC7984/extensions/ERC7984ERC20Wrapper.sol"; ``` -A wrapper contract built on top of [`ConfidentialFungibleToken`](#ConfidentialFungibleToken) that allows wrapping an `ERC20` token -into a confidential fungible token. The wrapper contract implements the `IERC1363Receiver` interface +A wrapper contract built on top of [`ERC7984`](#ERC7984) that allows wrapping an `ERC20` token +into an `ERC7984` token. The wrapper contract implements the `IERC1363Receiver` interface which allows users to transfer `ERC1363` tokens directly to the wrapper with a callback to wrap the tokens. @@ -690,83 +752,94 @@ tokens such as fee-on-transfer or other deflationary-type tokens are not support

Functions

-- [constructor(underlying_)](#ConfidentialFungibleTokenERC20Wrapper-constructor-contract-IERC20-) -- [decimals()](#ConfidentialFungibleTokenERC20Wrapper-decimals--) -- [rate()](#ConfidentialFungibleTokenERC20Wrapper-rate--) -- [underlying()](#ConfidentialFungibleTokenERC20Wrapper-underlying--) -- [onTransferReceived(, from, amount, data)](#ConfidentialFungibleTokenERC20Wrapper-onTransferReceived-address-address-uint256-bytes-) -- [wrap(to, amount)](#ConfidentialFungibleTokenERC20Wrapper-wrap-address-uint256-) -- [unwrap(from, to, amount)](#ConfidentialFungibleTokenERC20Wrapper-unwrap-address-address-euint64-) -- [unwrap(from, to, encryptedAmount, inputProof)](#ConfidentialFungibleTokenERC20Wrapper-unwrap-address-address-externalEuint64-bytes-) -- [finalizeUnwrap(requestID, amount, signatures)](#ConfidentialFungibleTokenERC20Wrapper-finalizeUnwrap-uint256-uint64-bytes---) -- [_unwrap(from, to, amount)](#ConfidentialFungibleTokenERC20Wrapper-_unwrap-address-address-euint64-) -- [_fallbackUnderlyingDecimals()](#ConfidentialFungibleTokenERC20Wrapper-_fallbackUnderlyingDecimals--) -- [_maxDecimals()](#ConfidentialFungibleTokenERC20Wrapper-_maxDecimals--) +- [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-) +- [_unwrap(from, to, amount)](#ERC7984ERC20Wrapper-_unwrap-address-address-euint64-) +- [_fallbackUnderlyingDecimals()](#ERC7984ERC20Wrapper-_fallbackUnderlyingDecimals--) +- [_maxDecimals()](#ERC7984ERC20Wrapper-_maxDecimals--) #### IERC1363Receiver [!toc] -#### ConfidentialFungibleToken [!toc] -- [name()](#ConfidentialFungibleToken-name--) -- [symbol()](#ConfidentialFungibleToken-symbol--) -- [tokenURI()](#ConfidentialFungibleToken-tokenURI--) -- [confidentialTotalSupply()](#ConfidentialFungibleToken-confidentialTotalSupply--) -- [confidentialBalanceOf(account)](#ConfidentialFungibleToken-confidentialBalanceOf-address-) -- [isOperator(holder, spender)](#ConfidentialFungibleToken-isOperator-address-address-) -- [setOperator(operator, until)](#ConfidentialFungibleToken-setOperator-address-uint48-) -- [confidentialTransfer(to, encryptedAmount, inputProof)](#ConfidentialFungibleToken-confidentialTransfer-address-externalEuint64-bytes-) -- [confidentialTransfer(to, amount)](#ConfidentialFungibleToken-confidentialTransfer-address-euint64-) -- [confidentialTransferFrom(from, to, encryptedAmount, inputProof)](#ConfidentialFungibleToken-confidentialTransferFrom-address-address-externalEuint64-bytes-) -- [confidentialTransferFrom(from, to, amount)](#ConfidentialFungibleToken-confidentialTransferFrom-address-address-euint64-) -- [confidentialTransferAndCall(to, encryptedAmount, inputProof, data)](#ConfidentialFungibleToken-confidentialTransferAndCall-address-externalEuint64-bytes-bytes-) -- [confidentialTransferAndCall(to, amount, data)](#ConfidentialFungibleToken-confidentialTransferAndCall-address-euint64-bytes-) -- [confidentialTransferFromAndCall(from, to, encryptedAmount, inputProof, data)](#ConfidentialFungibleToken-confidentialTransferFromAndCall-address-address-externalEuint64-bytes-bytes-) -- [confidentialTransferFromAndCall(from, to, amount, data)](#ConfidentialFungibleToken-confidentialTransferFromAndCall-address-address-euint64-bytes-) -- [discloseEncryptedAmount(encryptedAmount)](#ConfidentialFungibleToken-discloseEncryptedAmount-euint64-) -- [finalizeDiscloseEncryptedAmount(requestId, amount, signatures)](#ConfidentialFungibleToken-finalizeDiscloseEncryptedAmount-uint256-uint64-bytes---) -- [_setOperator(holder, operator, until)](#ConfidentialFungibleToken-_setOperator-address-address-uint48-) -- [_mint(to, amount)](#ConfidentialFungibleToken-_mint-address-euint64-) -- [_burn(from, amount)](#ConfidentialFungibleToken-_burn-address-euint64-) -- [_transfer(from, to, amount)](#ConfidentialFungibleToken-_transfer-address-address-euint64-) -- [_transferAndCall(from, to, amount, data)](#ConfidentialFungibleToken-_transferAndCall-address-address-euint64-bytes-) -- [_update(from, to, amount)](#ConfidentialFungibleToken-_update-address-address-euint64-) -#### IConfidentialFungibleToken [!toc] +#### ERC7984 [!toc] +- [supportsInterface(interfaceId)](#ERC7984-supportsInterface-bytes4-) +- [name()](#ERC7984-name--) +- [symbol()](#ERC7984-symbol--) +- [contractURI()](#ERC7984-contractURI--) +- [confidentialTotalSupply()](#ERC7984-confidentialTotalSupply--) +- [confidentialBalanceOf(account)](#ERC7984-confidentialBalanceOf-address-) +- [isOperator(holder, spender)](#ERC7984-isOperator-address-address-) +- [setOperator(operator, until)](#ERC7984-setOperator-address-uint48-) +- [confidentialTransfer(to, encryptedAmount, inputProof)](#ERC7984-confidentialTransfer-address-externalEuint64-bytes-) +- [confidentialTransfer(to, amount)](#ERC7984-confidentialTransfer-address-euint64-) +- [confidentialTransferFrom(from, to, encryptedAmount, inputProof)](#ERC7984-confidentialTransferFrom-address-address-externalEuint64-bytes-) +- [confidentialTransferFrom(from, to, amount)](#ERC7984-confidentialTransferFrom-address-address-euint64-) +- [confidentialTransferAndCall(to, encryptedAmount, inputProof, data)](#ERC7984-confidentialTransferAndCall-address-externalEuint64-bytes-bytes-) +- [confidentialTransferAndCall(to, amount, data)](#ERC7984-confidentialTransferAndCall-address-euint64-bytes-) +- [confidentialTransferFromAndCall(from, to, encryptedAmount, inputProof, data)](#ERC7984-confidentialTransferFromAndCall-address-address-externalEuint64-bytes-bytes-) +- [confidentialTransferFromAndCall(from, to, amount, data)](#ERC7984-confidentialTransferFromAndCall-address-address-euint64-bytes-) +- [requestDiscloseEncryptedAmount(encryptedAmount)](#ERC7984-requestDiscloseEncryptedAmount-euint64-) +- [discloseEncryptedAmount(encryptedAmount, cleartextAmount, decryptionProof)](#ERC7984-discloseEncryptedAmount-euint64-uint64-bytes-) +- [_setOperator(holder, operator, until)](#ERC7984-_setOperator-address-address-uint48-) +- [_mint(to, amount)](#ERC7984-_mint-address-euint64-) +- [_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] -#### ConfidentialFungibleToken [!toc] -#### IConfidentialFungibleToken [!toc] -- [OperatorSet(holder, operator, until)](#IConfidentialFungibleToken-OperatorSet-address-address-uint48-) -- [ConfidentialTransfer(from, to, amount)](#IConfidentialFungibleToken-ConfidentialTransfer-address-address-euint64-) -- [AmountDisclosed(encryptedAmount, amount)](#IConfidentialFungibleToken-AmountDisclosed-euint64-uint64-) +#### ERC7984 [!toc] +- [AmountDiscloseRequested(encryptedAmount, requester)](#ERC7984-AmountDiscloseRequested-euint64-address-) +#### ERC165 [!toc] +#### IERC7984 [!toc] +- [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] -#### ConfidentialFungibleToken [!toc] -- [ConfidentialFungibleTokenInvalidReceiver(receiver)](#ConfidentialFungibleToken-ConfidentialFungibleTokenInvalidReceiver-address-) -- [ConfidentialFungibleTokenInvalidSender(sender)](#ConfidentialFungibleToken-ConfidentialFungibleTokenInvalidSender-address-) -- [ConfidentialFungibleTokenUnauthorizedSpender(holder, spender)](#ConfidentialFungibleToken-ConfidentialFungibleTokenUnauthorizedSpender-address-address-) -- [ConfidentialFungibleTokenZeroBalance(holder)](#ConfidentialFungibleToken-ConfidentialFungibleTokenZeroBalance-address-) -- [ConfidentialFungibleTokenUnauthorizedUseOfEncryptedAmount(amount, user)](#ConfidentialFungibleToken-ConfidentialFungibleTokenUnauthorizedUseOfEncryptedAmount-euint64-address-) -- [ConfidentialFungibleTokenUnauthorizedCaller(caller)](#ConfidentialFungibleToken-ConfidentialFungibleTokenUnauthorizedCaller-address-) -- [ConfidentialFungibleTokenInvalidGatewayRequest(requestId)](#ConfidentialFungibleToken-ConfidentialFungibleTokenInvalidGatewayRequest-uint256-) -#### IConfidentialFungibleToken [!toc] +#### ERC7984 [!toc] +- [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]
- +

constructor(contract IERC20 underlying_)

internal

-# +#
@@ -774,14 +847,14 @@ tokens such as fee-on-transfer or other deflationary-type tokens are not support
- +

decimals() → uint8

public

-# +#
@@ -791,14 +864,14 @@ Returns the number of decimals of the token. Recommended to be 6.
- +

rate() → uint256

public

-# +#
@@ -809,14 +882,14 @@ For example, if the `rate` is 1000, then 1000 units of the underlying token equa
- +

underlying() → contract IERC20

public

-# +#
@@ -826,52 +899,52 @@ Returns the address of the underlying ERC-20 token that is being wrapped.
- +

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 [`ConfidentialFungibleTokenERC20Wrapper.rate`](#ConfidentialFungibleTokenERC20Wrapper-rate--). See [`ConfidentialFungibleTokenERC20Wrapper.wrap`](#ConfidentialFungibleTokenERC20Wrapper-wrap-address-uint256-) from more details on wrapping tokens. +sent beyond the nearest multiple of [`ERC7984ERC20Wrapper.rate`](#ERC7984ERC20Wrapper-rate--). See [`ERC7984ERC20Wrapper.wrap`](#ERC7984ERC20Wrapper-wrap-address-uint256-) from more details on wrapping tokens.
- +

wrap(address to, uint256 amount)

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 [`ConfidentialFungibleTokenERC20Wrapper.rate`](#ConfidentialFungibleTokenERC20Wrapper-rate--) such that `amount / rate()` confidential -tokens are sent. Amount transferred in is rounded down to the nearest multiple of [`ConfidentialFungibleTokenERC20Wrapper.rate`](#ConfidentialFungibleTokenERC20Wrapper-rate--). +`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--).
- +

unwrap(address from, address to, euint64 amount)

public

-# +#
@@ -880,8 +953,7 @@ Unwraps tokens from `from` and sends the underlying tokens to `to`. The caller m or be an approved operator for `from`. `amount * rate()` underlying tokens are sent to `to`. -This is an asynchronous function and waits for decryption to be completed off-chain before disbursing -tokens. +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`. @@ -890,49 +962,49 @@ The caller *must* already be approved by ACL for the given `amount`.
- +

unwrap(address from, address to, externalEuint64 encryptedAmount, bytes inputProof)

public

-# +#
-Variant of [`ConfidentialFungibleTokenERC20Wrapper.unwrap`](#ConfidentialFungibleTokenERC20Wrapper-unwrap-address-address-externalEuint64-bytes-) that passes an `inputProof` which approves the caller for the `encryptedAmount` +Variant of [`ERC7984ERC20Wrapper.unwrap`](#ERC7984ERC20Wrapper-unwrap-address-address-externalEuint64-bytes-) that passes an `inputProof` which approves the caller for the `encryptedAmount` in the ACL.
- +
-

finalizeUnwrap(uint256 requestID, uint64 amount, bytes[] signatures)

+

finalizeUnwrap(euint64 burntAmount, uint64 burntAmountCleartext, bytes decryptionProof)

public

-# +#
-Fills an unwrap request for a given request id related to a decrypted unwrap amount. +Fills an unwrap request for a given cipher-text `burntAmount` with the `cleartextAmount` and `decryptionProof`.
- +

_unwrap(address from, address to, euint64 amount)

internal

-# +#
@@ -940,70 +1012,1792 @@ Fills an unwrap request for a given request id related to a decrypted unwrap amo
- +

_fallbackUnderlyingDecimals() → uint8

internal

-# +#
Returns the default number of decimals of the underlying ERC-20 token that is being wrapped. -Used as a default fallback when [`ConfidentialFungibleTokenERC20Wrapper._tryGetAssetDecimals`](#ConfidentialFungibleTokenERC20Wrapper-_tryGetAssetDecimals-contract-IERC20-) fails to fetch decimals of the underlying +Used as a default fallback when [`ERC7984ERC20Wrapper._tryGetAssetDecimals`](#ERC7984ERC20Wrapper-_tryGetAssetDecimals-contract-IERC20-) fails to fetch decimals of the underlying ERC-20 token.
- +

_maxDecimals() → uint8

internal

-# +# +
+
+
+ +Returns the maximum number that will be used for [`IERC7984.decimals`](/confidential-contracts/api/interfaces#IERC7984-decimals--) by the wrapper. + +
+
+ + + +
+
+

UnwrapRequested(address indexed receiver, euint64 amount)

+
+

event

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

UnwrapFinalized(address indexed receiver, euint64 encryptedAmount, uint64 cleartextAmount)

+
+

event

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

InvalidUnwrapRequest(euint64 amount)

+
+

error

+# +
+
+
+ +
+
+ + + +
+ +## `ERC7984Freezable` + + + + + +
+ +```solidity +import "@openzeppelin/confidential-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. + +The freezing mechanism provides the guarantee to the contract owner +(e.g. a DAO or a well-configured multisig) that a specific confidential +amount of tokens held by an account won't be transferable until those +tokens are unfrozen. + +Inspired by https://github.com/OpenZeppelin/openzeppelin-community-contracts/blob/master/contracts/token/ERC20/extensions/ERC20Freezable.sol + +
+

Functions

+
+- [confidentialFrozen(account)](#ERC7984Freezable-confidentialFrozen-address-) +- [confidentialAvailable(account)](#ERC7984Freezable-confidentialAvailable-address-) +- [_confidentialAvailable(account)](#ERC7984Freezable-_confidentialAvailable-address-) +- [_setConfidentialFrozen(account, encryptedAmount)](#ERC7984Freezable-_setConfidentialFrozen-address-euint64-) +- [_update(from, to, encryptedAmount)](#ERC7984Freezable-_update-address-address-euint64-) +#### ERC7984 [!toc] +- [supportsInterface(interfaceId)](#ERC7984-supportsInterface-bytes4-) +- [name()](#ERC7984-name--) +- [symbol()](#ERC7984-symbol--) +- [decimals()](#ERC7984-decimals--) +- [contractURI()](#ERC7984-contractURI--) +- [confidentialTotalSupply()](#ERC7984-confidentialTotalSupply--) +- [confidentialBalanceOf(account)](#ERC7984-confidentialBalanceOf-address-) +- [isOperator(holder, spender)](#ERC7984-isOperator-address-address-) +- [setOperator(operator, until)](#ERC7984-setOperator-address-uint48-) +- [confidentialTransfer(to, encryptedAmount, inputProof)](#ERC7984-confidentialTransfer-address-externalEuint64-bytes-) +- [confidentialTransfer(to, amount)](#ERC7984-confidentialTransfer-address-euint64-) +- [confidentialTransferFrom(from, to, encryptedAmount, inputProof)](#ERC7984-confidentialTransferFrom-address-address-externalEuint64-bytes-) +- [confidentialTransferFrom(from, to, amount)](#ERC7984-confidentialTransferFrom-address-address-euint64-) +- [confidentialTransferAndCall(to, encryptedAmount, inputProof, data)](#ERC7984-confidentialTransferAndCall-address-externalEuint64-bytes-bytes-) +- [confidentialTransferAndCall(to, amount, data)](#ERC7984-confidentialTransferAndCall-address-euint64-bytes-) +- [confidentialTransferFromAndCall(from, to, encryptedAmount, inputProof, data)](#ERC7984-confidentialTransferFromAndCall-address-address-externalEuint64-bytes-bytes-) +- [confidentialTransferFromAndCall(from, to, amount, data)](#ERC7984-confidentialTransferFromAndCall-address-address-euint64-bytes-) +- [requestDiscloseEncryptedAmount(encryptedAmount)](#ERC7984-requestDiscloseEncryptedAmount-euint64-) +- [discloseEncryptedAmount(encryptedAmount, cleartextAmount, decryptionProof)](#ERC7984-discloseEncryptedAmount-euint64-uint64-bytes-) +- [_setOperator(holder, operator, until)](#ERC7984-_setOperator-address-address-uint48-) +- [_mint(to, amount)](#ERC7984-_mint-address-euint64-) +- [_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

+
+- [TokensFrozen(account, encryptedAmount)](#ERC7984Freezable-TokensFrozen-address-euint64-) +#### ERC7984 [!toc] +- [AmountDiscloseRequested(encryptedAmount, requester)](#ERC7984-AmountDiscloseRequested-euint64-address-) +#### ERC165 [!toc] +#### IERC7984 [!toc] +- [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] +- [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] +
+
+ + + +
+
+

confidentialFrozen(address account) → euint64

+
+

public

+# +
+
+
+ +Returns the confidential frozen balance of an account. + +
+
+ + + +
+
+

confidentialAvailable(address account) → euint64

+
+

public

+# +
+
+
+ +Returns the confidential available (unfrozen) balance of an account. Gives ACL allowance to `account`. + +
+
+ + + +
+
+

_confidentialAvailable(address account) → euint64

+
+

internal

+# +
+
+
+ +Internal function to calculate the available balance of an account. Does not give any allowances. + +
+
+ + + +
+
+

_setConfidentialFrozen(address account, euint64 encryptedAmount)

+
+

internal

+# +
+
+
+ +Internal function to freeze a confidential amount of tokens for an account. + +
+
+ + + +
+
+

_update(address from, address to, euint64 encryptedAmount) → euint64

+
+

internal

+# +
+
+
+ +See [`ERC7984._update`](#ERC7984-_update-address-address-euint64-). + +The `from` account must have sufficient unfrozen balance, +otherwise 0 tokens are transferred. +The default freezing behavior can be changed (for a pass-through for instance) by overriding +[`ERC7984Freezable._confidentialAvailable`](#ERC7984Freezable-_confidentialAvailable-address-). The internal function is used for actual gating (not the public function) +to avoid unnecessarily granting ACL allowances. + +
+
+ + + +
+
+

TokensFrozen(address indexed account, euint64 encryptedAmount)

+
+

event

+# +
+
+ +
+ +Emitted when a confidential amount of token is frozen for an account + +
+
+ + + +
+ +## `ERC7984ObserverAccess` + + + + + +
+ +```solidity +import "@openzeppelin/confidential-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. + +
+

Functions

+
+- [setObserver(account, newObserver)](#ERC7984ObserverAccess-setObserver-address-address-) +- [observer(account)](#ERC7984ObserverAccess-observer-address-) +- [_update(from, to, amount)](#ERC7984ObserverAccess-_update-address-address-euint64-) +#### ERC7984 [!toc] +- [supportsInterface(interfaceId)](#ERC7984-supportsInterface-bytes4-) +- [name()](#ERC7984-name--) +- [symbol()](#ERC7984-symbol--) +- [decimals()](#ERC7984-decimals--) +- [contractURI()](#ERC7984-contractURI--) +- [confidentialTotalSupply()](#ERC7984-confidentialTotalSupply--) +- [confidentialBalanceOf(account)](#ERC7984-confidentialBalanceOf-address-) +- [isOperator(holder, spender)](#ERC7984-isOperator-address-address-) +- [setOperator(operator, until)](#ERC7984-setOperator-address-uint48-) +- [confidentialTransfer(to, encryptedAmount, inputProof)](#ERC7984-confidentialTransfer-address-externalEuint64-bytes-) +- [confidentialTransfer(to, amount)](#ERC7984-confidentialTransfer-address-euint64-) +- [confidentialTransferFrom(from, to, encryptedAmount, inputProof)](#ERC7984-confidentialTransferFrom-address-address-externalEuint64-bytes-) +- [confidentialTransferFrom(from, to, amount)](#ERC7984-confidentialTransferFrom-address-address-euint64-) +- [confidentialTransferAndCall(to, encryptedAmount, inputProof, data)](#ERC7984-confidentialTransferAndCall-address-externalEuint64-bytes-bytes-) +- [confidentialTransferAndCall(to, amount, data)](#ERC7984-confidentialTransferAndCall-address-euint64-bytes-) +- [confidentialTransferFromAndCall(from, to, encryptedAmount, inputProof, data)](#ERC7984-confidentialTransferFromAndCall-address-address-externalEuint64-bytes-bytes-) +- [confidentialTransferFromAndCall(from, to, amount, data)](#ERC7984-confidentialTransferFromAndCall-address-address-euint64-bytes-) +- [requestDiscloseEncryptedAmount(encryptedAmount)](#ERC7984-requestDiscloseEncryptedAmount-euint64-) +- [discloseEncryptedAmount(encryptedAmount, cleartextAmount, decryptionProof)](#ERC7984-discloseEncryptedAmount-euint64-uint64-bytes-) +- [_setOperator(holder, operator, until)](#ERC7984-_setOperator-address-address-uint48-) +- [_mint(to, amount)](#ERC7984-_mint-address-euint64-) +- [_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

+
+- [ERC7984ObserverAccessObserverSet(account, oldObserver, newObserver)](#ERC7984ObserverAccess-ERC7984ObserverAccessObserverSet-address-address-address-) +#### ERC7984 [!toc] +- [AmountDiscloseRequested(encryptedAmount, requester)](#ERC7984-AmountDiscloseRequested-euint64-address-) +#### ERC165 [!toc] +#### IERC7984 [!toc] +- [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

+
+- [Unauthorized()](#ERC7984ObserverAccess-Unauthorized--) +#### ERC7984 [!toc] +- [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] +
+
+ + + +
+
+

setObserver(address account, address newObserver)

+
+

public

+# +
+
+
+ +Sets the observer for the given account `account` to `newObserver`. Can be called by the +account or the existing observer to abdicate the observer role (may only set to `address(0)`). + +
+
+ + + +
+
+

observer(address account) → address

+
+

public

+# +
+
+
+ +Returns the observer for the given account `account`. + +
+
+ + + +
+
+

_update(address from, address to, euint64 amount) → euint64 transferred

+
+

internal

+#
-Returns the maximum number that will be used for [`IConfidentialFungibleToken.decimals`](./interfaces#IConfidentialFungibleToken-decimals--) by the wrapper. +
+
+ + + +
+
+

ERC7984ObserverAccessObserverSet(address account, address oldObserver, address newObserver)

+
+

event

+# +
+
+ +
+ +Emitted when the observer is changed for the given account `account`. + +
+
+ + + +
+
+

Unauthorized()

+
+

error

+# +
+
+
+ +Thrown when an account tries to set a `newObserver` for a given `account` without proper authority. + +
+
+ + + +
+ +## `ERC7984Omnibus` + + + + + +
+ +```solidity +import "@openzeppelin/confidential-contracts/token/ERC7984/extensions/ERC7984Omnibus.sol"; +``` + +Extension of [`ERC7984`](#ERC7984) that emits additional events for omnibus transfers. +These events contain encrypted addresses for the sub-account sender and recipient. + + +There is no onchain accounting for sub-accounts--integrators must track sub-account +balances externally. + + +
+

Functions

+
+- [confidentialTransferOmnibus(omnibusTo, externalSender, externalRecipient, externalAmount, inputProof)](#ERC7984Omnibus-confidentialTransferOmnibus-address-externalEaddress-externalEaddress-externalEuint64-bytes-) +- [confidentialTransferOmnibus(omnibusTo, sender, recipient, amount)](#ERC7984Omnibus-confidentialTransferOmnibus-address-eaddress-eaddress-euint64-) +- [confidentialTransferFromOmnibus(omnibusFrom, omnibusTo, externalSender, externalRecipient, externalAmount, inputProof)](#ERC7984Omnibus-confidentialTransferFromOmnibus-address-address-externalEaddress-externalEaddress-externalEuint64-bytes-) +- [confidentialTransferFromOmnibus(omnibusFrom, omnibusTo, sender, recipient, amount)](#ERC7984Omnibus-confidentialTransferFromOmnibus-address-address-eaddress-eaddress-euint64-) +- [confidentialTransferAndCallOmnibus(omnibusTo, externalSender, externalRecipient, externalAmount, inputProof, data)](#ERC7984Omnibus-confidentialTransferAndCallOmnibus-address-externalEaddress-externalEaddress-externalEuint64-bytes-bytes-) +- [confidentialTransferAndCallOmnibus(omnibusTo, sender, recipient, amount, data)](#ERC7984Omnibus-confidentialTransferAndCallOmnibus-address-eaddress-eaddress-euint64-bytes-) +- [confidentialTransferFromAndCallOmnibus(omnibusFrom, omnibusTo, externalSender, externalRecipient, externalAmount, inputProof, data)](#ERC7984Omnibus-confidentialTransferFromAndCallOmnibus-address-address-externalEaddress-externalEaddress-externalEuint64-bytes-bytes-) +- [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] +- [supportsInterface(interfaceId)](#ERC7984-supportsInterface-bytes4-) +- [name()](#ERC7984-name--) +- [symbol()](#ERC7984-symbol--) +- [decimals()](#ERC7984-decimals--) +- [contractURI()](#ERC7984-contractURI--) +- [confidentialTotalSupply()](#ERC7984-confidentialTotalSupply--) +- [confidentialBalanceOf(account)](#ERC7984-confidentialBalanceOf-address-) +- [isOperator(holder, spender)](#ERC7984-isOperator-address-address-) +- [setOperator(operator, until)](#ERC7984-setOperator-address-uint48-) +- [confidentialTransfer(to, encryptedAmount, inputProof)](#ERC7984-confidentialTransfer-address-externalEuint64-bytes-) +- [confidentialTransfer(to, amount)](#ERC7984-confidentialTransfer-address-euint64-) +- [confidentialTransferFrom(from, to, encryptedAmount, inputProof)](#ERC7984-confidentialTransferFrom-address-address-externalEuint64-bytes-) +- [confidentialTransferFrom(from, to, amount)](#ERC7984-confidentialTransferFrom-address-address-euint64-) +- [confidentialTransferAndCall(to, encryptedAmount, inputProof, data)](#ERC7984-confidentialTransferAndCall-address-externalEuint64-bytes-bytes-) +- [confidentialTransferAndCall(to, amount, data)](#ERC7984-confidentialTransferAndCall-address-euint64-bytes-) +- [confidentialTransferFromAndCall(from, to, encryptedAmount, inputProof, data)](#ERC7984-confidentialTransferFromAndCall-address-address-externalEuint64-bytes-bytes-) +- [confidentialTransferFromAndCall(from, to, amount, data)](#ERC7984-confidentialTransferFromAndCall-address-address-euint64-bytes-) +- [requestDiscloseEncryptedAmount(encryptedAmount)](#ERC7984-requestDiscloseEncryptedAmount-euint64-) +- [discloseEncryptedAmount(encryptedAmount, cleartextAmount, decryptionProof)](#ERC7984-discloseEncryptedAmount-euint64-uint64-bytes-) +- [_setOperator(holder, operator, until)](#ERC7984-_setOperator-address-address-uint48-) +- [_mint(to, amount)](#ERC7984-_mint-address-euint64-) +- [_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

+
+- [OmnibusConfidentialTransfer(omnibusFrom, omnibusTo, sender, recipient, amount)](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) +#### ERC7984 [!toc] +- [AmountDiscloseRequested(encryptedAmount, requester)](#ERC7984-AmountDiscloseRequested-euint64-address-) +#### ERC165 [!toc] +#### IERC7984 [!toc] +- [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

+
+- [ERC7984UnauthorizedUseOfEncryptedAddress(addr, user)](#ERC7984Omnibus-ERC7984UnauthorizedUseOfEncryptedAddress-eaddress-address-) +#### ERC7984 [!toc] +- [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] +
+
+ + + +
+
+

confidentialTransferOmnibus(address omnibusTo, externalEaddress externalSender, externalEaddress externalRecipient, externalEuint64 externalAmount, bytes inputProof) → euint64

+
+

public

+# +
+
+
+ +Wraps the interfaces#IERC7984-confidentialTransfer-address-externalEuint64-bytes- function and emits the [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) event. + +
+
+ + + +
+
+

confidentialTransferOmnibus(address omnibusTo, eaddress sender, eaddress recipient, euint64 amount) → euint64

+
+

public

+# +
+
+
+ +Wraps the interfaces#IERC7984-confidentialTransfer-address-euint64- function and emits the [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) event. + +
+
+ + + +
+
+

confidentialTransferFromOmnibus(address omnibusFrom, address omnibusTo, externalEaddress externalSender, externalEaddress externalRecipient, externalEuint64 externalAmount, bytes inputProof) → euint64

+
+

public

+# +
+
+
+ +Wraps the interfaces#IERC7984-confidentialTransferFrom-address-address-externalEuint64-bytes- function and emits the [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) event. + +
+
+ + + +
+
+

confidentialTransferFromOmnibus(address omnibusFrom, address omnibusTo, eaddress sender, eaddress recipient, euint64 amount) → euint64

+
+

public

+# +
+
+
+ +Wraps the interfaces#IERC7984-confidentialTransferFrom-address-address-euint64- function and emits the [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) event. + +
+
+ + + +
+
+

confidentialTransferAndCallOmnibus(address omnibusTo, externalEaddress externalSender, externalEaddress externalRecipient, externalEuint64 externalAmount, bytes inputProof, bytes data) → euint64

+
+

public

+# +
+
+
+ +Wraps the interfaces#IERC7984-confidentialTransferAndCall-address-externalEuint64-bytes-bytes- function and emits the [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) event. + +
+
+ + + +
+
+

confidentialTransferAndCallOmnibus(address omnibusTo, eaddress sender, eaddress recipient, euint64 amount, bytes data) → euint64

+
+

public

+# +
+
+
+ +Wraps the interfaces#IERC7984-confidentialTransferAndCall-address-euint64-bytes- function and emits the [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) event. + +
+
+ + + +
+
+

confidentialTransferFromAndCallOmnibus(address omnibusFrom, address omnibusTo, externalEaddress externalSender, externalEaddress externalRecipient, externalEuint64 externalAmount, bytes inputProof, bytes data) → euint64

+
+

public

+# +
+
+
+ +Wraps the interfaces#IERC7984-confidentialTransferFromAndCall-address-address-externalEuint64-bytes-bytes- function and emits the [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) event. + +
+
+ + + +
+
+

confidentialTransferFromAndCallOmnibus(address omnibusFrom, address omnibusTo, eaddress sender, eaddress recipient, euint64 amount, bytes data) → euint64

+
+

public

+# +
+
+
+ +Wraps the interfaces#IERC7984-confidentialTransferFromAndCall-address-address-euint64-bytes- function and emits the [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-) event. + +
+
+ + + +
+
+

_confidentialTransferFromOmnibus(address omnibusFrom, address omnibusTo, eaddress sender, eaddress recipient, euint64 amount) → euint64

+
+

internal

+# +
+
+
+ +Handles the ACL allowances, does the transfer without a callback, and emits [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-). + +
+
+ + + +
+
+

_confidentialTransferFromAndCallOmnibus(address omnibusFrom, address omnibusTo, eaddress sender, eaddress recipient, euint64 amount, bytes data) → euint64

+
+

internal

+# +
+
+
+ +Handles the ACL allowances, does the transfer with a callback, and emits [`ERC7984Omnibus.OmnibusConfidentialTransfer`](#ERC7984Omnibus-OmnibusConfidentialTransfer-address-address-eaddress-eaddress-euint64-). + +
+
+ + + +
+
+

OmnibusConfidentialTransfer(address indexed omnibusFrom, address indexed omnibusTo, eaddress sender, eaddress indexed recipient, euint64 amount)

+
+

event

+# +
+
+ +
+ +Emitted when a confidential transfer is made representing the onchain settlement of +an omnibus transfer from `sender` to `recipient` of amount `amount`. Settlement occurs between +`omnibusFrom` and `omnibusTo` and is represented in a matching [`IERC7984.ConfidentialTransfer`](/confidential-contracts/api/interfaces#IERC7984-ConfidentialTransfer-address-address-euint64-) event. + + +`omnibusFrom` and `omnibusTo` get permanent ACL allowances for `sender` and `recipient`. + + +
+
+ + + +
+
+

ERC7984UnauthorizedUseOfEncryptedAddress(eaddress addr, address user)

+
+

error

+# +
+
+
+ +The caller `user` does not have access to the encrypted address `addr`. + + +Try using the equivalent transfer function with an input proof. + + +
+
+ + + +
+ +## `ERC7984Restricted` + + + + + +
+ +```solidity +import "@openzeppelin/confidential-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 +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` +to implement an allowlist. + +
+

Functions

+
+- [getRestriction(account)](#ERC7984Restricted-getRestriction-address-) +- [isUserAllowed(account)](#ERC7984Restricted-isUserAllowed-address-) +- [_update(from, to, value)](#ERC7984Restricted-_update-address-address-euint64-) +- [_setRestriction(account, restriction)](#ERC7984Restricted-_setRestriction-address-enum-ERC7984Restricted-Restriction-) +- [_blockUser(account)](#ERC7984Restricted-_blockUser-address-) +- [_allowUser(account)](#ERC7984Restricted-_allowUser-address-) +- [_resetUser(account)](#ERC7984Restricted-_resetUser-address-) +- [_checkRestriction(account)](#ERC7984Restricted-_checkRestriction-address-) +- [_checkSenderRestriction(account)](#ERC7984Restricted-_checkSenderRestriction-address-) +- [_checkRecipientRestriction(account)](#ERC7984Restricted-_checkRecipientRestriction-address-) +#### ERC7984 [!toc] +- [supportsInterface(interfaceId)](#ERC7984-supportsInterface-bytes4-) +- [name()](#ERC7984-name--) +- [symbol()](#ERC7984-symbol--) +- [decimals()](#ERC7984-decimals--) +- [contractURI()](#ERC7984-contractURI--) +- [confidentialTotalSupply()](#ERC7984-confidentialTotalSupply--) +- [confidentialBalanceOf(account)](#ERC7984-confidentialBalanceOf-address-) +- [isOperator(holder, spender)](#ERC7984-isOperator-address-address-) +- [setOperator(operator, until)](#ERC7984-setOperator-address-uint48-) +- [confidentialTransfer(to, encryptedAmount, inputProof)](#ERC7984-confidentialTransfer-address-externalEuint64-bytes-) +- [confidentialTransfer(to, amount)](#ERC7984-confidentialTransfer-address-euint64-) +- [confidentialTransferFrom(from, to, encryptedAmount, inputProof)](#ERC7984-confidentialTransferFrom-address-address-externalEuint64-bytes-) +- [confidentialTransferFrom(from, to, amount)](#ERC7984-confidentialTransferFrom-address-address-euint64-) +- [confidentialTransferAndCall(to, encryptedAmount, inputProof, data)](#ERC7984-confidentialTransferAndCall-address-externalEuint64-bytes-bytes-) +- [confidentialTransferAndCall(to, amount, data)](#ERC7984-confidentialTransferAndCall-address-euint64-bytes-) +- [confidentialTransferFromAndCall(from, to, encryptedAmount, inputProof, data)](#ERC7984-confidentialTransferFromAndCall-address-address-externalEuint64-bytes-bytes-) +- [confidentialTransferFromAndCall(from, to, amount, data)](#ERC7984-confidentialTransferFromAndCall-address-address-euint64-bytes-) +- [requestDiscloseEncryptedAmount(encryptedAmount)](#ERC7984-requestDiscloseEncryptedAmount-euint64-) +- [discloseEncryptedAmount(encryptedAmount, cleartextAmount, decryptionProof)](#ERC7984-discloseEncryptedAmount-euint64-uint64-bytes-) +- [_setOperator(holder, operator, until)](#ERC7984-_setOperator-address-address-uint48-) +- [_mint(to, amount)](#ERC7984-_mint-address-euint64-) +- [_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

+
+- [UserRestrictionUpdated(account, restriction)](#ERC7984Restricted-UserRestrictionUpdated-address-enum-ERC7984Restricted-Restriction-) +#### ERC7984 [!toc] +- [AmountDiscloseRequested(encryptedAmount, requester)](#ERC7984-AmountDiscloseRequested-euint64-address-) +#### ERC165 [!toc] +#### IERC7984 [!toc] +- [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

+
+- [UserRestricted(account)](#ERC7984Restricted-UserRestricted-address-) +#### ERC7984 [!toc] +- [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] +
+
+ + + +
+
+

getRestriction(address account) → enum ERC7984Restricted.Restriction

+
+

public

+# +
+
+
+ +Returns the restriction of a user account. + +
+
+ + + +
+
+

isUserAllowed(address account) → bool

+
+

public

+# +
+
+
+ +Returns whether a user account is allowed to interact with the token. + +Default implementation only disallows explicitly BLOCKED accounts (i.e. a blocklist). + +
+
+ + + +
+
+

_update(address from, address to, euint64 value) → euint64

+
+

internal

+# +
+
+
+ +See [`ERC7984._update`](#ERC7984-_update-address-address-euint64-). Enforces transfer restrictions (excluding minting and burning). + +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-)). + +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-). + +
+
+ + + +
+
+

_setRestriction(address account, enum ERC7984Restricted.Restriction restriction)

+
+

internal

+# +
+
+
+ +Updates the restriction of a user account. + +
+
+ + + +
+
+

_blockUser(address account)

+
+

internal

+# +
+
+
+ +Convenience function to block a user account (set to BLOCKED). + +
+
+ + + +
+
+

_allowUser(address account)

+
+

internal

+# +
+
+
+ +Convenience function to allow a user account (set to ALLOWED). + +
+
+ + + +
+
+

_resetUser(address account)

+
+

internal

+# +
+
+
+ +Convenience function to reset a user account to default restriction. + +
+
+ + + +
+
+

_checkRestriction(address account)

+
+

internal

+# +
+
+
+ +Checks if a user account is restricted. Reverts with [`ERC7984Restricted.UserRestricted`](#ERC7984Restricted-UserRestricted-address-) if so. + +
+
+ + + +
+
+

_checkSenderRestriction(address account)

+
+

internal

+# +
+
+
+ +Internal function which checks restriction of the `from` account before a transfer. +Working with [`ERC7984._update`](#ERC7984-_update-address-address-euint64-) function. + +
+
+ + + +
+
+

_checkRecipientRestriction(address account)

+
+

internal

+# +
+
+
+ +Internal function which checks restriction of the `to` account before a transfer. +Working with [`ERC7984._update`](#ERC7984-_update-address-address-euint64-) function. + +
+
+ + + +
+
+

UserRestrictionUpdated(address indexed account, enum ERC7984Restricted.Restriction restriction)

+
+

event

+# +
+
+ +
+ +Emitted when a user account's restriction is updated. + +
+
+ + + +
+
+

UserRestricted(address account)

+
+

error

+# +
+
+
+ +The operation failed because the user account is restricted. + +
+
+ + + +
+ +## `ERC7984Rwa` + + + + + +
+ +```solidity +import "@openzeppelin/confidential-contracts/token/ERC7984/extensions/ERC7984Rwa.sol"; +``` + +Extension of [`ERC7984`](#ERC7984) that supports confidential Real World Assets (RWAs). +This interface provides compliance checks, transfer controls and enforcement actions. + +
+

Modifiers

+
+- [onlyAdmin()](#ERC7984Rwa-onlyAdmin--) +- [onlyAgent()](#ERC7984Rwa-onlyAgent--) +
+
+ +
+

Functions

+
+- [constructor(admin)](#ERC7984Rwa-constructor-address-) +- [supportsInterface(interfaceId)](#ERC7984Rwa-supportsInterface-bytes4-) +- [isAdmin(account)](#ERC7984Rwa-isAdmin-address-) +- [isAgent(account)](#ERC7984Rwa-isAgent-address-) +- [addAgent(account)](#ERC7984Rwa-addAgent-address-) +- [removeAgent(account)](#ERC7984Rwa-removeAgent-address-) +- [pause()](#ERC7984Rwa-pause--) +- [unpause()](#ERC7984Rwa-unpause--) +- [blockUser(account)](#ERC7984Rwa-blockUser-address-) +- [unblockUser(account)](#ERC7984Rwa-unblockUser-address-) +- [setConfidentialFrozen(account, encryptedAmount, inputProof)](#ERC7984Rwa-setConfidentialFrozen-address-externalEuint64-bytes-) +- [setConfidentialFrozen(account, encryptedAmount)](#ERC7984Rwa-setConfidentialFrozen-address-euint64-) +- [confidentialMint(to, encryptedAmount, inputProof)](#ERC7984Rwa-confidentialMint-address-externalEuint64-bytes-) +- [confidentialMint(to, encryptedAmount)](#ERC7984Rwa-confidentialMint-address-euint64-) +- [confidentialBurn(account, encryptedAmount, inputProof)](#ERC7984Rwa-confidentialBurn-address-externalEuint64-bytes-) +- [confidentialBurn(account, encryptedAmount)](#ERC7984Rwa-confidentialBurn-address-euint64-) +- [forceConfidentialTransferFrom(from, to, encryptedAmount, inputProof)](#ERC7984Rwa-forceConfidentialTransferFrom-address-address-externalEuint64-bytes-) +- [forceConfidentialTransferFrom(from, to, encryptedAmount)](#ERC7984Rwa-forceConfidentialTransferFrom-address-address-euint64-) +- [confidentialAvailable(account)](#ERC7984Rwa-confidentialAvailable-address-) +- [confidentialFrozen(account)](#ERC7984Rwa-confidentialFrozen-address-) +- [paused()](#ERC7984Rwa-paused--) +- [isUserAllowed(account)](#ERC7984Rwa-isUserAllowed-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] +- [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) +#### Multicall [!toc] +- [multicall(data)](#Multicall-multicall-bytes---) +#### Pausable [!toc] +- [_requireNotPaused()](#Pausable-_requireNotPaused--) +- [_requirePaused()](#Pausable-_requirePaused--) +- [_pause()](#Pausable-_pause--) +- [_unpause()](#Pausable-_unpause--) +#### ERC7984Restricted [!toc] +- [getRestriction(account)](#ERC7984Restricted-getRestriction-address-) +- [_setRestriction(account, restriction)](#ERC7984Restricted-_setRestriction-address-enum-ERC7984Restricted-Restriction-) +- [_blockUser(account)](#ERC7984Restricted-_blockUser-address-) +- [_allowUser(account)](#ERC7984Restricted-_allowUser-address-) +- [_resetUser(account)](#ERC7984Restricted-_resetUser-address-) +- [_checkRestriction(account)](#ERC7984Restricted-_checkRestriction-address-) +- [_checkRecipientRestriction(account)](#ERC7984Restricted-_checkRecipientRestriction-address-) +#### ERC7984Freezable [!toc] +- [_confidentialAvailable(account)](#ERC7984Freezable-_confidentialAvailable-address-) +- [_setConfidentialFrozen(account, encryptedAmount)](#ERC7984Freezable-_setConfidentialFrozen-address-euint64-) +#### ERC7984 [!toc] +- [name()](#ERC7984-name--) +- [symbol()](#ERC7984-symbol--) +- [decimals()](#ERC7984-decimals--) +- [contractURI()](#ERC7984-contractURI--) +- [confidentialTotalSupply()](#ERC7984-confidentialTotalSupply--) +- [confidentialBalanceOf(account)](#ERC7984-confidentialBalanceOf-address-) +- [isOperator(holder, spender)](#ERC7984-isOperator-address-address-) +- [setOperator(operator, until)](#ERC7984-setOperator-address-uint48-) +- [confidentialTransfer(to, encryptedAmount, inputProof)](#ERC7984-confidentialTransfer-address-externalEuint64-bytes-) +- [confidentialTransfer(to, amount)](#ERC7984-confidentialTransfer-address-euint64-) +- [confidentialTransferFrom(from, to, encryptedAmount, inputProof)](#ERC7984-confidentialTransferFrom-address-address-externalEuint64-bytes-) +- [confidentialTransferFrom(from, to, amount)](#ERC7984-confidentialTransferFrom-address-address-euint64-) +- [confidentialTransferAndCall(to, encryptedAmount, inputProof, data)](#ERC7984-confidentialTransferAndCall-address-externalEuint64-bytes-bytes-) +- [confidentialTransferAndCall(to, amount, data)](#ERC7984-confidentialTransferAndCall-address-euint64-bytes-) +- [confidentialTransferFromAndCall(from, to, encryptedAmount, inputProof, data)](#ERC7984-confidentialTransferFromAndCall-address-address-externalEuint64-bytes-bytes-) +- [confidentialTransferFromAndCall(from, to, amount, data)](#ERC7984-confidentialTransferFromAndCall-address-address-euint64-bytes-) +- [requestDiscloseEncryptedAmount(encryptedAmount)](#ERC7984-requestDiscloseEncryptedAmount-euint64-) +- [discloseEncryptedAmount(encryptedAmount, cleartextAmount, decryptionProof)](#ERC7984-discloseEncryptedAmount-euint64-uint64-bytes-) +- [_setOperator(holder, operator, until)](#ERC7984-_setOperator-address-address-uint48-) +- [_mint(to, amount)](#ERC7984-_mint-address-euint64-) +- [_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] +- [Paused(account)](#Pausable-Paused-address-) +- [Unpaused(account)](#Pausable-Unpaused-address-) +#### ERC7984Restricted [!toc] +- [UserRestrictionUpdated(account, restriction)](#ERC7984Restricted-UserRestrictionUpdated-address-enum-ERC7984Restricted-Restriction-) +#### ERC7984Freezable [!toc] +- [TokensFrozen(account, encryptedAmount)](#ERC7984Freezable-TokensFrozen-address-euint64-) +#### ERC7984 [!toc] +- [AmountDiscloseRequested(encryptedAmount, requester)](#ERC7984-AmountDiscloseRequested-euint64-address-) +#### ERC165 [!toc] +#### IERC7984Rwa [!toc] +#### IERC7984 [!toc] +- [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] +- [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] +- [EnforcedPause()](#Pausable-EnforcedPause--) +- [ExpectedPause()](#Pausable-ExpectedPause--) +#### ERC7984Restricted [!toc] +- [UserRestricted(account)](#ERC7984Restricted-UserRestricted-address-) +#### ERC7984Freezable [!toc] +#### ERC7984 [!toc] +- [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] +- [AccessControlUnauthorizedAccount(account, neededRole)](#IAccessControl-AccessControlUnauthorizedAccount-address-bytes32-) +- [AccessControlBadConfirmation()](#IAccessControl-AccessControlBadConfirmation--) +
+
+ + + +
+
+

onlyAdmin()

+
+

internal

+# +
+
+ +
+ +Checks if the sender is an admin. + +
+
+ + + +
+
+

onlyAgent()

+
+

internal

+# +
+
+ +
+ +Checks if the sender is an agent. + +
+
+ + + +
+
+

constructor(address admin)

+
+

internal

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

supportsInterface(bytes4 interfaceId) → bool

+
+

public

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

isAdmin(address account) → bool

+
+

public

+# +
+
+
+ +Returns true if has admin role, false otherwise. + +
+
+ + + +
+
+

isAgent(address account) → bool

+
+

public

+# +
+
+
+ +Returns true if agent, false otherwise. + +
+
+ + + +
+
+

addAgent(address account)

+
+

public

+# +
+
+
+ +Adds agent. + +
+
+ + + +
+
+

removeAgent(address account)

+
+

public

+# +
+
+
+ +Removes agent. + +
+
+ + + +
+
+

pause()

+
+

public

+# +
+
+
+ +Pauses contract. + +
+
+ + + +
+
+

unpause()

+
+

public

+# +
+
+
+ +Unpauses contract. + +
+
+ + + +
+
+

blockUser(address account)

+
+

public

+# +
+
+
+ +Blocks a user account. + +
+
+ + + +
+
+

unblockUser(address account)

+
+

public

+# +
+
+
+ +Unblocks a user account. + +
+
+ + + +
+
+

setConfidentialFrozen(address account, externalEuint64 encryptedAmount, bytes inputProof)

+
+

public

+# +
+
+
+ +Sets confidential frozen for an account with proof. + +
+
+ + + +
+
+

setConfidentialFrozen(address account, euint64 encryptedAmount)

+
+

public

+# +
+
+
+ +Sets confidential frozen for an account. + +
+
+ + + +
+
+

confidentialMint(address to, externalEuint64 encryptedAmount, bytes inputProof) → euint64

+
+

public

+# +
+
+
+ +Mints confidential amount of tokens to account with proof. + +
+
+ + + +
+
+

confidentialMint(address to, euint64 encryptedAmount) → euint64

+
+

public

+# +
+
+
+ +Mints confidential amount of tokens to account. + +
+
+ + + +
+
+

confidentialBurn(address account, externalEuint64 encryptedAmount, bytes inputProof) → euint64

+
+

public

+# +
+
+
+ +Burns confidential amount of tokens from account with proof. + +
+
+ + + +
+
+

confidentialBurn(address account, euint64 encryptedAmount) → euint64

+
+

public

+# +
+
+
+ +Burns confidential amount of tokens from account. + +
+
+ + + +
+
+

forceConfidentialTransferFrom(address from, address to, externalEuint64 encryptedAmount, bytes inputProof) → euint64

+
+

public

+# +
+
+
+ +Variant of interfaces#IERC7984Rwa-forceConfidentialTransferFrom-address-address-euint64- with an input proof. + +
+
+ + + +
+
+

forceConfidentialTransferFrom(address from, address to, euint64 encryptedAmount) → euint64 transferred

+
+

public

+# +
+
+
+ +Force transfer callable by the role [`ERC7984Rwa.AGENT_ROLE`](#ERC7984Rwa-AGENT_ROLE-bytes32) which transfers tokens from `from` to `to` and +bypasses the [`ERC7984Restricted`](#ERC7984Restricted) (only on from) and [`++Pausable++`](https://docs.openzeppelin.com/contracts/api/utils#pausable) +checks. Frozen tokens are not transferred and must be unfrozen first. + +
+
+ + + +
+
+

confidentialAvailable(address account) → euint64

+
+

public

+# +
+
+
+ +Returns the confidential available (unfrozen) balance of an account. Gives ACL allowance to `account`. + +
+
+ + + +
+
+

confidentialFrozen(address account) → euint64

+
+

public

+# +
+
+
+ +Returns the confidential frozen balance of an account. + +
+
+ + + +
+
+

paused() → bool

+
+

public

+# +
+
+
+ +Returns true if the contract is paused, and false otherwise. + +
+
+ + + +
+
+

isUserAllowed(address account) → bool

+
+

public

+# +
+
+
+ +Returns whether a user account is allowed to interact with the token. + +Default implementation only disallows explicitly BLOCKED accounts (i.e. a blocklist). + +
+
+ + + +
+
+

_update(address from, address to, euint64 encryptedAmount) → euint64

+
+

internal

+# +
+
+
+ +Internal function which updates confidential balances while performing frozen and restriction compliance checks. + +
+
+ + + +
+
+

_forceUpdate(address from, address to, euint64 encryptedAmount) → euint64

+
+

internal

+# +
+
+
+ +Internal function which forces transfer of confidential amount of tokens from account to account by skipping compliance checks. + +
+
+ + + +
+
+

_checkSenderRestriction(address account)

+
+

internal

+# +
+
+
+ +Bypasses the `from` restriction check when performing a [`IERC7984Rwa.forceConfidentialTransferFrom`](/confidential-contracts/api/interfaces#IERC7984Rwa-forceConfidentialTransferFrom-address-address-euint64-). + +
+
+ + + +
+
+

AGENT_ROLE() → bytes32

+
+

public

+# +
+
+
+ +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.
- +
-## `ConfidentialFungibleTokenVotes` +## `ERC7984Votes` - +
```solidity -import "@openzeppelin/confidential-contracts/token/extensions/ConfidentialFungibleTokenVotes.sol"; +import "@openzeppelin/confidential-contracts/token/ERC7984/extensions/ERC7984Votes.sol"; ``` -Extension of [`ConfidentialFungibleToken`](#ConfidentialFungibleToken) supporting confidential votes tracking and delegation. +Extension of [`ERC7984`](#ERC7984) supporting confidential votes tracking and delegation. -The amount of confidential voting units an account has is equal to the confidential token balance of +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 account.

Functions

-- [confidentialTotalSupply()](#ConfidentialFungibleTokenVotes-confidentialTotalSupply--) -- [_update(from, to, amount)](#ConfidentialFungibleTokenVotes-_update-address-address-euint64-) -- [_getVotingUnits(account)](#ConfidentialFungibleTokenVotes-_getVotingUnits-address-) +- [confidentialTotalSupply()](#ERC7984Votes-confidentialTotalSupply--) +- [_update(from, to, amount)](#ERC7984Votes-_update-address-address-euint64-) +- [_getVotingUnits(account)](#ERC7984Votes-_getVotingUnits-address-) #### VotesConfidential [!toc] - [clock()](#VotesConfidential-clock--) - [CLOCK_MODE()](#VotesConfidential-CLOCK_MODE--) @@ -1032,30 +2826,33 @@ account. - [nonces(owner)](#Nonces-nonces-address-) - [_useNonce(owner)](#Nonces-_useNonce-address-) - [_useCheckedNonce(owner, nonce)](#Nonces-_useCheckedNonce-address-uint256-) -#### ConfidentialFungibleToken [!toc] -- [name()](#ConfidentialFungibleToken-name--) -- [symbol()](#ConfidentialFungibleToken-symbol--) -- [decimals()](#ConfidentialFungibleToken-decimals--) -- [tokenURI()](#ConfidentialFungibleToken-tokenURI--) -- [confidentialBalanceOf(account)](#ConfidentialFungibleToken-confidentialBalanceOf-address-) -- [isOperator(holder, spender)](#ConfidentialFungibleToken-isOperator-address-address-) -- [setOperator(operator, until)](#ConfidentialFungibleToken-setOperator-address-uint48-) -- [confidentialTransfer(to, encryptedAmount, inputProof)](#ConfidentialFungibleToken-confidentialTransfer-address-externalEuint64-bytes-) -- [confidentialTransfer(to, amount)](#ConfidentialFungibleToken-confidentialTransfer-address-euint64-) -- [confidentialTransferFrom(from, to, encryptedAmount, inputProof)](#ConfidentialFungibleToken-confidentialTransferFrom-address-address-externalEuint64-bytes-) -- [confidentialTransferFrom(from, to, amount)](#ConfidentialFungibleToken-confidentialTransferFrom-address-address-euint64-) -- [confidentialTransferAndCall(to, encryptedAmount, inputProof, data)](#ConfidentialFungibleToken-confidentialTransferAndCall-address-externalEuint64-bytes-bytes-) -- [confidentialTransferAndCall(to, amount, data)](#ConfidentialFungibleToken-confidentialTransferAndCall-address-euint64-bytes-) -- [confidentialTransferFromAndCall(from, to, encryptedAmount, inputProof, data)](#ConfidentialFungibleToken-confidentialTransferFromAndCall-address-address-externalEuint64-bytes-bytes-) -- [confidentialTransferFromAndCall(from, to, amount, data)](#ConfidentialFungibleToken-confidentialTransferFromAndCall-address-address-euint64-bytes-) -- [discloseEncryptedAmount(encryptedAmount)](#ConfidentialFungibleToken-discloseEncryptedAmount-euint64-) -- [finalizeDiscloseEncryptedAmount(requestId, amount, signatures)](#ConfidentialFungibleToken-finalizeDiscloseEncryptedAmount-uint256-uint64-bytes---) -- [_setOperator(holder, operator, until)](#ConfidentialFungibleToken-_setOperator-address-address-uint48-) -- [_mint(to, amount)](#ConfidentialFungibleToken-_mint-address-euint64-) -- [_burn(from, amount)](#ConfidentialFungibleToken-_burn-address-euint64-) -- [_transfer(from, to, amount)](#ConfidentialFungibleToken-_transfer-address-address-euint64-) -- [_transferAndCall(from, to, amount, data)](#ConfidentialFungibleToken-_transferAndCall-address-address-euint64-bytes-) -#### IConfidentialFungibleToken [!toc] +#### ERC7984 [!toc] +- [supportsInterface(interfaceId)](#ERC7984-supportsInterface-bytes4-) +- [name()](#ERC7984-name--) +- [symbol()](#ERC7984-symbol--) +- [decimals()](#ERC7984-decimals--) +- [contractURI()](#ERC7984-contractURI--) +- [confidentialBalanceOf(account)](#ERC7984-confidentialBalanceOf-address-) +- [isOperator(holder, spender)](#ERC7984-isOperator-address-address-) +- [setOperator(operator, until)](#ERC7984-setOperator-address-uint48-) +- [confidentialTransfer(to, encryptedAmount, inputProof)](#ERC7984-confidentialTransfer-address-externalEuint64-bytes-) +- [confidentialTransfer(to, amount)](#ERC7984-confidentialTransfer-address-euint64-) +- [confidentialTransferFrom(from, to, encryptedAmount, inputProof)](#ERC7984-confidentialTransferFrom-address-address-externalEuint64-bytes-) +- [confidentialTransferFrom(from, to, amount)](#ERC7984-confidentialTransferFrom-address-address-euint64-) +- [confidentialTransferAndCall(to, encryptedAmount, inputProof, data)](#ERC7984-confidentialTransferAndCall-address-externalEuint64-bytes-bytes-) +- [confidentialTransferAndCall(to, amount, data)](#ERC7984-confidentialTransferAndCall-address-euint64-bytes-) +- [confidentialTransferFromAndCall(from, to, encryptedAmount, inputProof, data)](#ERC7984-confidentialTransferFromAndCall-address-address-externalEuint64-bytes-bytes-) +- [confidentialTransferFromAndCall(from, to, amount, data)](#ERC7984-confidentialTransferFromAndCall-address-address-euint64-bytes-) +- [requestDiscloseEncryptedAmount(encryptedAmount)](#ERC7984-requestDiscloseEncryptedAmount-euint64-) +- [discloseEncryptedAmount(encryptedAmount, cleartextAmount, decryptionProof)](#ERC7984-discloseEncryptedAmount-euint64-uint64-bytes-) +- [_setOperator(holder, operator, until)](#ERC7984-_setOperator-address-address-uint48-) +- [_mint(to, amount)](#ERC7984-_mint-address-euint64-) +- [_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]
@@ -1071,11 +2868,14 @@ account. #### IERC5267 [!toc] - [EIP712DomainChanged()](#IERC5267-EIP712DomainChanged--) #### Nonces [!toc] -#### ConfidentialFungibleToken [!toc] -#### IConfidentialFungibleToken [!toc] -- [OperatorSet(holder, operator, until)](#IConfidentialFungibleToken-OperatorSet-address-address-uint48-) -- [ConfidentialTransfer(from, to, amount)](#IConfidentialFungibleToken-ConfidentialTransfer-address-address-euint64-) -- [AmountDisclosed(encryptedAmount, amount)](#IConfidentialFungibleToken-AmountDisclosed-euint64-uint64-) +#### ERC7984 [!toc] +- [AmountDiscloseRequested(encryptedAmount, requester)](#ERC7984-AmountDiscloseRequested-euint64-address-) +#### ERC165 [!toc] +#### IERC7984 [!toc] +- [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]
@@ -1092,26 +2892,28 @@ account. #### IERC5267 [!toc] #### Nonces [!toc] - [InvalidAccountNonce(account, currentNonce)](#Nonces-InvalidAccountNonce-address-uint256-) -#### ConfidentialFungibleToken [!toc] -- [ConfidentialFungibleTokenInvalidReceiver(receiver)](#ConfidentialFungibleToken-ConfidentialFungibleTokenInvalidReceiver-address-) -- [ConfidentialFungibleTokenInvalidSender(sender)](#ConfidentialFungibleToken-ConfidentialFungibleTokenInvalidSender-address-) -- [ConfidentialFungibleTokenUnauthorizedSpender(holder, spender)](#ConfidentialFungibleToken-ConfidentialFungibleTokenUnauthorizedSpender-address-address-) -- [ConfidentialFungibleTokenZeroBalance(holder)](#ConfidentialFungibleToken-ConfidentialFungibleTokenZeroBalance-address-) -- [ConfidentialFungibleTokenUnauthorizedUseOfEncryptedAmount(amount, user)](#ConfidentialFungibleToken-ConfidentialFungibleTokenUnauthorizedUseOfEncryptedAmount-euint64-address-) -- [ConfidentialFungibleTokenUnauthorizedCaller(caller)](#ConfidentialFungibleToken-ConfidentialFungibleTokenUnauthorizedCaller-address-) -- [ConfidentialFungibleTokenInvalidGatewayRequest(requestId)](#ConfidentialFungibleToken-ConfidentialFungibleTokenInvalidGatewayRequest-uint256-) -#### IConfidentialFungibleToken [!toc] +#### ERC7984 [!toc] +- [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]
- +

confidentialTotalSupply() → euint64

public

-# +#
@@ -1121,14 +2923,14 @@ Returns the confidential total supply of the token.
- +

_update(address from, address to, euint64 amount) → euint64 transferred

internal

-# +#
@@ -1136,14 +2938,14 @@ Returns the confidential total supply of the token.
- +

_getVotingUnits(address account) → euint64

internal

-# +#
@@ -1151,50 +2953,51 @@ Returns the confidential total supply of the token.
- +
-## `ConfidentialFungibleTokenUtils` +## `ERC7984Utils` - +
```solidity -import "@openzeppelin/confidential-contracts/token/utils/ConfidentialFungibleTokenUtils.sol"; +import "@openzeppelin/confidential-contracts/token/ERC7984/utils/ERC7984Utils.sol"; ``` -Library that provides common [`ConfidentialFungibleToken`](#ConfidentialFungibleToken) utility functions. +Library that provides common [`ERC7984`](#ERC7984) utility functions.

Functions

-- [checkOnTransferReceived(operator, from, to, amount, data)](#ConfidentialFungibleTokenUtils-checkOnTransferReceived-address-address-address-euint64-bytes-) +- [checkOnTransferReceived(operator, from, to, amount, data)](#ERC7984Utils-checkOnTransferReceived-address-address-address-euint64-bytes-)
- +

checkOnTransferReceived(address operator, address from, address to, euint64 amount, bytes data) → ebool

internal

-# +#
Performs a transfer callback to the recipient of the transfer `to`. Should be invoked -after all transfers "withCallback" on a [`ConfidentialFungibleToken`](#ConfidentialFungibleToken). +after all transfers "withCallback" on a [`ERC7984`](#ERC7984). The transfer callback is not invoked on the recipient if the recipient has no code (i.e. is an EOA). If the recipient has non-zero code, it must implement -[`IConfidentialFungibleTokenReceiver.onConfidentialTransferReceived`](./interfaces#IConfidentialFungibleTokenReceiver-onConfidentialTransferReceived-address-address-euint64-bytes-) and return an `ebool` indicating -whether the transfer was accepted or not. If the `ebool` is `false`, the transfer will be reversed. +[`IERC7984Receiver.onConfidentialTransferReceived`](/confidential-contracts/api/interfaces#IERC7984Receiver-onConfidentialTransferReceived-address-address-euint64-bytes-) and return an `ebool` indicating +whether the transfer was accepted or not. If the `ebool` is `false`, the transfer function +should try to refund the `from` address.
diff --git a/content/confidential-contracts/api/utils.mdx b/content/confidential-contracts/api/utils.mdx index 600364e3..05cb49e4 100644 --- a/content/confidential-contracts/api/utils.mdx +++ b/content/confidential-contracts/api/utils.mdx @@ -26,7 +26,7 @@ Miscellaneous contracts and libraries containing utility functions you can use t ## `FHESafeMath` - + @@ -39,11 +39,18 @@ import "@openzeppelin/confidential-contracts/utils/FHESafeMath.sol"; Library providing safe arithmetic operations for encrypted values 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. + +

Functions

- [tryIncrease(oldValue, delta)](#FHESafeMath-tryIncrease-euint64-euint64-) - [tryDecrease(oldValue, delta)](#FHESafeMath-tryDecrease-euint64-euint64-) +- [tryAdd(a, b)](#FHESafeMath-tryAdd-euint64-euint64-) +- [trySub(a, b)](#FHESafeMath-trySub-euint64-euint64-)
@@ -85,13 +92,49 @@ and `updated` will be the original value. + + +
+
+

tryAdd(euint64 a, euint64 b) → ebool success, euint64 res

+
+

internal

+# +
+
+
+ +Try to add `a` and `b`. If the operation is successful, `success` will be true and `res` +will be the sum of `a` and `b`. Otherwise, `success` will be false, and `res` will be 0. + +
+
+ + + +
+
+

trySub(euint64 a, euint64 b) → ebool success, euint64 res

+
+

internal

+# +
+
+
+ +Try to subtract `b` from `a`. If the operation is successful, `success` will be true and `res` +will be `a - b`. Otherwise, `success` will be false, and `res` will be 0. + +
+
+
## `HandleAccessManager` - + @@ -156,7 +199,7 @@ Unimplemented function that must revert if the message sender is not allowed to ## `CheckpointsConfidential` - + @@ -504,7 +547,7 @@ Returns checkpoint at given position. ## `Checkpoints` - + @@ -515,7 +558,7 @@ import "@openzeppelin/confidential-contracts/utils/structs/temporary-Checkpoints ``` This library defines the `Trace*` struct, for checkpointing values as they change at different points in -time, and later looking up past values by block number. See [`VotesConfidential`](./governance#VotesConfidential) as an example. +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. diff --git a/examples/SwapERC7984ToERC20.sol b/examples/SwapERC7984ToERC20.sol index 920dc710..09d7fd38 100644 --- a/examples/SwapERC7984ToERC20.sol +++ b/examples/SwapERC7984ToERC20.sol @@ -1,15 +1,15 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.24; +pragma solidity ^0.8.27; import {FHE, externalEuint64, euint64} from "@fhevm/solidity/lib/FHE.sol"; import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {IERC7984} from "@openzeppelin/confidential-contracts/interfaces/IERC7984.sol"; -contract SwapConfidentialToERC20 { - error SwapConfidentialToERC20InvalidGatewayRequest(uint256 requestId); +contract SwapERC7984ToERC20 { + error SwapERC7984ToERC20InvalidFinalization(euint64 amount); - mapping(uint256 requestId => address) private _receivers; + mapping(euint64 amount => address) private _receivers; IERC7984 private _fromToken; IERC20 private _toToken; @@ -23,22 +23,21 @@ contract SwapConfidentialToERC20 { FHE.allowTransient(amount, address(_fromToken)); euint64 amountTransferred = _fromToken.confidentialTransferFrom(msg.sender, address(this), amount); - bytes32[] memory cts = new bytes32[](1); - cts[0] = euint64.unwrap(amountTransferred); - uint256 requestID = FHE.requestDecryption(cts, this.finalizeSwap.selector); - - // register who is getting the tokens - _receivers[requestID] = msg.sender; + FHE.makePubliclyDecryptable(amountTransferred); + _receivers[amountTransferred] = msg.sender; } - function finalizeSwap(uint256 requestID, uint64 amount, bytes[] memory signatures) public virtual { - FHE.checkSignatures(requestID, signatures); - address to = _receivers[requestID]; - require(to != address(0), SwapConfidentialToERC20InvalidGatewayRequest(requestID)); - delete _receivers[requestID]; + function finalizeSwap(euint64 amount, uint64 cleartextAmount, bytes calldata decryptionProof) public virtual { + bytes32[] memory handles = new bytes32[](1); + handles[0] = euint64.unwrap(amount); + + FHE.checkSignatures(handles, abi.encode(cleartextAmount), decryptionProof); + address to = _receivers[amount]; + require(to != address(0), SwapERC7984ToERC20InvalidFinalization(amount)); + delete _receivers[amount]; - if (amount != 0) { - SafeERC20.safeTransfer(_toToken, to, amount); + if (cleartextAmount != 0) { + SafeERC20.safeTransfer(_toToken, to, cleartextAmount); } } }