Skip to main content

Class: ContractFunctionInteraction

contract.ContractFunctionInteraction

This is the class that is returned when calling e.g. contract.methods.myMethod(arg0, arg1). It contains available interactions one can call on a method, including view.

Hierarchy

  • BaseContractInteraction

    ContractFunctionInteraction

Constructors

constructor

new ContractFunctionInteraction(wallet, contractAddress, functionDao, args): ContractFunctionInteraction

Parameters

NameType
walletWallet
contractAddressAztecAddress
functionDaoFunctionAbi
argsany[]

Returns

ContractFunctionInteraction

Overrides

BaseContractInteraction.constructor

Properties

args

Protected args: any[]


contractAddress

Protected contractAddress: AztecAddress


functionDao

Protected functionDao: FunctionAbi


log

Protected log: Logger

Inherited from

BaseContractInteraction.log


tx

Protected Optional tx: Tx

Inherited from

BaseContractInteraction.tx


txRequest

Protected Optional txRequest: TxExecutionRequest

Inherited from

BaseContractInteraction.txRequest


wallet

Protected wallet: Wallet

Inherited from

BaseContractInteraction.wallet

Methods

create

create(opts?): Promise<TxExecutionRequest>

Create a transaction execution request that represents this call, encoded and authenticated by the user's wallet, ready to be simulated.

Parameters

NameTypeDescription
opts?SendMethodOptionsAn optional object containing additional configuration for the transaction.

Returns

Promise<TxExecutionRequest>

A Promise that resolves to a transaction instance.

Overrides

BaseContractInteraction.create


estimateGas

estimateGas(opts?): Promise<Pick<GasSettings, "gasLimits" | "teardownGasLimits">>

Estimates gas for a given tx request and returns gas limits for it.

Parameters

NameTypeDescription
opts?Omit<SendMethodOptions, "estimateGas" | "skipPublicSimulation">Options.

Returns

Promise<Pick<GasSettings, "gasLimits" | "teardownGasLimits">>

Gas limits.

Inherited from

BaseContractInteraction.estimateGas


getFeeOptionsFromEstimatedGas

getFeeOptionsFromEstimatedGas(request): Promise<undefined | { gasSettings: GasSettings ; paymentMethod: FeePaymentMethod }>

Helper method to return fee options based on the user opts, estimating tx gas if needed.

Parameters

NameTypeDescription
requestExecutionRequestInitRequest to execute for this interaction.

Returns

Promise<undefined | { gasSettings: GasSettings ; paymentMethod: FeePaymentMethod }>

Fee options for the actual transaction.

Inherited from

BaseContractInteraction.getFeeOptionsFromEstimatedGas


prove

prove(options?): Promise<Tx>

Proves a transaction execution request and returns a tx object ready to be sent.

Parameters

NameTypeDescription
optionsSendMethodOptionsoptional arguments to be used in the creation of the transaction

Returns

Promise<Tx>

The resulting transaction

Inherited from

BaseContractInteraction.prove


request

request(): FunctionCall

Returns an execution request that represents this operation. Useful as a building block for constructing batch requests.

Returns

FunctionCall

An execution request wrapped in promise.


send

send(options?): SentTx

Sends a transaction to the contract function with the specified options. This function throws an error if called on an unconstrained function. It creates and signs the transaction if necessary, and returns a SentTx instance, which can be used to track the transaction status, receipt, and events.

Parameters

NameTypeDescription
optionsSendMethodOptionsAn optional object containing 'from' property representing the AztecAddress of the sender. If not provided, the default address is used.

Returns

SentTx

A SentTx instance for tracking the transaction status and information.

Inherited from

BaseContractInteraction.send


simulate

simulate(options?): Promise<any>

Simulate a transaction and get its return values Differs from prove in a few important ways:

  1. It returns the values of the function execution
  2. It supports unconstrained, private and public functions

Parameters

NameTypeDescription
optionsSimulateMethodOptionsAn optional object containing additional configuration for the transaction.

Returns

Promise<any>

The result of the transaction as returned by the contract function.