Files
project-afterlife/blockchain/init-geth.sh
consultoria-as 14279a878c
Some checks failed
Deploy / deploy (push) Has been cancelled
feat: add AfterCoin (AFC) private blockchain for Minecraft casino
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>
2026-02-26 00:48:22 +00:00

51 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
set -e
GENESIS_FILE="/app/genesis.json"
DATADIR="/data"
# Initialize geth datadir if not already done
if [ ! -d "$DATADIR/geth/chaindata" ]; then
echo "Initializing geth datadir with genesis block..."
geth init --datadir "$DATADIR" "$GENESIS_FILE"
fi
# Import admin private key if provided and no accounts exist yet
if [ -n "$ADMIN_PRIVATE_KEY" ]; then
EXISTING_ACCOUNTS=$(geth account list --datadir "$DATADIR" 2>/dev/null || true)
if [ -z "$EXISTING_ACCOUNTS" ]; then
echo "Importing admin private key..."
TMPKEY=$(mktemp)
echo "$ADMIN_PRIVATE_KEY" > "$TMPKEY"
geth account import --datadir "$DATADIR" --password /dev/null --lightkdf "$TMPKEY"
rm -f "$TMPKEY"
else
echo "Account(s) already exist, skipping import."
fi
fi
echo "Starting geth node..."
exec geth \
--datadir "$DATADIR" \
--networkid 8888 \
--http \
--http.addr 0.0.0.0 \
--http.port 8545 \
--http.api eth,net,web3,personal,txpool \
--http.corsdomain "*" \
--http.vhosts "*" \
--ws \
--ws.addr 0.0.0.0 \
--ws.port 8546 \
--ws.api eth,net,web3 \
--ws.origins "*" \
--mine \
--miner.etherbase "$ADMIN_ADDRESS" \
--unlock "$ADMIN_ADDRESS" \
--password /dev/null \
--allow-insecure-unlock \
--nodiscover \
--maxpeers 0 \
--syncmode full \
--gcmode archive