pub struct DeploymentTxFactory<B, M> { /* private fields */ }
Available on crate feature providers only.
Expand description

To deploy a contract to the Ethereum network, a ContractFactory can be created which manages the Contract bytecode and Application Binary Interface (ABI), usually generated from the Solidity compiler.

Once the factory’s deployment transaction is mined with sufficient confirmations, the Contract object is returned.

§Example

use ethers_contract::ContractFactory;
use ethers_core::types::Bytes;
use ethers_providers::{Provider, Http};

// get the contract ABI and bytecode
let abi = Default::default();
let bytecode = Bytes::from_static(b"...");

// connect to the network
let client = Provider::<Http>::try_from("http://localhost:8545").unwrap();
let client = std::sync::Arc::new(client);

// create a factory which will be used to deploy instances of the contract
let factory = ContractFactory::new(abi, bytecode, client);

// The deployer created by the `deploy` call exposes a builder which gets consumed
// by the async `send` call
let contract = factory
    .deploy("initial value".to_string())?
    .confirmations(0usize)
    .send()
    .await?;
println!("{}", contract.address());

Implementations§

source§

impl<B, M> DeploymentTxFactory<B, M>
where B: Borrow<M> + Clone, M: Middleware,

source

pub fn new(abi: Abi, bytecode: Bytes, client: B) -> Self

Creates a factory for deployment of the Contract with bytecode, and the constructor defined in the abi. The client will be used to send any deployment transaction.

source

pub fn deploy_tokens( self, params: Vec<Token> ) -> Result<Deployer<B, M>, ContractError<M>>
where B: Clone,

Create a deployment tx using the provided tokens as constructor arguments

source

pub fn deploy<T: Tokenize>( self, constructor_args: T ) -> Result<Deployer<B, M>, ContractError<M>>

Constructs the deployment transaction based on the provided constructor arguments and returns a Deployer instance. You must call send() in order to actually deploy the contract.

Notes:

  1. If there are no constructor arguments, you should pass () as the argument.
  2. The default poll duration is 7 seconds.
  3. The default number of confirmations is 1 block.

Trait Implementations§

source§

impl<B, M> Clone for DeploymentTxFactory<B, M>
where B: Clone,

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<B: Debug, M: Debug> Debug for DeploymentTxFactory<B, M>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<B, M> RefUnwindSafe for DeploymentTxFactory<B, M>

§

impl<B, M> Send for DeploymentTxFactory<B, M>
where B: Send, M: Send,

§

impl<B, M> Sync for DeploymentTxFactory<B, M>
where B: Sync, M: Sync,

§

impl<B, M> Unpin for DeploymentTxFactory<B, M>
where B: Unpin, M: Unpin,

§

impl<B, M> UnwindSafe for DeploymentTxFactory<B, M>
where B: UnwindSafe, M: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> JsonSchemaMaybe for T