Adds a 65s, 1920x1080, silent demo video built entirely from real capture (headless-browser screenshots + a real macOS screencapture of a terminal session, composed with ffmpeg only) — no AI-generated footage. Honestly shows the live checkout, a real checkout-session error (Render DB outage), the public repo's chain table, a real SIMULATE-mode $wif mainnet proof (chain id, decimals, symbol, gas estimate), the already-proven testnet settlement tx, and an explicit caption that no mainnet $wif send has been executed. Surfaces a real gap found while building it: $wif is not yet selectable in the hosted checkout UI's network picker (packages/common's PaymentNetwork enum was never extended for it). Also fixes the SIMULATE log line to print symbol=WIF, and adds scripts/wif-demo-addendum-capture.sh for recording a real addendum clip once the owner runs the LIVE mainnet proof. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
214 lines
8.9 KiB
TypeScript
214 lines
8.9 KiB
TypeScript
/**
|
|
* $wif-on-Robinhood-Chain-mainnet settlement proof, for the World is Flat
|
|
* hackathon's eligibility rule ("your project has to use $wif onchain on
|
|
* Robinhood Chain").
|
|
*
|
|
* Robinhood Chain mainnet, chain id 4663. $wif token
|
|
* 0x5173b8eA6923c2d40267890D45C46a3480954773 — verified live via `eth_call`
|
|
* against rpc.mainnet.chain.robinhood.com on 2026-11-10: `decimals()` -> 18,
|
|
* `symbol()` -> "WIF" (see packages/chains/src/registry.ts's `robinhoodWif`
|
|
* entry and docs/worldisflat/SUBMISSION.md). The deployed bytecode has
|
|
* neither EIP-3009 nor EIP-2612 selectors, so this does a plain ERC-20
|
|
* `transfer`, verified the same way `scripts/robinhood-testnet-e2e.ts`
|
|
* verifies Robinhood testnet — a direct transfer to `payTo`, confirmed
|
|
* through the real SettleKit `createEvmVerifier` against the live chain.
|
|
*
|
|
* THIS SCRIPT NEVER SENDS A MAINNET TRANSACTION BY ITSELF.
|
|
*
|
|
* Two modes:
|
|
*
|
|
* 1. SIMULATE (default, always safe, no funds, no private key required):
|
|
* `eth_call`s the real `transfer` and runs `estimateGas` against the
|
|
* live mainnet RPC with the given FROM address. Proves the call would
|
|
* succeed (or shows exactly why not — e.g. insufficient $wif balance)
|
|
* without broadcasting anything or spending gas. This is the mode an
|
|
* agent may run on its own: read-only, zero cost.
|
|
*
|
|
* 2. LIVE=1 (owner-only, costs real mainnet gas + moves real $wif):
|
|
* requires PAYER_PRIVATE_KEY for a wallet already funded with mainnet
|
|
* ETH-equivalent native gas and a small amount of $wif, sends one real
|
|
* `transfer`, waits for confirmations, then verifies the tx through
|
|
* SettleKit's own `createEvmVerifier` and prints the tx hash + the
|
|
* Robinhood Chain explorer link. This is the one owner action left
|
|
* for World is Flat eligibility — nothing else in this script, or the
|
|
* repo, blocks it.
|
|
*
|
|
* Env:
|
|
* LIVE "1" to actually broadcast; unset/anything else -> simulate only
|
|
* PAYER_PRIVATE_KEY required when LIVE=1; a 0x-prefixed private key for a
|
|
* funded mainnet wallet (real funds — owner-only)
|
|
* FROM_ADDRESS simulate mode only: address to simulate the send from
|
|
* (default: a well-known $wif holder-looking placeholder
|
|
* is NOT assumed — pass a real address, or the zero
|
|
* address is used for a balance=0 sanity check)
|
|
* PAY_TO_ADDRESS merchant receive address (default: same as sender,
|
|
* for a minimal self-transfer proof, same pattern as
|
|
* the testnet script)
|
|
* PAY_AMOUNT_WIF default "0.000001" (sub-cent at ~$0.0006-0.001/WIF,
|
|
* deliberately tiny — this proof only needs *a* real
|
|
* $wif transfer to exist on Robinhood Chain mainnet,
|
|
* not a meaningful amount)
|
|
* ROBINHOOD_WIF_RPC_URL default the registry's mainnet RPC
|
|
*
|
|
* Run (simulate, safe, no funds, no key):
|
|
* apps/api/node_modules/.bin/tsx scripts/wif-mainnet-proof.ts
|
|
*
|
|
* Run (real, owner-only, spends real mainnet gas + $wif):
|
|
* LIVE=1 PAYER_PRIVATE_KEY=0x... apps/api/node_modules/.bin/tsx \
|
|
* scripts/wif-mainnet-proof.ts
|
|
*/
|
|
import {
|
|
createChainRpc,
|
|
createEvmVerifier,
|
|
getEvmChain,
|
|
type EvmChainSpec,
|
|
type Hex,
|
|
} from "../packages/chains/src/index.js";
|
|
import {
|
|
createPublicClient,
|
|
createWalletClient,
|
|
http,
|
|
parseUnits,
|
|
erc20Abi,
|
|
type Account,
|
|
} from "viem";
|
|
import { privateKeyToAccount } from "viem/accounts";
|
|
|
|
const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000" as Hex;
|
|
|
|
function say(line: string): void {
|
|
process.stdout.write(`${line}\n`);
|
|
}
|
|
|
|
function chainFor(spec: EvmChainSpec, rpcUrl: string) {
|
|
return {
|
|
id: spec.chainId,
|
|
name: spec.name,
|
|
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
rpcUrls: { default: { http: [rpcUrl] } },
|
|
} as const;
|
|
}
|
|
|
|
async function simulate(spec: EvmChainSpec, rpcUrl: string): Promise<void> {
|
|
say("SIMULATE mode: no funds move, no private key used, nothing is broadcast.");
|
|
const from = (process.env.FROM_ADDRESS?.trim() as Hex | undefined) ?? ZERO_ADDRESS;
|
|
const payTo = (process.env.PAY_TO_ADDRESS?.trim() as Hex | undefined) ?? from;
|
|
const amountMajor = process.env.PAY_AMOUNT_WIF?.trim() || "0.000001";
|
|
const amountBase = parseUnits(amountMajor, spec.token.decimals);
|
|
|
|
const client = createPublicClient({ chain: chainFor(spec, rpcUrl), transport: http(rpcUrl) });
|
|
|
|
const actualChainId = await client.getChainId();
|
|
if (actualChainId !== spec.chainId) {
|
|
throw new Error(`RPC at ${rpcUrl} serves chain id ${actualChainId}, expected ${spec.chainId} (${spec.name})`);
|
|
}
|
|
say(`connected: ${spec.name} chain id ${actualChainId} via ${rpcUrl}`);
|
|
|
|
const balance = await client.readContract({
|
|
address: spec.token.address,
|
|
abi: erc20Abi,
|
|
functionName: "balanceOf",
|
|
args: [from],
|
|
});
|
|
say(
|
|
`$wif balanceOf(${from}) = ${balance} base units (symbol=${spec.token.symbol}, decimals=${spec.token.decimals})`,
|
|
);
|
|
|
|
try {
|
|
const result = await client.simulateContract({
|
|
account: from,
|
|
address: spec.token.address,
|
|
abi: erc20Abi,
|
|
functionName: "transfer",
|
|
args: [payTo, amountBase],
|
|
});
|
|
const gas = await client.estimateContractGas({
|
|
account: from,
|
|
address: spec.token.address,
|
|
abi: erc20Abi,
|
|
functionName: "transfer",
|
|
args: [payTo, amountBase],
|
|
});
|
|
say(
|
|
`SIMULATED OK: transfer(${payTo}, ${amountBase}) from ${from} would return ${result.result}, ` +
|
|
`estimated gas ${gas}. No transaction was sent.`,
|
|
);
|
|
} catch (error: unknown) {
|
|
const message = error instanceof Error ? error.message : String(error);
|
|
say(
|
|
`SIMULATED CALL REVERTED (expected if ${from} holds no $wif — e.g. the zero-address default): ${message}\n` +
|
|
`Pass a real funded FROM_ADDRESS to simulate a transfer that would actually succeed.`,
|
|
);
|
|
}
|
|
}
|
|
|
|
async function sendLive(spec: EvmChainSpec, rpcUrl: string): Promise<void> {
|
|
say("LIVE mode: this broadcasts a real mainnet transaction and spends real gas + $wif.");
|
|
const payerKey = process.env.PAYER_PRIVATE_KEY?.trim() as Hex | undefined;
|
|
if (!payerKey) throw new Error("PAYER_PRIVATE_KEY is required when LIVE=1");
|
|
const payer: Account = privateKeyToAccount(payerKey);
|
|
const payTo = (process.env.PAY_TO_ADDRESS?.trim() as Hex | undefined) ?? payer.address;
|
|
const amountMajor = process.env.PAY_AMOUNT_WIF?.trim() || "0.000001";
|
|
const amountBase = parseUnits(amountMajor, spec.token.decimals);
|
|
|
|
const rpc = createChainRpc(spec, rpcUrl);
|
|
const actualChainId = await rpc.getChainId();
|
|
if (actualChainId !== spec.chainId) {
|
|
throw new Error(`RPC at ${rpcUrl} serves chain id ${actualChainId}, expected ${spec.chainId} (${spec.name})`);
|
|
}
|
|
say(`connected: ${spec.name} chain id ${actualChainId} via ${rpcUrl}`);
|
|
|
|
const wallet = createWalletClient({ account: payer, chain: chainFor(spec, rpcUrl), transport: http(rpcUrl) });
|
|
|
|
say(`sending ${amountMajor} ${spec.token.symbol} from ${payer.address} to ${payTo}`);
|
|
const txHash = await wallet.writeContract({
|
|
address: spec.token.address,
|
|
abi: erc20Abi,
|
|
functionName: "transfer",
|
|
args: [payTo, amountBase],
|
|
});
|
|
const explorerUrl = spec.explorerTx(txHash);
|
|
say(`submitted ${txHash}${explorerUrl ? ` (${explorerUrl})` : ""}`);
|
|
|
|
const verifier = createEvmVerifier({ spec, rpc });
|
|
const notBefore = new Date(Date.now() - 5_000);
|
|
const deadline = Date.now() + 180_000;
|
|
for (;;) {
|
|
const result = await verifier.verify({ txHash, payTo, expectedBase: amountBase, notBefore });
|
|
if (result.ok) {
|
|
say(
|
|
`VERIFIED: from=${result.from} amountBase=${result.amountBase} ` +
|
|
`confirmations=${result.confirmations} blockNumber=${result.blockNumber} blockTime=${result.blockTime.toISOString()}`,
|
|
);
|
|
say(`\n=== PASTE INTO THE WORLD IS FLAT SUBMISSION FORM ===`);
|
|
say(`tx hash: ${txHash}`);
|
|
say(`explorer: ${explorerUrl}`);
|
|
return;
|
|
}
|
|
if (!result.retryable) {
|
|
throw new Error(`verification failed (non-retryable): ${result.code} — ${result.reason}`);
|
|
}
|
|
if (Date.now() > deadline) {
|
|
throw new Error(`verification did not confirm within 180s: ${result.code} — ${result.reason}`);
|
|
}
|
|
say(`pending (${result.code}): ${result.reason}; confirmations=${result.confirmations}`);
|
|
await new Promise((resolve) => setTimeout(resolve, 5_000));
|
|
}
|
|
}
|
|
|
|
async function main(): Promise<void> {
|
|
const spec = getEvmChain("robinhoodWif", "mainnet") as EvmChainSpec;
|
|
const rpcUrl = process.env.ROBINHOOD_WIF_RPC_URL?.trim() || spec.defaultRpcUrl;
|
|
|
|
if (process.env.LIVE === "1") {
|
|
await sendLive(spec, rpcUrl);
|
|
} else {
|
|
await simulate(spec, rpcUrl);
|
|
}
|
|
}
|
|
|
|
main().catch((error: unknown) => {
|
|
process.stderr.write(`${error instanceof Error ? error.stack ?? error.message : String(error)}\n`);
|
|
process.exitCode = 1;
|
|
});
|