Struct fuels_programs::contract::Contract
source · pub struct Contract;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.
Implementations§
source§impl Contract
impl Contract
pub fn compute_contract_id_and_state_root( compiled_contract: &CompiledContract ) -> (ContractId, Bytes32)
sourcepub fn method_hash<D: Tokenizable + Parameterize + Debug, T: Account>(
contract_id: Bech32ContractId,
account: T,
signature: Selector,
args: &[Token],
log_decoder: LogDecoder,
is_payable: bool
) -> Result<ContractCallHandler<T, D>>
pub fn method_hash<D: Tokenizable + Parameterize + Debug, T: Account>( contract_id: Bech32ContractId, account: T, signature: Selector, args: &[Token], log_decoder: LogDecoder, is_payable: bool ) -> Result<ContractCallHandler<T, D>>
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 in fuels-core.
Note that this needs a wallet because the contract instance needs a wallet for the calls
sourcepub async fn deploy(
binary_filepath: &str,
account: &impl Account,
configuration: DeployConfiguration
) -> Result<Bech32ContractId>
pub async fn deploy( binary_filepath: &str, account: &impl Account, configuration: DeployConfiguration ) -> Result<Bech32ContractId>
Loads a compiled contract and deploys it to a running node