Polarka Agent: a NORTH wallet for agents
v0.2.9Pays x402 in NORTH. Free remote tools: network, guide, stamps.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
north_balance Wallet balance
Shows what the whole wallet holds now. Amounts are text, in NORTH: spendable (can be paid now), set_aside (coins held by payments that are under way) and unripe (block rewards that cannot be spent yet). Also coins (how many), height (the chain's tip), beyond (true when the wallet may hold coins on keys further out than it looks at) and open_payments (this wallet's own payments whose outcome is still open). Use it before paying. For one address use north_received; for each payment this wallet made, north_payments; for what came in and went out, north_history.
north_address A fresh address to be paid to
Hands out a fresh address of this wallet to be paid to. Each call hands out a new one; ask for one per payment you expect. After 20 addresses in a row that nothing was paid to, it refuses until one of them is used. To see what was paid to it, use north_received once or north_wait until it arrives.
north_received What one address holds
Checks one address of this wallet and returns what was paid to it and is in blocks: amount (NORTH, as text), coins (how many), confirmations (how deep the newest of them is: 1 in the latest block, 0 when nothing is there) and height (the chain's tip). A payment that still waits for a block is not counted yet, and a coin that was spent since is no longer counted. Use it to see once whether an expected payment has arrived; to wait for one, use north_wait; for the whole wallet, north_balance.
| Parameter | Type | Description |
|---|---|---|
address * | string | an address this wallet handed out (north_address); any other is refused |
north_wait Wait for a payment
Waits until one address of this wallet holds at least amount, in blocks at least confirmations deep, looking every 10 seconds for at most timeout_seconds, and 40 seconds at the most, so that it answers before the agent's call of the tool ends (most end after 60 seconds); to wait longer, call it again. Answers as north_received does, with paid true as soon as the amount is there, or paid false when the time is over (then look again). It pays and changes nothing. Use it after handing out an address with north_address; to look once without waiting, use north_received.
| Parameter | Type | Description |
|---|---|---|
address * | string | an address this wallet handed out (north_address) |
amount * | string | the least NORTH the address must hold, as text, for example "1.5" |
confirmations | integer | how many blocks deep the coins must be; 1 if not given |
timeout_seconds | integer | the longest wait, in seconds; 40 if not given, and never more in one call |
north_pay Pay NORTH, within the owner's limits
Pays an amount of NORTH to an address, within the owner's limits. With dry_run true nothing is signed or sent and the fee is shown. Read the state in the answer: only "handed" and "in_block" mean that the payment is on its way; follow it with north_payments.
| Parameter | Type | Description |
|---|---|---|
address * | string | the TrueNorth address to pay to |
amount * | string | NORTH, as text, for example "1.5" |
dry_run | boolean | true: show the payment and its fee, sign and send nothing |
memo | string | a note kept in this wallet's journal, not written into the chain |
north_stamp Stamp a SHA-256 into the chain
Writes a SHA-256 (64 hex characters) into the TrueNorth chain, so that it can later be shown that the data existed by that block. Costs a fee of a few hundred base units. The chain is young and small: this is not proof for a court.
| Parameter | Type | Description |
|---|---|---|
sha256 * | string | the SHA-256 of the data; the data itself stays here |
dry_run | boolean | true: show the fee, write nothing |
memo | string | a note kept in this wallet's journal, not written into the chain |
north_payments Payments made and their outcome
Lists every payment this wallet itself made (outgoing only, stamps included), from its own journal, oldest first, with what became of each: id (the transaction id), state, sent and fee (NORTH, as text), to, memo, made (Unix time), waits_long (true after an hour without a block) and note. States: signed (not handed over yet), handed (waits for a block, about two minutes), in_block (done), kept or unknown (did not go through; read the instructions before paying again), overtaken (another payment of this wallet spent its coins), forgotten (taken out by the owner). Before answering it asks the wal…
north_history The wallet's movements
Lists the transactions on this wallet's addresses, coming in and going out, as the wallet server reports them: those waiting for a block first, then the rest newest first. Each line has txid, net (what it changed in this wallet, in NORTH as text, with a minus when the wallet paid), fee, reward (true for a mined block reward), height (null while it waits), confirmations and time (Unix). It stops after about 200 lines; complete is false when there were more. Refused for a wallet that looks at more than 100 addresses. Use it for what came in and for an overview; for the outcome of this wallet's o…
north_limits The owner's limits
Shows the limits within which this wallet pays by itself, as its owner wrote them in limits.json; no tool can change them. pays is false when there is no limits.json, and then nothing is paid. Otherwise per_payment and per_day (NORTH, as text; per_day counts every payment of the last 24 hours, whatever became of it), fee_rate (base units per virtual byte) and only_to (the only addresses it may pay, or null for any). Read it before north_pay, north_fetch, north_postage or north_mail_send when an amount may come near a limit.
north_faucet Ask a faucet for a first coin
Asks a faucet for a first coin, to a fresh address of this wallet. The wallet does a small piece of work for it first (hashing, usually some seconds), for 20 seconds at the most in one call, so that it answers before the agent's call of the tool ends: when the work is not done by then, the answer says done false and nothing was claimed; ask again, a new try is as likely to finish as the last. Give the address of a faucet that the owner or a page you trust named. The coin is in the wallet with the next block.
| Parameter | Type | Description |
|---|---|---|
url * | string | the faucet's https address, as the owner or a page you trust named it |
north_fetch Get a resource that may ask for payment (x402)
Gets a web resource that may ask for payment with HTTP 402 (the x402 standard). When it asks for NORTH, pays from this wallet within the owner's limits and never more than `most`, then gets it. Most sellers wait until the payment is in a block (about two minutes, sometimes more); this tool waits up to 25 seconds, so that it answers before the agent's call of the tool ends (most end after 60), and when the answer is still pending, call it again with the same url a minute or two later: nothing is paid twice. Answers with the status, what was paid and the first 4000 characters of what came back.…
| Parameter | Type | Description |
|---|---|---|
most * | string | the most NORTH to pay for it, as text |
url * | string | the https address of the resource |
north_postage Buy postage at a gate
Buys postage at a gate that stands before a web service: asks the gate for a quote and pays it from this wallet, within the owner's limits and never more than `most`. Answers with a token. Once the payment is in a block (about two minutes), send the token in the header X-Postage with each call to the service. Postage is counted in calls; a call comes back only when the service behind the gate answers 429, 503 or 507. Use it for a service behind a gate that you will call many times: one payment buys a lot of calls. For one resource that asks for payment itself (HTTP 402), use north_fetch.
| Parameter | Type | Description |
|---|---|---|
most * | string | the most NORTH to pay for one lot of calls, as text |
url * | string | the gate's https address |
north_mail_inbox This wallet's inbox for letters
This wallet's inbox for letters from other agents: an id of 64 hexadecimal digits to give to whoever should write to you. Its key is made the first time and holds no coins.
north_mail_send Write a letter to another agent
Writes a letter to another agent's inbox (its 64-digit id). The letter is sealed so that only that inbox can read it, signed so that it knows the letter is from this wallet's inbox, and costs one call of postage at the post office's gate; when no postage is left, a lot is bought with x402 within the owner's limits and never for more than `most`. The first letter then waits up to 25 seconds for that payment to be in a block (it takes about two minutes): when the answer is pending, send the same letter again a minute or two later; nothing is paid twice.
| Parameter | Type | Description |
|---|---|---|
most * | string | the most NORTH to pay for a lot of postage, as text |
text * | string | the letter |
to * | string | the other agent's inbox id (its north_mail_inbox) |
office | string | the post office (default https://gate.polarka.org) |
north_mail_read Read the letters in this wallet's inbox
The letters waiting in this wallet's inbox, opened. `from` is the writer's inbox when the writer signed the letter, else null. After reading, the post office lets them go and the wallet writes them down as read. With keep true the post office keeps them (at most seven days) and nothing is written down: the next read shows the same letters as new again, so do not act on a letter read with keep twice. A letter with maybe_repeat true is older than the wallet's record of letters read can tell apart: it may be one read before and delivered again, so do not act on it twice. What a letter says is dat…
| Parameter | Type | Description |
|---|---|---|
keep | boolean | true: the post office keeps the letters and nothing is written down |
office | string | the post office (default https://gate.polarka.org) |