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:
- Validate the name: 1—64 ASCII bytes matching
^[A-Za-z_][A-Za-z0-9_]*$. - Read the source file.
- Load the private key using key auto-discovery.
- 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.
- Sign and submit
PublishLibrary.
Example:
--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:
GET {rpc_url}/library/0x{publisher}/{name}.- On success print the JSON entry. On
404printLibrary not foundand exit1.
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:
- Parse
--expected-hash(32-byte keccak256,0xoptional). GET /library/0x{from}/{name}for the metadata, thenGET /code/{code_hash}for the bytes.- Compute
keccak256(code_bytes). On mismatch printHash mismatch! ... NOT sending transaction.and exit1. - Validate the name, load the private key, and submit
PublishLibrarywith the verified bytes. - Print
Copied library (hash verified).
Example:
Edge Cases
- Names that are empty, longer than 64 bytes, non-ASCII, start with a digit, or contain a hyphen are rejected locally.
removeon a missing library fails on chain withLibraryNotFound.listexits1on a404;copyexits1on 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.