Skip to content

@fuel-ts/program v0.94.1Docs


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

ParameterTypeDescription
idstring | AbstractAddressThe contract's address.
abiJsonAbi | InterfaceThe contract's ABI (JSON ABI or Interface instance).
accountOrProviderProvider | AccountThe account or provider for interaction.

Returns

Contract

Defined in

contract.ts:47

Properties

PropertyTypeDefault valueDescriptionDefined in
accountnull | AccountundefinedThe account associated with the contract, if available.contract.ts:33
functionsInvokeFunctions{}A collection of functions available on the contract.contract.ts:38
idAbstractAddressundefinedThe unique contract identifier.contract.ts:18
interfaceInterfaceundefinedThe contract's ABI interface.contract.ts:28
providerProviderundefinedThe provider for interacting with the contract.contract.ts:23

Methods

buildFunction()

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

Build a function invocation scope for the provided function fragment.

Parameters

ParameterTypeDescription
funcFunctionFragmentThe 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

ParameterTypeDescription
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

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

Returns

MultiCallInvocationScope<any>

A MultiCallInvocationScope instance.

Defined in

contract.ts:111