To deploy a Contract, 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.
In , we have compiled the contract and got the abi and bytecode.
Create a wallet that can sign transactions.
Create a new instance of a ContractFactory for the contract described by the interface and bytecode initcode. The Contract Factory sends a special type of transaction, an initcode transaction (i.e. the to field is null, and the data field is the initcode) where the initcode will be evaluated and the result becomes the new code to be deployed as a new contract.
Deploy an instance of the contract. The address is available immediately, but the contract is NOT deployed yet.
Wait until the transaction is mined (i.e. contract is deployed)
- returns the receipt
- throws on failure (the reciept is on the error)