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.
| Network | Base mainnet (chainId 8453) |
|---|---|
| Address | 0xb0f3826fce02311128b7a61f23076aafb72c5ac4 ↗ |
| Compiler | solc 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 separateoperatorwallet viasetOperator()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 bykeccak256(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:
| SWC | Status | Why |
|---|---|---|
| SWC-100 default visibility | safe | all functions explicit |
| SWC-101 overflow | safe | 0.8+ built-in checks |
| SWC-104 unchecked call | safe | no external calls |
| SWC-105 unprotected withdrawal | safe | no funds held |
| SWC-107 reentrancy | safe | no external calls |
| SWC-115 tx.origin auth | safe | uses msg.sender |
| SWC-128 gas-DoS loops | safe | no 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 →