feat: add AfterCoin (AFC) private blockchain for Minecraft casino
Some checks failed
Deploy / deploy (push) Has been cancelled

Private Ethereum chain (Clique PoA, chain ID 8888) with ERC-20 token
(0 decimals, 1 AFC = 1 diamond) bridging casino balances on-chain so
players can view tokens in MetaMask.

- Geth v1.13.15 node with 5s block time, zero gas cost
- AfterCoin ERC-20 contract with owner-gated mint/burn/bridgeTransfer
- Bridge API (Express + ethers.js + SQLite) with register, deposit,
  withdraw, balance, and wallet endpoints
- Nonce queue for serial transaction safety
- Auto-deploys contract on first boot
- Updated mainframe Lua with diff-based on-chain sync (pcall fallback)
- Updated card generator Lua with wallet info display

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
consultoria-as
2026-02-26 00:48:22 +00:00
parent e65260c69b
commit 14279a878c
21 changed files with 2569 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
const Database = require("better-sqlite3");
const config = require("./config");
const db = new Database(config.DB_PATH);
// Enable WAL mode for better concurrent read performance
db.pragma("journal_mode = WAL");
// Create tables if they don't exist
db.exec(`
CREATE TABLE IF NOT EXISTS wallets (
disk_id TEXT PRIMARY KEY,
address TEXT NOT NULL,
private_key TEXT NOT NULL,
name TEXT,
created_at TEXT DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS contract_state (
key TEXT PRIMARY KEY,
value TEXT
);
`);
function getWallet(diskId) {
const stmt = db.prepare("SELECT * FROM wallets WHERE disk_id = ?");
return stmt.get(diskId) || null;
}
function createWallet(diskId, address, privateKey, name) {
const stmt = db.prepare(
"INSERT INTO wallets (disk_id, address, private_key, name) VALUES (?, ?, ?, ?)"
);
return stmt.run(diskId, address, privateKey, name);
}
function getContractAddress() {
const stmt = db.prepare(
"SELECT value FROM contract_state WHERE key = 'contract_address'"
);
const row = stmt.get();
return row ? row.value : null;
}
function setContractAddress(address) {
const stmt = db.prepare(
"INSERT OR REPLACE INTO contract_state (key, value) VALUES ('contract_address', ?)"
);
return stmt.run(address);
}
function getAllWallets() {
const stmt = db.prepare("SELECT * FROM wallets");
return stmt.all();
}
module.exports = {
db,
getWallet,
createWallet,
getContractAddress,
setContractAddress,
getAllWallets,
};