Compare commits
85 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0daf437f7 | ||
|
|
8eaeba35f5 | ||
|
|
4a44865a8c | ||
|
|
725fe0aa32 | ||
|
|
08adc18a68 | ||
|
|
1fcf4b6ce6 | ||
|
|
7c8ae9cfcb | ||
|
|
0cd5fccfad | ||
|
|
53ee187443 | ||
|
|
4577444c44 | ||
|
|
1cb3199e5c | ||
|
|
25c3024a89 | ||
|
|
ae0d5eb7c2 | ||
|
|
b8df000c8f | ||
|
|
eb1ec2f231 | ||
|
|
b65508995c | ||
|
|
2a7dbf0571 | ||
|
|
0dc6f4a45b | ||
|
|
2534b1b3b2 | ||
|
|
a11602d066 | ||
|
|
bec066bcb5 | ||
|
|
ef5a2b4baa | ||
|
|
9e273220b6 | ||
|
|
d55ab6d4e6 | ||
|
|
1a7c4e89ef | ||
|
|
c84a5e62f5 | ||
|
|
6978cca17d | ||
|
|
0e3016bfae | ||
|
|
d50b2d7e65 | ||
|
|
941e4210c6 | ||
|
|
3b1d3fcee6 | ||
|
|
81fd628292 | ||
|
|
f9dd0996ca | ||
|
|
87ceaed4be | ||
|
|
0e1721b130 | ||
|
|
c47d2eba4d | ||
|
|
1db4ce12d4 | ||
|
|
6c43e20e7a | ||
|
|
b2ecffb0c8 | ||
|
|
a953f71752 | ||
|
|
c5a53d6911 | ||
|
|
bcda16df1d | ||
|
|
d937668dc1 | ||
|
|
8279120e0a | ||
|
|
243beffa4f | ||
|
|
3a76d69a16 | ||
|
|
5b41675f33 | ||
|
|
80cde06bcc | ||
|
|
7d0b33dc42 | ||
|
|
173f4d44bf | ||
|
|
73e94349de | ||
|
|
796954f880 | ||
|
|
f0a88f551f | ||
|
|
f4b97c00ed | ||
|
|
38eccc8b9d | ||
|
|
a3b5f7132c | ||
|
|
a1e7db4abe | ||
|
|
689459c1fd | ||
|
|
755fc72094 | ||
|
|
620b7b91a1 | ||
|
|
fb9eea6c7e | ||
|
|
d83c583412 | ||
|
|
3f97b94d15 | ||
|
|
0ae9ac6f98 | ||
|
|
2333b6cfd2 | ||
|
|
73b31b371f | ||
|
|
fd0cf2cc54 | ||
|
|
27a981c84b | ||
|
|
29be1e37bc | ||
|
|
e727efc33e | ||
|
|
4af2c19f45 | ||
|
|
4f67ecdf62 | ||
|
|
3396846a30 | ||
|
|
5c27b45ac9 | ||
|
|
20f6e16394 | ||
|
|
2df9dd1120 | ||
|
|
74470defda | ||
|
|
8175c83026 | ||
|
|
e0ccafb140 | ||
|
|
20335e96c2 | ||
|
|
a56a0a3336 | ||
|
|
4ad47b1b43 | ||
|
|
0e6cc9a9a8 | ||
|
|
21c6c7ddb6 | ||
|
|
8efbfc6afa |
22
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
22
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: investigate
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
Note: Not all sections may be relevant, but please be as thorough while remaining concise as possible. Remove this Notice and any sections that don't feel pertinent.
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**Reproduction steps**
|
||||
Please include code snippets, with console.log output, any contract ABI, contract address, network and the full error.
|
||||
|
||||
**Environment:**
|
||||
Please include anything that may be useful in diagnosing the issue. Node vs Browser? Geth vs Parity vs Ganache? Third Party tools, like Hardhat? Mobile vs. Desktop?
|
||||
|
||||
**Search Terms**
|
||||
Often similar issues have come up before. Include any search terms you have tried in this repository's Issues (including closed issues) and Discussions, so if there are matching issues, we can be sure to add those keywords to make it easier for people to find in the future.
|
||||
22
.github/ISSUE_TEMPLATE/feature-request.md
vendored
Normal file
22
.github/ISSUE_TEMPLATE/feature-request.md
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
name: Feature Request
|
||||
about: Suggest a new feature for ethers
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
Note: The best place to start a Feature Request is usually in the Discussions, to mull through the desired feature, current options and think through the impact on the library overall.
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
80
CHANGELOG.md
80
CHANGELOG.md
@@ -3,6 +3,86 @@ Changelog
|
||||
|
||||
This change log is managed by `admin/cmds/update-versions` but may be manually updated.
|
||||
|
||||
ethers/v5.1.2 (2021-04-18 19:31)
|
||||
--------------------------------
|
||||
|
||||
- Increase provider tests gas price for sending a transaction. ([8eaeba3](https://github.com/ethers-io/ethers.js/commit/8eaeba35f550c3d9aa1ae62eb8d8e0c912818f7f))
|
||||
- Fixed run-checking non-filter Contract events. ([#1458](https://github.com/ethers-io/ethers.js/issues/1458); [4a44865](https://github.com/ethers-io/ethers.js/commit/4a44865a8c22adb9c55d5c37a81ee46ebc68228c))
|
||||
|
||||
ethers/v5.1.1 (2021-04-18 02:47)
|
||||
--------------------------------
|
||||
|
||||
- Increased sendTransaction timeout to 15 minutes and pull Pocket from tx tests. ([08adc18](https://github.com/ethers-io/ethers.js/commit/08adc18a68bdc730633bdaaf2329014a84c12b2b))
|
||||
- Export Eip1193Bridge in experimental package. ([1fcf4b6](https://github.com/ethers-io/ethers.js/commit/1fcf4b6ce6922d2bcb245375c967da3072f113ed))
|
||||
- Prevent non-typed transactions from unsafely ignoring specified access lists. ([#1364](https://github.com/ethers-io/ethers.js/issues/1364); [4577444](https://github.com/ethers-io/ethers.js/commit/4577444c448f41114263077c5b54fbe6af749fd4))
|
||||
- Update tests for current EIP-2930 support across backends. ([#1364](https://github.com/ethers-io/ethers.js/issues/1364); [1cb3199](https://github.com/ethers-io/ethers.js/commit/1cb3199e5cb01f5a55eb00ab6c7904606d7ea1dd))
|
||||
- Removed underscore from the JsonRpcBatchProvider name. ([#62](https://github.com/ethers-io/ethers.js/issues/62), [#656](https://github.com/ethers-io/ethers.js/issues/656), [#892](https://github.com/ethers-io/ethers.js/issues/892); [ae0d5eb](https://github.com/ethers-io/ethers.js/commit/ae0d5eb7c2e37a003d893671db59c2d5719aea0f))
|
||||
- Added better error detection when pre-EIP-155 transactions are disabled. ([b8df000](https://github.com/ethers-io/ethers.js/commit/b8df000c8f0ccd252b6049ac5a32a986d5a8e08d))
|
||||
- Fix Android React Native environment shims which crash on normalizing Korean test. ([#1298](https://github.com/ethers-io/ethers.js/issues/1298); [eb1ec2f](https://github.com/ethers-io/ethers.js/commit/eb1ec2f2318e2851073ea1634e5003cdb53f1c1b))
|
||||
- Fixed EIP-2930 transactions for EtherscanProvider. ([#1364](https://github.com/ethers-io/ethers.js/issues/1364); [b655089](https://github.com/ethers-io/ethers.js/commit/b65508995ce7d02f109a970ebeb625819beb915a))
|
||||
- Re-enable AlchemyProvider Berlin tests. ([bec066b](https://github.com/ethers-io/ethers.js/commit/bec066bcb5ab8b95a7e7ce4848d7b76d7f248ccc))
|
||||
- Added experimental _JsonRpcBatchProvider. ([#62](https://github.com/ethers-io/ethers.js/issues/62), [#656](https://github.com/ethers-io/ethers.js/issues/656), [#892](https://github.com/ethers-io/ethers.js/issues/892); [d55ab6d](https://github.com/ethers-io/ethers.js/commit/d55ab6d4e6025c484cc7e64486d927bd54a0772b))
|
||||
- Cache JsonRpcProvider requests for certain methods per event loop. ([#1371](https://github.com/ethers-io/ethers.js/issues/1371); [1a7c4e8](https://github.com/ethers-io/ethers.js/commit/1a7c4e89efecc2b8afc8bea4c1f8f75fdaac08c5))
|
||||
|
||||
ethers/v5.1.0 (2021-03-30 14:44)
|
||||
--------------------------------
|
||||
|
||||
- Added BigNumber.toBigInt method. ([#1415](https://github.com/ethers-io/ethers.js/issues/1415); [81fd628](https://github.com/ethers-io/ethers.js/commit/81fd628292b7dde90fe5115074fa68476a872dbf))
|
||||
- Abstracted Contract with BaseContract without meta-class properties for easier extensions. ([#1384](https://github.com/ethers-io/ethers.js/issues/1384); [87ceaed](https://github.com/ethers-io/ethers.js/commit/87ceaed4be21283619da74678cf371c228c918b7))
|
||||
- Fixed Contract properties that collide with null member properties. ([#1393](https://github.com/ethers-io/ethers.js/issues/1393); [0e1721b](https://github.com/ethers-io/ethers.js/commit/0e1721b13084dacf63089e47116f7d5331be4f36))
|
||||
- Added EIP-2930 support. ([#1364](https://github.com/ethers-io/ethers.js/issues/1364); [c47d2eb](https://github.com/ethers-io/ethers.js/commit/c47d2eba4dc741eb5cb754c3ef5064b8ea7ac7cc))
|
||||
- Added abstraction for EIP-2718 support. ([1db4ce1](https://github.com/ethers-io/ethers.js/commit/1db4ce12d49e235a7155de24ee153f409e7e7370))
|
||||
|
||||
ethers/v5.0.32 (2021-03-07 18:17)
|
||||
---------------------------------
|
||||
|
||||
- Bumped TypeScript to 4.2.2. ([#1288](https://github.com/ethers-io/ethers.js/issues/1288); [b2ecffb](https://github.com/ethers-io/ethers.js/commit/b2ecffb0c8d44c8ee65199e7866dc744abae4e6e))
|
||||
- Fixed shims from not displaying debug information. ([a953f71](https://github.com/ethers-io/ethers.js/commit/a953f717523a844a3a45810a5acc6630383884d3))
|
||||
- Force TypedData numbers to be in decimal. ([#1193](https://github.com/ethers-io/ethers.js/issues/1193); [c5a53d6](https://github.com/ethers-io/ethers.js/commit/c5a53d6911d7c41dd03a290b550e80f2919e9379))
|
||||
|
||||
ethers/v5.0.31 (2021-02-12 19:04)
|
||||
---------------------------------
|
||||
|
||||
- Prevent unhandled rejections when passing nullish into Contract constructor. ([#1234](https://github.com/ethers-io/ethers.js/issues/1234); [d937668](https://github.com/ethers-io/ethers.js/commit/d937668dc1d39cc293f64bbd30b99b29614d1607))
|
||||
- Better error messaging when provider backends give bogus responses. ([#1243](https://github.com/ethers-io/ethers.js/issues/1243); [8279120](https://github.com/ethers-io/ethers.js/commit/8279120e0ad1cbb7aeabd32c08e168a4228abbec))
|
||||
- Prevent unconfigured ENS names from making an init tx. ([#1290](https://github.com/ethers-io/ethers.js/issues/1290); [243beff](https://github.com/ethers-io/ethers.js/commit/243beffa4f83c910f5f1c5e0554531e5dcf3ab93))
|
||||
|
||||
ethers/v5.0.30 (2021-02-08 15:22)
|
||||
---------------------------------
|
||||
|
||||
- When in Status trigger personal_sign instead of eth_sign. ([#1285](https://github.com/ethers-io/ethers.js/issues/1285); [73e9434](https://github.com/ethers-io/ethers.js/commit/73e94349de94d2969ccb21c834119525ddfcb961))
|
||||
- Bump elliptic version for CVE-2020-28498. ([#1284](https://github.com/ethers-io/ethers.js/issues/1284); [796954f](https://github.com/ethers-io/ethers.js/commit/796954f8807b0c464c7baa8f7ff299e22685e192))
|
||||
|
||||
ethers/v5.0.29 (2021-02-03 14:36)
|
||||
---------------------------------
|
||||
|
||||
- Fixed typos in JSON ABI formatting. ([#1275](https://github.com/ethers-io/ethers.js/issues/1275); [73b31b3](https://github.com/ethers-io/ethers.js/commit/73b31b371fa47bacc4f5f6bed01d0d1e5d66fa2c))
|
||||
|
||||
ethers/v5.0.28 (2021-02-02 17:12)
|
||||
---------------------------------
|
||||
|
||||
- Added load balancer support to PocketProvider. ([#1052](https://github.com/ethers-io/ethers.js/issues/1052); [27a981c](https://github.com/ethers-io/ethers.js/commit/27a981c84b578feb762fdb37dd5325d9c335bd59))
|
||||
|
||||
ethers/v5.0.27 (2021-02-01 15:55)
|
||||
---------------------------------
|
||||
|
||||
- Added support for networks with slightly incorrect EIP-658 implementations. ([#952](https://github.com/ethers-io/ethers.js/issues/952), [#1251](https://github.com/ethers-io/ethers.js/issues/1251); [e727efc](https://github.com/ethers-io/ethers.js/commit/e727efc33eaa31c3af6adbb64a893caf354d0ba7))
|
||||
- Added Pocket network to the default provider. ([#1030](https://github.com/ethers-io/ethers.js/issues/1030), [#1052](https://github.com/ethers-io/ethers.js/issues/1052); [4af2c19](https://github.com/ethers-io/ethers.js/commit/4af2c19f455bb43406d3cc5421c3b3fdda75f78f))
|
||||
- Added TypeScript declaration maps. ([#401](https://github.com/ethers-io/ethers.js/issues/401); [3396846](https://github.com/ethers-io/ethers.js/commit/3396846a30a4be0ed58fe449589e7e4e54f3d32e))
|
||||
|
||||
ethers/v5.0.26 (2021-01-13 14:47)
|
||||
---------------------------------
|
||||
|
||||
- Fixed abundant UnhandledRejectErrors in provider polling. ([#1084](https://github.com/ethers-io/ethers.js/issues/1084), [#1208](https://github.com/ethers-io/ethers.js/issues/1208), [#1221](https://github.com/ethers-io/ethers.js/issues/1221), [#1235](https://github.com/ethers-io/ethers.js/issues/1235); [74470de](https://github.com/ethers-io/ethers.js/commit/74470defda5170338735bbbe676c207cdd5cc1cf), [20f6e16](https://github.com/ethers-io/ethers.js/commit/20f6e16394909a43498c1ac6c73152957bd121bd))
|
||||
- Fixed non-checksum address comparisons in abstract Signer. ([#1236](https://github.com/ethers-io/ethers.js/issues/1236); [8175c83](https://github.com/ethers-io/ethers.js/commit/8175c83026436b6335800780ca12b7257e1b490f))
|
||||
|
||||
ethers/v5.0.25 (2021-01-08 03:31)
|
||||
---------------------------------
|
||||
|
||||
- Safety check on digest length for signing. ([20335e9](https://github.com/ethers-io/ethers.js/commit/20335e96c2429e851081b72031ea3fd4cd677904))
|
||||
- Fixed listenerCount for contract when requesting for all events. ([#1205](https://github.com/ethers-io/ethers.js/issues/1205); [a56a0a3](https://github.com/ethers-io/ethers.js/commit/a56a0a33366ea9276fba5bc45f1e4678dd723fa6))
|
||||
- Lock package versions for the ESM builds. ([#1009](https://github.com/ethers-io/ethers.js/issues/1009); [0e6cc9a](https://github.com/ethers-io/ethers.js/commit/0e6cc9a9a8ebceae4529ccbb7c107618eb54490a))
|
||||
|
||||
ethers/v5.0.24 (2020-12-08 01:43)
|
||||
---------------------------------
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ Installing
|
||||
|
||||
```
|
||||
<script type="module">
|
||||
import { ethers } from "https://cdn.ethers.io/lib/ethers-5.0.umd.min.js";
|
||||
import { ethers } from "https://cdn.ethers.io/lib/ethers-5.0.esm.min.js";
|
||||
</script>
|
||||
```
|
||||
|
||||
@@ -80,9 +80,9 @@ everyone else with packages they do not need.
|
||||
|
||||
We will keep a list of useful packages here.
|
||||
|
||||
- `@ethersproject/experimental` ([documentation](https://docs.ethers.io))
|
||||
- `@ethersproject/cli` ([documentation](https://docs.ethers.io))
|
||||
- `@ethersproject/hardware-wallets` ([documentation](https://docs.ethers.io))
|
||||
- `@ethersproject/experimental` ([documentation](https://docs.ethers.io/v5/api/experimental/))
|
||||
- `@ethersproject/cli` ([documentation](https://docs.ethers.io/v5/cli/))
|
||||
- `@ethersproject/hardware-wallets` ([documentation](https://docs.ethers.io/v5/api/other/hardware/))
|
||||
|
||||
|
||||
License
|
||||
|
||||
@@ -1,24 +1,49 @@
|
||||
_section: ContractFactory @<ContractFactory> @SRC<contracts:class.ContractFactory>
|
||||
|
||||
@TODO: Fill this in, including @SRC links
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
_subsection: Creating Instances @<ContractFactory--creating>
|
||||
|
||||
_property: new ethers.ContractFactory(interface, bytecode [ , signer ]) @SRC<contracts:constructor.ContractFactory>
|
||||
|
||||
Creates a new instance of a **ContractFactory** for the contract described
|
||||
by the //interface// and //bytecode// initcode.
|
||||
|
||||
_property: ContractFactory.fromSolidity(compilerOutput [ , signer ]) => [[ContractFactory]]
|
||||
|
||||
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.
|
||||
|
||||
_property: contractFactory.connect(signer) => [[Contract]] @<ContractFactory-connect>
|
||||
|
||||
Returns a **new instance** of the ContractFactory with the same //interface//
|
||||
and //bytecode//, but with a different //signer//.
|
||||
|
||||
_subsection: Properties @<ContractFactory--properties>
|
||||
|
||||
_property: contractFactory.interface => [[Interface]]
|
||||
|
||||
The [[Contract]] interface.
|
||||
|
||||
_property: contractFactory.bytecode => string<[[DataHexString]]>
|
||||
|
||||
The bytecode (i.e. initcode) that this **ContractFactory** will
|
||||
use to deploy the Contract.
|
||||
|
||||
_property: contractFactory.signer => [[Signer]]
|
||||
|
||||
The [[Signer]] (if any) this ContractFactory will use to deploy instances
|
||||
of the Contract to the Blockchain.
|
||||
|
||||
|
||||
_subsection: Methods @<ContractFactory--methods>
|
||||
|
||||
@@ -29,36 +54,52 @@ same as using the [Contract constructor](Contract--creating) with
|
||||
//address// and this the //interface// and //signerOrProvider// passed
|
||||
in when creating the ContractFactory.
|
||||
|
||||
_property: contractFactory.getDeployTransaction(...args) => [[UnsignedTransaction]]
|
||||
_property: contractFactory.getDeployTransaction(...args [ , overrides ]) => [[UnsignedTransaction]]
|
||||
|
||||
Returns the unsigned transaction which would deploy this Contract with //args// passed
|
||||
to the Contract's constructor.
|
||||
|
||||
_property: contractFactory.deploy(...args) => Promise<[[Contract]]> @<ContractFactory-deploy>
|
||||
If the optional //overrides// is specified, they can be used to
|
||||
override the endowment ``value``, transaction ``nonce``, ``gasLimit`` or
|
||||
``gasPrice``.
|
||||
|
||||
_property: contractFactory.deploy(...args [ , overrides ]) => Promise<[[Contract]]> @<ContractFactory-deploy>
|
||||
|
||||
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
|
||||
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.
|
||||
|
||||
_code: Deploying a Contract
|
||||
If the optional //overrides// is specified, they can be used to
|
||||
override the endowment ``value``, transaction ``nonce``, ``gasLimit`` or
|
||||
``gasPrice``.
|
||||
|
||||
_code: Deploying a Contract @lang<javascript>
|
||||
|
||||
// <hide>
|
||||
const signer = ethers.LocalSigner();
|
||||
const signer = localSigner;
|
||||
const ContractFactory = ethers.ContractFactory;
|
||||
const bytecode = "608060405234801561001057600080fd5b5060405161012e38038061012e8339818101604052604081101561003357600080fd5b81019080805190602001909291908051906020019092919050505081600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508060008190555050506088806100a66000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80633fa4f24514602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b6000805490509056fea2646970667358221220926465385af0e8706644e1ff3db7161af699dc063beaadd55405f2ccd6478d7564736f6c63430007040033";
|
||||
// </hide>
|
||||
|
||||
|
||||
// If your contract constructor requires parameters, the ABI
|
||||
// must include the constructor
|
||||
const abi = [
|
||||
"constructor(address owner, uint256 initialValue)"
|
||||
"constructor(address owner, uint256 initialValue)",
|
||||
"function value() view returns (uint)"
|
||||
];
|
||||
|
||||
const factory = new ContractFactory(abi, bytecode, signer)
|
||||
// The factory we use for deploying contracts
|
||||
factory = new ContractFactory(abi, bytecode, signer)
|
||||
|
||||
const contract = await factory.deploy("ricmoo.eth", 42);
|
||||
// Deploy an instance of the contract
|
||||
contract = await factory.deploy("ricmoo.eth", 42);
|
||||
//<hide>
|
||||
//! async contract
|
||||
//</hide>
|
||||
|
||||
// The address is available immediately, but the contract
|
||||
// is NOT deployed yet
|
||||
@@ -69,7 +110,9 @@ contract.address
|
||||
contract.deployTransaction
|
||||
//!
|
||||
|
||||
// Wait until the transaction is mined
|
||||
// Wait until the transaction is mined (i.e. contract is deployed)
|
||||
// - returns the receipt
|
||||
// - throws on failure (the reciept is on the error)
|
||||
contract.deployTransaction.wait()
|
||||
//!
|
||||
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
_section: Contract @<Contract> @SRC<contracts:class.Contract>
|
||||
|
||||
Explain contract here...
|
||||
A **Contract** is an abstraction of code that has been deployed
|
||||
to the blockchain.
|
||||
|
||||
A Contract may be sent transactions, which will trigger its code
|
||||
to be run with the input of the transaction data.
|
||||
|
||||
_subsection: Creating Instances @<Contract--creating>
|
||||
|
||||
_property: new ethers.Contract(address, abi, signerOrProvider) @src<contracts:constructor.Contract>
|
||||
_property: new ethers.Contract(address, abi, signerOrProvider) @src<contracts:class.Contract>
|
||||
|
||||
_property: contract.attach(addressOrName) => [[Contract]] @<Contract-attach> @SRC<contracts:Contract.attach>
|
||||
_property: contract.attach(addressOrName) => [[Contract]] @<Contract-attach> @SRC<contracts:BaseContract.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>
|
||||
_property: contract.connect(providerOrSigner) => [[Contract]] @<Contract-connect> @SRC<contracts:BaseContract.connect>
|
||||
Returns a new instance of the Contract, but connected to
|
||||
//providerOrSigner//.
|
||||
|
||||
@@ -61,11 +65,11 @@ _subsection: Events @<Contract--events>
|
||||
_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>
|
||||
_property: contract.listenerCount([ event ]) => number @<Contract-listenerCount> @SRC<contracts:BaseContract.listenerCount>
|
||||
Return the number of listeners that are subscribed to //event//. If
|
||||
no event is provided, returns the total count of all events.
|
||||
|
||||
_property: contract.listeners(event) => Array<Listener> @<Contract-listeners> @SRC<contracts:Contract.listeners>
|
||||
_property: contract.listeners(event) => Array<Listener> @<Contract-listeners> @SRC<contracts:BaseContract.listeners>
|
||||
Return a list of listeners that are subscribed to //event//.
|
||||
|
||||
_property: contract.off(event, listener) => this @<Contract-off> @SRC<contracts>
|
||||
@@ -78,7 +82,7 @@ _property: contract.once(event, listener) => this @<Contract-once> @SRC<contrac
|
||||
Subscribe once to //event// calling //listener// when the event
|
||||
occurs.
|
||||
|
||||
_property: contract.removeAllListeners([ event ]) => this @<Contract-removeAllListeners> @SRC<contracts:Contract.removeAllListeners>
|
||||
_property: contract.removeAllListeners([ event ]) => this @<Contract-removeAllListeners> @SRC<contracts:BaseContract.removeAllListeners>
|
||||
Unsubscribe all listeners for //event//. If no event is provided,
|
||||
all events are unsubscribed.
|
||||
|
||||
@@ -101,7 +105,10 @@ free and does not require any ether, but **cannot make changes** to
|
||||
the blockchain state..
|
||||
|
||||
_property: contract.METHOD_NAME(...args [, overrides ]) => Promise<any> @<Contract-functionsCall>
|
||||
The type of the result depends on the ABI.
|
||||
The type of the result depends on the ABI. If the method returns a single
|
||||
value, it will be returned directly, otherwise a [[Result]] object will
|
||||
be returned with each parameter available positionally and if the parameter
|
||||
is named, it will also be available by its name.
|
||||
|
||||
For values that have a simple meaning in JavaScript, the types are fairly
|
||||
straight forward; strings and booleans are returned as JavaScript strings
|
||||
@@ -113,6 +120,32 @@ number is used. Otherwise a [[BigNumber]] is returned.
|
||||
|
||||
For bytes (both fixed length and dynamic), a [[DataHexString]] is returned.
|
||||
|
||||
If the call reverts (or runs out of gas), a [CALL_EXCEPTION](errors--call-exception)
|
||||
will be thrown which will include:
|
||||
|
||||
- ``error.address`` - the contract address
|
||||
- ``error.args`` - the arguments passed into the method
|
||||
- ``error.transaction`` - the transaction
|
||||
|
||||
The //overrides// object for a read-only method may include any of:
|
||||
|
||||
- ``overrides.from`` - the ``msg.sender`` (or ``CALLER``) to use during the
|
||||
execution of the code
|
||||
- ``overrides.value`` - the ``msg.value`` (or ``CALLVALUE``) to use during the
|
||||
exectuiont of the code
|
||||
- ``overrides.gasPrice`` - the price to pay per gas (theoretically); since there
|
||||
is no transaction, there is not going to be any fee charged, but the EVM still
|
||||
requires a value to report to ``tx.gasprice`` (or ``GASPRICE``);
|
||||
//most developers will not require this//
|
||||
- ``overrides.gasLimit`` - the amount of gas (theoretically) to allow a node
|
||||
to use during the execution of the code; since there is no transaction, there
|
||||
is not going to be any fee charged, but the EVM still processes gas metering
|
||||
so calls like ``gasleft`` (or ``GAS``) report meaningful values
|
||||
- ``overrides.blockTag`` - a block tag to simulate the execution at, which
|
||||
can be used for hypothetical historic analysis; note that many backends
|
||||
do not support this, or may require paid plans to access as the node database
|
||||
storage and processing requirements are much higher
|
||||
|
||||
_property: contract.functions.METHOD_NAME(...args [, overrides ]) => Promise<[[Result]]>
|
||||
|
||||
The result will always be a [[Result]], even if there is only a single
|
||||
@@ -130,6 +163,8 @@ allowing an alternate UTF-8 error strategy to be used.
|
||||
|
||||
Most developers should not require this.
|
||||
|
||||
The //overrides// are identical to the read-only operations above.
|
||||
|
||||
_heading: Write Methods (non-constant) @<Contract--write>
|
||||
|
||||
A non-constant method requires a transaction to be signed and requires
|
||||
@@ -147,6 +182,32 @@ Returns a [[providers-TransactionResponse]] for the transaction after
|
||||
it is sent to the network. This requires the **Contract** has a
|
||||
signer.
|
||||
|
||||
The //overrides// object for write methods may include any of:
|
||||
|
||||
- ``overrides.gasPrice`` - the price to pay per gas
|
||||
- ``overrides.gasLimit`` - the limit on the amount of gas to allow the transaction
|
||||
to consume; any unused gas is returned at the gasPrice
|
||||
- ``overrides.value`` - the amount of ether (in wei) to forward with the call
|
||||
- ``overrides.nonce`` - the nonce to use for the [[Signer]]
|
||||
|
||||
If the ``wait()`` method on the returned [[providers-TransactionResponse]]
|
||||
is called, there will be additional properties on the receipt:
|
||||
|
||||
- ``receipt.events`` - an array of the logs, with additional properties
|
||||
(if the ABI included a description for the events)
|
||||
- ``receipt.events[n].args`` - the parsed arguments
|
||||
- ``receipt.events[n].decode`` - a method that can be used to parse the
|
||||
log topics and data (this was used to compute ``args``)
|
||||
- ``receipt.events[n].event`` - the name of the event
|
||||
- ``receipt.events[n].eventSignature`` - the full signature of the event
|
||||
- ``receipt.removeListener()`` - a method to remove the listener that trigger
|
||||
this event
|
||||
- ``receipt.getBlock()`` - a method to return the [Block](providers-Block) this event occurred in
|
||||
- ``receipt.getTransaction()`` - a method to return the
|
||||
[Transaction](providers-TransactionResponse) this event occurred in
|
||||
- ``receipt.getTransactionReceipt()`` - a method to return the
|
||||
[Transaction Receipt](providers-TransactionReceipt) this event occurred in
|
||||
|
||||
|
||||
_heading: Write Methods Analysis @<Contract--check>
|
||||
|
||||
@@ -157,11 +218,17 @@ _property: contract.estimateGas.METHOD_NAME(...args [ , overrides ]) => Promise<
|
||||
Returns the estimate units of gas that would be required to
|
||||
execute the //METHOD_NAME// with //args// and //overrides//.
|
||||
|
||||
The //overrides// are identical to the overrides above for read-only
|
||||
or write methods, depending on the type of call of //METHOD_NAME//.
|
||||
|
||||
_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//.
|
||||
|
||||
The //overrides// are identical to the overrides above for read-only
|
||||
or write methods, depending on the type of call of //METHOD_NAME//.
|
||||
|
||||
_property: contract.callStatic.METHOD_NAME(...args [ , overrides ]) => Promise<any> @<contract-callStatic>
|
||||
Rather than executing the state-change of a transaction, it is possible
|
||||
to ask a node to //pretend// that a call is not state-changing and
|
||||
@@ -172,6 +239,8 @@ can be used to determine if a transaction will fail or succeed.
|
||||
|
||||
This otherwise functions the same as a [Read-Only Method](Contract--readonly).
|
||||
|
||||
The //overrides// are identical to the read-only operations above.
|
||||
|
||||
_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
|
||||
|
||||
@@ -136,7 +136,7 @@ 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
|
||||
[formatUnits](utils-formatunits] when displaying the token amounts in the UI.
|
||||
|
||||
_property: erc20.getBalance(owner [, overrides ]) => Promise<[[BigNumber]]>
|
||||
_property: erc20.balanceOf(owner [, overrides ]) => Promise<[[BigNumber]]>
|
||||
Returns the balance of //owner// for this ERC-20 token.
|
||||
|
||||
_property: erc20.symbol([ overrides ]) => Promise<string>
|
||||
|
||||
@@ -58,7 +58,7 @@ Set the current transaction count (nonce) for the signer.
|
||||
This may be useful in interacting with the signer outside of using
|
||||
this class.
|
||||
|
||||
_property: nonceManager.increaseTransactionCount( [ count = 1 ]) => void
|
||||
_property: nonceManager.incrementTransactionCount( [ count = 1 ]) => void
|
||||
Bump the current transaction count (nonce) by //count//.
|
||||
|
||||
This may be useful in interacting with the signer outside of using
|
||||
|
||||
@@ -5,11 +5,13 @@ with Ethereum and is available in all major Ethereum node implementations
|
||||
(e.g. [[link-geth]] and [[link-parity]]) as well as many
|
||||
third-party web services (e.g. [[link-infura]])
|
||||
|
||||
_property: new ethers.providers.JsonRpcProvider([ url [ , aNetworkish ] ]) @SRC<providers:constructor.JsonRpcProvider>
|
||||
Connect to a JSON-RPC API located at //url// using the //aNetworkish// network.
|
||||
If //url// is not specified, the default (i.e. ``http:/\/localhost:8545``) is used
|
||||
and if no network is specified, it will be determined automatically by
|
||||
querying the node.
|
||||
_property: new ethers.providers.JsonRpcProvider([ urlOrConnectionInfo [ , networkish ] ]) @SRC<providers:constructor.JsonRpcProvider>
|
||||
Connect to a JSON-RPC HTTP API using the URL or [[ConnectionInfo]] //urlOrConnectionInfo//
|
||||
connected to the //networkish// network.
|
||||
|
||||
If //urlOrConnectionInfo// is not specified, the default (i.e. ``http:/\/localhost:8545``)
|
||||
is used and if no network is specified, it will be determined automatically by querying the
|
||||
node using ``eth_chaindId`` and falling back on ``eth_networkId``.
|
||||
|
||||
_note: Note: Connecting to a Local Node
|
||||
Each node implementation is slightly different and may require specific
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
_section: Other Providers
|
||||
|
||||
Others...
|
||||
|
||||
_subsection: FallbackProvider @<FallbackProvider> @INHERIT<[[Provider]]> @SRC<providers/fallback-provider:class.FallbackProvider>
|
||||
|
||||
The **FallbackProvider** is the most advanced [[Provider]] available in
|
||||
@@ -11,7 +9,7 @@ It uses a quorum and connects to multiple [Providers](Provider) as backends,
|
||||
each configured with a //priority// and a //weight// .
|
||||
|
||||
When a request is made, the request is dispatched to multiple backends, randomly
|
||||
chosen (higher priority backends are always selected first) and the results from
|
||||
chosen (lower-value priority backends are always selected first) and the results from
|
||||
each are compared against the others. Only once the quorum has been reached will that
|
||||
result be accepted and returned to the caller.
|
||||
|
||||
@@ -40,9 +38,9 @@ _property: fallbackProviderConfig.provider => [[Provider]]
|
||||
The provider for this configuration.
|
||||
|
||||
_property: fallbackProviderConfig.priority => number
|
||||
The priority used for the provider. Higher priorities are favoured over lower
|
||||
priorities. If multiple providers share the same priority, they are chosen
|
||||
at random.
|
||||
The priority used for the provider. Lower-value priorities are favoured over
|
||||
higher-value priorities. If multiple providers share the same priority, they
|
||||
are chosen at random.
|
||||
|
||||
_property: fallbackProviderConfig.stallTimeout => number
|
||||
The timeout (in ms) after which another [[Provider]] will be attempted. This
|
||||
@@ -156,7 +154,7 @@ WebSockets are much more intensive on your server resources, as they must manage
|
||||
and maintain the state for each client. For this reason, many services may also
|
||||
charge additional fees for using their WebSocket endpoints.
|
||||
|
||||
_property: new ethers.provider.WebSocketProvider([ url [ , network ] ])
|
||||
_property: new ethers.providers.WebSocketProvider([ url [ , network ] ])
|
||||
Returns a new [[WebSocketProvider]] connected to //url// as the //network//.
|
||||
|
||||
If //url// is unspecified, the default ``"ws:/\/localhost:8546"`` will be used.
|
||||
|
||||
@@ -1,7 +1,20 @@
|
||||
_section: Provider @<Provider>
|
||||
|
||||
Explain what a provider is...
|
||||
A **Provider** in ethers is a read-only abstraction to
|
||||
access the blockchain data.
|
||||
|
||||
_note: Coming from Web3.js?
|
||||
If you are coming from Web3.js, this is one of the biggest
|
||||
differences you will encounter using ethers.
|
||||
|
||||
The ethers library creates a strong division between the
|
||||
operation a **Provider** can perform and those of a [[Signer]],
|
||||
which Web3.js lumps together.
|
||||
|
||||
This separation of concerns and a stricted subset of Provider
|
||||
operations allows for a larger variety of backends, a more
|
||||
consistent API and ensures other libraries to operate without
|
||||
being able to rely on any underlying assumption.
|
||||
|
||||
_subsection: Accounts Methods @<Provider--account-methods>
|
||||
|
||||
@@ -73,6 +86,10 @@ reading and debugging much simpler.
|
||||
The provider offers some basic operations to help resolve and
|
||||
work with ENS names.
|
||||
|
||||
_property: provider.getResolver(name) => Promise<[[EnsResolver]]>
|
||||
Returns an EnsResolver instance which can be used to further inquire
|
||||
about specific entries for an ENS name.
|
||||
|
||||
_property: provider.lookupAddress(address) => Promise<string> @<Provider-lookupAddress> @SRC<providers/base-provider>
|
||||
Performs a reverse lookup of the //address// in ENS using the
|
||||
//Reverse Registrar//. If the name does not exist, or the
|
||||
@@ -94,6 +111,25 @@ provider.resolveName("ricmoo.firefly.eth");
|
||||
//!
|
||||
|
||||
|
||||
_subsection: EnsResolver @<EnsResolver>
|
||||
|
||||
_property: resolver.name => string
|
||||
The name of this resolver.
|
||||
|
||||
_property: resolver.address => string<[[address]]>
|
||||
The address of the Resolver.
|
||||
|
||||
_property: resolver.getAddress([ cointType = 60 ]) => Promise<string>
|
||||
Returns a Promise which resolves to the [[link-eip-2304]] multicoin address
|
||||
stored for the //coinType//. By default an Ethereum [[address]]
|
||||
(``coinType = 60``) will be returned.
|
||||
|
||||
_property: resolver.getContentHash() => Promise<string>
|
||||
Returns a Promise which resolves to any stored [[link-eip-1577]] content hash.
|
||||
|
||||
_property: resolver.getText(key) => Promise<string>
|
||||
Returns a Promise which resolves to any stored [[link-eip-634]] text entry for //key//.
|
||||
|
||||
_subsection: Logs Methods @<Provider--log-methods>
|
||||
|
||||
_property: provider.getLogs(filter) => Promise<Array<[[providers-Log]]>> @<Provider-getLogs> @SRC<providers/base-provider>
|
||||
@@ -115,6 +151,13 @@ Returns the block number (or height) of the most recently mined block.
|
||||
_property: provider.getGasPrice() => Promise<[[BigNumber]]> @<Provider-getGasPrice> @SRC<providers/base-provider>
|
||||
Returns a //best guess// of the [[gas-price]] to use in a transaction.
|
||||
|
||||
_property: provider.ready => Promise<[[providers-Network]]> @<Provider-ready> @src<providers/base-provider>
|
||||
Returns a Promise which will stall until the network has heen established,
|
||||
ignoring errors due to the target node not being active yet.
|
||||
|
||||
This can be used for testing or attaching scripts to wait until the node is
|
||||
up and running smoothly.
|
||||
|
||||
_code: Network Status Examples @lang<javascript>
|
||||
|
||||
// The network information
|
||||
@@ -156,6 +199,21 @@ An estimate may not be accurate since there could be another transaction
|
||||
on the network that was not accounted for, but after being mined affected
|
||||
relevant state.
|
||||
|
||||
_property: provider.getTransaction(hash) => Promise<[[providers-TransactionResponse]]> @<Provider-getTransaction> @src<providers/base-provider>
|
||||
Returns the transaction with //hash// or null if the transaction is unknown.
|
||||
|
||||
If a transaction has not been mined, this method will search the transaction
|
||||
pool. Various backends may have more restrictive transaction pool access (e.g.
|
||||
if the gas price is too low or the transaction was only recently sent and not
|
||||
yet indexed) in which case this method may also return null.
|
||||
|
||||
_property: provider.getTransactionReceipt(hash) => Promise<[[providers-TransactionReceipt]]> @<Provider-getTransactionReceipt> @src<providers/base-provider>
|
||||
Returns the transaction receipt for //hash// or null if the transaction
|
||||
has not been mined.
|
||||
|
||||
To stall until the transaction has been mined, consider the ``waitForTransaction``
|
||||
method below.
|
||||
|
||||
_property: provider.sendTransaction(transaction) => Promise<[[providers-TransactionResponse]]> @<Provider-sendTransaction> @SRC<providers/base-provider>
|
||||
Submits //transaction// to the network to be mined. The //transaction// **must** be signed,
|
||||
and be valid (i.e. the nonce is correct and the account has sufficient balance to pay
|
||||
@@ -164,36 +222,47 @@ for the transaction).
|
||||
_property: provider.waitForTransaction(hash [ , confirms = 1 [ , timeout ] ]) => Promise<[TxReceipt](providers-TransactionReceipt)> @<Provider-waitForTransaction> @SRC<providers/base-provider>
|
||||
Returns a Promise which will not resolve until //transactionHash// is mined.
|
||||
|
||||
If //confirms// is 0, this method is non-blocking and if the
|
||||
transaction has not been mined returns null. Otherwise,
|
||||
this method will block until the transaction has //confirms//
|
||||
blocks mined on top of the block in which is was mined.
|
||||
|
||||
_subsection: Event Emitter Methods @<Provider--event-methods>
|
||||
|
||||
Explain events here...
|
||||
The EventEmitter API allows applications to use an
|
||||
[[link-wiki-observer-pattern]] to register callbacks for when
|
||||
various events occur.
|
||||
|
||||
This closely follows the Event Emitter provided by other JavaScript
|
||||
libraries with the exception that event names support some more
|
||||
[complex objects](Provider--events), not only strings. The objects
|
||||
are normalized internally.
|
||||
|
||||
_property: provider.on(eventName, listener) => this @<Provider-on> @SRC<providers/base-provider>
|
||||
Add a //listener// to be triggered for each //eventName//.
|
||||
Add a //listener// to be triggered for each //eventName// [event](Provider--events).
|
||||
|
||||
_property: provider.once(eventName, listener) => this @<Provider-once> @SRC<providers/base-provider>
|
||||
Add a //listener// to be triggered for only the next //eventName//,
|
||||
at which time it will be removed.
|
||||
Add a //listener// to be triggered for only the next
|
||||
//eventName// [event](Provider--events), at which time it will be removed.
|
||||
|
||||
_property: provider.emit(eventName, ...args) => boolean @<Provider-emit> @SRC<providers/base-provider>
|
||||
Notify all listeners of //eventName//, passing //args// to each listener. This
|
||||
is generally only used internally.
|
||||
Notify all listeners of the //eventName// [event](Provider--events),
|
||||
passing //args// to each listener. This is generally only used internally.
|
||||
|
||||
_property: provider.off(eventName [ , listener ]) => this @<Provider-off> @SRC<providers/base-provider>
|
||||
Remove a //listener// for //eventName//. If no //listener// is provided,
|
||||
all listeners for //eventName// are removed.
|
||||
Remove a //listener// for the //eventName// [event](Provider--events).
|
||||
If no //listener// is provided, all listeners for //eventName// are removed.
|
||||
|
||||
_property: provider.removeAllListeners([ eventName ]) => this @<Provider-removeAllListeners> @SRC<providers/base-provider>
|
||||
Remove all the listeners for //eventName//. If no //eventName// is provided,
|
||||
**all** events are removed.
|
||||
Remove all the listeners for the //eventName// [events](Provider--events).
|
||||
If no //eventName// is provided, **all** events are removed.
|
||||
|
||||
_property: provider.listenerCount([ eventName ]) => number @<Provider-listenerCount> @SRC<providers/base-provider>
|
||||
Returns the number of listeners for //eventName//. If no //eventName// is
|
||||
provided, the total number of listeners is returned.
|
||||
Returns the number of listeners for the //eventName// [events](Provider--events).
|
||||
If no //eventName// is provided, the total number of listeners is returned.
|
||||
|
||||
_property: provider.listeners(eventName) => Array<Listener> @<Provider-listeners> @SRC<providers/base-provider>
|
||||
Returns the list of Listeners for //eventName//.
|
||||
Returns the list of Listeners for the //eventName// [events](Provider--events).
|
||||
|
||||
|
||||
_heading: Events @<Provider--events>
|
||||
@@ -207,7 +276,7 @@ properties ``address`` (the source contract) and ``topics`` (a topic-set to matc
|
||||
|
||||
If ``address`` is unspecified, the filter matches any contract address.
|
||||
|
||||
See events for more information on how to specify topic-sets.
|
||||
See [EventFilters](providers-EventFilter) for more information on filtering events.
|
||||
|
||||
_definition: **Topic-Set Filter**
|
||||
|
||||
@@ -216,6 +285,8 @@ The value of a **Topic-Set Filter** is a array of Topic-Sets.
|
||||
This event is identical to a //Log Filter// with the address omitted (i.e. from
|
||||
any contract).
|
||||
|
||||
See [EventFilters](providers-EventFilter) for more information on filtering events.
|
||||
|
||||
_definition: **Transaction Filter**
|
||||
|
||||
The value of a **Transaction Filter** is any transaction hash.
|
||||
|
||||
@@ -1,23 +1,15 @@
|
||||
_section: Types
|
||||
|
||||
_subsection: BlockTag @<providers-BlockTag>
|
||||
A **BlockTag** specifies a specific location in the Blockchain.
|
||||
A **BlockTag** specifies a specific block location in the Blockchain.
|
||||
|
||||
- **``"latest"``** -- The most recently mined block
|
||||
- **``"earliest"``** -- Block #0
|
||||
- **``"pending"``** -- The block currently being prepared for mining; not all
|
||||
- **``"latest"``** - The most recently mined block
|
||||
- **``"earliest"``** - Block #0
|
||||
- **``"pending"``** - The block currently being prepared for mining; not all
|
||||
operations and backends support this BlockTag
|
||||
- **//number//** -- The block at this height
|
||||
- **//a negative number//** -- The block this many blocks ago
|
||||
|
||||
_heading: EventType @<providers-EventType>
|
||||
|
||||
And **EventType** can be any of the following.
|
||||
|
||||
- **//string//** -- TODO...
|
||||
- **//Array<string<[[DataHexString]]<32>> | Array<string<[[DataHexString]]<32>>>>//** -- TODO...
|
||||
- **//[[providers-EventFilter]]//** -- TODO...
|
||||
|
||||
- **//number//** - The block at this height
|
||||
- **//a negative number//** - The block this many blocks ago
|
||||
- **//hex string//** - The block at this height (as a hexidecimal value)
|
||||
|
||||
_subsection: Networkish @<providers-Networkish>
|
||||
A **Networkish** may be any of the following:
|
||||
@@ -111,10 +103,15 @@ _heading: EventFilter @<providers-EventFilter>
|
||||
_property: filter.address => string<[[address]]>
|
||||
The address to filter by, or ``null`` to match any address.
|
||||
|
||||
_property: filter.topics => Array<string<[[DataHexString]]<32>> | Array<string<[[DataHexString]]<32>>>>
|
||||
The topics to filter by, or ``null`` to match any topics. Each entry represents an
|
||||
**AND** condition that must match, or may be ``null`` to match anything. If a given
|
||||
entry is an Array, then that entry is treated as an **OR** for any value in the entry.
|
||||
_property: filter.topics => Array<string<[Data](DataHexString)<32>> | Array<string<[Data](DataHexString)<32>>>>
|
||||
The topics to filter by or ``null`` to match any topics.
|
||||
|
||||
Each entry represents an **AND** condition that must match, or may
|
||||
be ``null`` to match anything. If a given entry is an Array, then
|
||||
that entry is treated as an **OR** for any value in the entry.
|
||||
|
||||
See [Filters](events--filters) for more details and examples
|
||||
on specifying complex filters.
|
||||
|
||||
_heading: Filter @<providers-Filter> @INHERIT<[[providers-EventFilter]]>
|
||||
|
||||
@@ -205,7 +202,18 @@ The chain ID this transaction is authorized on, as specified by
|
||||
If the chain ID is 0 will disable EIP-155 and the transaction will be valid
|
||||
on any network. This can be **dangerous** and care should be taken, since it
|
||||
allows transactions to be replayed on networks that were possibly not
|
||||
intended.
|
||||
intended. Intentionally-replayable transactions are also disabled by default
|
||||
on recent versions of Geth and require configuration to enable.
|
||||
|
||||
_property: transactionRequest.type => null | number
|
||||
|
||||
The [[link-eip-2718]] type of this transaction envelope, or ``null``
|
||||
for legacy transactions that do not have an envelope.
|
||||
|
||||
_property: transactionRequest.accessList => [[providers-AccessListish]]
|
||||
|
||||
The [[providers-AccessList]] to include in an [[link-eip-2930]] transaction, which will
|
||||
include a ``type`` of ``1``.
|
||||
|
||||
_heading: TransactionResponse @<providers-TransactionResponse> @INHERIT<[[Transaction]]>
|
||||
|
||||
@@ -231,9 +239,28 @@ transaction was mined.
|
||||
_property: transaction.raw => string<[[DataHexString]]>
|
||||
The serialized transaction.
|
||||
|
||||
_property: transaction.wait([ confirmations = 1 ]) => Promise<[[providers-TransactionReceipt]]>
|
||||
Wait for //confirmations//. If 0, and the transaction has not been mined,
|
||||
``null`` is returned.
|
||||
_property: transaction.wait([ confirms = 1 ]) => Promise<[[providers-TransactionReceipt]]>
|
||||
Resolves to the [[providers-TransactionReceipt]] once the transaction
|
||||
has been included in the chain for //confirms// blocks. If //confirms//
|
||||
is 0, and the transaction has not been mined, ``null`` is returned.
|
||||
|
||||
If the transaction execution failed (i.e. the receipt status is ``0``),
|
||||
a [CALL_EXCEPTION](errors--call-exception) Error will be rejected with
|
||||
the following properties:
|
||||
|
||||
- ``error.transaction`` - the original transaction
|
||||
- ``error.transactionHash`` - the hash of the transaction
|
||||
- ``error.receipt`` - the actual receipt, with the status of ``0``
|
||||
|
||||
_property: transactionRequest.type => null | number
|
||||
|
||||
The [[link-eip-2718]] type of this transaction envelope, or ``null``
|
||||
for legacy transactions that do not have an envelope.
|
||||
|
||||
_property: transactionRequest.accessList => [[providers-AccessList]]
|
||||
|
||||
The [[providers-AccessList]] included in an [[link-eip-2930]] transaction, which will
|
||||
also have its ``type`` equal to ``1``.
|
||||
|
||||
_heading: TransactionReceipt @<providers-TransactionReceipt>
|
||||
|
||||
@@ -308,3 +335,110 @@ _property: receipt.status => boolean
|
||||
The status of a transaction is 1 is successful or 0 if it was
|
||||
reverted. Only transactions included in blocks [post-Byzantium Hard Fork](link-eip-609)
|
||||
have this property.
|
||||
|
||||
_subsection: Access Lists
|
||||
|
||||
An Access List is optional an includes a list of addresses and storage
|
||||
slots for that address which should be //warmed// or pre-fetched for
|
||||
use within the execution of this transaction. A //warmed// value has an
|
||||
additional upfront cost to access, but is discounted throughout the code
|
||||
execution for reading and writing.
|
||||
|
||||
_heading: AccessListish @<providers-AccessListish>
|
||||
|
||||
A looser description of an [[providers-AccessList]], which will be
|
||||
converted internally using [accessListify](utils-accessListify).
|
||||
|
||||
|
||||
It may be any of:
|
||||
|
||||
- any [[providers-AccessList]]
|
||||
- an Array of 2-element Arrays, where the first element is the address
|
||||
and second array is an array of storage keys
|
||||
- an object, whose keys represent the addresses and each value is an
|
||||
array of storage keys
|
||||
|
||||
When using the object form (the last option), the addresses and storage
|
||||
slots will be sorted. If an explicit order for the access list is
|
||||
required, one of the other forms must be used. Most developers
|
||||
**do not** require explicit order.
|
||||
|
||||
_code: equivalent to the AccessList example below @lang<javascript>
|
||||
|
||||
// Option 1:
|
||||
// AccessList
|
||||
// see below
|
||||
|
||||
// Option 2:
|
||||
// Array< [ Address, Array<Bytes32> ] >
|
||||
[
|
||||
[
|
||||
"0x0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
|
||||
[
|
||||
"0x0000000000000000000000000000000000000000000000000000000000000004",
|
||||
"0x0bcad17ecf260d6506c6b97768bdc2acfb6694445d27ffd3f9c1cfbee4a9bd6d"
|
||||
]
|
||||
],
|
||||
[
|
||||
"0x5FfC014343cd971B7eb70732021E26C35B744cc4",
|
||||
[
|
||||
"0x0000000000000000000000000000000000000000000000000000000000000001"
|
||||
]
|
||||
]
|
||||
]
|
||||
// <hide>
|
||||
;
|
||||
// </hide>
|
||||
|
||||
// Option 3:
|
||||
// Record<Address, Array<Bytes32>>
|
||||
// <hide>
|
||||
(
|
||||
// </hide>
|
||||
{
|
||||
"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e": [
|
||||
"0x0000000000000000000000000000000000000000000000000000000000000004",
|
||||
"0x0bcad17ecf260d6506c6b97768bdc2acfb6694445d27ffd3f9c1cfbee4a9bd6d"
|
||||
],
|
||||
"0x5FfC014343cd971B7eb70732021E26C35B744cc4": [
|
||||
"0x0000000000000000000000000000000000000000000000000000000000000001"
|
||||
]
|
||||
}
|
||||
// <hide>
|
||||
)
|
||||
// </hide>
|
||||
|
||||
|
||||
_heading: AccessList @<providers-AccessList>
|
||||
|
||||
An [[link-eip-2930]] transaction allows an optional **AccessList**
|
||||
which causes a transaction to //warm// (i.e. pre-cache) another
|
||||
addresses state and the specified storage keys.
|
||||
|
||||
This incurs an increased intrinsic cost for the transaction, but provides
|
||||
discounts for storage and state access throughout the execution of the
|
||||
transaction.
|
||||
|
||||
_code: example access list
|
||||
|
||||
// Array of objects with the form:
|
||||
// {
|
||||
// address: Address,
|
||||
// storageKey: Array< DataHexString< 32 > >
|
||||
// }
|
||||
|
||||
[
|
||||
{
|
||||
address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
|
||||
storageKeys: [
|
||||
"0x0000000000000000000000000000000000000000000000000000000000000004",
|
||||
"0x0bcad17ecf260d6506c6b97768bdc2acfb6694445d27ffd3f9c1cfbee4a9bd6d"
|
||||
]
|
||||
},
|
||||
{
|
||||
address: "0x5FfC014343cd971B7eb70732021E26C35B744cc4",
|
||||
storageKeys: [
|
||||
"0x0000000000000000000000000000000000000000000000000000000000000001"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -45,13 +45,13 @@ _property: ethers.utils.getAddress(address) => string<[[address]]> @<utils-getA
|
||||
Returns //address// as a Checksum Address.
|
||||
|
||||
If //address// is an invalid 40-nibble [[HexString]] or if it contains mixed case and
|
||||
the checksum is invalid, an InvalidArgument Error is thrown.
|
||||
the checksum is invalid, an [INVALID_ARGUMENT](errors--invalid-argument) Error is thrown.
|
||||
|
||||
The value of //address// may be any supported address format.
|
||||
|
||||
_property: ethers.utils.getIcapAddress(address) => string<[IcapAddress](address-icap)> @<utils-getIcapAddress> @SRC<address>
|
||||
Returns //address// as an [ICAP address](link-icap).
|
||||
Supports the same restrictions as [utils.getAddress](utils-getAddress).
|
||||
Supports the same restrictions as [getAddress](utils-getAddress).
|
||||
|
||||
_property: ethers.utils.isAddress(address) => boolean @<utils-isAddress> @SRC<address>
|
||||
Returns true if //address// is valid (in any supported format).
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
_section: Byte Manipulation
|
||||
|
||||
Tra la la...
|
||||
While there are many high-level APIs for interacting with
|
||||
Ethereum, such as [Contracts](Contract) and [Providers](Provider),
|
||||
a lot of the low level access requires byte manipulation
|
||||
operations.
|
||||
|
||||
Many of these operations are used internally, but can also be
|
||||
used to help normalize binary data representations from the
|
||||
output of various functions and methods.
|
||||
|
||||
_subsection: Types
|
||||
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
_section: HD Wallet @<hdnodes>
|
||||
|
||||
TODO: Explain [BIP32](link-bip-32) [BIP-39](link-bip-39) and whatnot here...
|
||||
The Hierarchal Desterministic (HD) Wallet was a standard
|
||||
created for Bitcoin, but lends itself well to a wide variety of
|
||||
Blockchains which rely on secp256k1 private keys.
|
||||
|
||||
For a more detailed technical understanding:
|
||||
|
||||
- [BIP-32](link-bip-32) - the hierarchal deterministic description
|
||||
- [BIP-39](link-bip-39) - the method used to derive the BIP-32 seed
|
||||
from human-readable sequences of words (i.e. a mnemonic)
|
||||
- [BIP-44](link-bip-44) - a standard defined to make BIP-32 easy
|
||||
to adapt to any future compatible blockchain
|
||||
|
||||
_subsection: Types
|
||||
|
||||
|
||||
@@ -48,39 +48,38 @@ Throw an Error with //message// and an optional //code// and
|
||||
additional //params// set.
|
||||
|
||||
_property: logger.throwArgumentError(message, name, value) => never @SRC<logger>
|
||||
Throw an [INVALID_ARGUMENT](errors-InvalidArgument) Error with //name// and //value//.
|
||||
|
||||
Throw an [INVALID_ARGUMENT](errors--invalid-argument) Error with //name// and //value//.
|
||||
|
||||
_heading: Usage Validation
|
||||
|
||||
There can be used to ensure various properties and actions are safe.
|
||||
|
||||
_property: logger.checkAbstract(target, kind) => void @SRC<logger>
|
||||
Checks that //target// is not //kind// and performs the same operations
|
||||
as ``checkNew``. This is useful for ensuring abstract classes are not
|
||||
being instantiated.
|
||||
_property: logger.checkAbstract(target, kind) => void @<Logger-checkAbstract> @SRC<logger>
|
||||
If //target// is //kind//, throws a [UNSUPPORTED_OPERATION](errors--unsupported-operation) error
|
||||
otherwise performs the same operations as [checkNew](Logger-checkNew).
|
||||
|
||||
_property: logger.checkArgumentCount(count, expectedCount [ , message) => void @SRC<logger>
|
||||
If //count// is not equal to //expectedCount//, throws a [MISSING_ARGUMENT](errors-MissingArgument)
|
||||
or [UNEXPECTED_ARGUMENT](errors-UnexpectedArgument) error.
|
||||
This is useful for ensuring abstract classes are not being instantiated.
|
||||
|
||||
_property: logger.checkNew(target, kind) => void @SRC<logger>
|
||||
_property: logger.checkArgumentCount(count, expectedCount [ , message) => void @<Logger-checkArgumentCount> @SRC<logger>
|
||||
If //count// is not equal to //expectedCount//, throws a [MISSING_ARGUMENT](errors--missing-argument)
|
||||
or [UNEXPECTED_ARGUMENT](errors--unexpected-argument) error.
|
||||
|
||||
_property: logger.checkNew(target, kind) => void @<Logger-checkNew> @SRC<logger>
|
||||
If //target// is not a valid ``this`` or ``target`` value, throw a
|
||||
[MISSING_NEW](errors-MissingNew) error. This is useful to ensure
|
||||
[MISSING_NEW](errors--missing-new) error. This is useful to ensure
|
||||
callers of a Class are using ``new``.
|
||||
|
||||
_property: logger.checkNormalize(message) => void @SRC<logger>
|
||||
_property: logger.checkNormalize(message) => void @<Logger-checkNoralize> @SRC<logger>
|
||||
Check that the environment has a correctly functioning [[link-js-normalize]]. If not, a
|
||||
[UNSUPPORTED_OPERATION](errors-UnsupportedOperation) error is thrown.
|
||||
[UNSUPPORTED_OPERATION](errors--unsupported-operation) error is thrown.
|
||||
|
||||
_property: logger.checkSafeUint53(value [, message ]) => void @SRC<logger>
|
||||
_property: logger.checkSafeUint53(value [, message ]) => void @<Logger-checkSafeUint53> @SRC<logger>
|
||||
If //value// is not safe as a [JavaScript number](link-wiki-ieee754), throws a
|
||||
[NUMERIC_FAULT](errors-NumericFault) error.
|
||||
|
||||
[NUMERIC_FAULT](errors--numeric-fault) error.
|
||||
|
||||
_heading: Censorship @<Logger--censorship>
|
||||
|
||||
_property: Logger.setCensorship(censor [ , permanent = false ]) => void @SRC<logger>
|
||||
_property: Logger.setCensorship(censor [ , permanent = false ]) => void @<Logger-setCensorship> @SRC<logger>
|
||||
Set error censorship, optionally preventing errors from being uncensored.
|
||||
|
||||
In production applications, this prevents any error from leaking information
|
||||
@@ -88,7 +87,7 @@ by masking the message and values of errors.
|
||||
|
||||
This can impact debugging, making it substantially more difficult.
|
||||
|
||||
_property: Logger.setLogLevel(logLevel) => void @SRC<logger>
|
||||
_property: Logger.setLogLevel(logLevel) => void @<Logger-setLogLevel> @SRC<logger>
|
||||
Set the log level, to suppress logging output below a [particular log level](Logger-levels).
|
||||
|
||||
|
||||
@@ -98,76 +97,113 @@ Every error in Ethers has a ``code`` value, which is a string that will
|
||||
match one of the following error codes.
|
||||
|
||||
|
||||
_heading: Generic Error Codes
|
||||
_heading: Generic Error Codes @<errors-generic>
|
||||
|
||||
_property: Logger.errors.NOT_IMPLEMENTED
|
||||
The operation is not implemented.
|
||||
_property: Logger.errors.NOT_IMPLEMENTED @<errors--not-implemented>
|
||||
The operation is not implemented. This may occur when calling a method
|
||||
on a sub-class that has not fully implemented its abstract superclass.
|
||||
|
||||
_property: Logger.errors.SERVER_ERROR
|
||||
_property: Logger.errors.SERVER_ERROR @<errors--server-error>
|
||||
There was an error communicating with a server.
|
||||
|
||||
_property: Logger.errors.TIMEOUT @<errors-Timeout>
|
||||
This may occur for a number of reasons, for example:
|
||||
|
||||
- a [CORS](link-cors) issue; this is quite often the problem and also the
|
||||
hardest to diagnose and fix, so it is very beneficial to familiarize
|
||||
yourself with CORS; some backends allow you configure your CORS, such as
|
||||
the geth command-line or conifguration files or the INFURA and Alchemy
|
||||
dashboards by specifing allowed Origins, methods, etc.
|
||||
- an SSL issue; for example, if you are trying to connect to a local node via
|
||||
HTTP but are serving the content from a secure HTTPS website
|
||||
- a link issue; a firewall is preventing the traffic from reaching the server
|
||||
- a server issue; the server is down, or is returning 500 error codes
|
||||
- a backend DDoS mitigation proxy; for example, Etherscan operates behind a
|
||||
Cloudflare proxy, which will block traffic if the request is sent via
|
||||
specific User Agents or the client fingerprint is detected as a bot in some
|
||||
cases
|
||||
|
||||
_property: Logger.errors.TIMEOUT @<errors--timeout>
|
||||
A timeout occurred.
|
||||
|
||||
_property: Logger.errors.UNKNOWN_ERROR @<errors-UnknownError>
|
||||
_property: Logger.errors.UNKNOWN_ERROR @<errors--unknown-error>
|
||||
A generic unknown error.
|
||||
|
||||
_property: Logger.errors.UNSUPPORTED_OPERATION @<errors-UnsupportedOperation>
|
||||
_property: Logger.errors.UNSUPPORTED_OPERATION @<errors--unsupported-operation>
|
||||
The operation is not supported.
|
||||
|
||||
This can happen for a variety reasons, for example:
|
||||
|
||||
_heading: Safety Error Codes
|
||||
- Some backends do not support certain operations; such as passing a blockTag
|
||||
to an [[EtherscanProvider]] for [call](Provider-call)
|
||||
- A [[Contract]] object connected to [[Provider]] (instead of a [[Signer]]) cannot
|
||||
[sign](Signer-signTransaction) or [send](Signer-sendTransaction) transactions
|
||||
- a [[Contract]] connected to a [[Signer]] without a [[Provider]] is write-only
|
||||
and cannot estimate gas or execute static calls
|
||||
|
||||
_property: Logger.errors.BUFFER_OVERRUN
|
||||
|
||||
_heading: Safety Error Codes @<errors-safety>
|
||||
|
||||
_property: Logger.errors.BUFFER_OVERRUN @<errors--buffer-overrun>
|
||||
The amount of data needed is more than the amount of data required,
|
||||
which would cause the data buffer to read past its end.
|
||||
|
||||
_property: Logger.errors.NUMERIC_FAULT @<errors-NumericFault>
|
||||
This can occur if a contract erroneously returns invalid ABI-encoded
|
||||
data or RLP data is malformed.
|
||||
|
||||
_property: Logger.errors.NUMERIC_FAULT @<errors--numeric-fault>
|
||||
There was an invalid operation done on numeric values.
|
||||
|
||||
Common cases of this occur when there is [[link-wiki-overflow]],
|
||||
[[link-wiki-underflow]] in fixed numeric types or division by zero.
|
||||
|
||||
|
||||
_heading: Usage Error Codes
|
||||
_heading: Usage Error Codes @<errors-usage>
|
||||
|
||||
_property: Logger.errors.INVALID_ARGUMENT @<errors-InvalidArgument>
|
||||
_property: Logger.errors.INVALID_ARGUMENT @<errors--invalid-argument>
|
||||
The type or value of an argument is invalid. This will generally also
|
||||
include the ``name`` and ``value`` of the argument. Any function which
|
||||
accepts sensitive data (such as a private key) will include the string
|
||||
``[\[REDACTED]\]`` instead of the value passed in.
|
||||
``"[\[REDACTED]\]"`` instead of the value passed in.
|
||||
|
||||
_property: Logger.errors.MISSING_ARGUMENT @<errors-MissingArgument>
|
||||
_property: Logger.errors.MISSING_ARGUMENT @<errors--missing-argument>
|
||||
An expected parameter was not specified.
|
||||
|
||||
_property: Logger.errors.MISSING_NEW @<errors-MissingNew>
|
||||
An object is a Class, but is now being called with ``new``.
|
||||
_property: Logger.errors.MISSING_NEW @<errors--missing-new>
|
||||
An object is a Class, but is not being called with ``new``.
|
||||
|
||||
_property: Logger.errors.UNEXPECTED_ARGUMENT @<errors-UnexpectedArgument>
|
||||
_property: Logger.errors.UNEXPECTED_ARGUMENT @<errors--unexpected-argument>
|
||||
Too many parameters we passed into a function.
|
||||
|
||||
|
||||
_heading: Ethereum Error Codes
|
||||
_heading: Ethereum Error Codes @<errors-ethereum>
|
||||
|
||||
_property: Logger.errors.CALL_EXCEPTION
|
||||
_property: Logger.errors.CALL_EXCEPTION @<errors--call-exception>
|
||||
An attempt to call a blockchain contract (getter) resulted in a
|
||||
revert or other error.
|
||||
revert or other error, such as insufficient gas (out-of-gas) or an
|
||||
invalid opcode. This can also occur during gas estimation or if
|
||||
waiting for a [[providers-TransactionReceipt]] which failed during execution.
|
||||
|
||||
_property: Logger.errors.INSUFFICIENT_FUNDS
|
||||
Consult the contract to determine the cause, such as a failed condition
|
||||
in a ``require`` statement. The ``reason`` property may provide more
|
||||
context for the cause of this error.
|
||||
|
||||
_property: Logger.errors.INSUFFICIENT_FUNDS @<errors--insufficient-funds>
|
||||
The account is attempting to make a transaction which costs more than is
|
||||
available.
|
||||
|
||||
A sending account must have enough ether to pay for the value, the gas limit
|
||||
(at the gas price) as well as the intrinsic cost of data. The intrinsic cost
|
||||
of data is 4 gas for each zero byte and 68 gas for each non-zero byte.
|
||||
of data is 4 gas for each zero byte and 68 gas for each non-zero byte, as well
|
||||
as 35000 gas if a transaction contains no ``to`` property and is therefore
|
||||
expected to create a new account.
|
||||
|
||||
_property: Logger.errors.NETWORK_ERROR
|
||||
_property: Logger.errors.NETWORK_ERROR @<errors--network>
|
||||
An Ethereum network validation error, such as an invalid chain ID.
|
||||
|
||||
_property: Logger.errors.NONCE_EXPIRED
|
||||
_property: Logger.errors.NONCE_EXPIRED @<errors--nonce-expired>
|
||||
The nonce being specified has already been used in a mined transaction.
|
||||
|
||||
_property: Logger.errors.REPLACEMENT_UNDERPRICED
|
||||
_property: Logger.errors.REPLACEMENT_UNDERPRICED @<errors--replacement-underpriced>
|
||||
When replacing a transaction, by using a nonce which has already been sent to
|
||||
the network, but which has not been mined yet the new transaction must specify
|
||||
a higher gas price.
|
||||
@@ -175,9 +211,12 @@ a higher gas price.
|
||||
This error occurs when the gas price is insufficient to //bribe// the transaction
|
||||
pool to prefer the new transaction over the old one. Generally, the new gas price
|
||||
should be about 50% + 1 wei more, so if a gas price of 10 gwei was used, the
|
||||
replacement should be 15.000000001 gwei.
|
||||
replacement should be 15.000000001 gwei. This is not enforced by the protocol, as
|
||||
it deals with unmined transactions, and can be configured by each node, however
|
||||
to ensure a transaction is propagated to a miner it is best practice to follow
|
||||
the defaults most nodes have enabled.
|
||||
|
||||
_property: Logger.errors.UNPREDICTABLE_GAS_LIMIT
|
||||
_property: Logger.errors.UNPREDICTABLE_GAS_LIMIT @<errors--unpredicatable-gas-limit>
|
||||
When estimating the required amount of gas for a transaction, a node is queried for
|
||||
its best guess.
|
||||
|
||||
|
||||
@@ -1,9 +1,40 @@
|
||||
_section: Property Utilities
|
||||
|
||||
_property: ethers.utils.checkProperties() => void
|
||||
This is a collection of utility functions used for handling
|
||||
properties in a platform-safe way.
|
||||
|
||||
The next major version of ethers will no longer be compatible
|
||||
with ES3, so many of these will be removed in favor of the
|
||||
built-in options available in ES2015 and above.
|
||||
|
||||
_property: ethers.utils.checkProperties(object, check) => void
|
||||
|
||||
Checks that //object// only contains properties included
|
||||
in //check//, and throws [INVALID_ARGUMENT](errors--invalid-argument) if not.
|
||||
|
||||
_property: ethers.utils.deepCopy(anObject) => any
|
||||
|
||||
Creates a recursive copy of //anObject//. Frozen (i.e. and other known
|
||||
immutable) objects are copied by reference.
|
||||
|
||||
_property: ethers.utils.defineReadOnly(anObject, name, value) => void
|
||||
|
||||
Uses the ``Object.defineProperty`` method to set a read-only property
|
||||
on an object.
|
||||
|
||||
_property: ethers.utils.getStatic(aConstructor, key) => any
|
||||
|
||||
Recursively check for a static method //key// on an inheritance chain
|
||||
from //aConstructor// to all ancestors.
|
||||
|
||||
This is used to mimic behaviour in other languages where ``this`` in
|
||||
a static method will also search ancestors.
|
||||
|
||||
_property: ethers.utils.resolveProperties(anObject) => Promise<any> @<utils-resolveproperties> @SRC<properties>
|
||||
|
||||
Retruns a Promise which resolves all child values on //anObject//.
|
||||
|
||||
_property: ethers.utils.shallowCopy(anObject) => any
|
||||
|
||||
Returns a shallow copy of //anObject//. This is the same as
|
||||
using ``Object.assign({ }, anObject)``.
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
_section: Strings @<strings>
|
||||
|
||||
Tra la la
|
||||
A **String** is a representation of a human-readable input of output,
|
||||
which are often taken for granted.
|
||||
|
||||
When dealing with blockchains, properly handling human-readable and
|
||||
human-provided data is important to prevent loss of funds, assets,
|
||||
incorrect permissions, etc.
|
||||
|
||||
_subsection: Bytes32String @<Bytes32String>
|
||||
|
||||
|
||||
@@ -97,6 +97,15 @@ used to encode the chain ID into the serialized transaction.
|
||||
|
||||
_subsection: Functions @<transactions--functions>
|
||||
|
||||
_property: ethers.utils.accessListify(anAcceslistish) => [[providers-AccessList]] @<utils-accessListify> @SRC<transactions:accessListify>
|
||||
Normalizes the [[providers-AccessListish]] //anAccessListish// into
|
||||
an [[providers-AccessList]].
|
||||
|
||||
This is useful for other utility functions which wish to remain
|
||||
flexible as to the input parameter for access lists, such as
|
||||
when creating a [[Signer]] which needs to manipulate a possibly
|
||||
typed transaction envelope.
|
||||
|
||||
_property: ethers.utils.parseTransaction(aBytesLike) => [[Transaction]] @<utils-parseTransaction> @SRC<transactions:parse>
|
||||
Parses the transaction properties from a serialized transaction.
|
||||
|
||||
|
||||
@@ -1,34 +1,40 @@
|
||||
_section: Events
|
||||
|
||||
Explain how topics and such work
|
||||
|
||||
_subsection: Solidity Topics
|
||||
|
||||
How to compute the topic...
|
||||
_section: Events @<events>
|
||||
|
||||
_subsection: Logs and Filtering
|
||||
|
||||
Example hog logs are used.
|
||||
Logs and filtering are used quite often in blockchain applications,
|
||||
since they allow for efficient queries of indexed data and provide
|
||||
lower-cost data storage when the data is not required to be
|
||||
accessed on-chain.
|
||||
|
||||
Link to provider.getLogs and contract.on
|
||||
These can be used in conjunction with the [Provider Events API](Provider--event-methods)
|
||||
and with the [Contract Events API](Contract--events).
|
||||
|
||||
_heading: Filters
|
||||
The Contract Events API also provides [higher-level methods](Contract--filters)
|
||||
to compute and query this data, which should be preferred over the lower-level filter.
|
||||
|
||||
Filter are used as a way to query ... efficient, explain bloom filters lightly
|
||||
_heading: Filters @<events--filters>
|
||||
|
||||
A filter may have up to 4 topic-sets, where each topic-set refers
|
||||
to a condition that must match the log topic in that position (i.e. each
|
||||
condition is ``AND``-ed together).
|
||||
When a Contract creates a log, it can include up to 4 pieces of
|
||||
data to be indexed by. The indexed data is hashed and included in
|
||||
a [[link-wiki-bloomfilter]], which is a data structure that allows
|
||||
for efficient filtering.
|
||||
|
||||
If a topic-set is ``null``, a log topic in that position is not filtered
|
||||
So, a filter may correspondingly have up to 4 topic-sets, where each
|
||||
topic-set refers to a condition that must match the indexed log topic
|
||||
in that position (i.e. each condition is ``AND``-ed together).
|
||||
|
||||
If a topic-set is ``null``, a log topic in that position is **not filtered**
|
||||
at all and **any value** matches.
|
||||
|
||||
If a topic-set is a single topic, a log topic in that position must match
|
||||
If a topic-set is a single topic, a log topic in that position **must** match
|
||||
**that topic**.
|
||||
|
||||
If a topic-set is an array of topics, a log topic in that position must
|
||||
match any **one** of the topics (i.e. the topic in this position are ``OR``-ed).
|
||||
match **any one** of the topics (i.e. the topic in this position are ``OR``-ed).
|
||||
|
||||
This may sound complicated at first, but is more easily understood with
|
||||
some examples.
|
||||
|
||||
_table: Example Log Matching @style<full>
|
||||
|
||||
@@ -152,6 +158,56 @@ contract.filters.Transfer(myAddress, otherAddress)
|
||||
contract.filters.Transfer(null, [ myAddress, otherAddress ])
|
||||
//!
|
||||
|
||||
|
||||
_subsection: Solidity Topics @<events-solidity>
|
||||
|
||||
This is a quick (and non-comprehensive) overview of how events are computed
|
||||
in Solidity.
|
||||
|
||||
This is likely out of the scope for most developers, but may be interesting
|
||||
to those who want to learn a bit more about the underlying technology.
|
||||
|
||||
Solidity provides two types of events, anonymous and non-anonymous. The
|
||||
default is non-anonymous, and most developers will not need to worry about
|
||||
anonymous events.
|
||||
|
||||
For non-anonymous events, up to 3 topics may be indexed (instead of 4), since
|
||||
the first topic is reserved to specify the event signature. This allows
|
||||
non-anonymous events to always be filtered by their event signature.
|
||||
|
||||
This topic hash is always in the first slot of the indexed data, and is
|
||||
computed by normalizing the Event signature and taking the keccak256 hash
|
||||
of it.
|
||||
|
||||
For anonymous events, up to 4 topics may be indexed, and there is no
|
||||
signature topic hash, so the events cannot be filtered by the event
|
||||
signature.
|
||||
|
||||
Each additional indexed property is processed depending on whether its
|
||||
length is fixed or dynamic.
|
||||
|
||||
For fixed length types (e.g. ``uint``, ``bytes5``), all of which are
|
||||
internally exactly 32 bytes (shorter types are padded with zeros;
|
||||
numeric values are padded on the left, data values padded on the right),
|
||||
these are included directly by their actual value, 32 bytes of data.
|
||||
|
||||
For dynamic types (e.g. ``string``, ``uint256[]``) , the value is hashed
|
||||
using keccak256 and this hash is used.
|
||||
|
||||
Because dynamic types are hashed, there are important consequences in
|
||||
parsing events that should be kept in mind. Mainly that the original
|
||||
value is lost in the event. So, it is possible to tell is a topic is
|
||||
equal to a given string, but if they do not match, there is no way
|
||||
to determine what the value was.
|
||||
|
||||
If a developer requires that a string value is required to be both
|
||||
able to be filtered and also able to be read, the value must be included
|
||||
in the signature twice, once indexed and once non-indexed (e.g.
|
||||
``someEvent(string indexed searchBy, string clearText)``).
|
||||
|
||||
For a more detailed description, please refer to the
|
||||
[Solidity Event Documentation](link-solidity-events).
|
||||
|
||||
_heading: Other Things? TODO
|
||||
|
||||
Explain what happens to strings and bytes, how to filter and retain the value
|
||||
|
||||
@@ -43,6 +43,8 @@ function getDefinitions(source) {
|
||||
if (depth === 3) {
|
||||
add("var", node.name.escapedText, node.name.end);
|
||||
}
|
||||
} else if (ts.isGetAccessorDeclaration(node)) {
|
||||
add("getter", (lastClass + "." + node.name.text), node.name.end);
|
||||
}
|
||||
ts.forEachChild(node, (node) => { return visit(node, depth + 1); });
|
||||
}
|
||||
@@ -129,6 +131,13 @@ function codeContextify(context) {
|
||||
context.Wallet = ethers.Wallet;
|
||||
context.provider = new ethers.providers.InfuraProvider("mainnet", "49a0efa3aaee4fd99797bfa94d8ce2f1");
|
||||
|
||||
// We use a local dev node for some signing examples, but want to
|
||||
// resolve ENS names against mainnet; super hacky but makes the
|
||||
// docs nicer
|
||||
context.localProvider = new ethers.providers.JsonRpcProvider();
|
||||
context.localSigner = context.localProvider.getSigner();
|
||||
context.localProvider.resolveName = context.provider.resolveName.bind(context.provider);
|
||||
|
||||
context.BigNumber.prototype[inspect.custom] = function(depth, options) {
|
||||
return `{ BigNumber: ${JSON.stringify(this.toString()) } }`;
|
||||
}
|
||||
@@ -153,8 +162,11 @@ function codeContextify(context) {
|
||||
module.exports = {
|
||||
title: "ethers",
|
||||
subtitle: "v5.0",
|
||||
description: "Documentation for ethers, a complete, tiny and simple Ethereum library.",
|
||||
logo: "logo.svg",
|
||||
|
||||
socialImage: "social.jpg",
|
||||
|
||||
prefix: "/v5",
|
||||
|
||||
link: "https:/\/docs.ethers.io",
|
||||
@@ -171,6 +183,7 @@ module.exports = {
|
||||
codeRoot: "../",
|
||||
|
||||
externalLinks: {
|
||||
"link-mail": "mailto:me@ricmoo.com",
|
||||
"link-alchemy": { name: "Alchemy", url: "https:/\/alchemyapi.io" },
|
||||
"link-cloudflare": { name: "Cloudflare", url: "https:/\/developers.cloudflare.com/distributed-web/ethereum-gateway/" },
|
||||
"link-ens": { name: "ENS", url: "https:/\/ens.domains/" },
|
||||
@@ -190,7 +203,8 @@ module.exports = {
|
||||
"link-react-native": { name: "React Native", url: "https:/\/reactnative.dev" },
|
||||
"link-rtd": "https:/\/github.com/readthedocs/sphinx_rtd_theme",
|
||||
"link-semver": { name: "semver", url: "https:/\/semver.org" },
|
||||
"link-solidity": { name: "Solidity" , url: "https:/\/solidity.readthedocs.io/en/v0.6.2/" },
|
||||
"link-solidity": { name: "Solidity" , url: "https:/\/solidity.readthedocs.io/" },
|
||||
"link-solidity-events": "https:/\/docs.soliditylang.org/en/v0.8.1/abi-spec.html#events",
|
||||
"link-sphinx": { name: "Sphinx", url: "https:/\/www.sphinx-doc.org/" },
|
||||
|
||||
"link-alchemy-signup": "https:/\/dashboard.alchemyapi.io/signup?referral=55a35117-028e-4b7c-9e47-e275ad0acc6d",
|
||||
@@ -239,12 +253,18 @@ module.exports = {
|
||||
"link-eip-155": { name: "EIP-155", url: "https:/\/eips.ethereum.org/EIPS/eip-155" },
|
||||
"link-eip-191": { name: "EIP-191", url: "https:/\/eips.ethereum.org/EIPS/eip-191" },
|
||||
"link-eip-609": { name: "EIP-609", url: "https:/\/eips.ethereum.org/EIPS/eip-609" },
|
||||
"link-eip-634": { name: "EIP-634", url: "https:/\/eips.ethereum.org/EIPS/eip-634" },
|
||||
"link-eip-712": { name: "EIP-712", url: "https:/\/eips.ethereum.org/EIPS/eip-712" },
|
||||
"link-eip-1014": { name: "EIP-1014", url: "https:/\/eips.ethereum.org/EIPS/eip-1014" },
|
||||
"link-eip-1193": { name: "EIP-1193", url: "https:/\/eips.ethereum.org/EIPS/eip-1193" },
|
||||
"link-eip-1577": { name: "EIP-1577", url: "https:/\/eips.ethereum.org/EIPS/eip-1577" },
|
||||
"link-eip-2098": { name: "EIP-2098", url: "https:/\/eips.ethereum.org/EIPS/eip-2098" },
|
||||
"link-eip-2304": { name: "EIP-2304", url: "https:/\/eips.ethereum.org/EIPS/eip-2304" },
|
||||
"link-eip-2718": { name: "EIP-2718", url: "https:/\/eips.ethereum.org/EIPS/eip-2718" },
|
||||
"link-eip-2930": { name: "EIP-2930", url: "https:/\/eips.ethereum.org/EIPS/eip-2930" },
|
||||
"link-bip-39": { name: "BIP-39", url: "https:/\/en.bitcoin.it/wiki/BIP_0039" },
|
||||
"link-bip-32": { name: "BIP-32", url: "https:/\/github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" },
|
||||
"link-bip-44": { name: "BIP-44", url: "https:/\/en.bitcoin.it/wiki/BIP_0044" },
|
||||
|
||||
"link-npm-elliptic": { name: "elliptic", url: "https:/\/www.npmjs.com/package/elliptic" },
|
||||
"link-npm-ethersproject-shims": { name: "Shims", url: "https:/\/www.npmjs.com/package/@ethersproject/shims" },
|
||||
@@ -260,8 +280,12 @@ module.exports = {
|
||||
"link-js-proxy": "https:/\/developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy",
|
||||
"link-js-typedarray": "https:/\/developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray",
|
||||
|
||||
"link-cors": { name: "CORS", url: "https:/\/developer.mozilla.org/en-US/docs/Web/HTTP/CORS" },
|
||||
|
||||
"link-ricmoo-humanreadableabi": "https:/\/blog.ricmoo.com/human-readable-contract-abis-in-ethers-js-141902f4d917",
|
||||
|
||||
"link-other-ethereum-dev-docs": "https:/\/ethereum.org/en/developers/docs/",
|
||||
|
||||
"link-wiki-basicauth": { name: "Basic Authentication", url: "https:/\/en.wikipedia.org/wiki/Basic_access_authentication" },
|
||||
"link-wiki-backoff": { name: "Exponential Backoff", url: "https:/\/en.wikipedia.org/wiki/Exponential_backoff" },
|
||||
"link-wiki-bloomfilter": { name: "Bloom Filter", url: "https:/\/en.wikipedia.org/wiki/Bloom_filter" },
|
||||
@@ -272,6 +296,7 @@ module.exports = {
|
||||
"link-wiki-hmac": "https:/\/en.wikipedia.org/wiki/HMAC",
|
||||
"link-wiki-iban": "https:/\/en.wikipedia.org/wiki/International_Bank_Account_Number",
|
||||
"link-wiki-ieee754": "https:/\/en.wikipedia.org/wiki/Double-precision_floating-point_format",
|
||||
"link-wiki-observer-pattern": { name: "Obeserver Pattern", url: "https:/\/en.wikipedia.org/wiki/Observer_pattern" },
|
||||
"link-wiki-ripemd": "https:/\/en.m.wikipedia.org/wiki/RIPEMD",
|
||||
"link-wiki-sha2": "https:/\/en.wikipedia.org/wiki/SHA-2",
|
||||
"link-wiki-twoscomplement": "https:/\/en.wikipedia.org/wiki/Two%27s_complement",
|
||||
|
||||
@@ -7,7 +7,7 @@ Many things are the way they are for good (at the time, at least) reasons,
|
||||
but I always welcome criticism, and am completely willing to have my mind
|
||||
changed on things.
|
||||
|
||||
So, pull requests are always welcome, but please keep a few points in mind:
|
||||
Pull requests are always welcome, but please keep a few points in mind:
|
||||
|
||||
- Backwards-compatibility-breaking changes will not be accepted; they may be
|
||||
considered for the next major version
|
||||
@@ -15,6 +15,9 @@ So, pull requests are always welcome, but please keep a few points in mind:
|
||||
arguments as to why
|
||||
- The library aims to be lean, so keep an eye on the dist/ethers.min.js
|
||||
file size before and after your changes
|
||||
- Keep the PR simple and readable; only modify files in the ``docs.wrm/``
|
||||
and ``packages/*/src.ts/`` folders, as this allows the changes to be easily
|
||||
verified
|
||||
- Add test cases for both expected and unexpected input
|
||||
- Any new features need to be supported by me (future issues, documentation,
|
||||
testing, migration), so anything that is overly complicated or specific
|
||||
@@ -27,60 +30,135 @@ have a public discussion and figure out the best way to address the problem/feat
|
||||
|
||||
_subsection: Building @<contributing--building>
|
||||
|
||||
If you wish to modify the source code, there are a few steps involved in
|
||||
setting up your environment.
|
||||
The build process for ethers is unfortunatly not super trivial, but
|
||||
I have attempted to make it as straight-forward as possible.
|
||||
|
||||
Since the library uses a monorepo, you must install an initial required
|
||||
set of libraries, which can then be used to install the remaining libraries
|
||||
used within each package, as well as link all the packages within the repo
|
||||
with each other.
|
||||
It is a mono-repo which attempts to be compatibile with a large
|
||||
number of environments, build tools and platforms, which is why
|
||||
there are a some weird things it must do.
|
||||
|
||||
_code: Preparing for builds @lang<shell>
|
||||
There are several custom scripts in the ``misc/admin`` folder
|
||||
to help manage the monorepo. Developers working on contributing
|
||||
to ethers should not generally need to worry about those, since
|
||||
they are wrapped up behind ``npm run SCRIPT`` operations.
|
||||
|
||||
_code: Installing @lang<shell>
|
||||
|
||||
# Clone the repository
|
||||
/home/ricmoo> git clone git@github.com:ethers-io/ethers.js.git
|
||||
/home/ricmoo> git clone https://github.com/ethers-io/ethers.js.git
|
||||
|
||||
/home/ricmoo> cd ethers.js
|
||||
|
||||
# Install the base dependencies
|
||||
# Install all dependencies:
|
||||
# - Hoists all sub-package dependencies in the package.json (preinstall)
|
||||
# - Installs all the (hoisted) dependencies and devDependencies (install)
|
||||
# - Build the rat-nests (in .package_node_modules) (postinstall)
|
||||
# - Create a dependency graph for the TypeScript (postinstall)
|
||||
# - Link the rat-nets into each project (postinstall)
|
||||
/home/ricmoo/ethers.js> npm install
|
||||
|
||||
# Install each module's dependencies and link the libraries
|
||||
# internally, so they reference each other
|
||||
/home/ricmoo/ethers.js> npm run bootstrap
|
||||
_heading: Making Changes @<contributing--updating>
|
||||
|
||||
|
||||
_subsection: Making your changes @<contributing--updating>
|
||||
|
||||
TODO: Add more information here.
|
||||
Once your environment is set up, you should be able to simply
|
||||
start the ``auto-build`` feature, and make changes to the
|
||||
TypeScript source.
|
||||
|
||||
_code: Watching and Building @lang<shell>
|
||||
|
||||
# Begin watching the files and re-building whenever they change
|
||||
/home/ricmoo/ethers.js> npm run auto-build
|
||||
|
||||
# Or if you do not want to watch and just build
|
||||
/home/ricmoo/ethers.js> npm run build
|
||||
|
||||
# Sometimes the issue only affects the ESM modules
|
||||
/home/ricmoo/ethers.js> npm run auto-build-esm
|
||||
_heading: Creating Browser-Ready Files
|
||||
|
||||
To create files for use directly in a browser, the distribution
|
||||
files (located in ``packages/ethers/dist``) need to be built
|
||||
which requires several intermediate builds, scripts and for
|
||||
various rollup scripts to execute.
|
||||
|
||||
# Or if you only need to run a single build
|
||||
/home/ricmoo/ethers.js> npm run _build-cjs
|
||||
/home/ricmoo/ethers.js> npm run _build-esm
|
||||
_code: Building Distribution Files @lang<shell>
|
||||
|
||||
# If you need to rebuild all the libs (esm + cjs) and dist files
|
||||
# Note: this requires node 10 or newer
|
||||
/home/ricmoo/ethers.js> npm run build-all
|
||||
|
||||
_heading: Testing
|
||||
|
||||
_code: Testing @lang<shell>
|
||||
|
||||
# Rebuilds all files and bundles testcases up for testing
|
||||
# Rebuilds all files (npm run build-all) and bundles testcases up for testing
|
||||
/home/ricmoo/ethers.js> npm test
|
||||
|
||||
# Often you don't need the full CI experience
|
||||
/home/ricmoo/ethers.js> npm run _test-node
|
||||
/home/ricmoo/ethers.js> npm run test-node
|
||||
|
||||
_heading: Distribution
|
||||
|
||||
Most developers should not ever require this step, but for people
|
||||
forking ethers and creating alternates (for example if you have
|
||||
a non-EVM compatible chain but are trying to reuse this package).
|
||||
|
||||
This script will rebuild the entire ethers project, compare it
|
||||
against npm, re-write package versions, update internal hashes,
|
||||
re-write various TypeScript files (to get around some ES+TS
|
||||
limitations for Tree Shaking and linking), re-write map files,
|
||||
bundle stripped versions of dependencies and basically just a
|
||||
whole bunch of stuff.
|
||||
|
||||
If you use this and get stuck, [message me](link-mail).
|
||||
|
||||
_code: Preparing the Distribution @lang<shell>
|
||||
|
||||
# Prepare all the distribution files
|
||||
# - Remove all generated files (i.e. npm run clean)
|
||||
# - Re-install all dependencies, hoisting, etc. (npm install)
|
||||
# - Spell check all strings in every TypeScript files
|
||||
# - Build everything from scratch with this clean install
|
||||
# - Compare local with npm, bumping the version if changed
|
||||
# - Build everything again (with the updated versions)
|
||||
# - Update the CHANGELOG.md with the git history since the last change
|
||||
/home/ricmoo/ethers.js> npm run update-version
|
||||
|
||||
_note: Do NOT check in dist files in a PR
|
||||
|
||||
For Pull Requests, please ONLY commit files in the ``docs.wrm/`` and
|
||||
``packages/*/src.ts/`` folders. I will prepare the distribution builds
|
||||
myself and keeping the PR relevant makes it easier to verify the changes.
|
||||
|
||||
_heading: Publishing
|
||||
|
||||
Again, this should not be necessary for most developers. This step
|
||||
requires using the ``misc/admin/cmds/config-set`` script for a number
|
||||
of values, including private keys, NPM session keys, AWS access keys,
|
||||
GitHub API tokens, etc.
|
||||
|
||||
The config file is encrypted with about 30 seconds of scrypt password-based
|
||||
key derivation function, so brute-forcing the file is quite expensive.
|
||||
|
||||
The config file also contains a plain-text mnemonic. This is a money-pot.
|
||||
Place a tempting amount of ether or Bitcoin on this account and set up an
|
||||
e-mail alert for this account.
|
||||
|
||||
If any attacker happens across your encrypted config, they will have instant
|
||||
access to the plain-text mnemonic, so they have the option to immediately
|
||||
steal the ether (i.e. the responsible-disclosure bond).
|
||||
|
||||
If you ever see this ether taken, your encrypted file is compromised! Rotate
|
||||
all your AWS keys, NPM session keys, etc. immedately.
|
||||
|
||||
@TODO: document all the keys that need to be set for each step
|
||||
|
||||
_code: Preparing the Distribution @lang<shell>
|
||||
|
||||
# Publish
|
||||
# - Update any changed packages to NPM
|
||||
# - Create a release on GitHub with the latest CHANGELOG.md description
|
||||
# - Upload the bundled files the the CDN
|
||||
# - Flush the CDN edge caches
|
||||
/home/ricmoo/ethers.js> npm run publish-all
|
||||
|
||||
|
||||
_subsection: Documentation @<contributing--documentation>
|
||||
|
||||
@@ -95,7 +173,7 @@ Style Guide (this section will have much more coming):
|
||||
- Prefix external links with ``link-``
|
||||
- Changing an anchor name must be well justified, as it will break all existing links
|
||||
to that section; flatworm will support symlinks in the future
|
||||
- In general, I aim for xonsistency; look to similar situations throughout the documentation
|
||||
- In general, I aim for consistency; look to similar situations throughout the documentation
|
||||
|
||||
|
||||
_heading: Building
|
||||
|
||||
@@ -17,7 +17,7 @@ _subsection: Installing @<cookbook-reactnative-shims>
|
||||
To use ethers in React Native, you must either provide shims for the needed
|
||||
missing functionality, or use the ethers.js shim.
|
||||
|
||||
It is **HIGHLY RECOMMENDED** you check out the [security section](cookbook-reactnative-security>
|
||||
It is **HIGHLY RECOMMENDED** you check out the [security section](cookbook-reactnative-security)
|
||||
below for instructions on installing packages which can affect the security
|
||||
of your application.
|
||||
|
||||
|
||||
BIN
docs.wrm/favicon.ico
Normal file
BIN
docs.wrm/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
@@ -101,7 +101,7 @@ with Ethereum and is available in all major Ethereum node implementations
|
||||
third-party web services (e.g. [[link-infura]]). It typically provides:
|
||||
|
||||
- A connection to the Ethereum network (a [[Provider]])
|
||||
- Holds your private key and can sign thing (a [[Signer]])
|
||||
- Holds your private key and can sign things (a [[Signer]])
|
||||
|
||||
_code: Connecting to an RPC client @lang<script>
|
||||
|
||||
@@ -165,7 +165,7 @@ If you are familiar with Databases, this is similar to an //Object Relational Ma
|
||||
|
||||
In order to communicate with the Contract on-chain, this class
|
||||
needs to know what methods are available and how to encode and
|
||||
decode the data, which is what the //Application Binary Interface// (API)
|
||||
decode the data, which is what the //Application Binary Interface// (ABI)
|
||||
provides.
|
||||
|
||||
This class is a //meta-class//, which means its methods are constructed
|
||||
@@ -311,14 +311,14 @@ const daiContract = new ethers.Contract("dai.tokens.ethers.eth", daiAbi, provide
|
||||
myAddress = await signer.getAddress()
|
||||
//! async myAddress
|
||||
|
||||
// Filter for all token transfers to me
|
||||
// Filter for all token transfers from me
|
||||
filterFrom = daiContract.filters.Transfer(myAddress, null);
|
||||
// <hide>
|
||||
filterFrom
|
||||
// </hide>
|
||||
//!
|
||||
|
||||
// Filter for all token transfers from me
|
||||
// Filter for all token transfers to me
|
||||
filterTo = daiContract.filters.Transfer(null, myAddress);
|
||||
// <hide>
|
||||
filterTo
|
||||
|
||||
@@ -45,6 +45,7 @@ _toc:
|
||||
migration
|
||||
testing
|
||||
contributing
|
||||
other-resources
|
||||
documentation
|
||||
license
|
||||
|
||||
|
||||
17
docs.wrm/other-resources.wrm
Normal file
17
docs.wrm/other-resources.wrm
Normal file
@@ -0,0 +1,17 @@
|
||||
_section: Other Resources
|
||||
|
||||
There is a lot of documentation on the internet to help you get started,
|
||||
learn more or cover advanced topics. Here are a few resources to check out.
|
||||
|
||||
_subsection: Ethereum Overview
|
||||
|
||||
- Official [Ethereum Developer Documentations](link-other-ethereum-dev-docs)
|
||||
- The [Solidity Documentation](link-solidity), the defactor language for smart
|
||||
contracts as well as a resource for some of the core concepts of Ethereum
|
||||
|
||||
_subsection: Tutorials
|
||||
|
||||
I do not manage or maintain these tutorials, but have happened across them.
|
||||
If a link is dead or outdated, please [let me know](link-mail) and I'll update it.
|
||||
|
||||
- No links yet; send me some
|
||||
BIN
docs.wrm/social.jpg
Normal file
BIN
docs.wrm/social.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
1
docs/api-keys/redirects.txt
Normal file
1
docs/api-keys/redirects.txt
Normal file
@@ -0,0 +1 @@
|
||||
index.html => /v5/api-keys
|
||||
9
docs/errors/redirects.txt
Normal file
9
docs/errors/redirects.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
server-error => /v5/api/utils/logger/#errors--server-error
|
||||
unsupported-operation => /v5/api/utils/logger/#errors--unsupported-operation
|
||||
numeric-fault => /v5/api/utils/logger/#errors--numeric-fault
|
||||
call-exception => /v5/api/utils/logger/#errors--numeric-fault
|
||||
insufficient-funds => /v5/api/utils/logger/#errors--insufficient-funds
|
||||
nonce-expired => /v5/api/utils/logger/#errors--nonce-expired
|
||||
replacement-underpriced => /v5/api/utils/logger/#errors--replacement-underpriced
|
||||
unpredicatable-gas-limit => /v5/api/utils/logger/#errors--unpredicatable-gas-limit
|
||||
|
||||
BIN
docs/favicon.ico
Normal file
BIN
docs/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
@@ -26,8 +26,8 @@ Developer Documentation
|
||||
* [Signing Messages](getting-started)
|
||||
* [Ethereum Basics](concepts)
|
||||
* [Events](concepts/events)
|
||||
* [Solidity Topics](concepts/events)
|
||||
* [Logs and Filtering](concepts/events)
|
||||
* [Solidity Topics](concepts/events)
|
||||
* [Gas](concepts/gas)
|
||||
* [Gas Price](concepts/gas)
|
||||
* [Gas Limit](concepts/gas)
|
||||
@@ -47,6 +47,7 @@ Developer Documentation
|
||||
* [Accounts Methods](api/providers/provider)
|
||||
* [Blocks Methods](api/providers/provider)
|
||||
* [Ethereum Naming Service (ENS) Methods](api/providers/provider)
|
||||
* [EnsResolver](api/providers/provider)
|
||||
* [Logs Methods](api/providers/provider)
|
||||
* [Network Status Methods](api/providers/provider)
|
||||
* [Transactions Methods](api/providers/provider)
|
||||
@@ -253,8 +254,10 @@ Developer Documentation
|
||||
* [Schemas](testing)
|
||||
* [Contributing and Hacking](contributing)
|
||||
* [Building](contributing)
|
||||
* [Making your changes](contributing)
|
||||
* [Documentation](contributing)
|
||||
* [Other Resources](other-resources)
|
||||
* [Ethereum Overview](other-resources)
|
||||
* [Tutorials](other-resources)
|
||||
* [Flatworm Docs](documentation)
|
||||
* [Fragments](documentation)
|
||||
* [Markdown](documentation)
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -12,6 +12,7 @@ Application Programming Interface
|
||||
* [Accounts Methods](providers/provider)
|
||||
* [Blocks Methods](providers/provider)
|
||||
* [Ethereum Naming Service (ENS) Methods](providers/provider)
|
||||
* [EnsResolver](providers/provider)
|
||||
* [Logs Methods](providers/provider)
|
||||
* [Network Status Methods](providers/provider)
|
||||
* [Transactions Methods](providers/provider)
|
||||
|
||||
@@ -12,14 +12,17 @@ Creating Instances
|
||||
|
||||
#### **new ***ethers* . **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 ] ) => *[ContractFactory](/v5/api/contract/contract-factory/)*
|
||||
|
||||
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 ) => *[Contract](/v5/api/contract/contract/)*
|
||||
|
||||
Returns a **new instance** of the ContractFactory with the same *interface* and *bytecode*, but with a different *signer*.
|
||||
|
||||
|
||||
Properties
|
||||
@@ -27,14 +30,17 @@ Properties
|
||||
|
||||
#### *contractFactory* . **interface** => *[Interface](/v5/api/utils/abi/interface/)*
|
||||
|
||||
The [Contract](/v5/api/contract/contract/) interface.
|
||||
|
||||
|
||||
#### *contractFactory* . **bytecode** => *string< [DataHexString](/v5/api/utils/bytes/#DataHexString) >*
|
||||
|
||||
The bytecode (i.e. initcode) that this **ContractFactory** will use to deploy the Contract.
|
||||
|
||||
|
||||
#### *contractFactory* . **signer** => *[Signer](/v5/api/signer/#Signer)*
|
||||
|
||||
The [Signer](/v5/api/signer/#Signer) (if any) this ContractFactory will use to deploy instances of the Contract to the Blockchain.
|
||||
|
||||
|
||||
Methods
|
||||
@@ -45,49 +51,87 @@ Methods
|
||||
Return an instance of a [Contract](/v5/api/contract/contract/) attached to *address*. This is the same as using the [Contract constructor](/v5/api/contract/contract/#Contract--creating) with *address* and this the *interface* and *signerOrProvider* passed in when creating the ContractFactory.
|
||||
|
||||
|
||||
#### *contractFactory* . **getDeployTransaction**( ...args ) => *[UnsignedTransaction](/v5/api/utils/transactions/#UnsignedTransaction)*
|
||||
#### *contractFactory* . **getDeployTransaction**( ...args [ , overrides ] ) => *[UnsignedTransaction](/v5/api/utils/transactions/#UnsignedTransaction)*
|
||||
|
||||
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`, transaction `nonce`, `gasLimit` or `gasPrice`.
|
||||
|
||||
#### *contractFactory* . **deploy**( ...args ) => *Promise< [Contract](/v5/api/contract/contract/) >*
|
||||
|
||||
#### *contractFactory* . **deploy**( ...args [ , overrides ] ) => *Promise< [Contract](/v5/api/contract/contract/) >*
|
||||
|
||||
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`, transaction `nonce`, `gasLimit` or `gasPrice`.
|
||||
|
||||
```
|
||||
// <hide>
|
||||
const signer = ethers.LocalSigner();
|
||||
const ContractFactory = ethers.ContractFactory;
|
||||
// </hide>
|
||||
|
||||
```javascript
|
||||
// If your contract constructor requires parameters, the ABI
|
||||
// must include the constructor
|
||||
const abi = [
|
||||
"constructor(address owner, uint256 initialValue)"
|
||||
"constructor(address owner, uint256 initialValue)",
|
||||
"function value() view returns (uint)"
|
||||
];
|
||||
|
||||
const factory = new ContractFactory(abi, bytecode, signer)
|
||||
// The factory we use for deploying contracts
|
||||
factory = new ContractFactory(abi, bytecode, signer)
|
||||
|
||||
const contract = await factory.deploy("ricmoo.eth", 42);
|
||||
// Deploy an instance of the contract
|
||||
contract = await factory.deploy("ricmoo.eth", 42);
|
||||
|
||||
// The address is available immediately, but the contract
|
||||
// is NOT deployed yet
|
||||
contract.address
|
||||
//!
|
||||
// '0x26E9685C018Bf3A401DFA632827e7e6C7D96b1C0'
|
||||
|
||||
// The transaction that the signer sent to deploy
|
||||
contract.deployTransaction
|
||||
//!
|
||||
// {
|
||||
// blockHash: null,
|
||||
// blockNumber: null,
|
||||
// chainId: 1337,
|
||||
// confirmations: 0,
|
||||
// creates: '0x26E9685C018Bf3A401DFA632827e7e6C7D96b1C0',
|
||||
// data: '0x608060405234801561001057600080fd5b5060405161012e38038061012e8339818101604052604081101561003357600080fd5b81019080805190602001909291908051906020019092919050505081600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508060008190555050506088806100a66000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80633fa4f24514602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b6000805490509056fea2646970667358221220926465385af0e8706644e1ff3db7161af699dc063beaadd55405f2ccd6478d7564736f6c63430007040033000000000000000000000000ab7c8803962c0f2f5bbbe3fa8bf41cd82aa1923c000000000000000000000000000000000000000000000000000000000000002a',
|
||||
// from: '0xf3e6942b256A60B596B24F633caE8aDB4983fCA6',
|
||||
// gasLimit: { BigNumber: "126462" },
|
||||
// gasPrice: { BigNumber: "1" },
|
||||
// hash: '0x4037630fdadbbe0aac0bf90eba61118e35ee5fc28329e2134bb2bad0bfc12684',
|
||||
// nonce: 1,
|
||||
// r: '0xc3bb79ea4600864cd110fe74d31d38bb3702c327fd5aef9feddf66903cc87a4f',
|
||||
// s: '0x35cc2ffe352c02b5fcfbbcd2e348001af670f64438d7a9b2c34756ec293a0784',
|
||||
// to: null,
|
||||
// transactionIndex: null,
|
||||
// v: 2709,
|
||||
// value: { BigNumber: "0" },
|
||||
// wait: [Function]
|
||||
// }
|
||||
|
||||
// Wait until the transaction is mined
|
||||
// Wait until the transaction is mined (i.e. contract is deployed)
|
||||
// - returns the receipt
|
||||
// - throws on failure (the reciept is on the error)
|
||||
contract.deployTransaction.wait()
|
||||
//!
|
||||
// { Promise: {
|
||||
// blockHash: '0x1715de2bdfec15a7f64fb79a8254699274be6776df244d24a04945a3218543e6',
|
||||
// blockNumber: 2,
|
||||
// byzantium: true,
|
||||
// confirmations: 1,
|
||||
// contractAddress: '0x26E9685C018Bf3A401DFA632827e7e6C7D96b1C0',
|
||||
// cumulativeGasUsed: { BigNumber: "126462" },
|
||||
// from: '0xf3e6942b256A60B596B24F633caE8aDB4983fCA6',
|
||||
// gasUsed: { BigNumber: "126462" },
|
||||
// logs: [],
|
||||
// logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
||||
// status: 1,
|
||||
// to: null,
|
||||
// transactionHash: '0x4037630fdadbbe0aac0bf90eba61118e35ee5fc28329e2134bb2bad0bfc12684',
|
||||
// transactionIndex: 0
|
||||
// } }
|
||||
|
||||
// Now the contract is safe to interact with
|
||||
contract.value()
|
||||
//!
|
||||
// { Promise: { BigNumber: "42" } }
|
||||
```
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -117,7 +117,7 @@ Meta-Class
|
||||
|
||||
#### *contract* . **METHOD_NAME**( ...args [ , overrides ] ) => *Promise< any >*
|
||||
|
||||
The type of the result depends on the ABI.
|
||||
The type of the result depends on the ABI. If the method returns a single value, it will be returned directly, otherwise a [Result](/v5/api/utils/abi/interface/#Result) object will be returned with each parameter available positionally and if the parameter is named, it will also be available by its name.
|
||||
|
||||
For values that have a simple meaning in JavaScript, the types are fairly straight forward; strings and booleans are returned as JavaScript strings and booleans.
|
||||
|
||||
@@ -125,6 +125,16 @@ For numbers, if the **type** is in the JavaScript safe range (i.e. less than 53
|
||||
|
||||
For bytes (both fixed length and dynamic), a [DataHexString](/v5/api/utils/bytes/#DataHexString) is returned.
|
||||
|
||||
The *overrides* object for a read-only method may include any of:
|
||||
|
||||
- `overrides.from` - the `msg.sender` (or `CALLER`) to use during the execution of the code
|
||||
- `overrides.value` - the `msg.value` (or `CALLVALUE`) to use during the exectuiont of the code
|
||||
- `overrides.gasPrice` - the price to pay per gas (theoretically); since there is no transaction, there is not going to be any fee charged, but the EVM still requires a value to report to `tx.gasprice` (or `GASPRICE`); *most developers will not require this*
|
||||
- `overrides.gasLimit` - the amount of gas (theoretically) to allow a node to use during the execution of the code; since there is no transaction, there is not going to be any fee charged, but the EVM still processes gas metering so calls like `gasleft` (or `GAS`) report meaningful values
|
||||
- `overrides.blockTag` - a block tag to simulate the execution at, which can be used for hypothetical historic analysis; note that many backends do not support this, or may require paid plans to access as the node database storage and processing requirements are much higher
|
||||
|
||||
|
||||
|
||||
|
||||
#### *contract* . *functions* . **METHOD_NAME**( ...args [ , overrides ] ) => *Promise< [Result](/v5/api/utils/abi/interface/#Result) >*
|
||||
|
||||
@@ -136,6 +146,8 @@ Another use for this method is for error recovery. For example, if a function re
|
||||
|
||||
Most developers should not require this.
|
||||
|
||||
The *overrides* are identical to the read-only operations above.
|
||||
|
||||
|
||||
### Write Methods (non-constant)
|
||||
|
||||
@@ -143,6 +155,29 @@ Most developers should not require this.
|
||||
|
||||
Returns a [TransactionResponse](/v5/api/providers/types/#providers-TransactionResponse) for the transaction after it is sent to the network. This requires the **Contract** has a signer.
|
||||
|
||||
The *overrides* object for write methods may include any of:
|
||||
|
||||
- `overrides.gasPrice` - the price to pay per gas
|
||||
- `overrides.gasLimit` - the limit on the amount of gas to allow the transaction to consume; any unused gas is returned at the gasPrice
|
||||
- `overrides.value` - the amount of ether (in wei) to forward with the call
|
||||
- `overrides.nonce` - the nonce to use for the [Signer](/v5/api/signer/#Signer)
|
||||
|
||||
|
||||
|
||||
If the `wait()` method on the returned [TransactionResponse](/v5/api/providers/types/#providers-TransactionResponse) is called, there will be additional properties on the receipt:
|
||||
|
||||
- `receipt.events` - an array of the logs, with additional properties (if the ABI included a description for the events)
|
||||
- `receipt.events[n].args` - the parsed arguments
|
||||
- `receipt.events[n].decode` - a method that can be used to parse the log topics and data (this was used to compute `args`)
|
||||
- `receipt.events[n].event` - the name of the event
|
||||
- `receipt.events[n].eventSignature` - the full signature of the event
|
||||
- `receipt.removeListener()` - a method to remove the listener that trigger this event
|
||||
- `receipt.getBlock()` - a method to return the [Block](/v5/api/providers/types/#providers-Block) this event occurred in
|
||||
- `receipt.getTransaction()` - a method to return the [Transaction](/v5/api/providers/types/#providers-TransactionResponse) this event occurred in
|
||||
- `receipt.getTransactionReceipt()` - a method to return the [Transaction Receipt](/v5/api/providers/types/#providers-TransactionReceipt) this event occurred in
|
||||
|
||||
|
||||
|
||||
|
||||
### Write Methods Analysis
|
||||
|
||||
@@ -150,11 +185,15 @@ Returns a [TransactionResponse](/v5/api/providers/types/#providers-TransactionRe
|
||||
|
||||
Returns the estimate units of gas that would be required to execute the *METHOD_NAME* with *args* and *overrides*.
|
||||
|
||||
The *overrides* are identical to the overrides above for read-only or write methods, depending on the type of call of *METHOD_NAME*.
|
||||
|
||||
|
||||
#### *contract* . *populateTransaction* . **METHOD_NAME**( ...args [ , overrides ] ) => *Promise< [UnsignedTx](/v5/api/utils/transactions/#UnsignedTransaction) >*
|
||||
|
||||
Returns an [UnsignedTransaction](/v5/api/utils/transactions/#UnsignedTransaction) which represents the transaction that would need to be signed and submitted to the network to execute *METHOD_NAME* with *args* and *overrides*.
|
||||
|
||||
The *overrides* are identical to the overrides above for read-only or write methods, depending on the type of call of *METHOD_NAME*.
|
||||
|
||||
|
||||
#### *contract* . *callStatic* . **METHOD_NAME**( ...args [ , overrides ] ) => *Promise< any >*
|
||||
|
||||
@@ -164,6 +203,8 @@ This does not actually change any state, but is free. This in some cases can be
|
||||
|
||||
This otherwise functions the same as a [Read-Only Method](/v5/api/contract/contract/#Contract--readonly).
|
||||
|
||||
The *overrides* are identical to the read-only operations above.
|
||||
|
||||
|
||||
### Event Filters
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -48,7 +48,7 @@ Set the current transaction count (nonce) for the signer.
|
||||
This may be useful in interacting with the signer outside of using this class.
|
||||
|
||||
|
||||
#### *nonceManager* . **increaseTransactionCount**( [ count = 1 ] ) => *void*
|
||||
#### *nonceManager* . **incrementTransactionCount**( [ count = 1 ] ) => *void*
|
||||
|
||||
Bump the current transaction count (nonce) by *count*.
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -54,6 +54,7 @@ Provider Documentation
|
||||
* [Accounts Methods](provider)
|
||||
* [Blocks Methods](provider)
|
||||
* [Ethereum Naming Service (ENS) Methods](provider)
|
||||
* [EnsResolver](provider)
|
||||
* [Logs Methods](provider)
|
||||
* [Network Status Methods](provider)
|
||||
* [Transactions Methods](provider)
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -7,9 +7,11 @@ Documentation: [html](https://docs.ethers.io/)
|
||||
JsonRpcProvider
|
||||
===============
|
||||
|
||||
#### **new ***ethers* . *providers* . **JsonRpcProvider**( [ url [ , aNetworkish ] ] )
|
||||
#### **new ***ethers* . *providers* . **JsonRpcProvider**( [ urlOrConnectionInfo [ , networkish ] ] )
|
||||
|
||||
Connect to a JSON-RPC API located at *url* using the *aNetworkish* network. If *url* is not specified, the default (i.e. `http://localhost:8545`) is used and if no network is specified, it will be determined automatically by querying the node.
|
||||
Connect to a JSON-RPC HTTP API using the URL or [ConnectionInfo](/v5/api/utils/web/#ConnectionInfo) *urlOrConnectionInfo* connected to the *networkish* network.
|
||||
|
||||
If *urlOrConnectionInfo* is not specified, the default (i.e. `http://localhost:8545`) is used and if no network is specified, it will be determined automatically by querying the node using `eth_chaindId` and falling back on `eth_networkId`.
|
||||
|
||||
|
||||
#### Note: Connecting to a Local Node
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -36,7 +36,7 @@ The provider for this configuration.
|
||||
|
||||
#### *fallbackProviderConfig* . **priority** => *number*
|
||||
|
||||
The priority used for the provider. Higher priorities are favoured over lower priorities. If multiple providers share the same priority, they are chosen at random.
|
||||
The priority used for the provider. Lower-value priorities are favoured over higher-value priorities. If multiple providers share the same priority, they are chosen at random.
|
||||
|
||||
|
||||
#### *fallbackProviderConfig* . **stallTimeout** => *number*
|
||||
@@ -123,7 +123,7 @@ This is identical to `sendAsync`. Historically, this used a synchronous web requ
|
||||
WebSocketProvider
|
||||
-----------------
|
||||
|
||||
#### **new ***ethers* . *provider* . **WebSocketProvider**( [ url [ , network ] ] )
|
||||
#### **new ***ethers* . *providers* . **WebSocketProvider**( [ url [ , network ] ] )
|
||||
|
||||
Returns a new [WebSocketProvider](/v5/api/providers/other/#WebSocketProvider) connected to *url* as the *network*.
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -7,6 +7,15 @@ Documentation: [html](https://docs.ethers.io/)
|
||||
Provider
|
||||
========
|
||||
|
||||
#### Coming from Web3.js?
|
||||
|
||||
If you are coming from Web3.js, this is one of the biggest differences you will encounter using ethers.
|
||||
|
||||
The ethers library creates a strong division between the operation a **Provider** can perform and those of a [Signer](/v5/api/signer/#Signer), which Web3.js lumps together.
|
||||
|
||||
This separation of concerns and a stricted subset of Provider operations allows for a larger variety of backends, a more consistent API and ensures other libraries to operate without being able to rely on any underlying assumption.
|
||||
|
||||
|
||||
Accounts Methods
|
||||
----------------
|
||||
|
||||
@@ -33,7 +42,7 @@ Returns the number of transactions *address* has ever **sent**, as of *blockTag*
|
||||
```javascript
|
||||
// Get the balance for an account...
|
||||
provider.getBalance("ricmoo.firefly.eth");
|
||||
// { Promise: { BigNumber: "284831012276355695" } }
|
||||
// { Promise: { BigNumber: "25334210474552466902" } }
|
||||
|
||||
// Get the code for a contract...
|
||||
provider.getCode("registrar.firefly.eth");
|
||||
@@ -45,7 +54,7 @@ provider.getStorageAt("registrar.firefly.eth", 0)
|
||||
|
||||
// Get transaction count of an account...
|
||||
provider.getTransactionCount("ricmoo.firefly.eth");
|
||||
// { Promise: 689 }
|
||||
// { Promise: 712 }
|
||||
```
|
||||
|
||||
Blocks Methods
|
||||
@@ -96,7 +105,7 @@ provider.getBlockWithTransactions(100004)
|
||||
// blockHash: '0xf93283571ae16dcecbe1816adc126954a739350cd1523a1559eabeae155fbb63',
|
||||
// blockNumber: 100004,
|
||||
// chainId: 0,
|
||||
// confirmations: 11212224,
|
||||
// confirmations: 11717911,
|
||||
// creates: null,
|
||||
// data: '0x',
|
||||
// from: '0xcf00A85f3826941e7A25BFcF9Aac575d40410852',
|
||||
@@ -118,6 +127,11 @@ provider.getBlockWithTransactions(100004)
|
||||
Ethereum Naming Service (ENS) Methods
|
||||
-------------------------------------
|
||||
|
||||
#### *provider* . **getResolver**( name ) => *Promise< [EnsResolver](/v5/api/providers/provider/#EnsResolver) >*
|
||||
|
||||
Returns an EnsResolver instance which can be used to further inquire about specific entries for an ENS name.
|
||||
|
||||
|
||||
#### *provider* . **lookupAddress**( address ) => *Promise< string >*
|
||||
|
||||
Performs a reverse lookup of the *address* in ENS using the *Reverse Registrar*. If the name does not exist, or the forward lookup does not match, `null` is returned.
|
||||
@@ -138,6 +152,34 @@ provider.resolveName("ricmoo.firefly.eth");
|
||||
// { Promise: '0x8ba1f109551bD432803012645Ac136ddd64DBA72' }
|
||||
```
|
||||
|
||||
EnsResolver
|
||||
-----------
|
||||
|
||||
#### *resolver* . **name** => *string*
|
||||
|
||||
The name of this resolver.
|
||||
|
||||
|
||||
#### *resolver* . **address** => *string< [Address](/v5/api/utils/address/#address) >*
|
||||
|
||||
The address of the Resolver.
|
||||
|
||||
|
||||
#### *resolver* . **getAddress**( [ cointType = 60 ] ) => *Promise< string >*
|
||||
|
||||
Returns a Promise which resolves to the [EIP-2304](https://eips.ethereum.org/EIPS/eip-2304) multicoin address stored for the *coinType*. By default an Ethereum [Address](/v5/api/utils/address/#address) (`coinType = 60`) will be returned.
|
||||
|
||||
|
||||
#### *resolver* . **getContentHash**( ) => *Promise< string >*
|
||||
|
||||
Returns a Promise which resolves to any stored [EIP-1577](https://eips.ethereum.org/EIPS/eip-1577) content hash.
|
||||
|
||||
|
||||
#### *resolver* . **getText**( key ) => *Promise< string >*
|
||||
|
||||
Returns a Promise which resolves to any stored [EIP-634](https://eips.ethereum.org/EIPS/eip-634) text entry for *key*.
|
||||
|
||||
|
||||
Logs Methods
|
||||
------------
|
||||
|
||||
@@ -166,6 +208,13 @@ Returns the block number (or height) of the most recently mined block.
|
||||
Returns a *best guess* of the [Gas Price](/v5/concepts/gas/#gas-price) to use in a transaction.
|
||||
|
||||
|
||||
#### *provider* . **ready** => *Promise< [Network](/v5/api/providers/types/#providers-Network) >*
|
||||
|
||||
Returns a Promise which will stall until the network has heen established, ignoring errors due to the target node not being active yet.
|
||||
|
||||
This can be used for testing or attaching scripts to wait until the node is up and running smoothly.
|
||||
|
||||
|
||||
```javascript
|
||||
// The network information
|
||||
provider.getNetwork()
|
||||
@@ -177,16 +226,16 @@ provider.getNetwork()
|
||||
|
||||
// The current block number
|
||||
provider.getBlockNumber()
|
||||
// { Promise: 11312227 }
|
||||
// { Promise: 11817914 }
|
||||
|
||||
// Get the current suggested gas price (in wei)...
|
||||
gasPrice = await provider.getGasPrice()
|
||||
// { BigNumber: "46200000000" }
|
||||
// { BigNumber: "207000000000" }
|
||||
|
||||
// ...often this gas price is easier to understand or
|
||||
// display to the user in gwei (giga-wei, or 1e9 wei)
|
||||
utils.formatUnits(gasPrice, "gwei")
|
||||
// '46.2'
|
||||
// '207.0'
|
||||
```
|
||||
|
||||
Transactions Methods
|
||||
@@ -204,6 +253,20 @@ Returns an estimate of the amount of gas that would be required to submit *trans
|
||||
An estimate may not be accurate since there could be another transaction on the network that was not accounted for, but after being mined affected relevant state.
|
||||
|
||||
|
||||
#### *provider* . **getTransaction**( hash ) => *Promise< [TransactionResponse](/v5/api/providers/types/#providers-TransactionResponse) >*
|
||||
|
||||
Returns the transaction with *hash* or null if the transaction is unknown.
|
||||
|
||||
If a transaction has not been mined, this method will search the transaction pool. Various backends may have more restrictive transaction pool access (e.g. if the gas price is too low or the transaction was only recently sent and not yet indexed) in which case this method may also return null.
|
||||
|
||||
|
||||
#### *provider* . **getTransactionReceipt**( hash ) => *Promise< [TransactionReceipt](/v5/api/providers/types/#providers-TransactionReceipt) >*
|
||||
|
||||
Returns the transaction receipt for *hash* or null if the transaction has not been mined.
|
||||
|
||||
To stall until the transaction has been mined, consider the `waitForTransaction` method below.
|
||||
|
||||
|
||||
#### *provider* . **sendTransaction**( transaction ) => *Promise< [TransactionResponse](/v5/api/providers/types/#providers-TransactionResponse) >*
|
||||
|
||||
Submits *transaction* to the network to be mined. The *transaction* **must** be signed, and be valid (i.e. the nonce is correct and the account has sufficient balance to pay for the transaction).
|
||||
@@ -213,43 +276,45 @@ Submits *transaction* to the network to be mined. The *transaction* **must** be
|
||||
|
||||
Returns a Promise which will not resolve until *transactionHash* is mined.
|
||||
|
||||
If *confirms* is 0, this method is non-blocking and if the transaction has not been mined returns null. Otherwise, this method will block until the transaction has *confirms* blocks mined on top of the block in which is was mined.
|
||||
|
||||
|
||||
Event Emitter Methods
|
||||
---------------------
|
||||
|
||||
#### *provider* . **on**( eventName , listener ) => *this*
|
||||
|
||||
Add a *listener* to be triggered for each *eventName*.
|
||||
Add a *listener* to be triggered for each *eventName* [event](/v5/api/providers/provider/#Provider--events).
|
||||
|
||||
|
||||
#### *provider* . **once**( eventName , listener ) => *this*
|
||||
|
||||
Add a *listener* to be triggered for only the next *eventName*, at which time it will be removed.
|
||||
Add a *listener* to be triggered for only the next *eventName* [event](/v5/api/providers/provider/#Provider--events), at which time it will be removed.
|
||||
|
||||
|
||||
#### *provider* . **emit**( eventName , ...args ) => *boolean*
|
||||
|
||||
Notify all listeners of *eventName*, passing *args* to each listener. This is generally only used internally.
|
||||
Notify all listeners of the *eventName* [event](/v5/api/providers/provider/#Provider--events), passing *args* to each listener. This is generally only used internally.
|
||||
|
||||
|
||||
#### *provider* . **off**( eventName [ , listener ] ) => *this*
|
||||
|
||||
Remove a *listener* for *eventName*. If no *listener* is provided, all listeners for *eventName* are removed.
|
||||
Remove a *listener* for the *eventName* [event](/v5/api/providers/provider/#Provider--events). If no *listener* is provided, all listeners for *eventName* are removed.
|
||||
|
||||
|
||||
#### *provider* . **removeAllListeners**( [ eventName ] ) => *this*
|
||||
|
||||
Remove all the listeners for *eventName*. If no *eventName* is provided, **all** events are removed.
|
||||
Remove all the listeners for the *eventName* [events](/v5/api/providers/provider/#Provider--events). If no *eventName* is provided, **all** events are removed.
|
||||
|
||||
|
||||
#### *provider* . **listenerCount**( [ eventName ] ) => *number*
|
||||
|
||||
Returns the number of listeners for *eventName*. If no *eventName* is provided, the total number of listeners is returned.
|
||||
Returns the number of listeners for the *eventName* [events](/v5/api/providers/provider/#Provider--events). If no *eventName* is provided, the total number of listeners is returned.
|
||||
|
||||
|
||||
#### *provider* . **listeners**( eventName ) => *Array< Listener >*
|
||||
|
||||
Returns the list of Listeners for *eventName*.
|
||||
Returns the list of Listeners for the *eventName* [events](/v5/api/providers/provider/#Provider--events).
|
||||
|
||||
|
||||
### Events
|
||||
@@ -260,7 +325,7 @@ A filter is an object, representing a contract log Filter, which has the optiona
|
||||
|
||||
If `address` is unspecified, the filter matches any contract address.
|
||||
|
||||
See events for more information on how to specify topic-sets.
|
||||
See [EventFilters](/v5/api/providers/types/#providers-EventFilter) for more information on filtering events.
|
||||
|
||||
|
||||
#### **Topic-Set Filter**
|
||||
@@ -269,6 +334,8 @@ The value of a **Topic-Set Filter** is a array of Topic-Sets.
|
||||
|
||||
This event is identical to a *Log Filter* with the address omitted (i.e. from any contract).
|
||||
|
||||
See [EventFilters](/v5/api/providers/types/#providers-EventFilter) for more information on filtering events.
|
||||
|
||||
|
||||
#### **Transaction Filter**
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -10,8 +10,6 @@ Types
|
||||
BlockTag
|
||||
--------
|
||||
|
||||
### EventType
|
||||
|
||||
Networkish
|
||||
----------
|
||||
|
||||
@@ -118,9 +116,13 @@ Events and Logs
|
||||
The address to filter by, or `null` to match any address.
|
||||
|
||||
|
||||
#### *filter* . **topics** => *Array< string< [DataHexString](/v5/api/utils/bytes/#DataHexString)< 32 > > | Array< string< [DataHexString](/v5/api/utils/bytes/#DataHexString)< 32 > > > >*
|
||||
#### *filter* . **topics** => *Array< string< [Data](/v5/api/utils/bytes/#DataHexString)< 32 > > | Array< string< [Data](/v5/api/utils/bytes/#DataHexString)< 32 > > > >*
|
||||
|
||||
The topics to filter by, or `null` to match any topics. Each entry represents an **AND** condition that must match, or may be `null` to match anything. If a given entry is an Array, then that entry is treated as an **OR** for any value in the entry.
|
||||
The topics to filter by or `null` to match any topics.
|
||||
|
||||
Each entry represents an **AND** condition that must match, or may be `null` to match anything. If a given entry is an Array, then that entry is treated as an **OR** for any value in the entry.
|
||||
|
||||
See [Filters](/v5/concepts/events/#events--filters) for more details and examples on specifying complex filters.
|
||||
|
||||
|
||||
### Filter
|
||||
@@ -268,9 +270,17 @@ The number of blocks that have been mined (including the initial block) since th
|
||||
The serialized transaction.
|
||||
|
||||
|
||||
#### *transaction* . **wait**( [ confirmations = 1 ] ) => *Promise< [TransactionReceipt](/v5/api/providers/types/#providers-TransactionReceipt) >*
|
||||
#### *transaction* . **wait**( [ confirms = 1 ] ) => *Promise< [TransactionReceipt](/v5/api/providers/types/#providers-TransactionReceipt) >*
|
||||
|
||||
Resolves to the [TransactionReceipt](/v5/api/providers/types/#providers-TransactionReceipt) once the transaction has been included in the chain for *confirms* blocks. If *confirms* is 0, and the transaction has not been mined, `null` is returned.
|
||||
|
||||
If the transaction execution failed (i.e. the receipt status is `0`), a [CALL_EXCEPTION](/v5/api/utils/logger/#errors--call-exception) Error will be rejected with the following properties:
|
||||
|
||||
- `error.transaction` - the original transaction
|
||||
- `error.transactionHash` - the hash of the transaction
|
||||
- `error.receipt` - the actual receipt, with the status of `0`
|
||||
|
||||
|
||||
Wait for *confirmations*. If 0, and the transaction has not been mined, `null` is returned.
|
||||
|
||||
|
||||
### TransactionReceipt
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -273,7 +273,7 @@ walletMnemonic.publicKey
|
||||
walletMnemonic.mnemonic
|
||||
// {
|
||||
// locale: 'en',
|
||||
// path: 'm/44\'/60\'/0\'/0/0',
|
||||
// path: "m/44'/60'/0'/0/0",
|
||||
// phrase: 'announce room limb pattern dry unit scale effort smooth jazz weasel alcohol'
|
||||
// }
|
||||
|
||||
@@ -335,7 +335,7 @@ contract = new ethers.Contract("dai.tokens.ethers.eth", abi, signer)
|
||||
|
||||
// Get the number of tokens for this account
|
||||
tokens = await contract.balanceOf(signer.getAddress())
|
||||
// { BigNumber: "15923148775162018481031" }
|
||||
// { BigNumber: "198172622063578627973" }
|
||||
|
||||
//
|
||||
// Pre-flight (check for revert) on DAI from the signer
|
||||
@@ -352,7 +352,7 @@ contract.callStatic.transfer("donations.ethers.eth", tokens)
|
||||
|
||||
// This will fail since it is greater than the token balance
|
||||
contract.callStatic.transfer("donations.ethers.eth", tokens.add(1))
|
||||
// Error: call revert exception (method="transfer(address,uint256)", errorSignature="Error(string)", errorArgs=["Dai/insufficient-balance"], reason="Dai/insufficient-balance", code=CALL_EXCEPTION, version=abi/5.0.9)
|
||||
// Error: call revert exception (method="transfer(address,uint256)", errorSignature="Error(string)", errorArgs=["Dai/insufficient-balance"], reason="Dai/insufficient-balance", code=CALL_EXCEPTION, version=abi/5.0.12)
|
||||
```
|
||||
|
||||
ExternallyOwnedAccount
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -21,14 +21,14 @@ Converting and Verifying
|
||||
|
||||
Returns *address* as a Checksum Address.
|
||||
|
||||
If *address* is an invalid 40-nibble [HexString](/v5/api/utils/bytes/#HexString) or if it contains mixed case and the checksum is invalid, an InvalidArgument Error is thrown.
|
||||
If *address* is an invalid 40-nibble [HexString](/v5/api/utils/bytes/#HexString) or if it contains mixed case and the checksum is invalid, an [INVALID_ARGUMENT](/v5/api/utils/logger/#errors--invalid-argument) Error is thrown.
|
||||
|
||||
The value of *address* may be any supported address format.
|
||||
|
||||
|
||||
#### *ethers* . *utils* . **getIcapAddress**( address ) => *string< [IcapAddress](/v5/api/utils/address/#address-icap) >*
|
||||
|
||||
Returns *address* as an [ICAP address](https://github.com/ethereum/wiki/wiki/Inter-exchange-Client-Address-Protocol-%28ICAP%29). Supports the same restrictions as [utils.getAddress](/v5/api/utils/address/#utils-getAddress).
|
||||
Returns *address* as an [ICAP address](https://github.com/ethereum/wiki/wiki/Inter-exchange-Client-Address-Protocol-%28ICAP%29). Supports the same restrictions as [getAddress](/v5/api/utils/address/#utils-getAddress).
|
||||
|
||||
|
||||
#### *ethers* . *utils* . **isAddress**( address ) => *boolean*
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -85,7 +85,7 @@ BigNumber.from(42n)
|
||||
|
||||
// Numbers outside the safe range fail:
|
||||
BigNumber.from(Number.MAX_SAFE_INTEGER);
|
||||
// Error: overflow (fault="overflow", operation="BigNumber.from", value=9007199254740991, code=NUMERIC_FAULT, version=bignumber/5.0.11)
|
||||
// Error: overflow (fault="overflow", operation="BigNumber.from", value=9007199254740991, code=NUMERIC_FAULT, version=bignumber/5.0.14)
|
||||
```
|
||||
|
||||
Methods
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -164,20 +164,20 @@ Return a copy of *array* shuffled using [Fisher-Yates Shuffle](https://en.wikipe
|
||||
|
||||
```javascript
|
||||
utils.randomBytes(8)
|
||||
// Uint8Array [ 82, 221, 254, 37, 192, 138, 147, 109 ]
|
||||
// Uint8Array [ 97, 223, 223, 186, 224, 0, 90, 28 ]
|
||||
|
||||
const data = [ 1, 2, 3, 4, 5, 6, 7 ];
|
||||
|
||||
// Returns a new Array
|
||||
utils.shuffled(data);
|
||||
// [
|
||||
// 6,
|
||||
// 5,
|
||||
// 3,
|
||||
// 2,
|
||||
// 7,
|
||||
// 1,
|
||||
// 4,
|
||||
// 1
|
||||
// 6,
|
||||
// 7,
|
||||
// 2
|
||||
// ]
|
||||
|
||||
// The Original is unscathed...
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -52,7 +52,7 @@ utils.keccak256("0x1234")
|
||||
|
||||
// Do NOT use UTF-8 strings that are not a DataHexstring
|
||||
utils.keccak256("hello world")
|
||||
// Error: invalid arrayify value (argument="value", value="hello world", code=INVALID_ARGUMENT, version=bytes/5.0.6)
|
||||
// Error: invalid arrayify value (argument="value", value="hello world", code=INVALID_ARGUMENT, version=bytes/5.0.10)
|
||||
|
||||
// If needed, convert strings to bytes first:
|
||||
utils.keccak256(utils.toUtf8Bytes("hello world"))
|
||||
@@ -300,6 +300,24 @@ TypedDataEncoder.getPayload(domain, types, value)
|
||||
// },
|
||||
// primaryType: 'Mail',
|
||||
// types: {
|
||||
// EIP712Domain: [
|
||||
// {
|
||||
// name: 'name',
|
||||
// type: 'string'
|
||||
// },
|
||||
// {
|
||||
// name: 'version',
|
||||
// type: 'string'
|
||||
// },
|
||||
// {
|
||||
// name: 'chainId',
|
||||
// type: 'uint256'
|
||||
// },
|
||||
// {
|
||||
// name: 'verifyingContract',
|
||||
// type: 'address'
|
||||
// }
|
||||
// ],
|
||||
// Mail: [
|
||||
// {
|
||||
// name: 'from',
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -51,34 +51,36 @@ Throw an Error with *message* and an optional *code* and additional *params* set
|
||||
|
||||
#### *logger* . **throwArgumentError**( message , name , value ) => *never*
|
||||
|
||||
Throw an [INVALID_ARGUMENT](/v5/api/utils/logger/#errors-InvalidArgument) Error with *name* and *value*.
|
||||
Throw an [INVALID_ARGUMENT](/v5/api/utils/logger/#errors--invalid-argument) Error with *name* and *value*.
|
||||
|
||||
|
||||
### Usage Validation
|
||||
|
||||
#### *logger* . **checkAbstract**( target , kind ) => *void*
|
||||
|
||||
Checks that *target* is not *kind* and performs the same operations as `checkNew`. This is useful for ensuring abstract classes are not being instantiated.
|
||||
If *target* is *kind*, throws a [UNSUPPORTED_OPERATION](/v5/api/utils/logger/#errors--unsupported-operation) error otherwise performs the same operations as [checkNew](/v5/api/utils/logger/#Logger-checkNew).
|
||||
|
||||
This is useful for ensuring abstract classes are not being instantiated.
|
||||
|
||||
|
||||
#### *logger* . **checkArgumentCount**( count , expectedCount [ , message ) => *void*
|
||||
|
||||
If *count* is not equal to *expectedCount*, throws a [MISSING_ARGUMENT](/v5/api/utils/logger/#errors-MissingArgument) or [UNEXPECTED_ARGUMENT](/v5/api/utils/logger/#errors-UnexpectedArgument) error.
|
||||
If *count* is not equal to *expectedCount*, throws a [MISSING_ARGUMENT](/v5/api/utils/logger/#errors--missing-argument) or [UNEXPECTED_ARGUMENT](/v5/api/utils/logger/#errors--unexpected-argument) error.
|
||||
|
||||
|
||||
#### *logger* . **checkNew**( target , kind ) => *void*
|
||||
|
||||
If *target* is not a valid `this` or `target` value, throw a [MISSING_NEW](/v5/api/utils/logger/#errors-MissingNew) error. This is useful to ensure callers of a Class are using `new`.
|
||||
If *target* is not a valid `this` or `target` value, throw a [MISSING_NEW](/v5/api/utils/logger/#errors--missing-new) error. This is useful to ensure callers of a Class are using `new`.
|
||||
|
||||
|
||||
#### *logger* . **checkNormalize**( message ) => *void*
|
||||
|
||||
Check that the environment has a correctly functioning [String.normalize](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize). If not, a [UNSUPPORTED_OPERATION](/v5/api/utils/logger/#errors-UnsupportedOperation) error is thrown.
|
||||
Check that the environment has a correctly functioning [String.normalize](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize). If not, a [UNSUPPORTED_OPERATION](/v5/api/utils/logger/#errors--unsupported-operation) error is thrown.
|
||||
|
||||
|
||||
#### *logger* . **checkSafeUint53**( value [ , message ] ) => *void*
|
||||
|
||||
If *value* is not safe as a [JavaScript number](https://en.wikipedia.org/wiki/Double-precision_floating-point_format), throws a [NUMERIC_FAULT](/v5/api/utils/logger/#errors-NumericFault) error.
|
||||
If *value* is not safe as a [JavaScript number](https://en.wikipedia.org/wiki/Double-precision_floating-point_format), throws a [NUMERIC_FAULT](/v5/api/utils/logger/#errors--numeric-fault) error.
|
||||
|
||||
|
||||
### Censorship
|
||||
@@ -104,13 +106,23 @@ Errors
|
||||
|
||||
#### *Logger* . *errors* . **NOT_IMPLEMENTED**
|
||||
|
||||
The operation is not implemented.
|
||||
The operation is not implemented. This may occur when calling a method on a sub-class that has not fully implemented its abstract superclass.
|
||||
|
||||
|
||||
#### *Logger* . *errors* . **SERVER_ERROR**
|
||||
|
||||
There was an error communicating with a server.
|
||||
|
||||
This may occur for a number of reasons, for example:
|
||||
|
||||
- a [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) issue; this is quite often the problem and also the hardest to diagnose and fix, so it is very beneficial to familiarize yourself with CORS; some backends allow you configure your CORS, such as the geth command-line or conifguration files or the INFURA and Alchemy dashboards by specifing allowed Origins, methods, etc.
|
||||
- an SSL issue; for example, if you are trying to connect to a local node via HTTP but are serving the content from a secure HTTPS website
|
||||
- a link issue; a firewall is preventing the traffic from reaching the server
|
||||
- a server issue; the server is down, or is returning 500 error codes
|
||||
- a backend DDoS mitigation proxy; for example, Etherscan operates behind a Cloudflare proxy, which will block traffic if the request is sent via specific User Agents or the client fingerprint is detected as a bot in some cases
|
||||
|
||||
|
||||
|
||||
|
||||
#### *Logger* . *errors* . **TIMEOUT**
|
||||
|
||||
@@ -126,6 +138,14 @@ A generic unknown error.
|
||||
|
||||
The operation is not supported.
|
||||
|
||||
This can happen for a variety reasons, for example:
|
||||
|
||||
- Some backends do not support certain operations; such as passing a blockTag to an [EtherscanProvider](/v5/api/providers/api-providers/#EtherscanProvider) for [call](/v5/api/providers/provider/#Provider-call)
|
||||
- A [Contract](/v5/api/contract/contract/) object connected to [Provider](/v5/api/providers/provider/) (instead of a [Signer](/v5/api/signer/#Signer)) cannot [sign](/v5/api/signer/#Signer-signTransaction) or [send](/v5/api/signer/#Signer-sendTransaction) transactions
|
||||
- a [Contract](/v5/api/contract/contract/) connected to a [Signer](/v5/api/signer/#Signer) without a [Provider](/v5/api/providers/provider/) is write-only and cannot estimate gas or execute static calls
|
||||
|
||||
|
||||
|
||||
|
||||
### Safety Error Codes
|
||||
|
||||
@@ -133,6 +153,8 @@ The operation is not supported.
|
||||
|
||||
The amount of data needed is more than the amount of data required, which would cause the data buffer to read past its end.
|
||||
|
||||
This can occur if a contract erroneously returns invalid ABI-encoded data or RLP data is malformed.
|
||||
|
||||
|
||||
#### *Logger* . *errors* . **NUMERIC_FAULT**
|
||||
|
||||
@@ -145,7 +167,7 @@ Common cases of this occur when there is [overflow](https://en.wikipedia.org/wik
|
||||
|
||||
#### *Logger* . *errors* . **INVALID_ARGUMENT**
|
||||
|
||||
The type or value of an argument is invalid. This will generally also include the `name` and `value` of the argument. Any function which accepts sensitive data (such as a private key) will include the string `[[REDACTED]]` instead of the value passed in.
|
||||
The type or value of an argument is invalid. This will generally also include the `name` and `value` of the argument. Any function which accepts sensitive data (such as a private key) will include the string `"[[REDACTED]]"` instead of the value passed in.
|
||||
|
||||
|
||||
#### *Logger* . *errors* . **MISSING_ARGUMENT**
|
||||
@@ -155,7 +177,7 @@ An expected parameter was not specified.
|
||||
|
||||
#### *Logger* . *errors* . **MISSING_NEW**
|
||||
|
||||
An object is a Class, but is now being called with `new`.
|
||||
An object is a Class, but is not being called with `new`.
|
||||
|
||||
|
||||
#### *Logger* . *errors* . **UNEXPECTED_ARGUMENT**
|
||||
@@ -167,14 +189,16 @@ Too many parameters we passed into a function.
|
||||
|
||||
#### *Logger* . *errors* . **CALL_EXCEPTION**
|
||||
|
||||
An attempt to call a blockchain contract (getter) resulted in a revert or other error.
|
||||
An attempt to call a blockchain contract (getter) resulted in a revert or other error, such as insufficient gas (out-of-gas) or an invalid opcode. This can also occur during gas estimation or if waiting for a [TransactionReceipt](/v5/api/providers/types/#providers-TransactionReceipt) which failed during execution.
|
||||
|
||||
Consult the contract to determine the cause, such as a failed condition in a `require` statement. The `reason` property may provide more context for the cause of this error.
|
||||
|
||||
|
||||
#### *Logger* . *errors* . **INSUFFICIENT_FUNDS**
|
||||
|
||||
The account is attempting to make a transaction which costs more than is available.
|
||||
|
||||
A sending account must have enough ether to pay for the value, the gas limit (at the gas price) as well as the intrinsic cost of data. The intrinsic cost of data is 4 gas for each zero byte and 68 gas for each non-zero byte.
|
||||
A sending account must have enough ether to pay for the value, the gas limit (at the gas price) as well as the intrinsic cost of data. The intrinsic cost of data is 4 gas for each zero byte and 68 gas for each non-zero byte, as well as 35000 gas if a transaction contains no `to` property and is therefore expected to create a new account.
|
||||
|
||||
|
||||
#### *Logger* . *errors* . **NETWORK_ERROR**
|
||||
@@ -191,7 +215,7 @@ The nonce being specified has already been used in a mined transaction.
|
||||
|
||||
When replacing a transaction, by using a nonce which has already been sent to the network, but which has not been mined yet the new transaction must specify a higher gas price.
|
||||
|
||||
This error occurs when the gas price is insufficient to *bribe* the transaction pool to prefer the new transaction over the old one. Generally, the new gas price should be about 50% + 1 wei more, so if a gas price of 10 gwei was used, the replacement should be 15.000000001 gwei.
|
||||
This error occurs when the gas price is insufficient to *bribe* the transaction pool to prefer the new transaction over the old one. Generally, the new gas price should be about 50% + 1 wei more, so if a gas price of 10 gwei was used, the replacement should be 15.000000001 gwei. This is not enforced by the protocol, as it deals with unmined transactions, and can be configured by each node, however to ensure a transaction is propagated to a miner it is best practice to follow the defaults most nodes have enabled.
|
||||
|
||||
|
||||
#### *Logger* . *errors* . **UNPREDICTABLE_GAS_LIMIT**
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -7,27 +7,35 @@ Documentation: [html](https://docs.ethers.io/)
|
||||
Property Utilities
|
||||
==================
|
||||
|
||||
#### *ethers* . *utils* . **checkProperties**( ) => *void*
|
||||
#### *ethers* . *utils* . **checkProperties**( object , check ) => *void*
|
||||
|
||||
Checks that *object* only contains properties included in *check*, and throws [INVALID_ARGUMENT](/v5/api/utils/logger/#errors--invalid-argument) if not.
|
||||
|
||||
|
||||
#### *ethers* . *utils* . **deepCopy**( anObject ) => *any*
|
||||
|
||||
Creates a recursive copy of *anObject*. Frozen (i.e. and other known immutable) objects are copied by reference.
|
||||
|
||||
|
||||
#### *ethers* . *utils* . **defineReadOnly**( anObject , name , value ) => *void*
|
||||
|
||||
Uses the `Object.defineProperty` method to set a read-only property on an object.
|
||||
|
||||
|
||||
#### *ethers* . *utils* . **getStatic**( aConstructor , key ) => *any*
|
||||
|
||||
Recursively check for a static method *key* on an inheritance chain from *aConstructor* to all ancestors.
|
||||
|
||||
This is used to mimic behaviour in other languages where `this` in a static method will also search ancestors.
|
||||
|
||||
|
||||
#### *ethers* . *utils* . **resolveProperties**( anObject ) => *Promise< any >*
|
||||
|
||||
Retruns a Promise which resolves all child values on *anObject*.
|
||||
|
||||
|
||||
#### *ethers* . *utils* . **shallowCopy**( anObject ) => *any*
|
||||
|
||||
Returns a shallow copy of *anObject*. This is the same as using `Object.assign({ }, anObject)`.
|
||||
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -8,8 +8,8 @@ Ethereum Basics
|
||||
===============
|
||||
|
||||
* [Events](events)
|
||||
* [Solidity Topics](events)
|
||||
* [Logs and Filtering](events)
|
||||
* [Solidity Topics](events)
|
||||
* [Gas](gas)
|
||||
* [Gas Price](gas)
|
||||
* [Gas Limit](gas)
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -7,9 +7,6 @@ Documentation: [html](https://docs.ethers.io/)
|
||||
Events
|
||||
======
|
||||
|
||||
Solidity Topics
|
||||
---------------
|
||||
|
||||
Logs and Filtering
|
||||
------------------
|
||||
|
||||
@@ -135,5 +132,8 @@ contract.filters.Transfer(null, [ myAddress, otherAddress ])
|
||||
// }
|
||||
```
|
||||
|
||||
Solidity Topics
|
||||
---------------
|
||||
|
||||
### Other Things? TODO
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user