Local development
Run the tests, a local chain with a MUSD model, and deploy to testnet.
Par is three Solidity contracts, a keeper and this Next.js app. Everything runs locally against a model of the MUSD rules Par relies on.
Repository layout#
| Folder | What it holds |
|---|---|
contracts/ | ParFactory, ParVault, ParCircuit, ParMarket, a MUSD model for tests (contracts/mocks), Hardhat tests and deploy scripts. |
keeper/ | The keeper bot (TypeScript, viem). |
web/ | This app (Next.js 14, wagmi, Reown AppKit, Mezo Passport). |
scripts/ | dev-local.sh, the one-command local demo. |
Run the tests#
git clone https://github.com/linoxbt/par && cd par/contractsnpm installnpm testThe suite runs against the MUSD model. To run it against the real MUSD contracts, which the script clones and deploys on its fixtures:
npm run test:musdOne-command local demo#
./scripts/dev-local.shThis starts a Hardhat node, deploys the MUSD model and Par, seeds the Circuit demo (three shops, a 600 s cycle with a 60 s settle window) and a guarantee, then starts the keeper and the app. Open http://localhost:3000, connect a wallet to http://127.0.0.1:8545 (chain 31337) and import a Hardhat test key: account #0 owns the guarantee demo vault, accounts #1 to #3 are the Circuit shops.
On the local chain you can skip ahead to a due date or a cycle close:
curl -s -X POST localhost:8545 -H 'content-type: application/json' \ -d '{"jsonrpc":"2.0","id":1,"method":"evm_increaseTime","params":[300]}'Deploy to Mezo testnet#
cd contractsMATSNET_PRIVATE_KEY=<deployer key> npm run deploy:matsnetThe script deploys ParFactory (with stressBps = 4000 and targetIcr = 1.6e18) ParCircuit and ParMarket, writes contracts/deployments/matsnet.json, and prints the frontend and keeper environment. npm run abis then regenerates web/lib/deployments.ts, which these docs read their addresses from.
Regenerate ABIs#
cd contracts && npm run abisThis compiles and writes web/lib/abi.ts, keeper/src/abi.ts and web/lib/deployments.ts.
Run the app#
cd webnpm install --legacy-peer-depsNEXT_PUBLIC_CHAIN=testnet \NEXT_PUBLIC_FACTORY=<factory> \NEXT_PUBLIC_CIRCUIT=<circuit> \NEXT_PUBLIC_MARKET=<market> \NEXT_PUBLIC_FACTORY_BLOCK=<block> \NEXT_PUBLIC_REOWN_PROJECT_ID=<project id> \npm run devThe Reown project id is public (create one at cloud.reown.com). The marketing, docs and legal pages are server-rendered and load no wallet code.
Seed the testnet demo#
contracts/scripts/seed-demo.ts creates three shop vaults with clearing lines, a circle with a 600 s cycle and 60 s settle window, and a tangled invoice graph (2,900 MUSD gross, 100 MUSD net). It needs an admin key and three shop keys; see the header of the script for the variables.