Skip to content

@fuel-ts/contract v0.95.0Docs


Class: ContractFactory

ContractFactory provides utilities for deploying and configuring contracts.

Constructors

new ContractFactory()

new ContractFactory(bytecode, abi, accountOrProvider): ContractFactory

Create a ContractFactory instance.

Parameters

bytecode: BytesLike

The bytecode of the contract.

abi: Interface | JsonAbi

The contract's ABI (Application Binary Interface).

accountOrProvider: null | Provider | Account = null

An account or provider to be associated with the factory.

Returns

ContractFactory

Defined in

packages/contract/src/contract-factory.ts:73

Properties

account

account: null | Account

Defined in

packages/contract/src/contract-factory.ts:64


bytecode

bytecode: BytesLike

Defined in

packages/contract/src/contract-factory.ts:61


interface

interface: Interface

Defined in

packages/contract/src/contract-factory.ts:62


provider

provider: null | Provider

Defined in

packages/contract/src/contract-factory.ts:63

Methods

connect()

connect(provider): ContractFactory

Connect the factory to a provider.

Parameters

provider: Provider

The provider to be associated with the factory.

Returns

ContractFactory

A new ContractFactory instance.

Defined in

packages/contract/src/contract-factory.ts:115


createTransactionRequest()

createTransactionRequest(deployOptions?): object

Create a transaction request to deploy a contract with the specified options.

Parameters

deployOptions?: object & CreateTransactionRequestLike & object

Options for deploying the contract.

Returns

object

The CreateTransactionRequest object for deploying the contract.

contractId

contractId: string

transactionRequest

transactionRequest: CreateTransactionRequest

Defined in

packages/contract/src/contract-factory.ts:125


deploy()

deploy<TContract>(deployOptions): Promise<DeployContractResult<TContract>>

Deploy a contract of any length with the specified options.

Type Parameters

TContract extends Contract = Contract

Parameters

deployOptions: DeployContractOptions = {}

Options for deploying the contract.

Returns

Promise<DeployContractResult<TContract>>

A promise that resolves to the deployed contract instance.

Defined in

packages/contract/src/contract-factory.ts:200


deployAsBlobTx()

deployAsBlobTx<TContract>(deployOptions): Promise<DeployContractResult<TContract>>

Chunks and deploys a contract via a loader contract. Suitable for deploying contracts larger than the max contract size.

Type Parameters

TContract extends Contract = Contract

Parameters

deployOptions: DeployContractOptions = ...

Options for deploying the contract.

Returns

Promise<DeployContractResult<TContract>>

A promise that resolves to the deployed contract instance.

Defined in

packages/contract/src/contract-factory.ts:256


deployAsBlobTxForScript()

deployAsBlobTxForScript(): Promise<object>

Returns

Promise<object>

blobId

blobId: string

waitForResult()

waitForResult: () => Promise<object>

Returns

Promise<object>

configurableOffsetDiff

configurableOffsetDiff: number

loaderBytecode

loaderBytecode: string

Defined in

packages/contract/src/contract-factory.ts:380


deployAsCreateTx()

deployAsCreateTx<TContract>(deployOptions): Promise<DeployContractResult<TContract>>

Deploy a contract with the specified options.

Type Parameters

TContract extends Contract = Contract

Parameters

deployOptions: DeployContractOptions = {}

Options for deploying the contract.

Returns

Promise<DeployContractResult<TContract>>

A promise that resolves to the deployed contract instance.

Defined in

packages/contract/src/contract-factory.ts:218


setConfigurableConstants()

setConfigurableConstants(configurableConstants): void

Set configurable constants of the contract with the specified values.

Parameters

configurableConstants

An object containing configurable names and their values.

Returns

void

Defined in

packages/contract/src/contract-factory.ts:467