Skip to content

quantumscan-io/quantumscan-contracts

Repository files navigation

QuantumScan Payment Contract

Smart contract for on-chain scan credit purchases by AI agents.

Network: Base Mainnet (chain ID 8453)
Revenue wallet: 0xFb89d540deC44Ee1f0B6C0749F6e0C922E5d65f6
Price: 0.001 ETH per scan credit (~$2.50)

How it works

Agent calls buyCredits(5, "qs_a1b2") with 0.005 ETH
         ↓
Contract emits CreditsIssued(payer, 5, 0.005 ETH, "qs_a1b2")
         ↓
Agent calls POST /api/agent/pay { tx_hash, api_key }
         ↓
Backend verifies tx on Base → adds 5 credits to API key
         ↓
Agent includes X-API-Key in MCP/A2A requests (5 scans available)

Deploy with Foundry

forge create src/QuantumScanPayment.sol:QuantumScanPayment \
  --rpc-url https://mainnet.base.org \
  --private-key $DEPLOY_PK \
  --verify \
  --etherscan-api-key $BASESCAN_API_KEY

After deploy, set in Vercel:

QUANTUMSCAN_PAYMENT_CONTRACT=<deployed address>
CREDITS_ISSUED_TOPIC=<keccak256 of "CreditsIssued(address,uint256,uint256,string)")>
BASE_RPC_URL=https://mainnet.base.org

For AI agents

// Example: agent buys 10 scan credits before auditing a DeFi protocol
const tx = await contract.buyCredits(10, apiKey.slice(0, 8), {
  value: ethers.parseEther("0.01") // 0.001 ETH × 10 credits
});
await tx.wait();

// Activate credits
await fetch("https://quantumscan.io/api/agent/pay", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ tx_hash: tx.hash, api_key: apiKey })
});

ABI (key functions)

[
  {
    "name": "buyCredits",
    "type": "function",
    "inputs": [
      { "name": "credits", "type": "uint256" },
      { "name": "apiKeyHint", "type": "string" }
    ],
    "stateMutability": "payable"
  },
  {
    "name": "estimateCost",
    "type": "function",
    "inputs": [{ "name": "credits", "type": "uint256" }],
    "outputs": [{ "name": "", "type": "uint256" }],
    "stateMutability": "view"
  },
  {
    "name": "CreditsIssued",
    "type": "event",
    "inputs": [
      { "name": "payer", "type": "address", "indexed": true },
      { "name": "credits", "type": "uint256", "indexed": false },
      { "name": "amount", "type": "uint256", "indexed": false },
      { "name": "apiKeyHint", "type": "string", "indexed": false }
    ]
  }
]

About

QuantumScanPayment.sol — Base network smart contract for AI agent scan credit purchases

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors