Khata

Invoice financing for small Indian suppliers. A contract checks the e-invoice QR, investors pay USDT

Khata

Created At

ETHGlobal Mumbai

Project Description

Every B2B e-invoice in India is signed by the tax network, and the signed data sits in the invoice's QR code. A small supplier waits 60 to 90 days to be paid. An investor could advance the cash, but worries that the invoice is fake or edited, or that it was already sold to someone else.

Khata checks both on-chain. A contract on Whitechain verifies the RSA signature from the QR and lets each invoice be financed only once. The invoice becomes an ERC-20 note that only investors with a valid credential can hold. Investors pay in USDT, and the money goes straight to the supplier in the same transaction. At maturity the debtor pays the face value and the holders redeem.

Every wallet in the demo is a labelled demo wallet, and the full flow runs on invoices signed with a labelled "DEMO IRP (not government)" key. I built it on my own.

How it's Made

The contracts are Solidity 0.8.30, built and tested with Foundry, on Whitechain Sepolia. KhataRegistry checks the NIC RS256 signature with OpenZeppelin's RSA library (it uses the modexp precompile) and binds each invoice's nullifier once. AttesterRegistry holds the accepted attesters, credentials and revocations. KhataFactory creates one KhataNote, an ERC-20, per invoice. The note enforces the transfer rule itself: the receiver needs a valid credential, and nothing moves after maturity. Funding pays the prize USDT to the seller and delivers the notes in one transaction.

Arkiv (SDK 1.0.1, Rabdi testnet) holds credentials, revocations, marketplace listings and an attester heartbeat. The app reads them, but Whitechain cannot read Arkiv, so every credential is a signed message that the note contract checks again. Whitechain never has to trust Arkiv.

The front end is Vite and TypeScript with viem. Reads go through Anon-RPC's browser harness, over Tor with Nym as the fallback. The tests are Foundry for the contracts, 141 browser tests, and a live Playwright test that runs the whole lifecycle on the real chains. The demo wallets' keys stay on a small signer on the server, and the page never holds them.

There is also an optional zero-knowledge path. bindInvoiceZk accepts an UltraHonk proof (a Noir circuit, proved with Barretenberg in the browser in under 15 seconds) that a genuine NIC token with a given nullifier, value and seller exists, without revealing the tax IDs or the document number. It produces the same nullifier as the plain path, so an invoice can't be financed once through each. I treat it as a working experiment: the Noir dependencies it uses are unaudited.

background image mobile

Join the mailing list

Get the latest news and updates