Pay for sessions with X402 Protocol
import os, json, requests from eth_account import Account from x402.clients.requests import x402_requests ENDPOINT = "https://api.anchorbrowser.io/v1/sessions" BODY = {} key = os.getenv("PRIVATE_KEY") or exit("Set PRIVATE_KEY=0x...") pre = requests.post(ENDPOINT, json=BODY, timeout=30) if pre.status_code == 200: print(json.dumps(pre.json(), indent=2)) exit() price = int(pre.json()["accepts"][0]["maxAmountRequired"]) res = x402_requests(Account.from_key(key)).post(ENDPOINT, json=BODY, timeout=60) print(json.dumps(res.json(), indent=2))