Installation
op-alloy consists of a number of crates that provide a range of functionality essential for interfacing with any OP Stack chain.
The most succinct way to work with op-alloy
is to add the op-alloy
crate
with the full
feature flag from the command-line using Cargo.
cargo add op-alloy --features full
Alternatively, you can add the following to your Cargo.toml
file.
op-alloy = { version = "0.5", features = ["full"] }
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 op-alloy
crate with the features you need.
After op-alloy
is added as a dependency, crates re-exported by op-alloy
are now available.
#![allow(unused)] fn main() { use op_alloy::{ genesis::{RollupConfig, SystemConfig}, consensus::OpBlock, protocol::BlockInfo, network::Optimism, provider::ext::engine::OpEngineApi, rpc_types::OpTransactionReceipt, rpc_jsonrpsee::traits::RollupNode, rpc_types_engine::OpAttributesWithParent, }; }
Features
The op-alloy
defines many feature flags including the following.
Default
std
k256
serde
Full enables the most commonly used crates.
full
The k256
feature flag enables the k256
feature on the op-alloy-consensus
crate.
k256
Arbitrary enables arbitrary features on crates, deriving the Arbitrary
trait on types.
arbitrary
Serde derives serde's Serialize and Deserialize traits on types.
serde
Additionally, individual crates can be enabled using their shorthand names.
For example, the consensus
feature flag provides the op-alloy-consensus
re-export
so op-alloy-consensus
types can be used from op-alloy
through op_alloy::consensus::InsertTypeHere
.
Crates
op-alloy-network
op-alloy-genesis
(supportsno_std
)op-alloy-protocol
(supportsno_std
)op-alloy-provider
op-alloy-consensus
(supportsno_std
)op-alloy-rpc-jsonrpsee
op-alloy-rpc-types
(supportsno_std
)op-alloy-rpc-types-engine
(supportsno_std
)
no_std
As noted above, the following crates are no_std
compatible.
To add no_std
support to a crate, ensure the check_no_std
script is updated to include this crate once no_std
compatible.