Icon HelpCircleForumIcon Link

⌘K

Icon HelpCircleForumIcon Link
Contractfactory

Icon LinkClass: ContractFactory

@fuel-ts/contract .index .ContractFactory

ContractFactory provides utilities for deploying and configuring contracts.

Icon LinkConstructors

Icon Linkconstructor

new ContractFactory(bytecode, abi, accountOrProvider?): ContractFactory

Create a ContractFactory instance.

Icon LinkParameters

NameTypeDefault valueDescription
bytecodeBytesLike undefinedThe bytecode of the contract.
abiInterface | JsonAbiundefinedThe contract's ABI (Application Binary Interface).
accountOrProvidernull | Provider | Account nullAn account or provider to be associated with the factory.

Icon LinkReturns

ContractFactory

Icon LinkDefined in

packages/contract/src/contract-factory.ts:68 Icon Link

Icon LinkProperties

Icon Linkaccount

account: null | Account

Icon LinkDefined in

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


Icon Linkbytecode

bytecode: BytesLike

Icon LinkDefined in

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


Icon Linkinterface

interface: Interface

Icon LinkDefined in

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


Icon Linkprovider

provider: null | Provider

Icon LinkDefined in

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

Icon LinkMethods

Icon LinkblobTransactionRequest

blobTransactionRequest(options): BlobTransactionRequest

Create a blob transaction request, used for deploying contract chunks.

Icon LinkParameters

NameTypeDescription
options{ bytecode: BytesLike } & { chunkSizeMultiplier?: number ; configurableConstants?: { [name: string]: unknown; } ; salt?: BytesLike ; stateRoot?: BytesLike ; storageSlots?: StorageSlot[] } & CreateTransactionRequestLikeoptions for creating a blob transaction request.

Icon LinkReturns

BlobTransactionRequest

a populated BlobTransactionRequest.

Icon LinkDefined in

packages/contract/src/contract-factory.ts:444 Icon Link


Icon Linkconnect

connect(provider): ContractFactory

Connect the factory to a provider.

Icon LinkParameters

NameTypeDescription
providerProvider The provider to be associated with the factory.

Icon LinkReturns

ContractFactory

A new ContractFactory instance.

Icon LinkDefined in

packages/contract/src/contract-factory.ts:110 Icon Link


Icon LinkcreateTransactionRequest

createTransactionRequest(deployOptions?): Object

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

Icon LinkParameters

NameTypeDescription
deployOptions?{ chunkSizeMultiplier?: number ; configurableConstants?: { [name: string]: unknown; } ; salt?: BytesLike ; stateRoot?: BytesLike ; storageSlots?: StorageSlot[] } & CreateTransactionRequestLike & { bytecode?: BytesLike }Options for deploying the contract.

Icon LinkReturns

Object

The CreateTransactionRequest object for deploying the contract.

NameType
contractIdstring
transactionRequestCreateTransactionRequest

Icon LinkDefined in

packages/contract/src/contract-factory.ts:120 Icon Link


Icon Linkdeploy

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

Deploy a contract of any length with the specified options.

Icon LinkType parameters

NameType
TContractextends Contract = Contract

Icon LinkParameters

NameTypeDescription
deployOptionsDeployContractOptions Options for deploying the contract.

Icon LinkReturns

Promise<DeployContractResult <TContract>>

A promise that resolves to the deployed contract instance.

Icon LinkDefined in

packages/contract/src/contract-factory.ts:195 Icon Link


Icon LinkdeployAsBlobTx

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.

Icon LinkType parameters

NameType
TContractextends Contract = Contract

Icon LinkParameters

NameTypeDescription
deployOptionsDeployContractOptions Options for deploying the contract.

Icon LinkReturns

Promise<DeployContractResult <TContract>>

A promise that resolves to the deployed contract instance.

Icon LinkDefined in

packages/contract/src/contract-factory.ts:251 Icon Link


Icon LinkdeployAsCreateTx

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

Deploy a contract with the specified options.

Icon LinkType parameters

NameType
TContractextends Contract = Contract

Icon LinkParameters

NameTypeDescription
deployOptionsDeployContractOptions Options for deploying the contract.

Icon LinkReturns

Promise<DeployContractResult <TContract>>

A promise that resolves to the deployed contract instance.

Icon LinkDefined in

packages/contract/src/contract-factory.ts:213 Icon Link


Icon LinkfundTransactionRequest

fundTransactionRequest(request, options?): Promise<TransactionRequest >

Takes a transaction request, estimates it and funds it.

Icon LinkParameters

NameTypeDescription
requestTransactionRequest the request to fund.
optionsDeployContractOptions options for funding the request.

Icon LinkReturns

Promise<TransactionRequest >

a funded transaction request.

Icon LinkDefined in

packages/contract/src/contract-factory.ts:164 Icon Link


Icon LinkgetAccount

getAccount(): Account

Icon LinkReturns

Account

Icon LinkDefined in

packages/contract/src/contract-factory.ts:414 Icon Link


Icon LinkgetMaxChunkSize

getMaxChunkSize(deployOptions, chunkSizeMultiplier?): number

Get the maximum chunk size for deploying a contract by chunks.

Icon LinkParameters

NameTypeDefault value
deployOptionsDeployContractOptions undefined
chunkSizeMultipliernumberCHUNK_SIZE_MULTIPLIER

Icon LinkReturns

number

Icon LinkDefined in

packages/contract/src/contract-factory.ts:457 Icon Link


Icon LinkprepareDeploy

prepareDeploy(deployOptions): Promise<{ contractId: string ; transactionRequest: CreateTransactionRequest }>

Icon LinkParameters

NameType
deployOptionsDeployContractOptions

Icon LinkReturns

Promise<{ contractId: string ; transactionRequest: CreateTransactionRequest }>

Icon LinkDefined in

packages/contract/src/contract-factory.ts:421 Icon Link


Icon LinksetConfigurableConstants

setConfigurableConstants(configurableConstants): void

Set configurable constants of the contract with the specified values.

Icon LinkParameters

NameTypeDescription
configurableConstantsObjectAn object containing configurable names and their values.

Icon LinkReturns

void

Icon LinkDefined in

packages/contract/src/contract-factory.ts:377 Icon Link