Search documentation of Cartouche

# API Reference Cartouche v#0.1.3

Copy Markdown View Source

## Modules

Cartouche

Cartouche is a library for interacting with private keys, signatures, and Etheruem.

Cartouche.Address

Helpers for Ethereum addresses.

Cartouche.Assembly

A for-fun assembler of EVM assembly code from a simple lisp-like language used to construct Quark scripts.

Cartouche.Base58

Base58 encoding and decoding using the Bitcoin/Solana alphabet.

Cartouche.Block

Represents a block from the Ethereum JSON-RPC endpoint.

Cartouche.Block.Withdrawal

A validator withdrawal entry from a post-Shanghai block (EIP-4895).

Cartouche.Chain

Chain registry and chain-id parsing helpers.

Cartouche.Contract.IConsole

This module was auto-generated by Cartouche. Any changes may be lost.

Cartouche.Contract.Sleuth

This module was auto-generated by Cartouche. Any changes may be lost.

Cartouche.DebugTrace

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

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

A wrapper for an ERC-20 contract, allowing the code to interact by pulling data from the contract, or sending transaction to it.

Cartouche.Erc20.Call

Module to call operations and receive return value, without sending a transaction.

Cartouche.Erc20.CallData

Module to encode `calldata` for given adaptor operations.

Cartouche.FeeHistory

Represents fee history data as defined in EIP-1559.

Cartouche.Filter

A system to create an Ethereum log filter and have parsed events passed back to registered processes.

Cartouche.HTTP

HTTP helpers used by cartouche's RPC transports.

Cartouche.Hash

Keccak-256 helpers for hashing arbitrary binaries.

Cartouche.Hex

Helper module for parsing and encoding hex values.

Cartouche.Hex.InvalidHex

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.Keys

Cartouche library to generate Ethereum key pairs.

Cartouche.OpenChain

API Client for [OpenChain.xyz](https://openchain.xyz] API.

Cartouche.RPC

Excessively simple RPC client for Ethereum.

Cartouche.Receipt

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

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

EIP-191 (`personal_sign`) signature recovery primitives.

Cartouche.RecoveryBit

There are a number of ways to look at recovery bits. Either

Cartouche.Signer

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

Signer to sign messages from a Google Cloud KMS key.

Cartouche.Signer.Curvy

Signer to sign messages using a private key directly.

Cartouche.Sleuth

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

Cartouche.Solana.ATA

Associated Token Account (ATA) utilities for Solana.

Cartouche.Solana.Keys

Ed25519 keypair generation and management for Solana.

Cartouche.Solana.PDA

Program Derived Addresses (PDAs) for Solana.

Cartouche.Solana.Programs

Well-known Solana program IDs and addresses.

Cartouche.Solana.RPC

JSON-RPC client for Solana.

Cartouche.Solana.Signer

GenServer that wraps Ed25519 signing backends for Solana.

Cartouche.Solana.Signer.CloudKMS

Ed25519 signing backend using Google Cloud KMS.

Cartouche.Solana.Signer.Ed25519

Ed25519 signing backend using a local private key seed.

Cartouche.Solana.SystemProgram

Instructions for the Solana System Program.

Cartouche.Solana.Token

High-level token operations for Solana: balance queries, transfers, and ATA management.

Cartouche.Solana.TokenProgram

Instruction builders for the SPL Token Program.

Cartouche.Solana.Transaction

Build, serialize, sign, and deserialize Solana transactions (legacy format).

Cartouche.Solana.Transaction.AccountMeta

Account reference with permission flags.

Cartouche.Solana.Transaction.CompiledInstruction

An instruction compiled to account indices.

Cartouche.Solana.Transaction.Header

Message header with account permission counts.

Cartouche.Solana.Transaction.Instruction

A high-level instruction before compilation.

Cartouche.Solana.Transaction.Message

The transaction message that gets signed.

Cartouche.Trace

Represents an Ethereum transaction trace, which contains information about the call graph of an executed transaction.

Cartouche.Trace.Action

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

Represents an Ethereum `eth_callMany` trace, which contains information about the call graph of the speculative execution of several transactions.

Cartouche.Transaction

A module to help build, sign and encode Ethereum transactions.

Cartouche.Transaction.V1

Represents a V1 or "Legacy" (that is, pre-EIP-1559) transaction.

Cartouche.Transaction.V2

Represents a V2 or EIP-1559 transaction.

Cartouche.Typed

Module to build EIP-712 typed data, which can then be signed or recovered from.

Cartouche.Typed.Domain

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

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

An Ethereum VM in Cartouche, that can only execute pure functions.

Cartouche.VM.Context

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

Terminal result of a `Cartouche.VM` run: the final stack, whether the call reverted, and the return data.

Cartouche.VM.Input

Input to a `Cartouche.VM` execution: the calldata handed to the EVM entrypoint and the call's `msg.value`.

Cartouche.VM.InvalidVm

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.

Cartouche.Wei

Conversions between Ethereum denominations and wei.

## Mix Tasks

mix cartouche.gen

`cartouche.gen` generates wrapper modules from Solidity artifacts.