This repository contains the reference implementation for ERC-7518, a security token standard that extends ERC-1155 to provide a flexible framework for managing compliant real-asset security tokens.
ERC-7518 introduces partitioned token management through the ERC-1155 multi-token paradigm, where each tokenId represents a distinct partition with its own set of rights, privileges, and compliance rules. This architecture enables management of tokenized real-world assets including fractional ownership, multiple share classes, and granular compliance controls. The standard also defines features like token locks, forced transfers, freezing, payouts, wrapping, and compliance hooks. (eips.ethereum.org)
- Partitions via
tokenId: Enables semi-fungible tokens with partition‑specific logic. - Compliance Hooks: Methods like
canTransfer,lockTokens,forceTransfer, andfreezeprovide dynamic and enforceable rules. - Payouts & Batch Payouts: Built-in functions for token‑holder distributions.
- Interoperability: Wrapping and unwrapping tokens, enabling cross‑chain or cross‑standard compatibility.
- Built on ERC‑1155 + ERC‑165: Ensures backward compatibility and easy integration with wallets and dApps.
ERC-7518 represents partitions as ERC-1155 id or tokenIds.
Each tokenId corresponds to a distinct partition of a wrapped or regulated asset.
All compliance checks, locks, and transfer rules are evaluated per partition.
| Concept | Description | Implemented In |
|---|---|---|
Partition (id) |
Logical slice of an asset (e.g., restricted share class, lockup, compliance rule). | erc1155mod.sol |
| Partition Balances | Tracked under ERC-1155 balances: balanceOf(account, partitionId) |
erc1155mod.sol |
| Compliance Check | Hook executed before every transfer to validate partition rule. | erc7518.sol (pre-transfer gate that calls canTransfer) |
| Lock / Restrict | Temporarily freezes partition transfers. | erc7518.sol |
| Wrap / Unwrap | Converts partitioned tokens ↔ fungible main balance. | erc7518.sol (wrapToken, wrapTokenFromPartition, unwrapToken) |
| Force Transfer | Admin-triggered override respecting partition metadata. | erc7518.sol |
tokenId == partitionId.
Partitions can be minted, merged, or wrapped dynamically without redeploying the contract.
erc‑7518‑foundry/
├── src/
│ ├── erc7518.sol # Entry contract, vault and wrapper
│ ├── erc1155mod.sol # ERC-1155 base ledger (partitions)
│ └── STObasev2.sol # Security Token Offering contract
├── test/
│ └── ERC7518.t.sol # Foundry tests
├── script/
│ └── Deploy.s.sol # Deployment script
├── lib/ # Dependencies (e.g., OZ contracts)
├── foundry.toml
├── README.md
└── LICENSE
Note: STObasev2 stands for Security Token Offering. It is scoped to offering setup and settlement only, not a generic compliance or freeze module.
The reference implementation has three main contracts that together realize the full ERC-7518 lifecycle.
| Contract | Role | Description |
|---|---|---|
| erc1155mod.sol | Base Ledger | Implements the ERC-1155 multi-token standard with minor optimizations. Each tokenId represents a distinct partition and holds balances, mint, burn, and transfer logic. |
| STObasev2.sol | Security Token Offering (STO) | Handles offering lifecycle and settlement. Manages sale inventory and pricing, settles purchases, and transfers purchased ERC‑1155 tokenId balances to investors. It does not implement global freezes or a generic transfer gate. |
| erc7518.sol | Vault and Wrapper | Acts as the entry point for ERC-7518. It handles wrapping and unwrapping of external security tokens (ERC-20, ERC-721, or partitioned ERC-1400), integrates the compliance layer, and delegates balance management to erc1155mod.sol. |
- Mint, issuer creates a partition by minting
tokenIdinerc1155mod.sol. - STO settlement (optional),
STObasev2.solsettles a purchase and transfers the purchasedtokenIdto the investor. - Transfer, holder moves
tokenIdusingsafeTransferFrom,erc7518.solcalls the pre‑transfer gate (canTransfer) before updating balances. - Wrap from partition, holder calls
wrapTokenFromPartition(partitionId, tokenId, amount, data),erc7518.solperforms the vault action and mints the wrapped representation. - Unwrap, holder calls
unwrapToken(tokenId, amount, data),erc7518.solburns wrapped balance and releases the original asset. - Payout / Merge / Burn, issuer optionally distributes payouts, merges partitions, or burns when the lifecycle ends.
| Action | Where |
|---|---|
| Mint partition | src/erc1155mod.sol |
| Settle an STO purchase | src/STObasev2.sol |
| Pre‑transfer gate | src/erc7518.sol (canTransfer call) |
| Wrap from partition | src/erc7518.sol (wrapTokenFromPartition) |
| Unwrap | src/erc7518.sol (unwrapToken) |
- Each
tokenIdrepresents a unique partition with independent compliance rules - Dynamic allocation of tokens between different classes or categories
- Support for temporary non-fungibility during regulatory holding periods
- Efficient management of complex asset structures within a single contract
canTransfer()- Pre-transfer compliance validationrestrictTransfer()/removeRestriction()- Dynamic transfer restrictions per partitionfreezeAddress()/unFreeze()- Account-level compliance actions- Off-chain voucher support for dynamic compliance verification
lockTokens()- Time-based token vesting and holding periodsunlockToken()- Automated release after lock expirytransferableBalance()- Query available balance excluding locked tokenslockedBalanceOf()- Query locked token amounts
forceTransfer()- Authorized recovery for lost keys or compliance violations- Bypass standard transfer restrictions for regulatory enforcement
payout()- Single recipient distributionsbatchPayout()- Efficient multi-recipient payouts in single transaction
wrapToken()/unwrapToken()- ERC-20 token wrapping- Full backward compatibility with ERC-1155
- Foundry installed (
forge,cast). - Solidity ≥ 0.8.x.
# Install dependencies
forge install
# Build contracts
forge build
# Run tests
forge test -vvv
# Run gas snapshot
forge snapshot
# Deploy to network
forge script script/Deploy.s.sol --rpc-url <RPC_URL> --broadcast --verify# Run all tests with verbosity
forge test -vvv
# Run specific test file
forge test --match-path test/ERC7518.t.sol
# Gas report
forge test --gas-report- Fractional real estate classes: Define separate tranches (e.g., common vs. preferred) as partitions.
- Tranche-based finance: Different risk/return tiers represented by partition-specific token IDs.
- Cross-chain compliant RWAs: Tokens retain compliance state while moving across chains.
- Implement compliance logic: Add
canTransfer(...)checks using off-chain vouchers or on-chain registries. - Add recovery and lock features: Support token recovery via
forceTransfer, and vesting vialockTokens. - Support freezing: Allow
freeze()andunfreeze()on accounts or partitions. - Enable payouts: Safely distribute payouts using
payout()andbatchPayout(). - Incorporate interoperability: Use
wrapToken()andunwrapToken()for cross-chain or cross-standard compatibility. - Audit, document, license: Add comments, documentation, and choose a suitable open-source license (e.g., MIT).
This project is released under the GPL-3.0 License.
Maintained by Zoniqx

