A ContractFactory is used to deploy a Contract to the blockchain.

Type parameters

Type parameterValue
A extends any[]any[]
IBaseContract

Constructors

new ContractFactory()

new ContractFactory<A, I>(
   abi, 
   bytecode, 
runner?): ContractFactory<A, I>

Create a new ContractFactory with abi and bytecode, optionally connected to runner.

The bytecode may be the bytecode property within the standard Solidity JSON output.

Parameters

ParameterType
abiInterface | InterfaceAbi
bytecodeBytesLike | { "object": string; }
runner?null | ContractRunner

Returns

ContractFactory<A, I>

Source

contract/factory.ts:49

Properties

PropertyModifierTypeDescription
bytecodereadonlystringThe Contract deployment bytecode. Often called the initcode.
interfacereadonlyInterfaceThe Contract Interface.
runnerreadonlynull | ContractRunnerThe ContractRunner to deploy the Contract as.

Methods

connect()

connect(runner): ContractFactory<A, I>

Return a new ContractFactory with the same ABI and bytecode, but connected to runner.

Parameters

ParameterTypeDescription
runnernull | ContractRunnerThe runner to connect to.

Returns

ContractFactory<A, I>

A new ContractFactory.

Source

contract/factory.ts:192


deploy()

deploy(...args): Promise<BaseContract & {
  "deploymentTransaction": ContractTransactionResponse;
} & Omit<I, keyof BaseContract>>

Resolves to the Contract deployed by passing args into the constructor.

This will resovle to the Contract before it has been deployed to the network, so the baseContract.waitForDeployment should be used before sending any transactions to it.

Parameters

ParameterTypeDescription
argsContractMethodArgs<A>The arguments to the constructor.

Returns

Promise<BaseContract & { "deploymentTransaction": ContractTransactionResponse; } & Omit<I, keyof BaseContract>>

A promise resolving to the Contract.

Source

contract/factory.ts:123


getDeployTransaction()

getDeployTransaction(...args): Promise<ContractDeployTransaction>

Resolves to the transaction to deploy the contract, passing args into the constructor.

Parameters

ParameterTypeDescription
argsContractMethodArgs<A>The arguments to the constructor.

Returns

Promise<ContractDeployTransaction>

A promise resolving to the deployment transaction.

Source

contract/factory.ts:86


fromSolidity()

static fromSolidity<A, I>(output, runner?): ContractFactory<A, I>

Create a new ContractFactory from the standard Solidity JSON output.

Type parameters

Type parameterValue
A extends any[]any[]
IContractInterface

Parameters

ParameterTypeDescription
outputanyThe Solidity JSON output.
runner?ContractRunnerThe runner to connect to.

Returns

ContractFactory<A, I>

A new ContractFactory.

Source

contract/factory.ts:203