# Cartouche v0.1.3 - API Reference

## Modules

- [Cartouche](Cartouche.md): Cartouche is a library for interacting with private keys, signatures, and Etheruem.

- [Cartouche.Address](Cartouche.Address.md): Helpers for Ethereum addresses.

- [Cartouche.Assembly](Cartouche.Assembly.md): A for-fun assembler of EVM assembly code from a simple
lisp-like language used to construct Quark scripts.
- [Cartouche.Base58](Cartouche.Base58.md): Base58 encoding and decoding using the Bitcoin/Solana alphabet.
- [Cartouche.Block](Cartouche.Block.md): Represents a block from the Ethereum JSON-RPC endpoint.
- [Cartouche.Block.Withdrawal](Cartouche.Block.Withdrawal.md): A validator withdrawal entry from a post-Shanghai block (EIP-4895).
- [Cartouche.Chain](Cartouche.Chain.md): Chain registry and chain-id parsing helpers.

- [Cartouche.Contract.IConsole](Cartouche.Contract.IConsole.md): This module was auto-generated by Cartouche. Any changes may be lost.
- [Cartouche.Contract.Sleuth](Cartouche.Contract.Sleuth.md): This module was auto-generated by Cartouche. Any changes may be lost.
- [Cartouche.DebugTrace](Cartouche.DebugTrace.md): Represents an Ethereum transaction debug trace, which contains information
about the call graph of an executed transaction. Note: this is different
from `trace_call` and instead has deep struct logs for execution.
- [Cartouche.DebugTrace.StructLog](Cartouche.DebugTrace.StructLog.md): One execution step inside a `Cartouche.DebugTrace` — the EVM opcode,
program counter, call depth, remaining gas, gas cost of this step, and
the stack snapshot at that point.

- [Cartouche.Erc20](Cartouche.Erc20.md): A wrapper for an [ERC-20 contract](https://eips.ethereum.org/EIPS/eip-20),
allowing the code to interact by pulling data from the contract, or sending
transaction to it.

- [Cartouche.Erc20.Call](Cartouche.Erc20.Call.md): Module to call operations and receive return value, without sending a transaction.

- [Cartouche.Erc20.CallData](Cartouche.Erc20.CallData.md): Module to encode `calldata` for given adaptor operations.

- [Cartouche.FeeHistory](Cartouche.FeeHistory.md): Represents fee history data as defined in EIP-1559.
- [Cartouche.Filter](Cartouche.Filter.md): A system to create an Ethereum log filter and have
parsed events passed back to registered processes.

- [Cartouche.HTTP](Cartouche.HTTP.md): HTTP helpers used by cartouche's RPC transports.

- [Cartouche.Hash](Cartouche.Hash.md): Keccak-256 helpers for hashing arbitrary binaries.
- [Cartouche.Hex](Cartouche.Hex.md): Helper module for parsing and encoding hex values.
- [Cartouche.Keys](Cartouche.Keys.md): Cartouche library to generate Ethereum key pairs.

- [Cartouche.OpenChain](Cartouche.OpenChain.md): API Client for [OpenChain.xyz](https://openchain.xyz] API.

- [Cartouche.RPC](Cartouche.RPC.md): Excessively simple RPC client for Ethereum.

- [Cartouche.Receipt](Cartouche.Receipt.md): Represents an Ethereum transaction receipt, which contains information
about the success or failure of an Ethereum transaction after it has
been included in a mined Ethereum block.
- [Cartouche.Receipt.Log](Cartouche.Receipt.Log.md): An event log entry emitted during the transaction referenced by a
`Cartouche.Receipt` — address, data, indexed topics, and the block/tx
position needed to locate the log on chain.

- [Cartouche.Recover](Cartouche.Recover.md): EIP-191 (`personal_sign`) signature recovery primitives.
- [Cartouche.RecoveryBit](Cartouche.RecoveryBit.md): There are a number of ways to look at recovery bits. Either
- [Cartouche.Signer](Cartouche.Signer.md): Cartouche.Signer is a GenServer which can sign messages. This module takes an
mfa (mod, func, args triple) which defines how to actually sign messages.
For instance, `Cartouche.Signer.Curvy` will sign with a public key, or
`Cartouche.Signer.CloudKMS` will sign using a GCP Cloud KMS key. In either
case, the caller should start the GenServer, and then call:
`Cartouche.Signer.sign(MySigner, "message")`. This should return back a
properly signed message.
- [Cartouche.Signer.CloudKMS](Cartouche.Signer.CloudKMS.md): Signer to sign messages from a Google Cloud KMS key.

- [Cartouche.Signer.Curvy](Cartouche.Signer.Curvy.md): Signer to sign messages using a private key directly.
- [Cartouche.Sleuth](Cartouche.Sleuth.md): Sleuth allows you to run a contract call as a single
`eth_call` call.
- [Cartouche.Solana.ATA](Cartouche.Solana.ATA.md): Associated Token Account (ATA) utilities for Solana.
- [Cartouche.Solana.Keys](Cartouche.Solana.Keys.md): Ed25519 keypair generation and management for Solana.
- [Cartouche.Solana.PDA](Cartouche.Solana.PDA.md): Program Derived Addresses (PDAs) for Solana.
- [Cartouche.Solana.Programs](Cartouche.Solana.Programs.md): Well-known Solana program IDs and addresses.
- [Cartouche.Solana.RPC](Cartouche.Solana.RPC.md): JSON-RPC client for Solana.
- [Cartouche.Solana.Signer](Cartouche.Solana.Signer.md): GenServer that wraps Ed25519 signing backends for Solana.
- [Cartouche.Solana.Signer.CloudKMS](Cartouche.Solana.Signer.CloudKMS.md): Ed25519 signing backend using Google Cloud KMS.
- [Cartouche.Solana.Signer.Ed25519](Cartouche.Solana.Signer.Ed25519.md): Ed25519 signing backend using a local private key seed.
- [Cartouche.Solana.SystemProgram](Cartouche.Solana.SystemProgram.md): Instructions for the Solana System Program.
- [Cartouche.Solana.Token](Cartouche.Solana.Token.md): High-level token operations for Solana: balance queries, transfers,
and ATA management.
- [Cartouche.Solana.TokenProgram](Cartouche.Solana.TokenProgram.md): Instruction builders for the SPL Token Program.
- [Cartouche.Solana.Transaction](Cartouche.Solana.Transaction.md): Build, serialize, sign, and deserialize Solana transactions (legacy format).
- [Cartouche.Solana.Transaction.AccountMeta](Cartouche.Solana.Transaction.AccountMeta.md): Account reference with permission flags.
- [Cartouche.Solana.Transaction.CompiledInstruction](Cartouche.Solana.Transaction.CompiledInstruction.md): An instruction compiled to account indices.
- [Cartouche.Solana.Transaction.Header](Cartouche.Solana.Transaction.Header.md): Message header with account permission counts.
- [Cartouche.Solana.Transaction.Instruction](Cartouche.Solana.Transaction.Instruction.md): A high-level instruction before compilation.
- [Cartouche.Solana.Transaction.Message](Cartouche.Solana.Transaction.Message.md): The transaction message that gets signed.
- [Cartouche.Trace](Cartouche.Trace.md): Represents an Ethereum transaction trace, which contains information
about the call graph of an executed transaction.
- [Cartouche.Trace.Action](Cartouche.Trace.Action.md): A single sub-action inside a `Cartouche.Trace` — the `call`, `create`,
or `suicide` operation the traced transaction performed at one frame of
its call graph (from, to, value, gas, input, and call-type metadata).

- [Cartouche.TraceCall](Cartouche.TraceCall.md): Represents an Ethereum `eth_callMany` trace, which contains information
about the call graph of the speculative execution of several transactions.
- [Cartouche.Transaction](Cartouche.Transaction.md): A module to help build, sign and encode Ethereum transactions.

- [Cartouche.Transaction.V1](Cartouche.Transaction.V1.md): Represents a V1 or "Legacy" (that is, pre-EIP-1559) transaction.

- [Cartouche.Transaction.V2](Cartouche.Transaction.V2.md): Represents a V2 or EIP-1559 transaction.

- [Cartouche.Typed](Cartouche.Typed.md): Module to build EIP-712 typed data, which can then be signed or recovered from.

- [Cartouche.Typed.Domain](Cartouche.Typed.Domain.md): EIP-712 domain separator — the standard `EIP712Domain` struct
(`name`, `version`, `chainId`, `verifyingContract`, `salt`). Each field is
optional; only the populated fields contribute to the encoded domain type.

- [Cartouche.Typed.Type](Cartouche.Typed.Type.md): EIP-712 type definition — an ordered list of `{name, field_type}` field
entries. Field types are either primitives (`:address`, `{:uint, 256}`,
`:bool`, …) or string references to other named types.

- [Cartouche.VM](Cartouche.VM.md): An Ethereum VM in Cartouche, that can only execute pure functions.

- [Cartouche.VM.Context](Cartouche.VM.Context.md): Runtime execution state of a `Cartouche.VM` step: program counter, stack,
memory, transient storage, halt/revert flags, return data, and the FFI
table available to the VM.

- [Cartouche.VM.ExecutionResult](Cartouche.VM.ExecutionResult.md): Terminal result of a `Cartouche.VM` run: the final stack, whether the
call reverted, and the return data.

- [Cartouche.VM.Input](Cartouche.VM.Input.md): Input to a `Cartouche.VM` execution: the calldata handed to the EVM
entrypoint and the call's `msg.value`.

- [Cartouche.Wei](Cartouche.Wei.md): Conversions between Ethereum denominations and wei.

- Exceptions
  - [Cartouche.Hex.InvalidHex](Cartouche.Hex.InvalidHex.md): Raised by `Cartouche.Hex` decode/encode bang functions when input is not
valid hex (wrong length, non-hex characters, missing/extra `0x` prefix, etc.).
  - [Cartouche.VM.InvalidVm](Cartouche.VM.InvalidVm.md): Raised by `Cartouche.VM.exec/3` (and friends) when the EVM run terminates
in a non-recoverable error state — e.g. invalid opcode, stack underflow,
or unhandled exception inside an opcode handler.

## Mix Tasks

- [mix cartouche.gen](Mix.Tasks.Cartouche.Gen.md): `cartouche.gen` generates wrapper modules from Solidity artifacts.

