Source code
1. Overview
1. Overview
ComplianceManage does not mint tokens and does not manage asset sale state. It is called by business contracts such as RWAToken. Its core value is separating “whether a user is allowed to perform a specific operation” from the token business layer, forming a compliance service layer that can be governed and upgraded independently.2. Responsibilities and Compliance Model
2. Responsibilities and Compliance Model
- Blacklist: blacklisted addresses are rejected directly on the token transfer path.
- Signature authorization: before sensitive operations such as primary purchases, a user must present a valid signature authorization.
- Verified token caller restriction: only approved business contracts can consume (validate and use) these signature authorizations.
ComplianceManage is not a general-purpose KYC registry and not a full identity system. It is positioned as an on-chain compliance controller for specific business contracts.3. Standards, EIPs, and Cryptographic Components
3. Standards, EIPs, and Cryptographic Components
- ECDSA
- EIP-191 style signatures
- Fields bound into the message
ECDSA is the most common signature recovery mechanism on Ethereum. This implementation uses ECDSA.recover() to recover the signer from a message digest and signature, then checks whether the signer is the owner or an authorized signature manager.- ERC-1967 and UUPS: runs behind an
ERC-1967proxy usingUUPSUpgradeable. Upgrade authorization is controlled by_authorizeUpgrade(). - Initializable and OwnableUpgradeable: as an upgradeable instance, initialization must be done via
initialize().OwnableUpgradeableprovides top-level governance control.
4. Permission Model and Role Boundaries
4. Permission Model and Role Boundaries
PERMISSION_LIST_MANAGER, responsible for blacklist management.PERMISSION_SIGNATURE_MANAGER, responsible for signature authorization operations and approving which token contracts can call signature verification.5. Blacklist Management
5. Blacklist Management
mapping(address => bool) public blacklist. Business contracts can read the mapping directly or query via isBlacklisted() (read-only).Two update methods are provided:setBlacklist(address[] calldata users, bool status): batch updates, up to 100 addresses per call.setBlacklistSingle(address user, bool status): single-address update.
- The batch interface caps length to avoid extreme gas usage from oversized arrays.
- State is written and events are emitted only when the status actually changes.
- The zero address is rejected in the single-address function; in the batch function it is skipped.
6. Signature Verification Flow and Replay Protection
6. Signature Verification Flow and Replay Protection
verifySignature() is the key business entrypoint and is protected by onlyVerifiedToken. A typical flow is:Build digest
Recover signer
EIP-191 signed message and recovers the signer, then validates whether the signer is the owner or a signature manager.7. Verified Token Allowlist
7. Verified Token Allowlist
verifiedTokens mapping restricts which business contracts can call verifySignature().RWATokenis registered as a verified token after deployment.- Calls from unregistered addresses revert with
TokenNotVerified(). - Allowing a business contract to consume signatures is an independent governance decision.
8. Sub-admin Configuration Model
8. Sub-admin Configuration Model
mapping(address => SubAdmin) public subAdmins:9. Upgrade Mechanism and Storage Compatibility
9. Upgrade Mechanism and Storage Compatibility
- The proxy shell does not decide who can upgrade; the owner ultimately controls it.
- New implementations must preserve storage layout compatibility.
uint256[50] private __gap;reserves space for future variables, but it does not permit arbitrary reordering of state variables.
10. Security Analysis and Audit Focus
10. Security Analysis and Audit Focus
- Whether the signature path matches the off-chain signing service exactly, especially the encoding order of
operationand nonce. - Whether
verifiedTokenscontains only trusted business contracts. - Whether signature-manager and list-manager privileges align with the operational process.
- Whether the owner role is controlled via a secure multisig or governance process for upgrades and admin management.
- Whether future upgrades keep the message format and nonce semantics compatible.
11. Interaction with RWAToken
11. Interaction with RWAToken
RWAToken is one of the primary callers of ComplianceManage:- Transfer integration:
RWAToken._update()queries theblacklistmapping directly to reject transfers involving blacklisted addresses. - Subscription integration:
RWAToken.mint()callsverifySignature(), requiring buyers to pass signature authorization beforeUSDTpayment and token minting can proceed.