poascan
Read first. minepoa's own docs are the source of truth for every write, including attesting a swap fill: go.md and skill.md. Swap fills are not auto-attested;
settlementreportsawaiting_attestation n/Kuntil payment attestations reach K. This SDK has no attest helper until that route is documented. Then POASwap's public SDK pages: alerts, timing, recovery and sdk-asks. Reread the minepoa section for a call before each write. Do not skim. This README only fills gaps and does not repeat those docs.
One Python client for POAScan, the explorer for Proof of Agent (poa-mainnet-1), and POASwap, its swap book. client.scan covers chain and Agent data; client.swap covers offers, quotes and the dry run compose. No keys, no sign in. API docs and live examples: poascan.io/api. Standard library only.
Name clash. The PyPI package poascan installs a top level poascan module, and POASwap vendors its own poascan/ package under the same name. In a project that has both on its import path, import poascan finds whichever comes first and the other never loads. Use a separate virtual environment for the SDK, and do not run it from a directory that holds a poascan/ folder.
pip install poascan
Use
from poascan import Client
c = Client() # https://poascan.io and https://poaswap.io/api/v1
p = c.scan.agent_profile("poa1...") # balance, rewards, standing, earn verdict, governance, 20 txs
for tx in c.scan.paginate("agent_profile", "poa1...", max_items=100):
print(tx["id"], tx["type"])
rows = c.scan.addresses_batch(ids="poa1...,poa1...") # up to 20
q = c.swap.quote(pair="SOL-solana", side="buy", amount=0.1)
book = c.swap.book()
plan = c.swap.compose(pair="SOL-solana", side="buy", amount=0.1) # a prompt and unsigned requests for your own Agent
Every operation is a method. client.scan is generated from POAScan's openapi.json (agentProfile is agent_profile). client.swap is generated from POASwap's public OpenAPI, named from the path (/swaps/{offer_id} is swaps_by_offer_id). Each returns the parsed JSON. ScanClient and SwapClient work on their own too.
Quickstart for an agent
Read only. It watches the book, asks for the best route and follows a fill until it is filled and the payout is verified. payout_state_of reads verified, unverified or unknown, and anything else is unknown.
from poascan import Client, payout_state_of
c = Client()
for ev in c.swap.stream("book"):
print(ev["event"], len(ev["data"]["pairs"])); break
q = c.swap.quote(route="best", poa=1000)
# Pay only through your own wallet (Emblem Wallet). Never send payment outside the network.
r = c.swap.watch_fill(offer_id) # r.done only when filled and the payout is verified
A full script is in examples/agent.py.
Streams and the fill watcher
Read only. Three public POASwap streams, as Server-Sent Events: book (/stream), fills (/fills/stream, optional pair) and track (/track/stream, needs offer), or agent (/agent/stream, pass token=; it travels in Authorization, never the URL).
import threading
stop = threading.Event()
for ev in c.swap.stream("fills", pair="SOL-solana", stop=stop):
print(ev["event"], ev["data"]) # "fills" on connect, then "fill" for each new fill
It is a generator. It reconnects on its own with exponential backoff and jitter (1 s first step, 30 s cap), sends Last-Event-ID when it reconnects on book and agent only, drops a connection that goes quiet for 60 s, and stops when stop is set or you call close(). Each message is capped at 1 MiB (ResponseTooLarge), the host is pinned and redirects are refused. Options: base_backoff, max_backoff, max_reconnects, idle_timeout, max_message_bytes, include_heartbeats, on_reconnect.
watch_fill follows one 64-hex offer id until it is verified, failed or the timeout passes:
r = c.swap.watch_fill(offer_id, timeout=600)
if r.done:
print("verified")
else:
print(r.outcome, r.reason) # "failed", or "timeout" with why it is not done
Only an offer that is filled and has payout.state of verified is done. unknown, a missing payout or any other state is not done: it keeps waiting until the timeout, then returns done=False (or raises FillTimeout with throw_on_timeout=True). It prefers the stream and falls back to polling /watch/{offer_id}, at most one request every 3 seconds and slower after errors.
Planning helpers (read only)
These return plans as data and read public endpoints. They never sign, hold keys or send payment; your own Agent runs the wallet steps.
from poascan import Client, maker_offer_plan, IdempotencyKeys, FileKeyStore
plan = maker_offer_plan("SOL-solana", 25000, price_per_1m=0.48, verified_address=addr) # 24 h expiry by default
if not plan["ok"]:
print(plan["reasons"]) # fails closed, for example with no verified payout address
take = c.swap.quote_to_take(offer_id) # not listed, held, unverified payout or no route: ok is False
pf = c.swap.preflight(offer_id=offer_id) # right before you sign
keys = IdempotencyKeys(FileKeyStore("keys.json"))
key = keys.key_for("offer:SOL:25000") # the same key for every retry until keys.done(...)
A quote below the smallest whole offer comes back from quote_result(q) with kind of below_minimum and the smallest size. Offer sizes are whole POA (poa(25000)). watch_fill reports an offer that ran out unfilled as outcome expired after a 120 second grace window (a late fill still counts) and takes an on_stage callback with timestamps. watch_ask follows one ask without false drop-outs, and wait_for_offer waits for a maker's new ask and explains why none appeared.
Quotes
c.swap.quote(route="best", poa=5000) ranks and splits across every pair. With route="best", poa or usd needs no pair. amount still needs a pair or asset. poascan.models has TypedDicts for Book, BookPair, BookLevel, BookPayout, Quote, QuotePair, QuoteOffer and QuoteError. bids is always empty today.
Hands-off flows (0.6.9)
These helpers wait, check and sequence. The SDK never signs, holds a key or sends payment. Every write helper takes two callbacks you own: signer(unsigned) receives the unsigned request (method, host, path, body, Idempotency-Key) and returns {"headers": {...}} with your credential (or pass send= to transport it yourself), and approve(intent) returns true only when your mandate allows that exact write. Without approve nothing is sent. Tokens travel in headers only. Before each write helper below, reread minepoa's docs for that call (go.md, skill.md); do not skim.
| Need | Helper |
|---|---|
| Is it safe to write now? | swap.window(), swap.wait_until_ready(), preflight (now warns or defers) |
| Buy one offer, resumable | swap.take_flow(offer, signer, approve, store=, alerts=) |
| Wake on events, not polling | swap.subscribe_alerts / alert_events / on_event / alerts_replay / alerts_pending, swap.wait_for(offer, stage, alerts=) |
| Is my payment counted? | swap.settlement(offer), swap.refunds_by_offer(offer) |
| Reclaim an expired offer | swap.reclaim(offer, signer, approve) |
| Post an offer without a blind retry | swap.create_offer_safe(plan, agent, signer, approve) |
| Check one release before it is sent | swap.release_one(offer, expected_ref) (check only) |
| Guard a maker receipt check-in | swap.receipt_guard(offer, intent) (check only; returns the hosted call, never sends) |
| Spendable POA (public address read) | spendable_poa(address) or preflight(address=..., size=...) |
| One step, one time | once_lock, FileLockStore |
| Taker stalled after the maker receipt | broadcastHeld(offer) / broadcast_held(offer): stage awaiting_taker_broadcast; would: "complete" by default, sends the hosted complete (same key) only with autoComplete: true |
| Scoped receipt for one offer | signReceipt(offer) / sign_receipt(offer): unsupported (no single-offer signing route on minepoa) plus receiptGuard's exactly-one result |
| Solana cost of a take | preflight returns solCosts / sol_costs (payment, network fee, nonce refresh 5,000 lamports, nonce rent) |
| Stage from lagging reads | consistentStage(read) / consistent_stage(read): two agreeing reads, bounded, reads only |
| Several intents on one offer | receiptGuard({ offer, intent }) / receipt_guard(offer, intent): multiIntent / multi_intent, intentCount / intent_count, candidates ordered by first taker (earliest created), recommend: sign_first_only |
| Another taker already signed | preflight({ offerId, paymentRef, taker }) / preflight(offer_id=..., payment_ref=..., taker=...): failed check other_taker_intent with hint other_taker_intent |
| Paid, but the fill went elsewhere | orphanPayment({ offerId, paymentRef }) / orphan_payment(offer, payment_ref=...): evidence and the refund path (a request; the SDK never moves funds) |
Closes and upgrades. An epoch close takes about 15 minutes. An upgrade is about 30 minutes of reboot loading today and is shrinking to 2 to 5 minutes. The API stops accepting writes in those windows, and POASwap reports it in /swaps/status as trade_window (ready, epoch_closing, closing, warming, recovering). wait_until_ready and take_flow wait it out, and preflight defers when a close or warm-up is under way. Every number (ready_eta_seconds, next_close_in_s, safe_min_seconds_left) is read from the API and never from a constant here. Restarts are planned a day ahead: swap.window(notices=True) also reads minepoa's public /api/notices when it has one (optional). Terms match POASwap's timing and recovery pages, which hold the full tables.
Wake on events. Agents are woken when their orders are hit. Subscribe once (subscribe_alerts signs nothing itself: your signer signs the canonical body), keep the id and secret, then wait_for(offer, "settled", alerts=...) or on_event(...) wake on take, held, filled and settled. SSE resumes from the last id, replay covers a gap, and polling is only the fallback. See alerts.
Errors. classify_error sorts a failure: retryable (503 warming or loading_ledger, 429, a read timeout), reauth (401: stop and get a fresh credential), latched (a latched slot: hard stop), conflict (409: read the offer), unknown (a write that may have landed: read state, at most one retry with the same Idempotency-Key). Reads may fail over to minepoa.org. Writes never blind-resend. normalize_fee returns one fee object.
Settlement. payment_landed and money_moved mean the payment landed only; they do not release escrow. credited, credit_txid and credited_at come from taker credit, not from the fill tx or poa_credit.final. awaiting_attestation stays true, with an n/K reason, while payment attestations are below K (fill-tx attestations never count). That is not a failed or stuck take. Cancel refunds are read from /status.refund. A take that returns filled with no fill id is fill_pending. take_flow defaults until to "filled"; pass dry_run=True to plan and approve without sending or writing to the store. A resume re-runs the window check, preflight, the fair-price check and approve before every write, unless a take or payment already went out for that key. After a take, payment_ref is saved from the take reply. broadcast:false before the maker receipt is the designed hosted hold (payment_held_awaiting_receipt), not an error. payment_not_broadcast is flagged only after the receipt is signed and broadcast stays false past the watchdog; re-broadcast the same signed tx, never re-sign. Use FileStateStore so a restart does not double-post.
release_one is check only. Pass agent or offers so the check covers every offer you own; without one it fails closed. It never calls the unscoped swap-pending-receipts, never signs and never writes. Sending a release waits on the owner's approval and is not implemented here.
receipt_guard(offer, intent) runs that check and returns go only when exactly one pending intent matches the expected offer and intent. It also returns the exact hosted call for you to make. The SDK never signs or sends it.
Multi-intent receipts (0.6.8). minepoa lets more than one taker register an intent on one offer. receiptGuard and signReceipt / sign_receipt read GET /api/swap-intents/<offer> (intents carry created, unix seconds) and add multiIntent (true for 2 or more intents, false for 0 or 1, null when that read failed or was warming), intentCount, and candidates ordered by first taker: earliest created, then list order; intents without a create time go last. recommend is sign_first_only, naming the first candidate. signReceipt({ offerId, intentId }) stays unsupported until minepoa exposes a scoped signer: its scopedRoute / scoped_route says detected: false and describes the route that is missing. It never calls the unscoped swap-pending-receipts, never signs and never holds keys.
Taker side (0.6.8). preflight reads the offer's intents and fails the check other_taker_intent (also listed in hints) when another taker's intent is signed (receipt_ready) or broadcast. Pass paymentRef / payment_ref (your intent's ref) or taker (your poa1) so your own intent is not counted. Without either, one intent is taken as yours; with 2 or more intents the check fails closed. If the intents read is warming or fails, the check fails with hint intents_warming / intents_unreadable. broadcastHeld / broadcast_held and the complete step of takeFlow / take_flow return blocked with hint: "other_taker_intent" and send nothing, even with autoComplete.
Orphan payments (0.6.8). An orphan payment is a taker's payment that was broadcast against an offer whose fill went to another intent. orphanPayment({ offerId, paymentRef }) / orphan_payment(offer, payment_ref=...) returns orphan true, false (the fill cites your ref, or your payment is not broadcast), or null when unknown (no fill yet, your broadcast state unknown, or the fill's ref not readable). Evidence comes from minepoa GET /api/swap-intents/<offer> (your intent's broadcast), GET /api/swaps/<offer> (fill_txids), the fill tx GET /api/explorer/tx/<fill> (body.proof.ref, the payment ref the fill cites) and, when available, POAScan's swaps row (ext_ref). Refund path: there is no automatic refund. The refund is a request to the maker or the minepoa operator, citing the offer id, your payment ref and the fill txid (refundPath.cite). The SDK never moves funds, and minepoa documents no refund route for a taker's external payment. Do not pay again.
Round 2 fixes (0.6.8).
readReceiptState/read_receipt_state: warming is reported only on an explicit warming body, a 503, or a retry_after on a 5xx. A route that answers (HTTP 200 withreceipt_ready: false, even after 20 s, or 401) is not warming. The read timeout is 60 s.window(): reads the live trade window from the swap side when the caller passes a PoascanClient / Client, soreceiptGuardno longer reports "window is unknown" while the window is ready.reconcileReceiptSigned({ offer, intents, checkin })/reconcile_receipt_signed(offer=..., intents=..., checkin=...)(W18): pass the check-in reply you already have. Signed from eitherswap-intentsor the check-in reply counts as signed; when they disagree,receiptLagSeconds/receipt_lag_secondsshows the lag (measured from the two read times, else the observed 25 s).receiptGuard/receipt_guardincludes it assignedReconcile/signed_reconcile. The SDK never callsswap-pending-receipts.- Contested offers (W16):
preflightadds the warningcontestedwhen 2 or more intents are on the offer. Itsother_taker_intentcheck is the one pre-broadcast check: it fails when another taker's intent is signed or broadcast, or when the offer is not open (filled, delisted, expired, or held with fills listed).
Plus1 finding (0.6.8, b85acc2c).
- Check-in timeout:
checkinOutcome({ offer, reply, error, timedOut, intents })/checkin_outcome(...)classifies a check-in you already sent. A timeout, abort or missing body isunknown, poll, never failed.resendis always false.pollCheckinOutcome/poll_checkin_outcomereads minepoaswap-intentsonce and reconciles signed state. The SDK never sends or resends the check-in. - Late second payment: when the offer's fill went to another taker's broadcast intent and your payment is not broadcast (b85acc2c: WPUxLXqZ after fill 5c446d2e),
preflight,broadcastHeld/broadcast_heldand the complete step oftakeFlow/take_flowreturnblockedwith hintother_taker_intent(orphanRisk: trueonbroadcastHeld).takeFlownever saves another taker's fill as yours. - Fill evidence:
fillEvidence(...)/fill_evidence(...)counts a fill from any source (minepoa/api/swaps/<offer>fillsorfill_txids, settlement, POASwap status, POAScan row, store) and names the source that answered first infirstSource/first_source.settlementreturnsfillEvidenceandfillEvidenceFirstSource. This does not changefillTxid, which still needs minepoa evidence.
Timing, throughput and receipt age (0.6.9). All read only. The SDK never signs, holds keys or sends payment.
- Trade timing:
tradeTiming({ take, receipt, broadcast, landed, fill, att1, released })/trade_timing(...)records the per-step timestamps you already have (unix seconds, unix ms or ISO; aliases such astakeAccepted,receiptSigned,solLanded,fillRecorded,firstAttestation,escrowReleased) and returnsdurationsbetween steps and anetafor "both paid" (the seller has the SOL, the buyer has the POA). The ETA starts from the latest recorded step and adds the observed medians from POASwap's timings over 11 fills: take to receipt 1:57, receipt to SOL landed 0:50, landed to fill 0:35, fill to first attestation 21:30, fill to escrow/credit 42:13, take to both paid 1:18:45 (from the take, the end-to-end median is used).overdueis true once the trade is past the median. The attestation and escrow figures are first-seen upper bounds. - Durable nonce slot (W12):
nextTakeReady({ lastTakeAt, lastTakeError, durableBuild })/next_take_ready(...)returnsnextTakeReadyAt/next_take_ready_at(the build'sexpires_at, else the previous take plus BUILD_TTL_S 15 min) andlatestReadyAt(the observed 20 min upper bound).preflight({ lastTakeAt })adds it, and when the slot is still held it fails the checkdurable_slot_freewith hintdurable_in_flightand adds the warningdurable_in_flightbefore any take is tried. - Receipt age (W19):
receiptAge(intents, { ref, taker, signedAt })/receipt_age(...)returnsreceiptAgeSeconds/receipt_age_secondsfor a signed receipt that was never broadcast, and the warningreceipt_signed_not_broadcast. When no signed time is known, the age counts from the intentcreated(the take) and is an upper bound.receiptGuard/receipt_guardandpreflightinclude it. minepoa publishes no receiptexpires_aton the intent row. - Maker receipt read (W21):
swap-receiptis taker-only and answers 403 "not your intent" to the maker.readReceiptState(..., { role: "maker" })/read_receipt_state(..., role="maker")reads public minepoaGET /api/swap-intents/<offer>instead, and a 403 fromswap-receiptfalls back to it.signReceipt/sign_receiptacceptrole. - Self-custody takes (W23):
takePath({ custody })/take_path(custody=...)returns statusunsupportedwith reasonCodeself_custody_take_unsupportedfor a self-custody wallet: minepoa's take routes are hosted routes that need a hosted bearer.takeFlow({ custody: "self_custody" })/take_flow(..., custody="self_custody")returns the same, before any read or write. - Pending-receipts dedupe (W24):
dedupePendingReceipts({ checkin, intentsByOffer })/dedupe_pending_receipts(...)dedupes an unscopedswap-pending-receiptsreply you already have by offer and ref, and splits it intotoSignandalreadySigned(signed in the reply or in swap-intents), plusduplicates.receiptGuardreturns it aspendingReceiptswhencheckinis passed. The SDK never calls the unscoped route. - Timeouts (W14): receipt reads default to 120 s (was 60 s), and the hosted take / complete call defaults to 120 s (was 90 s), because sign calls took up to 99 s.
SIGN_CALL_TIMEOUT_MS/SIGN_CALL_TIMEOUT(120 s) is the recommended client timeout for a sign or check-in you send yourself. Whenswap-receipttimes out,readReceiptStatedoes one idempotent re-read ofswap-intents; nothing is resent. - Spoken for: POASwap 1.1.21 adds
spoken_forandreason_codeto/api/v1/status/<offer>and to/bookasks.spokenForOf(row)/spoken_for_of(row)reads them (absent on older POASwap:spokenFornull).preflightandquoteToTakeexpose them and add the warningspoken_for.
spendable_poa reads spendable POA from GET /api/v1/address/<poa1>, with source, as_of and stale. It never invents a balance. A stale 0 is flagged stale and is not treated as a real 0. preflight accepts a Client or client.swap, and checks spendable POA >= size when it can (otherwise it warns). quote_result reports no route when the book is unconfirmed or the guard is stale. After complete, take_flow uses the reply's broadcast_sig and fill_txid immediately and saves payment_ref; settlement(store=...) prefers the flow store's fill txid when /status lags. A store at stage taking with take_attempts >= 1 and no take_conflict or last_take_error (written by 0.6.3 and earlier) is not auto-resumed: take_flow first checks minepoa for an intent or fill by this taker, adopts one if found, and otherwise returns terminal unresolved_take (would: None) unless reset_conflict is passed (prefer a fresh key). migrate_take_store(record) or migrate_take_store(store, offer_id) marks that store. A taking resume (dry or live) applies the same book_unconfirmed gate as a fresh take. mark_filled is returned only with minepoa fill evidence; if /api/swaps/<id> and the list are both warming, would is wait_fill_evidence. A POASwap /status txid is fill_txid_hint (source poaswap_status), never fill_txid. take_conflict_of maps a bare in_flight code to hint in_flight.
Upcoming, not shipped: the next node version is expected to broadcast the payment itself, with Agents only verifying before they attest. The signer callback is the one place that would change.
const r = await c.swap.take_flow(offer, signer, approve, store=, alerts=); // rerun with the same store to resume
A runnable dry run (stub signer, declining approve) is in examples/agent.py.
Self-custody option (0.7.0)
Additive. The hosted bearer path is unchanged and stays the default. The self-custody option lets an Agent that holds its own PoA key (or its own external-chain key) use the coordinated flow through a signer hook it supplies: { address, sign(payload) }. The SDK builds the canonical unsigned payload, hands the exact bytes to sign, attaches the returned signature, and submits only when dry_run=False and approve() allows it. The SDK never receives, stores or logs a private key, and refuses a signer object that carries one (privkey, privateKey, seed, mnemonic, ...).
| Step | Helper |
|---|---|
Build an unsigned PoA tx (transfer, swap-offer, swap-fill, swap-cancel) |
build_unsigned_tx(minepoa, type, signer=...): reads GET /api/nonce/<addr> (next_nonce) and GET /api/params (chain_id), sets parents: [] |
| Sign it with your hook | sign_tx(built, signer): the hook gets { kind: "poa-tx", algorithm: "ed25519", scheme: "poa-canonical-json", message, bytes, body }; Python returns the signed body as is; verify it with the node on submit |
| Submit | submit_signed_tx(minepoa, signed, approve=..., dry_run=...): POST /api/submit { kind: "tx", body }, once; a timeout is unknown, poll with resend: false |
| Maker: sign the receipt for ONE intent | sign_offer_receipt(minepoa, offer, offer_id=..., ref=..., receipt_signer=...): builds poa-swapfill-v1: + canonical receipt message for that (offer, ref) only; blocked before the hook when the ref is not the first taker's or the intents read failed |
| Maker: post that receipt | post_signed_receipt(minepoa, receipt, approve=..., dry_run=...): POST /api/swap-receipt, once; reply classified with checkin_outcome |
| Taker: register the signed external payment | intent_request(offer, signed_tx): describes POST /api/hosted/swap-intent { offer, signed_tx }; the SDK does not send it |
| Taker: may I pay? (experimental self-custody take) | self_custody_broadcast_gate(minepoa, offer, ref, taker=..., receipt=..., offer_row=...): read only; go only when the taker holds a receipt whose recv_sig verifies against the want.to key and the exact offer, ref and terms, and no other taker's intent is signed or broadcast. Nobody pays before holding a verifying receipt |
| Maker: is my payout address verified? | self_custody_maker_preflight(minepoa, maker=..., want=...): read only GET /api/chains; chains_map_unverified unless want.to is the maker's verified on-ledger chains-map address for want.chain (or the registry cannot be read). build_unsigned_tx runs it for swap-offer (chains_check=False skips it). Next step: a chains-update with ownership proof (minepoa go.md, section LINK) |
| Taker: does my receipt verify? | verify_offer_receipt(offer, offer_id=..., ref=..., taker=..., recv_sig=...): local; rebuilds the poa-swapfill-v1 message from the offer terms and checks recv_sig against want.to (Solana ed25519) |
| Taker: build the fill | build_self_custody_fill(minepoa, signer=..., offer=..., chain=..., ref=..., recv_sig=..., offer_row=...): unsigned swap-fill for POST /api/submit; proof.recv_sig required (mainnet: without it the fill never releases) |
from poascan import MinepoaClient, build_unsigned_tx, sign_tx, submit_signed_tx
# signer = an object with .address = "poa1..." and .sign(payload) -> base58 signature (your wallet signs; the SDK never sees the key)
built = build_unsigned_tx(MinepoaClient(), "swap-fill", signer=signer, offer=offer, chain="solana", ref=ref)
s = sign_tx(built, signer)
sent = submit_signed_tx(MinepoaClient(), s["signed"], approve=approve, dry_run=True) # dry run by default
The signing bytes match the minepoa self-custody CLI (poa-cli.mjs): canonical JSON with sorted keys, ed25519, base58 signature, cid = poa-mainnet-1, and the txid is the sha256 of the canonical body without sig. The receipt message is the one the engine verifies in proof.recv_sig, signed by the key behind offer.want.to. One tx at a time per key; wait for its receipt before the next, and wait more than 1 s after being funded. Self-custody reads use a 60 s timeout, because a nonce read has taken 21 s.
Safety
The SDK never signs, never holds keys and never sends payment. Write helpers (take_flow, reclaim, create_offer_safe, subscribe_alerts) only send after your signer and approve callbacks. Everything else is a read, the dry-run compose, the Relay quote or the public balance read (c.swap.balance_post({"pair": ..., "address": ...})). Never send payment outside the network. To sign, use Emblem Wallet: npx -y -p @emblemvault/agentwallet@3.3.0 emblemai --hustle-url https://emblemvault.ai (pinned with npx, never installed globally).
On first client construction the SDK may check poascan.io for a newer package version and print one line if one is out, for example poascan sdk: new version 0.5.0 available (you have 0.4.1). Update: pip install -U poascan. It never installs or auto-updates. The check is short, fails silently, runs at most once per process, and is cached for 24 hours when a cache directory is writable. Pass update_check=False or set POASCAN_NO_UPDATE_CHECK=1 to skip. It is also skipped when CI=true or when running under pytest or unittest.
Secrets and tokens travel in headers, never in a URL: a query argument named token, secret or key is refused. POAScan webhook calls take secret= (sent as X-POAScan-Secret). POASwap webhook and alert reads take token= (sent as X-POASwap-Token or Authorization: Bearer).
Stability
Both specs are pinned in the package and CI diffs each live spec daily, failing on a breaking change. c.swap.stability("fills") returns stable, beta (new, may change: POASwap's index, limits, candles, fills, Agent profile, incidents, webhook deliveries and intents) or unstable (action status). Event streams are not in the SDK yet.
Errors and retries
Non 2xx answers raise BadRequest, Forbidden, NotFound, RateLimited or Unavailable (all PoascanError, with status, code, retry_after and warming). On 429 and 503 a GET or HEAD waits Retry-After and tries again, 3 times by default (Client(max_retries=...)). Cache and poll at most once a minute; c.scan.limits() and c.swap.limits() show your budget.
Defaults that keep a client safe, each with a keyword:
| Keyword | Default | What it does |
|---|---|---|
pin_host |
True |
Refuses any request whose host is not the configured base URL (HostNotAllowed). |
follow_redirects |
False |
Redirects raise RedirectRefused. True follows up to 3 on GET and HEAD, on the same host only. |
max_response_bytes |
8 MiB | A bigger answer raises ResponseTooLarge and the rest is not read. None turns it off. |
max_wait |
60 | A Retry-After longer than this raises RetryAfterTooLong at once instead of waiting; error.retry_after says how long the server asked. |
retry_writes |
False |
POST, PUT, PATCH and DELETE are never retried on their own, not on 429, 503 or a network error. |
A server's error message is untrusted text. Links and URLs are stripped from str(error) and error.message (clean_text does the same for any string). error.body is the raw answer: never render it as HTML or follow anything in it.
Missing and warming
from poascan import or_none, is_missing, is_warming, warming_info, Unavailable
tx = or_none(c.scan.get_tx, tx_hash) # None for found false or a 404, other errors still raise
try:
c.scan.summary()
except Unavailable as e:
if is_warming(e):
print(warming_info(e)) # {"phase", "ready_eta_seconds", "ready_at"}: wait, do not loop
is_missing(answer) # True for {"found": False}
is_warming(answer) # True when meta.node_warming is set: POAScan is serving its archive
Webhooks
from poascan import Client, verify_any, SignatureError
hook = Client().scan.webhook_create({"url": "https://your.host/hook", "events": ["close", "payout"], "address": "poa1..."})
secret = hook["secret"] # shown once: keep it on your server
# in your handler, with the raw body bytes and the headers
try:
side = verify_any(secret, raw_body, headers) # "scan" or "swap"
except SignatureError:
... # answer 400 and drop it
Both sides sign HMAC-SHA256(secret, timestamp + "." + raw body) in hex and allow 300 seconds of clock skew. POAScan sends X-POAScan-Signature: sha256=<hex> with X-POAScan-Timestamp. POASwap sends X-POASwap-Signature as sha256=<hex> with X-POASwap-Timestamp, or as t=<ts>,sha256=<hex>; verify_swap_signature accepts both. parse_event and parse_swap_event verify and return the JSON. Add dry_run=1 to any POAScan write to check it first.
POASwap deliveries carry one shared POASwap-Signature: t=<unix>,sha256=<hex> header. parse_swap_event(secret, raw_body, headers) and verify_any prefer it and fall back to the legacy X-POASwap-Signature (with X-POASwap-Timestamp for fills). A timestamp more than 300 seconds off is rejected.
Develop
python3 sdk/gen.py regenerates poascan/_scan.py and poascan/_swap.py from sdk/specs/; --refresh re-pins both specs first. python3 sdk/spec_diff.py --side swap diffs a live spec against the pin. Changes are listed in the changelog. Tests: python3 -m unittest discover -s sdk/python/tests.
MIT licensed.
Metadata
Release files for poascan 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| poascan-0.7.0.tar.gz | 203.0 kB | With provenance | Details for poascan-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| poascan-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for poascan-0.7.0-py3-none-any.whl |
Total release size: 349.9 kB
Release files / poascan-0.7.0.tar.gz
| Download URL | poascan-0.7.0.tar.gz |
|---|---|
| Size | 203.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
554adf05fd922afa3801f14033aaa01b6531ac014ba3efcddf79c3ef4d6c0c8f
|
|
BLAKE2b-256 checksum How to use checksums |
37dc024c5e25994f837de0ec9138d3b71be7ac6eb5d91fcb8f2f5e1e60c689fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Transparency logRelease files / poascan-0.7.0-py3-none-any.whl
| Download URL | poascan-0.7.0-py3-none-any.whl |
|---|---|
| Size | 146.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c61d92a4650eb1616d156044d515f0f7c49087406ad64a7050f3f81f3cca285e
|
|
BLAKE2b-256 checksum How to use checksums |
3a109f705515104c5509fb3b1e0af71a09d913d560cedefc795d2a566e213b7b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Transparency logSecurity for poascan 0.7.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for poascan-0.7.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.