# CompliR > Counterparty-risk oracle for USDC on Arc mainnet. Signed, graded verdicts before money moves. ## Integration prompt You are integrating CompliR into this codebase. CompliR (https://trycomplir.xyz) is a counterparty-risk oracle for USDC on Arc mainnet (chain 5042): before money moves to or from an address, it returns a graded, signed verdict. Docs: https://trycomplir.xyz/docs GOAL Add a CompliR check at every point where this codebase sends USDC to an address it did not create itself, or accepts USDC from an outside payer. Do not change any existing behaviour when CompliR is disabled. STEP 1 - FIND THE MONEY FLOWS (report them to me before editing) Search for: transfers, withdrawals, payouts, refunds, escrow releases, invoice payments, x402/payment middleware, "payTo", "toAddress", "destinationAddress", "transfer(", "withdraw", "release(". For each, note: file:line, direction (outbound/inbound), who controls the address (user-typed? our own wallet?), and amount source. Skip transfers between wallets this app itself created. STEP 2 - THE API - Free verdict, always answers (no payment, no key): GET https://trycomplir.xyz/api/v1/attestation/
→ 200 {address, tier, score, reasons[{code, weight, evidence}], recommendedLimits {maxPerTxUsdc, maxPerDayUsdc}, rationale, eddRequested[], edd {id, url, status} | null, nextRescreenAt, attestation {signature, validUntil, registryTx, typedData}, decisionId, screenedAt, expired, refreshing, source}. It runs the full screen (sanctions, Circle USDC blocklist, two-hop funder trace, analyst). An address never seen before is screened on demand: the first call takes ~20-60 s (source "fresh"); later calls answer in < 1 s (source "store"). Concurrent calls for one address share one screen. It does not return 404 for unknown addresses. If the stored verdict has expired (attestation.validUntil < now) it is still returned at once with expired: true and refreshing: true while CompliR re-screens in the background; the next call gets the fresh verdict. - Paid screen, optional (~0.01 USDC via x402): POST https://trycomplir.xyz/api/v1/screen body {"address":"0x…","amountUsdc":,"clientId":"","payeeBook":[{"label":"…","address":"0x…"}]} Use it only when you need context the GET cannot take: amountUsdc (amount-aware limits and a guarantee bond on LOW), payeeBook (lookalike / address-poisoning check against your known payees), a forced re-screen right now, or attribution by clientId. Unpaid it returns HTTP 402 with x402 v2 requirements (network eip155:5042, asset USDC 0x3600000000000000000000000000000000000000). Pay with the SDK (packages/sdk in github.com/mrnetwork0001/CompliR: class CompliR with verdict()/screen()/watch()) or any x402 v2 client. The PAYMENT-SIGNATURE envelope and a worked signing example are at https://trycomplir.xyz/docs/x402#payload. - Watch an address (re-graded continuously): POST https://trycomplir.xyz/api/v1/watch body {"address":"0x…","webhookUrl":"https://…"} → you later receive POST {type:"tier.changed", address, from, to, verdict} with header x-complir-event: tier.changed. - Field notes: attestation.validUntil (same value as attestation.typedData.message.validUntil) is when the signature lapses: HIGH 1 h, MEDIUM 24 h, LOW 7 d. nextRescreenAt is when CompliR plans to re-grade. registryTx is null until the on-chain mirror lands seconds later; only on-chain callers need it. edd is present mainly on MEDIUM; a HIGH sanctions or blocklist hit has none. - On-chain (Solidity, optional): ICompliR(0xA82EDb5e111c31C63E06EF0007f2fa1a9e7EB30d).isAllowed(payee, ICompliR.Tier.MEDIUM) returns true only for a non-expired LOW/MEDIUM attestation. Interface: contracts/src/ICompliR.sol in the CompliR repo. STEP 3 - POLICY TO IMPLEMENT - Use the free GET for every check. Add the paid POST only where amount-aware limits or payee-book lookalike checks matter (for example large payouts). Most integrations need no payer key. - Outbound payment to an outside address: HIGH → block. Return a clear error ("This address is flagged as high risk by CompliR: ") and log decisionId. MEDIUM → allow at most recommendedLimits.maxPerTxUsdc; if the request is larger, block or require manual approval (pick the pattern this codebase already uses). If edd.url is present, surface it. LOW → allow. - Inbound payer (someone paying us): HIGH → refuse the request (or refund if already settled); otherwise proceed. - New user/creator/vendor wallet at signup: screen it; if HIGH, flag the account; register a watch so later changes reach us. - Cache each verdict per address until min(attestation.validUntil, nextRescreenAt). An expired verdict is still the latest answer: use its tier and fetch again later (the GET refreshes it for free). - Calling the GET: send ?wait=8 (seconds) on hot paths. If the address is new and its screen takes longer, you get HTTP 202 {status:"screening", retryAfterSeconds} with a Retry-After header; the screen keeps running server-side. Without ?wait the server waits up to 25 s and then answers 503 SCREENING_IN_PROGRESS with Retry-After (never a 2xx without a verdict). Set your client timeout above the wait (e.g. 15 s with ?wait=8, 35 s without). Use 120 s for the POST. - Rate limit: only new first-sight screens are limited (30 per minute per IP); reads of known addresses are unlimited. Every response carries RateLimit-Policy; first-sight responses add RateLimit-Limit / RateLimit-Remaining / RateLimit-Reset. Over the limit you get 429 RATE_LIMITED with Retry-After. - RETRY CONTRACT (required): a check is "unreachable" only after retries. On 202, 503 SCREENING_IN_PROGRESS or 429: wait the Retry-After seconds, then GET again (up to ~60 s in total); do not use fast backoff on these. On 502/503/504 without Retry-After, a network error or a client timeout: retry up to 3 times with backoff (1 s, 2 s, 4 s); transient failures usually clear in under a second, and a retry after a timeout returns the finished screen. Do not retry 400/404. IMPORTANT, because the recommended fail mode is closed: 202, 429 and 503 SCREENING_IN_PROGRESS are NOT oracle failures. Implement the wait-and-retry for them before (or together with) fail-closed; otherwise a rate limit or a slow first sight becomes a blocked legitimate payment. Cap the total wait (e.g. 20-30 s) so a payment request cannot hang, and only then apply the fail mode. Retrying the same address while its screen runs costs no rate-limit budget (only starting a new first-sight screen does). - If CompliR is still unreachable after retries: follow env COMPLIR_FAIL_MODE. Default "closed" for outbound payments (block or queue for manual review, and log it loudly); "open" (allow and log a warning) only where blocking would do more harm, such as small inbound payments. Never fail open silently: record decisionId=null and the error with the payment. STEP 4 - IMPLEMENTATION RULES - Put all CompliR code in ONE new module (e.g. lib/complir.ts or complir.py) exposing checkAddress(address, {amountUsdc, direction}) → {allowed, tier, maxUsdc, reason, decisionId}. Call it from the money-flow points; keep each call site to a few lines. - Config via env: COMPLIR_URL (default https://trycomplir.xyz; empty = disabled → checkAddress returns allowed:true), COMPLIR_FAIL_MODE, COMPLIR_CLIENT_ID, and COMPLIR_PAYER_PRIVATE_KEY only if you add paid screens (most integrations do not). Add them to .env.example with comments. - Match the codebase's language, style, lint rules and error-handling patterns. Lowercase addresses before calling. Never log private keys. - Store decisionId alongside the payment/withdrawal record so the decision can be replayed at https://trycomplir.xyz/log/. - Add tests with the HTTP calls mocked: HIGH blocks, MEDIUM caps, LOW passes, disabled = no-op, 202 then 200, 429 then 200 and 503 SCREENING_IN_PROGRESS then 200 each wait Retry-After and succeed (the payment is screened, not blocked), two 502s then 200 succeeds, persistent failure follows fail mode. - Add a short README section "Counterparty screening (CompliR)". STEP 5 - VERIFY Run the existing test suite and type checks. Then a live smoke test against https://trycomplir.xyz: - 0x098b716b8aaf21512996dc57eb0615e2383e2f96 (a real OFAC-listed wallet) must be blocked as HIGH. - A normal active wallet should pass as LOW. Report: the money flows found, files changed, the policy at each point, test results, and anything you were unsure about.