#!/usr/bin/env python3 """Do the remaining devnet transaction types on FLOP TESTNET with a wallet (default test-01), one at a time, exactly like the devnet runner does (runner.py), but pointed at the testnet RPC (wss://testnet.flop.network). Usage: python3 testnet_devnet_types.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. Already done on testnet: System.remark (block 100855). This script does the other three types: 1. System.remark_with_event 2. Balances.burn (dust, keep_alive=True) 3. Utility.batch (2x System.remark bundled) Each is a separate extrinsic; nonce is re-read before each submit. These prove the wallet can do every devnet transaction type on testnet. They do NOT count as inference spend for the airdrop. 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 payload(text): return "0x" + text.encode().hex() def get_nonce(sub): return sub.query("System", "Account", [ADDRESS])["nonce"].value def get_free(sub): return sub.query("System", "Account", [ADDRESS])["data"]["free"].value def submit(sub, kp, kind, pallet, call_name, params): nonce = get_nonce(sub) call = sub.compose_call(pallet, call_name, params) ext = sub.create_signed_extrinsic(call=call, keypair=kp, nonce=nonce) receipt = sub.submit_extrinsic(ext, wait_for_inclusion=True) print(f"{kind}: success={receipt.is_success} " f"tx={receipt.extrinsic_hash} block={receipt.block_hash and sub.get_block_number(receipt.block_hash)}") if not receipt.is_success: print(f" error: {receipt.error_message}") return receipt.is_success def main(): global ADDRESS ap = argparse.ArgumentParser(description="Remaining devnet tx types 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" 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(f"start: balance {get_free(sub) / 10**18:.6f} FLOP, nonce {get_nonce(sub)}") ok = True # 1. remark_with_event ok &= submit(sub, kp, "remark_with_event", "System", "remark_with_event", {"remark": payload("testnet probe test-01 remark_with_event")}) # 2. burn (dust, keep_alive=True) ok &= submit(sub, kp, "burn", "Balances", "burn", {"value": 10**14, "keep_alive": True}) # 3. batch of 2 remarks inner = [ sub.compose_call("System", "remark", {"remark": payload("testnet probe test-01 batch #1")}), sub.compose_call("System", "remark", {"remark": payload("testnet probe test-01 batch #2")}), ] ok &= submit(sub, kp, "batch(2x remark)", "Utility", "batch", {"calls": inner}) print(f"end: balance {get_free(sub) / 10**18:.6f} FLOP, nonce {get_nonce(sub)}") return 0 if ok else 1 if __name__ == "__main__": raise SystemExit(main())