pub struct Contract {
    pub compiled_contract: CompiledContract,
    pub wallet: WalletUnlocked,
}
Expand description

Contract is a struct to interface with a contract. That includes things such as compiling, deploying, and running transactions against a contract. The contract has a wallet attribute, used to pay for transactions and sign them. It allows doing calls without passing a wallet/signer each time.

Fields§

§compiled_contract: CompiledContract§wallet: WalletUnlocked

Implementations§

Creates an ABI call based on a function selector and the encoding of its call arguments, which is a slice of Tokens. It returns a prepared ContractCall that can further be used to make the actual transaction. This method is the underlying implementation of the functions generated from an ABI JSON spec, i.e, this is what’s generated:

quote! {
    #doc
    pub fn #name(&self #input) -> #result {
        Contract::method_hash(#tokenized_signature, #arg)
    }
}

For more details see code_gen/functions_gen.rs in fuels-core.

Note that this needs a wallet because the contract instance needs a wallet for the calls

Loads a compiled contract and deploys it to a running node

Loads a compiled contract with salt and deploys it to a running node

Deploys a compiled contract to a running node To deploy a contract, you need a wallet with enough assets to pay for deployment. This wallet will also receive the change.

Crafts a transaction used to deploy a contract

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

Calls U::from(self).

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

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more