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

Sleuth allows you to run a contract call as a single
`eth_call` call.

Note: Cartouche.Contract.Sleuth generated from `mix cartouche.gen --prefix cartouche/contract ./priv/Sleuth.json`

# `query`

```elixir
@spec query(binary(), binary(), ABI.FunctionSelector.t(), Keyword.t()) ::
  {:ok, term()} | {:error, String.t()}
```

Runs a Sleuth contract query: deploys `bytecode` on-chain via `eth_call`
with `query` calldata and decodes the result against `selector`. Returns
the decoded values without struct annotations.

# `query_annotated`

```elixir
@spec query_annotated(binary(), binary(), ABI.FunctionSelector.t(), Keyword.t()) ::
  {:ok, term()} | {:error, String.t()}
```

Same as `query/4`, but tags each decoded value with its ABI type for
callers that need both type and value (e.g. when re-encoding).

# `query_by`

```elixir
@spec query_by(module()) :: {:ok, term()} | {:error, String.t()}
```

Single-argument form of `query_by/2`: defaults `fun` to `:query` and
`opts` to `[]`.

# `query_by`

```elixir
@spec query_by(module(), atom() | Keyword.t()) :: {:ok, term()} | {:error, String.t()}
```

Convenience wrapper that derives bytecode, query calldata, and selector
from a generated contract module. Resolves `mod.bytecode/0`,
`mod.encode_<fun>/0`, and `mod.<fun>_selector/0` and forwards the rest
to `query/4`.

# `query_by`

```elixir
@spec query_by(module(), atom(), Keyword.t()) :: {:ok, term()} | {:error, String.t()}
```

Three-argument form of `query_by/2`: explicit `fun` and `opts`.

# `query_v2`

```elixir
@spec query_v2(binary(), binary(), ABI.FunctionSelector.t(), Keyword.t()) ::
  {:ok, term()} | {:error, String.t()}
```

Variant of `query/4` that exposes the full set of decode options
(`:annotated`, `:decode_binaries`, `:decode_structs`, `:named_returns`,
`:sleuth_address`) as keyword opts. Returns results with named-return
annotations when configured.

---

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