2020-05-08 10:24:40 +03:00
|
|
|
_section: ContractFactory @<ContractFactory> @SRC<contracts:class.ContractFactory>
|
|
|
|
|
2020-06-12 10:38:55 +03:00
|
|
|
@TODO: Fill this in, including @SRC links
|
2020-05-08 10:24:40 +03:00
|
|
|
|
|
|
|
_subsection: Creating Instances @<ContractFactory--creating>
|
|
|
|
|
2020-09-06 08:57:06 +03:00
|
|
|
_property: new ethers.ContractFactory(interface, bytecode [ , signer ]) @SRC<contracts:constructor.ContractFactory>
|
2020-05-08 10:24:40 +03:00
|
|
|
|
|
|
|
_property: ContractFactory.fromSolidity(compilerOutput [ , signer ]) => [[ContractFactory]]
|
|
|
|
|
2020-06-12 10:38:55 +03:00
|
|
|
_property: contractFactory.connect(signer) => [[Contract]] @<ContractFactory-connect>
|
2020-05-08 10:24:40 +03:00
|
|
|
|
|
|
|
|
|
|
|
_subsection: Properties @<ContractFactory--properties>
|
|
|
|
|
|
|
|
_property: contractFactory.interface => [[Interface]]
|
|
|
|
|
|
|
|
_property: contractFactory.bytecode => string<[[DataHexString]]>
|
|
|
|
|
|
|
|
_property: contractFactory.signer => [[Signer]]
|
|
|
|
|
|
|
|
|
|
|
|
_subsection: Methods @<ContractFactory--methods>
|
|
|
|
|
2020-06-12 10:38:55 +03:00
|
|
|
_property: contractFactory.attach(address) => [[Contract]] @<ContractFactory-attach>
|
2020-05-08 10:24:40 +03:00
|
|
|
|
2020-10-03 19:30:15 +03:00
|
|
|
Return an instance of a [[Contract]] attached to //address//. This is the
|
2020-06-12 10:38:55 +03:00
|
|
|
same as using the [Contract constructor](Contract--creating) with
|
2020-11-23 07:03:50 +03:00
|
|
|
//address// and this the //interface// and //signerOrProvider// passed
|
2020-05-08 10:24:40 +03:00
|
|
|
in when creating the ContractFactory.
|
|
|
|
|
|
|
|
_property: contractFactory.getDeployTransaction(...args) => [[UnsignedTransaction]]
|
|
|
|
|
|
|
|
Returns the unsigned transaction which would deploy this Contract with //args// passed
|
|
|
|
to the Contract's constructor.
|
|
|
|
|
2020-06-12 10:38:55 +03:00
|
|
|
_property: contractFactory.deploy(...args) => Promise<[[Contract]]> @<ContractFactory-deploy>
|
2020-05-08 10:24:40 +03:00
|
|
|
|
2020-07-03 08:44:17 +03:00
|
|
|
Uses the signer to deploy the Contract with //args// passed into the constructor and
|
2020-10-03 19:30:15 +03:00
|
|
|
returns a Contract which is attached to the address where this contract **will** be
|
2020-07-03 08:44:17 +03:00
|
|
|
deployed once the transaction is mined.
|
2020-05-08 10:24:40 +03:00
|
|
|
|
2020-07-03 08:44:17 +03:00
|
|
|
The transaction can be found at ``contract.deployTransaction``, and no interactions
|
2020-05-08 10:24:40 +03:00
|
|
|
should be made until the transaction is mined.
|
|
|
|
|
|
|
|
_code: Deploying a Contract
|
|
|
|
|
|
|
|
// <hide>
|
|
|
|
const signer = ethers.LocalSigner();
|
|
|
|
const ContractFactory = ethers.ContractFactory;
|
|
|
|
// </hide>
|
|
|
|
|
|
|
|
// If your contract constructor requires parameters, the ABI
|
|
|
|
// must include the constructor
|
|
|
|
const abi = [
|
|
|
|
"constructor(address owner, uint256 initialValue)"
|
|
|
|
];
|
|
|
|
|
|
|
|
const factory = new ContractFactory(abi, bytecode, signer)
|
|
|
|
|
|
|
|
const contract = await factory.deploy("ricmoo.eth", 42);
|
|
|
|
|
|
|
|
// The address is available immediately, but the contract
|
|
|
|
// is NOT deployed yet
|
|
|
|
contract.address
|
|
|
|
//!
|
|
|
|
|
|
|
|
// The transaction that the signer sent to deploy
|
|
|
|
contract.deployTransaction
|
|
|
|
//!
|
|
|
|
|
|
|
|
// Wait until the transaction is mined
|
|
|
|
contract.deployTransaction.wait()
|
|
|
|
//!
|
|
|
|
|
2020-07-03 08:44:17 +03:00
|
|
|
// Now the contract is safe to interact with
|
2020-05-08 10:24:40 +03:00
|
|
|
contract.value()
|
|
|
|
//!
|