ERC20Confidential moves confidential balances with the same functions as FHERC20. This page lists those functions and the few places where ERC20Confidential behaves differently. Read the FHERC20 page for the full behavior of each overload.
The transfer functions
Every transfer function comes in two overloads: one for a wallet, which passes an encrypted input and its proof, and one for a contract, which passes asharedEuint64.
Each returns a
sharedEuint64 holding the amount that actually moved. From a wallet, encrypt the amount in confidential units and name the token as the consuming contract:
Where it differs from FHERC20
_beforeConfidentialMove runs before all eight transfer functions and both unshield overloads. It does nothing by default. Override it to freeze accounts or pause the confidential side; see extend ERC20Confidential.
All eight transfer functions and both unshield overloads are nonReentrant, so a callback cannot call another transfer or unshield on the same token.
Operators
An operator can move any amount of a holder’s confidential balance until a deadline:isOperator(holder, spender) returns true while block.timestamp is at or before the deadline, and always returns true when holder and spender are the same address. Setting the deadline to 0 revokes the operator. Each call emits OperatorSet(holder, operator, until). For the operator model in depth, see operators.
Confidential operators and public allowances are separate. approve and transferFrom keep working on the public balance and have no effect on the confidential one, and setOperator grants nothing on the public side.
Transfers with a callback
confidentialTransferAndCall and confidentialTransferFromAndCall call onConfidentialTransferReceived on the recipient after the transfer, using the same IERC7984Receiver interface as FHERC20. If the receiver returns an encrypted false, the token moves the amount back to the sender. See transfer callbacks for how to write a receiver.
Events
The sender and the recipient can both decrypt the
amount handle of a transfer they took part in.