# Python 3, read-only. No wallet. import urllib.request,urllib.error,json,base64,sys p=sys.argv[1] if len(sys.argv)>1 else 'flp' amount={'flp':'10000','fli':'10000','gfc':'20000'} if p not in amount: raise ValueError('Bad product') u='https://skylark-x402-testnet-discovery.vercel.app/api/v1/'+p+'/current' try: urllib.request.urlopen(urllib.request.Request(u),timeout=12);raise ValueError('Expected 402') except urllib.error.HTTPError as e: if e.code!=402: raise h=e.headers.get('payment-required');assert h and len(h)<30000 c=json.loads(base64.b64decode(h,validate=True)) a=c['accepts'][0] assert c['x402Version']==2 and len(c['accepts'])==1 and c['resource']['url']==u assert a['network']=='eip155:84532' and str(a['amount'])==amount[p] assert a['asset'].lower()=='0x036cbd53842c5426634e7929541ec2318f3dcf7e' assert a['payTo'].lower()=='0xc58d304313c60fcad5a923164ddf9fbedec564b9' assert 'bazaar' in c['extensions'] print({'product':p,'paid':False,'amount_atomic':a['amount']})