Documentation

Devnet integration guides and Phase 1 receipt-settlement specification.

Quickstart

The devnet contract path is Solana-native. SDK examples on this page are wrapper targets: the wrapper must build the compact receipt fields, proof instruction, token delegate, PDAs, and masterpool accounts before sending the transaction.

Install

npm install @clawfarm/sdk

Configure devnet

import { ClawFarm } from '@clawfarm/sdk'

const cf = new ClawFarm({
  cluster: 'devnet',
})

SDK wrapper target

A contract-aligned wrapper should prepare receipt hashes first, then submit the prepared receipt with a gateway-capable signer proof and payer payment delegate.

TypeScript

const prepared = await cf.receipts.prepare({
  providerWallet,
  payer: connectedWallet.publicKey,
  payerUsdcToken,
  requestNonce,
  metadata: {
    model: 'model-l-001',
    unit: 'tokens',
  },
  promptTokens: 420,
  completionTokens: 180,
  chargeUsdc: '0.025000',
})

const receipt = await cf.receipts.submit(prepared, {
  gatewaySigner,
  paymentDelegate,
})

console.log(receipt.receiptPda)
console.log(receipt.economicRecordPda)

Python

prepared = cf.receipts.prepare(
    provider_wallet=provider_wallet,
    payer=connected_wallet.public_key,
    payer_usdc_token=payer_usdc_token,
    request_nonce=request_nonce,
    metadata={"model": "model-l-001", "unit": "tokens"},
    prompt_tokens=420,
    completion_tokens=180,
    charge_usdc="0.025000",
)

receipt = cf.receipts.submit(
    prepared,
    gateway_signer=gateway_signer,
    payment_delegate=payment_delegate,
)

Rust

let prepared = cf.receipts().prepare()
    .provider_wallet(provider_wallet)
    .payer(connected_wallet.pubkey())
    .payer_usdc_token(payer_usdc_token)
    .request_nonce(request_nonce)
    .metadata_model("model-l-001")
    .metadata_unit("tokens")
    .prompt_tokens(420)
    .completion_tokens(180)
    .charge_usdc("0.025000")
    .build()
    .await?;

let receipt = cf.receipts()
    .submit(prepared)
    .gateway_signer(gateway_signer)
    .payment_delegate(payment_delegate)
    .send()
    .await?;

Current devnet contract shape

The SDK wrapper target maps to `attestation.submit_receipt`. The contract does not accept model IDs or endpoint metadata as direct receipt fields; those values belong in metadata that the wrapper hashes.

SubmitReceiptArgs
request_nonce_hash, metadata_hash, prompt_tokens, completion_tokens, charge_atomic, receipt_hash.
Receipt hash
Built with the clawfarm:receipt:v2 domain, provider wallet, payer, Test USDC mint, token counts, and charge amount.
Proof instruction
The transaction includes an immediately preceding ed25519 verification instruction for the configured gateway-capable signer over receipt_hash.
Payment delegate
The payer authorizes bounded Test USDC movement through the payer token account and payment delegate signer.
Masterpool accounts
The wrapper supplies config, provider account, epoch cursor/state, receipt economic record, treasury vault, and provider pending vault accounts.

Gateway wrapper target

A gateway API may collect receipt metadata, but it must create or return a Solana transaction that follows the current devnet contract shape. It is not a contract-native REST endpoint.

POST /devnet/receipt-transactions
{
  "providerWallet": "<provider-wallet>",
  "payer": "<payer-wallet>",
  "payerUsdcToken": "<payer-usdc-token>",
  "requestNonce": "<client-generated-nonce>",
  "metadata": {
    "model": "model-l-001",
    "unit": "tokens"
  },
  "promptTokens": 420,
  "completionTokens": 180,
  "chargeUsdc": "0.025000"
}

The gateway wrapper response should contain a transaction or signing payload that includes the ed25519 proof instruction and `attestation.submit_receipt` accounts.

Gateway selection

Applications or gateways choose the provider before receipt submission. The on-chain programs record the provider wallet, payer, payment amount, token usage, receipt hash, and epoch weights.

Directory
Endpoint, model, price, and limits are off-chain operator metadata.
Selection
Any app may choose a provider wallet before submitting a compact receipt.
Settlement
The contract settles only the compact receipt facts and configured vault accounting.

Provider

Providers register one wallet-controlled ProviderAccount and stake Test USDC on devnet.

Register
Masterpool registration records the provider wallet, stake amount, and active status. Endpoint, model, and pricing metadata live in the off-chain gateway or operator directory layer.
Stake
Devnet provider stake: 100 Test USDC.
Pricing
Input, output, request, image, second, or task units.
Receipts
A configured provider or gateway signer signs the compact receipt hash before on-chain settlement.

The masterpool account does not store endpoint infrastructure; applications and gateways bind endpoint metadata outside the on-chain provider account.

Models

Model identifiers are off-chain labels used by applications and gateway directories. The current on-chain receipt stores compact hashes, wallet identities, token counts, payment amount, and epoch weights.

model-l-001
Language model identifier supplied as receipt metadata outside the ProviderAccount.
model-i-001
Image model identifier supplied as receipt metadata outside the ProviderAccount.
model-v-001
Video model identifier supplied as receipt metadata outside the ProviderAccount.

Protocol

ClawFarm Phase 1 is a receipt-driven settlement protocol for AI inference on Solana.

Architecture

WALLET / APP LAYER
  Users · Builders · Agents · Provider operators

OFF-CHAIN DIRECTORY
  Provider choices · Model labels · Endpoint metadata · Price metadata

ATTESTATION LAYER
  ProviderSigner records · Compact receipts · Challenge lifecycle · Finalization authority

MASTERPOOL LAYER
  ProviderAccount · Test USDC split · Epoch weight · Locked CLAW streams · Vault accounting

Smart contracts

clawfarm-attestation
Verifies compact receipts, stores receipt status, opens challenges, and finalizes receipt economics through CPI.
clawfarm-masterpool
Owns reward, treasury, provider stake, provider pending revenue, and challenge-bond vault accounting.
ProviderAccount
Stores provider wallet, stake state, pending revenue counters, challenge counters, and registration status.
ReceiptEconomicRecord
Stores immutable receipt-time payment split, epoch weight, challenge deadline, and economic status.

Receipt lifecycle

1. Wallet authorizes bounded Test USDC settlement through a payer token delegate.
2. App or gateway prepares request_nonce_hash, metadata_hash, charge_atomic, and receipt_hash.
3. A configured gateway-capable signer signs receipt_hash, and the transaction includes the ed25519 proof instruction.
4. Attestation submits the compact receipt and records payment through masterpool CPI.
5. Masterpool splits Test USDC into provider-pending and treasury vaults.
6. Receipt survives or fails the challenge window.
7. Finalized receipts activate buyer/provider epoch weight and release provider pending USDC.
8. Finalized epochs create locked CLAW streams for claimable rewards.

Phase 1 economics

USDC split
97% provider-share Test USDC, 3% treasury Test USDC on the current devnet deployment.
Provider release
Provider-share USDC remains pending until attestation marks the receipt finalized.
Epoch reward
Receipts record buyer and provider epoch weight; rewards are not paid directly per call.
Pool split
30% buyer-side CLAW pool and 70% provider-side CLAW pool by finalized epoch weight.
Reward lock
Claimed epoch rewards create locked streams using the configured lock-days snapshot.

Challenges

Bond unit
Challenges are bonded in CLAW.
Rejected challenge
The challenger bond is burned and the receipt remains economically valid.
Accepted challenge
The bond is returned, provider-share USDC is refunded to the payer, reward-vault transfer and burn economics apply, and activated receipt weight is removed when applicable.
Timeout stance
Receipt economics finalize only through the attestation lifecycle after the configured challenge window.

Devnet parameters

Cluster
Solana devnet
Masterpool program
DWbzvr2F8hKquw7cXQqhpEc8JnJ1covmP6f28Rwmy15q
Attestation program
BwRMqumgiHbeMhG9xs1a76vUjmprrokr6WsPCzhz3pKK
CLAW mint
EW7npwHnVtTXvimde3Zj6dHX4mWbSAb5zkkHCrvkC8ui
Test USDC mint
Hpq3GKSHa6rX9pGSRw2Gvoz6AbP16GMtHPVMxLr7P553
Provider stake
100 Test USDC
Challenge bond
Configured CLAW bond on devnet.
Challenge window
Short devnet window for rollout testing; mainnet timing remains pending until mainnet config is deployed.
Reward lock
Configured lock-days snapshot; current Phase 1 default is 180 days.

Reproducibility

Contract state and builds should be verified against the current clawfarm-masterpool repository.

Devnet state check

npx clawfarm phase1 status --cluster devnet

Contract build

git clone <contract-source-url>
cd clawfarm-masterpool
anchor build
anchor test

Resources

Reference files and mirrors for developers, providers, and auditors.

Contract source
Protocol facts derive from the current clawfarm-masterpool repository.
Phase 1 economics
Receipt settlement, epoch weight, challenge, and reward-stream accounting.
Website source
Repository URL publishes after protocol organization migration.