Skip to content

@fuel-ts/contract v0.94.6Docs


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:68

Properties

account

account: null | Account

Defined in

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


bytecode

bytecode: BytesLike

Defined in

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


interface

interface: Interface

Defined in

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


provider

provider: null | Provider

Defined in

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

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:110


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:120


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:195


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:251


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:213


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:381