Katama·Docs
StatsWorkspace ↗

Smart contract

KatamaCredits.sol — minimal event-emitter on Base mainnet. Holds no funds, has no payable functions, exposes a single privileged role for the daily cron.

NetworkBase mainnet (chainId 8453)
Address0xb0f3826fce02311128b7a61f23076aafb72c5ac4
Compilersolc 0.8.35 (paris evm) · optimizer 200 runs
Bytecode size~2.3 KB
Deploy gas~570k · < $0.01 on Base

Roles

  • owner — set at deploy time, can rotate the operator or transfer ownership. Has no power over emitted events.
  • operator — the only role that can call logUserDaily, logKataBurn, logCreditsPurchase. The treasury wallet serves this role; for production we recommend setting a separate operator wallet via setOperator() so the owner key can stay cold.

Events

event UserDailyActivity(
  bytes32 indexed userIdHash,
  uint32  indexed date,
  uint32  generations,
  uint32  creditsUsed,
  uint16  videoCount,
  uint16  imageCount,
  uint16  otherCount,
  uint256 kataBurnedWei
);

event KataBurned(uint256 amountWei, string source, uint64 timestamp);

event CreditsPurchased(
  bytes32 indexed userIdHash,
  uint32  creditsGranted,
  uint32  eurCents,
  string  method,
  uint64  timestamp
);

State

  • totalBatches, totalGenerations, totalKataBurned — cumulative platform counters.
  • batchKeyUsed[bytes32] — idempotency dedupe keyed by keccak256(userIdHash, date). Prevents accidental double-logging.

Audit

Auditable against the SWC registry — every relevant class is either prevented by design or by the 0.8+ runtime. Quick map:

SWCStatusWhy
SWC-100 default visibilitysafeall functions explicit
SWC-101 overflowsafe0.8+ built-in checks
SWC-104 unchecked callsafeno external calls
SWC-105 unprotected withdrawalsafeno funds held
SWC-107 reentrancysafeno external calls
SWC-115 tx.origin authsafeuses msg.sender
SWC-128 gas-DoS loopssafeno loops over user input

Reading the events off-chain

// viem
const logs = await publicClient.getLogs({
  address: "0xb0f3826fce02311128b7a61f23076aafb72c5ac4",
  event: {
    type: "event",
    name: "UserDailyActivity",
    inputs: [
      { type: "bytes32", name: "userIdHash", indexed: true },
      { type: "uint32",  name: "date", indexed: true },
      // ...
    ],
  },
  args: { date: 20260611 },  // optional filter
});

Next: Security model →