RegX

Compliant invoice financing: ERC-3643 notes on Whitechain, settled in USDT, order book on Arkiv

RegX

Created At

ETHGlobal Mumbai

Project Description

RegX is a compliant invoice-financing market. A small business (MSME) tokenizes a receivable as a regulated security, verified investors fund it in USDT at a discount, and the coupons and repayment are settled on-chain. Investors who want out before maturity can sell on a public order book that anyone can read.

The problem. Invoice financing is slow and opaque. Investors can't see when an issuer misses a payment, and settlement goes through banks and back offices. Tokenizing a receivable only helps if the token keeps the rules a regulated security needs: who may hold it, how much each holder may own, and when it may move. Settlement also has to happen in a real stablecoin, not an IOU.

How it works

  1. Issuance. Each invoice becomes an ERC-3643 (T-REX) note on Whitechain Sepolia: 1 USDT face value per unit, issued at 0.97 USDT, paying a 0.01 USDT coupon. Investors identify through ONCHAINID: a trusted claim issuer signs a KYC claim, and the identity is registered in the T-REX Identity Registry. Only verified wallets can hold or receive units.
  2. Subscription. During the subscription window, verified investors call subscribe(). Their USDT goes straight to the issuer and units are minted to them in the same transaction. The mint goes through T-REX compliance: identity check, a 150-unit holding cap per investor, and a module that allows minting only before the subscription deadline. An unverified wallet's subscription reverts on-chain.
  3. Secondary trading (DvP). Makers sign EIP-712 orders and publish them as entities on Arkiv, so the order book is public, queryable data owned by each maker, and orders expire with their Arkiv entity. A taker fills an order through the RegXDvP contract, which swaps note units for USDT atomically in one transaction. Before submitting, the app runs an on-chain checkFill pre-trade check that explains exactly why a trade would fail: buyer not verified, wallet frozen, token paused, compliance rule broken, or insufficient balance or allowance. Unverified buyers are blocked inside the transfer itself.
  4. Coupons and maturity. Coupon payment and maturity settlement are permissionless. Once a date passes, anyone can trigger them. USDT is pulled from the issuer's on-chain allowance and paid pro rata to every holder. At maturity, face value is repaid and the units are burned. A missed payment shows up as a public revert, not a quiet bank delay.
  5. Issuer controls. The issuer, acting as the T-REX agent, can freeze wallets and pause the token, and those controls are enforced in the contracts.
  6. Public history on Arkiv. A keeper mirrors every on-chain event into Arkiv as typed entities: fills, subscriptions, coupons, redemptions, freezes, pauses and KYC grants. Writes are idempotent, keyed by transaction hash and log index, so anyone can re-run the keeper and reproduce the dataset. The keeper also auto-settles coupons and maturity when they fall due.

Why on-chain stablecoin settlement matters. Delivery and payment have to be atomic and auditable. USDT on Whitechain lets the same transaction that enforces ERC-3643 compliance also move the money. That removes settlement risk, and every subscription, coupon and repayment can be checked on the explorer.

What's proven on testnet. The full lifecycle has run with real Whitechain test USDT:

  • verified subscriptions
  • a rejected subscription from an unverified investor
  • an atomic DvP trade, plus a blocked buy from an unverified investor
  • a coupon paid automatically to all holders
  • maturity repayment of 15 USDT with the units burned

All 12 contracts are verified on the Whitechain explorer, and 24 Foundry tests run against the real T-REX token.

Stack. Solidity with Tokeny T-REX v4.1.6 and ONCHAINID; Foundry; viem and wagmi; a Next.js web app with views for markets, portfolio, issuer and activity; and the Arkiv SDK for the order book and event history.

How it's Made

RegX is a TypeScript monorepo built with npm workspaces. It has four parts:

  • contracts/ (Foundry, Solidity 0.8.17, EVM target paris): the smart contracts.
  • shared/: ABIs, Arkiv schemas, EIP-712 order helpers and a revert-reason decoder, used by both the scripts and the web app.
  • scripts/: deployment, keeper and lifecycle CLIs, run with tsx and viem.
  • web/: a Next.js 15 app built with wagmi, viem, React Query and Tailwind 4.

Contracts (Whitechain Sepolia, chain 1874). We used Tokeny's official T-REX v4.1.6 (the ERC-3643 standard) and ONCHAINID v2.2.1 directly rather than writing our own permissioned token. The setup is:

  • One shared identity layer serves every note: an Identity Registry and its storage, a Claim Topics Registry (KYC is topic 1), and a Trusted Issuers Registry.
  • Each note gets its own T-REX Token and ModularCompliance contract, with two custom modules attached:
    • InvestorCapModule caps how many units one holder can own (150).
    • RegXNote is the hacky part. We wrote it as a T-REX compliance module that is also the note's lifecycle contract. Because it sits inside the compliance hooks, it sees every mint, transfer and burn. It uses those hooks to keep an on-chain set of holders, which is how it pays coupons pro rata without an off-chain snapshot. It also enforces the lifecycle in the transfer path: minting only before the subscription deadline, transfers only before maturity, burns always allowed. On top of that it exposes subscribe() (USDT goes from the investor to the issuer, then units are minted), plus permissionless payCoupon(i) and settleMaturity(). Both pull USDT from the issuer's allowance and pay every holder, and maturity also burns the units. Since the note is a token agent, it can mint and burn directly.
  • RegXDvP settles EIP-712 signed orders (domain RegX/1, bound to the chain ID). It supports partial fills, cancellation by nonce, and atomic swaps of units for USDT. It also has a view function, checkFill, that rebuilds what T-REX would check: paused, frozen wallets, free (unfrozen) balance, allowances, isVerified(buyer) and compliance.canTransfer. It returns a reason code, so the UI can explain why a trade would fail before the user spends gas.

24 Foundry tests run against the real T-REX Token, with a mock USDT. All 12 contracts are verified on Whitechain's Blockscout explorer by a script that calls its verification API.

Whitechain (partner). We started on Hedera's Asset Tokenization Studio and moved to Whitechain partway through. What Whitechain gave us:

  • An EVM chain with roughly 1-second blocks and a 5 gwei base fee, so the full lifecycle (subscribe, trade, coupon, maturity) could run live within minutes on short-dated test notes.
  • A real test USDT (6 decimals, with permit). Every payment in the demo is actual stablecoin settlement with explorer links, not a token we minted ourselves.
  • Standard tooling that just works: Blockscout verification, and Multicall3, which the web app uses to batch its reads.

Arkiv (partner). Arkiv is the market's data layer. We built on SDK 1.0.1's schema-first API on the Rabdi testnet with four typed schemas:

  • regx.asset: the security's metadata and live stats.
  • regx.order: the order book.
  • regx.fill and regx.action: trades, and corporate and compliance events.

Makers publish their signed orders as Arkiv entities from their own wallets, so each maker owns their order. Each entity expires when its order does, which means expired orders drop out of the book without a cleanup job. Arkiv strings are capped at 128 bytes, so signatures go in a bytes column. The web app queries the book with Arkiv's select().where().orderBy() and then reads each order's remaining size from the DvP contract, combining off-chain discovery with on-chain truth.

background image mobile

Join the mailing list

Get the latest news and updates

RegX | ETHGlobal