Cartouche (Cartouche v0.2.2)

Copy Markdown View Source

Cartouche is a library for interacting with private keys, signatures, and Ethereum.

API discovery

Cartouche exposes a machine-readable API surface for AI agents and introspection tooling via descripex:

Cartouche.describe()                  # registered modules + namespaces
Cartouche.describe(:signer)            # function list for one module
Cartouche.describe(:signer, :sign_direct)   # full param/return detail
Cartouche.describe(:solana_rpc)        # Solana RPC helpers
Cartouche.describe(:transaction_v1)    # nested Transaction.V1 helpers
Cartouche.describe(:transaction_v2)    # nested Transaction.V2 helpers

The registered module list is built up as Phase 12 lands; see ROADMAP.md Phase 12 for the annotation pass.

API Functions

FunctionArityDescriptionParam Kinds
get_contract_address1Resolve a configured contract reference (raw address, 0x-hex, or alias atom) to a 20-byte address.address: value
describe2Describe Cartouche's registered API surface at progressive levels of detail.mod_or_short: value, func_name: value

Summary

Functions

Return a Level 1 overview of all modules in this library.

Return Level 2 function list for a module by full atom, Descripex short name, or Cartouche alias.

Return Level 3 function detail for a module by full atom, Descripex short name, or Cartouche alias.

Returns a contract address, that may have been set in configuration.

Types

address()

@type address() :: <<_::160>>

bytes32()

@type bytes32() :: <<_::256>>

contract()

@type contract() :: address() | atom()

signature()

@type signature() :: <<_::520>>

Functions

describe()

@spec describe() :: [map()]

Return a Level 1 overview of all modules in this library.

describe(mod_or_short)

@spec describe(module() | atom()) :: [map()]

Return Level 2 function list for a module by full atom, Descripex short name, or Cartouche alias.

describe(mod_or_short, func_name)

@spec describe(module() | atom(), atom()) :: map() | nil

Return Level 3 function detail for a module by full atom, Descripex short name, or Cartouche alias.

get_contract_address(address)

@spec get_contract_address(binary() | atom()) :: address()

Returns a contract address, that may have been set in configuration.

Examples

iex> Cartouche.get_contract_address(<<1::160>>)
<<1::160>>

iex> Cartouche.get_contract_address("0x0000000000000000000000000000000000000001")
<<1::160>>

iex> Application.put_env(:cartouche, :contracts, [test: "0x0000000000000000000000000000000000000001"])
iex> Cartouche.get_contract_address(:test)
<<1::160>>