Skip to content
프로젝트

소개

Alloy 프로젝트를 위한 트랜스포트, 미들웨어 및 네트워크입니다.

시스템 및 인프라

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
+1
in 7 days
+1
in 15 days
+2
in 1 month
+7

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

Alloy

Alloy connects applications to blockchains.

Alloy is a rewrite of ethers-rs from the ground up, with exciting new features, high performance, and excellent docs.

We also have a book on all things Alloy and many examples to help you get started.

Telegram chat

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 the alloy crate from the command line using Cargo:

cargo add alloy

Alternatively, you can add the following to your Cargo.toml file:

alloy = "2"

The default features include contracts, an HTTP provider, Ethereum RPC types, and a local signer. For WebSocket and IPC transports plus commonly used extended RPC APIs, enable the full feature:

cargo add alloy --features full

full is a convenience bundle, not every optional integration. Node process bindings, ENS, genesis and trie support, and cloud or hardware signers remain opt-in. For finer control, enable only the features you need or depend on the individual crates directly.

A comprehensive list of available features can be found on docs.rs or in the alloy crate's Cargo.toml.

If you want to use ProviderBuilder::connect_anvil* helpers from the alloy meta-crate, enable the provider-anvil-node feature:

cargo add alloy --features provider-anvil-node

If you only need the alloy::node_bindings re-export, enable the node-bindings feature:

cargo add alloy --features node-bindings

If you are already using full, add node-bindings explicitly because full does not include it:

cargo add alloy --features "full,node-bindings"

If you depend on alloy-provider directly instead of the alloy meta-crate, enable the anvil-node feature there.

Examples

Connecting to a Provider

Here's a simple example of connecting to an Ethereum node and querying the latest block:

use alloy::providers::{Provider, ProviderBuilder};

# async fn example() -> Result<(), Box<dyn std::error::Error>> {
// Create a provider with the HTTP transport using the `reqwest` crate.
let rpc_url = "https://eth.llamarpc.com";
let provider = ProviderBuilder::new().connect(rpc_url).await?;

// Get the latest block number.
let latest_block = provider.get_block_number().await?;
println!("Latest block number: {latest_block}");

// Get chain ID.
let chain_id = provider.get_chain_id().await?;
println!("Chain ID: {chain_id}");
# Ok(())
# }

Network generic

Alloy is network-generic, allowing you to work with any Ethereum-compatible chain. Here's an example using Optimism (see op-alloy) to demonstrate this capability:

use alloy::providers::{Provider, ProviderBuilder};
use op_alloy::network::Optimism;

# async fn example() -> Result<(), Box<dyn std::error::Error>> {
// Connect to Optimism mainnet.
let rpc_url = "https://mainnet.optimism.io";
let provider = ProviderBuilder::new_with_network::<Optimism>().connect(rpc_url).await?;
# Ok(())
# }

For more examples, check out the Alloy examples repository.

Overview

This repository contains the following crates:

Supported Rust Versions (MSRV)

The current MSRV (minimum supported rust version) is 1.94.1.

Alloy will keep a rolling MSRV policy of at least two versions behind the latest stable release.

Note that the MSRV is not increased automatically, and only as part of a patch (pre-1.0) or minor (post-1.0) release.

Contributing

Thanks for your help improving the project! We are so happy to have you! We have a contributing guide to help you get involved in the Alloy project.

Pull requests will not be merged unless CI passes, so please ensure that your contribution follows the linting rules and passes clippy.

Note on no_std

Because these crates are primarily network-focused, we do not intend to support no_std for most of them at this time.

The following crates support no_std with default features disabled:

Crate Version Badge
alloy-eips Crates.io
alloy-genesis Crates.io
alloy-serde Crates.io
alloy-consensus Crates.io
alloy-consensus-any Crates.io
alloy-network-primitives Crates.io
alloy-rpc-types-eth Crates.io
alloy-rpc-types-debug Crates.io
alloy-rpc-types-engine Crates.io

If you would like to add no_std support to a crate, please make sure to update scripts/check_no_std.sh as well.

Credits

None of these crates would have been possible without the great work done in:

Project Description
ethers.js A complete and compact JavaScript library for interacting with the Ethereum blockchain.
rust-web3 Rust library for Ethereum JSON-RPC client communication, including support for async and WASM.
ruint A fast, no-std, const-friendly implementation of fixed-size unsigned integers in Rust.
ethabi Ethereum ABI encoding/decoding in Rust for contracts and transactions.
ethcontract-rs Rust library to generate type-safe bindings to Ethereum smart contracts.
guac_rs Rust implementation of the GUAC protocol for Ethereum state channels.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in these crates by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

관련 프로젝트 살펴보기

불러오는 중…