Skip to content

@fuel-ts/program v0.94.1Docs


Class: FunctionInvocationScope<TArgs, TReturn>

Represents a scope for invoking a function.

Extends

  • BaseInvocationScope<TReturn>

Type Parameters

Type ParameterDefault typeDescription
TArgs extends any[]any[]The type of the function arguments.
TReturnanyThe type of the return value.

Constructors

new FunctionInvocationScope()

new FunctionInvocationScope<TArgs, TReturn>(program, func, args): FunctionInvocationScope<TArgs, TReturn>

Constructs an instance of FunctionInvocationScope.

Parameters

ParameterTypeDescription
programAbstractProgramThe program.
funcFunctionFragmentThe function fragment.
argsTArgsThe arguments.

Returns

FunctionInvocationScope<TArgs, TReturn>

Overrides

BaseInvocationScope<TReturn>.constructor

Defined in

functions/invocation-scope.ts:34

Properties

PropertyModifierTypeDefault valueInherited fromDefined in
argsprotectedTArgsundefined-functions/invocation-scope.ts:25
externalAbisprotectedRecord<string, JsonAbi>{}BaseInvocationScope.externalAbisfunctions/base-invocation-scope.ts:67
funcprotectedFunctionFragmentundefined-functions/invocation-scope.ts:22
functionInvocationScopesprotectedInvocationScopeLike[][]BaseInvocationScope.functionInvocationScopesfunctions/base-invocation-scope.ts:62
hasCallParamsGasLimitprotectedbooleanfalseBaseInvocationScope.hasCallParamsGasLimitfunctions/base-invocation-scope.ts:66
isMultiCallprotectedbooleanfalseBaseInvocationScope.isMultiCallfunctions/base-invocation-scope.ts:65
programprotectedAbstractProgramundefinedBaseInvocationScope.programfunctions/base-invocation-scope.ts:61
requiredCoinsprotectedCoinQuantity[][]BaseInvocationScope.requiredCoinsfunctions/base-invocation-scope.ts:64
transactionRequestprotectedScriptTransactionRequestundefinedBaseInvocationScope.transactionRequestfunctions/base-invocation-scope.ts:60
txParameters?protectedPartial<object>undefinedBaseInvocationScope.txParametersfunctions/base-invocation-scope.ts:63

Accessors

calls

get protected calls(): ContractCall[]

Getter for the contract calls.

Returns

ContractCall[]

An array of contract calls.

Inherited from

BaseInvocationScope.calls

Defined in

functions/base-invocation-scope.ts:89

Methods

addBatchTransfer()

addBatchTransfer(transferParams): FunctionInvocationScope<TArgs, TReturn>

Adds multiple transfers to the contract call transaction request.

Parameters

ParameterTypeDescription
transferParamsTransferParams[]An array of TransferParams objects representing the transfers to be made.

Returns

FunctionInvocationScope<TArgs, TReturn>

The current instance of the class.

Inherited from

BaseInvocationScope.addBatchTransfer

Defined in

functions/base-invocation-scope.ts:337


addCall()

protected addCall(funcScope): FunctionInvocationScope<TArgs, TReturn>

Adds a single call to the invocation scope.

Parameters

ParameterTypeDescription
funcScopeInvocationScopeLikeThe function scope to add.

Returns

FunctionInvocationScope<TArgs, TReturn>

The current instance of the class.

Inherited from

BaseInvocationScope.addCall

Defined in

functions/base-invocation-scope.ts:175


addCalls()

protected addCalls(funcScopes): FunctionInvocationScope<TArgs, TReturn>

Adds multiple calls to the invocation scope.

Parameters

ParameterTypeDescription
funcScopesInvocationScopeLike[]An array of function scopes to add.

Returns

FunctionInvocationScope<TArgs, TReturn>

The current instance of the class.

Inherited from

BaseInvocationScope.addCalls

Defined in

functions/base-invocation-scope.ts:186


addContracts()

addContracts(contracts): FunctionInvocationScope<TArgs, TReturn>

Adds contracts to the invocation scope.

Parameters

ParameterTypeDescription
contractsAbstractContract[]An array of contracts to add.

Returns

FunctionInvocationScope<TArgs, TReturn>

The current instance of the class.

Inherited from

BaseInvocationScope.addContracts

Defined in

functions/base-invocation-scope.ts:305


addSigners()

addSigners(signers): FunctionInvocationScope<TArgs, TReturn>

Parameters

ParameterType
signersAccount | Account[]

Returns

FunctionInvocationScope<TArgs, TReturn>

Inherited from

BaseInvocationScope.addSigners

Defined in

functions/base-invocation-scope.ts:350


addTransfer()

addTransfer(transferParams): FunctionInvocationScope<TArgs, TReturn>

Adds an asset transfer to an Account on the contract call transaction request.

Parameters

ParameterTypeDescription
transferParamsTransferParamsThe object representing the transfer to be made.

Returns

FunctionInvocationScope<TArgs, TReturn>

The current instance of the class.

Inherited from

BaseInvocationScope.addTransfer

Defined in

functions/base-invocation-scope.ts:319


call()

call<T>(): Promise<object>

Submits the contract call transaction and returns a promise that resolves to an object containing the transaction ID and a function to wait for the result. The promise will resolve as soon as the transaction is submitted to the node.

Type Parameters

Type ParameterDefault typeDescription
TTReturnThe type of the return value.

Returns

Promise<object>

A promise that resolves to an object containing:

  • transactionId: The ID of the submitted transaction.
  • waitForResult: A function that waits for the transaction result.
NameTypeDefined in
transactionIdstringfunctions/base-invocation-scope.ts:378
waitForResult() => Promise<FunctionResult<T>>functions/base-invocation-scope.ts:379

Inherited from

BaseInvocationScope.call

Defined in

functions/base-invocation-scope.ts:377


callParams()

callParams(callParams): FunctionInvocationScope<TArgs, TReturn>

Sets the call parameters for the function invocation.

Parameters

ParameterTypeDescription
callParamsPartial<object>The call parameters.

Returns

FunctionInvocationScope<TArgs, TReturn>

The instance of FunctionInvocationScope.

Throws

If the function is not payable and forward is set.

Defined in

functions/invocation-scope.ts:77


checkGasLimitTotal()

protected checkGasLimitTotal(): void

Checks if the total gas limit is within the acceptable range.

Returns

void

Inherited from

BaseInvocationScope.checkGasLimitTotal

Defined in

functions/base-invocation-scope.ts:218


dryRun()

dryRun<T>(): Promise<DryRunResult<T>>

Executes a transaction in dry run mode.

Type Parameters

Type ParameterDefault type
TTReturn

Returns

Promise<DryRunResult<T>>

The result of the invocation call.

Inherited from

BaseInvocationScope.dryRun

Defined in

functions/base-invocation-scope.ts:435


fundWithRequiredCoins()

fundWithRequiredCoins(): Promise<ScriptTransactionRequest>

Funds the transaction with the required coins.

Returns

Promise<ScriptTransactionRequest>

The current instance of the class.

Inherited from

BaseInvocationScope.fundWithRequiredCoins

Defined in

functions/base-invocation-scope.ts:252


get()

get<T>(): Promise<DryRunResult<T>>

Type Parameters

Type ParameterDefault type
TTReturn

Returns

Promise<DryRunResult<T>>

Inherited from

BaseInvocationScope.get

Defined in

functions/base-invocation-scope.ts:449


getCallConfig()

getCallConfig(): CallConfig<TArgs>

Gets the call configuration.

Returns

CallConfig<TArgs>

The call configuration.

Defined in

functions/invocation-scope.ts:47


getProvider()

getProvider(): Provider

Returns

Provider

Inherited from

BaseInvocationScope.getProvider

Defined in

functions/base-invocation-scope.ts:463


getRequiredCoins()

protected getRequiredCoins(): CoinQuantity[]

Gets the required coins for the transaction.

Returns

CoinQuantity[]

An array of required coin quantities.

Inherited from

BaseInvocationScope.getRequiredCoins

Defined in

functions/base-invocation-scope.ts:138


getTransactionCost()

getTransactionCost(): Promise<TransactionCost>

Gets the transaction cost for dry running the transaction.

Returns

Promise<TransactionCost>

The transaction cost details.

Inherited from

BaseInvocationScope.getTransactionCost

Defined in

functions/base-invocation-scope.ts:237


getTransactionId()

getTransactionId(chainId?): Promise<string>

Obtains the ID of a transaction.

Parameters

ParameterTypeDescription
chainId?numberthe chainId to use to hash the transaction with

Returns

Promise<string>

the ID of the transaction.

Inherited from

BaseInvocationScope.getTransactionId

Defined in

functions/base-invocation-scope.ts:475


getTransactionRequest()

getTransactionRequest(): Promise<ScriptTransactionRequest>

Prepares and returns the transaction request object.

Returns

Promise<ScriptTransactionRequest>

The prepared transaction request.

Inherited from

BaseInvocationScope.getTransactionRequest

Defined in

functions/base-invocation-scope.ts:362


prepareTransaction()

protected prepareTransaction(): Promise<void>

Prepares the transaction by updating the script request, required coins, and checking the gas limit.

Returns

Promise<void>

Inherited from

BaseInvocationScope.prepareTransaction

Defined in

functions/base-invocation-scope.ts:196


setArguments()

setArguments(...args): FunctionInvocationScope<TArgs, TReturn>

Sets the arguments for the function invocation.

Parameters

ParameterTypeDescription
...argsTArgsThe arguments.

Returns

FunctionInvocationScope<TArgs, TReturn>

The instance of FunctionInvocationScope.

Defined in

functions/invocation-scope.ts:65


simulate()

simulate<T>(): Promise<DryRunResult<T>>

Simulates a transaction.

Type Parameters

Type ParameterDefault type
TTReturn

Returns

Promise<DryRunResult<T>>

The result of the invocation call.

Inherited from

BaseInvocationScope.simulate

Defined in

functions/base-invocation-scope.ts:408


txParams()

txParams(txParams): FunctionInvocationScope<TArgs, TReturn>

Sets the transaction parameters.

Parameters

ParameterTypeDescription
txParamsPartial<object>The transaction parameters to set.

Returns

FunctionInvocationScope<TArgs, TReturn>

The current instance of the class.

Inherited from

BaseInvocationScope.txParams

Defined in

functions/base-invocation-scope.ts:284


updateContractInputAndOutput()

protected updateContractInputAndOutput(): void

Updates the transaction request with the current input/output.

Returns

void

Inherited from

BaseInvocationScope.updateContractInputAndOutput

Defined in

functions/base-invocation-scope.ts:119


updateRequiredCoins()

protected updateRequiredCoins(): void

Updates the required coins for the transaction.

Returns

void

Inherited from

BaseInvocationScope.updateRequiredCoins

Defined in

functions/base-invocation-scope.ts:151


updateScriptRequest()

protected updateScriptRequest(): void

Updates the script request with the current contract calls.

Returns

void

Inherited from

BaseInvocationScope.updateScriptRequest

Defined in

functions/base-invocation-scope.ts:105