2020-05-31 16:38:41 +00:00
|
|
|
#![warn(
|
|
|
|
missing_debug_implementations,
|
|
|
|
missing_docs,
|
|
|
|
rust_2018_idioms,
|
|
|
|
unreachable_pub
|
|
|
|
)]
|
2020-12-17 11:26:01 +00:00
|
|
|
#![deny(broken_intra_doc_links)]
|
2020-05-31 16:38:41 +00:00
|
|
|
#![doc(test(
|
|
|
|
no_crate_inject,
|
|
|
|
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
|
|
|
))]
|
|
|
|
|
2020-06-20 13:55:07 +00:00
|
|
|
//! # Complete Ethereum & Celo library and wallet implementation.
|
2020-05-22 18:37:21 +00:00
|
|
|
//!
|
2020-05-31 16:38:41 +00:00
|
|
|
//! > ethers-rs is a port of [ethers-js](github.com/ethers-io/ethers.js) in Rust.
|
2020-05-24 15:55:46 +00:00
|
|
|
//!
|
2020-06-11 08:40:07 +00:00
|
|
|
//! ## Quickstart: `prelude`
|
2020-06-04 18:44:02 +00:00
|
|
|
//!
|
2020-06-11 08:40:07 +00:00
|
|
|
//! A prelude is provided which imports all the important data types and traits for you. Use this
|
|
|
|
//! when you want to quickly bootstrap a new project.
|
|
|
|
//!
|
2020-06-20 13:55:07 +00:00
|
|
|
//! ```no_run
|
2020-06-11 08:40:07 +00:00
|
|
|
//! # #[allow(unused)]
|
2020-06-04 18:44:02 +00:00
|
|
|
//! use ethers::prelude::*;
|
|
|
|
//! ```
|
|
|
|
//!
|
2020-06-11 08:40:07 +00:00
|
|
|
//! Examples on how you can use the types imported by the prelude can be found in
|
2020-06-20 13:55:07 +00:00
|
|
|
//! the [`examples` directory of the repository](https://github.com/gakonst/ethers-rs/tree/master/ethers/examples)
|
2020-06-11 08:40:07 +00:00
|
|
|
//! and in the `tests/` directories of each crate.
|
|
|
|
//!
|
|
|
|
//! # Quick explanation of each module in ascending order of abstraction
|
|
|
|
//!
|
|
|
|
//! ## `core`
|
|
|
|
//!
|
2020-06-20 13:55:07 +00:00
|
|
|
//! Contains all the [necessary data structures](core::types) for interacting
|
2020-06-11 08:40:07 +00:00
|
|
|
//! with Ethereum, along with cryptographic utilities for signing and verifying
|
|
|
|
//! ECDSA signatures on `secp256k1`. Bindings to the solidity compiler and `ganache-cli`
|
|
|
|
//! are also provided as helpers. To simplify your imports, consider using the re-exported
|
|
|
|
//! modules described in the next subsection.
|
|
|
|
//!
|
|
|
|
//! ## `utils`, `types`, `abi`
|
|
|
|
//!
|
|
|
|
//! These are re-exports of the [`utils`], [`types`] and [`abi`] modules from the `core` crate
|
2020-06-04 18:44:02 +00:00
|
|
|
//!
|
2020-06-11 08:40:07 +00:00
|
|
|
//! ## `providers`
|
2020-06-04 18:44:02 +00:00
|
|
|
//!
|
2020-06-11 08:40:07 +00:00
|
|
|
//! Ethereum nodes expose RPC endpoints (by default at `localhost:8545`). You can connect
|
|
|
|
//! to them by using the [`Provider`]. The provider instance
|
|
|
|
//! allows you to issue requests to the node which involve querying the state of Ethereum or
|
|
|
|
//! broadcasting transactions with unlocked accounts on the node.
|
2020-05-24 15:55:46 +00:00
|
|
|
//!
|
2020-06-11 08:40:07 +00:00
|
|
|
//! ## `signers`
|
2020-05-24 15:55:46 +00:00
|
|
|
//!
|
2020-12-31 19:08:12 +00:00
|
|
|
//! This module provides a [`Signer`] trait which can be used for signing messages
|
|
|
|
//! or transactions. A [`Wallet`] type is implemented which can be used with a
|
|
|
|
//! raw private key, or a YubiHSM2. We also provide Ledger support.
|
2020-05-24 15:55:46 +00:00
|
|
|
//!
|
2020-06-11 08:40:07 +00:00
|
|
|
//! ## `contract`
|
2020-05-24 15:55:46 +00:00
|
|
|
//!
|
2020-06-11 08:40:07 +00:00
|
|
|
//! Interacting with Ethereum is not restricted to sending or receiving funds. It also involves
|
|
|
|
//! using smart contracts, which can be thought of as programs with persistent storage.
|
|
|
|
//!
|
|
|
|
//! Interacting with a smart contract requires broadcasting carefully crafted
|
2020-06-20 13:55:07 +00:00
|
|
|
//! [transactions](core::types::TransactionRequest) where the `data` field contains
|
2020-06-11 08:40:07 +00:00
|
|
|
//! the [function's
|
|
|
|
//! selector](https://ethereum.stackexchange.com/questions/72363/what-is-a-function-selector)
|
|
|
|
//! along with the arguments of the called function. This module provides the
|
|
|
|
//! [`Contract`] and [`ContractFactory`] abstractions so that you do not have to worry about that.
|
|
|
|
//! It also provides typesafe bindings via the [`abigen`] macro and the [`Abigen` builder].
|
|
|
|
//!
|
2020-12-31 19:08:12 +00:00
|
|
|
//! ## `middleware`
|
|
|
|
//!
|
|
|
|
//! In order to keep the ethers architecture as modular as possible, providers define a [`Middleware`]
|
|
|
|
//! trait which defines all the methods to interact with an Ethereum node. By implementing the
|
|
|
|
//! middleware trait, you are able to override the default behavior of methods and do things such
|
|
|
|
//! as using other gas oracles, escalating your transactions' gas prices, or signing your transactions
|
|
|
|
//! with a [`Signer`]. The middleware architecture allows users to either use one of the existing
|
|
|
|
//! middleware, or they are free to write on of their own.
|
|
|
|
//!
|
2020-06-20 13:55:07 +00:00
|
|
|
//! [`Provider`]: providers::Provider
|
2020-12-31 19:08:12 +00:00
|
|
|
//! [`Middleware`]: providers::Middleware
|
2020-06-20 13:55:07 +00:00
|
|
|
//! [`Wallet`]: signers::Wallet
|
2020-12-31 19:08:12 +00:00
|
|
|
//! [`Signer`]: signers::Signer
|
2020-06-20 13:55:07 +00:00
|
|
|
//! [`ContractFactory`]: contract::ContractFactory
|
|
|
|
//! [`Contract`]: contract::Contract
|
|
|
|
//! [`abigen`]: ./contract/macro.abigen.html
|
|
|
|
//! [`Abigen` builder]: contract::Abigen
|
|
|
|
//! [`utils`]: core::utils
|
|
|
|
//! [`abi`]: core::abi
|
|
|
|
//! [`types`]: core::types
|
|
|
|
pub use ethers_contract as contract;
|
|
|
|
pub use ethers_core as core;
|
2020-09-24 21:33:09 +00:00
|
|
|
pub use ethers_middleware as middleware;
|
2020-12-31 17:19:14 +00:00
|
|
|
pub use ethers_providers as providers;
|
|
|
|
pub use ethers_signers as signers;
|
2020-09-24 21:33:09 +00:00
|
|
|
|
2020-06-11 08:40:07 +00:00
|
|
|
// Re-export ethers_core::utils/types/abi
|
2020-06-20 13:55:07 +00:00
|
|
|
// We hide these docs so that the rustdoc links send the visitor
|
|
|
|
// to the corresponding crate, instead of the re-export
|
|
|
|
#[doc(hidden)]
|
2020-06-11 08:40:07 +00:00
|
|
|
pub use ethers_core::abi;
|
2020-06-20 13:55:07 +00:00
|
|
|
#[doc(hidden)]
|
2020-06-11 08:40:07 +00:00
|
|
|
pub use ethers_core::types;
|
2020-06-20 13:55:07 +00:00
|
|
|
#[doc(hidden)]
|
2020-05-31 16:20:08 +00:00
|
|
|
pub use ethers_core::utils;
|
|
|
|
|
2020-06-11 08:40:07 +00:00
|
|
|
/// Easy imports of frequently used type definitions and traits
|
2020-06-20 13:55:07 +00:00
|
|
|
#[doc(hidden)]
|
2020-05-31 16:20:08 +00:00
|
|
|
pub mod prelude {
|
|
|
|
pub use ethers_contract::*;
|
2020-12-31 17:19:14 +00:00
|
|
|
pub use ethers_core::types::*;
|
|
|
|
pub use ethers_middleware::*;
|
2020-05-31 16:20:08 +00:00
|
|
|
pub use ethers_providers::*;
|
|
|
|
pub use ethers_signers::*;
|
|
|
|
}
|