ContractFactory
A ContractFactory is used to deploy a Contract to the blockchain.
Type parameters
Type parameter | Value |
---|---|
A extends any [] | any [] |
I | BaseContract |
Constructors
new ContractFactory()
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
Parameter | Type |
---|---|
abi | Interface | InterfaceAbi |
bytecode | BytesLike | { "object" : string ; } |
runner ? | null | ContractRunner |
Returns
ContractFactory
<A
, I
>
Source
Properties
Property | Modifier | Type | Description |
---|---|---|---|
bytecode | readonly | string | The Contract deployment bytecode. Often called the initcode. |
interface | readonly | Interface | The Contract Interface. |
runner | readonly | null | ContractRunner | The ContractRunner to deploy the Contract as. |
Methods
connect()
Return a new ContractFactory with the same ABI and bytecode, but connected to runner
.
Parameters
Parameter | Type | Description |
---|---|---|
runner | null | ContractRunner | The runner to connect to. |
Returns
ContractFactory
<A
, I
>
A new ContractFactory.
Source
deploy()
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
Parameter | Type | Description |
---|---|---|
…args | ContractMethodArgs <A > | The arguments to the constructor. |
Returns
Promise
<BaseContract
& {
"deploymentTransaction"
: ContractTransactionResponse
;
} & Omit
<I
, keyof BaseContract
>>
A promise resolving to the Contract.
Source
getDeployTransaction()
Resolves to the transaction to deploy the contract, passing args
into the constructor.
Parameters
Parameter | Type | Description |
---|---|---|
…args | ContractMethodArgs <A > | The arguments to the constructor. |
Returns
Promise
<ContractDeployTransaction
>
A promise resolving to the deployment transaction.
Source
fromSolidity()
Create a new ContractFactory from the standard Solidity JSON output.
Type parameters
Type parameter | Value |
---|---|
A extends any [] | any [] |
I | ContractInterface |
Parameters
Parameter | Type | Description |
---|---|---|
output | any | The Solidity JSON output. |
runner ? | ContractRunner | The runner to connect to. |
Returns
ContractFactory
<A
, I
>
A new ContractFactory.
Source
Was this page helpful?