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
API Functions
| Function | Arity | Description | Param Kinds |
|---|---|---|---|
query_v2 | 4 | Run a Sleuth query with the full decode option set exposed. | bytecode: value, query: value, selector: value, opts: value |
query_by | 3 | Run a Sleuth query using a generated contract module's bytecode, calldata encoder, and selector. | mod: value, fun: value, opts: value |
query_annotated | 4 | Run a Sleuth query and tag each decoded return value with its ABI type. | bytecode: value, query: value, selector: value, opts: value |
query | 4 | Run a Sleuth contract query and return decoded values without ABI type annotations. | bytecode: value, query: value, selector: value, opts: value |
Summary
Functions
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.
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).
Single-argument form of query_by/2: defaults fun to :query and
opts to [].
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.
Three-argument form of query_by/2: explicit fun and opts.
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.
Functions
@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.
@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).
Single-argument form of query_by/2: defaults fun to :query and
opts to [].
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.
Three-argument form of query_by/2: explicit fun and opts.
@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.