Last updated
Last updated
To deploy a , additional information is needed that is not available on a Contract object itself.
Mainly, the bytecode (more specifically the initcode) of a contract is required.
The Contract Factory sends special transactions to completly contract deployment. Before the main contract creation transaction, there are several transactions that have to be executed:
FileCreateTransaction
- including a customData field with fileChunk and fileKey properties. Returns fileId as property in customData of transaction's response.
n
x FileAppendTransaction
- in Hedera ecosystem, each transaction has maximum size of 6KB
, so if there is a contract with a bigger size, it has to be separated into chunks. Each chunk must be uploaded via FileAppendTransaction
with customData containing fileId and fileChunk.
ContractCreateTransaction
- actually deploying the contract, the transaction includes gasLimit and customData with bytecodeFileId
The Contract Factory executes the defined transactions under the hood and the complexity is hidden from the hethers
users.
new hethers.ContractFactory( interface , bytecode [ , signer ] )
Creates a new instance of a ContractFactory for the contract described by the interface and bytecode initcode.
ContractFactory.fromSolidity( compilerOutput [ , signer ] )
⇒ Consumes the output of the Solidity compiler, extracting the ABI and bytecode from it, allowing for the various formats the solc compiler has emitted over its life.
contractFactory.connect( signer )
⇒ Returns a new instance of the ContractFactory with the same interface and bytecode, but with a different signer.
The bytecode (i.e. initcode) that this ContractFactory will use to deploy the Contract.
Returns the unsigned transaction which would deploy this Contract with args passed to the Contract's constructor.
If the optional overrides is specified, they can be used to override the endowment value
and transactiongasLimit.
Uses the signer to deploy the Contract with args passed into the constructor and returns a Contract which is attached to the address where this contract will be deployed once the transaction is mined.
The transaction can be found at contract.deployTransaction
, and no interactions should be made until the transaction is mined.
If the optional overrides is specified, they can be used to override the endowment value
and transaction gasLimit
.
The interface.
The (if any) this ContractFactory will use to deploy instances of the Contract.
Return an instance of a attached to address. This is the same as using the Contract constructor with address and this the interface and signerOrProvider passed in when creating the ContractFactory.