Skip to content

Commit

Permalink
Consistent link names in docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed May 8, 2020
1 parent 7f0374c commit 84d37fd
Show file tree
Hide file tree
Showing 45 changed files with 2,859 additions and 740 deletions.
1 change: 1 addition & 0 deletions docs.wrm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**.bak
77 changes: 77 additions & 0 deletions docs.wrm/api/contract/contract-factory.wrm
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()
//!
89 changes: 48 additions & 41 deletions docs.wrm/api/contract/contract.wrm
Original file line number Diff line number Diff line change
@@ -1,57 +1,64 @@
_section: Contract @<contract> @SRC<contracts:class.Contract>
_section: Contract @<Contract> @SRC<contracts:class.Contract>

_subsection: Properties
Explain contract here...

_subsection: Creating Instances @<contract--creating>

_property: new ethers.Contract(address, abi, signerOrProvider) @src<contracts:constructor.Contract>

_property: contract.attach(addressOrName) => [[Contract]] @<contract-attach> @SRC<contracts:Contract.attach>
Returns a new instance of the **Contract** attached to a new
address. This is useful if there are multiple similar or identical
copies of a Contract on the network and you wish to interact with
each of them.

_property: contract.connect(providerOrSigner) => [[Contract]] @<contract-connect> @SRC<contracts:Contract.connect>
Returns a new instance of the Contract, but connected to
//providerOrSigner//.

By passing in a [[Provider]], this will return a downgraded
**Contract** which only has read-only access (i.e. constant calls).

By passing in a [[Signer]]. the will return a **Contract** which
will act on behalf of that signer.


_subsection: Properties @<contrct--properties>

_property: contract.address => string<[[address]]>
This is the address (or ENS name) the contract was constructed with.

_property: contract.addressPromise => string<[[address]]>
_property: contract.resolvedAddress => string<[[address]]>
This is a promise that will resolve to the address the **Contract**
object is attached to. If an [[address]] was provided to the constructor,
it will be equal to this; if an ENS name was provided, this will be the
resolved address.

_property: contract.deployTransaction => [[provider-transactionresponse]]
_property: contract.deployTransaction => [[providers-TransactionResponse]]
If the **Contract** object is the result of a ContractFactory deployment,
this is the transaction which was used to deploy the contract.

_property: contract.interface => [[abi-interface]]
This is the ABI as an [[abi-interface]].
_property: contract.interface => [[Interface]]
This is the ABI as an [[Interface]].

_property: contract.provider => [[provider]]
_property: contract.provider => [[Provider]]
If a provider was provided to the constructor, this is that provider. If
a signer was provided that had a [[provider]], this is that provider.
a signer was provided that had a [[Provider]], this is that provider.

_property: contract.signer => [[signer]]
_property: contract.signer => [[Signer]]
If a signer was provided to the constructor, this is that signer.


_subsection: Methods

_property: contract.attach(addressOrName) => [[contract]] @<contract-attach> @SRC<contracts:Contract.attach>
Returns a new instance of the **Contract** attached to a new
address. This is useful if there are multiple similar or identical
copies of a Contract on the network and you wish to interact with
each of them.

_property: contract.connect(providerOrSigner) => [[contract]] @<contract-connect> @SRC<contracts:Contract.connect>
Returns a new instance of the Contract, but connected to
//providerOrSigner//.

By passing in a [[provider]], this will return a downgraded
**Contract** which only has read-only access (i.e. constant calls).

By passing in a [[signer]]. the will return a **Contract** which
will act on behalf of that signer.

_property: contract.deployed() => Promise<[[contract]]> @<contract-deployed> @SRC<contracts>
_property: contract.deployed() => Promise<[[Contract]]> @<contract-deployed> @SRC<contracts>

_property: Contract.isIndexed(value) => boolean @<contract-isIndexed> @SRC<contracts>


_subsection: Events

_property: contract.queryFilter(event [ , fromBlockOrBlockHash [ , toBlock ]) => Promise<Array<Event>> @<contract-queryfilter> @SRC<contracts>
_property: contract.queryFilter(event [ , fromBlockOrBlockHash [ , toBlock ]) => Promise<Array<Event>> @<contract-queryFilter> @SRC<contracts>
Return Events that match the //event//.

_property: contract.listenerCount([ event ]) => number @<contract-listenerCount> @SRC<contracts:Contract.listenerCount>
Expand All @@ -76,7 +83,7 @@ Unsubscribe all listeners for //event//. If no event is provided,
all events are unsubscribed.


_subsection: Meta-Class @<contract-metaclass>
_subsection: Meta-Class @<contract--metaclass>

A Meta-Class is a Class which has any of its properties determined
at run-time. The **Contract** object uses a Contract's ABI to
Expand All @@ -85,15 +92,15 @@ describe the generic ways to interact with the properties added
at run-time during the **Contract** constructor.


_heading: Read-Only Methods (constant) @<contract-readonly>
_heading: Read-Only Methods (constant) @<contract--readonly>

A constant method is read-only and evaluates a small amount of EVM
code against the current blockchain state and can be computed by
asking a single node, which can return a result. It is therefore
free and does not require any ether, but **cannot make changes** to
the blockchain state..

_property: contract.METHOD_NAME(...args [ overrides ]) => Promise<any> @<contract-call>
_property: contract.METHOD_NAME(...args [ overrides ]) => Promise<any> @<contract-functionsCall>
The type of the result depends on the ABI.

For values that have a simple meaning in JavaScript, the types are fairly
Expand All @@ -102,12 +109,12 @@ and booleans.

For numbers, if the **type** is in the JavaSsript safe range (i.e. less
than 53 bits, such as an ``int24`` or ``uint48``) a normal JavaScript
number is used. Otherwise a [[bignumber]] is returned.
number is used. Otherwise a [[BigNumber]] is returned.

For bytes (both fixed length and dynamic), a [[datahexstring]] is returned.
For bytes (both fixed length and dynamic), a [[DataHexString]] is returned.


_heading: Write Methods (non-constant) @<contract-write>
_heading: Write Methods (non-constant) @<contract--write>

A non-constant method requires a transaction to be signed and requires
payment in the form of a fee to be paid to a miner. This transaction
Expand All @@ -119,23 +126,23 @@ It cannot return a result. If a result is required, it should be logged
using a Solidity event (or EVM log), which can then be queried from the
transaction receipt.

_property: contract.METHOD_NAME(...args [ , overrides ]) => Promise<[[provider-transactionresponse]]> @<contract-send>
Returns a [[provider-transactionresponse]] for the transaction after
_property: contract.METHOD_NAME(...args [ , overrides ]) => Promise<[[providers-TransactionResponse]]> @<contract-functionsSend>
Returns a [[providers-TransactionResponse]] for the transaction after
it is sent to the network. This requires the **Contract** has a
signer.


_heading: Write Methods Analysis @<contract-write-check>
_heading: Write Methods Analysis @<contract--check>

There are secveral options to analyze properties and results of a
write method without actually executing it.

_property: contract.estimateGas.METHOD_NAME(...args [ , overrides ]) => Promise<[[bignumber]]> @<contract-estimateGas>
_property: contract.estimateGas.METHOD_NAME(...args [ , overrides ]) => Promise<[[BigNumber]]> @<contract-estimateGas>
Returns the estimate units of gas that would be required to
execute the //METHOD_NAME// with //args// and //overrides//.

_property: contract.populateTransaction.METHOD_NAME(...args [ , overrides ]) => Promise<[UnsignedTx](types-unsignedtransaction)> @<contract-populateTransaction>
Returns an [[types-unsignedtransaction]] which represents the transaction
_property: contract.populateTransaction.METHOD_NAME(...args [ , overrides ]) => Promise<[UnsignedTx](UnsignedTransaction)> @<contract-populateTransaction>
Returns an [[UnsignedTransaction]] which represents the transaction
that would need to be signed and submitted to the network to execute
//METHOD_NAME// with //args// and //overrides//.

Expand All @@ -147,9 +154,9 @@ return the result.
This does not actually chagne any state, but is free. This in some cases
can be used to determine if a transaction will fail or succeed.

This otherwise functions the same as a [Read-Only Method](contract-readonly).
This otherwise functions the same as a [Read-Only Method](contract--readonly).

_heading: Event Filters @<contract-filter>
_heading: Event Filters @<contract-filters>
An event filter is made up of topics, which are values logged in a
[[link-wiki-bloomfilter]], allowing efficient searching for entries
which match a filter.
Expand Down
42 changes: 21 additions & 21 deletions docs.wrm/api/contract/example.wrm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const erc20 = new ethers.Contract(address, abi, provider);
const erc20_rw = new ethers.Contract(address, abi, signer)


_heading: ERC20Contract @INHERIT<[[contract]]>
_heading: ERC20Contract @INHERIT<[[Contract]]>

_property: new ethers.Contract(address, abi, providerOrSigner)
See the above code example for creating an Instance which will
Expand All @@ -50,56 +50,56 @@ add the additional properties defined in //abi// to a **Contract**
connected to //address// using the //providerOrSigner//.


_subsection: Properties @NOTE<(inheritted from [[contract]])>
_subsection: Properties @NOTE<(inheritted from [[Contract]])>

_property: erc20.address => string<[[address]]>
This is the address (or ENS name) the contract was constructed with.

_property: erc20.addressPromise => string<[[address]]>
_property: erc20.resolvedAddress => string<[[address]]>
This is a promise that will resolve to the address the **Contract**
object is attached to. If an [[address]] was provided to the constructor,
it will be equal to this; if an ENS name was provided, this will be the
resolved address.

_property: erc20.deployTransaction => [[provider-transactionresponse]]
_property: erc20.deployTransaction => [[providers-TransactionResponse]]
If the **Contract** object is the result of a ContractFactory deployment,
this is the transaction which was used to deploy the contract.

_property: erc20.interface => [[abi-interface]]
This is the ABI as an [[abi-interface]].
_property: erc20.interface => [[Interface]]
This is the ABI as an [[Interface]].

_property: erc20.provider => [[provider]]
_property: erc20.provider => [[Provider]]
If a provider was provided to the constructor, this is that provider. If
a signer was provided that had a [[provider]], this is that provider.
a signer was provided that had a [[Provider]], this is that provider.

_property: erc20.signer => [[signer]]
_property: erc20.signer => [[Signer]]
If a signer was provided to the constructor, this is that signer.


_subsection: Methods @NOTE<(inheritted from [[contract]])>
_subsection: Methods @NOTE<(inheritted from [[Contract]])>

_property: erc20.attach(addressOrName) => [[contract]]
_property: erc20.attach(addressOrName) => [[Contract]]
Returns a new instance of the **Contract** attached to a new
address. This is useful if there are multiple similar or identical
copies of a Contract on the network and you wish to interact with
each of them.

_property: erc20.connect(providerOrSigner) => [[contract]]
_property: erc20.connect(providerOrSigner) => [[Contract]]
Returns a new instance of the Contract, but connected to
//providerOrSigner//.

By passing in a [[provider]], this will return a downgraded
By passing in a [[Provider]], this will return a downgraded
**Contract** which only has read-only access (i.e. constant calls).

By passing in a [[signer]]. the will return a **Contract** which
By passing in a [[Signer]]. the will return a **Contract** which
will act on behalf of that signer.

_property: erc20.deployed() => Promise<Contract>

_property: Contract.isIndexed(value) => boolean


_subsection: Events @NOTE<(inheritted from [[contract]])> @<erc20-events>
_subsection: Events @NOTE<(inheritted from [[Contract]])> @<erc20-events>

_property: erc20.queryFilter(event [ , fromBlockOrBlockHash [ , toBlock ]) => Promise<Array<Event>> @<erc20-queryfilter>
Return Events that match the //event//.
Expand Down Expand Up @@ -133,16 +133,16 @@ on the ABI which was passed into the **Contract**.

_property: erc20.decimals([ overrides ]) => Promise<number>
Returns the number of decimal places used by this ERC-20 token. This can be
used with [parseUnits](utils-parseunits) when taking input from the user or
used with [parseUnits](utils-parseUnits) when taking input from the user or
[formatUnits](utils-formatunits] when displaying the token amounts in the UI.

_property: erc20.getBalance(owner [, overrides ]) => Promise<[[bignumber]]>
_property: erc20.getBalance(owner [, overrides ]) => Promise<[[BigNumber]]>
Returns the balance of //owner// for this ERC-20 token.

_property: erc20.symbol([ overrides ]) => Promise<string>
Returns the symbol of the token.

_property: erc20_rw.transfer(target, amount [, overrides ]) => Promise<[[provider-transactionresponse]]>
_property: erc20_rw.transfer(target, amount [, overrides ]) => Promise<[[providers-TransactionResponse]]>
Transfers //amount// tokens to //target// from the current signer.
The return value (a boolean) is inaccessible during a write operation
using a transaction. Other techniques (such as events) are required
Expand All @@ -155,12 +155,12 @@ the current signer, without actually signing or sending a transaction.

This can be used to preflight check that a transaction will be successful.

_property: erc20.estimate.transfer(target, amount [, overrides ]) => Promise<[[bignumber]]>
_property: erc20.estimateGas.transfer(target, amount [, overrides ]) => Promise<[[BigNumber]]>
Returns an estimate for how many units of gas would be required
to transfer //amount// tokens to //target//.

_property: erc20.populateTransaction.transfer(target, amount [, overrides ]) => Promise<[UnsignedTx](types-unsignedtransaction)>
Returns an [[types-unsignedtransaction]] which could be signed and submitted
_property: erc20.populateTransaction.transfer(target, amount [, overrides ]) => Promise<[UnsignedTx](UnsignedTransaction)>
Returns an [[UnsignedTransaction]] which could be signed and submitted
to the network to transaction //amount// tokens to //target//.


Expand Down
8 changes: 7 additions & 1 deletion docs.wrm/api/contract/index.wrm
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
Loading

0 comments on commit 84d37fd

Please sign in to comment.