Tokens
| This document is better viewed at https://docs.openzeppelin.com/confidential-contracts/api/token |
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.
-
ERC7984ERC20Wrapper: Extension ofERC7984which wraps anERC20into a confidential token. The wrapper allows for free conversion in both directions at a fixed rate. -
ERC7984Freezable: An extension ofERC7984, which allows accounts granted the "freezer" role to freeze and unfreeze tokens. -
ERC7984ObserverAccess: An extension ofERC7984, which allows each account to add an observer who is given access to their transfer and balance amounts. -
ERC7984Restricted: An extension ofERC7984that implements user account transfer restrictions. -
ERC7984Omnibus: An extension ofERC7984that emits additional events for omnibus transfers, which contain encrypted addresses for the sub-account sender and recipient. -
ERC7984Rwa: Extension ofERC7984that supports confidential Real World Assets (RWAs) by providing compliance checks, transfer controls and enforcement actions. -
ERC7984Votes: An extension ofERC7984that supports confidential vote tracking and delegation viaVotesConfidential. -
ERC7984Hooked: An extension ofERC7984that calls pre and post transfer hooks on installed modules. -
ERC7984Utils: A library that provides the on-transfer callback check used byERC7984. -
ERC7984HookModule: A an abstract, base implementation for hook modules compatible withERC7984Hooked. -
ERC7984BalanceCapHookModule: An example hook module forERC7984Hookedthat enforces a per-account encrypted balance cap. -
ERC7984HolderCapHookModule: An example hook module forERC7984Hookedthat enforces a maximum number of holders. Must be installed before any tokens are minted.
Core
ERC7984
import "@openzeppelin/confidential-contracts/token/ERC7984/ERC7984.sol";
Reference implementation for 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)
that can only be decrypted by authorized parties.
Key features:
-
All balances are encrypted
-
Transfers happen without revealing amounts
-
Support for operators (delegated transfer capabilities with time bounds)
-
Transfer and call pattern
-
Safe overflow/underflow handling for FHE operations
-
constructor(name_, symbol_, contractURI_) -
supportsInterface(interfaceId) -
name() -
symbol() -
decimals() -
contractURI() -
confidentialTotalSupply() -
confidentialBalanceOf(account) -
isOperator(holder, spender) -
setOperator(operator, until) -
confidentialTransfer(to, encryptedAmount, inputProof) -
confidentialTransfer(to, amount) -
confidentialTransferFrom(from, to, encryptedAmount, inputProof) -
confidentialTransferFrom(from, to, amount) -
confidentialTransferAndCall(to, encryptedAmount, inputProof, data) -
confidentialTransferAndCall(to, amount, data) -
confidentialTransferFromAndCall(from, to, encryptedAmount, inputProof, data) -
confidentialTransferFromAndCall(from, to, amount, data) -
requestDiscloseEncryptedAmount(encryptedAmount) -
discloseEncryptedAmount(encryptedAmount, cleartextAmount, decryptionProof) -
_setOperator(holder, operator, until) -
_mint(to, amount) -
_burn(from, amount) -
_transfer(from, to, amount) -
_transferAndCall(from, to, amount, data) -
_update(from, to, amount)
-
AmountDiscloseRequested(encryptedAmount, requester)
-
OperatorSet(holder, operator, until) -
ConfidentialTransfer(from, to, amount) -
AmountDisclosed(encryptedAmount, amount)
-
ERC7984InvalidReceiver(receiver) -
ERC7984InvalidSender(sender) -
ERC7984UnauthorizedSpender(holder, spender) -
ERC7984UnauthorizedUseOfEncryptedAmount(amount, user) -
ERC7984UnauthorizedCaller(caller)
supportsInterface(bytes4 interfaceId) → bool public
Returns true if this contract implements the interface defined by
interfaceId. See the corresponding
ERC section
to learn more about how these ids are created.
This function call must use less than 30 000 gas.
contractURI() → string public
Returns the contract URI. See ERC-7572 for details.
confidentialBalanceOf(address account) → euint64 public
Returns the confidential balance of the account account.
isOperator(address holder, address spender) → bool public
Returns true if spender is currently an operator for holder.
setOperator(address operator, uint48 until) public
See IERC7984.setOperator. Operators are given ACL allowance (ability to decrypt) for the transferred amount
of transfers they initiate.
confidentialTransfer(address to, externalEuint64 encryptedAmount, bytes inputProof) → euint64 public
Transfers the encrypted amount encryptedAmount to to with the given input proof inputProof.
Returns the encrypted amount that was actually transferred.
confidentialTransfer(address to, euint64 amount) → euint64 public
Similar to confidentialTransfer 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 public
Transfers the encrypted amount encryptedAmount from from to to with the given input proof
inputProof. msg.sender must be either from or an operator for from.
Returns the encrypted amount that was actually transferred.
confidentialTransferFrom(address from, address to, euint64 amount) → euint64 public
Similar to confidentialTransferFrom 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 public
Similar to confidentialTransfer but with a callback to to after
the transfer.
The callback is made to the IERC7984Receiver.onConfidentialTransferReceived 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 public
Similar to confidentialTransfer but with a callback to to after the transfer.
confidentialTransferFromAndCall(address from, address to, externalEuint64 encryptedAmount, bytes inputProof, bytes data) → euint64 public
Similar to confidentialTransferFrom but with a callback to to
after the transfer.
confidentialTransferFromAndCall(address from, address to, euint64 amount, bytes data) → euint64 public
Similar to confidentialTransferFrom but with a callback to to
after the transfer.
requestDiscloseEncryptedAmount(euint64 encryptedAmount) public
Starts the process to disclose an encrypted amount encryptedAmount publicly by making it
publicly decryptable. Emits the AmountDiscloseRequested event.
Both msg.sender and address(this) must have permission to access the encrypted amount
encryptedAmount to request disclosure of the encrypted amount encryptedAmount.
|
discloseEncryptedAmount(euint64 encryptedAmount, uint64 cleartextAmount, bytes decryptionProof) public
Publicly discloses an encrypted value with a given decryption proof. Emits the {AmountDisclosed} event.
May not be tied to a prior request via requestDiscloseEncryptedAmount.
|
_transferAndCall(address from, address to, euint64 amount, bytes data) → euint64 transferred internal
Transfers the given amount of tokens from from to to and calls the onConfidentialTransferReceived
function on the recipient.
The token contract initiates a second transfer refunding the tokens from the recipient to the sender—the amount is 0 if the callback succeeds, otherwise the amount is the amount that was transferred.
The returned transferred amount is a fresh ciphertext computed as sent - refund
and msg.sender only receives a transient FHE allowance for it. This value is generally
intended to be processed only in the same transaction. Event observers see sent and refund individually.
The refund triggered when IERC7984Receiver.onConfidentialTransferReceived returns an encrypted
false is best-effort only. A receiver that transfers, burns, or otherwise reduces its balance during
the hook can still return false, in which case the refund transfers zero tokens. The sender’s tokens
end up with the recipient rather than being refunded.
|
Refunds are subject to the same validation flow as a normal transfer—they may fail for a variety of
reasons (such as failed hook validation in ERC7984Hooked). In these cases, the tokens do not return to the sender.
|
_update(address from, address to, euint64 amount) → euint64 transferred internal
Safely moves up to amount from from to to, or mints/burns if from/to is the zero address.
Emits a confidentialTransfer event with the successfully transferred amount.
AmountDiscloseRequested(euint64 indexed encryptedAmount, address indexed requester) event
Emitted when an encrypted amount encryptedAmount is requested for disclosure by requester.
ERC7984InvalidReceiver(address receiver) error
The given receiver receiver is invalid for transfers.
ERC7984UnauthorizedSpender(address holder, address spender) error
The given holder holder is not authorized to spend on behalf of spender.
Extensions
ERC7984ERC20Wrapper
import "@openzeppelin/confidential-contracts/token/ERC7984/extensions/ERC7984ERC20Wrapper.sol";
A wrapper contract built on top of 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.
| Minting assumes the full amount of the underlying token transfer has been received, hence some non-standard tokens such as fee-on-transfer or other deflationary-type tokens are not supported by this wrapper. |
-
constructor(underlying_) -
onTransferReceived(, from, amount, data) -
wrap(to, amount) -
unwrap(from, to, amount) -
unwrap(from, to, encryptedAmount, inputProof) -
finalizeUnwrap(unwrapRequestId, unwrapAmountCleartext, decryptionProof) -
decimals() -
rate() -
underlying() -
unwrapAmount(unwrapRequestId) -
supportsInterface(interfaceId) -
inferredTotalSupply() -
maxTotalSupply() -
unwrapRequester(unwrapRequestId) -
_checkConfidentialTotalSupply() -
_update(from, to, amount) -
_unwrap(from, to, amount) -
_fallbackUnderlyingDecimals() -
_maxDecimals()
-
name() -
symbol() -
contractURI() -
confidentialTotalSupply() -
confidentialBalanceOf(account) -
isOperator(holder, spender) -
setOperator(operator, until) -
confidentialTransfer(to, encryptedAmount, inputProof) -
confidentialTransfer(to, amount) -
confidentialTransferFrom(from, to, encryptedAmount, inputProof) -
confidentialTransferFrom(from, to, amount) -
confidentialTransferAndCall(to, encryptedAmount, inputProof, data) -
confidentialTransferAndCall(to, amount, data) -
confidentialTransferFromAndCall(from, to, encryptedAmount, inputProof, data) -
confidentialTransferFromAndCall(from, to, amount, data) -
requestDiscloseEncryptedAmount(encryptedAmount) -
discloseEncryptedAmount(encryptedAmount, cleartextAmount, decryptionProof) -
_setOperator(holder, operator, until) -
_mint(to, amount) -
_burn(from, amount) -
_transfer(from, to, amount) -
_transferAndCall(from, to, amount, data)
-
UnwrapRequested(receiver, unwrapRequestId, amount) -
UnwrapFinalized(receiver, unwrapRequestId, encryptedAmount, cleartextAmount)
-
AmountDiscloseRequested(encryptedAmount, requester)
-
OperatorSet(holder, operator, until) -
ConfidentialTransfer(from, to, amount) -
AmountDisclosed(encryptedAmount, amount)
-
InvalidUnwrapRequest(unwrapRequestId) -
ERC7984TotalSupplyOverflow()
-
ERC7984InvalidReceiver(receiver) -
ERC7984InvalidSender(sender) -
ERC7984UnauthorizedSpender(holder, spender) -
ERC7984UnauthorizedUseOfEncryptedAmount(amount, user) -
ERC7984UnauthorizedCaller(caller)
wrap(address to, uint256 amount) → euint64 public
See IERC7984ERC20Wrapper.wrap. Tokens are exchanged at a fixed rate specified by rate such that
amount / rate() confidential tokens are sent. The amount transferred in is rounded down to the nearest
multiple of rate.
Returns the amount of wrapped token sent.
unwrap(address from, address to, euint64 amount) → bytes32 public
Unwrap without passing an input proof. See {unwrap-address-address-bytes32-bytes} for more details.
unwrap(address from, address to, externalEuint64 encryptedAmount, bytes inputProof) → bytes32 public
See IERC7984ERC20Wrapper.unwrap. amount * rate() underlying tokens are sent to to.
The unwrap request created by this function must be finalized by calling finalizeUnwrap.
|
finalizeUnwrap(bytes32 unwrapRequestId, uint64 unwrapAmountCleartext, bytes decryptionProof) public
Finalizes an unwrap request identified by unwrapRequestId with the given unwrapAmountCleartext and decryptionProof.
rate() → uint256 public
Returns the rate at which the underlying token is converted to the wrapped token.
For example, if the rate is 1000, then 1000 units of the underlying token equal 1 unit of the wrapped token.
underlying() → address public
Returns the address of the underlying ERC-20 token that is being wrapped.
unwrapAmount(bytes32 unwrapRequestId) → euint64 public
Returns the amount of wrapper tokens that were unwrapped for a given unwrapRequestId.
supportsInterface(bytes4 interfaceId) → bool public
Returns true if this contract implements the interface defined by
interfaceId. See the corresponding
ERC section
to learn more about how these ids are created.
This function call must use less than 30 000 gas.
inferredTotalSupply() → uint256 public
Returns the underlying balance divided by the rate, a value greater or equal to the actual
confidentialTotalSupply.
The return value of this function can be inflated by directly sending underlying tokens to the wrapper contract.
Reductions will lag compared to confidentialTotalSupply since it is updated on unwrap while this function updates
on finalizeUnwrap.
|
maxTotalSupply() → uint256 public
Returns the maximum total supply of wrapped tokens supported by the encrypted datatype.
unwrapRequester(bytes32 unwrapRequestId) → address public
Gets the address that will receive the ERC-20 tokens associated with a pending unwrap request identified by
unwrapRequestId. Returns address(0) if there is no pending unwrap request with id unwrapRequestId.
_checkConfidentialTotalSupply() internal
This function must revert if the new confidentialTotalSupply is invalid (overflow occurred).
Overflow can be detected here since the wrapper holdings are non-confidential. In other cases, it may be impossible
to infer total supply overflow synchronously. This function may revert even if the confidentialTotalSupply did
not overflow.
|
_update(address from, address to, euint64 amount) → euint64 internal
Safely moves up to amount from from to to, or mints/burns if from/to is the zero address.
Emits a confidentialTransfer event with the successfully transferred amount.
_unwrap(address from, address to, euint64 amount) → bytes32 internal
Internal logic for handling the creation of unwrap requests. Returns the unwrap request id.
_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 {_tryGetAssetDecimals} fails to fetch decimals of the underlying ERC-20 token.
_maxDecimals() → uint8 internal
Returns the maximum number that will be used for decimals by the wrapper.
ERC7984Freezable
import "@openzeppelin/confidential-contracts/token/ERC7984/extensions/ERC7984Freezable.sol";
Extension of ERC7984 that implements a confidential
freezing mechanism that can be managed by calling the internal function
_setConfidentialFrozen by an inheriting contract.
The freezing mechanism provides the guarantee that a specific confidential amount of tokens held by an account won’t be transferable until those tokens are unfrozen.
-
confidentialFrozen(account) -
confidentialAvailable(account) -
_confidentialAvailable(account) -
_setConfidentialFrozen(account, encryptedAmount) -
_update(from, to, encryptedAmount)
-
supportsInterface(interfaceId) -
name() -
symbol() -
decimals() -
contractURI() -
confidentialTotalSupply() -
confidentialBalanceOf(account) -
isOperator(holder, spender) -
setOperator(operator, until) -
confidentialTransfer(to, encryptedAmount, inputProof) -
confidentialTransfer(to, amount) -
confidentialTransferFrom(from, to, encryptedAmount, inputProof) -
confidentialTransferFrom(from, to, amount) -
confidentialTransferAndCall(to, encryptedAmount, inputProof, data) -
confidentialTransferAndCall(to, amount, data) -
confidentialTransferFromAndCall(from, to, encryptedAmount, inputProof, data) -
confidentialTransferFromAndCall(from, to, amount, data) -
requestDiscloseEncryptedAmount(encryptedAmount) -
discloseEncryptedAmount(encryptedAmount, cleartextAmount, decryptionProof) -
_setOperator(holder, operator, until) -
_mint(to, amount) -
_burn(from, amount) -
_transfer(from, to, amount) -
_transferAndCall(from, to, amount, data)
-
TokensFrozen(account, encryptedAmount)
-
AmountDiscloseRequested(encryptedAmount, requester)
-
OperatorSet(holder, operator, until) -
ConfidentialTransfer(from, to, amount) -
AmountDisclosed(encryptedAmount, amount)
-
ERC7984InvalidReceiver(receiver) -
ERC7984InvalidSender(sender) -
ERC7984UnauthorizedSpender(holder, spender) -
ERC7984UnauthorizedUseOfEncryptedAmount(amount, user) -
ERC7984UnauthorizedCaller(caller)
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.
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
_confidentialAvailable. The internal function is used for actual gating (not the public function)
to avoid unnecessarily granting ACL allowances.
ERC7984ObserverAccess
import "@openzeppelin/confidential-contracts/token/ERC7984/extensions/ERC7984ObserverAccess.sol";
Extension of ERC7984 that allows each account to add an observer who is given
permanent ACL access to its transfer and balance amounts. An observer can be added or removed at any point in time.
-
setObserver(account, newObserver) -
observer(account) -
_update(from, to, amount)
-
supportsInterface(interfaceId) -
name() -
symbol() -
decimals() -
contractURI() -
confidentialTotalSupply() -
confidentialBalanceOf(account) -
isOperator(holder, spender) -
setOperator(operator, until) -
confidentialTransfer(to, encryptedAmount, inputProof) -
confidentialTransfer(to, amount) -
confidentialTransferFrom(from, to, encryptedAmount, inputProof) -
confidentialTransferFrom(from, to, amount) -
confidentialTransferAndCall(to, encryptedAmount, inputProof, data) -
confidentialTransferAndCall(to, amount, data) -
confidentialTransferFromAndCall(from, to, encryptedAmount, inputProof, data) -
confidentialTransferFromAndCall(from, to, amount, data) -
requestDiscloseEncryptedAmount(encryptedAmount) -
discloseEncryptedAmount(encryptedAmount, cleartextAmount, decryptionProof) -
_setOperator(holder, operator, until) -
_mint(to, amount) -
_burn(from, amount) -
_transfer(from, to, amount) -
_transferAndCall(from, to, amount, data)
-
ERC7984ObserverAccessObserverSet(account, oldObserver, newObserver)
-
AmountDiscloseRequested(encryptedAmount, requester)
-
OperatorSet(holder, operator, until) -
ConfidentialTransfer(from, to, amount) -
AmountDisclosed(encryptedAmount, amount)
-
Unauthorized()
-
ERC7984InvalidReceiver(receiver) -
ERC7984InvalidSender(sender) -
ERC7984UnauthorizedSpender(holder, spender) -
ERC7984UnauthorizedUseOfEncryptedAmount(amount, user) -
ERC7984UnauthorizedCaller(caller)
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)).
_update(address from, address to, euint64 amount) → euint64 transferred internal
Safely moves up to amount from from to to, or mints/burns if from/to is the zero address.
Emits a confidentialTransfer event with the successfully transferred amount.
ERC7984Restricted
import "@openzeppelin/confidential-contracts/token/ERC7984/extensions/ERC7984Restricted.sol";
Extension of ERC7984 that implements user account transfer restrictions through the
canTransact 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 canTransact function acts as
a blocklist. Developers can override canTransact to check that restriction == ALLOWED
to implement an allowlist.
-
getRestriction(account) -
canTransact(account) -
_update(from, to, value) -
_setRestriction(account, restriction) -
_blockUser(account) -
_allowUser(account) -
_resetUser(account) -
_checkRestriction(account) -
_checkSenderRestriction(account) -
_checkRecipientRestriction(account)
-
supportsInterface(interfaceId) -
name() -
symbol() -
decimals() -
contractURI() -
confidentialTotalSupply() -
confidentialBalanceOf(account) -
isOperator(holder, spender) -
setOperator(operator, until) -
confidentialTransfer(to, encryptedAmount, inputProof) -
confidentialTransfer(to, amount) -
confidentialTransferFrom(from, to, encryptedAmount, inputProof) -
confidentialTransferFrom(from, to, amount) -
confidentialTransferAndCall(to, encryptedAmount, inputProof, data) -
confidentialTransferAndCall(to, amount, data) -
confidentialTransferFromAndCall(from, to, encryptedAmount, inputProof, data) -
confidentialTransferFromAndCall(from, to, amount, data) -
requestDiscloseEncryptedAmount(encryptedAmount) -
discloseEncryptedAmount(encryptedAmount, cleartextAmount, decryptionProof) -
_setOperator(holder, operator, until) -
_mint(to, amount) -
_burn(from, amount) -
_transfer(from, to, amount) -
_transferAndCall(from, to, amount, data)
-
UserRestrictionUpdated(account, restriction)
-
AmountDiscloseRequested(encryptedAmount, requester)
-
OperatorSet(holder, operator, until) -
ConfidentialTransfer(from, to, amount) -
AmountDisclosed(encryptedAmount, amount)
-
UserRestricted(account)
-
ERC7984InvalidReceiver(receiver) -
ERC7984InvalidSender(sender) -
ERC7984UnauthorizedSpender(holder, spender) -
ERC7984UnauthorizedUseOfEncryptedAmount(amount, user) -
ERC7984UnauthorizedCaller(caller)
getRestriction(address account) → enum ERC7984Restricted.Restriction public
Returns the restriction of a user account.
canTransact(address account) → bool public
Returns whether a user account is allowed to receive or send tokens.
Default implementation only disallows explicitly BLOCKED accounts (i.e. a blocklist).
_update(address from, address to, euint64 value) → euint64 internal
See ERC7984._update. Enforces transfer restrictions.
Requirements:
-
frommust be allowed to transfer tokens (seecanTransact). -
tomust be allowed to receive tokens (seecanTransact).
The default restriction behavior can be changed (for a pass-through for instance) by overriding
_checkSenderRestriction and/or _checkRecipientRestriction.
_setRestriction(address account, enum ERC7984Restricted.Restriction restriction) internal
Updates the restriction of a user account.
_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 UserRestricted if so.
_checkSenderRestriction(address account) internal
Internal function which checks restriction of the from account before a transfer.
Working with _update function.
_checkRecipientRestriction(address account) internal
Internal function which checks restriction of the to account before a transfer.
Working with _update function.
ERC7984Omnibus
import "@openzeppelin/confidential-contracts/token/ERC7984/extensions/ERC7984Omnibus.sol";
Extension of 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. |
-
confidentialTransferOmnibus(omnibusTo, externalSender, externalRecipient, externalAmount, inputProof) -
confidentialTransferOmnibus(omnibusTo, sender, recipient, amount) -
confidentialTransferFromOmnibus(omnibusFrom, omnibusTo, externalSender, externalRecipient, externalAmount, inputProof) -
confidentialTransferFromOmnibus(omnibusFrom, omnibusTo, sender, recipient, amount) -
confidentialTransferAndCallOmnibus(omnibusTo, externalSender, externalRecipient, externalAmount, inputProof, data) -
confidentialTransferAndCallOmnibus(omnibusTo, sender, recipient, amount, data) -
confidentialTransferFromAndCallOmnibus(omnibusFrom, omnibusTo, externalSender, externalRecipient, externalAmount, inputProof, data) -
confidentialTransferFromAndCallOmnibus(omnibusFrom, omnibusTo, sender, recipient, amount, data) -
_confidentialTransferFromOmnibus(omnibusFrom, omnibusTo, sender, recipient, amount) -
_confidentialTransferFromAndCallOmnibus(omnibusFrom, omnibusTo, sender, recipient, amount, data)
-
supportsInterface(interfaceId) -
name() -
symbol() -
decimals() -
contractURI() -
confidentialTotalSupply() -
confidentialBalanceOf(account) -
isOperator(holder, spender) -
setOperator(operator, until) -
confidentialTransfer(to, encryptedAmount, inputProof) -
confidentialTransfer(to, amount) -
confidentialTransferFrom(from, to, encryptedAmount, inputProof) -
confidentialTransferFrom(from, to, amount) -
confidentialTransferAndCall(to, encryptedAmount, inputProof, data) -
confidentialTransferAndCall(to, amount, data) -
confidentialTransferFromAndCall(from, to, encryptedAmount, inputProof, data) -
confidentialTransferFromAndCall(from, to, amount, data) -
requestDiscloseEncryptedAmount(encryptedAmount) -
discloseEncryptedAmount(encryptedAmount, cleartextAmount, decryptionProof) -
_setOperator(holder, operator, until) -
_mint(to, amount) -
_burn(from, amount) -
_transfer(from, to, amount) -
_transferAndCall(from, to, amount, data) -
_update(from, to, amount)
-
OmnibusConfidentialTransfer(omnibusFrom, omnibusTo, sender, recipient, amount)
-
AmountDiscloseRequested(encryptedAmount, requester)
-
OperatorSet(holder, operator, until) -
ConfidentialTransfer(from, to, amount) -
AmountDisclosed(encryptedAmount, amount)
-
ERC7984UnauthorizedUseOfEncryptedAddress(addr, user)
-
ERC7984InvalidReceiver(receiver) -
ERC7984InvalidSender(sender) -
ERC7984UnauthorizedSpender(holder, spender) -
ERC7984UnauthorizedUseOfEncryptedAmount(amount, user) -
ERC7984UnauthorizedCaller(caller)
confidentialTransferOmnibus(address omnibusTo, externalEaddress externalSender, externalEaddress externalRecipient, externalEuint64 externalAmount, bytes inputProof) → euint64 public
Wraps the confidentialTransfer function and emits the OmnibusConfidentialTransfer event.
confidentialTransferOmnibus(address omnibusTo, eaddress sender, eaddress recipient, euint64 amount) → euint64 public
Wraps the confidentialTransfer function and emits the OmnibusConfidentialTransfer event.
confidentialTransferFromOmnibus(address omnibusFrom, address omnibusTo, externalEaddress externalSender, externalEaddress externalRecipient, externalEuint64 externalAmount, bytes inputProof) → euint64 public
Wraps the confidentialTransferFrom function and emits the OmnibusConfidentialTransfer event.
confidentialTransferFromOmnibus(address omnibusFrom, address omnibusTo, eaddress sender, eaddress recipient, euint64 amount) → euint64 public
Wraps the confidentialTransferFrom function and emits the OmnibusConfidentialTransfer event.
confidentialTransferAndCallOmnibus(address omnibusTo, externalEaddress externalSender, externalEaddress externalRecipient, externalEuint64 externalAmount, bytes inputProof, bytes data) → euint64 public
Wraps the confidentialTransferAndCall function and emits the OmnibusConfidentialTransfer event.
confidentialTransferAndCallOmnibus(address omnibusTo, eaddress sender, eaddress recipient, euint64 amount, bytes data) → euint64 public
Wraps the confidentialTransferAndCall function and emits the OmnibusConfidentialTransfer event.
confidentialTransferFromAndCallOmnibus(address omnibusFrom, address omnibusTo, externalEaddress externalSender, externalEaddress externalRecipient, externalEuint64 externalAmount, bytes inputProof, bytes data) → euint64 public
Wraps the confidentialTransferFromAndCall function and emits the OmnibusConfidentialTransfer event.
confidentialTransferFromAndCallOmnibus(address omnibusFrom, address omnibusTo, eaddress sender, eaddress recipient, euint64 amount, bytes data) → euint64 public
Wraps the confidentialTransferFromAndCall function and emits the OmnibusConfidentialTransfer 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 OmnibusConfidentialTransfer.
_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 OmnibusConfidentialTransfer.
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 event.
omnibusFrom and omnibusTo get permanent ACL allowances for sender and recipient.
|
ERC7984Rwa
import "@openzeppelin/confidential-contracts/token/ERC7984/extensions/ERC7984Rwa.sol";
Extension of ERC7984 that supports confidential Real World Assets (RWAs).
This interface provides compliance checks, transfer controls and enforcement actions.
-
onlyAdmin() -
onlyAgent()
-
constructor(admin) -
supportsInterface(interfaceId) -
isAdmin(account) -
isAgent(account) -
addAgent(account) -
removeAgent(account) -
pause() -
unpause() -
blockUser(account) -
unblockUser(account) -
setConfidentialFrozen(account, encryptedAmount, inputProof) -
setConfidentialFrozen(account, encryptedAmount) -
confidentialMint(to, encryptedAmount, inputProof) -
confidentialMint(to, encryptedAmount) -
confidentialBurn(account, encryptedAmount, inputProof) -
confidentialBurn(account, encryptedAmount) -
recoverAddress(lostAccount, newAccount) -
forceConfidentialTransferFrom(from, to, encryptedAmount, inputProof) -
forceConfidentialTransferFrom(from, to, encryptedAmount) -
confidentialAvailable(account) -
confidentialFrozen(account) -
paused() -
canTransact(account) -
_update(from, to, encryptedAmount) -
_checkSenderRestriction(account) -
_checkRecipientRestriction(account) -
_requireNotPaused() -
_isForceTransfer(selector) -
_msgSender() -
_msgData() -
AGENT_ROLE()
-
hasRole(role, account) -
_checkRole(role) -
_checkRole(role, account) -
getRoleAdmin(role) -
grantRole(role, account) -
revokeRole(role, account) -
renounceRole(role, callerConfirmation) -
_setRoleAdmin(role, adminRole) -
_grantRole(role, account) -
_revokeRole(role, account) -
DEFAULT_ADMIN_ROLE()
-
multicall(data)
-
_requirePaused() -
_pause() -
_unpause()
-
getRestriction(account) -
_setRestriction(account, restriction) -
_blockUser(account) -
_allowUser(account) -
_resetUser(account) -
_checkRestriction(account)
-
_confidentialAvailable(account) -
_setConfidentialFrozen(account, encryptedAmount)
-
name() -
symbol() -
decimals() -
contractURI() -
confidentialTotalSupply() -
confidentialBalanceOf(account) -
isOperator(holder, spender) -
setOperator(operator, until) -
confidentialTransfer(to, encryptedAmount, inputProof) -
confidentialTransfer(to, amount) -
confidentialTransferFrom(from, to, encryptedAmount, inputProof) -
confidentialTransferFrom(from, to, amount) -
confidentialTransferAndCall(to, encryptedAmount, inputProof, data) -
confidentialTransferAndCall(to, amount, data) -
confidentialTransferFromAndCall(from, to, encryptedAmount, inputProof, data) -
confidentialTransferFromAndCall(from, to, amount, data) -
requestDiscloseEncryptedAmount(encryptedAmount) -
discloseEncryptedAmount(encryptedAmount, cleartextAmount, decryptionProof) -
_setOperator(holder, operator, until) -
_mint(to, amount) -
_burn(from, amount) -
_transfer(from, to, amount) -
_transferAndCall(from, to, amount, data)
-
Paused(account) -
Unpaused(account)
-
UserRestrictionUpdated(account, restriction)
-
TokensFrozen(account, encryptedAmount)
-
AmountDiscloseRequested(encryptedAmount, requester)
-
TokensRecovered(lostAccount, newAccount, amount)
-
OperatorSet(holder, operator, until) -
ConfidentialTransfer(from, to, amount) -
AmountDisclosed(encryptedAmount, amount)
-
RoleAdminChanged(role, previousAdminRole, newAdminRole) -
RoleGranted(role, account, sender) -
RoleRevoked(role, account, sender)
-
ERC7984RwaSelfRecoveryNotAllowed()
-
EnforcedPause() -
ExpectedPause()
-
UserRestricted(account)
-
ERC7984InvalidReceiver(receiver) -
ERC7984InvalidSender(sender) -
ERC7984UnauthorizedSpender(holder, spender) -
ERC7984UnauthorizedUseOfEncryptedAmount(amount, user) -
ERC7984UnauthorizedCaller(caller)
-
AccessControlUnauthorizedAccount(account, neededRole) -
AccessControlBadConfirmation()
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.
recoverAddress(address lostAccount, address newAccount) → euint64 public
Recovers the address of a lost account to a new account.
forceConfidentialTransferFrom(address from, address to, externalEuint64 encryptedAmount, bytes inputProof) → euint64 public
Variant of forceConfidentialTransferFrom with an input proof.
forceConfidentialTransferFrom(address from, address to, euint64 encryptedAmount) → euint64 public
Force transfer callable by the role AGENT_ROLE which transfers tokens from from to to and
bypasses the ERC7984Restricted (only on from) and 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.
canTransact(address account) → bool public
Returns whether a user account is allowed to receive or send tokens.
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.
_checkSenderRestriction(address account) internal
Bypasses ERC7984Restricted from restriction check when performing a forced transfer or token recovery.
_checkRecipientRestriction(address account) internal
Bypasses ERC7984Restricted to restriction check when performing a forced transfer or token recovery.
_requireNotPaused() internal
Bypasses {Pausable} check when performing a forceConfidentialTransferFrom.
_isForceTransfer(bytes4 selector) → bool internal
Internal function which checks if the current function call should be treated as a force transfer.
_msgSender() → address internal
Restrict overrides of {Context._msgSender}. Please use other account abstraction methods instead.
_msgData() → bytes internal
Restrict overrides of {Context._msgData}. Please use other account abstraction methods instead.
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.
ERC7984Votes
import "@openzeppelin/confidential-contracts/token/ERC7984/extensions/ERC7984Votes.sol";
Extension of ERC7984 supporting confidential votes tracking and delegation.
The amount of confidential voting units an account has is equal to the balance of that account. Voting power is taken into account when an account delegates votes to itself or to another account.
-
confidentialTotalSupply() -
_update(from, to, amount) -
_getVotingUnits(account)
-
clock() -
CLOCK_MODE() -
getVotes(account) -
getPastVotes(account, timepoint) -
getPastTotalSupply(timepoint) -
delegates(account) -
delegate(delegatee) -
delegateBySig(delegatee, nonce, expiry, v, r, s) -
_delegate(account, delegatee) -
_transferVotingUnits(from, to, amount) -
_moveDelegateVotes(from, to, amount) -
_validateTimepoint(timepoint)
-
getHandleAllowance(handle, account, persistent) -
_validateHandleAllowance()
-
_domainSeparatorV4() -
_hashTypedDataV4(structHash) -
eip712Domain() -
_EIP712Name() -
_EIP712Version()
-
nonces(owner) -
_useNonce(owner) -
_useCheckedNonce(owner, nonce)
-
supportsInterface(interfaceId) -
name() -
symbol() -
decimals() -
contractURI() -
confidentialBalanceOf(account) -
isOperator(holder, spender) -
setOperator(operator, until) -
confidentialTransfer(to, encryptedAmount, inputProof) -
confidentialTransfer(to, amount) -
confidentialTransferFrom(from, to, encryptedAmount, inputProof) -
confidentialTransferFrom(from, to, amount) -
confidentialTransferAndCall(to, encryptedAmount, inputProof, data) -
confidentialTransferAndCall(to, amount, data) -
confidentialTransferFromAndCall(from, to, encryptedAmount, inputProof, data) -
confidentialTransferFromAndCall(from, to, amount, data) -
requestDiscloseEncryptedAmount(encryptedAmount) -
discloseEncryptedAmount(encryptedAmount, cleartextAmount, decryptionProof) -
_setOperator(holder, operator, until) -
_mint(to, amount) -
_burn(from, amount) -
_transfer(from, to, amount) -
_transferAndCall(from, to, amount, data)
-
DelegateVotesChanged(delegate, previousVotes, newVotes) -
DelegateChanged(delegator, fromDelegate, toDelegate)
-
EIP712DomainChanged()
-
AmountDiscloseRequested(encryptedAmount, requester)
-
OperatorSet(holder, operator, until) -
ConfidentialTransfer(from, to, amount) -
AmountDisclosed(encryptedAmount, amount)
-
VotesExpiredSignature(expiry) -
ERC6372InconsistentClock() -
ERC5805FutureLookup(timepoint, clock)
-
HandleAccessManagerNotAllowed(handle, account)
-
InvalidAccountNonce(account, currentNonce)
-
ERC7984InvalidReceiver(receiver) -
ERC7984InvalidSender(sender) -
ERC7984UnauthorizedSpender(holder, spender) -
ERC7984UnauthorizedUseOfEncryptedAmount(amount, user) -
ERC7984UnauthorizedCaller(caller)
_update(address from, address to, euint64 amount) → euint64 transferred internal
Safely moves up to amount from from to to, or mints/burns if from/to is the zero address.
Emits a confidentialTransfer event with the successfully transferred amount.
ERC7984Hooked
import "@openzeppelin/confidential-contracts/token/ERC7984/extensions/ERC7984Hooked.sol";
Extension of ERC7984 that supports hook modules. Inspired by ERC-7579 modules.
Modules are called before and after transfers. Before the transfer, modules conduct checks to see if they approve the given transfer and return an encrypted boolean. If any module returns false, the transferred amount becomes 0. After the transfer, modules are notified of the final transfer amount and may do accounting as necessary. Modules may revert on either call, which will propagate and revert the entire transaction.
| Hook modules are trusted contracts—they have access to any private state the token has access to. This arbitrary ACL access allows hook modules to grant themselves (or any other address) allowance to view any handle the token has access to. ACL allowances granted by the hook module persist even after the module is uninstalled. |
-
onlyAuthorizedModuleChange()
-
isModuleInstalled(module) -
installModule(module, initData) -
uninstallModule(module) -
modules(start, end) -
maxModules() -
_authorizeModuleChange() -
_installModule(module, initData) -
_uninstallModule(module) -
_update(from, to, encryptedAmount) -
_runPreTransferHooks(from, to, encryptedAmount) -
_runPostTransferHooks(from, to, encryptedAmount) -
_validateHandleAllowance(handle)
-
getHandleAllowance(handle, account, persistent)
-
supportsInterface(interfaceId) -
name() -
symbol() -
decimals() -
contractURI() -
confidentialTotalSupply() -
confidentialBalanceOf(account) -
isOperator(holder, spender) -
setOperator(operator, until) -
confidentialTransfer(to, encryptedAmount, inputProof) -
confidentialTransfer(to, amount) -
confidentialTransferFrom(from, to, encryptedAmount, inputProof) -
confidentialTransferFrom(from, to, amount) -
confidentialTransferAndCall(to, encryptedAmount, inputProof, data) -
confidentialTransferAndCall(to, amount, data) -
confidentialTransferFromAndCall(from, to, encryptedAmount, inputProof, data) -
confidentialTransferFromAndCall(from, to, amount, data) -
requestDiscloseEncryptedAmount(encryptedAmount) -
discloseEncryptedAmount(encryptedAmount, cleartextAmount, decryptionProof) -
_setOperator(holder, operator, until) -
_mint(to, amount) -
_burn(from, amount) -
_transfer(from, to, amount) -
_transferAndCall(from, to, amount, data)
-
ERC7984HookedModuleInstalled(module) -
ERC7984HookedModuleUninstalled(module)
-
AmountDiscloseRequested(encryptedAmount, requester)
-
OperatorSet(holder, operator, until) -
ConfidentialTransfer(from, to, amount) -
AmountDisclosed(encryptedAmount, amount)
-
ERC7984HookedInvalidModule(module) -
ERC7984HookedDuplicateModule(module) -
ERC7984HookedNonexistentModule(module) -
ERC7984HookedExceededMaxModules()
-
HandleAccessManagerNotAllowed(handle, account)
-
ERC7984InvalidReceiver(receiver) -
ERC7984InvalidSender(sender) -
ERC7984UnauthorizedSpender(holder, spender) -
ERC7984UnauthorizedUseOfEncryptedAmount(amount, user) -
ERC7984UnauthorizedCaller(caller)
installModule(address module, bytes initData) public
Installs a hook module.
Consider gas footprint of the module before adding it since all modules will perform both steps (pre-hook, post-hook) on all transfers.
modules(uint256 start, uint256 end) → address[] public
Returns a slice of the list of modules installed on the token with inclusive start and exclusive end.
| Use an end value of type(uint256).max to get the entire list of modules. |
_authorizeModuleChange() internal
Authorization logic for installing and uninstalling modules. Must be implemented by the concrete contract.
_installModule(address module, bytes initData) internal
Internal function which installs a hook module.
_update(address from, address to, euint64 encryptedAmount) → euint64 transferred internal
See ERC7984._update.
Modified to run pre and post transfer hooks. Zero tokens are transferred if a module does not approve the transfer.
_runPreTransferHooks(address from, address to, euint64 encryptedAmount) → ebool compliant internal
Runs the pre-transfer hooks for all modules.
_runPostTransferHooks(address from, address to, euint64 encryptedAmount) internal
Runs the post-transfer hooks for all modules.
_validateHandleAllowance(bytes32 handle) → bool internal
See HandleAccessManager._validateHandleAllowance. Allow modules to access any handle the token has access to.
Utilities
ERC7984Utils
import "@openzeppelin/confidential-contracts/token/ERC7984/utils/ERC7984Utils.sol";
Library that provides common ERC7984 utility functions.
-
checkOnTransferReceived(operator, from, to, amount, data)
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 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
IERC7984Receiver.onConfidentialTransferReceived 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.
ERC7984HookModule
import "@openzeppelin/confidential-contracts/token/ERC7984/utils/ERC7984HookModule.sol";
An abstract base contract for building ERC-7984 hook modules. Compatible with ERC7984Hooked.
-
preTransfer(from, to, encryptedAmount) -
postTransfer(from, to, encryptedAmount) -
onInstall(initData) -
supportsInterface(interfaceId) -
_onInstall(, ) -
_preTransfer(, , , ) -
_postTransfer(, , , ) -
_getTokenHandleAllowance(token, handle) -
_getTokenHandleAllowance(token, handle, persistent) -
_emitPreTransferResults(token, from, to, encryptedAmount, compliant, context) -
_accessHandle(token, handle)
-
ERC7984HookModuleResult(token, from, to, encryptedAmount, result, context)
-
ERC7984HookModuleUnauthorizedAccount(account) -
ERC7984HookModuleUnauthorizedUseOfEncryptedAmount(amount, user)
preTransfer(address from, address to, euint64 encryptedAmount) → ebool public
Hook that runs before a transfer. Should not mutate token state. Module is already
granted transient access to encryptedAmount.
postTransfer(address from, address to, euint64 encryptedAmount) public
Performs operation after transfer.
supportsInterface(bytes4 interfaceId) → bool public
Returns true if this contract implements the interface defined by
interfaceId. See the corresponding
ERC section
to learn more about how these ids are created.
This function call must use less than 30 000 gas.
_onInstall(address, bytes) internal
Internal function which may be overridden by the derived contract to perform actions when the module is installed. Should clean up dirty state from possible previous installations.
_preTransfer(address, address, address, euint64) → ebool internal
Internal function which runs before a transfer. Transient access is already granted to the module
for encryptedAmount. If additional handle access is needed from the token, call _getTokenHandleAllowance.
ACL allowance on encryptedAmount is already checked for msg.sender in preTransfer.
|
_postTransfer(address, address, address, euint64) internal
Internal function which performs operations after transfers. Transient access is already granted to the module
for encryptedAmount. If additional handle access is needed from the token, call _getTokenHandleAllowance.
ACL allowance on encryptedAmount is already checked for msg.sender in postTransfer.
|
_getTokenHandleAllowance(address token, euint64 handle) internal
Allow modules to get access to token handles during transaction.
_getTokenHandleAllowance(address token, euint64 handle, bool persistent) internal
Allow modules to get access to token handles.
_emitPreTransferResults(address token, address from, address to, euint64 encryptedAmount, ebool compliant, bytes32 context) internal
Optionally emit the result of the pre-transfer hook.
Grants persistent ACL on compliant to both this contract and from.
_accessHandle(address token, euint64 handle) internal
Get transient ACL allowance for the given handle from a contract that inherits HandleAccessManager.
Additionally verifies that the token is authorized to access the handle.
ERC7984BalanceCapHookModule
import "@openzeppelin/confidential-contracts/token/ERC7984/utils/ERC7984BalanceCapHookModule.sol";
An ERC-7984 hook module that limits the balance of each investor.
The cap is stored as an encrypted euint64 value. The pre-transfer hook compares the recipient’s prospective balance to the
encrypted cap and emits an encrypted compliance result via ERC7984HookModule._emitPreTransferResults.
This module is compatible with ERC7984Hooked.
| This module notifies senders of the result of the pre-transfer hook. This can be used to leak information about the balance of the recipient. This is a potential security risk and should be used with caution. Production use-cases may want to remove this notification. |
-
setMaxBalance(token, newMaxBalance, inputProof) -
maxBalance(token) -
_setMaxBalance(token, newMaxBalance) -
_preTransfer(token, from, to, encryptedAmount) -
_onInstall(token, initData)
-
preTransfer(from, to, encryptedAmount) -
postTransfer(from, to, encryptedAmount) -
onInstall(initData) -
supportsInterface(interfaceId) -
_postTransfer(, , , ) -
_getTokenHandleAllowance(token, handle) -
_getTokenHandleAllowance(token, handle, persistent) -
_emitPreTransferResults(token, from, to, encryptedAmount, compliant, context) -
_accessHandle(token, handle)
-
ERC7984BalanceCapHookModuleMaxBalanceSet(token, newMaxBalance)
-
ERC7984HookModuleResult(token, from, to, encryptedAmount, result, context)
-
ERC7984HookModuleUnauthorizedAccount(account) -
ERC7984HookModuleUnauthorizedUseOfEncryptedAmount(amount, user)
setMaxBalance(address token, externalEuint64 newMaxBalance, bytes inputProof) public
Sets the max balance for a given token token to the encrypted value newMaxBalance.
msg.sender must have the agent role on token.
maxBalance(address token) → euint64 public
Gets the encrypted max balance for a given token token. Returns the zero handle if unset.
_setMaxBalance(address token, euint64 newMaxBalance) internal
Sets the encrypted max balance for a given token, grants the module persistent ACL, and emits an event.
_preTransfer(address token, address from, address to, euint64 encryptedAmount) → ebool result internal
Internal function which runs before a transfer. Transient access is already granted to the module
for encryptedAmount. If additional handle access is needed from the token, call _getTokenHandleAllowance.
ACL allowance on encryptedAmount is already checked for msg.sender in preTransfer.
|
_onInstall(address token, bytes initData) internal
See ERC7984HookModule._onInstall. The initData must contain the initial max balance for the token
along with the input proof for the max balance. These are encoded using standard ABI encoding.
ERC7984HolderCapHookModule
import "@openzeppelin/confidential-contracts/token/ERC7984/utils/ERC7984HolderCapHookModule.sol";
An ERC-7984 hook module that limits the number of holders for a given token.
| This module must be installed prior to minting any tokens. After the total supply is initialized, it is not possible to guarantee that the number of holders is 0, so the module can not be installed. |
| This module may not function correctly with non-standard tokens such as fee on transfer. |
-
setMaxHolderCount(token, maxHolderCount_) -
maxHolderCount(token) -
holderCount(token) -
_setMaxHolderCount(token, maxHolderCount_) -
_preTransfer(token, from, to, encryptedAmount) -
_postTransfer(token, from, to, encryptedAmount) -
_onInstall(token, initData)
-
preTransfer(from, to, encryptedAmount) -
postTransfer(from, to, encryptedAmount) -
onInstall(initData) -
supportsInterface(interfaceId) -
_getTokenHandleAllowance(token, handle) -
_getTokenHandleAllowance(token, handle, persistent) -
_emitPreTransferResults(token, from, to, encryptedAmount, compliant, context) -
_accessHandle(token, handle)
-
ERC7984HolderCapHookModuleMaxHolderCountSet(token, newMaxHolderCount)
-
ERC7984HookModuleResult(token, from, to, encryptedAmount, result, context)
-
ERC7984HolderCapHookModuleInvalidMaxHolderCount(maxHolderCount) -
ERC7984HolderCapHookModuleTotalSupplyInitialized()
-
ERC7984HookModuleUnauthorizedAccount(account) -
ERC7984HookModuleUnauthorizedUseOfEncryptedAmount(amount, user)
setMaxHolderCount(address token, uint64 maxHolderCount_) public
Sets the max number of holders for the given token token to maxHolderCount_.
msg.sender must have the agent role on token
holderCount(address token) → euint64 public
Gets current number of holders for the given token token.
_setMaxHolderCount(address token, uint64 maxHolderCount_) internal
Sets the max holder count for a given token to maxHolderCount_ and emits an event.
_preTransfer(address token, address from, address to, euint64 encryptedAmount) → ebool result internal
Internal function which runs before a transfer. Transient access is already granted to the module
for encryptedAmount. If additional handle access is needed from the token, call _getTokenHandleAllowance.
ACL allowance on encryptedAmount is already checked for msg.sender in preTransfer.
|
_postTransfer(address token, address from, address to, euint64 encryptedAmount) internal
Internal function which performs operations after transfers. Transient access is already granted to the module
for encryptedAmount. If additional handle access is needed from the token, call _getTokenHandleAllowance.
ACL allowance on encryptedAmount is already checked for msg.sender in postTransfer.
|
_onInstall(address token, bytes initData) internal
See ERC7984HookModule._onInstall. The initData must contain the initial max holder count for the token
as a standard ABI encoded uint64.
ERC7984HolderCapHookModuleMaxHolderCountSet(address indexed token, uint64 newMaxHolderCount) event
Emitted when the max holder count for a given token is set.