# `Cartouche`
[🔗](https://github.com/zenhive/cartouche/blob/main/lib/cartouche.ex#L1)

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`](https://hexdocs.pm/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
| Function | Arity | Description | Param Kinds |
| --- | --- | --- | --- |
| `get_contract_address` | 1 | Resolve a configured contract reference (raw address, 0x-hex, or alias atom) to a 20-byte address. | `address: value` |
| `describe` | 2 | Describe Cartouche's registered API surface at progressive levels of detail. | `mod_or_short: value`, `func_name: value` |

# `address`

```elixir
@type address() :: &lt;&lt;_::160&gt;&gt;
```

# `bytes32`

```elixir
@type bytes32() :: &lt;&lt;_::256&gt;&gt;
```

# `contract`

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

# `signature`

```elixir
@type signature() :: &lt;&lt;_::520&gt;&gt;
```

# `describe`

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

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

# `describe`

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

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

# `describe`

```elixir
@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`

```elixir
@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>>

---

*Consult [api-reference.md](api-reference.md) for complete listing*
