Interfaces
| This document is better viewed at https://docs.openzeppelin.com/confidential-contracts/api/interfaces |
These interfaces are available as .sol files and are useful to interact with third party contracts that implement them.
Core
IERC7984
import "@openzeppelin/confidential-contracts/interfaces/IERC7984.sol";
Draft interface for a confidential fungible token standard utilizing the Zama FHE library.
-
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)
-
supportsInterface(interfaceId)
-
OperatorSet(holder, operator, until) -
ConfidentialTransfer(from, to, amount) -
AmountDisclosed(encryptedAmount, amount)
contractURI() → string external
Returns the contract URI. See ERC-7572 for details.
confidentialBalanceOf(address account) → euint64 external
Returns the confidential balance of the account account.
isOperator(address holder, address spender) → bool external
Returns true if spender is currently an operator for holder.
setOperator(address operator, uint48 until) external
Sets operator as an operator for holder until the timestamp until.
| An operator may transfer any amount of tokens on behalf of a holder while approved. |
confidentialTransfer(address to, externalEuint64 encryptedAmount, bytes inputProof) → euint64 external
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 transferred external
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 external
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 transferred external
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 transferred external
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 transferred external
Similar to confidentialTransfer 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 confidentialTransferFrom but with a callback to to
after the transfer.
confidentialTransferFromAndCall(address from, address to, euint64 amount, bytes data) → euint64 transferred external
Similar to confidentialTransferFrom but with a callback to to
after the transfer.
OperatorSet(address indexed holder, address indexed operator, uint48 until) event
Emitted when the expiration timestamp for an operator operator is updated for a given holder.
The operator may move any amount of tokens on behalf of the holder until the timestamp until.
ConfidentialTransfer(address indexed from, address indexed to, euint64 indexed amount) event
Emitted when a confidential transfer is made from from to to of encrypted amount amount.
AmountDisclosed(euint64 indexed encryptedAmount, uint64 amount) event
Emitted when an encrypted amount is disclosed.
Accounts with access to the encrypted amount encryptedAmount that is also accessible to this contract
should be able to disclose the amount. This functionality is implementation specific.
IERC7984Receiver
import "@openzeppelin/confidential-contracts/interfaces/IERC7984Receiver.sol";
Interface for contracts that can receive ERC7984 transfers with a callback.
-
onConfidentialTransferReceived(operator, from, amount, data)
onConfidentialTransferReceived(address operator, address from, euint64 amount, bytes data) → ebool external
Called upon receiving a confidential token transfer. Returns an encrypted boolean indicating success of the callback. If false is returned, the token contract will attempt to refund the transfer.
| The calling contract (token) must be granted ACL allowance to read the confidential return value if it is initialized. Uninitialized return values are treated as a false boolean. |
| Do not manually refund the transfer AND return false, as this can lead to double refunds. |
Extensions
IERC7984ERC20Wrapper
import "@openzeppelin/confidential-contracts/interfaces/IERC7984ERC20Wrapper.sol";
Interface for ERC7984ERC20Wrapper contract.
-
wrap(to, amount) -
unwrap(from, to, encryptedAmount, inputProof) -
underlying() -
finalizeUnwrap(unwrapRequestId, unwrapAmountCleartext, decryptionProof) -
rate() -
unwrapAmount(unwrapRequestId)
-
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)
-
supportsInterface(interfaceId)
-
Wrap(to, underlyingAmount, encryptedWrappedAmount) -
UnwrapRequested(receiver, unwrapRequestId, amount) -
UnwrapFinalized(receiver, unwrapRequestId, encryptedAmount, cleartextAmount)
-
OperatorSet(holder, operator, until) -
ConfidentialTransfer(from, to, amount) -
AmountDisclosed(encryptedAmount, amount)
wrap(address to, uint256 amount) → euint64 external
Wraps amount of the underlying token into a confidential token and sends it to to.
Returns amount of wrapped token sent.
unwrap(address from, address to, externalEuint64 encryptedAmount, bytes inputProof) → bytes32 external
Unwraps tokens from from and sends the underlying tokens to to. The caller must be from
or be an approved operator for from.
Returns the unwrap request id.
| The returned unwrap request id must never be zero. |
underlying() → address external
Returns the address of the underlying ERC-20 token that is being wrapped.
finalizeUnwrap(bytes32 unwrapRequestId, uint64 unwrapAmountCleartext, bytes decryptionProof) external
Finalizes an unwrap request identified by unwrapRequestId with the given unwrapAmountCleartext and decryptionProof.
rate() → uint256 external
Returns the rate at which the underlying token is converted to the wrapped token.
For example, if the rate is 1000, then 1000 units of the underlying token equal 1 unit of the wrapped token.
unwrapAmount(bytes32 unwrapRequestId) → euint64 external
Returns the amount of wrapper tokens that were unwrapped for a given unwrapRequestId.
Wrap(address indexed to, uint256 underlyingAmount, euint64 encryptedWrappedAmount) event
Emitted when underlyingAmount of the underlying token was wrapped into encryptedWrappedAmount
confidential tokens and sent to to.
UnwrapRequested(address indexed receiver, bytes32 indexed unwrapRequestId, euint64 amount) event
Emitted when an unwrap request is made for a given receiver, unwrapRequestId, and amount.
amount is denominated in confidential wrapper tokens (this contract’s units), not in
underlying ERC-20 tokens.
|
UnwrapFinalized(address indexed receiver, bytes32 indexed unwrapRequestId, euint64 encryptedAmount, uint64 cleartextAmount) event
Emitted when an unwrap request is finalized for a given receiver, unwrapRequestId, encryptedAmount, and cleartextAmount.
cleartextAmount is the decrypted unwrap amount denominated in confidential wrapper tokens
(this contract’s units), not in underlying ERC-20 tokens.
|
IERC7984Hooked
import "@openzeppelin/confidential-contracts/interfaces/IERC7984Hooked.sol";
Interface for an ERC-7984 token that supports hook modules.
-
isModuleInstalled(module) -
installModule(module, initData) -
uninstallModule(module) -
isModuleManager(account)
-
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)
-
supportsInterface(interfaceId)
-
ERC7984HookedModuleInstalled(module) -
ERC7984HookedModuleUninstalled(module)
-
OperatorSet(holder, operator, until) -
ConfidentialTransfer(from, to, amount) -
AmountDisclosed(encryptedAmount, amount)
installModule(address module, bytes initData) external
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.
IERC7984HookModule
import "@openzeppelin/confidential-contracts/interfaces/IERC7984HookModule.sol";
Interface for an ERC-7984 hook module.
-
preTransfer(from, to, encryptedAmount) -
postTransfer(from, to, encryptedAmount) -
onInstall(initData)
-
supportsInterface(interfaceId)
-
ERC7984HookModuleResult(token, from, to, encryptedAmount, result, context)
preTransfer(address from, address to, euint64 encryptedAmount) → ebool external
Hook that runs before a transfer. Should not mutate token state. Module is already
granted transient access to encryptedAmount.