Skip to content

@fuel-ts/program v0.94.5Docs


Class: Contract

Contract provides a way to interact with the contract program type.

Implements

Constructors

new Contract()

new Contract(id, abi, accountOrProvider): Contract

Creates an instance of the Contract class.

Parameters

id: string | AbstractAddress

The contract's address.

abi: JsonAbi | Interface

The contract's ABI (JSON ABI or Interface instance).

accountOrProvider: Provider | Account

The account or provider for interaction.

Returns

Contract

Defined in

contract.ts:47

Properties

account

account: null | Account

The account associated with the contract, if available.

Implementation of

AbstractContract.account

Defined in

contract.ts:33


functions

functions: InvokeFunctions = {}

A collection of functions available on the contract.

Defined in

contract.ts:38


id

id: AbstractAddress

The unique contract identifier.

Implementation of

AbstractContract.id

Defined in

contract.ts:18


interface

interface: Interface

The contract's ABI interface.

Implementation of

AbstractContract.interface

Defined in

contract.ts:28


provider

provider: Provider

The provider for interacting with the contract.

Implementation of

AbstractContract.provider

Defined in

contract.ts:23

Methods

buildFunction()

buildFunction(func): InvokeFunction<any[], any>

Build a function invocation scope for the provided function fragment.

Parameters

func: FunctionFragment

The function fragment to build a scope for.

Returns

InvokeFunction<any[], any>

A function that creates a FunctionInvocationScope.

Defined in

contract.ts:91


getBalance()

getBalance(assetId): Promise<BN>

Get the balance for a given asset ID for this contract.

Parameters

assetId: BytesLike

The specified asset ID.

Returns

Promise<BN>

The balance of the contract for the specified asset.

Defined in

contract.ts:122


multiCall()

multiCall(calls): MultiCallInvocationScope<any>

Create a multi-call invocation scope for the provided function invocation scopes.

Parameters

calls: FunctionInvocationScope<any[], any>[]

An array of FunctionInvocationScopes to execute in a batch.

Returns

MultiCallInvocationScope<any>

A MultiCallInvocationScope instance.

Defined in

contract.ts:111