No pitfalls are highlighted in the tests for this example.
API Reference
Overview
ERC20-like token with encrypted balances and compliance checks
Developer Notes
Example for fhEVM Examples - Identity Category
name
Token name
symbol
Token symbol
DECIMALS
Token decimals
totalSupply
Total supply (public for transparency)
complianceChecker
Compliance checker interface (can be ComplianceRules or custom)
owner
Owner/admin
pendingOwner
Pending owner for two-step ownership transfer
Transfer
Emitted on token transfers (indexed for efficient filtering)
Parameters
Name
Type
Description
from
address
Address tokens are transferred from
to
address
Address tokens are transferred to
Approval
Emitted when spending allowance is set
Parameters
Name
Type
Description
owner
address
Address of the token owner
spender
address
Address authorized to spend
Mint
Emitted when new tokens are minted
Parameters
Name
Type
Description
to
address
Address receiving the minted tokens
amount
uint256
Number of tokens minted
ComplianceCheckerUpdated
Emitted when the compliance checker contract is updated
Parameters
Name
Type
Description
newChecker
address
Address of the new compliance checker
OwnershipTransferStarted
Emitted when ownership transfer is initiated
Parameters
Name
Type
Description
currentOwner
address
Current owner address
pendingOwner
address
Address that can accept ownership
OwnershipTransferred
Emitted when ownership transfer is completed
Parameters
Name
Type
Description
previousOwner
address
Previous owner address
newOwner
address
New owner address
OnlyOwner
Thrown when caller is not the contract owner
OnlyPendingOwner
Thrown when caller is not the pending owner
InvalidOwner
Thrown when new owner is the zero address
ComplianceCheckerNotSet
Thrown when compliance checker is required but not set
UnauthorizedCiphertext
Thrown when caller supplies an unauthorized ciphertext handle
TotalSupplyOverflow
Thrown when mint amount would exceed uint64 accounting bounds
constructor
Initialize the token
Parameters
Name
Type
Description
tokenName
string
Token name
tokenSymbol
string
Token symbol
checker
address
Address of the compliance checker contract
setComplianceChecker
Set the compliance checker contract
Parameters
Name
Type
Description
checker
address
Address of the compliance checker
transferOwnership
Initiate transfer of contract ownership
Parameters
Name
Type
Description
newOwner
address
Address that can accept ownership
acceptOwnership
Accept ownership transfer
mint
Mint tokens to an address
Only owner can mint. Compliance is NOT checked on mint.
Parameters
Name
Type
Description
to
address
Recipient address
amount
uint256
Amount to mint (plaintext)
transfer
Transfer tokens with encrypted amount
Branch-free transfer with compliance checks
Parameters
Name
Type
Description
to
address
Recipient address
encryptedAmount
externalEuint64
Encrypted amount to transfer
inputProof
bytes
Proof for encrypted input
Return Values
Name
Type
Description
success
bool
Always returns true (actual transfer amount may be 0) Key insight: We never revert on failed compliance. Instead: - If compliant: transfer the requested amount - If not compliant: transfer 0 (no state change, no info leak)
transfer
Transfer with euint64 amount (for approved callers)