Hundiiii

Sell unpaid invoices to verified investors for USDT, atomically.

Hundiiii

Created At

ETHGlobal Mumbai

Project Description

Hundi is onchain invoice financing on Whitechain. An exporter usually waits 60 to 90 days to be paid after shipping goods. Selling the invoice at a discount to get cash early is established practice, and regulated platforms such as India's TReDS already support it. Hundi explores what a shared ledger can add.

How it works:

  1. A verifier approves exporters, importers and investors, with a role, expiry and jurisdiction for each.
  2. The exporter issues an invoice with its face value, due date and discount. Only hashes of the reference and document go on chain, and a reference can be registered only once.
  3. The importer who owes the money confirms the invoice. No units exist before this, so nothing can be bought early.
  4. Verified investors buy all or part of the invoice. USDT goes to the exporter and units go to the investor in one transaction, or neither moves.
  5. Investors can resell to other verified investors. Transfers to unverified wallets are blocked by the contract, and transfers stop on the due date.
  6. On the due date, the contract collects USDT from the importer and pays whoever holds the units. Investors don't need to do anything, and anyone can trigger settlement.
  7. If the importer pays short, the invoice defaults after a grace period and holders share what was recovered, including later recoveries.

A regular payment rail only moves money. It can't swap a claim for cash atomically or send repayment to the current holder. Here, both happen in one contract.

This is a testnet prototype and doesn't claim to be production-ready. Double financing is only blocked inside Hundi, nothing prices the importer's credit risk, importers must pay onchain, and a token isn't a legal agreement. The README lists these limits in full.

How it's Made

Contracts are written in Solidity 0.8.30 with Foundry and OpenZeppelin 5.4, and are deployed and verified on Whitechain Sepolia (chain 1874).

There are two contracts. ParticipantRegistry is a KYB allowlist holding roles, expiry, jurisdiction and freeze status. HundiInvoice is an ERC-1155 where each token id is one invoice and one unit equals 0.000001 USDT of face value. All transfer rules sit in the _update hook, so direct and batch transfers can't bypass them. All units are minted to the exporter when the importer confirms, and funding simply moves them to investors, so partial fills need no special handling.

Design details: holders are tracked on chain with EnumerableSet, so paying out needs no indexer. The USDT has a blocklist, so distribution uses trySafeTransfer and one blocked wallet can't stop everyone else being paid. A failed collection doesn't revert, so an invoice can't get stuck open. Claims are tracked per holder, so a holder who collects early still shares in later recoveries after a default.

The frontend is Next.js 16 with wagmi, viem and Tailwind, deployed on Vercel, with a screen for each party and a public timeline per invoice. Every transaction is simulated first, so a contract rule appears as a clear message before the wallet asks for a signature. A small TypeScript keeper settles due invoices and pays holders, but settle and distribute are permissionless, so anyone can run them.

Partner technology: Whitechain settles everything in its USDT. 1-second blocks make a multi-party flow feel instant, viem already includes the chain and Multicall3 handles batched reads. Blockscout verification worked on the first try. We tested against the real USDT on an Anvil fork before spending scarce faucet WBT. The USDT supports permit, so we also built and fork-tested fundWithPermit, though the app still uses approve then fund.

Hacky bits: the public RPC rejects log queries over 10,000 blocks, which broke our approved list and invoice history once the chain passed that point, so the app now reads events in chunks. Short due dates and a 60-second grace period exist only for the demo. Fork testing used a window.ethereum shim to drive the UI without a real wallet.

AI tools (Claude Code) generated most of the code, tests and docs under my direction, as documented in AI_USAGE.md.

background image mobile

Join the mailing list

Get the latest news and updates