civitas makes agent keys, charters agents and manages them straight on a Solana RPC, pays for calls as an agent, and serves a sample paid feed. Principal commands sign with a keypair file and send the transaction themselves.
Version 0.2.0. It installs as the civitas binary with the four packages it uses:
npm install ./civitas-contract-0.2.0.tgz ./civitas-program-0.2.0.tgz ./civitas-agent-0.2.0.tgz ./civitas-service-0.2.0.tgz ./civitas-cli-0.2.0.tgzAmounts are integer base units: 1000000 is 1 USDC. Its usage, as civitas --help prints it:
civitas <command> [options]
keygen --out KEYPAIR.json
consent --keypair AGENT.json --principal KEY --card-hash HEX [--expires-at ISO|UNIX]
charter --agent-keypair AGENT.json (or --agent KEY --consent-signature BASE58 --consent-expires-at ISO|UNIX)
--name NAME --endpoint URL --offers TEXT [--deposit UNITS]
--max-per-call UNITS --max-per-period UNITS --period-seconds SECONDS [--card-out PATH]
policy --agent KEY --max-per-call UNITS --max-per-period UNITS --period-seconds SECONDS
fund --agent KEY --amount UNITS
withdraw --agent KEY --amount UNITS
freeze --agent KEY
unfreeze --agent KEY
revoke --agent KEY
list --agent KEY --endpoint URL --price UNITS
unlist --agent KEY
pay <url> [--max-per-call UNITS]
serve --price UNITS --port PORT --submitter KEYPAIR.json [--principal KEY]
Global options: --rpc URL, --api URL, --cluster NETWORK, --keypair PATH, --json, --help
Policy options: --counterparty KEY (repeatable), --expires-at UNIX_SECONDS
USDC amounts are integer base units. 1 USDC = 1,000,000 units.Global flags
| Flag | Environment | What it is |
|---|---|---|
--rpc | SOLANA_RPC_URL | The Solana RPC. Defaults to the local validator when the cluster is localnet. |
--api | CIVITAS_API_URL | The Civitas API’s base URL, for agent cards, the payer’s nonce and receipts. |
--cluster | CLUSTER | The network name. Defaults to localnet. |
--keypair | CIVITAS_KEYPAIR_PATH | A 64-byte Solana keypair file: the principal for management commands, the agent for consent and pay, the payee agent for serve. |
--help, -h | Print the usage and exit. | |
--json | Print JSON to stdout, and errors as JSON to stderr. |
Other environment variables it reads:
SOLANA_WS_URL: WebSocket RPC for following transactions.SUBMITTER_KEYPAIR_PATH: The default forserve --submitter.SERVICE_PRINCIPAL: The default forserve --principal.LOOKUP_TABLE: An active address lookup table to build transactions over.USDC_MINT: Forserve: the mint to check the program’s config against.
Commands
keygen
Writes a new Solana keypair file and prints its public key. It won’t overwrite an existing file.
--outstringrequired- Where to write the keypair file.
Prints:
publicKey: The new public key.path: Where the file was written.
From civitas 0.2.0 on a local validator with the Civitas API, 2026-11-26 UTC:
civitas keygen --out research-agent.json --json{
"publicKey": "7NwcJTttoLkrohqpPkNdEjvX3w478dix31CSSc375tC5",
"path": "<dir>/research-agent.json"
}consent
Signs the agent key’s consent to be chartered by --principal with the card --card-hash, for a principal who has only the public key. --keypair is the agent’s keypair file. The consent is good for an hour unless --expires-at says otherwise.
--keypairstringrequired- A 64-byte Solana keypair file: the principal for management commands, the agent for
consentandpay, the payee agent forserve. --principalstringrequired- The public key of the wallet that will charter the agent.
--card-hashstringrequired- The card’s hash, 64 hex digits, as
POST /v1/cardsreturned it. --expires-atstring- When the consent expires, ISO 8601 UTC or Unix seconds. Defaults to an hour from now.
Prints:
signature: The consent signature, base58: pass it tocharter --consent-signature.expiresAt: The expiry it signed, ISO 8601 UTC: pass it tocharter --consent-expires-at.
From civitas 0.2.0 on a local validator with the Civitas API, 2026-11-26 UTC:
civitas consent --keypair research-agent.json --principal <principal address> --card-hash ddfcac0b0e97a20438a58d8d6d41c046abb4d1fb21cfe6d0e894d5d9162a8124 --json{
"signature": "2bSJTQc23m5KiiM9ZjCbnSkKjCBV7GQc9JwBNXHaK3aSc7aB9zQsBKXxQ97YxxsXhCFnVtEMCTTx7xk9LXvrGGiY",
"expiresAt": "2026-11-26T12:09:53.000Z"
}charter
Charters an agent under the --keypair wallet: agent account, policy version 1, vault and the first deposit. The agent key’s consent comes one of two ways: --agent-keypair signs it on the spot, or --agent with --consent-signature and --consent-expires-at carries one made with civitas consent. With --api the card is posted to the API and its URI stored on chain; without, the card JSON is written to --card-out and its file: URI stored.
--keypairstringrequired- A 64-byte Solana keypair file: the principal for management commands, the agent for
consentandpay, the payee agent forserve. --agentstring- The agent’s public key.
--agent-keypairstring- For
charter: the agent’s keypair file, which signs the consent on the spot. Use it or--agentwith a consent signature. --consent-signaturestring- For
charterwith--agent: the signaturecivitas consentprinted. --consent-expires-atstring- For
charter: the expiry the consent signed, ISO 8601 UTC or Unix seconds. With--agent-keypairit defaults to an hour from now. --namestringrequired- The agent card’s name.
--endpointstringrequired- For
charter, the card’s endpoint; forlist, the service’s URL. An http or https URL. --offersstringrequired- What the agent offers, for its card.
--card-outstring- Where to write the card JSON. Defaults to
<agent>.card.json. --depositstring- First deposit in base units. Defaults to 0.
--max-per-callstringrequired- For
charterandpolicy, the policy’s per-call limit; forpay, the most this call may cost, amount and fee together. Base units. --max-per-periodstringrequired- The policy’s period cap, base units.
--period-secondsstringrequired- The policy’s period length in seconds.
--expires-atstring- The policy’s expiry in Unix seconds. Defaults to 0, for none.
--counterpartystring, repeatable- A payee the agent may pay. Repeat it for each; leave it out for open.
Prints:
signature: The transaction’s signature.agent: The agent key.cardHash:charteronly: the card’s hash.cardUri:charteronly: the card’s URI.
From civitas 0.2.0 on a local validator with the Civitas API, 2026-11-26 UTC:
With a consent from civitas consent:
civitas charter --keypair research-principal.json --agent 7NwcJTttoLkrohqpPkNdEjvX3w478dix31CSSc375tC5 \
--consent-signature <signature> --consent-expires-at 2026-11-26T12:09:53.000Z \
--name "Research agent" --endpoint "https://research.example/agent" --offers "Buys station readings per call" \
--max-per-call 300000 --max-per-period 2000000 --period-seconds 86400 --deposit 1000000 \
--api http://127.0.0.1:4380 --json{
"signature": "3AxSBYojfuUAamreyHdHktd8gc9tzFVvzQLh6J6wxs3x8kdiEE3QeDisiJqKmXZLhaHJSWd84wpbyRdcn2ePrhee",
"agent": "7NwcJTttoLkrohqpPkNdEjvX3w478dix31CSSc375tC5",
"cardHash": "ddfcac0b0e97a20438a58d8d6d41c046abb4d1fb21cfe6d0e894d5d9162a8124",
"cardUri": "http://127.0.0.1:4380/v1/cards/ddfcac0b0e97a20438a58d8d6d41c046abb4d1fb21cfe6d0e894d5d9162a8124"
}With the agent’s keypair file, which signs the consent itself:
civitas charter --keypair feed-principal.json --agent-keypair feed-agent.json \
--name "Station feed" --endpoint http://127.0.0.1:27431/feed --offers "Station readings, one per call" \
--max-per-call 100000 --max-per-period 100000 --period-seconds 86400 --api http://127.0.0.1:4380 --json{
"signature": "fxeG3RZY9UUM6HYr2M3pwLxjCGaLDaHokhaG2CF4vLZGBeCnm92g83KfAzK6fdGTMH2DZPJg2RADCzdUJBAF8wG",
"agent": "7rAhGgYhJgfiskiVo6XrL5yv88uNp1ZVC3pBR9YaXHhT",
"cardHash": "92d9bf9c2252a8ef69698e2110ee9140e8a0e2bc516ad618befb750bf40a5594",
"cardUri": "http://127.0.0.1:4380/v1/cards/92d9bf9c2252a8ef69698e2110ee9140e8a0e2bc516ad618befb750bf40a5594"
}policy
Sets a new policy. Its version goes up by one.
--keypairstringrequired- A 64-byte Solana keypair file: the principal for management commands, the agent for
consentandpay, the payee agent forserve. --agentstringrequired- The agent’s public key.
--max-per-callstringrequired- For
charterandpolicy, the policy’s per-call limit; forpay, the most this call may cost, amount and fee together. Base units. --max-per-periodstringrequired- The policy’s period cap, base units.
--period-secondsstringrequired- The policy’s period length in seconds.
--expires-atstring- The policy’s expiry in Unix seconds. Defaults to 0, for none.
--counterpartystring, repeatable- A payee the agent may pay. Repeat it for each; leave it out for open.
Prints:
signature: The transaction’s signature.agent: The agent key.cardHash:charteronly: the card’s hash.cardUri:charteronly: the card’s URI.
fund
Deposits USDC from the --keypair wallet into the agent’s vault. Any wallet can fund any agent.
--keypairstringrequired- A 64-byte Solana keypair file: the principal for management commands, the agent for
consentandpay, the payee agent forserve. --agentstringrequired- The agent’s public key.
--amountstringrequired- Base units.
Prints:
signature: The transaction’s signature.agent: The agent key.cardHash:charteronly: the card’s hash.cardUri:charteronly: the card’s URI.
withdraw
Withdraws USDC from the vault to the principal.
--keypairstringrequired- A 64-byte Solana keypair file: the principal for management commands, the agent for
consentandpay, the payee agent forserve. --agentstringrequired- The agent’s public key.
--amountstringrequired- Base units.
Prints:
signature: The transaction’s signature.agent: The agent key.cardHash:charteronly: the card’s hash.cardUri:charteronly: the card’s URI.
freeze
Freezes the agent. Its next settlement is refused.
--keypairstringrequired- A 64-byte Solana keypair file: the principal for management commands, the agent for
consentandpay, the payee agent forserve. --agentstringrequired- The agent’s public key.
Prints:
signature: The transaction’s signature.agent: The agent key.cardHash:charteronly: the card’s hash.cardUri:charteronly: the card’s URI.
unfreeze
Unfreezes the agent.
--keypairstringrequired- A 64-byte Solana keypair file: the principal for management commands, the agent for
consentandpay, the payee agent forserve. --agentstringrequired- The agent’s public key.
Prints:
signature: The transaction’s signature.agent: The agent key.cardHash:charteronly: the card’s hash.cardUri:charteronly: the card’s URI.
revoke
Revokes the agent: the vault returns to the principal and the agent is closed for good.
--keypairstringrequired- A 64-byte Solana keypair file: the principal for management commands, the agent for
consentandpay, the payee agent forserve. --agentstringrequired- The agent’s public key.
Prints:
signature: The transaction’s signature.agent: The agent key.cardHash:charteronly: the card’s hash.cardUri:charteronly: the card’s URI.
list
Lists the agent’s service with its endpoint and price per call, or changes the listing.
--keypairstringrequired- A 64-byte Solana keypair file: the principal for management commands, the agent for
consentandpay, the payee agent forserve. --agentstringrequired- The agent’s public key.
--endpointstringrequired- For
charter, the card’s endpoint; forlist, the service’s URL. An http or https URL. --pricestringrequired- Price per call in base units.
Prints:
signature: The transaction’s signature.agent: The agent key.cardHash:charteronly: the card’s hash.cardUri:charteronly: the card’s URI.
From civitas 0.2.0 on a local validator with the Civitas API, 2026-11-26 UTC:
civitas list --keypair feed-principal.json --agent 7rAhGgYhJgfiskiVo6XrL5yv88uNp1ZVC3pBR9YaXHhT --endpoint http://127.0.0.1:27431/feed --price 200000 --json{
"signature": "42y775vdBU68RF4LjSrUF5YT3YBytHAqWoYX9fPaZhPJu3epkoaJhMNuTLAePcXhkmts8Te7gZ6ubpLNfaCUZm1C",
"agent": "7rAhGgYhJgfiskiVo6XrL5yv88uNp1ZVC3pBR9YaXHhT"
}unlist
Takes the agent’s service out of the catalog.
--keypairstringrequired- A 64-byte Solana keypair file: the principal for management commands, the agent for
consentandpay, the payee agent forserve. --agentstringrequired- The agent’s public key.
Prints:
signature: The transaction’s signature.agent: The agent key.cardHash:charteronly: the card’s hash.cardUri:charteronly: the card’s URI.
pay
Calls <url> as the --keypair agent with @civitas/agent, paying the 402 if there is one, and prints the response.
<url>urlrequired- The URL to call.
--keypairstringrequired- A 64-byte Solana keypair file: the principal for management commands, the agent for
consentandpay, the payee agent forserve. --max-per-callstring- For
charterandpolicy, the policy’s per-call limit; forpay, the most this call may cost, amount and fee together. Base units.
Prints:
status: The response’s HTTP status.body: The response body as text.payment: The PaymentResponse, ornullif the call wasn’t paid.latencyMs: Milliseconds from the 402 to the paid response, ornull.
From civitas 0.2.0 on a local validator with the Civitas API, 2026-11-26 UTC:
civitas pay http://127.0.0.1:27431/feed --keypair research-agent.json --max-per-call 300000 --api http://127.0.0.1:4380 --json{
"status": 200,
"body": "{\"cluster\":\"localnet\",\"slot\":31805,\"observedAt\":\"2026-11-26T11:10:04.530Z\"}",
"payment": {
"success": true,
"network": "localnet",
"transaction": "5gQNsw9SsHmkCKcgpYof61qFpN7tvPf9ZZczsXU5JoLjK89c3rV7nuEDyoeA5a6Y5wwHmLK4XKijgEnTJSQpJV2f",
"payer": "7NwcJTttoLkrohqpPkNdEjvX3w478dix31CSSc375tC5",
"receipt": {
"settlementSignature": "5gQNsw9SsHmkCKcgpYof61qFpN7tvPf9ZZczsXU5JoLjK89c3rV7nuEDyoeA5a6Y5wwHmLK4XKijgEnTJSQpJV2f",
"callId": "3b31bc7ba08e63d4b50652704a1c3db2ff3457c12fdc76d14b494e7e27a8b9f0",
"payer": "7NwcJTttoLkrohqpPkNdEjvX3w478dix31CSSc375tC5",
"payee": "7rAhGgYhJgfiskiVo6XrL5yv88uNp1ZVC3pBR9YaXHhT",
"amount": "200000",
"servedAt": "2026-11-26T11:10:04.000Z",
"responseHash": "88a2423ab34eb183cd3574edb3ff6922cbce1bb51066eaa565666cfa2fd56518",
"signature": "32k6RV5xtFNBRcnH12mAL8FVEw458skNCWQSErGR7rgoWWvHMRN9dK7StgaVMMGhHETZTWM8ZhW12V49A76V7QzC"
}
},
"latencyMs": 631
}serve
Serves a sample JSON feed at http://127.0.0.1:<port>/feed behind @civitas/service, with --keypair as the payee and --submitter paying the network fees. When the payee is chartered, --principal names the wallet that chartered it, and serve refuses to start if the charter says otherwise. Runs until stopped.
--keypairstringrequired- A 64-byte Solana keypair file: the principal for management commands, the agent for
consentandpay, the payee agent forserve. --pricestringrequired- Price per call in base units.
--portstringrequired- The port
servebinds on 127.0.0.1. --submitterstringrequired- The keypair file that signs and pays for settlements. Defaults to
SUBMITTER_KEYPAIR_PATH. --principalstring- The public key of the wallet that chartered the payee. Required when the payee is chartered. Defaults to
SERVICE_PRINCIPAL.
Prints once it is listening:
url: The feed’s URL.payee: The payee key.price: The price per call, base units.
From civitas 0.2.0 on a local validator with the Civitas API, 2026-11-26 UTC:
civitas serve --keypair feed-agent.json --submitter feed-principal.json --principal <feed principal> --price 200000 --port 27431 --api http://127.0.0.1:4380url: http://127.0.0.1:27431/feed
payee: 7rAhGgYhJgfiskiVo6XrL5yv88uNp1ZVC3pBR9YaXHhT
price: 200000Output and exit codes
Each command prints its fields as name: value lines, or one JSON object with --json. It exits 0 on success and 1 on any failure. With --json a failure writes { "error": "<name>", "message": "<detail>" } to stderr; a program refusal keeps its program error name, such as OverPeriodCap. Here the agent’s own limit is below price plus fee, so it refuses before signing:
civitas pay http://127.0.0.1:27431/feed --keypair research-agent.json --max-per-call 150000 --api http://127.0.0.1:4380 --json{
"error": "OverPerCallLimit",
"message": "Payment plus fee requires 200500 base units."
}