Developer documentation

M2M Developer Documentation

Reference for Anchor programs, the Dual-Verification Oracle, and client integration. Sections use URL anchors for deep linking (for example /docs#smart-contracts).

Introduction

Welcome to the M2M Developer Documentation. The M2M stack empowers developers, hardware manufacturers, and node operators to interface with the world's first Solana-native DePIN for machine-to-machine energy transfer. This documentation covers our on-chain Anchor programs, the Dual-Verification Oracle middleware, and the TypeScript SDK required to build client applications and integrate charging hardware.

The M2M project is open source: you can inspect, fork, and contribute to the public repositories as they are published; protocol details here match what we ship in those repos.

Smart Contracts (Solana Escrow)

The M2M protocol relies on trustless smart contracts to manage session funding, verification, and settlement. The core protocol is written in Rust using the Anchor framework.

V1 Devnet program details

V1 programs are currently live on Solana Devnet. Mainnet program IDs will be published following our Phase 1 security audits.

Program IDDevnet
M2MEscrow1111111111111111111111111111111

Note: Devnet placeholder. Replace with audited mainnet ID after deployment.

Core instructions

  • initialize_escrow — Locks the estimated USDC session cost from the driver's wallet.
  • verify_presence — Authenticates the physical QR code scan, securely linking the driver's cryptographic signature to the physical node.
  • settle_session — Triggered by the Dual-Verification Oracle to release funds to the host and refund any unspent USDC to the driver.
  • dispute_resolution — Fallback mechanism for unmatched hardware and telematics reports.

Hardware Oracle API (V2)

The M2M Oracle is the trust boundary between the physical world and the Solana blockchain. It accepts cryptographically signed webhook payloads from charger backends, validates the QR "Proof of Presence", and drives the escrow settlement only when vehicle telemetry and charger data agree.

1. Session initialization (Scan-to-Authenticate)

When a driver scans the host's QR code, the client SDK requests session initialization. The Oracle verifies the escrow lock and authorizes the hardware to energize.

POST /api/v2/oracle/session-initJSON
{
  "charger_id": "m2m_node_8841",
  "session_token": "sess_9x8f2a1...",
  "qr_proof_signature": "5Kj8f...Ed25519_sig",
  "escrow_pubkey": "7xVp...SolanaAddress",
  "hardware_status": "authorized_pending_plug",
  "timestamp": "2026-04-11T12:00:00Z"
}

2. Dual-verification settlement payload

Upon session completion, the Oracle reconciles the data. Settlement is only authorized if the delta between hardware output and vehicle intake is within the accepted physical loss tolerance (typically < 2%).

POST /api/v2/oracle/session-settleJSON
{
  "session_id": "sess_9x8f2a1...",
  "charger_reported_kwh": 42.5,
  "vehicle_reported_kwh": 41.8,
  "delta_status": "within_tolerance",
  "settlement_amount_usdc": 14.50,
  "host_wallet": "Host...Address",
  "driver_wallet": "Driver...Address"
}

SDK setup

The official @m2m/sdk (npm) provides a unified interface for the entire session lifecycle, integrating seamlessly with @solana/wallet-adapter-react.

Installation & configuration

The package handles wallet signing, RPC connections, and WebSocket subscriptions to the Oracle for real-time charging status. Configure your Solana RPC (Devnet for V1), wallet adapter, and Oracle base URL via your environment variables. Full installation steps, React hooks (useM2MSession), and boilerplate examples will ship with the public beta release.