API Reference

xAI Blockchain API

Seal & verify data integrity on-chain

xAI Blockchain provides two simple endpoints to anchor a data fingerprint on the ledger and verify its integrity later. Data is canonicalized (canonical JSON) then keccak256-hashed before being written on-chain — only the fingerprint is stored, never the raw data.

Base URL

https://blockchain.xai.io.vn

Authentication

The public sandbox runs in `mock` mode (simulated tx/hash, no wallet needed). The on-chain build signs with a relayer key stored in a Cloudflare secret — no keys on the client. Rate limit ~5 req/min/IP recommended.

Ledger

POST /api/anchor

Anchor a data fingerprint on the ledger

Auth: None (public sandbox)

Body parameters

FieldTypeDescription
scenario* 'e_invoice' | 'fund_disbursal' | 'kyc_profile' Business scenario type
payloadId* string Business identifier, e.g. `INV-2026-001`
dataFields* object Key-value data fields to anchor

Example request

curl -X POST 'https://blockchain.xai.io.vn/api/anchor' \
  -H 'Content-Type: application/json' \
  -d '{
    "scenario": "e_invoice",
    "payloadId": "INV-2026-001",
    "dataFields": { "taxId": "0312345678", "amount": 500000000, "issuedAt": "2026-05-30" }
  }'
const res = await fetch('https://blockchain.xai.io.vn/api/anchor', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    scenario: 'e_invoice',
    payloadId: 'INV-2026-001',
    dataFields: { taxId: '0312345678', amount: 500_000_000, issuedAt: '2026-05-30' },
  }),
});
const { dataHash, explorerUrl } = await res.json();

Example response

{
  "success": true,
  "mode": "mock",
  "dataHash": "0x9af1…c20b",
  "transactionHash": "0x4e8d…7a31",
  "blockNumber": 14283910,
  "timestamp": 1769990400,
  "scenario": "e_invoice",
  "payloadId": "INV-2026-001",
  "explorerUrl": "https://sepolia.basescan.org/tx/0x4e8d…7a31"
}

Error codes

400Validation failed
409Fingerprint already anchored
POST /api/verify

Verify data against the anchored record

Auth: None (public sandbox)

Body parameters

FieldTypeDescription
dataFields* object Data to check (re-hashed & matched)

Example request

curl -X POST 'https://blockchain.xai.io.vn/api/verify' \
  -H 'Content-Type: application/json' \
  -d '{ "dataFields": { "taxId": "0312345678", "amount": 500000000, "issuedAt": "2026-05-30" } }'

Example response

{
  "success": true,
  "mode": "mock",
  "dataHash": "0x9af1…c20b",
  "onChain": true,
  "payloadId": "INV-2026-001",
  "timestamp": 1769990400,
  "anchoredBy": "0x71C…e3F2"
}

Smart contract

xAISandboxRegistry.sol

Registry contract (EVM, Base Sepolia) — 3 public functions

Auth: Signed by relayer (on-chain mode)

Interface

// Solidity — xAISandboxRegistry
function anchorData(bytes32 _dataHash, string _payloadId) external; // ghi, emit DataAnchored
function verifyData(bytes32 _dataHash)
  external view returns (bytes32, string, uint256, address);        // đọc bản ghi
function isAnchored(bytes32 _dataHash) external view returns (bool); // kiểm tra nhanh