# `Onchain.Configuration`
[🔗](https://github.com/ZenHive/onchain-stack/blob/onchain-v0.16.0/packages/onchain/lib/onchain/configuration.ex#L1)

Configuration and API discovery for the signing, transaction and RPC modules
(formerly the `Cartouche` root module). Application-env keys stay under
`:cartouche`.

## API discovery

This module exposes a machine-readable API surface for AI agents and
introspection tooling via [`descripex`](https://hexdocs.pm/descripex):

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

The registered module list is built up as Phase 12 lands; see the root
`ROADMAP.md` Phase 2012 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, _::_*8&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> Onchain.Configuration.get_contract_address(<<1::160>>)
    <<1::160>>

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

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

---

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