OpenZeppelin and ERC-3643: how a security token is built
What the T-REX suite takes from OpenZeppelin 4.8, what ERC-3643 adds in identity and permissions, and how to test mint, forcedTransfer and recovery.

A team preparing a security token with eligibility requirements, such as a bond reserved for verified investors or shares with a cap on the number of holders, soon comes across two names. OpenZeppelin Contracts is a Solidity contract library released in audited versions, with implementations of tokens, access control and upgradeable proxies. ERC-3643 is the Final Ethereum standard for permissioned tokens: it defines how the token connects to an identity registry and to a compliance contract that decides whether each operation can go ahead.
The relationship between the two is more specific than seeing them side by side suggests. The ERC-3643 reference implementation, the T-REX suite, takes contract ownership, initialization and some of its proxies from OpenZeppelin, using version 4.8 of the library, and writes the token, identity and compliance logic itself. Building a security token with them therefore comes down to three engineering decisions: which OpenZeppelin version to use and how the contracts will be upgraded, who holds each permission over the token, and how each operation is tested on its own, because not all of them go through the same checks.
What T-REX takes from OpenZeppelin, and which version
The ERC3643 Association maintains the suite in a public repository under the GPL-3.0 license; its latest release is 4.1.3, from June 2025, while Tokeny, the company that developed T-REX, keeps its own repository at 4.1.6. Both declare @openzeppelin/contracts and @openzeppelin/contracts-upgradeable as dependencies in the ^4.8.3 range, meaning any 4.x version from 4.8.3 onward.
What the suite uses from the library is limited. The token, the identity registry and its storage, the trusted issuers registry, the claim topics registry and the compliance contract all inherit, directly or through the agent role, from OwnableUpgradeable, the upgradeable version of OpenZeppelin's ownership contract, and the suite's proxies rely on Initializable. Upgradeable compliance modules use UUPSUpgradeable and are deployed behind an ERC1967Proxy. The token, by contrast, does not inherit OpenZeppelin's ERC-20 implementation: it imports only the IERC20 interface and keeps its own accounting of balances, freezes and transfers. The agent role does not use AccessControl either, but a small library of the suite's own called Roles.
The version matters above all for upgradeable contracts. OpenZeppelin's stable line is now 5.x, with 5.6.1 from February 2026 as the latest audited release, and its documentation warns that for upgradeable contracts the storage layouts of different major versions should be assumed incompatible: upgrading in place from 4.9.3 to 5.0.0 is unsafe. Version 5.x stores each contract's state in its own namespace (ERC-7201), whereas 4.x lays it out sequentially. In a T-REX project this has a practical consequence: a custom compliance module that inherits from the suite's base contracts also inherits its OpenZeppelin version, and moving to 5.x means rewriting those bases and deploying new contracts rather than upgrading the existing ones. The version is decided before the first deployment and written down.
The library also separates what has been audited from what has not. It tags audited releases as latest on npm and final releases still awaiting audit as dev, currently 5.7.0. That audit covers OpenZeppelin's code at that version; the suite's code, the project's extensions, its configuration and its integrations need their own review, as we explain in our article on what a smart contract audit demonstrates.
What ERC-3643 adds: identity, compliance and two permission levels
On top of that base, the ERC-3643 specification defines six components: the token, the Identity Registry and its storage, the Trusted Issuers Registry, the Claim Topics Registry and the Compliance contract. The registry links each wallet to an ONCHAINID identity and a country; the token asks the registry whether the receiver is verified and asks the compliance contract whether the operation respects the offering rules. How isVerified and canTransfer work is covered in the ERC-3643 glossary entry; what matters when building the token is who controls each component.
The specification requires ERC-173, the contract ownership standard, and adds an agent role appointed by the owner. In T-REX the split is clear. The token owner can replace the identity registry and the compliance contract with setIdentityRegistry and setCompliance; the owner of the compliance contract adds or removes modules with addModule and removeModule; and the owner of each contract that has agents, namely the token, the identity registry and its storage, appoints or removes them with addAgent and removeAgent. The token's agents run day-to-day operations: mint and burn, pause and unpause, setAddressFrozen and freezePartialTokens, forcedTransfer and recoveryAddress. The token is paused when it is initialized, so no transfer works until an agent calls unpause, a detail that surfaces in the first integration test.
In this version of the suite the agent role is a single role: any agent of the token can execute every one of those functions. If the issuer wants to separate who mints, who freezes and who recovers wallets, Tokeny's repository includes an AgentManager contract that holds the agent role and splits it into narrower roles such as SupplyModifier, Freezer, TransferManager or RecoveryAgent; the ERC3643 Association repository does not include it, so that separation has to be designed explicitly. The same question arises with OpenZeppelin's access control, where every role has an admin role: besides knowing who holds a permission, the team needs to know who can grant it.
The most far-reaching permission is not in the token. T-REX proxies delegate to the implementation designated by an authority contract, TREXImplementationAuthority, whose owner selects the active version with useTREXVersion, so every proxy pointing to that authority switches code at the same time. In production, both that owner and the token owner should be multisig accounts or governance contracts with a written procedure, because whoever controls the authority can replace the logic of every contract that depends on it.
Testing each operation: what every function checks
An ordinary transfer goes through every check: pause, freezes, free balance, verified receiver and compliance rules. Agent operations follow different paths, and here the specification and the reference implementation do not fully match. The specification states that mint and forcedTransfer bypass the compliance rules and only require a verified receiver. T-REX does apply those rules on mint: it calls canTransfer(address(0), _to, _amount) before minting and rejects the mint if they are not met. On forcedTransfer it only checks that the receiver is verified and, if the amount exceeds the free balance, unfreezes the difference; it still notifies the compliance contract of the operation, so modules update their counters. burn only checks the balance. None of the three checks the pause, so an agent can mint, burn or force transfers while the token is paused.
| Function | Who executes it | What T-REX checks | Test that should not be missing |
|---|---|---|---|
| transfer | Holder | Pause, freezes, free balance, verified receiver and compliance rules | Sending to a verified receiver and to one without claims; the second is rejected without moving balances |
| mint | Agent | Verified receiver and compliance rules; no pause check | Minting exactly at a module's limit and one unit above it |
| forcedTransfer | Agent | Sender balance and verified receiver; unfreezes as needed; no compliance rules or pause check | A forced transfer that exceeds a configured limit, with the procedure that authorizes it |
| burn | Agent | Balance; unfreezes as needed; no pause check | Burning against a partially frozen balance |
| recoveryAddress | Agent | Balance on the lost wallet and new wallet registered as a management key of the identity | A legitimate recovery and attempts from an account without the agent role or to an unlinked wallet |
That difference determines what has to be tested. Take a hypothetical bond issuance with a module that caps each investor's position at 50,000 units. In T-REX, a mint that would take an investor above the cap is rejected, while a forced transfer to the same investor goes through. That may be the intended behavior if the issuer reserves forcedTransfer for defined cases, such as enforcing a court decision or correcting a registry error, but then the procedure that authorizes its use has to be written down and tested. With another implementation that follows the specification to the letter, mint would also exceed the cap, so the question for a provider is which code each function runs, not only which standard it implements.
In the investor application, simulating an operation with canTransfer reserves nothing: balances, freezes or claims can change between the query and the execution, and the interface has to treat a rejection as a possible outcome, without showing as completed an operation the network has not yet confirmed.
Recovering a wallet: what recoveryAddress does
Recovery is the function that depends most on procedures outside the network. Its signature in the specification is recoveryAddress(lostWallet, newWallet, investorOnchainID), and in T-REX only an agent can call it. The token contract requires the lost wallet to hold a balance and the new wallet to already be a management key of the investor's ONCHAINID identity. If both conditions are met, it registers the new wallet in the identity registry with the same country, moves the entire balance with forcedTransfer, replicates any partial freeze and address freeze, and removes the lost wallet from the registry.
Two design decisions follow. The first is who adds the new key to the identity: if the lost wallet was the only management key, the investor can no longer do it, so the identity needs another management key, held for example by the platform's identity manager, and that custody has to be documented. The second is how the agent confirms that the request comes from the holder. The contract trusts the agent, so identity verification, the evidence retained and the review period are part of the issuer's procedure. The acceptance test covers both sides: a legitimate recovery that reconciles balance, freezes and identity, and the attempts that must fail, from an account without the agent role, to a wallet that is not a key of the identity or from a lost wallet with no balance.
What to document at deployment
The suite includes a factory, TREXFactory, whose deployTREXSuite function deploys the token, the registries and the compliance contract in a single call, behind proxies connected to the implementation authority. Reviewing that deployment later requires a complete inventory of what was deployed, and the technical handover should record at least:
- The suite version and the OpenZeppelin version used to compile it, with an exact reference to the deployed code.
- The addresses of the proxies, the implementations and the implementation authority.
- The owner of each contract and of the authority, with the account type and the procedure for using it.
- The agents of the token and the registries, and which functions each one executes.
- The required claim topics, the trusted issuers and the compliance modules with their parameters.
- The results of the per-operation tests, including expected rejections.
With that inventory, each requirement of the offering maps to a configuration and a test, and an upgrade is reviewed by comparing two versions of the same document.
ERC-3643 standardizes identity and compliance; the investor's rights are set by the issuance
The value of ERC-3643 lies in setting common interfaces for identity, compliance and administration, and in having a public reference implementation where every check can be read in the code. A platform, a custodian or a trading venue that knows those interfaces can integrate with a token without learning a different model for each issuer. ERC-1400, another proposal for tokenized securities, defines a family of interfaces with balance partitions, but it was never published as an EIP: the proposal remained in an issue, now closed, in Ethereum's EIPs repository.
What the standard does not decide is the investor's right, which is set by the issuance document, the identification process behind each claim, or reconciliation with the official securities register where the law requires one, as with the ERIR in Spain. Nor does it decide the applicable regime: a token that is a financial instrument falls outside MiCA under its Article 2(4) and is governed by securities law. The suite enforces on every operation the conditions it is configured with, and making sure those conditions match the offering is the work of the issuer and its law firm.
At Metlabs we develop security token issuances with ERC-3643 and a white-label tokenization platform that covers investor onboarding, subscription and issuer operations. If you are assessing an implementation, tell us about the instrument, the jurisdiction, the eligibility rules and your existing integrations, and we will tell you which part is suite configuration and which part requires custom development.
- ERC-3643 Association: T-REX reference implementation (GitHub)
- EIP-3643: T-REX, Token for Regulated EXchanges
- ERC-3643 specification
- Tokeny Solutions: T-REX repository (GitHub)
- OpenZeppelin Contracts
- OpenZeppelin Contracts: access control
- ONCHAINID documentation
- Ethereum EIPs issue #1411: ERC-1400 security token standard
- MiCA Article 2
Got a blockchain project in mind?
From idea to product, strategy and technology must move forward together.







