docs
This commit is contained in:
parent
f82f8db57f
commit
4b6fbf00a8
|
@ -1,12 +1,10 @@
|
||||||
use ethers::providers::{Provider, ProviderTrait};
|
use ethers::{types::UnsignedTransaction, HttpProvider, MainnetWallet};
|
||||||
use ethers::types::{BlockNumber, UnsignedTransaction};
|
|
||||||
use ethers::wallet::MainnetWallet;
|
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), failure::Error> {
|
async fn main() -> Result<(), failure::Error> {
|
||||||
let provider = Provider::try_from("http://localhost:8545")?;
|
let provider = HttpProvider::try_from("http://localhost:8545")?;
|
||||||
let client = MainnetWallet::from_str(
|
let client = MainnetWallet::from_str(
|
||||||
"d8ebe1e50cfea1f9961908d9df28e64bb163fee9ee48320361b2eb0a54974269",
|
"d8ebe1e50cfea1f9961908d9df28e64bb163fee9ee48320361b2eb0a54974269",
|
||||||
)?
|
)?
|
||||||
|
@ -19,7 +17,7 @@ async fn main() -> Result<(), failure::Error> {
|
||||||
let tx = UnsignedTransaction {
|
let tx = UnsignedTransaction {
|
||||||
to: Some("986eE0C8B91A58e490Ee59718Cca41056Cf55f24".parse().unwrap()),
|
to: Some("986eE0C8B91A58e490Ee59718Cca41056Cf55f24".parse().unwrap()),
|
||||||
gas: 21000.into(),
|
gas: 21000.into(),
|
||||||
gas_price: 100000.into(),
|
gas_price: 100_000.into(),
|
||||||
value: 10000.into(),
|
value: 10000.into(),
|
||||||
input: vec![].into(),
|
input: vec![].into(),
|
||||||
nonce,
|
nonce,
|
||||||
|
|
|
@ -1,20 +1,18 @@
|
||||||
use ethers::providers::{Provider, ProviderTrait};
|
use ethers::{
|
||||||
use ethers::types::{Address, BlockNumber, TransactionRequest};
|
types::{BlockNumber, TransactionRequest},
|
||||||
|
HttpProvider,
|
||||||
|
};
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::str::FromStr;
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), failure::Error> {
|
async fn main() -> Result<(), failure::Error> {
|
||||||
let provider = Provider::try_from("http://localhost:8545")?;
|
let provider = HttpProvider::try_from("http://localhost:8545")?;
|
||||||
|
let from = "4916064D2E9C1b2ccC466EEc3d30B2b08F1C130D".parse()?;
|
||||||
let from = Address::from_str("4916064D2E9C1b2ccC466EEc3d30B2b08F1C130D")?;
|
|
||||||
|
|
||||||
let tx_hash = provider
|
let tx_hash = provider
|
||||||
.send_transaction(TransactionRequest {
|
.send_transaction(TransactionRequest {
|
||||||
from,
|
from,
|
||||||
to: Some(Address::from_str(
|
to: Some("9A7e5d4bcA656182e66e33340d776D1542143006".parse()?),
|
||||||
"9A7e5d4bcA656182e66e33340d776D1542143006",
|
|
||||||
)?),
|
|
||||||
value: Some(1000u64.into()),
|
value: Some(1000u64.into()),
|
||||||
gas: None,
|
gas: None,
|
||||||
gas_price: None,
|
gas_price: None,
|
||||||
|
|
15
src/lib.rs
15
src/lib.rs
|
@ -1,10 +1,25 @@
|
||||||
//! ethers-rs
|
//! ethers-rs
|
||||||
//!
|
//!
|
||||||
//! ethers-rs is a port of [ethers-js](github.com/ethers-io/ethers.js) in Rust.
|
//! ethers-rs is a port of [ethers-js](github.com/ethers-io/ethers.js) in Rust.
|
||||||
|
//!
|
||||||
|
//! # Quickstart
|
||||||
|
//!
|
||||||
|
//! ## Sending Ether
|
||||||
|
//!
|
||||||
|
//! ## Checking the state of the blockchain
|
||||||
|
//!
|
||||||
|
//! ## Deploying and interacting with a smart contract
|
||||||
|
//!
|
||||||
|
//! ## Watching on-chain events
|
||||||
|
//!
|
||||||
|
//! More examples can be found in the [`examples` directory of the
|
||||||
|
//! repositry](https://github.com/gakonst/ethers-rs)
|
||||||
|
|
||||||
pub mod providers;
|
pub mod providers;
|
||||||
|
pub use providers::HttpProvider;
|
||||||
|
|
||||||
pub mod signers;
|
pub mod signers;
|
||||||
|
pub use signers::{AnyWallet, MainnetWallet};
|
||||||
|
|
||||||
/// Ethereum related datatypes
|
/// Ethereum related datatypes
|
||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
|
@ -69,11 +69,11 @@ impl Provider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<&str> for Provider {
|
impl TryFrom<&str> for super::Provider<Provider> {
|
||||||
type Error = ParseError;
|
type Error = ParseError;
|
||||||
|
|
||||||
fn try_from(src: &str) -> Result<Self, Self::Error> {
|
fn try_from(src: &str) -> Result<Self, Self::Error> {
|
||||||
Ok(Provider::new(Url::parse(src)?))
|
Ok(super::Provider(Provider::new(Url::parse(src)?)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,10 @@ pub mod instantiated {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::signers::Wallet;
|
use crate::signers::Wallet;
|
||||||
|
|
||||||
|
/// A Wallet instantiated with chain_id = 1 for Ethereum Mainnet.
|
||||||
pub type MainnetWallet = Wallet<Mainnet>;
|
pub type MainnetWallet = Wallet<Mainnet>;
|
||||||
|
|
||||||
|
/// A wallet which does not use EIP-155 and does not take the chain id into account
|
||||||
|
/// when creating transactions
|
||||||
pub type AnyWallet = Wallet<EIP155Disabled>;
|
pub type AnyWallet = Wallet<EIP155Disabled>;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue