Alloy Series: Installation

Installation process of alloy and brief description.

Installation

  • Alloy consists of a number of crates that provide a range of functionality essential for interfacing with any Ethereum-based blockchain.
  • The easiest way to get started is to add alloy crate from the command-line using Cargo:
cargo add alloy
  • Alternatively, you can add the following to your Cargo.toml file
alloy = "1.0"
  • For more fine-grained control over the features you wish to include, you can add the individual crates to your Cargo.toml file, or use the alloy crate with the features you need.
  • After alloy is added as a dependency you can now import alloy as follows:
use alloy::{
    network::EthereumWallet,
    node_bindings::Anvil,
    primitives::U256,
    providers::ProviderBuilder,
    signers::local::PrivateKeySigner,
    sol
}

Features

  • The alloy meta-crate defines a number of feature-flags:

Default

  • std
  • reqwest
  • alloy-core/default
  • essentials

Essentials

  • contract
  • provider-http
  • rpc-types
  • signer-local

Full

  • consensus
  • eips
  • essentials
  • k256
  • kzg
  • network
  • provider-ws
  • provider-ipc
  • provider-trace-api
  • provider-txpool-api
  • provider-debug-api
  • provider-anvil-api
  • pubsub

  • By default alloy uses reqwest HTTP client.
  • Alternatively one can swithc to hyper.

Crates

  • alloy -> Meta-crate for the entire project, including alloy-core
  • aloy-consensus -> Ethereum consensus interface
  • alloy-contract -> Interact with on-chain contracts
  • alloy-eips -> Ethereum Improvement Proposals (EIP) implementations
  • alloy-genesis -> Ethereum genesis file definitions.
  • alloy-json-rpc -> Core data types for JSON-RPC 2.0 clients
  • alloy-network -> Network abstraction for RPC types
    • alloy-network-primitives -> Primitive types for the network abstraction.
  • alloy-node-bindings -> Etehreum execution layer client bindings
  • alloy-provider -> Interface with an Ethereum blockchain.
  • alloy-pubsub -> Ethereum JSON-RPC publish-subscribe tower service and type definitions
  • alloy-rpc-client -> Low-level Ethereum JSON-RPC client implementation
  • alloy-rpc-types -> Meta-crate for all Ethereum JSON-RPC types
    • alloy-rpc-types-admin -> Types for the admin Ethereum JSON-RPC namespace
    • alloy-rpc-types-anvil -> Types for the Anvil development node's Ethereum JSON-RPC namespace.
    • alloy-rpc-types-engine -> Types for the engine Ethereum JSON-RPC namespace
    • alloy-rpc-types-eth -> Types for the eth Ethereum JSON-RPC namespace
    • alloy-rpc-types-mev -> Types for the MEV bundle JSON-RPC namespace
    • alloy-rpc-types-trace -> Types fooor the trace Ethereum JSON-RPC namespace
    • alloy-rpc-types-txpool -> Types for the txpool Ethereum JSON-RPC namespace
  • alloy-serde -> Serde related utilities
  • alloy-signer -> Ethereum signer abstraction
    • alloy-signer-aws -> AWS KMS signer implementation
    • alloy-signer-gcp -> GCP KMS signer implementation
    • alloy-signer-ledger -> Ledger Signer implementation
    • alloy-signer-local -> Local signer implementations
    • alloy-signer-trezor -> Trezor signer implementation
  • alloy-transport -> Low-level Ethereum JSON-RPC transaport abstraction
  • alloy-transport-http -> HTTP Transport implementation
  • alloy-transport-ipc -> IPC Transport Implementation
  • alloy-transport-ws -> WS transport implementation
  • alloy-core -> consists of the following crates
    • alloy-dyn-abi -> Run-time ABI and EIP-712 implementations
    • alloy-json-abi -> Full Ethereum JSON-ABI implementation
    • alloy-primitives -> Primitive integer and byte types
    • alloy-sol-macor-expander -> Expander used in the Solidity to Rust procedural macro
    • alloy-sol-type-parser -> A simple parser for solidity type strings
    • alloy-sol-types -> Compile time ABI and EIP 712 implementations
    • syn-solidity -> syn powered solidity parser