#!/usr/bin/env python3 """Single System.remark on FLOP TESTNET with a wallet (default test-01), exactly like the devnet runner does (runner.py run_wallet), but pointed at the testnet RPC (wss://testnet.flop.network — the RPC the explorer testnet.flopscan.io reads from). One transaction only, tiny fee. Proves the wallet can transact on testnet. Does NOT count as inference spend (that needs the gateway). Usage: python3 testnet_remark.py [--label ] The wallet label selects which wallet in the encrypted store to use; the address is read from that wallet entry (never hardcoded). Default label flop-devnet-test-01. Never prints the mnemonic or private key. """ import argparse import json import os import subprocess import sys import time RPC_URL = "wss://testnet.flop.network" ENC = os.path.expanduser("~/workspace/flop-wallet/test-wallets/wallets.json.enc") PW = os.path.expanduser("~/workspace/flop-wallet/vault/wallet-password.txt") def decrypt_wallets(store=ENC, pw=PW): out = subprocess.run( ["openssl", "enc", "-d", "-aes-256-cbc", "-iter", "200000", "-in", store, "-pass", f"file:{pw}"], capture_output=True, check=True) return json.loads(out.stdout.decode()) def main(): global ADDRESS ap = argparse.ArgumentParser(description="One System.remark on FLOP testnet") ap.add_argument("--label", default="flop-devnet-test-01", help="wallet label in the encrypted store") ap.add_argument("--store", default=ENC) ap.add_argument("--pw", default=PW) args = ap.parse_args() from substrateinterface import SubstrateInterface, Keypair, KeypairType wallets = decrypt_wallets(args.store, args.pw) w = next(x for x in wallets if x["label"] == args.label) ADDRESS = w["address"] kp = Keypair.create_from_mnemonic( w["mnemonic"], ss58_format=42, crypto_type=KeypairType.ED25519) assert kp.ss58_address == ADDRESS, "derived address mismatch" print("keypair ok:", ADDRESS) sub = None last = None for i in range(5): try: sub = SubstrateInterface(url=RPC_URL, ws_options={"timeout": 120}) sub.init_runtime() break except Exception as e: last = e print(f"RPC connect attempt {i + 1} failed ({type(e).__name__}), retrying...") time.sleep(10) if sub is None: raise RuntimeError(f"cannot reach testnet RPC: {last}") print("connected, chain head block:", sub.get_block_number(sub.get_chain_head())) acct = sub.query("System", "Account", [ADDRESS]) free = acct["data"]["free"].value nonce = acct["nonce"].value print(f"balance: {free / 10**18:.4f} FLOP, nonce: {nonce}") payload = "0x" + "testnet probe test-01".encode().hex() call = sub.compose_call("System", "remark", {"remark": payload}) ext = sub.create_signed_extrinsic(call=call, keypair=kp, nonce=nonce) print("submitting remark...") receipt = sub.submit_extrinsic(ext, wait_for_inclusion=True) print("is_success:", receipt.is_success) print("extrinsic_hash:", receipt.extrinsic_hash) print("block_hash:", receipt.block_hash) if receipt.block_hash: print("block number:", sub.get_block_number(receipt.block_hash)) if not receipt.is_success: print("error:", receipt.error_message) return 1 acct2 = sub.query("System", "Account", [ADDRESS]) print(f"after: balance {acct2['data']['free'].value / 10**18:.6f} FLOP, nonce {acct2['nonce'].value}") return 0 if __name__ == "__main__": raise SystemExit(main())