gitmyhub

Arc-Netting

TypeScript ★ 0 updated 10d ago

A demo that nets out chains of B2B debts off chain and settles only the leftover balance in USDC on a test blockchain.

TypeScriptSolidityReactViteWagmiViemFoundrysetup: moderatecomplexity 3/5

ArcNetting is a project built for the Arc Testnet that tackles a simple but expensive problem in business to business payments. When companies owe each other money in a chain, like A owes B, B owes C, and C owes A, settling each debt separately means moving the full gross amount every time, which ties up a lot of cash. This project nets those obligations together first, so only the leftover balance actually moves. In the example used by the project, three payments worth 280 USDC total get reduced to a single 20 USDC transfer, a savings of almost 93 percent.

The system has two main parts. A smart contract called NettingHub, written in Solidity and deployed on the Arc Testnet, keeps track of who owes what and requires both sides of a debt to confirm it before it counts. It does not do the actual math of figuring out the smallest set of payments needed. That work happens off chain in a TypeScript engine that looks at all the obligations, matches the biggest debtors against the biggest creditors, and works out the minimum number of transfers needed to settle everyone up. An operator then submits that result to the contract, which checks it and moves the final USDC amounts.

The repository also includes a frontend built with Vite, React, and libraries called Wagmi and Viem for connecting to blockchains, giving users a way to register obligations, confirm them, and watch settlements happen. There is a working demo already live on the Arc Testnet showing three parties settling a real cycle of debts on chain, along with the test suite, deployment scripts, and documentation needed to reproduce it.

This project would be useful to someone curious about how netting reduces the amount of money that has to move between businesses, or to a developer wanting a small working example of combining an on chain settlement contract with an off chain calculation engine. The code is open source under the MIT license, and setup instructions cover building and testing the contracts, running the netting engine, and deploying both the contract and the frontend.

Where it fits