-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
2,859 additions
and
740 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
**.bak |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
_section: ContractFactory @<ContractFactory> @SRC<contracts:class.ContractFactory> | ||
|
||
|
||
_subsection: Creating Instances @<ContractFactory--creating> | ||
|
||
_property: new ethers.ContractFactory(interface, bydecode [ , signer ]) @SRC<contracts:constructor.ContractFactory> | ||
|
||
_property: ContractFactory.fromSolidity(compilerOutput [ , signer ]) => [[ContractFactory]] | ||
|
||
_property: contractFactory.connect(signer) => [[Contract]] | ||
|
||
|
||
_subsection: Properties @<ContractFactory--properties> | ||
|
||
_property: contractFactory.interface => [[Interface]] | ||
|
||
_property: contractFactory.bytecode => string<[[DataHexString]]> | ||
|
||
_property: contractFactory.signer => [[Signer]] | ||
|
||
|
||
_subsection: Methods @<ContractFactory--methods> | ||
|
||
_property: contractFactory.attach(address) => [[Contract]] | ||
|
||
Return an instance of a [[Contract]] attched to //address//. This is the | ||
same as using the [Contract constructor](contract--creating) with | ||
//address// and this the the //interface// and //signerOrProvider// passed | ||
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. | ||
|
||
_property: contractFactory.deploy(...args) => Promise<[[Contract]]> | ||
|
||
Uses the signer to deploy the Contract with //args// passed into tgee constructor and | ||
retruns a Contract which is attached to the address where this contract **will** be | ||
deployed once the transction is mined. | ||
|
||
The transction can be found at ``contract.deployTransaction``, and no interactions | ||
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() | ||
//! | ||
|
||
// Now the contract is safe to ineract with | ||
contract.value() | ||
//! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
_section: Contract Interaction @<contracts> | ||
|
||
Explain what contracts are... | ||
A **Contract** object is an abstraction of a contract (EVM bytecode) | ||
deployed on the Ethereum network. It allows for a simple way to | ||
serialize calls and transaxtions to an on-chain contract and | ||
deserialize their results and emitted logs. | ||
|
||
A **ContractFactory** is an abstraction a contract's //bytecode// | ||
and facilitates deploying a contract. | ||
|
||
_toc: | ||
contract | ||
contract-factory | ||
example |
Oops, something went wrong.