Smart Contracts
All AsiliChain contracts deploy to Mantle Network (chainId 5000). Every contract is UUPS-upgradeable via OpenZeppelin’s proxy pattern, gated by a 3-of-5 multisig DEFAULT_ADMIN_ROLE.
Deployment Order
Section titled “Deployment Order”Deployment order is strict — each contract’s initializer requires addresses from previously deployed contracts.
| Step | Contract | Status | Type | Depends on |
|---|---|---|---|---|
| 1 | FarmerRegistry.sol | ✅ Implemented | UUPS Proxy | Nothing — deploy first |
| 2 | CreditScore.sol | ⏳ Specced | UUPS Proxy | Nothing — deploy second |
| 3 | BatchToken.sol | ⏳ Specced | ERC-1155 + UUPS | FarmerRegistry |
| 4 | TraceLog.sol | ⏳ Specced | UUPS Proxy | BatchToken |
| 5 | PurchaseOrder.sol | ⏳ Specced | UUPS Proxy | BatchToken + TraceLog |
| 6 | ProtocolFee.sol | ⏳ Specced | UUPS Proxy | Nothing — deploy independently |
| 7 | LendingVault.sol | ⏳ Specced | ERC-4626 + UUPS | All of the above |
Contract Responsibilities
Section titled “Contract Responsibilities”| Contract | Status | Core job | Key callers |
|---|---|---|---|
| FarmerRegistry | ✅ Implemented | Stores verified farmer identities, MAAIF IDs, GPS references, cooperative memberships | API (registration), BatchToken (mint-time check) |
| CreditScore | ⏳ Specced | Tracks repayment history. Permanent, public, portable. | LendingVault (repayment/default), API (delivery) |
| BatchToken | ⏳ Specced | ERC-1155 semi-fungible coffee batch token. Primary collateral. | API (mint), LendingVault (lock/unlock/burn) |
| TraceLog | ⏳ Specced | Records 8-stage custody journey per batch | API (stage updates), LendingVault (EXPORTED trigger) |
| PurchaseOrder | ⏳ Specced | Records buyer commitment. Upgrades collateral tier. | Buyer portal (create), Cooperative (confirm) |
| ProtocolFee | ⏳ Specced | Collects 4% margin per settlement. 3-of-5 multisig withdrawals. | LendingVault (collect on SETTLED) |
| LendingVault | ⏳ Specced | ERC-4626 vault. MFI deposits, loan origination, auto-repayment. | API (originate), TraceLog (EXPORTED event) |