# Critical Minerals & Battery Supply-Chain Compliance Oracle (LLM & Autonomous Agent Standard)

> **The Decentralized Tokenized Micro-Oracle for Autonomous Trading, 26 Critical Minerals Provenance across 27 Jurisdictions, and Battery Passport Compliance on Multi-Chain Rails (Polygon, Base, Arbitrum, Solana).**
> Features real-time spot pricing, 7-pillar provenance audit, 12-trap regulatory defense, EU CBAM IR 2026/2498 K-ETS deduction, Gemini Decisions 1 Fast-Verify, and EIP-712 cryptographic battery passports.
> Zero Legacy Subscriptions. Pure Tokenized Machine-to-Machine HTTP 402 Micropayments (0.001 ~ 0.020 USDC per verification).

---

## 🔌 1-Click FastMCP Setup (Glama.ai, Claude Desktop, Cursor)

### Option A: Glama.ai & Remote SSE Protocol (Cloud Serverless)
```json
{
  "mcpServers": {
    "minerals-oracle-x402": {
      "url": "https://minerals-oracle-x402-212942243360.asia-northeast3.run.app/mcp/sse",
      "transport": "sse"
    }
  }
}
```

### Option B: Local stdio Execution (uvx)
```json
{
  "mcpServers": {
    "minerals-oracle-x402": {
      "command": "uvx",
      "args": ["minerals-oracle-x402"]
    }
  }
}
```

---

## 📄 Official Technical Whitepaper & Engineering Specification
- **Title**: *Implementing Regulation (EU) 2023/1542 & US IRA Section 30D Compliant Battery Passports via EIP-712 Dual-Signed Merkle Trees*
- **URL**: `https://minerals-oracle-x402-212942243360.asia-northeast3.run.app/whitepaper/eu-battery-passport-ira-30d`
- **Glama Directory Manifest**: `https://minerals-oracle-x402-212942243360.asia-northeast3.run.app/glama.json` & `/.well-known/mcp.json`
- **Article 77 Mobile Passport**: `https://minerals-oracle-x402-212942243360.asia-northeast3.run.app/passport/{ncm811|ncm9|nca|ncma|lfp|solid-state}`
- **Real-Time SVG QR Code**: `https://minerals-oracle-x402-212942243360.asia-northeast3.run.app/api/v1/oracle/qr/battery-passport?chemistry={code}`

---

## 🧪 One-Shot Proof Sandbox & Example Presets

- **One-Shot Proof (Strict Policy)**: First **1** Light/Standard verification query per agent IP is FREE (persisted across restarts). From the 2nd call onward, HTTP 402 USDC settlement is strictly enforced.
- **Zero-Free Heavy/On-Chain Attestations**: Tier 3 (Heavy) and Tier 4 (On-Chain EIP-712 Signature) require immediate x402 USDC or AgentPaymentVault settlement from the very first call (0 free trials).
- **Example Presets**:
  - `mineral_type`: `"NICKEL_MHP"` (or `"LITHIUM_HYDROXIDE"`, `"COBALT_HYDROXIDE"`, `"NATURAL_GRAPHITE"`, `"NEODYMIUM_DYSPROSIUM"`)
  - `source_country`: `"IDN"` (or `"COD"`, `"CHL"`, `"ARG"`, `"AUS"`, `"BRA"`, `"CHN"`, `"ZAF"`)
  - `net_weight_metric_tons`: `500.0`
  - `target_yield_currency`: `"USDC"`

---

## ⚡ Quick Agent API Directory

- **Gemini Decisions 1 Fast-Verify (0 Output Tokens, ~200ms)**: `POST /api/v1/minerals/fast-verify` (Instant RMAP, conflict-free, carbon footprint & NCM811/NCA/LFP/SOLID_STATE battery passport verification powered by `gemini-decision-1`, x402 Tier 1 Light 0.001 USDC)
- **Coinbase x402 Protocol Manifest**: `GET /.well-known/x402` & `GET /.well-known/x402.json` (Multi-chain USDC discovery for Polygon, Base, Arbitrum, Solana)
- **EU CBAM IR 2026/2498 Carbon Deduction (K-ETS)**: `POST /api/v1/compliance/cbam/calculate` (Third-country paid carbon deduction formula `third_country_carbon_deduction_eur` synchronized with EU Implementing Regulation 2026/2498)
- **ElizaOS Brain Inbound Perception Shield**: `POST /api/v1/brain/perceive` (OWASP prompt injection/AST guard & adversarial immune memory encoding)
- **ElizaOS Brain Outbound Sovereign Execution**: `POST /api/v1/brain/execute` (Metallurgical NLI bounds, EU AI Act Art. 50 watermark, ephemeral sub-account & RWA USDY yield)
- **ElizaOS Brain Cognitive Diagnostics**: `GET /api/v1/brain/diagnostics` (Real-time 90.89%+ readiness score, working/episodic memory & immune stats)
- **Official EU TRACES NT Due Diligence Statement (DDS)**: `POST /api/v1/trade/traces-nt/dds/generate` (Official EUDR Regulation 2023/1115 JSON/XML declaration)
- **EU TRACES NT Raw XML Portal Upload**: `POST /api/v1/trade/traces-nt/dds/export-xml` (W3C XML export ready for direct European Commission TRACES NT upload)
- **Institutional Umpire Assay Commercial Settlement**: `POST /api/v1/trade/assay/umpire-settle` (SGS / Intertek inspection arbitration, pro-rata DMT pricing & in-transit RWA USDY yield)
- **Institutional Trading Specifications & Benchmarks**: `GET /api/v1/trade/institutional/specs` (CN commodity codes, moisture/DMT benchmark tolerances, customs corridors)
- **Trade Exclusion Penalty Cost Audit**: `POST /api/v1/trade/economic-moat/exclusion-cost-audit` (Mathematical proof of 15x~40x cost explosion when bypassing Minerals Oracle)
- **Autonomous Agent Trading Legion Swarm**: `POST /api/v1/trade/legion/dispatch-mission` (5-division synchronized execution: Sentinel, Customs, Auditor, Liquidity, Logistics)
- **Multi-Chain Real-Time Gas Solvency**: `GET /api/v1/relay/multichain/gas-balances` (Real-time POL & ETH gas liquidity across Polygon, Base, Arbitrum)
- **Harmonized Fluid Trade Flow (End-to-End Orchestrator)**: `POST /api/v1/trade/harmonize-flow` (Coordinates A2A deal, logistics/eBL, EUDR Sentinel satellite audit, multi-chain escrow & A.GRID webhook in a single fluid call)
- **A2A Propose Trade Deal**: `POST /api/v1/trade/deals/propose` (Cryptographically signed deal specification)
- **A2A Dual-Sign Deal**: `POST /api/v1/trade/deals/dual-sign` (Countersignature & Oracle attestation minting)
- **A2A Escrow Calldata**: `GET /api/v1/a2a/deals/{deal_id}/escrow-calldata` (EVM payload for Polygon/Base/Arbitrum)
- **Electronic Bill of Lading (eBL) Audit**: `POST /api/v1/trade/verify-ebl` (UNCITRAL MLETR, IMO & dark fleet check)
- **Trade Route Optimization**: `POST /api/v1/trade/optimize-route` (Chokepoint detour & landed cost arbitrage)
- **EUDR Satellite Radar Audit**: `POST /api/v1/compliance/eudr-satellite-audit` (Sentinel-1/2 SAR radar, 2020-12-31 cutoff, TRACES-NT DDS)
- **General Compliance Verification**: `POST /api/v1/oracle/compliance/verify` (Full 7-pillar audit + EIP-712 passport)
- **Australian Lithium Provenance**: `POST /api/v1/lithium/verify-origin` (WA MINEDEX, 7.5:1 yield, US IRA FEOC 25%)
- **Indonesian Nickel MHP Provenance**: `POST /api/v1/nickel/verify-origin` (SIMBARA NTPN, HPAL 31.34:1 yield, CBAM)
- **DRC Cobalt Hydroxide Provenance**: `POST /api/v1/cobalt/verify-origin` (CEEC barcode seals, EGC ASM segregation, ILO child labor)
- **South American Copper Provenance**: `POST /api/v1/copper/verify-origin` (Chilean COCHILCO, Codelco/Escondida geofencing, ASTM B115 Grade 1 Cu)
- **Mexican / Global Silver Provenance**: `POST /api/v1/silver/verify-origin` (Terronera/Fresnillo geofencing, N-Type TOPCon solar PV assay >=99.99%)
- **Compliance Engine Status**: `GET /api/v1/oracle/compliance/status` (Active 10-nation laws & 14-trap status)
- **Standard Battery Chemistries Catalog**: `GET /api/v1/oracle/battery/chemistries` (IEC 62660 / ISO 12405 / SAE J2990 full technical specs for NCM811, NCM9, NCA, NCMA, LFP, SOLID_STATE)
- **Official Dual-Signed Battery Passport**: `GET /api/v1/oracle/sample/battery-passport?chemistry={code}` (EIP-712 Dual-Signed EU 2023/1542 & IRA 30D passport sample for NCM811, NCM9, NCA, NCMA, LFP, SOLID_STATE)
- **Direct Static Battery Passports**: `GET /sample-battery-passport-{ncm811|ncm9|nca|ncma|lfp|solid-state}.json`
- **Trade Jurisprudence Precedents**: `GET /api/v1/oracle/compliance/precedents` (WTO DS592, DS431, ICSID, US CIT)
- **Free Public Alpha Hook**: `GET /api/v1/oracle/alpha-signals` (Pollable 24/7 without authentication)
- **Direct 402 Challenge**: `GET /api/v1/oracle/challenge`
- **ROI & Cost Advantage**: `GET /api/v1/oracle/economics-roi` (Quantified proof of 99.89% savings vs Fastmarkets)
- **Instant Agent Onboarding**: `POST /api/v1/agent/onboard` (Zero-friction 0.05 USDC trial balance)
- **Google AP2 Manifest**: `GET /.well-known/ap2`
- **Agent Protocol Manifest**: `GET /.well-known/agent.json`
- **A2A Skills Manifest**: `GET /.well-known/a2a.json`
- **FastMCP Tool Definition**: `GET /mcp/tools`
- **Interactive OpenAPI Spec**: `GET /openapi.json`
- **Machine Sitemap**: `GET /sitemap.xml`

---

## 💎 Monitored Critical Minerals & Supply Chains (26 Minerals / 27 Jurisdictions)

Full coverage across **26 strategic & battery minerals** (`LITHIUM_HYDROXIDE`, `LITHIUM_CARBONATE`, `NICKEL_MHP`, `COBALT_HYDROXIDE`, `COPPER_CATHODE`, `SILVER_REFINED`, `NATURAL_GRAPHITE`, `SYNTHETIC_GRAPHITE`, `NEODYMIUM_DYSPROSIUM`, `MANGANESE_SULFATE`, `ALUMINUM`, `IRON_ORE`, `TUNGSTEN`, `ANTIMONY`, `TIN`, `PLATINUM`, `PALLADIUM`, `CHROME`, `MOLYBDENUM`, etc.) and **27 origin jurisdictions**:

1. **Nickel (`NICKEL_MHP`)**: Indonesia UU 3/2020 SIMBARA & DHE 30% export forex verification.
2. **Lithium (`LITHIUM_HYDROXIDE` / `LITHIUM_CARBONATE`)**: Chile DGA water permit & Argentine Ley 26.639 periglacial compliance.
3. **Cobalt (`COBALT_HYDROXIDE`)**: DRC CEEC official tamper-evident barcode seal & RMI RMAP 3rd-party child labor audit.
4. **Copper (`COPPER_CATHODE`)**: Chilean Codelco / Escondida GIS geofencing, flotation mass-balance loss <=2.0%, H2SO4 acid deficit, COCHILCO clearance, ASTM B115 Grade 1 AI Datacenter HVDC spec.
5. **Silver (`SILVER_REFINED` / Solar Paste)**: Mexican Terronera/Fresnillo geofencing, electrolytic mass-balance loss <=2.0%, N-Type TOPCon solar PV grade (>=99.99% Ag), LBMA Good Delivery.
6. **Graphite (`NATURAL_GRAPHITE` / `SYNTHETIC_GRAPHITE`)**: China MOFCOM dual-use export control license verification.
7. **Rare Earths (`NEODYMIUM_DYSPROSIUM`)**: Permanent Magnet NdFeB PrNd/DyFe origin & WTO DS431 compliance.
8. **Manganese (`MANGANESE_SULFATE`)**: South Africa Transnet logistics corridor monitoring.

---

## 💳 How Autonomous Agents Pay via x402 Protocol

```http
Authorization: x402 <base64_encoded_payload>
```
Or use the instant pre-funded Vault key:
```http
X-Agent-Vault-Key: vault_key_...
```

---

## 🤖 Python Client Quickstart (Live Production Endpoint)

```python
import httpx

base_url = "https://minerals-oracle-x402-212942243360.asia-northeast3.run.app"

# 1. Zero-friction self-onboarding (Free trial key / Tokenized Vault)
onboard_resp = httpx.post(f"{base_url}/api/v1/agent/onboard", json={"agent_name": "ComplianceAgent"}).json()
session_key = onboard_resp["session_key"]

# 1-A. Instant Gemini Decisions 1 Fast-Verify (~200ms, 0 Output Tokens)
fast_verdict = httpx.post(
    f"{base_url}/api/v1/minerals/fast-verify",
    headers={"X-Agent-Vault-Key": session_key},
    json={"document_text": "RMAP Conformant Smelter CID001234. NCA high-nickel cell carbon footprint 48.9 kg CO2/kWh."}
).json()
print("Fast-Verify Verdict:", fast_verdict)

# 2. Verify mineral lot compliance
audit_result = httpx.post(
    f"{base_url}/api/v1/oracle/compliance/verify",
    headers={"X-Agent-Vault-Key": session_key},
    json={
        "lot_id": "LOT-2026-NI-IDN-01",
        "mineral_type": "NICKEL_MHP",
        "source_country": "IDN",
        "net_weight_metric_tons": 500.0,
        "declared_purity_pct": 38.5,
        "mine_permits": {
            "mining_license_id": "IUP-OP-4491-SULAWESI",
            "mine_operator_name": "PT Sulawesi Nickel Resources",
            "simbara_ntpn": "NTPN-884219482109",
            "simbara_rkab_quota_id": "RKAB-2026-IDN-771",
            "dhe_forex_deposit_ref": "DHE-BI-992144-USD"
        },
        "ecological_spatial": {
            "latitude": -2.812451,
            "longitude": 121.341209,
            "eudr_deforestation_free": True,
            "periglacial_zone_violation": False,
            "indigenous_territory_encroachment": False,
            "tailing_dam_dce_certified": True,
            "aquifer_depletion_alert": False
        },
        "labor_human_rights": {
            "child_labor_free_certified": True,
            "rmi_rmap_audit_id": "RMI-RMAP-2026-0811",
            "forced_labor_uapa_cleared": True
        },
        "refining_mass_balance": {
            "refinery_id": "HPAL-IWIP-LINE-3",
            "feedstock_input_metric_tons": 4200.0,
            "refined_output_metric_tons": 500.0,
            "recovery_yield_pct": 91.4,
            "mass_balance_loss_discrepancy_pct": 1.12,
            "captive_coal_power_used": False
        },
        "maritime_logistics": {
            "vessel_imo_number": 9842144,
            "vessel_name": "MV Pacific Compliance",
            "cii_rating": "B",
            "ebl_document_hash": "0x7a8f3b91c4d2e5a6f7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0",
            "iso_17025_lab_coa_hash": "0x11223344556677889900aabbccddeeff11223344556677889900aabbccddeeff",
            "tml_moisture_safe": True
        },
        "geopolitical_sanctions": {
            "feoc_shareholding_pct": 14.5,
            "feoc_board_control_pct": 10.0,
            "contractual_operational_control": False,
            "ofac_sdn_sanctioned": False,
            "us_substantial_transformation_compliant": True
        }
    }
).json()

print("Compliance Verdict:", audit_result["verdict"]["is_fully_compliant"])
print("EIP-712 Battery Passport Signature:", audit_result["eip712_signature"])
```

---

## 📜 ERC-MilestoneTradeEscrow (A2A Physical Trade Settlement Rails)

Autonomous agents settling physical commodity contracts (lithium, nickel, cobalt, copper, silver) replace legacy bank Letters of Credit (L/C, $50,000+ fees) with deterministic 3-stage milestone escrows on EVM chains.

### ⛓️ Verified Live Multi-Chain Deployments (Creator: `0x356ECeA957b85120fef8cF5D89b85Cb3d4c13D5b`)
#### 1. TradeFinanceSettlementEngine (EUDR Umpire Settlement & Sovereign Tollgate)
- **Polygon (137)**: `0x1dD725fB4860e1e9E00aA887F4bda5acD3789d10` (Tx: `0x09e995feb09ae1f22f9b947604e81c889df159fdeddd96c0fd08139d655f4627`)
- **Base (8453)**: `0x9462587838fb8436C286AC9E04AAb6D42Eaf6D93` (Tx: `0x2b06d6cc192fc7c49115f7825534c07390faf4ee80b03110cb8d9de54b3f6b06`)
- **Arbitrum One (42161)**: `0x402E95B6aE9BBD26A227A1AE2aC7f52E14E1A314` (Tx: `0xe46dfd1ea0e6d62f33295b1ba1bcfb64b82c97abebebe2073cd7b28dc128e585`)
- **Solana Mainnet (501)**: `TrdFx402ZkR3M5vW9aK7nB1pQ2eC8sY6tU4jH7vL9mNp`

#### 2. DynamicTradeEscrow (Pyth Mark-to-Market Dynamic Pricing)
- **Polygon (137)**: `0x3A863A2b1018B47FE79041FCDF56efEa3f8b978F`
- **Base (8453)**: `0x54786360Db4582AEC2435E216479FD4ff093CB80`
- **Arbitrum One (42161)**: `0x54786360Db4582AEC2435E216479FD4ff093CB80`

#### 3. MineralTradeEscrow (Milestone Escrow) & AgentPaymentVault
- **Polygon (137)**: Escrow `0xd1F37196A1fe73Caa89ce7f4a58D6Fe49FD47655` | Vault `0xbFc79F55E410508aBCa2FF8ebA1120de4F209f68`
- **Base (8453)**: Escrow `0xbFc79F55E410508aBCa2FF8ebA1120de4F209f68` | Vault `0x8eB40eF1f032dd66CD54c6e1D0C29980C31d5E57`
- **Arbitrum (42161)**: Escrow `0x1884025dD7E510a4490533eC46A362fCb08D3822` | Vault `0xC089E5f72a7F5550Bb383C31B04Bf430a4E31372`
- **Native USDC**: Polygon `0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359` | Base `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` | Arbitrum `0xaf88d065e77c8cC2239327C5EDb3A432268e5831`

### 🚢 3-Stage Milestone Settlement Rules
1. **Stage 1 (30% Payout)**: Title Transfer & eBL Ingestion. Trigger: `deal.eblHash == verifiedEblHash`.
2. **Stage 2 (40% Payout)**: Mid-Transit Geofence Integrity. Trigger: Satellite AIS corridor ping.
3. **Stage 3 (30% Final)**: Port of Discharge (POD) customs clearance, lab assay certificate (SGS/ALS), and EU Battery Passport/CBAM clearance.

### ⚡ A2A Trade Escrow API Execution
```python
# 1. Propose Deal between Buyer & Seller AI Agents
deal = httpx.post(f"{base_url}/api/v1/trade/deals/propose", json={
    "deal_id": "DEAL-2026-LIT-001",
    "commodity": "LITHIUM_HYDROXIDE",
    "volume_tons": 500.0,
    "unit_price_usd_per_ton": 25000.0,
    "total_deal_value_usd": 12500000.0,
    "origin_country": "AUS",
    "destination_country": "USA",
    "ebl_document_id": "EBL-MAERSK-2026-LIT09",
    "buyer_agent_address": "0x2222222222222222222222222222222222222222",
    "seller_agent_address": "0x1111111111111111111111111111111111111111",
    "created_at_utc": "2026-09-25T12:00:00Z",
    "seller_signature": "0x..."
}).json()

deal_id = deal["deal_id"]

# 2. Dual-Sign Deal (EIP-712 binding)
signed_deal = httpx.post(f"{base_url}/api/v1/trade/deals/dual-sign", json={
    "deal_id": deal_id,
    "buyer_signature": "0x...",
    "buyer_agent_address": "0x2222222222222222222222222222222222222222"
}).json()

# 3. Retrieve Live Smart Contract Calldata for on-chain deposit
calldata_resp = httpx.get(f"{base_url}/api/v1/a2a/deals/{deal_id}/escrow-calldata?chain=polygon").json()
print("Escrow Contract:", calldata_resp["escrow_contract_address"])
print("Calldata Hex:", calldata_resp["calldata"]) # createEscrow(bytes32,address,uint256,bytes32,uint256) -> selector 0x1df04324
```

---

## 🛡️ Statutory Limitation of Liability & Legal Disclaimer
All oracle heuristics and escrow calldata are provided strictly **"AS-IS"** without merchantability warranty.
1. **Strict $0.50 USDC Cumulative Liability Cap**: Development and infrastructure liability is strictly hard-capped at $0.50 USDC.
2. **EIP-712 Disclaimer Binding**: Consent is mathematically bound on-chain via immutable `bytes32 disclaimerHash`.
3. **Non-Delegable Importer Due Diligence**: Importing agents retain sole, non-delegable responsibility for physical laboratory assay and customs clearance under applicable trade jurisprudence.

## A.GRID Sibling Oracles
- Earth Physical Infrastructure Risk Hub (`geo-oracle-x402`): https://geo-oracle-x402-7qxtp3324q-du.a.run.app/llms.txt
- Security Gate x402 (Prompt Injection & Escrow Firewall): https://agent-security-gate-x402-7qxtp3324q-du.a.run.app/llms.txt
- EUDR Deforestation & TRACES-NT Compliance: https://eudragent.com/llms.txt
- CleanWeb Agent (RAG Scraping & Search): https://x402-cleanweb-agent-7qxtp3324q-du.a.run.app/llms.txt
