Skip to main content

Synopsis

cowboy lib manages the CIP-26 library catalog: Python source files published under a publisher account so that actors can import them by (publisher, name). --rpc-url and --private-key are global flags. The RPC URL resolves like any command’s (--rpc-url, then COWBOY_RPC_URL, then the selected environment’s endpoint, then http://localhost:4000); the private key uses key auto-discovery.

Subcommands

cowboy lib publish

Publish (or update) a library under the signer’s publisher address. Behavior:
  1. Validate the name: 1—64 ASCII bytes matching ^[A-Za-z_][A-Za-z0-9_]*$.
  2. Read the source file.
  3. Load the private key using key auto-discovery.
  4. Size the transaction’s gas from the source length (200 base cycles + 22 cycles/byte; 41 cells/byte; each padded 25%, floor 200,000). A source over 131,072 bytes is rejected before signing.
  5. Sign and submit PublishLibrary.
Flags: Example:
Output is the transaction submission summary (see --help).

cowboy lib remove

Remove a library under the signer’s publisher address. Non-idempotent: removing a missing library fails with LibraryNotFound. Flags:

cowboy lib list

Query a library’s catalog entry. Read-only; no private key. Behavior:
  1. GET {rpc_url}/library/0x{publisher}/{name}.
  2. On success print the JSON entry. On 404 print Library not found and exit 1.
Flags: Example:

cowboy lib copy

Fetch a library from another publisher, verify its hash locally, and republish the audited bytes under your own publisher account. No new chain instruction is used; this is a client-side helper that ends in an ordinary PublishLibrary. Behavior:
  1. Parse --expected-hash (32-byte keccak256, 0x optional).
  2. GET /library/0x{from}/{name} for the metadata, then GET /code/{code_hash} for the bytes.
  3. Compute keccak256(code_bytes). On mismatch print Hash mismatch! ... NOT sending transaction. and exit 1.
  4. Validate the name, load the private key, and submit PublishLibrary with the verified bytes.
  5. Print Copied library (hash verified).
Flags: Example:

Edge Cases

  • Names that are empty, longer than 64 bytes, non-ASCII, start with a digit, or contain a hyphen are rejected locally.
  • remove on a missing library fails on chain with LibraryNotFound.
  • list exits 1 on a 404; copy exits 1 on a hash mismatch and sends no transaction.
  • The largest publishable source is 131,072 bytes (the codec’s library cap, which binds before the User-lane limit). Larger sources are rejected before signing.