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


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<ProvenTx>

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<ProvenTx>

The resulting transaction

Inherited from

BaseContractInteraction.prove


proveInternal

proveInternal(options?): Promise<TxProvingResult>

Creates a transaction execution request, simulates and proves it. Differs from .prove in that its result does not include the wallet nor the composed tx object, but only the proving result. This object can then be used to either create a ProvenTx ready to be sent, or directly send the transaction.

Parameters

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

Returns

Promise<TxProvingResult>

The proving result.

Inherited from

BaseContractInteraction.proveInternal


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.


simulateWithProfile

simulateWithProfile(options?): Promise<ProfileResult>

Simulate a transaction and profile the gate count for each function in the transaction.

Parameters

NameTypeDescription
optionsSimulateMethodOptionsSame options as simulate.

Returns

Promise<ProfileResult>

An object containing the function return value and profile result.