Skip to content

Class: Contract

@fuel-ts/program.Contract

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

Implements

Constructors

constructor

new Contract(id, abi, accountOrProvider): Contract

Creates an instance of the Contract class.

Parameters

NameTypeDescription
idstring | AbstractAddressThe contract's address.
abiJsonAbi | Interface<JsonAbi>The contract's ABI (JSON ABI or Interface instance).
accountOrProviderProvider | AccountThe 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<JsonAbi>

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

NameTypeDescription
funcFunctionFragment<JsonAbi, string>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

NameTypeDescription
assetIdBytesLikeThe 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

NameTypeDescription
callsFunctionInvocationScope<any[], any>[]An array of FunctionInvocationScopes to execute in a batch.

Returns

MultiCallInvocationScope<any>

A MultiCallInvocationScope instance.

Defined in

contract.ts:111