From acd601e7e7939b3a45b7839d6dc0d42041c5bd67 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Sun, 2 Feb 2020 00:53:22 -0500 Subject: [PATCH] Updated docs output. --- docs/README.md | 53 +- docs/api/README.md | 34 +- docs/api/contract/index.html | 4 +- docs/api/index.html | 4 +- docs/api/other/README.md | 23 + docs/api/other/hardware/README.md | 38 ++ docs/api/other/hardware/index.html | 8 + docs/api/other/index.html | 4 + docs/api/providers/README.md | 11 +- docs/api/providers/api-providers/README.md | 54 +- docs/api/providers/api-providers/index.html | 24 +- docs/api/providers/index.html | 4 +- docs/api/providers/jsonrpc-provider/README.md | 108 +++- .../api/providers/jsonrpc-provider/index.html | 28 +- docs/api/providers/other/README.md | 149 ++++- docs/api/providers/other/index.html | 33 +- docs/api/providers/provider/README.md | 36 +- docs/api/providers/provider/index.html | 54 +- docs/api/providers/types/README.md | 518 ++++++++++++++++-- docs/api/providers/types/index.html | 105 +++- docs/api/signer/README.md | 319 ++++++++++- docs/api/signer/index.html | 59 +- docs/api/utils/README.md | 18 +- docs/api/utils/abi/README.md | 399 ++++++++++++++ docs/api/utils/abi/index.html | 74 +++ docs/api/utils/address/README.md | 62 ++- docs/api/utils/address/index.html | 19 +- docs/api/utils/bignumber/README.md | 52 +- docs/api/utils/bignumber/index.html | 50 +- docs/api/utils/bytes/README.md | 56 +- docs/api/utils/bytes/index.html | 30 +- docs/api/utils/constants/README.md | 9 +- docs/api/utils/constants/index.html | 10 +- docs/api/utils/display-logic/index.html | 4 +- docs/api/utils/encoding/README.md | 45 ++ docs/api/utils/encoding/index.html | 7 + docs/api/utils/fixednumber/README.md | 88 ++- docs/api/utils/fixednumber/index.html | 45 +- docs/api/utils/hashing/README.md | 30 +- docs/api/utils/hashing/index.html | 30 +- docs/api/utils/index.html | 4 +- docs/api/utils/properties/README.md | 22 + docs/api/utils/properties/index.html | 4 + docs/api/utils/signing-key/README.md | 27 + docs/api/utils/signing-key/index.html | 4 + docs/api/utils/strings/README.md | 181 +++++- docs/api/utils/strings/index.html | 44 +- docs/api/utils/transactions/README.md | 205 +++++++ docs/api/utils/transactions/index.html | 34 ++ docs/cli/README.md | 33 ++ docs/cli/asm/README.md | 47 ++ docs/cli/asm/index.html | 9 + docs/cli/ens/README.md | 101 ++++ docs/cli/ens/index.html | 9 + docs/cli/ethers/README.md | 283 ++++++++++ docs/cli/ethers/index.html | 34 ++ docs/cli/index.html | 4 + docs/cli/plugin/README.md | 277 ++++++++++ docs/cli/plugin/index.html | 38 ++ docs/cli/typescript/README.md | 49 ++ docs/cli/typescript/index.html | 9 + docs/concepts/README.md | 5 +- docs/concepts/events/index.html | 4 +- docs/concepts/gas/index.html | 4 +- docs/concepts/index.html | 6 +- docs/contributing/index.html | 4 +- docs/cookbook/index.html | 4 +- docs/documentation/README.md | 87 ++- docs/documentation/index.html | 20 +- docs/getting-started/index.html | 4 +- docs/hacking/index.html | 4 +- docs/index.html | 6 +- docs/license/index.html | 4 +- docs/migration/index.html | 4 +- docs/static/style.css | 26 +- docs/testing/index.html | 4 +- 76 files changed, 3881 insertions(+), 421 deletions(-) create mode 100644 docs/api/other/README.md create mode 100644 docs/api/other/hardware/README.md create mode 100644 docs/api/other/hardware/index.html create mode 100644 docs/api/other/index.html create mode 100644 docs/api/utils/abi/README.md create mode 100644 docs/api/utils/abi/index.html create mode 100644 docs/api/utils/encoding/README.md create mode 100644 docs/api/utils/encoding/index.html create mode 100644 docs/api/utils/properties/README.md create mode 100644 docs/api/utils/properties/index.html create mode 100644 docs/api/utils/signing-key/README.md create mode 100644 docs/api/utils/signing-key/index.html create mode 100644 docs/api/utils/transactions/README.md create mode 100644 docs/api/utils/transactions/index.html create mode 100644 docs/cli/README.md create mode 100644 docs/cli/asm/README.md create mode 100644 docs/cli/asm/index.html create mode 100644 docs/cli/ens/README.md create mode 100644 docs/cli/ens/index.html create mode 100644 docs/cli/ethers/README.md create mode 100644 docs/cli/ethers/index.html create mode 100644 docs/cli/index.html create mode 100644 docs/cli/plugin/README.md create mode 100644 docs/cli/plugin/index.html create mode 100644 docs/cli/typescript/README.md create mode 100644 docs/cli/typescript/index.html diff --git a/docs/README.md b/docs/README.md index 89cbcca63..5a2042d58 100644 --- a/docs/README.md +++ b/docs/README.md @@ -54,7 +54,9 @@ Developer Documentation * [Buckets](api/contract) * [Signers](api/signer) * [Signer](api/signer) - * [Wallet inherits Signer](api/signer) + * [Wallet](api/signer) + * [VoidSigner](api/signer) + * [ExternallyOwnedAccount](api/signer) * [Providers](api/providers) * [Provider](api/providers/provider) * [Accounts Methods](api/providers/provider) @@ -65,25 +67,35 @@ Developer Documentation * [Transactions Methods](api/providers/provider) * [Event Emitter Methods](api/providers/provider) * [Inspection Methods](api/providers/provider) - * [JSON-RPC Provider](api/providers/jsonrpc-provider) - * [JsonRpcProvider](api/providers/jsonrpc-provider) + * [JsonRpcProvider](api/providers/jsonrpc-provider) * [JsonRpcSigner](api/providers/jsonrpc-provider) * [JsonRpcUncheckedSigner](api/providers/jsonrpc-provider) * [API Providers](api/providers/api-providers) * [EtherscanProvider](api/providers/api-providers) * [InfuraProvider](api/providers/api-providers) - * [NodesmithProvider](api/providers/api-providers) * [AlchemyProvider](api/providers/api-providers) * [CloudfrontProvider](api/providers/api-providers) * [Other Providers](api/providers/other) * [FallbackProvider](api/providers/other) * [IpcProvider](api/providers/other) + * [UrlJsonRpcProvider](api/providers/other) + * [Web3Provider](api/providers/other) * [Types](api/providers/types) - * [Blocks](api/providers/types) + * [Network](api/providers/types) + * [Block](api/providers/types) * [Events and Logs](api/providers/types) * [Transactions](api/providers/types) * [Utilities](api/utils) * [Addresses](api/utils/address) + * [Address Formats](api/utils/address) + * [Functions](api/utils/address) + * [Application Binary Interface](api/utils/abi) + * [Formats](api/utils/abi) + * [Fragment](api/utils/abi) + * [ConstructorFragment](api/utils/abi) + * [EventFragment](api/utils/abi) + * [FunctionFragment](api/utils/abi) + * [ParamType](api/utils/abi) * [BigNumber](api/utils/bignumber) * [Types](api/utils/bignumber) * [Creating Instances](api/utils/bignumber) @@ -104,7 +116,7 @@ Developer Documentation * [Units](api/utils/display-logic) * [Functions](api/utils/display-logic) * [FixedNumber](api/utils/fixednumber) - * [Types](api/utils/fixednumber) + * [FixedFormat](api/utils/fixednumber) * [Creating Instances](api/utils/fixednumber) * [Properties](api/utils/fixednumber) * [Methods](api/utils/fixednumber) @@ -115,6 +127,31 @@ Developer Documentation * [Strings](api/utils/strings) * [Bytes32String](api/utils/strings) * [UTF-8 Strings](api/utils/strings) + * [UnicodeNormalizationForm](api/utils/strings) + * [Custom UTF-8 Error Handling](api/utils/strings) + * [Transactions](api/utils/transactions) + * [Types](api/utils/transactions) + * [Functions](api/utils/transactions) + * [Other Libraries](api/other) + * [Hardware Wallets](api/other/hardware) + * [LedgerSigner](api/other/hardware) +* [Command Line Interfaces](cli) + * [Sandbox Utility](cli/ethers) + * [Help](cli/ethers) + * [Examples](cli/ethers) + * [Assembler](cli/asm) + * [Help](cli/asm) + * [Examples](cli/asm) + * [ENS](cli/ens) + * [Help](cli/ens) + * [Examples](cli/ens) + * [TypeScript](cli/typescript) + * [Help](cli/typescript) + * [Examples](cli/typescript) + * [Making Your Own](cli/plugin) + * [CLI](cli/plugin) + * [Plugin](cli/plugin) + * [ArgParser](cli/plugin) * [Cookbook](cookbook) * [Migration Guide](migration) * [From Web3](migration) @@ -125,6 +162,8 @@ Developer Documentation * [Flatworm Docs](documentation) * [Fragments](documentation) * [Markdown](documentation) + * [Configuration](documentation) + * [Extended Directive Functions](documentation) * [License and Copyright](license) @@ -143,4 +182,4 @@ older versions of the library. ----- -**Content Hash:** f1da4df3feeb06a567657ae41d8498ea3315f68d05dc2f9e86c2858b5d2b2f89 \ No newline at end of file +**Content Hash:** bf4f628855f6f4c54ceca8c845e7ec93498135aa2d045f582d7c98e3a05294d7 \ No newline at end of file diff --git a/docs/api/README.md b/docs/api/README.md index 6c8267955..96246bdfc 100644 --- a/docs/api/README.md +++ b/docs/api/README.md @@ -16,7 +16,9 @@ Here... * [Buckets](contract) * [Signers](signer) * [Signer](signer) - * [Wallet inherits Signer](signer) + * [Wallet](signer) + * [VoidSigner](signer) + * [ExternallyOwnedAccount](signer) * [Providers](providers) * [Provider](providers/provider) * [Accounts Methods](providers/provider) @@ -27,25 +29,35 @@ Here... * [Transactions Methods](providers/provider) * [Event Emitter Methods](providers/provider) * [Inspection Methods](providers/provider) - * [JSON-RPC Provider](providers/jsonrpc-provider) - * [JsonRpcProvider](providers/jsonrpc-provider) + * [JsonRpcProvider](providers/jsonrpc-provider) * [JsonRpcSigner](providers/jsonrpc-provider) * [JsonRpcUncheckedSigner](providers/jsonrpc-provider) * [API Providers](providers/api-providers) * [EtherscanProvider](providers/api-providers) * [InfuraProvider](providers/api-providers) - * [NodesmithProvider](providers/api-providers) * [AlchemyProvider](providers/api-providers) * [CloudfrontProvider](providers/api-providers) * [Other Providers](providers/other) * [FallbackProvider](providers/other) * [IpcProvider](providers/other) + * [UrlJsonRpcProvider](providers/other) + * [Web3Provider](providers/other) * [Types](providers/types) - * [Blocks](providers/types) + * [Network](providers/types) + * [Block](providers/types) * [Events and Logs](providers/types) * [Transactions](providers/types) * [Utilities](utils) * [Addresses](utils/address) + * [Address Formats](utils/address) + * [Functions](utils/address) + * [Application Binary Interface](utils/abi) + * [Formats](utils/abi) + * [Fragment](utils/abi) + * [ConstructorFragment](utils/abi) + * [EventFragment](utils/abi) + * [FunctionFragment](utils/abi) + * [ParamType](utils/abi) * [BigNumber](utils/bignumber) * [Types](utils/bignumber) * [Creating Instances](utils/bignumber) @@ -66,7 +78,7 @@ Here... * [Units](utils/display-logic) * [Functions](utils/display-logic) * [FixedNumber](utils/fixednumber) - * [Types](utils/fixednumber) + * [FixedFormat](utils/fixednumber) * [Creating Instances](utils/fixednumber) * [Properties](utils/fixednumber) * [Methods](utils/fixednumber) @@ -77,8 +89,16 @@ Here... * [Strings](utils/strings) * [Bytes32String](utils/strings) * [UTF-8 Strings](utils/strings) + * [UnicodeNormalizationForm](utils/strings) + * [Custom UTF-8 Error Handling](utils/strings) + * [Transactions](utils/transactions) + * [Types](utils/transactions) + * [Functions](utils/transactions) +* [Other Libraries](other) + * [Hardware Wallets](other/hardware) + * [LedgerSigner](other/hardware) ----- -**Content Hash:** 82f760f38f47d32016d3fca512c5dc75539d885d13138f1faa15f4be82edf8aa \ No newline at end of file +**Content Hash:** 9efeac06691d2415dcc248d1567676602f7df029abd5f844480b12bb844588a7 \ No newline at end of file diff --git a/docs/api/contract/index.html b/docs/api/contract/index.html index 2baadd28b..e1d95b64f 100644 --- a/docs/api/contract/index.html +++ b/docs/api/contract/index.html @@ -1,6 +1,6 @@ -Contracts
+Contracts

Contracts

Explain what contracts are...

Buckets

-
\ No newline at end of file +
\ No newline at end of file diff --git a/docs/api/index.html b/docs/api/index.html index 5b948eac6..07b55515e 100644 --- a/docs/api/index.html +++ b/docs/api/index.html @@ -1,4 +1,4 @@ -Application Programming Interface
+Application Programming Interface \ No newline at end of file +
\ No newline at end of file diff --git a/docs/api/other/README.md b/docs/api/other/README.md new file mode 100644 index 000000000..6b0ba5b0f --- /dev/null +++ b/docs/api/other/README.md @@ -0,0 +1,23 @@ +----- + +Documentation: [html](https://docs-beta.ethers.io/) + +----- + + +Other Libraries +=============== + + +Now that ethers is more modular, it is possible to have additional +ancillary packages, which are not part of the core but optionally +add functionality only needed in certain situations. + + +* [Hardware Wallets](hardware) + * [LedgerSigner](hardware) + + + +----- +**Content Hash:** bafa126f115321049791ba83b99acf79f82f222eb246124c601983ad8cb4b73a \ No newline at end of file diff --git a/docs/api/other/hardware/README.md b/docs/api/other/hardware/README.md new file mode 100644 index 000000000..b091b0765 --- /dev/null +++ b/docs/api/other/hardware/README.md @@ -0,0 +1,38 @@ +----- + +Documentation: [html](https://docs-beta.ethers.io/) + +----- + + +Hardware Wallets +================ + + + +LedgerSigner +------------ + + +The [Ledger Hardware Wallets](https://www.ledger.com) are a fairly +popular brand. + +TODO: importing + + +### API + + + +#### **new** **LedgerSigner** ( [ provider [ , type [ , path ] ] ] ) **=>** *[LedgerSigner](./)* + +Connects to a Ledger Hardware Wallet. The *type* if left unspecified is +determined by the environment; in node the default is "hid" and in the browser +"u2f" is the default. The default Ethereum path is used if *path* is left unspecified. + + + + + +----- +**Content Hash:** 240366cd9757f396d08ed65ebfceafa51f82bfc44c04695ab68e3560e7a0016b \ No newline at end of file diff --git a/docs/api/other/hardware/index.html b/docs/api/other/hardware/index.html new file mode 100644 index 000000000..b5814c69b --- /dev/null +++ b/docs/api/other/hardware/index.html @@ -0,0 +1,8 @@ +Hardware Wallets
+

Hardware Wallets

+ +

LedgerSigner inherits Signer

+

The Ledger Hardware Wallets are a fairly popular brand.

TODO: importing

+

API

+ +
new LedgerSigner ( [ provider [ , type [ , path ] ] ] ) LedgerSigner

Connects to a Ledger Hardware Wallet. The type if left unspecified is determined by the environment; in node the default is "hid" and in the browser "u2f" is the default. The default Ethereum path is used if path is left unspecified.

\ No newline at end of file diff --git a/docs/api/other/index.html b/docs/api/other/index.html new file mode 100644 index 000000000..b7bc2b9ac --- /dev/null +++ b/docs/api/other/index.html @@ -0,0 +1,4 @@ +Other Libraries
+

Other Libraries

+

Now that ethers is more modular, it is possible to have additional ancillary packages, which are not part of the core but optionally add functionality only needed in certain situations.

+
\ No newline at end of file diff --git a/docs/api/providers/README.md b/docs/api/providers/README.md index 9b81df842..4fc65353b 100644 --- a/docs/api/providers/README.md +++ b/docs/api/providers/README.md @@ -64,25 +64,26 @@ Provider Documentation * [Transactions Methods](provider) * [Event Emitter Methods](provider) * [Inspection Methods](provider) -* [JSON-RPC Provider](jsonrpc-provider) - * [JsonRpcProvider](jsonrpc-provider) +* [JsonRpcProvider](jsonrpc-provider) * [JsonRpcSigner](jsonrpc-provider) * [JsonRpcUncheckedSigner](jsonrpc-provider) * [API Providers](api-providers) * [EtherscanProvider](api-providers) * [InfuraProvider](api-providers) - * [NodesmithProvider](api-providers) * [AlchemyProvider](api-providers) * [CloudfrontProvider](api-providers) * [Other Providers](other) * [FallbackProvider](other) * [IpcProvider](other) + * [UrlJsonRpcProvider](other) + * [Web3Provider](other) * [Types](types) - * [Blocks](types) + * [Network](types) + * [Block](types) * [Events and Logs](types) * [Transactions](types) ----- -**Content Hash:** 4bae65aa1521a7ecf045f950c9a702ad597d83095d079e66a5abbd327373877c \ No newline at end of file +**Content Hash:** 90fa0754bfed9594694637e2d5167de53e514a4c3527cd10a42083488ad112bf \ No newline at end of file diff --git a/docs/api/providers/api-providers/README.md b/docs/api/providers/api-providers/README.md index 3c964f12b..47e53a007 100644 --- a/docs/api/providers/api-providers/README.md +++ b/docs/api/providers/api-providers/README.md @@ -30,10 +30,23 @@ The **EtherscanProvider** is backed by a combination of the various #### *provider* . **getHistory** ( address ) **=>** *Array< History >* +@TODO... Explain +#### **Supported Networks** + + + +* Homestead (Mainnet) +* Ropsten (proof-of-work testnet) +* Rinkeby (proof-of-Authority testnet) +* Görli (clique testnet) +* Kovan (proof-of-authority testnet) + + + InfuraProvider -------------- @@ -42,18 +55,18 @@ InfuraProvider The **InfuraProvider** is backed by the popular [INFURA](https://infura.io) Ethereum service. -It supports Mainnet (homestead) and all common testnets (Ropsten, Rinkeby, -Görli and Kovan). + +#### **Supported Networks** -NodesmithProvider ------------------ + +* Homestead (Mainnet) +* Ropsten (proof-of-work testnet) +* Rinkeby (proof-of-Authority testnet) +* Görli (clique testnet) +* Kovan (proof-of-authority testnet) -The **NodesmithProvider** is backed by [Nodesmith](https://nodesmith.io). - -It supports Mainnet (homestead) and all common testnets (Ropsten, Rinkeby, -Görli and Kovan), as well as the Ethereum-like network [Aion](https://aion.network). AlchemyProvider @@ -62,8 +75,18 @@ AlchemyProvider The **AlchemtProvider** is backed by [Alchemy](https://alchemyapi.io). -It supports Mainnet (homestead) and all common testnets (Ropsten, Rinkeby, -Görli and Kovan). + +#### **Supported Networks** + + + +* Homestead (Mainnet) +* Ropsten (proof-of-work testnet) +* Rinkeby (proof-of-Authority testnet) +* Görli (clique testnet) +* Kovan (proof-of-authority testnet) + + CloudfrontProvider @@ -73,9 +96,16 @@ CloudfrontProvider The CloudfrontProvider is backed by the [Cloudflare Ethereum Gateway](https://developers.cloudflare.com/distributed-web/ethereum-gateway/). -It only supports Mainnet (homestead). + +#### **Supported Networks** + + + +* Homestead (Mainnet) + + ----- -**Content Hash:** 2e1dfa80bd4ab1ba02610654b00ee4250a89758a496670822e7950d5db449b1c \ No newline at end of file +**Content Hash:** 516111e087ee3f12588ba555c0719f7170ea532e269590586c95ddc1d7eb7e7b \ No newline at end of file diff --git a/docs/api/providers/api-providers/index.html b/docs/api/providers/api-providers/index.html index b962180f3..f3d5d3c39 100644 --- a/docs/api/providers/api-providers/index.html +++ b/docs/api/providers/api-providers/index.html @@ -1,14 +1,16 @@ -API Providers
+API Providers

API Providers

There are many services which offer a web API for accessing the Ethereum Blockchain. These Providers allow connecting to them, which simplifies development, since you do not need to run your own instance or cluster of Ethereum nodes.

However, this reliance on third-party services can reduce resiliance, security and increase the amount of required trust. To mitigate these issues, it is recommended you use a Default Provider.

-

EtherscanProvider

+

EtherscanProvider inherits Provider

The EtherscanProvider is backed by a combination of the various Etherscan APIs.

-
provider . getHistory ( address ) Array< History >

-

InfuraProvider

-

The InfuraProvider is backed by the popular INFURA Ethereum service.

It supports Mainnet (homestead) and all common testnets (Ropsten, Rinkeby, Görli and Kovan).

-

NodesmithProvider

-

The NodesmithProvider is backed by Nodesmith.

It supports Mainnet (homestead) and all common testnets (Ropsten, Rinkeby, Görli and Kovan), as well as the Ethereum-like network Aion.

-

AlchemyProvider

-

The AlchemtProvider is backed by Alchemy.

It supports Mainnet (homestead) and all common testnets (Ropsten, Rinkeby, Görli and Kovan).

-

CloudfrontProvider

-

The CloudfrontProvider is backed by the Cloudflare Ethereum Gateway.

It only supports Mainnet (homestead).

\ No newline at end of file +
provider . getHistory ( address ) Array< History >

@TODO... Explain

+
Supported Networks
  • Homestead (Mainnet)
  • Ropsten (proof-of-work testnet)
  • Rinkeby (proof-of-Authority testnet)
  • Görli (clique testnet)
  • Kovan (proof-of-authority testnet)
+

InfuraProvider inherits UrlJsonRpcProvider

+

The InfuraProvider is backed by the popular INFURA Ethereum service.

+
Supported Networks
  • Homestead (Mainnet)
  • Ropsten (proof-of-work testnet)
  • Rinkeby (proof-of-Authority testnet)
  • Görli (clique testnet)
  • Kovan (proof-of-authority testnet)
+

AlchemyProvider inherits UrlJsonRpcProvider

+

The AlchemtProvider is backed by Alchemy.

+
Supported Networks
  • Homestead (Mainnet)
  • Ropsten (proof-of-work testnet)
  • Rinkeby (proof-of-Authority testnet)
  • Görli (clique testnet)
  • Kovan (proof-of-authority testnet)
+

CloudfrontProvider inherits UrlJsonRpcProvider

+

The CloudfrontProvider is backed by the Cloudflare Ethereum Gateway.

+
Supported Networks
  • Homestead (Mainnet)
\ No newline at end of file diff --git a/docs/api/providers/index.html b/docs/api/providers/index.html index 6b16e4c0c..d7e37f1d5 100644 --- a/docs/api/providers/index.html +++ b/docs/api/providers/index.html @@ -1,4 +1,4 @@ -Providers
+Providers

Providers

A Provider is an abstraction of a connection to the Ethereum network, providing a concise, consistent interface to standard Ethereum node functionality.

The ethers.js library provides several options which should cover the vast majority of use-cases, but also includes the necessary functions and classes for sub-classing if a more custom configuration is necessary.

Most users should be able to simply use the Default Provider.

Default Provider

@@ -6,4 +6,4 @@
ethers . getDefaultProvider ( [ network ] ) Provider

Returns a new Provider, backed by multiple services, connected to network. Is no network is provided, homestead (i.e. mainnet) is used.

Provider Documentation

-
\ No newline at end of file +
\ No newline at end of file diff --git a/docs/api/providers/jsonrpc-provider/README.md b/docs/api/providers/jsonrpc-provider/README.md index 08147caf5..11fe7a7e3 100644 --- a/docs/api/providers/jsonrpc-provider/README.md +++ b/docs/api/providers/jsonrpc-provider/README.md @@ -5,21 +5,37 @@ Documentation: [html](https://docs-beta.ethers.io/) ----- -JSON-RPC Provider -================= - - -Explain here... - - JsonRpcProvider ---------------- +=============== -TODO... +The [JSON-RPC API](https://github.com/ethereum/wiki/wiki/JSON-RPC) is a +very popular method for interacting with Ethereum and is available in all +major Ethereum node implementations (e.g. [Geth](https://geth.ethereum.org) +and [Parity](https://www.parity.io)) as well as many third-party web +services (e.g. [INFURA](https://infura.io)) -#### *provider* . **getSigner** ( [ addressOrIndex ] ) **=>** *[JsonRpcSigner](./)* +#### **new** *ethers* . *providers* . **JsonRpcProvider** ( [ url [ , aNetworkish ] ] ) + +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. + + + + +#### Note: Connecting to a Local Node + +Each node implementation is slightly different and may require specific command-line +flags or changes in their Settings UI to enable JSON-RPC, unlock accounrs +or expose specific APIs. Please consult theit documentation. + + + + +#### *jsonRpcProvider* . **getSigner** ( [ addressOrIndex ] ) **=>** *[JsonRpcSigner](./)* Returns a [JsonRpcSigner](./) which is managed by this Ethereum node, at *addressOrIndex*. If no *addressOrIndex* is provided, the first @@ -28,27 +44,91 @@ account (account #0) is used. -#### *provider* . **getUncheckSigner** ( [ addressOrIndex ] ) **=>** *[JsonRpcUncheckedSigner](./)* +#### *jsonRpcProvider* . **getUncheckedSigner** ( [ addressOrIndex ] ) **=>** *[JsonRpcUncheckedSigner](./)* +#### *jsonRpcProvider* . **listAccounts** ( ) **=>** *Array< string >* + +Returns a list of all account addresses managed by this provider. + + + + +#### *jsonRpcProvider* . **send** ( method , params ) **=>** *Promise< any >* + +Allows sending raw messages to the provider. + +This can be used for backend-specific calls, such as for debugging or +specific account management. + + + + JsonRpcSigner ------------- -TODO... Explain +A **JsonRpcSigner** is a simple Signer which is backed by a connected +[JsonRpcProvider](./). + + +#### *signer* . **provider** **=>** *[JsonRpcProvider](./)* + +The provider this signer was established from. + + + + +#### *signer* . **connectUnchecked** ( ) **=>** *[JsonRpcUncheckedSigner](./)* + +Returns a new Signer object which does not perform addtional checks when +sending a transaction. See [JsonRpcUncheckedSigner](./) for more details. + + + + +#### *signer* . **sendUncheckedTransaction** ( transaction ) **=>** *Promise< string< [DataHexstring](../../utils/bytes)< 32 > > >* + +Sends the *transaction* and returns a Promise which resolves to the +opacque transaction hash. + + + + +#### *signer* . **unlock** ( password ) **=>** *Promise< boolean >* + +Request the node unlock the account (if locked) using *password*. + + JsonRpcUncheckedSigner ---------------------- -TODO... Explain +The JSON-RPC API only provides a transaction hash as the response when a +transaction is sent, but the ethers Provider requires populating all details +of a transaction before returning it. For example, the gas price and gas limit +may be adjusted by the node or the nonce automatically included, in which case +the opaque transaction hash has discarded this. + +To remedy this, the [JsonRpcSigner](./) immeidately queries the provider for +the details using the returned transaction hash to populate the [TransactionResponse](../types) +object. + +Some backends do not respond immediately and instead defer releasing the +details of a transaction it was responsible for signing until it is mined. + +The **UncheckedSigner** does not populate any additional information and will +immediately return the result as a mock [TransactionResponse](../types)-like +object, with most of the properties set to null, but allows access to the +transaction hash quickly, if that is all that is required. ----- -**Content Hash:** 09091214806fa2270a7425521fd948901355db2ec3406597fb5e29141b40639b \ No newline at end of file +**Content Hash:** 4d82738b8e1db6b6421b7234b0d302c35aa25aed707ab2cfb0798e2613e41abd \ No newline at end of file diff --git a/docs/api/providers/jsonrpc-provider/index.html b/docs/api/providers/jsonrpc-provider/index.html index 3cc54a18a..ea35b82aa 100644 --- a/docs/api/providers/jsonrpc-provider/index.html +++ b/docs/api/providers/jsonrpc-provider/index.html @@ -1,11 +1,17 @@ -JSON-RPC Provider
-

JSON-RPC Provider

-

Explain here...

-

JsonRpcProvider

-

TODO...

-
provider . getSigner ( [ addressOrIndex ] ) JsonRpcSigner

Returns a JsonRpcSigner which is managed by this Ethereum node, at addressOrIndex. If no addressOrIndex is provided, the first account (account #0) is used.

-
provider . getUncheckSigner ( [ addressOrIndex ] ) JsonRpcUncheckedSigner

-

JsonRpcSigner

-

TODO... Explain

-

JsonRpcUncheckedSigner

-

TODO... Explain

\ No newline at end of file +JSON-RPC Provider
+

JsonRpcProvider inherits Provider

+

The JSON-RPC API is a very popular method for interacting with Ethereum and is available in all major Ethereum node implementations (e.g. Geth and Parity) as well as many third-party web services (e.g. INFURA)

+
new ethers . providers . JsonRpcProvider ( [ url [ , aNetworkish ] ] )

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.

+
Note: Connecting to a Local Node

Each node implementation is slightly different and may require specific command-line flags or changes in their Settings UI to enable JSON-RPC, unlock accounrs or expose specific APIs. Please consult theit documentation.

+
jsonRpcProvider . getSigner ( [ addressOrIndex ] ) JsonRpcSigner

Returns a JsonRpcSigner which is managed by this Ethereum node, at addressOrIndex. If no addressOrIndex is provided, the first account (account #0) is used.

+
jsonRpcProvider . getUncheckedSigner ( [ addressOrIndex ] ) JsonRpcUncheckedSigner

+
jsonRpcProvider . listAccounts ( ) Array< string >

Returns a list of all account addresses managed by this provider.

+
jsonRpcProvider . send ( method , params ) Promise< any >

Allows sending raw messages to the provider.

This can be used for backend-specific calls, such as for debugging or specific account management.

+

JsonRpcSigner inherits Signer

+

A JsonRpcSigner is a simple Signer which is backed by a connected JsonRpcProvider.

+
signer . provider JsonRpcProvider

The provider this signer was established from.

+
signer . connectUnchecked ( ) JsonRpcUncheckedSigner

Returns a new Signer object which does not perform addtional checks when sending a transaction. See JsonRpcUncheckedSigner for more details.

+
signer . sendUncheckedTransaction ( transaction ) Promise< string< DataHexstring< 32 > > >

Sends the transaction and returns a Promise which resolves to the opacque transaction hash.

+
signer . unlock ( password ) Promise< boolean >

Request the node unlock the account (if locked) using password.

+

JsonRpcUncheckedSigner inherits Signer

+

The JSON-RPC API only provides a transaction hash as the response when a transaction is sent, but the ethers Provider requires populating all details of a transaction before returning it. For example, the gas price and gas limit may be adjusted by the node or the nonce automatically included, in which case the opaque transaction hash has discarded this.

To remedy this, the JsonRpcSigner immeidately queries the provider for the details using the returned transaction hash to populate the TransactionResponse object.

Some backends do not respond immediately and instead defer releasing the details of a transaction it was responsible for signing until it is mined.

The UncheckedSigner does not populate any additional information and will immediately return the result as a mock TransactionResponse-like object, with most of the properties set to null, but allows access to the transaction hash quickly, if that is all that is required.

\ No newline at end of file diff --git a/docs/api/providers/other/README.md b/docs/api/providers/other/README.md index b01ae540f..1bcc12811 100644 --- a/docs/api/providers/other/README.md +++ b/docs/api/providers/other/README.md @@ -16,16 +16,36 @@ FallbackProvider ---------------- -Explain... +The **FallbackProvider** is the most advanced [Provider](../provider) available in +ethers. + +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 +choosen (higher prioirty 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. + +By default the quorum requires 50% (rounded up) of the backends to agree. The *weight* +can be used to give a backend Provider more influence. -### Properties +#### **new** *ethers* . *providers* . **FallbackProvider** ( providers [ , quorum ] ) + +Creates a new instance of a FallbackProvider connected to *providers*. If +quorum is not specified, half of the total sum of the provider weights is +used. + +The *providers* can be either an array of [Provider](../provider) or [FallbackProviderConfig](./). +If a [Provider](../provider) is provided, the defaults are a priority of 1 and a weight of 1. -#### *provider* . **providers** **=>** *Array< [Provider](../provider) >* -The list of Providers this is connected to. +#### *provider* . **providerConfigs** **=>** *Array< [FallbackProviderConfig](./) >* + +The list of Provider Configurations that describe the backends. @@ -38,9 +58,42 @@ resolved. By default this is *half the sum of the weights*. -#### *provider* . **weights** **=>** *Array< number >* +### FallbackProviderConfig -The weight each of the Providers adds to a results acceptance. + + +#### *fallbackProviderConfig* . **provider** **=>** *[Provider](../provider)* + +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 prioirty, they are choosen +at random. + + + + +#### *fallbackProviderConfig* . **stallTimeout** **=>** *number* + +The timeout (in ms) after which another [Provider](../provider) will be attempted. This +does not affect the current Provider; if it returns a result it is counted +as part of the quorum. + +Lower values will result in more network traffic, but may reduce the response +time of requests. + + + + +#### *fallbackProviderConfig* . **weight** **=>** *number* + +The weight a response from this provider provides. This can be used if a given +[Provider](../provider) is more trusted, for example. @@ -49,9 +102,89 @@ IpcProvider ----------- -Explain... +The **IpcProvider** allows the JSON-RPC API to be used over a local +filename on the file system, exposed by Geth, Parity and other nodes. + +This is only available in *node.js* (as it requires file system access, +and may have additional complications due to file permissions. See any +related notes on the documentation for the actual node implementation websites. + + +#### *ipcProvider* . **path** **=>** *string* + +The path this [Provider](../provider) is connected to. + + + + +UrlJsonRpcProvider +------------------ + + +This class is intended to be sub-classed and not used directly. It +simplifies creating a [Provider](../provider) where a normal [JsonRpcProvider](../jsonrpc-provider) +would suffice, with a little extra effort needed to generate the JSON-RPC +URL. + + +#### **new** *ethers* . *providers* . **UrlJsonRpcProvider** ( [ network [ , apiKey ] ] ) + +Sub-classes do not need to override this. Instead they should override the +static method `getUrl` and optionally `getApiKey`. + + + + +#### *urlJsonRpcProvider* . **apiKey** **=>** *any* + +The value of the apiKey that was returned from `InheritedClass.getApiKey`. + + + + +#### *InheritingClass* . **getApiKey** ( apiKey ) **=>** *any* + +This function should examine the *apiKey* to ensure it is valid and +return a (possible modified) value to use in `getUrl`. + + + + +#### *InheritingClass* . **getUrl** ( network , apiKey ) **=>** *string* + +The URL to use for the JsonRpcProvider instance. + + + + +Web3Provider +------------ + + +The Web3Provider is meant to ease moving from a [web3.js based](https://github.com/ethereum/web3.js) +application to ethers by wraping an existing Web3-compatible (such as a +[Web3HttpProvider](https://github.com/ethereum/web3.js/tree/1.x/packages/web3-providers-http) +[Web3IpcProvider](https://github.com/ethereum/web3.js/tree/1.x/packages/web3-providers-ipc) or +[Web3WsProvider](https://github.com/ethereum/web3.js/tree/1.x/packages/web3-providers-ws)) +and exposing it as an ethers.js [Provider](../provider) which can then be used with the rest of +the library. + + +#### **new** *ethers* . *providers* . **Web3Provider** ( web3Provider [ , network ] ) + +Create a new **Web3Provider**, which wraps an [EIP-1193 Provider]() or +Web3Provider-compatible Provider. + + + + +#### *web3Provider* . **provider** **=>** *Web3CompatibleProvider* + +The provider used to create this instance. + + ----- -**Content Hash:** c950a8710b679e9061aa834f8b0366614dcb031270627249acb412813bb5ca94 \ No newline at end of file +**Content Hash:** 95791f5b36e1becb2e1222424eb25b0b14743670c827dea2041b048e686d2118 \ No newline at end of file diff --git a/docs/api/providers/other/index.html b/docs/api/providers/other/index.html index 36fe20985..d7947b4bb 100644 --- a/docs/api/providers/other/index.html +++ b/docs/api/providers/other/index.html @@ -1,12 +1,27 @@ -Other Providers
+Other Providers

Other Providers

Others...

-

FallbackProvider

-

Explain...

-

Properties

- -
provider . providers Array< Provider >

The list of Providers this is connected to.

+

FallbackProvider inherits Provider

+

The FallbackProvider is the most advanced Provider available in ethers.

It uses a quorum and connects to multiple Providers as backends, each configured with a priority and a weight .

When a request is made, the request is dispatched to multiple backends, randomly choosen (higher prioirty 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.

By default the quorum requires 50% (rounded up) of the backends to agree. The weight can be used to give a backend Provider more influence.

+
new ethers . providers . FallbackProvider ( providers [ , quorum ] )

Creates a new instance of a FallbackProvider connected to providers. If quorum is not specified, half of the total sum of the provider weights is used.

The providers can be either an array of Provider or FallbackProviderConfig. If a Provider is provided, the defaults are a priority of 1 and a weight of 1.

+
provider . providerConfigs Array< FallbackProviderConfig >

The list of Provider Configurations that describe the backends.

provider . quorum number

The quorum the backend responses must agree upon before a result will be resolved. By default this is half the sum of the weights.

-
provider . weights Array< number >

The weight each of the Providers adds to a results acceptance.

-

IpcProvider

-

Explain...

\ No newline at end of file +

FallbackProviderConfig

+ +
fallbackProviderConfig . provider Provider

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 prioirty, they are choosen at random.

+
fallbackProviderConfig . stallTimeout number

The timeout (in ms) after which another Provider will be attempted. This does not affect the current Provider; if it returns a result it is counted as part of the quorum.

Lower values will result in more network traffic, but may reduce the response time of requests.

+
fallbackProviderConfig . weight number

The weight a response from this provider provides. This can be used if a given Provider is more trusted, for example.

+

IpcProvider inherits JsonRpcProvider

+

The IpcProvider allows the JSON-RPC API to be used over a local filename on the file system, exposed by Geth, Parity and other nodes.

This is only available in node.js (as it requires file system access, and may have additional complications due to file permissions. See any related notes on the documentation for the actual node implementation websites.

+
ipcProvider . path string

The path this Provider is connected to.

+

UrlJsonRpcProvider inherits JsonRpcProvider

+

This class is intended to be sub-classed and not used directly. It simplifies creating a Provider where a normal JsonRpcProvider would suffice, with a little extra effort needed to generate the JSON-RPC URL.

+
new ethers . providers . UrlJsonRpcProvider ( [ network [ , apiKey ] ] )

Sub-classes do not need to override this. Instead they should override the static method getUrl and optionally getApiKey.

+
urlJsonRpcProvider . apiKey any

The value of the apiKey that was returned from InheritedClass.getApiKey.

+
InheritingClass . getApiKey ( apiKey ) any

This function should examine the apiKey to ensure it is valid and return a (possible modified) value to use in getUrl.

+
InheritingClass . getUrl ( network , apiKey ) string

The URL to use for the JsonRpcProvider instance.

+

Web3Provider inherits JsonRpcProvider

+

The Web3Provider is meant to ease moving from a web3.js based application to ethers by wraping an existing Web3-compatible (such as a Web3HttpProvider Web3IpcProvider or Web3WsProvider) and exposing it as an ethers.js Provider which can then be used with the rest of the library.

+
new ethers . providers . Web3Provider ( web3Provider [ , network ] )

Create a new Web3Provider, which wraps an [EIP-1193 Provider]() or Web3Provider-compatible Provider.

+
web3Provider . provider Web3CompatibleProvider

The provider used to create this instance.

\ No newline at end of file diff --git a/docs/api/providers/provider/README.md b/docs/api/providers/provider/README.md index d396191f4..430daa232 100644 --- a/docs/api/providers/provider/README.md +++ b/docs/api/providers/provider/README.md @@ -24,7 +24,7 @@ Returns the balance of *address* as of the *blockTag* block height. -#### *provider* . **getCode** ( address [ , blockTag="latest" ] ) **=>** *Promise< [Hexstring](../../utils/bytes) >* +#### *provider* . **getCode** ( address [ , blockTag="latest" ] ) **=>** *Promise< string< [DataHexstring](../../utils/bytes) > >* Returns the contract code of *address* as of the *blockTag* block height. If there is no contract currently deployed, the result is `0x`. @@ -32,9 +32,9 @@ no contract currently deployed, the result is `0x`. -#### *provider* . **getStorageAt** ( address , position [ , blockTag="latest" ] ) **=>** *Promise< [Hexstring](../../utils/bytes) >* +#### *provider* . **getStorageAt** ( addr , pos [ , blockTag="latest" ] ) **=>** *Promise< string< [DataHexstring](../../utils/bytes) > >* -Returns the `Bytes32` value of the *position* at *address*, as of the *blockTag*. +Returns the `Bytes32` value of the position *pos* at address *addr*, as of the *blockTag*. @@ -53,7 +53,21 @@ sent to the network. ```javascript -Skipping JavaScript Evaluation. +// Get the balance for an account... +provider.getBalance("ricmoo.firefly.eth"); +// { Promise: { BigNumber: "2049005886712300740" } } + +// Get the code for a contract... +provider.getCode("registrar.firefly.eth"); +// { Promise: "0x606060405236156100885763ffffffff60e060020a60003504166369fe0e2d81146100fa578063704b6c021461010f57806379502c551461012d578063bed866f614610179578063c37067fa1461019e578063c66485b2146101ab578063d80528ae146101c9578063ddca3f43146101f7578063f2c298be14610219578063f3fef3a314610269575b6100f85b6000808052600760209081527f6d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6df80543490810190915560408051918252517fdb7750418f9fa390aaf85d881770065aa4adbe46343bcff4ae573754c829d9af929181900390910190a25b565b005b341561010257fe5b6100f860043561028a565b005b341561011757fe5b6100f8600160a060020a03600435166102ec565b005b341561013557fe5b61013d610558565b60408051600160a060020a0396871681526020810195909552928516848401526060840191909152909216608082015290519081900360a00190f35b341561018157fe5b61018c600435610580565b60408051918252519081900360200190f35b6100f8600435610595565b005b34156101b357fe5b6100f8600160a060020a03600435166105e6565b005b34156101d157fe5b6101d9610676565b60408051938452602084019290925282820152519081900360600190f35b34156101ff57fe5b61018c61068d565b60408051918252519081900360200190f35b6100f8600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284375094965061069495505050505050565b005b341561027157fe5b6100f8600160a060020a0360043516602435610ab2565b005b60025433600160a060020a039081169116146102a65760006000fd5b600454604080519182526020820183905280517f854231545a00e13c316c82155f2b8610d638e9ff6ebc4930676f84a5af08a49a9281900390910190a160048190555b50565b60025433600160a060020a039081169116146103085760006000fd5b60025460408051600160a060020a039283168152918316602083015280517fbadc9a52979e89f78b7c58309537410c5e51d0f63a0a455efe8d61d2b474e6989281900390910190a16002805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a038381169190911790915560008054604080516020908101849052815160e060020a6302571be30281527f91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e26004820152915192909416936302571be39360248084019492938390030190829087803b15156103e957fe5b60325a03f115156103f657fe5b50505060405180519050600160a060020a0316631e83409a826000604051602001526040518263ffffffff1660e060020a0281526004018082600160a060020a0316600160a060020a03168152602001915050602060405180830381600087803b151561045f57fe5b60325a03f1151561046c57fe5b50506040805160008054600354602093840183905284517f0178b8bf00000000000000000000000000000000000000000000000000000000815260048101919091529351600160a060020a039091169450630178b8bf9360248082019493918390030190829087803b15156104dd57fe5b60325a03f115156104ea57fe5b505060408051805160035460025460e860020a62d5fa2b0284526004840191909152600160a060020a03908116602484015292519216925063d5fa2b0091604480830192600092919082900301818387803b151561054457fe5b60325a03f1151561055157fe5b5050505b50565b600054600354600254600454600154600160a060020a039485169492831692165b9091929394565b6000818152600760205260409020545b919050565b6000818152600760209081526040918290208054349081019091558251908152915183927fdb7750418f9fa390aaf85d881770065aa4adbe46343bcff4ae573754c829d9af92908290030190a25b50565b60025433600160a060020a039081169116146106025760006000fd5b60015460408051600160a060020a039283168152918316602083015280517f279875333405c968e401e3bc4e71d5f8e48728c90f4e8180ce28f74efb5669209281900390910190a16001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790555b50565b600654600554600160a060020a033016315b909192565b6004545b90565b80516001820190600080808060048510806106af5750601485115b156106ba5760006000fd5b600093505b8484101561072a57855160ff16925060618310806106e05750607a8360ff16115b80156106fc575060308360ff1610806106fc575060398360ff16115b5b801561070d57508260ff16602d14155b156107185760006000fd5b6001909501945b6001909301926106bf565b60045434101561073a5760006000fd5b866040518082805190602001908083835b6020831061076a5780518252601f19909201916020918201910161074b565b51815160209384036101000a60001901801990921691161790526040805192909401829003822060035483528282018190528451928390038501832060008054948401819052865160e060020a6302571be3028152600481018390529651929a509098509650600160a060020a0390921694506302571be393602480820194509192919082900301818787803b15156107ff57fe5b60325a03f1151561080c57fe5b505060405151600160a060020a031691909114905061082b5760006000fd5b60008054600354604080517f06ab5923000000000000000000000000000000000000000000000000000000008152600481019290925260248201869052600160a060020a03308116604484015290519216926306ab59239260648084019382900301818387803b151561089a57fe5b60325a03f115156108a757fe5b505060008054600154604080517f1896f70a00000000000000000000000000000000000000000000000000000000815260048101879052600160a060020a0392831660248201529051919092169350631896f70a9260448084019391929182900301818387803b151561091657fe5b60325a03f1151561092357fe5b50506001546040805160e860020a62d5fa2b02815260048101859052600160a060020a033381166024830152915191909216925063d5fa2b009160448082019260009290919082900301818387803b151561097a57fe5b60325a03f1151561098757fe5b505060008054604080517f5b0fc9c300000000000000000000000000000000000000000000000000000000815260048101869052600160a060020a0333811660248301529151919092169350635b0fc9c39260448084019391929182900301818387803b15156109f357fe5b60325a03f11515610a0057fe5b505060058054349081019091556006805460010190556000838152600760209081526040918290208054840190558151600160a060020a03331681529081019290925280518493507f179ef3319e6587f6efd3157b34c8b357141528074bcb03f9903589876168fa149281900390910190a260408051348152905182917fdb7750418f9fa390aaf85d881770065aa4adbe46343bcff4ae573754c829d9af919081900360200190a25b50505050505050565b60025433600160a060020a03908116911614610ace5760006000fd5b604051600160a060020a0383169082156108fc029083906000818181858888f193505050501515610aff5760006000fd5b60408051600160a060020a03841681526020810183905281517fac375770417e1cb46c89436efcf586a74d0298fee9838f66a38d40c65959ffda929181900390910190a15b50505600a165627a7a723058205c3628c01dc80233f51979d91a76cec2a25d84e86c9838d34672734ca2232b640029" } + +// Get the storage value at position 0... +provider.getStorageAt("registrar.firefly.eth", 0) +// { Promise: "0x000000000000000000000000314159265dd8dbb310642f98f50c066173c1259b" } + +// Get transaction count of an account... +provider.getTransactionCount("ricmoo.firefly.eth"); +// { Promise: 608 } ``` @@ -95,7 +109,7 @@ forward lookup does not match, `null` is returned. -#### *provider* . **resovleName** ( name ) **=>** *Promise< string >* +#### *provider* . **resolveName** ( name ) **=>** *Promise< string< [Address](../../utils/address) > >* Looks up the address of *name*. If the name is not owned, or does not have a *Resolver* configured, or the *Resolver* does @@ -109,7 +123,13 @@ not have an address configured, `null` is returned. ```javascript -Skipping JavaScript Evaluation. +// Reverse lookup of an ENS by address... +provider.lookupAddress("0x6fC21092DA55B392b045eD78F4732bff3C580e2c"); +// { Promise: "registrar.firefly.eth" } + +// Lookup an address of an ENS name... +provider.resolveName("ricmoo.firefly.eth"); +// { Promise: "0x8ba1f109551bD432803012645Ac136ddd64DBA72" } ``` @@ -161,7 +181,7 @@ Transactions Methods -#### *provider* . **call** ( transaction [ , blockTag="latest" ] ) **=>** *Promise< [Hexstring](../../utils/bytes) >* +#### *provider* . **call** ( transaction [ , blockTag="latest" ] ) **=>** *Promise< string< [Hexstring](../../utils/bytes) > >* Returns the result of executing the *transaction*, using *call*. A call does not require any ether, but cannot change any state. This is useful @@ -273,4 +293,4 @@ Returns true if and only if *object* is a Provider. ----- -**Content Hash:** 95fe0eed62718e6b1f1836b94380b8dd580d48931b261723c8100531c1f570c2 \ No newline at end of file +**Content Hash:** 87f4f33bb310790874b49a3f2295ecc85bf3249bb7908f81a5324483767add72 \ No newline at end of file diff --git a/docs/api/providers/provider/index.html b/docs/api/providers/provider/index.html index 3fc310be1..f82cc09eb 100644 --- a/docs/api/providers/provider/index.html +++ b/docs/api/providers/provider/index.html @@ -1,51 +1,51 @@ -Abstract Provider
+Abstract Provider

Provider

Explain what a provider is...

Accounts Methods

-
provider . getBalance ( address [ , blockTag = "latest" ] ) Promise< BigNumber >

Returns the balance of address as of the blockTag block height.

-
provider . getCode ( address [ , blockTag = "latest" ] ) Promise< Hexstring >

Returns the contract code of address as of the blockTag block height. If there is no contract currently deployed, the result is 0x.

-
provider . getStorageAt ( address , position [ , blockTag = "latest" ] ) Promise< Hexstring >

Returns the Bytes32 value of the position at address, as of the blockTag.

-
provider . getTransactionCount ( address [ , blockTag = "latest" ] ) Promise< number >

Returns the number of transactions address has ever sent, as of blockTag. This value is required to be the nonce for the next transaction from address sent to the network.

+
provider . getBalance ( address [ , blockTag = "latest" ] ) Promise< BigNumber >

Returns the balance of address as of the blockTag block height.

+
provider . getCode ( address [ , blockTag = "latest" ] ) Promise< string< DataHexstring > >

Returns the contract code of address as of the blockTag block height. If there is no contract currently deployed, the result is 0x.

+
provider . getStorageAt ( addr , pos [ , blockTag = "latest" ] ) Promise< string< DataHexstring > >

Returns the Bytes32 value of the position pos at address addr, as of the blockTag.

+
provider . getTransactionCount ( address [ , blockTag = "latest" ] ) Promise< number >

Returns the number of transactions address has ever sent, as of blockTag. This value is required to be the nonce for the next transaction from address sent to the network.

Examples

-
Skipping JavaScript Evaluation.
+

// Get the balance for an account...
provider.getBalance("ricmoo.firefly.eth");
// { Promise: { BigNumber: "2049005886712300740" } }

// Get the code for a contract...
provider.getCode("registrar.firefly.eth");
// { Promise: "0x606060405236156100885763ffffffff60e060020a60003504166369fe0e2d81146100fa578063704b6c021461010f57806379502c551461012d578063bed866f614610179578063c37067fa1461019e578063c66485b2146101ab578063d80528ae146101c9578063ddca3f43146101f7578063f2c298be14610219578063f3fef3a314610269575b6100f85b6000808052600760209081527f6d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6df80543490810190915560408051918252517fdb7750418f9fa390aaf85d881770065aa4adbe46343bcff4ae573754c829d9af929181900390910190a25b565b005b341561010257fe5b6100f860043561028a565b005b341561011757fe5b6100f8600160a060020a03600435166102ec565b005b341561013557fe5b61013d610558565b60408051600160a060020a0396871681526020810195909552928516848401526060840191909152909216608082015290519081900360a00190f35b341561018157fe5b61018c600435610580565b60408051918252519081900360200190f35b6100f8600435610595565b005b34156101b357fe5b6100f8600160a060020a03600435166105e6565b005b34156101d157fe5b6101d9610676565b60408051938452602084019290925282820152519081900360600190f35b34156101ff57fe5b61018c61068d565b60408051918252519081900360200190f35b6100f8600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284375094965061069495505050505050565b005b341561027157fe5b6100f8600160a060020a0360043516602435610ab2565b005b60025433600160a060020a039081169116146102a65760006000fd5b600454604080519182526020820183905280517f854231545a00e13c316c82155f2b8610d638e9ff6ebc4930676f84a5af08a49a9281900390910190a160048190555b50565b60025433600160a060020a039081169116146103085760006000fd5b60025460408051600160a060020a039283168152918316602083015280517fbadc9a52979e89f78b7c58309537410c5e51d0f63a0a455efe8d61d2b474e6989281900390910190a16002805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a038381169190911790915560008054604080516020908101849052815160e060020a6302571be30281527f91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e26004820152915192909416936302571be39360248084019492938390030190829087803b15156103e957fe5b60325a03f115156103f657fe5b50505060405180519050600160a060020a0316631e83409a826000604051602001526040518263ffffffff1660e060020a0281526004018082600160a060020a0316600160a060020a03168152602001915050602060405180830381600087803b151561045f57fe5b60325a03f1151561046c57fe5b50506040805160008054600354602093840183905284517f0178b8bf00000000000000000000000000000000000000000000000000000000815260048101919091529351600160a060020a039091169450630178b8bf9360248082019493918390030190829087803b15156104dd57fe5b60325a03f115156104ea57fe5b505060408051805160035460025460e860020a62d5fa2b0284526004840191909152600160a060020a03908116602484015292519216925063d5fa2b0091604480830192600092919082900301818387803b151561054457fe5b60325a03f1151561055157fe5b5050505b50565b600054600354600254600454600154600160a060020a039485169492831692165b9091929394565b6000818152600760205260409020545b919050565b6000818152600760209081526040918290208054349081019091558251908152915183927fdb7750418f9fa390aaf85d881770065aa4adbe46343bcff4ae573754c829d9af92908290030190a25b50565b60025433600160a060020a039081169116146106025760006000fd5b60015460408051600160a060020a039283168152918316602083015280517f279875333405c968e401e3bc4e71d5f8e48728c90f4e8180ce28f74efb5669209281900390910190a16001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790555b50565b600654600554600160a060020a033016315b909192565b6004545b90565b80516001820190600080808060048510806106af5750601485115b156106ba5760006000fd5b600093505b8484101561072a57855160ff16925060618310806106e05750607a8360ff16115b80156106fc575060308360ff1610806106fc575060398360ff16115b5b801561070d57508260ff16602d14155b156107185760006000fd5b6001909501945b6001909301926106bf565b60045434101561073a5760006000fd5b866040518082805190602001908083835b6020831061076a5780518252601f19909201916020918201910161074b565b51815160209384036101000a60001901801990921691161790526040805192909401829003822060035483528282018190528451928390038501832060008054948401819052865160e060020a6302571be3028152600481018390529651929a509098509650600160a060020a0390921694506302571be393602480820194509192919082900301818787803b15156107ff57fe5b60325a03f1151561080c57fe5b505060405151600160a060020a031691909114905061082b5760006000fd5b60008054600354604080517f06ab5923000000000000000000000000000000000000000000000000000000008152600481019290925260248201869052600160a060020a03308116604484015290519216926306ab59239260648084019382900301818387803b151561089a57fe5b60325a03f115156108a757fe5b505060008054600154604080517f1896f70a00000000000000000000000000000000000000000000000000000000815260048101879052600160a060020a0392831660248201529051919092169350631896f70a9260448084019391929182900301818387803b151561091657fe5b60325a03f1151561092357fe5b50506001546040805160e860020a62d5fa2b02815260048101859052600160a060020a033381166024830152915191909216925063d5fa2b009160448082019260009290919082900301818387803b151561097a57fe5b60325a03f1151561098757fe5b505060008054604080517f5b0fc9c300000000000000000000000000000000000000000000000000000000815260048101869052600160a060020a0333811660248301529151919092169350635b0fc9c39260448084019391929182900301818387803b15156109f357fe5b60325a03f11515610a0057fe5b505060058054349081019091556006805460010190556000838152600760209081526040918290208054840190558151600160a060020a03331681529081019290925280518493507f179ef3319e6587f6efd3157b34c8b357141528074bcb03f9903589876168fa149281900390910190a260408051348152905182917fdb7750418f9fa390aaf85d881770065aa4adbe46343bcff4ae573754c829d9af919081900360200190a25b50505050505050565b60025433600160a060020a03908116911614610ace5760006000fd5b604051600160a060020a0383169082156108fc029083906000818181858888f193505050501515610aff5760006000fd5b60408051600160a060020a03841681526020810183905281517fac375770417e1cb46c89436efcf586a74d0298fee9838f66a38d40c65959ffda929181900390910190a15b50505600a165627a7a723058205c3628c01dc80233f51979d91a76cec2a25d84e86c9838d34672734ca2232b640029" }

// Get the storage value at position 0...
provider.getStorageAt("registrar.firefly.eth", 0)
// { Promise: "0x000000000000000000000000314159265dd8dbb310642f98f50c066173c1259b" }

// Get transaction count of an account...
provider.getTransactionCount("ricmoo.firefly.eth");
// { Promise: 608 }

Blocks Methods

-
provider . getBlock ( block ) Promise< Block >

Get the block from the network, where the result.transactions is a list of transaction hashes.

-
provider . getBlockWithTransactions ( block ) Promise< BlockWithTransactions >

Get the block from the network, where the result.transactions is an Array of TransactionResponse objects.

+
provider . getBlock ( block ) Promise< Block >

Get the block from the network, where the result.transactions is a list of transaction hashes.

+
provider . getBlockWithTransactions ( block ) Promise< BlockWithTransactions >

Get the block from the network, where the result.transactions is an Array of TransactionResponse objects.

Ethereum Naming Service (ENS) Methods

TODO: Explain ENS here...

-
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.

-
provider . resovleName ( name ) Promise< string >

Looks up the address of name. If the name is not owned, or does not have a Resolver configured, or the Resolver does not have an address configured, null is returned.

+
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.

+
provider . resolveName ( name ) Promise< string< Address > >

Looks up the address of name. If the name is not owned, or does not have a Resolver configured, or the Resolver does not have an address configured, null is returned.

Examples

-
Skipping JavaScript Evaluation.
+

// Reverse lookup of an ENS by address...
provider.lookupAddress("0x6fC21092DA55B392b045eD78F4732bff3C580e2c");
// { Promise: "registrar.firefly.eth" }

// Lookup an address of an ENS name...
provider.resolveName("ricmoo.firefly.eth");
// { Promise: "0x8ba1f109551bD432803012645Ac136ddd64DBA72" }

Logs Methods

-
provider . getLogs ( filter ) Promise< Array< Log > >

Returns the Array of Log matching the filter.

Keep in mind that many backends will discard old events, and that requests which are too broad may get dropped as they require too many resources to execute the query.

+
provider . getLogs ( filter ) Promise< Array< Log > >

Returns the Array of Log matching the filter.

Keep in mind that many backends will discard old events, and that requests which are too broad may get dropped as they require too many resources to execute the query.

Network Status Methods

-
provider . getNetwork ( ) Promise< Network >

Returns the Network this Provider is connected to.

-
provider . getBlockNumber ( ) Promise< number >

Returns the block number (or height) of the most recently mined block.

-
provider . getGasPrice ( ) Promise< BigNumber >

Returns a best guess of the Gas Price to use in a transaction.

+
provider . getNetwork ( ) Promise< Network >

Returns the Network this Provider is connected to.

+
provider . getBlockNumber ( ) Promise< number >

Returns the block number (or height) of the most recently mined block.

+
provider . getGasPrice ( ) Promise< BigNumber >

Returns a best guess of the Gas Price to use in a transaction.

Transactions Methods

-
provider . call ( transaction [ , blockTag = "latest" ] ) Promise< Hexstring >

Returns the result of executing the transaction, using call. A call does not require any ether, but cannot change any state. This is useful for calling gettings on Contracts.

-
provider . estimateGas ( transaction ) Promise< BigNumber >

Returns an estimate of the amount of gas that would be required to submit transaction to the network.

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 . sendTransaction ( transaction ) Promise< 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).

-
provider . waitForTransaction ( transactionHash ) Promise< TransactionReceipt >

Returns a Promise which will not resolve until transactionHash is mined.

+
provider . call ( transaction [ , blockTag = "latest" ] ) Promise< string< Hexstring > >

Returns the result of executing the transaction, using call. A call does not require any ether, but cannot change any state. This is useful for calling gettings on Contracts.

+
provider . estimateGas ( transaction ) Promise< BigNumber >

Returns an estimate of the amount of gas that would be required to submit transaction to the network.

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 . sendTransaction ( transaction ) Promise< 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).

+
provider . waitForTransaction ( transactionHash ) Promise< TransactionReceipt >

Returns a Promise which will not resolve until transactionHash is mined.

Event Emitter Methods

Explain events here...

-
provider . on ( eventName , listener ) this

Add a listener to be triggered for each eventName.

-
provider . once ( eventName , listener ) this

Add a listener to be triggered for only the next eventName, at which time it be removed.

-
provider . emit ( eventName , ...args ) boolean

Notify all listeners of eventName, 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.

-
provider . removeAllListeners ( [ eventName ] ) this

Remove all the listeners for eventName. 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.

-
provider . listeners ( eventName ) Array< Listener >

Returns the list of Listeners for eventName.

+
provider . on ( eventName , listener ) this

Add a listener to be triggered for each eventName.

+
provider . once ( eventName , listener ) this

Add a listener to be triggered for only the next eventName, at which time it be removed.

+
provider . emit ( eventName , ...args ) boolean

Notify all listeners of eventName, 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.

+
provider . removeAllListeners ( [ eventName ] ) this

Remove all the listeners for eventName. 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.

+
provider . listeners ( eventName ) Array< Listener >

Returns the list of Listeners for eventName.

Inspection Methods

-
Provider . isProvider ( object ) boolean

Returns true if and only if object is a Provider.

\ No newline at end of file +
Provider . isProvider ( object ) boolean

Returns true if and only if object is a Provider.

\ No newline at end of file diff --git a/docs/api/providers/types/README.md b/docs/api/providers/types/README.md index d28b1cb56..a582bc3a3 100644 --- a/docs/api/providers/types/README.md +++ b/docs/api/providers/types/README.md @@ -19,38 +19,166 @@ A **BlockTag** specifies a specific location in the Blockchain. * **`"latest"`** -- The most recently mined block * **`"earliest"`** -- Block #0 -* **`"pending"`** -- The block currently being prepared for mining; not all operations support this BlockTag +* **`"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 -### Network +### EventType + + +And **EventType** can be any of the following. + + + +* ***string*** -- TODO... +* ***Array> | Array>>>*** -- TODO... +* ***[EventFilter](./)*** -- TODO... + + +Network +------- A **Network** represents an Etherem network. +#### *network* . **name** **=>** *string* -* **name** -- The human-readable name of the network -* **chainId** -- The Chain ID of the network -* **ensAddress** -- The address at which the ENS registry is deployed - - -Blocks ------- +The human-readable name of the network, such as `homestead`. If the network +name is unknown, this will be `"unknown"`. -### Block + +#### *network* . **chainId** **=>** *number* + +The Chain ID of the network. + + + + +#### *network* . **ensAddress** **=>** *string< [Address](../../utils/address) >* + +The address at which the ENS registry is deployed on this network. + + + + +Block +----- + + + +#### *block* . **hash** **=>** *string< [DataHexstring](../../utils/bytes)< 32 > >* + +The hash of this block. + + + + +#### *block* . **parentHash** **=>** *string< [DataHexstring](../../utils/bytes)< 32 > >* + +The hash of the previous block. + + + + +#### *block* . **number** **=>** *number* + +The height (number) of this block. + + + + +#### *block* . **timestamp** **=>** *number* + +The timestamp of this block. + + + + +#### *block* . **nonce** **=>** *string< [DataHexstring](../../utils/bytes) >* + +The nonce used as part of the proof-of-work to mine this block. + +This property is generally of little interest developers. + + + + +#### *block* . **difficulty** **=>** *number* + +The difficulty target required to be met by the miner of the block. + +This property is generally of little interest developers. + + + + +#### *block* . **gasLimit** **=>** *[BigNumber](../../utils/bignumber)* + +The maximum amount of gas that this block was permitted to use. This +is a value that can be voted up or voted down by miners and is used +to automatically adjust the bandwidth requirements of the network. + +This property is generally of little interest developers. + + + + +#### *block* . **gasUsed** **=>** *[BigNumber](../../utils/bignumber)* + +The total amount of gas used by all transactions in this block. + + + + +#### *block* . **miner** **=>** *string* + +The coinbase address of this block, which indicates the address the +miner that mined this block would like the subsidy reward to go to. + + + + +#### *block* . **extraData** **=>** *string* + +This is extra data a miner may choose to include when mining a block. + +This property is generally of little interest developers. + + + + +### Block (with transaction hashes) + + +Often only the hashes of the transactions included in a block are needed, +so by default a block only contains this information, as it is +substantially less data. + + +#### *block* . **transactions** **=>** *Array< string< [DataHexstring](../../utils/bytes)< 32 > > >* + +A list of the transactions hashes for each transaction this block +includes. -TODO ### BlockWithTransactions -TODO +If all transactions for a block are needed, this object instead includes +the full details on each transaction. + + +#### *block* . **transactions** **=>** *Array< [TransactionResponse](./) >* + +A list of the transactions this block includes. + + Events and Logs @@ -61,31 +189,127 @@ Events and Logs ### EventFilter -TODO + +#### *filter* . **address** **=>** *string< [Address](../../utils/address) >* + +The address to filter by, or `null` to match any address. -### EventType -TODO +#### *filter* . **topics** **=>** *Array< string< [DataHexstring](../../utils/bytes)< 32 > >|Array< string< [DataHexstring](../../utils/bytes)< 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. + + ### Filter -TODO + +#### *filter* . **fromBlock** **=>** *[BlockTag](./)* + +The starting block (inclusive) to search for logs matching the filter criteria. + + + + +#### *filter* . **toBlock** **=>** *[BlockTag](./)* + +The end block (inclusive) to search for logs matching the filter criteria. + + ### FilterByBlockHash -TODO + +#### *filter* . **blockHash** **=>** *string< [DataHexstring](../../utils/bytes)< 32 > >* + +The specific block (by its block hash) to search for logs matching the filter criteria. + + ### Log -A network... + +#### *log* . **blockNumber** **=>** *number* + +The block height (number) of the block including the transaction of this log. + + + + +#### *log* . **blockHash** **=>** *string< [DataHexstring](../../utils/bytes)< 32 > >* + +The block hash of the block including the transaction of this log. + + + + +#### *log* . **removed** **=>** *boolean* + +During a re-org, if a transaction is orphaned, this will be set to true +to indicate the Log entry has been removed; it will likely be emitted +again in the near future when another block is mined with the transaction +that triggered this log, but keep in mind the values may change. + + + + +#### *log* . **transactionLogIndex** **=>** *number* + +The index of this log in the transaction. + + + + +#### *log* . **address** **=>** *string< [Address](../../utils/address) >* + +The address of the contract that generated this log. + + + + +#### *log* . **data** **=>** *string< [DataHexstring](../../utils/bytes) >* + +The data included in this log. + + + + +#### *log* . **topics** **=>** *Array< string< [DataHexstring](../../utils/bytes)< 32 > > >* + +The list of topics (indexed properties) for this log. + + + + +#### *log* . **transactionHash** **=>** *string< [DataHexstring](../../utils/bytes)< 32 > >* + +The transaction hash of the transaction of this log. + + + + +#### *log* . **transactionIndex** **=>** *number* + +The index of the transaction in the block of the transaction of this log. + + + + +#### *log* . **logIndex** **=>** *number* + +The index of this log across all logs in the entire **block**. + + Transactions @@ -99,33 +323,263 @@ Transactions A transaction request describes a transaction that is to be sent to the network or otherwise processed. -It contains the fields: - -* **to** --- target address -* **from** --- target address -* **nonce** --- target address -* **gasLimit** --- target address -* **gasPrice** --- target address -* **data** --- target address -* **value** --- target address -* **chainId** --- target address - All fields are optional and may be a promise which resolves to the required type. +#### *transactionRequest* . **to** **=>** *string|Promise< string >* + +The address (or ENS name) this transaction it to. + + + + +#### *transactionRequest* . **from** **=>** *string< [Address](../../utils/address) >|Promise< string< [Address](../../utils/address) > >* + +The address this transaction is from. + + + + +#### *transactionRequest* . **nonce** **=>** *number|Promise< number >* + +The nonce for this transaction. This should be set to the number of +transactions ever sent **from** this address. + + + + +#### *transactionRequest* . **gasLimit** **=>** *[BigNumber](../../utils/bignumber)|Promise< [BigNumber](../../utils/bignumber) >* + +The maximum amount of gas this transaction is permitted to use. + + + + +#### *transactionRequest* . **gasPrice** **=>** *[BigNumber](../../utils/bignumber)|Promise< [BigNumber](../../utils/bignumber) >* + +The price (in wei) per unit of gas this transaction will pay. + + + + +#### *transactionRequest* . **data** **=>** *[DataHexstring](../../utils/bytes)|Promise< [DataHexstring](../../utils/bytes) >* + +The transaction data. + + + + +#### *transactionRequest* . **value** **=>** *[BigNumber](../../utils/bignumber)|Promise< [BigNumber](../../utils/bignumber) >* + +The amount (in wei) this transaction is sending. + + + + +#### *transactionRequest* . **chainId** **=>** *number|Promise< number >* + +The chain ID this transaction is authorized on, as specified by +[EIP-155](https://eips.ethereum.org/EIPS/eip-155). + +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. + + + + ### TransactionResponse -A **TransactionResponse** .. +A **TransactionResponse** includes all properties of a [Transaction](../../utils/transactions) as well as several +properties that are useful once it has been mined. + + +#### *transaction* . **blockNumber** **=>** *number* + +The number ("height") of the block this transaction was mined in. If the block has not been mined, +this is `null`. + + + + +#### *transaction* . **blockHash** **=>** *string< [DataHexstring](../../utils/bytes)< 32 > >* + +The hash of the block this transaction was mined in. If the block has not been mined, +this is `null`. + + + + +#### *transaction* . **timestamp** **=>** *number* + +The timestamp of the block this transaction was mined in. If the block has not been mined, +this is `null`. + + + + +#### *transaction* . **confirmations** **=>** *number* + +The number of blocks that have been mined (including the initial block) since this +transaction was mined. + + + + +#### *transaction* . **raw** **=>** *string< [DataHexstring](../../utils/bytes) >* + +The serialized transaction. + + + + +#### *transaction* . **wait** ( [ confirmations=1 ] ) **=>** *Promise< [TransactionReceipt](./) >* + +Wait for *confirmations*. If 0, and the transaction has not been mined, +`null` is returned. + + ### TransactionReceipt -TODO + +#### *receipt* . **to** **=>** *string< [Address](../../utils/address) >* + +The address this transaction is to. This is `null` if the the +transaction was an **init transaction**, used to deploy a contract. + + + + +#### *receipt* . **from** **=>** *string< [Address](../../utils/address) >* + +The address this transaction is from. + + + + +#### *receipt* . **contractAddress** **=>** *string< [Address](../../utils/address) >* + +If this transaction has a ``null` to address, it is an **init transaction** +used to deploy a contract, in which case this is the address created by that +contract. + +To compute a contract address, the [getContractAddress](../../utils/address) +utility function can also be used with a [TransactionResponse](./) +object, which requires the transaction nonce and the address of the sender. + + + + +#### *receipt* . **transactionIndex** **=>** *number* + +The index of this transaction in the list of transactions included in +the block this transaction was mined in. + + + + +#### *receipt* . **root** **=>** *string* + +The intermediate state root of a receipt. + +Only transactions included in blocks **before** the [Byzantium Hard Fork](https://eips.ethereum.org/EIPS/eip-609) +have this property, as it was replaced by the `status` property. + +The property is generally of little use to developers. At the time +it could be used to verify a state transition with a fraud-proof +only considering the single transaction; without it the full block +must be considered. + + + + +#### *receipt* . **gasUsed** **=>** *[BigNumber](../../utils/bignumber)* + +The amount of gas actually used by this transaction. + + + + +#### *receipt* . **logsBloom** **=>** *string< [DataHexstring](../../utils/bytes) >* + +A [bloom-filter](https://en.wikipedia.org/wiki/Bloom_filter), which +incldues all the addresses and topics included in any log in this +transaction. + + + + +#### *receipt* . **blockHash** **=>** *string< [DataHexstring](../../utils/bytes)< 32 > >* + +The block hash of the block that this transaction was included in. + + + + +#### *receipt* . **transactionHash** **=>** *string< [DataHexstring](../../utils/bytes)< 32 > >* + +The transaction hash of this transaction. + + + + +#### *receipt* . **logs** **=>** *Array< [Log](./) >* + +All the logs emitted by this transaction. + + + + +#### *receipt* . **blockNumber** **=>** *number* + +The block height (number) of the block that this transaction was +included in. + + + + +#### *receipt* . **confirmations** **=>** *number* + +The number of blocks that have been mined since this transaction, +including the actual block it was mined in. + + + + +#### *receipt* . **cumulativeGasUsed** **=>** *[BigNumber](../../utils/bignumber)* + +For the block this transaction was included in, this is the sum of the +gas used used by each transaction in the ordered list of transactions +up to (and including) this transaction. + +This is generally of little interest to developers. + + + + +#### *receipt* . **byzantium** **=>** *boolean* + +This is true if the block is in a [post-Byzantium Hard Fork](https://eips.ethereum.org/EIPS/eip-609) +block. + + + + +#### *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](https://eips.ethereum.org/EIPS/eip-609) +have this property. + + ----- -**Content Hash:** f6d5ea85b1ddef3a5b5bc0745984620507c001cf7d898c7842e006ddcd2b056b \ No newline at end of file +**Content Hash:** ef41b33439a40aa374a5af245d4320705c3a647c86f90d9bb8c127503e2477c9 \ No newline at end of file diff --git a/docs/api/providers/types/index.html b/docs/api/providers/types/index.html index 96c902f4f..474c4f1ac 100644 --- a/docs/api/providers/types/index.html +++ b/docs/api/providers/types/index.html @@ -1,33 +1,92 @@ -Types
+Types

Types

BlockTag

-

A BlockTag specifies a specific location in the Blockchain.

  • "latest" – The most recently mined block
  • "earliest" – Block #0
  • "pending" – The block currently being prepared for mining; not all operations support this BlockTag
  • number – The block at this height
  • a negative number – The block this many blocks ago
-

Network

-

A Network represents an Etherem network.

  • name – The human-readable name of the network
  • chainId – The Chain ID of the network
  • ensAddress – The address at which the ENS registry is deployed
-

Blocks

+

A BlockTag specifies a specific location in the Blockchain.

  • "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
+

EventType

+

And EventType can be any of the following.

+

Network

+

A Network represents an Etherem network.

+
network . name string

The human-readable name of the network, such as homestead. If the network name is unknown, this will be "unknown".

+
network . chainId number

The Chain ID of the network.

+
network . ensAddress string< Address >

The address at which the ENS registry is deployed on this network.

+

Block

-

Block

-

TODO

-

BlockWithTransactions

-

TODO

+
block . hash string< DataHexstring< 32 > >

The hash of this block.

+
block . parentHash string< DataHexstring< 32 > >

The hash of the previous block.

+
block . number number

The height (number) of this block.

+
block . timestamp number

The timestamp of this block.

+
block . nonce string< DataHexstring >

The nonce used as part of the proof-of-work to mine this block.

This property is generally of little interest developers.

+
block . difficulty number

The difficulty target required to be met by the miner of the block.

This property is generally of little interest developers.

+
block . gasLimit BigNumber

The maximum amount of gas that this block was permitted to use. This is a value that can be voted up or voted down by miners and is used to automatically adjust the bandwidth requirements of the network.

This property is generally of little interest developers.

+
block . gasUsed BigNumber

The total amount of gas used by all transactions in this block.

+
block . miner string

The coinbase address of this block, which indicates the address the miner that mined this block would like the subsidy reward to go to.

+
block . extraData string

This is extra data a miner may choose to include when mining a block.

This property is generally of little interest developers.

+

Block (with transaction hashes)

+

Often only the hashes of the transactions included in a block are needed, so by default a block only contains this information, as it is substantially less data.

+
block . transactions Array< string< DataHexstring< 32 > > >

A list of the transactions hashes for each transaction this block includes.

+

BlockWithTransactions inherits Block

+

If all transactions for a block are needed, this object instead includes the full details on each transaction.

+
block . transactions Array< TransactionResponse >

A list of the transactions this block includes.

Events and Logs

-

EventFilter

-

TODO

-

EventType

-

TODO

-

Filter

-

TODO

-

FilterByBlockHash

-

TODO

+

EventFilter

+ +
filter . address string< Address >

The address to filter by, or null to match any address.

+
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.

+

Filter inherits EventFilter

+ +
filter . fromBlock BlockTag

The starting block (inclusive) to search for logs matching the filter criteria.

+
filter . toBlock BlockTag

The end block (inclusive) to search for logs matching the filter criteria.

+

FilterByBlockHash inherits EventFilter

+ +
filter . blockHash string< DataHexstring< 32 > >

The specific block (by its block hash) to search for logs matching the filter criteria.

Log

-

A network...

+ +
log . blockNumber number

The block height (number) of the block including the transaction of this log.

+
log . blockHash string< DataHexstring< 32 > >

The block hash of the block including the transaction of this log.

+
log . removed boolean

During a re-org, if a transaction is orphaned, this will be set to true to indicate the Log entry has been removed; it will likely be emitted again in the near future when another block is mined with the transaction that triggered this log, but keep in mind the values may change.

+
log . transactionLogIndex number

The index of this log in the transaction.

+
log . address string< Address >

The address of the contract that generated this log.

+
log . data string< DataHexstring >

The data included in this log.

+
log . topics Array< string< DataHexstring< 32 > > >

The list of topics (indexed properties) for this log.

+
log . transactionHash string< DataHexstring< 32 > >

The transaction hash of the transaction of this log.

+
log . transactionIndex number

The index of the transaction in the block of the transaction of this log.

+
log . logIndex number

The index of this log across all logs in the entire block.

Transactions

TransactionRequest

-

A transaction request describes a transaction that is to be sent to the network or otherwise processed.

It contains the fields:

  • to — target address
  • from — target address
  • nonce — target address
  • gasLimit — target address
  • gasPrice — target address
  • data — target address
  • value — target address
  • chainId — target address

All fields are optional and may be a promise which resolves to the required type.

-

TransactionResponse

-

A TransactionResponse ..

-

TransactionReceipt

-

TODO

\ No newline at end of file +

A transaction request describes a transaction that is to be sent to the network or otherwise processed.

All fields are optional and may be a promise which resolves to the required type.

+
transactionRequest . to string  |  Promise< string >

The address (or ENS name) this transaction it to.

+
transactionRequest . from string< Address >  |  Promise< string< Address > >

The address this transaction is from.

+
transactionRequest . nonce number  |  Promise< number >

The nonce for this transaction. This should be set to the number of transactions ever sent from this address.

+
transactionRequest . gasLimit BigNumber  |  Promise< BigNumber >

The maximum amount of gas this transaction is permitted to use.

+
transactionRequest . gasPrice BigNumber  |  Promise< BigNumber >

The price (in wei) per unit of gas this transaction will pay.

+
transactionRequest . data DataHexstring  |  Promise< DataHexstring >

The transaction data.

+
transactionRequest . value BigNumber  |  Promise< BigNumber >

The amount (in wei) this transaction is sending.

+
transactionRequest . chainId number  |  Promise< number >

The chain ID this transaction is authorized on, as specified by EIP-155.

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.

+

TransactionResponse inherits Transaction

+

A TransactionResponse includes all properties of a Transaction as well as several properties that are useful once it has been mined.

+
transaction . blockNumber number

The number ("height") of the block this transaction was mined in. If the block has not been mined, this is null.

+
transaction . blockHash string< DataHexstring< 32 > >

The hash of the block this transaction was mined in. If the block has not been mined, this is null.

+
transaction . timestamp number

The timestamp of the block this transaction was mined in. If the block has not been mined, this is null.

+
transaction . confirmations number

The number of blocks that have been mined (including the initial block) since this transaction was mined.

+
transaction . raw string< DataHexstring >

The serialized transaction.

+
transaction . wait ( [ confirmations = 1 ] ) Promise< TransactionReceipt >

Wait for confirmations. If 0, and the transaction has not been mined, null is returned.

+

TransactionReceipt

+ +
receipt . to string< Address >

The address this transaction is to. This is null if the the transaction was an init transaction, used to deploy a contract.

+
receipt . from string< Address >

The address this transaction is from.

+
receipt . contractAddress string< Address >

If this transaction has a ``null` to address, it is an init transaction used to deploy a contract, in which case this is the address created by that contract.

To compute a contract address, the getContractAddress utility function can also be used with a TransactionResponse object, which requires the transaction nonce and the address of the sender.

+
receipt . transactionIndex number

The index of this transaction in the list of transactions included in the block this transaction was mined in.

+
receipt . root string

The intermediate state root of a receipt.

Only transactions included in blocks before the Byzantium Hard Fork have this property, as it was replaced by the status property.

The property is generally of little use to developers. At the time it could be used to verify a state transition with a fraud-proof only considering the single transaction; without it the full block must be considered.

+
receipt . gasUsed BigNumber

The amount of gas actually used by this transaction.

+
receipt . logsBloom string< DataHexstring >

A bloom-filter, which incldues all the addresses and topics included in any log in this transaction.

+
receipt . blockHash string< DataHexstring< 32 > >

The block hash of the block that this transaction was included in.

+
receipt . transactionHash string< DataHexstring< 32 > >

The transaction hash of this transaction.

+
receipt . logs Array< Log >

All the logs emitted by this transaction.

+
receipt . blockNumber number

The block height (number) of the block that this transaction was included in.

+
receipt . confirmations number

The number of blocks that have been mined since this transaction, including the actual block it was mined in.

+
receipt . cumulativeGasUsed BigNumber

For the block this transaction was included in, this is the sum of the gas used used by each transaction in the ordered list of transactions up to (and including) this transaction.

This is generally of little interest to developers.

+
receipt . byzantium boolean

This is true if the block is in a post-Byzantium Hard Fork block.

+
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 have this property.

\ No newline at end of file diff --git a/docs/api/signer/README.md b/docs/api/signer/README.md index d7209abe5..a4da80dd2 100644 --- a/docs/api/signer/README.md +++ b/docs/api/signer/README.md @@ -9,17 +9,41 @@ Signers ======= -Tra la la... +A Signer represents... Signer ------ +The **Signer** class is abstract and cannot be directly instaniated. Instead +use one of the concreate sub-classes, such as the [Wallet](./), [VoidSigner](./) +or [JsonRpcSigner](../providers/jsonrpc-provider). + #### *signer* . **connect** ( provider ) **=>** *[Signer](./)* -TODO +Sub-classes **must** implement this, however they may simply throw an error +if changing providers is not supported. + + + + +#### *signer* . **getAddress** ( ) **=>** *Promise< string< [Address](../utils/address) > >* + +Returns a Promise that resolves to the account address. + +This is a Promise so that a **Signer** can be designed around an +asynchronous source, such as hardware wallets. + +Sub-classes **must** implement this. + + + + +#### *Signer* . **isSigner** ( object ) **=>** *boolean* + +Returns true if an only if *object* is a **Signer**. @@ -30,44 +54,311 @@ TODO #### *signer* . **getBalance** ( [ blockTag="latest" ] ) **=>** *Promise< [BigNumber](../utils/bignumber) >* -TODO +Returns the balance of this wallet at *blockTag*. + + + + +#### *signer* . **getChainId** ( ) **=>** *Promise< number >* + +Returns ths chain ID this wallet is connected to. + + + + +#### *signer* . **getGasPrice** ( ) **=>** *Promise< [BigNumber](../utils/bignumber) >* + +Returns the current gas price. #### *signer* . **getTransactionCount** ( [ blockTag="latest" ] ) **=>** *Promise< number >* -TODO +Returns the number of transactions this account has ever sent. This +is the value required to be included in transactions as the `nonce`. -Wallet inherits Signer ----------------------- +#### *signer* . **call** ( transactionRequest ) **=>** *Promise< string< [DataHexstring](../utils/bytes) > >* + +Returns the result of calling using the *transactionRequest*, with this +account address being used as the `from` field. + + + + +#### *signer* . **estimateGas** ( transactionRequest ) **=>** *Promise< [BigNumber](../utils/bignumber) >* + +Returns the result of estimating the cost to send the *transactionRequest*, +with this account address being used as the `from` field. + + + + +#### *signer* . **resolveName** ( ensName ) **=>** *Promise< string< [Address](../utils/address) > >* + +Returns the address associated with the *ensName*. + + + + +### Signing + + + +#### *signer* . **signMessage** ( message ) **=>** *Promise< string< [FlatSignature](../utils/bytes) > >* + +This returns a Promise which resolves to the [Flat-Format Signature](../utils/bytes) +of *message*. + +Sub-classes **must** implement this, however they may throw if signing a +message is not supported. + + + + +#### Note + +If *message* is a string, it is **treated as a string** and +converted to its representation in UTF8 bytes. + +**If and only if** a message is a [Bytes](../utils/bytes) will it be treated as +binary data. + +For example, the string `"0x1234"` is 6 characters long (and in +this case 6 bytes long). This is **not** equivalent to the array +`[ 0x12, 0x34 ]`, which is 2 bytes long. + +A common case is to sign a hash. In this case, if the hash is a +string, it **must** be converted to an array first, using the +[arrayify](../utils/bytes) utility function. + + + + + +#### *signer* . **signTransaction** ( transactionRequest ) **=>** *Promise< string< [DataHexstring](../utils/bytes) > >* + +Returns a Promise which resolves to the signed transaction of the +*transactionRequest*. This method does not populate any missing fields. + +Sub-classes **must** implement this, however they may throw if signing a +transaction is not supported. + + + + +#### *signer* . **sendTransaction** ( transactionRequest ) **=>** *Promise< [TransactionResponse](../providers/types) >* + +This method populates the transactionRequest with missing fields, using +[populateTransaction](./) and returns a Promise which resolves to the transaction. + +Sub-classes **must** implement this, however they may throw if signing a +transaction is not supported. + + + + +### Sub-Classes + + +It is very important that all important properties of a **Signer** are +**immutable**. Since Ethereum is very asynchronous and deals with critical +data (such as ether and other potentially valuable crypto assets), keeping +properties such as the *provider* and *address* static helps prevent +serious issues. + +A sub-class **must** call `super()`. + + +#### *signer* . **checkTransaction** ( transactionRequest ) **=>** *[TransactionRequest](../providers/types)* + +This is generally not required to be overridden, but may needed to provide +custom behaviour in sub-classes. + +This should return a **copy** of the *transactionRequest*, with any properties +needed by `call`, `estimateGas` and `populateTransaction` (which is used +by sendTransaction). It should also throw an error if any unknown key is specified. + +The default implementation checks only valid [TransactionRequest](../providers/types) properties +exist and adds `from` to the transaction if it does not exist, or verifies it is equal +to the Signer's address if it does exist. + + + + +#### *signer* . **populateTransaction** ( transactionRequest ) **=>** *Promise< [TransactionRequest](../providers/types) >* + +This is generally not required to be overridden, but may needed to provide +custom behaviour in sub-classes. + +This should return a **copy** of *transactionRequest*, follow the same procedure +as `checkTransaction` and fill in any properties required for sending a transaction. +The result should have all promises resolved; if needed the [resolveProperties](../utils/properties) +utility function can be used for this. + +The default implementation calls `checkTransaction` and resolves to if it is an +ENS name, adds `gasPrice`, `nonce`, `gasLimit` and `chainId` based on the +related operations on Signer. + + + + +Wallet +------ The Wallet class inherits [Signer](./) and can sign transactions and messages using a private key as a standard Externally Owned Account (EOA). -### Creating an Instance - - - #### **new** *ethers* . **Wallet** ( privateKey [ , provider ] ) -TODO +Create a new Wallet instance for *privateKey* and optionally +connected to the *provider*. -#### *Wallet* . **fromEncryptedJson** ( json , password ) +#### *ethers* . *Wallet* . **createRandom** ( [ options={} ] ) **=>** *[Wallet](./)* -TODO +Returns a new Wallet with a random private key, generated from +cryptographically secure entropy sources. If the current environment +does not have a secure entropy source, an error is thrown. + + + + +#### *ethers* . *Wallet* . **fromEncryptedJson** ( json , password [ , progress ] ) **=>** *Promise< [Wallet](./) >* + +Create an instance from an encrypted JSON wallet. If *progress* +is provided it will be called during decryption with a value between 0 and +1 indicating the progress towards completion. + + + + +#### *ethers* . *Wallet* . **fromMnemonic** ( mnemonic [ , path , [ wordlist ] ] ) **=>** *[Wallet](./)* + +Create an instance from a mnemonic phrase. + +If path is not specified, the Ethereum default path is used (i.e. m/44'/60'/0'/0/0). + +If wordlist is not specified, the English Wordlist is used. + + + + +### Properties + + + +#### *wallet* . **address** **=>** *string< [Address](../utils/address) >* + +The address for the account this Wallet represents. + + + + +#### *wallet* . **provider** **=>** *[Provider](../providers/provider)* + +The provider this wallet is connected to, which will ge used for any [Blockchain Methods](./) +methods. This can be null. + + + + +#### Note + +A **Wallet** instance is immuatable, so if you wish to change the Provider, you +may use the [connect](./) method to create a new instance connected +to the desired provider. + + + + +#### *wallet* . **publicKey** **=>** *string< [DataHexstring](../utils/bytes)< 65 > >* + +The uncompressed public key for this Wallet represents. + + + + +### Methods + + + +#### *wallet* . **encrypt** ( password , [ options={} , [ progress ] ] ) **=>** *Promise< string >* + +Encrypt the wallet using *password* returning a Promise which resolves +to a JSON wallet. + + + + +VoidSigner +---------- + + +A **VoidSigner** is a simple Signer which cannot sign. + +It is useful as a read-only signer, when an API requires a +Signer as a parameter, but it is known only read-only operations +will be carried. + +For example, the `call` operation will automatically have the +provided address passed along during the execution. + + +#### **new** *ethers* . **VoidSigner** ( address ) **=>** *[VoidSigner](./)* + +Create a new instance of a **VoidSigner** for *address*. + + + + +#### *voidSigner* . **address** **=>** *string< [Address](../utils/address) >* + +The address of this **VoidSigner**. + + + + +ExternallyOwnedAccount +---------------------- + + + +#### *eoa* . **address** **=>** *string< [Address](../utils/address) >* + +The [Address](../utils/address) of this EOA. + + + + +#### *eoa* . **privateKey** **=>** *string< [DataHexstring](../utils/bytes)< 32 > >* + +The privateKey of this EOA + + + + +#### *eoa* . **mnemonic** **=>** *string* + +*Optional*. The account HD mnemonic, if it has one and can be determined. + + + + +#### *eoa* . **path** **=>** *string* + +*Optional*. The account HD path, if it has one and can be determined. ----- -**Content Hash:** 62c0d9640e683e41970dc1c779bd3b59ed08c27d99e15f6b51e7bae31ac1975e \ No newline at end of file +**Content Hash:** 0d8eb5d3cf69da2ecac958fba6a88d9f4d1aa6c6545354a2b00ccee770832c96 \ No newline at end of file diff --git a/docs/api/signer/index.html b/docs/api/signer/index.html index 0eb1955fe..518891468 100644 --- a/docs/api/signer/index.html +++ b/docs/api/signer/index.html @@ -1,16 +1,53 @@ -Signer
+Signer

Signers

-

Tra la la...

-

Signer

+

A Signer represents...

+

Signer

+

The Signer class is abstract and cannot be directly instaniated. Instead use one of the concreate sub-classes, such as the Wallet, VoidSigner or JsonRpcSigner.

+
signer . connect ( provider ) Signer

Sub-classes must implement this, however they may simply throw an error if changing providers is not supported.

+
signer . getAddress ( ) Promise< string< Address > >

Returns a Promise that resolves to the account address.

This is a Promise so that a Signer can be designed around an asynchronous source, such as hardware wallets.

Sub-classes must implement this.

+
Signer . isSigner ( object ) boolean

Returns true if an only if object is a Signer.

+

Blockchain Methods

-
signer . connect ( provider ) Signer

TODO

-

Blockchain Methods

+
signer . getBalance ( [ blockTag = "latest" ] ) Promise< BigNumber >

Returns the balance of this wallet at blockTag.

+
signer . getChainId ( ) Promise< number >

Returns ths chain ID this wallet is connected to.

+
signer . getGasPrice ( ) Promise< BigNumber >

Returns the current gas price.

+
signer . getTransactionCount ( [ blockTag = "latest" ] ) Promise< number >

Returns the number of transactions this account has ever sent. This is the value required to be included in transactions as the nonce.

+
signer . call ( transactionRequest ) Promise< string< DataHexstring > >

Returns the result of calling using the transactionRequest, with this account address being used as the from field.

+
signer . estimateGas ( transactionRequest ) Promise< BigNumber >

Returns the result of estimating the cost to send the transactionRequest, with this account address being used as the from field.

+
signer . resolveName ( ensName ) Promise< string< Address > >

Returns the address associated with the ensName.

+

Signing

-
signer . getBalance ( [ blockTag = "latest" ] ) Promise< BigNumber >

TODO

-
signer . getTransactionCount ( [ blockTag = "latest" ] ) Promise< number >

TODO

-

Wallet inherits Signer

+
signer . signMessage ( message ) Promise< string< FlatSignature > >

This returns a Promise which resolves to the Flat-Format Signature of message.

Sub-classes must implement this, however they may throw if signing a message is not supported.

+
Note

If message is a string, it is treated as a string and converted to its representation in UTF8 bytes.

If and only if a message is a Bytes will it be treated as binary data.

For example, the string "0x1234" is 6 characters long (and in this case 6 bytes long). This is not equivalent to the array [ 0x12, 0x34 ], which is 2 bytes long.

A common case is to sign a hash. In this case, if the hash is a string, it must be converted to an array first, using the arrayify utility function.

+ +
signer . signTransaction ( transactionRequest ) Promise< string< DataHexstring > >

Returns a Promise which resolves to the signed transaction of the transactionRequest. This method does not populate any missing fields.

Sub-classes must implement this, however they may throw if signing a transaction is not supported.

+
signer . sendTransaction ( transactionRequest ) Promise< TransactionResponse >

This method populates the transactionRequest with missing fields, using populateTransaction and returns a Promise which resolves to the transaction.

Sub-classes must implement this, however they may throw if signing a transaction is not supported.

+

Sub-Classes

+

It is very important that all important properties of a Signer are immutable. Since Ethereum is very asynchronous and deals with critical data (such as ether and other potentially valuable crypto assets), keeping properties such as the provider and address static helps prevent serious issues.

A sub-class must call super().

+
signer . checkTransaction ( transactionRequest ) TransactionRequest

This is generally not required to be overridden, but may needed to provide custom behaviour in sub-classes.

This should return a copy of the transactionRequest, with any properties needed by call, estimateGas and populateTransaction (which is used by sendTransaction). It should also throw an error if any unknown key is specified.

The default implementation checks only valid TransactionRequest properties exist and adds from to the transaction if it does not exist, or verifies it is equal to the Signer's address if it does exist.

+
signer . populateTransaction ( transactionRequest ) Promise< TransactionRequest >

This is generally not required to be overridden, but may needed to provide custom behaviour in sub-classes.

This should return a copy of transactionRequest, follow the same procedure as checkTransaction and fill in any properties required for sending a transaction. The result should have all promises resolved; if needed the resolveProperties utility function can be used for this.

The default implementation calls checkTransaction and resolves to if it is an ENS name, adds gasPrice, nonce, gasLimit and chainId based on the related operations on Signer.

+

The Wallet class inherits Signer and can sign transactions and messages using a private key as a standard Externally Owned Account (EOA).

-

Creating an Instance

+
new ethers . Wallet ( privateKey [ , provider ] )

Create a new Wallet instance for privateKey and optionally connected to the provider.

+
ethers . Wallet . createRandom ( [ options = {} ] ) Wallet

Returns a new Wallet with a random private key, generated from cryptographically secure entropy sources. If the current environment does not have a secure entropy source, an error is thrown.

+
ethers . Wallet . fromEncryptedJson ( json , password [ , progress ] ) Promise< Wallet >

Create an instance from an encrypted JSON wallet. If progress is provided it will be called during decryption with a value between 0 and 1 indicating the progress towards completion.

+
ethers . Wallet . fromMnemonic ( mnemonic [ , path , [ wordlist ] ] ) Wallet

Create an instance from a mnemonic phrase.

If path is not specified, the Ethereum default path is used (i.e. m/44'/60'/0'/0/0).

If wordlist is not specified, the English Wordlist is used.

+

Properties

-
new ethers . Wallet ( privateKey [ , provider ] )

TODO

-
Wallet . fromEncryptedJson ( json , password )

TODO

\ No newline at end of file +
wallet . address string< Address >

The address for the account this Wallet represents.

+
wallet . provider Provider

The provider this wallet is connected to, which will ge used for any Blockchain Methods methods. This can be null.

+
Note

A Wallet instance is immuatable, so if you wish to change the Provider, you may use the connect method to create a new instance connected to the desired provider.

+
wallet . publicKey string< DataHexstring< 65 > >

The uncompressed public key for this Wallet represents.

+

Methods

+ +
wallet . encrypt ( password , [ options = {} , [ progress ] ] ) Promise< string >

Encrypt the wallet using password returning a Promise which resolves to a JSON wallet.

+

VoidSigner inherits Signer

+

A VoidSigner is a simple Signer which cannot sign.

It is useful as a read-only signer, when an API requires a Signer as a parameter, but it is known only read-only operations will be carried.

For example, the call operation will automatically have the provided address passed along during the execution.

+
new ethers . VoidSigner ( address ) VoidSigner

Create a new instance of a VoidSigner for address.

+
voidSigner . address string< Address >

The address of this VoidSigner.

+

ExternallyOwnedAccount

+ +
eoa . address string< Address >

The Address of this EOA.

+
eoa . privateKey string< DataHexstring< 32 > >

The privateKey of this EOA

+
eoa . mnemonic string

Optional. The account HD mnemonic, if it has one and can be determined.

+
eoa . path string

Optional. The account HD path, if it has one and can be determined.

\ No newline at end of file diff --git a/docs/api/utils/README.md b/docs/api/utils/README.md index 0ba1d965e..e9f0dcde8 100644 --- a/docs/api/utils/README.md +++ b/docs/api/utils/README.md @@ -14,6 +14,15 @@ are also quite useful for application developers. * [Addresses](address) + * [Address Formats](address) + * [Functions](address) +* [Application Binary Interface](abi) + * [Formats](abi) + * [Fragment](abi) + * [ConstructorFragment](abi) + * [EventFragment](abi) + * [FunctionFragment](abi) + * [ParamType](abi) * [BigNumber](bignumber) * [Types](bignumber) * [Creating Instances](bignumber) @@ -34,7 +43,7 @@ are also quite useful for application developers. * [Units](display-logic) * [Functions](display-logic) * [FixedNumber](fixednumber) - * [Types](fixednumber) + * [FixedFormat](fixednumber) * [Creating Instances](fixednumber) * [Properties](fixednumber) * [Methods](fixednumber) @@ -45,8 +54,13 @@ are also quite useful for application developers. * [Strings](strings) * [Bytes32String](strings) * [UTF-8 Strings](strings) + * [UnicodeNormalizationForm](strings) + * [Custom UTF-8 Error Handling](strings) +* [Transactions](transactions) + * [Types](transactions) + * [Functions](transactions) ----- -**Content Hash:** ae9deb0419f2da1644ae9588d27ecc475961b741fa9d7b27b2cf13ddf62d50b6 \ No newline at end of file +**Content Hash:** 87e3535244311d1d85bda676c07cc903e6e0fe7d4c7207943dcf2e72bc33e3d9 \ No newline at end of file diff --git a/docs/api/utils/abi/README.md b/docs/api/utils/abi/README.md new file mode 100644 index 000000000..e63053c66 --- /dev/null +++ b/docs/api/utils/abi/README.md @@ -0,0 +1,399 @@ +----- + +Documentation: [html](https://docs-beta.ethers.io/) + +----- + + +Application Binary Interface +============================ + + +Explain an ABI. + + +Formats +------- + + + +### JSON String ABI (Solidity Output JSON) + + +The **JSON ABI Format** is the format that is +[output from the Solidity compiler](https://solidity.readthedocs.io/en/v0.6.0/using-the-compiler.html#output-description). + +A JSON serialized object is always a string, which represents an Array +of Objects, where each Object has various properties describing the [Fragment](./) of the ABI. + +The deserialied JSON string (which is a normal JavaScript Object) may +also be passed into any function which accepts a JSON String ABI. + + +### Humanb-Readable ABI + + +The Human-Readable ABI was + +[article](https://blog.ricmoo.com/human-readable-contract-abis-in-ethers-js-141902f4d917) + + +### Output Formats + + +Each [Fragment](./) and [ParamType](./) may be output using its `format` +method. + + +#### *utils* . *FragmentTypes* . **full** **=>** *string* + +This is a full human-readable string, including all parameter names, any +optional modifiers (e.g. `indexed`, `public`, etc) and white-space +to aid in human readabiliy. + + + + +#### *utils* . *FragmentTypes* . **minimal** **=>** *string* + +This is similar to `full`, except with no unnecessary whitespace or parameter +names. This is useful for storing a minimal string which can still fully +reconstruct the original Fragment using [Fragment . from](./). + + + + +#### *utils* . *FragmentTypes* . **json** **=>** *string* + +This returns a JavaScript Object which is safe to call `JSON.stringify` +on to create a JSON string. + + + + +#### *utils* . *FragmentTypes* . **sighash** **=>** *string* + +This is a minimal output format, which is used by Solidity when computing a +signature hash or an event topic hash. + + + + +#### Note + +The `sighash` format is **insufficient** to re-create the original [Fragment](./), +since it discards modifiers such as indexed, anonymous, stateMutability, etc. + + + + +Fragment +-------- + + +An ABI is a collection of **Fragments**, where each fragment specifies: + + + +* An Event +* A Function +* A Constructor + + +### Properties + + + +#### *fragment* . **name** **=>** *string* + +This is the name of the Event or Function. This will be null for +a [ConstructorFragment](./). + + + + +#### *fragment* . **type** **=>** *string* + +This is a string which indicates the type of the [Fragment](./). This +will be one of: + + + +* `constructor` +* `event` +* `function` + + + + +#### *fragment* . **inputs** **=>** *Array< [ParamType](./) >* + +This is an array of of each [ParamType](./) for the input parameters to +the Constructor, Event of Function. + + + + +### Methods + + + +#### *utils* . *Fragment* . **from** ( objectOrString ) **=>** *[Fragment](./)* + +Returns a + + + + +#### *utils* . *Fragment* . **isFragment** ( object ) **=>** *boolean* + +Tra lal al + + + + +ConstructorFragment +------------------- + + + +### Properties + + + +#### *fragment* . **gas** **=>** *[BigNumber](../bignumber)* + +This is the gas limit that should be used during deployment. It may be +null. + + + + +#### *fragment* . **payable** **=>** *boolean* + +This is whether the constructor may receive ether during deployment as +an endowment (i.e. msg.value != 0). + + + + +#### *fragment* . **stateMutability** **=>** *string* + +This is the state mutability of the constructor. It can be any of: + + + +* `nonpayable` +* `payable` + + + + +### Methods + + + +#### *utils* . *ConstructorFragment* . **from** ( objectOrString ) **=>** *[ConstructorFragment](./)* + +Tra la la... + + + + +#### *utils* . *ConstructorFragment* . **isConstructorFragment** ( object ) **=>** *boolean* + +Tra lal al + + + + +EventFragment +------------- + + + +### Properties + + + +#### *fragment* . **anonymous** **=>** *boolean* + +This is whether the event is anonymous. An anonymous Event does not inject its +topic hash as topic0 when creating a log. + + + + +### Methods + + + +#### *utils* . *EventFragment* . **from** ( objectOrString ) **=>** *[EventFragment](./)* + +Tra la la... + + + + +#### *utils* . *EventFragment* . **isEventFragment** ( object ) **=>** *boolean* + +Tra lal al + + + + +FunctionFragment +---------------- + + + +### Properties + + + +#### *fragment* . **constant** **=>** *boolean* + +This is whether the function is constant (i.e. does not change state). This +is true if the state mutability is `pure` or `view`. + + + + +#### *fragment* . **stateMutability** **=>** *string* + +This is the state mutability of the constructor. It can be any of: + + + +* `nonpayable` +* `payable` +* `pure` +* `view` + + + + +#### *fragment* . **outputs** **=>** *Array< [ParamType](./) >* + +A list of the Function output parameters. + + + + +### Method + + + +#### *utils* . *FunctionFragment* . **from** ( objectOrString ) **=>** *[FunctionFragment](./)* + +Tra la la... + + + + +#### *utils* . *FunctionFragment* . **isFunctionFragment** ( object ) **=>** *boolean* + +Tra lal al + + + + +ParamType +--------- + + +The following examples will represent the Solidity parameter: + +`string foobar` + + +### Properties + + + +#### *paramType* . **name** **=>** *string* + +The local parameter name. This may be null for unnamed parameters. For example, +the parameter definition `string foobar` would be `foobar`. + + + + +#### *paramType* . **type** **=>** *string* + +The full type of the parameter, including tuple and array symbols. This may be null +for unnamed parameters. For the above example, this would be `foobar`. + + + + +#### *paramType* . **basetype** **=>** *string* + +The base type of the parameter. For primitive types (e.g. `address`, `uint256`, etc) +this is equal to [type](./). For arrays, it will be the string `array` and for +a tuple, it will be the string `tuple`. + + + + +#### *paramType* . **indexed** **=>** *boolean* + +Whether the parameter has been marked as indexed. This **only** applies +to parameters which are part of an [EventFragment](./). + + + + +#### *paramType* . **arrayChildren** **=>** *[ParamType](./)* + +The type of children of the array. This is null for for any parameter +wjhich is not an array. + + + + +#### *paramType* . **arrayLength** **=>** *number* + +The length of the array, or `-1` for dynamic-length arrays. This is +null for parameters which is not arrays. + + + + +#### *paramType* . **components** **=>** *Array< [ParamType](./) >* + +The components of a tuple. This is null for non-tuple parameters. + + + + +### Methods + + +Tra la la... + + +#### *paramType* . **format** ( [ outputType="sighash" ] ) + +Tra la la... + + + + +#### *utils* . *ParamType* . **from** ( objectOrString ) **=>** *[ParamType](./)* + +Tra la la... + + + + +#### *utils* . *ParamType* . **isParamType** ( object ) **=>** *boolean* + +Tra la la... + + + + + +----- +**Content Hash:** cae7aa26d26d5f02ebe0f227e25759db5d2437b4104d2950b364ced87e7c83f6 \ No newline at end of file diff --git a/docs/api/utils/abi/index.html b/docs/api/utils/abi/index.html new file mode 100644 index 000000000..770f92b8d --- /dev/null +++ b/docs/api/utils/abi/index.html @@ -0,0 +1,74 @@ +Application Binary Interface
+

Application Binary Interface

+

Explain an ABI.

+

Formats

+ +

JSON String ABI (Solidity Output JSON)

+

The JSON ABI Format is the format that is output from the Solidity compiler.

A JSON serialized object is always a string, which represents an Array of Objects, where each Object has various properties describing the Fragment of the ABI.

The deserialied JSON string (which is a normal JavaScript Object) may also be passed into any function which accepts a JSON String ABI.

+

Humanb-Readable ABI

+

The Human-Readable ABI was

article

+

Output Formats

+

Each Fragment and ParamType may be output using its format method.

+
utils . FragmentTypes . full string

This is a full human-readable string, including all parameter names, any optional modifiers (e.g. indexed, public, etc) and white-space to aid in human readabiliy.

+
utils . FragmentTypes . minimal string

This is similar to full, except with no unnecessary whitespace or parameter names. This is useful for storing a minimal string which can still fully reconstruct the original Fragment using Fragment . from.

+
utils . FragmentTypes . json string

This returns a JavaScript Object which is safe to call JSON.stringify on to create a JSON string.

+
utils . FragmentTypes . sighash string

This is a minimal output format, which is used by Solidity when computing a signature hash or an event topic hash.

+
Note

The sighash format is insufficient to re-create the original Fragment, since it discards modifiers such as indexed, anonymous, stateMutability, etc.

+

Fragment

+

An ABI is a collection of Fragments, where each fragment specifies:

  • An Event
  • A Function
  • A Constructor
+

Properties

+ +
fragment . name string

This is the name of the Event or Function. This will be null for a ConstructorFragment.

+
fragment . type string

This is a string which indicates the type of the Fragment. This will be one of:

  • constructor
  • event
  • function
+
fragment . inputs Array< ParamType >

This is an array of of each ParamType for the input parameters to the Constructor, Event of Function.

+

Methods

+ +
utils . Fragment . from ( objectOrString ) Fragment

Returns a

+
utils . Fragment . isFragment ( object ) boolean

Tra lal al

+

ConstructorFragment inherits Fragment

+ +

Properties

+ +
fragment . gas BigNumber

This is the gas limit that should be used during deployment. It may be null.

+
fragment . payable boolean

This is whether the constructor may receive ether during deployment as an endowment (i.e. msg.value != 0).

+
fragment . stateMutability string

This is the state mutability of the constructor. It can be any of:

  • nonpayable
  • payable
+

Methods

+ +
utils . ConstructorFragment . from ( objectOrString ) ConstructorFragment

Tra la la...

+
utils . ConstructorFragment . isConstructorFragment ( object ) boolean

Tra lal al

+

EventFragment inherits Fragment

+ +

Properties

+ +
fragment . anonymous boolean

This is whether the event is anonymous. An anonymous Event does not inject its topic hash as topic0 when creating a log.

+

Methods

+ +
utils . EventFragment . from ( objectOrString ) EventFragment

Tra la la...

+
utils . EventFragment . isEventFragment ( object ) boolean

Tra lal al

+

FunctionFragment inherits ConstructorFragment

+ +

Properties

+ +
fragment . constant boolean

This is whether the function is constant (i.e. does not change state). This is true if the state mutability is pure or view.

+
fragment . stateMutability string

This is the state mutability of the constructor. It can be any of:

  • nonpayable
  • payable
  • pure
  • view
+
fragment . outputs Array< ParamType >

A list of the Function output parameters.

+

Method

+ +
utils . FunctionFragment . from ( objectOrString ) FunctionFragment

Tra la la...

+
utils . FunctionFragment . isFunctionFragment ( object ) boolean

Tra lal al

+

ParamType

+

The following examples will represent the Solidity parameter:

string foobar

+

Properties

+ +
paramType . name string

The local parameter name. This may be null for unnamed parameters. For example, the parameter definition string foobar would be foobar.

+
paramType . type string

The full type of the parameter, including tuple and array symbols. This may be null for unnamed parameters. For the above example, this would be foobar.

+
paramType . basetype string

The base type of the parameter. For primitive types (e.g. address, uint256, etc) this is equal to type. For arrays, it will be the string array and for a tuple, it will be the string tuple.

+
paramType . indexed boolean

Whether the parameter has been marked as indexed. This only applies to parameters which are part of an EventFragment.

+
paramType . arrayChildren ParamType

The type of children of the array. This is null for for any parameter wjhich is not an array.

+
paramType . arrayLength number

The length of the array, or -1 for dynamic-length arrays. This is null for parameters which is not arrays.

+
paramType . components Array< ParamType >

The components of a tuple. This is null for non-tuple parameters.

+

Methods

+

Tra la la...

+
paramType . format ( [ outputType = "sighash" ] )

Tra la la...

+
utils . ParamType . from ( objectOrString ) ParamType

Tra la la...

+
utils . ParamType . isParamType ( object ) boolean

Tra la la...

\ No newline at end of file diff --git a/docs/api/utils/address/README.md b/docs/api/utils/address/README.md index 06fc12769..ae7714e79 100644 --- a/docs/api/utils/address/README.md +++ b/docs/api/utils/address/README.md @@ -14,11 +14,51 @@ Explain addresses,formats and checksumming here. Also see: [constants.AddressZero](../constants) -### Functions +Address Formats +--------------- -#### *utils* . **getAddress** ( address ) **=>** *string* +### Address + + +An **Address** is a [DataHexstring](../bytes) of 20 bytes (40 nibbles), with optional +mixed case. + +If the case is mixed, it is a **Checksum Address**, which uses a specific pattern +of uppercase and lowercase letters within a given address to reduce the risk +of errors introduced from typing an address or cut and paste issues. + +All functions that return an Address will return a Checksum Address. + + +### ICAP Address + + +The **ICAP Address Format** was an early attempt to introduce a checksum +into Ethereum addresses using the popular banking industry's +[IBAN](https://en.wikipedia.org/wiki/International_Bank_Account_Number) +format with the country code specified as **XE**. + +Due to the way IBAN encodes address, only addresses that fit into 30 base-36 +characters are actually compatible, so the format was adapted to support 31 +base-36 characters which is large enough for a full Ethereum address, however +the preferred method was to select a private key whose address has a `0` as +the first byte, which allows the address to be formatted as a fully compatibly +standard IBAN address with 30 base-36 characters. + +In general this format is no longer widely supported anymore, however any function that +accepts an address can receive an ICAP address, and it will be converted internally. + +To convert an address into the ICAP format, see [getIcapAddress](./). + + +Functions +--------- + + + +#### *utils* . **getAddress** ( address ) **=>** *string< [Address](./) >* Returns *address* as a Checksum Address. @@ -37,15 +77,15 @@ Returns true if *address* is valid (in any supported format). -#### *utils* . **getIcapAddress** ( address ) **=>** *string* +#### *utils* . **getIcapAddress** ( address ) **=>** *string< [IcapAddress](./) >* -Returns *address* as an ICAP address. Supports the same restrictions as -[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 [utils.getAddress](./). -#### *utils* . **getContractAddress** ( transaction ) **=>** *string* +#### *utils* . **getContractAddress** ( transaction ) **=>** *string< [Address](./) >* Returns the contract address that would result if *transaction* was used to deploy a contract. @@ -53,6 +93,14 @@ used to deploy a contract. +#### *utils* . **getCreate2Address** ( from , salt , initCodeHash ) **=>** *string< [Address](./) >* + +Returns the contract address that would result from the given +[CREATE2](https://eips.ethereum.org/EIPS/eip-1014) call. + + + + ----- -**Content Hash:** 2dd561245955594d7080796077503064181258304572112d320139ae2594f383 \ No newline at end of file +**Content Hash:** 7835c97c8afbbdf59c39d32a9d79d86c4e446a2ed6acd6eae1f21c0b190b73c1 \ No newline at end of file diff --git a/docs/api/utils/address/index.html b/docs/api/utils/address/index.html index ae28ec45b..48000ee8a 100644 --- a/docs/api/utils/address/index.html +++ b/docs/api/utils/address/index.html @@ -1,9 +1,16 @@ -Addresses
-

Addresses

+Addresses
+

Addresses

Explain addresses,formats and checksumming here.

Also see: constants.AddressZero

-

Functions

+

Address Formats

-
utils . getAddress ( address ) string

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 throw.

The value of address may be any supported address format.

+

Address

+

An Address is a DataHexstring of 20 bytes (40 nibbles), with optional mixed case.

If the case is mixed, it is a Checksum Address, which uses a specific pattern of uppercase and lowercase letters within a given address to reduce the risk of errors introduced from typing an address or cut and paste issues.

All functions that return an Address will return a Checksum Address.

+

ICAP Address

+

The ICAP Address Format was an early attempt to introduce a checksum into Ethereum addresses using the popular banking industry's IBAN format with the country code specified as XE.

Due to the way IBAN encodes address, only addresses that fit into 30 base-36 characters are actually compatible, so the format was adapted to support 31 base-36 characters which is large enough for a full Ethereum address, however the preferred method was to select a private key whose address has a 0 as the first byte, which allows the address to be formatted as a fully compatibly standard IBAN address with 30 base-36 characters.

In general this format is no longer widely supported anymore, however any function that accepts an address can receive an ICAP address, and it will be converted internally.

To convert an address into the ICAP format, see getIcapAddress.

+

Functions

+ +
utils . getAddress ( address ) string< Address >

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 throw.

The value of address may be any supported address format.

utils . isAddress ( address ) boolean

Returns true if address is valid (in any supported format).

-
utils . getIcapAddress ( address ) string

Returns address as an ICAP address. Supports the same restrictions as utils.getAddress.

-
utils . getContractAddress ( transaction ) string

Returns the contract address that would result if transaction was used to deploy a contract.

\ No newline at end of file +
utils . getIcapAddress ( address ) string< IcapAddress >

Returns address as an ICAP address. Supports the same restrictions as utils.getAddress.

+
utils . getContractAddress ( transaction ) string< Address >

Returns the contract address that would result if transaction was used to deploy a contract.

+
utils . getCreate2Address ( from , salt , initCodeHash ) string< Address >

Returns the contract address that would result from the given CREATE2 call.

\ No newline at end of file diff --git a/docs/api/utils/bignumber/README.md b/docs/api/utils/bignumber/README.md index ebcb7c843..9d4babc6d 100644 --- a/docs/api/utils/bignumber/README.md +++ b/docs/api/utils/bignumber/README.md @@ -108,7 +108,44 @@ Returns an instance of a **BigNumber** for *aBigNumberish*. ```javascript -Skipping JavaScript Evaluation. +// From a decimal string... +BigNumber.from("42") +// { BigNumber: "42" } + +// From a hexstring... +BigNumber.from("0x2a") +// { BigNumber: "42" } + +// From a negative hexstring... +BigNumber.from("-0x2a") +// { BigNumber: "-42" } + +// From an Array (or Uint8Array)... +BigNumber.from([ 42 ]) +// { BigNumber: "42" } + +// From an existing BigNumber... +let one1 = constants.One; +let one2 = BigNumber.from(one1) + +one2 +// { BigNumber: "1" } + +// ...which returns the same instance +one1 === one2 +// true + +// From a (safe) number... +BigNumber.from(42) +// { BigNumber: "42" } + +// From a ES2015 BigInt... (only on platforms with BigInt support) +BigNumber.from(42n) +// { BigNumber: "42" } + +// Numbers outside the safe range fail: +BigNumber.from(Number.MAX_SAFE_INTEGER); +// Error: overflow (fault="overflow", operation="BigNumber.from", value=9007199254740991, version=bignumber/5.0.0-beta.135) ``` @@ -273,7 +310,7 @@ Returns the value of *bignumber* as a base-10 string. -#### *bignumber* . **toHexString** ( ) **=>** *string* +#### *bignumber* . **toHexString** ( ) **=>** *string< [DataHexstring](../bytes) >* Returns the value of *bignumber* as a base-16, `0x`-prefixed [hexstring](../bytes). @@ -296,7 +333,11 @@ Returns true if and only if the *object* is a BigNumber object. ```javascript -Skipping JavaScript Evaluation. +let a = BigNumber.from(42); +let b = BigNumber.from("91"); + + a.mul(b); + // { BigNumber: "3822" } ``` @@ -328,7 +369,8 @@ To demonstrate how this may be an issue in your code, consider: ```javascript -Skipping JavaScript Evaluation. +(Number.MAX_SAFE_INTEGER + 2 - 2) == (Number.MAX_SAFE_INTEGER) +// false ``` @@ -344,4 +386,4 @@ mathematical operations handled safely. ----- -**Content Hash:** 76be4f72801f0d772c1ebe1acff4c41f6d52ed96f603de4b168f12d099470273 \ No newline at end of file +**Content Hash:** 8aa8cbe047d299ae822c3d322def66e29bbbd395d1c9bad59c61c97432d83ffa \ No newline at end of file diff --git a/docs/api/utils/bignumber/index.html b/docs/api/utils/bignumber/index.html index b6038b88d..a20e3202c 100644 --- a/docs/api/utils/bignumber/index.html +++ b/docs/api/utils/bignumber/index.html @@ -1,4 +1,4 @@ -Big Number
+Big Number

BigNumber

Explain about BigNumber here...

Importing

@@ -19,47 +19,47 @@
BigNumber . from ( aBigNumberish ) BigNumber

Returns an instance of a BigNumber for aBigNumberish.

Examples:

-
Skipping JavaScript Evaluation.
+

// From a decimal string...
BigNumber.from("42")
// { BigNumber: "42" }

// From a hexstring...
BigNumber.from("0x2a")
// { BigNumber: "42" }

// From a negative hexstring...
BigNumber.from("-0x2a")
// { BigNumber: "-42" }

// From an Array (or Uint8Array)...
BigNumber.from([ 42 ])
// { BigNumber: "42" }

// From an existing BigNumber...
let one1 = constants.One;
let one2 = BigNumber.from(one1)

one2
// { BigNumber: "1" }

// ...which returns the same instance
one1 === one2
// true

// From a (safe) number...
BigNumber.from(42)
// { BigNumber: "42" }

// From a ES2015 BigInt... (only on platforms with BigInt support)
BigNumber.from(42n)
// { BigNumber: "42" }

// Numbers outside the safe range fail:
BigNumber.from(Number.MAX_SAFE_INTEGER);
// Error: overflow (fault="overflow", operation="BigNumber.from", value=9007199254740991, version=bignumber/5.0.0-beta.135)

Methods

The BigNumber class is immutable, so no operations can change the value it represents.

Math Operations

-
bignumber . add ( otherValue ) BigNumber

Returns a BigNumber with the value of bignumber + otherValue.

-
bignumber . sub ( otherValue ) BigNumber

Returns a BigNumber with the value of bignumber otherValue.

-
bignumber . mul ( otherValue ) BigNumber

Returns a BigNumber with the value of bignumber × otherValue.

-
bignumber . div ( divisor ) BigNumber

Returns a BigNumber with the value of bignumber ÷ divisor.

-
bignumber . mod ( divisor ) BigNumber

Returns a BigNumber with the value of the remainder of bignumber ÷ divisor.

-
bignumber . pow ( exponent ) BigNumber

Returns a BigNumber with the value of bignumber to the power of exponent.

-
bignumber . abs ( ) BigNumber

Returns a BigNumber with the absolute value of bignumber.

-
bignumber . maskn ( bitcount ) BigNumber

Returns a BigNumber with the value of bignumber with bits beyond the bitcount least significant bits set to zero.

+
bignumber . add ( otherValue ) BigNumber

Returns a BigNumber with the value of bignumber + otherValue.

+
bignumber . sub ( otherValue ) BigNumber

Returns a BigNumber with the value of bignumber otherValue.

+
bignumber . mul ( otherValue ) BigNumber

Returns a BigNumber with the value of bignumber × otherValue.

+
bignumber . div ( divisor ) BigNumber

Returns a BigNumber with the value of bignumber ÷ divisor.

+
bignumber . mod ( divisor ) BigNumber

Returns a BigNumber with the value of the remainder of bignumber ÷ divisor.

+
bignumber . pow ( exponent ) BigNumber

Returns a BigNumber with the value of bignumber to the power of exponent.

+
bignumber . abs ( ) BigNumber

Returns a BigNumber with the absolute value of bignumber.

+
bignumber . maskn ( bitcount ) BigNumber

Returns a BigNumber with the value of bignumber with bits beyond the bitcount least significant bits set to zero.

Two's Compliment

Two's Complicment is an elegant method used to encode and decode fixed-width signed values while efficiently preserving mathematic operations. Most users will not need to interact with these.

-
bignumber . fromTwos ( bitwidth ) BigNumber

Returns a BigNumber with the value of bignumber converted from twos-compliment with bitwidth.

-
bignumber . toTwos ( bitwidth ) BigNumber

Returns a BigNumber with the value of bignumber converted to twos-compliment with bitwidth.

+
bignumber . fromTwos ( bitwidth ) BigNumber

Returns a BigNumber with the value of bignumber converted from twos-compliment with bitwidth.

+
bignumber . toTwos ( bitwidth ) BigNumber

Returns a BigNumber with the value of bignumber converted to twos-compliment with bitwidth.

Comparison and Equivalence

-
bignumber . eq ( otherValue ) boolean

Returns true if and only if the value of bignumber is equal to otherValue.

-
bignumber . lt ( otherValue ) boolean

Returns true if and only if the value of bignumber < otherValue.

-
bignumber . lte ( otherValue ) boolean

Returns true if and only if the value of bignumber otherValue.

-
bignumber . gt ( otherValue ) boolean

Returns true if and only if the value of bignumber > otherValue.

-
bignumber . gte ( otherValue ) boolean

Returns true if and only if the value of bignumber otherValue.

-
bignumber . isZero ( ) boolean

Returns true if and only if the value of bignumber is zero.

+
bignumber . eq ( otherValue ) boolean

Returns true if and only if the value of bignumber is equal to otherValue.

+
bignumber . lt ( otherValue ) boolean

Returns true if and only if the value of bignumber < otherValue.

+
bignumber . lte ( otherValue ) boolean

Returns true if and only if the value of bignumber otherValue.

+
bignumber . gt ( otherValue ) boolean

Returns true if and only if the value of bignumber > otherValue.

+
bignumber . gte ( otherValue ) boolean

Returns true if and only if the value of bignumber otherValue.

+
bignumber . isZero ( ) boolean

Returns true if and only if the value of bignumber is zero.

Conversion

-
bignumber . toNumber ( ) number

Returns the value of bignumber as a JavaScript value.

This will throw an error if the value is greater than or equal to Number.MAX_SAFE_INTEGER or less than or equal to Number.MIN_SAFE_INTEGER.

-
bignumber . toString ( ) string

Returns the value of bignumber as a base-10 string.

-
bignumber . toHexString ( ) string

Returns the value of bignumber as a base-16, `0x`-prefixed hexstring.

+
bignumber . toNumber ( ) number

Returns the value of bignumber as a JavaScript value.

This will throw an error if the value is greater than or equal to Number.MAX_SAFE_INTEGER or less than or equal to Number.MIN_SAFE_INTEGER.

+
bignumber . toString ( ) string

Returns the value of bignumber as a base-10 string.

+
bignumber . toHexString ( ) string< DataHexstring >

Returns the value of bignumber as a base-16, `0x`-prefixed hexstring.

Inspection

-
BigNumnber . isBigNumber ( object ) boolean

Returns true if and only if the object is a BigNumber object.

+
BigNumnber . isBigNumber ( object ) boolean

Returns true if and only if the object is a BigNumber object.

Examples

-
Skipping JavaScript Evaluation.
+

let a = BigNumber.from(42);
let b = BigNumber.from("91");

a.mul(b);
// { BigNumber: "3822" }

Notes

A few short notes on numbers...

Why can't I just use numbers?

The first problem many encounter when dealing with Ethereum is the concept of numbers. Most common currencies are broken down with very little granularity. For example, there are only 100 cents in a single dollar. However, there are 1018 wei in a single ether.

JavaScript uses IEEE 754 double-precision binary floating point numbers to represent numeric values. As a result, there are holes in the integer set after 9,007,199,254,740,991; which is problematic for Ethereum// because that is only around 0.009 ether (in wei), which means any value over that will begin to experience rounding errors.

To demonstrate how this may be an issue in your code, consider:

-
Skipping JavaScript Evaluation.
-

To remedy this, all numbers (which can be large) are stored and manipulated as Big Numbers.

The functions parseEther( etherString ) and formatEther( wei ) can be used to convert between string representations, which are displayed to or entered by the user and Big Number representations which can have mathematical operations handled safely.

\ No newline at end of file +
(Number.MAX_SAFE_INTEGER + 2 - 2) == (Number.MAX_SAFE_INTEGER)
// false
+

To remedy this, all numbers (which can be large) are stored and manipulated as Big Numbers.

The functions parseEther( etherString ) and formatEther( wei ) can be used to convert between string representations, which are displayed to or entered by the user and Big Number representations which can have mathematical operations handled safely.

\ No newline at end of file diff --git a/docs/api/utils/bytes/README.md b/docs/api/utils/bytes/README.md index 7dee7ac39..46f4bda74 100644 --- a/docs/api/utils/bytes/README.md +++ b/docs/api/utils/bytes/README.md @@ -45,7 +45,7 @@ binary data as a string. ### Hexstring -A **hexstring** is a string which has a `0x` prefix followed by any +A **Hexstring** is a string which has a `0x` prefix followed by any number of nibbles (i.e. case-insensitive hexidecumal characters, `0-9` and `a-f`). @@ -56,15 +56,23 @@ number of nibbles (i.e. case-insensitive hexidecumal characters, `0-9` and `a-f` * **r** and **s** --- The x co-ordinate of **r** and the **s** value of the signature * **v** --- The parity of the y co-ordinate of **r** -* **_vs** --- The [compact representation](https://link_here) of the **(r, s)** and **v** +* **_vs** --- The [compact representation](https://eips.ethereum.org/EIPS/eip-2098) of the **s** and **v** * **recoveryParam** --- The normalized (i.e. 0 or 1) value of **v** +### Flat-Format Signature + + +A **Flat-Format Signature** is a common Signature format where +the r, s and v are concanenated into a 65 byte (130 nibble) +[DataHexstring](./). + + ### SignatureLike A **SignatureLike** is similar to a [Signature](./), except redundant properties -may be omitted. +may be omitted or it may be a [Flat-Format Signature](./). For example, if **_vs** is specified, **s** and **v** may be omitted. Likewise, if **recoveryParam** is provided, **v** may be omitted (as in these cases the @@ -111,14 +119,14 @@ Converts *datahexstringOrArrayish* to a Uint8Array. -#### *utils* . **hexlify** ( hexstringOrArrayish ) **=>** *string* +#### *utils* . **hexlify** ( hexstringOrArrayish ) **=>** *string< [DataHexstring](./) >* Converts *hexstringOrArrayish* to a [DataHexstring](./). -#### *utils* . **hexValue** ( aBigNumberish ) **=>** *string* +#### *utils* . **hexValue** ( aBigNumberish ) **=>** *string< [Hexstring](./) >* Converts *aBigNumberish* to a [Hexstring](./), with no *unnecessary* leading zeros. @@ -131,7 +139,29 @@ zeros. ```javascript -Skipping JavaScript Evaluation. +// Convert a hexstring to a Uint8Array +arrayify("0x1234") +// [ 18, 52 ] + +// Convert an Array to a hexstring +hexlify([1, 2, 3, 4]) +// 0x01020304 + +// Convert an Object to a hexstring +hexlify({ length: 2, "0": 1, "1": 2 }) +// 0x0102 + +// Convert an Array to a hexstring +hexlify([ 1 ]) +// 0x01 + +// Convert a number to a stripped hex value +hexValue(1) +// 0x1 + +// Convert an Array to a stripped hex value +hexValue([ 1, 2 ]) +// 0x102 ``` @@ -171,21 +201,21 @@ Hexstring Manipulation -#### *utils* . **hexConcat** ( arrayOfBytesLike ) **=>** *[DataHexstring](./)* +#### *utils* . **hexConcat** ( arrayOfBytesLike ) **=>** *string< [DataHexstring](./) >* Concatenates all the [BytesLike](./) in *arrayOfBytesLike* into a single [DataHexstring](./) -#### *utils* . **hexDataLength** ( aBytesLike ) **=>** *[DataHexstring](./)* +#### *utils* . **hexDataLength** ( aBytesLike ) **=>** *string< [DataHexstring](./) >* Returns the length (in bytes) of *aBytesLike*. -#### *utils* . **hexDataSlice** ( aBytesLike , offset [ , endOffset ] ) **=>** *[DataHexstring](./)* +#### *utils* . **hexDataSlice** ( aBytesLike , offset [ , endOffset ] ) **=>** *string< [DataHexstring](./) >* Returns a [DataHexstring](./) representation of a slice of *aBytesLike*, from *offset* (in bytes) to *endOffset* (in bytes). If *endOffset* is @@ -194,7 +224,7 @@ omitted, the length of *aBytesLike* is used. -#### *utils* . **hexStripZeros** ( aBytesLike ) **=>** *[Hexstring](./)* +#### *utils* . **hexStripZeros** ( aBytesLike ) **=>** *string< [Hexstring](./) >* Returns a [Hexstring](./) representation of *aBytesLike* with all leading zeros removed. @@ -202,7 +232,7 @@ leading zeros removed. -#### *utils* . **hexZeroPad** ( aBytesLike , length ) **=>** *[DataHexstring](./)* +#### *utils* . **hexZeroPad** ( aBytesLike , length ) **=>** *string< [DataHexstring](./) >* Returns a [DataHexstring](./) representation of *aBytesLike* padded to *length* bytes. @@ -217,7 +247,7 @@ Signature Conversion -#### *utils* . **joinSignature** ( aSignatureLike ) **=>** *[DataHexstring](./)* +#### *utils* . **joinSignature** ( aSignatureLike ) **=>** *string< [FlatSignature](./) >* Return the flat-format of *aSignaturelike*, which is 65 bytes (130 nibbles) long, concatenating the **r**, **s** and (normalized) **v** of a Signature. @@ -235,4 +265,4 @@ Any missing properties will be computed. ----- -**Content Hash:** fce7a8c85402ef3d94ffe261157fa3e0644c5c5d0641d9de7820a9a798bcb6c7 \ No newline at end of file +**Content Hash:** ef5d3728657f7c650f7531071145048e55ee632bd0fe4ee01b6d11a1e9b1c39b \ No newline at end of file diff --git a/docs/api/utils/bytes/index.html b/docs/api/utils/bytes/index.html index 8fb78207f..e26ea5e25 100644 --- a/docs/api/utils/bytes/index.html +++ b/docs/api/utils/bytes/index.html @@ -1,4 +1,4 @@ -Byte Manipulation
+Byte Manipulation

Byte Manipulation

Tra la la...

Types

@@ -10,11 +10,13 @@

DataHexstring

A DataHexstring is identical to a Hexstring except that it has an even number of nibbles, and therefore is a valid representation of binary data as a string.

Hexstring

-

A hexstring is a string which has a 0x prefix followed by any number of nibbles (i.e. case-insensitive hexidecumal characters, 0-9 and a-f).

+

A Hexstring is a string which has a 0x prefix followed by any number of nibbles (i.e. case-insensitive hexidecumal characters, 0-9 and a-f).

Signature

-
  • r and s — The x co-ordinate of r and the s value of the signature
  • v — The parity of the y co-ordinate of r
  • _vs — The compact representation of the (r, s) and v
  • recoveryParam — The normalized (i.e. 0 or 1) value of v
+
  • r and s — The x co-ordinate of r and the s value of the signature
  • v — The parity of the y co-ordinate of r
  • _vs — The compact representation of the s and v
  • recoveryParam — The normalized (i.e. 0 or 1) value of v
+

Flat-Format Signature

+

A Flat-Format Signature is a common Signature format where the r, s and v are concanenated into a 65 byte (130 nibble) DataHexstring.

SignatureLike

-

A SignatureLike is similar to a Signature, except redundant properties may be omitted.

For example, if _vs is specified, s and v may be omitted. Likewise, if recoveryParam is provided, v may be omitted (as in these cases the missing values can be computed).

+

A SignatureLike is similar to a Signature, except redundant properties may be omitted or it may be a Flat-Format Signature.

For example, if _vs is specified, s and v may be omitted. Likewise, if recoveryParam is provided, v may be omitted (as in these cases the missing values can be computed).

Inspection

utils . isBytes ( object ) boolean

Returns true if and only if object is a valid Bytes.

@@ -23,11 +25,11 @@

Converting between Arrays and Hexstrings

utils . arrayify ( datahexstringOrArrayish [ , options ] ) Uint8Array

Converts datahexstringOrArrayish to a Uint8Array.

-
utils . hexlify ( hexstringOrArrayish ) string

Converts hexstringOrArrayish to a DataHexstring.

-
utils . hexValue ( aBigNumberish ) string

Converts aBigNumberish to a Hexstring, with no unnecessary leading zeros.

+
utils . hexlify ( hexstringOrArrayish ) string< DataHexstring >

Converts hexstringOrArrayish to a DataHexstring.

+
utils . hexValue ( aBigNumberish ) string< Hexstring >

Converts aBigNumberish to a Hexstring, with no unnecessary leading zeros.

Examples

-
Skipping JavaScript Evaluation.
+

// Convert a hexstring to a Uint8Array
arrayify("0x1234")
// [ 18, 52 ]

// Convert an Array to a hexstring
hexlify([1, 2, 3, 4])
// 0x01020304

// Convert an Object to a hexstring
hexlify({ length: 2, "0": 1, "1": 2 })
// 0x0102

// Convert an Array to a hexstring
hexlify([ 1 ])
// 0x01

// Convert a number to a stripped hex value
hexValue(1)
// 0x1

// Convert an Array to a stripped hex value
hexValue([ 1, 2 ])
// 0x102

Array Manipulation

@@ -36,12 +38,12 @@
utils . zeroPad ( aBytesLike , length ) Uint8Array

Retutns a Uint8Array of the data in aBytesLike with 0 bytes prepended to length bytes long.

If aBytesLike is already longer than length bytes long, an InvalidArgument error will be thrown.

Hexstring Manipulation

-
utils . hexConcat ( arrayOfBytesLike ) DataHexstring

Concatenates all the BytesLike in arrayOfBytesLike into a single DataHexstring

-
utils . hexDataLength ( aBytesLike ) DataHexstring

Returns the length (in bytes) of aBytesLike.

-
utils . hexDataSlice ( aBytesLike , offset [ , endOffset ] ) DataHexstring

Returns a DataHexstring representation of a slice of aBytesLike, from offset (in bytes) to endOffset (in bytes). If endOffset is omitted, the length of aBytesLike is used.

-
utils . hexStripZeros ( aBytesLike ) Hexstring

Returns a Hexstring representation of aBytesLike with all leading zeros removed.

-
utils . hexZeroPad ( aBytesLike , length ) DataHexstring

Returns a DataHexstring representation of aBytesLike padded to length bytes.

If aBytesLike is already longer than length bytes long, an InvalidArgument error will be thrown.

+
utils . hexConcat ( arrayOfBytesLike ) string< DataHexstring >

Concatenates all the BytesLike in arrayOfBytesLike into a single DataHexstring

+
utils . hexDataLength ( aBytesLike ) string< DataHexstring >

Returns the length (in bytes) of aBytesLike.

+
utils . hexDataSlice ( aBytesLike , offset [ , endOffset ] ) string< DataHexstring >

Returns a DataHexstring representation of a slice of aBytesLike, from offset (in bytes) to endOffset (in bytes). If endOffset is omitted, the length of aBytesLike is used.

+
utils . hexStripZeros ( aBytesLike ) string< Hexstring >

Returns a Hexstring representation of aBytesLike with all leading zeros removed.

+
utils . hexZeroPad ( aBytesLike , length ) string< DataHexstring >

Returns a DataHexstring representation of aBytesLike padded to length bytes.

If aBytesLike is already longer than length bytes long, an InvalidArgument error will be thrown.

Signature Conversion

-
utils . joinSignature ( aSignatureLike ) DataHexstring

Return the flat-format of aSignaturelike, which is 65 bytes (130 nibbles) long, concatenating the r, s and (normalized) v of a Signature.

-
utils . splitSignature ( aSignatureLikeOrBytesLike ) Signature

Return the full expanded-format of aSignaturelike or a flat-format DataHexstring. Any missing properties will be computed.

\ No newline at end of file +
utils . joinSignature ( aSignatureLike ) string< FlatSignature >

Return the flat-format of aSignaturelike, which is 65 bytes (130 nibbles) long, concatenating the r, s and (normalized) v of a Signature.

+
utils . splitSignature ( aSignatureLikeOrBytesLike ) Signature

Return the full expanded-format of aSignaturelike or a flat-format DataHexstring. Any missing properties will be computed.

\ No newline at end of file diff --git a/docs/api/utils/constants/README.md b/docs/api/utils/constants/README.md index 92e834637..c36eb95b6 100644 --- a/docs/api/utils/constants/README.md +++ b/docs/api/utils/constants/README.md @@ -17,7 +17,8 @@ The **ethers.contants** Object contains commonly used values. ```javascript -Skipping JavaScript Evaluation. +//const { constants } = require("ethers"); +// const { constants } = require("@ethersproject/constants"); ``` @@ -27,14 +28,14 @@ Bytes -#### *constants* . **AddressZero** **=>** *[DataHexstring](../bytes)* +#### *constants* . **AddressZero** **=>** *string< [Address](../address) >* The Address Zero, which is 20 bytes (40 nibbles) of zero. -#### *constants* . **HashZero** **=>** *[DataHexstring](../bytes)* +#### *constants* . **HashZero** **=>** *string< [DataHexstring](../bytes)< 32 > >* The Hash Zero, which is 32 bytes (64 nibbles) of zero. @@ -103,4 +104,4 @@ The BigNumber value representing the maximum `uint256` value. ----- -**Content Hash:** 11a9a2e37a2a553b79931caf5374bcd894edf343a897c4253ddeaf4d2f8e1213 \ No newline at end of file +**Content Hash:** 622800454a6a66b0fc5bbd1aa149f58e00727d81f05a8d32f3eb7be9e1abbf8d \ No newline at end of file diff --git a/docs/api/utils/constants/index.html b/docs/api/utils/constants/index.html index ea4bf5ffc..cb122a4a4 100644 --- a/docs/api/utils/constants/index.html +++ b/docs/api/utils/constants/index.html @@ -1,14 +1,14 @@ -Constants
+Constants

Constants

The ethers.contants Object contains commonly used values.

Importing

-
Skipping JavaScript Evaluation.
+

//const { constants } = require("ethers");
// const { constants } = require("@ethersproject/constants");

Bytes

-
constants . AddressZero DataHexstring

The Address Zero, which is 20 bytes (40 nibbles) of zero.

-
constants . HashZero DataHexstring

The Hash Zero, which is 32 bytes (64 nibbles) of zero.

+
constants . AddressZero string< Address >

The Address Zero, which is 20 bytes (40 nibbles) of zero.

+
constants . HashZero string< DataHexstring< 32 > >

The Hash Zero, which is 32 bytes (64 nibbles) of zero.

Strings

constants . EtherSymbol string

The Ether symbol, Ξ.

@@ -19,4 +19,4 @@
constants . One BigNumber

The BigNumber value representing "1".

constants . Two BigNumber

The BigNumber value representing "2".

constants . WeiPerEther BigNumber

The BigNumber value representing "1000000000000000000", which is the number of Wei per Ether.

-
constants . MaxUint256 BigNumber

The BigNumber value representing the maximum uint256 value.

\ No newline at end of file +
constants . MaxUint256 BigNumber

The BigNumber value representing the maximum uint256 value.

\ No newline at end of file diff --git a/docs/api/utils/display-logic/index.html b/docs/api/utils/display-logic/index.html index 2c1964070..a4c396a2f 100644 --- a/docs/api/utils/display-logic/index.html +++ b/docs/api/utils/display-logic/index.html @@ -1,4 +1,4 @@ -Display Logic and Input
+Display Logic and Input

Display Logic and Input

When creating an Application, it is useful to convert between user-friendly strings (usually displaying ether) and the machine-readable values that contracts and maths depend on (usually in wei).

For example, a Wallet may specify the balance in ether, and gas prices in gwei for the User Interface, but when sending a transaction, both must be specified in wei.

The parseUnits will parse a string representing ether, such as 1.1 into a BigNumber in wei, and is useful when a user types in a value, such as sending 1.1 ether.

The formatUnits will format a BigNumberish into a string, which is useful when displaying a balance.

Units

@@ -17,4 +17,4 @@
utils . formatUnits ( value [ , unit = "ether" ] ) string

Returns a string representation of value formatted with unit digits (if it is a number) or to the unit specified (if a string).

utils . formatEther ( value ) string

The equivalent to calling formatUnits(value, "ether").

utils . parseUnits ( value [ , unit = "ether" ] ) BigNumber

Returns a BigNumber representation of value, parsed with unit digits (if it is a number) or from the unit specified (if a string).

-
utils . parseEther ( value ) BigNumber

The equivalent to calling parseUnits(value, "ether").

\ No newline at end of file +
utils . parseEther ( value ) BigNumber

The equivalent to calling parseUnits(value, "ether").

\ No newline at end of file diff --git a/docs/api/utils/encoding/README.md b/docs/api/utils/encoding/README.md new file mode 100644 index 000000000..16869464c --- /dev/null +++ b/docs/api/utils/encoding/README.md @@ -0,0 +1,45 @@ +----- + +Documentation: [html](https://docs-beta.ethers.io/) + +----- + + +Encoding Utilities +================== + + + +#### *utils* . *base58* . **decode** ( textData ) **=>** *Uin8Array* + +Return a typed Uint8Array representation of *textData* decoded using +base-58 encoding. + + + + +#### *utils* . *base58* . **encode** ( aBytesLike ) **=>** *string* + +Return *aBytesLike* encoded as a string using the base-58 encoding. + + + + +#### *utils* . *base64* . **decode** ( textData ) **=>** *Uin8Array* + +Return a typed Uint8Array representation of *textData* decoded using +base-64 encoding. + + + + +#### *utils* . *base64* . **encode** ( aBytesLike ) **=>** *string* + +Return *aBytesLike* encoded as a string using the base-64 encoding. + + + + + +----- +**Content Hash:** a4f4ef6d28d4fde749cce30bb537f6ad3d6d0ae6070623757c75091441523f4e \ No newline at end of file diff --git a/docs/api/utils/encoding/index.html b/docs/api/utils/encoding/index.html new file mode 100644 index 000000000..9ac4ca84d --- /dev/null +++ b/docs/api/utils/encoding/index.html @@ -0,0 +1,7 @@ +Encoding Utilies
+

Encoding Utilities

+ +
utils . base58 . decode ( textData ) Uin8Array

Return a typed Uint8Array representation of textData decoded using base-58 encoding.

+
utils . base58 . encode ( aBytesLike ) string

Return aBytesLike encoded as a string using the base-58 encoding.

+
utils . base64 . decode ( textData ) Uin8Array

Return a typed Uint8Array representation of textData decoded using base-64 encoding.

+
utils . base64 . encode ( aBytesLike ) string

Return aBytesLike encoded as a string using the base-64 encoding.

\ No newline at end of file diff --git a/docs/api/utils/fixednumber/README.md b/docs/api/utils/fixednumber/README.md index 19348695d..8d9c47e9c 100644 --- a/docs/api/utils/fixednumber/README.md +++ b/docs/api/utils/fixednumber/README.md @@ -10,15 +10,83 @@ FixedNumber -Types ------ +FixedFormat +----------- + + +A **FixedFormat** is a simple object which represents a decimal +(base-10) Fixed-Point data representation. Usually using this +class directly is uneccessary, as passing in a [Format Strings](./) +directly into the [FixedNumber](./) will automatically create this. + + +### Format Strings + + +A format string is composed of three components, including signed-ness, +bit-width and number of decimals. + +A signed format string begins with `fixed`, which an unsigned format +string begins with `ufixed`, followed by the width (in bits) and the +number of decimals. + +The width must be conguent to 0 mod 8 (i.e. `(width % 8) == 0`) and no +larger than 256 bits and the number of decimals must be no larger than 80. + +For example: -### FixedFormat +* **fixed128x18** is signed, 128 bits wide and has 18 decimals; this is useful for most purposes +* **fixed32x0** is signed, 32 bits wide and has 0 decimals; this would be the same as a ``int32_t` in C +* **ufixed32x0** is unsigned, 32 bits wide and has 0 decimals; this would be the same as a ``uint32_t` in C +* **fixed** is shorthand for ``fixed128x18` +* **ufixed** is shorthand for ``ufixed128x18` + + +### Creating Instances + + + +#### *FixedFormat* . **from** ( value="fixed128x18" ) **=>** *[FixedFormat](./)* + +Returns a new instance of a **FixedFormat** defined by *value*. Any valid [Format Strings](./) +may be passed in as well as any object which has any of `signed`, `width` and `decimals` +defined, including a [FixedFormat](./) object. + + + + +### Properties + + + +#### *fixedFormat* . **signed** **=>** *boolean* + + + + + + +#### *fixedFormat* . **width** **=>** *number* + + + + + + +#### *fixedFormat* . **decimals** **=>** *number* + + + + + + +#### *fixedFormat* . **name** **=>** *string* + + -TODO #### ***"fixed"*** @@ -36,21 +104,21 @@ The FixedNumber constructor cannot be called directly. There are several static methods for creating a FixedNumber. -#### *BigNumber* . **from** ( value [ , format="fixed" ] ) **=>** *[FixedNumber](./)* +#### *FixedNumber* . **from** ( value [ , format="fixed" ] ) **=>** *[FixedNumber](./)* Returns an instance of a **FixedNumber** for *value* as a *format*. -#### *BigNumber* . **fromBytes** ( aBytesLike [ , format="fixed" ] ) **=>** *[FixedNumber](./)* +#### *FixedNumber* . **fromBytes** ( aBytesLike [ , format="fixed" ] ) **=>** *[FixedNumber](./)* Returns an instance of a **FixedNumber** for *value* as a *format*. -#### *BigNumber* . **fromString** ( value [ , format="fixed" ] ) **=>** *[FixedNumber](./)* +#### *FixedNumber* . **fromString** ( value [ , format="fixed" ] ) **=>** *[FixedNumber](./)* Returns an instance of a **FixedNumber** for *value* as a *format*. The *value* must not contain more decimals than the *format* permits. @@ -58,7 +126,7 @@ not contain more decimals than the *format* permits. -#### *BigNumber* . **fromValue** ( value [ , decimals=0 [ , format="fixed" ] ] ) **=>** *[FixedNumber](./)* +#### *FixedNumber* . **fromValue** ( value [ , decimals=0 [ , format="fixed" ] ] ) **=>** *[FixedNumber](./)* Returns an instance of a **FixedNumber** for *value* with *decimals* as a *format*. @@ -158,7 +226,7 @@ Due to rounding in JavaScript numbers, the value is only approximate. -#### *BigNumber* . **isFixedNumber** ( value ) **=>** *boolean* +#### *FixedNumber* . **isFixedNumber** ( value ) **=>** *boolean* Returns true if and only if *value* is a **FixedNumber**. @@ -167,4 +235,4 @@ Returns true if and only if *value* is a **FixedNumber**. ----- -**Content Hash:** e58731f51c5fe088aa89a78c7649ec914dce2d65dac9c1de3c4b3a89c911b46b \ No newline at end of file +**Content Hash:** bb1362f52031bfae2d988bdc25d31a560da087c2eba5988d70fa40e659766960 \ No newline at end of file diff --git a/docs/api/utils/fixednumber/index.html b/docs/api/utils/fixednumber/index.html index 40705fe4f..445d5c330 100644 --- a/docs/api/utils/fixednumber/index.html +++ b/docs/api/utils/fixednumber/index.html @@ -1,17 +1,26 @@ -Fixed Number
+Fixed Number

FixedNumber

-

Types

+

FixedFormat

+

A FixedFormat is a simple object which represents a decimal (base-10) Fixed-Point data representation. Usually using this class directly is uneccessary, as passing in a Format Strings directly into the FixedNumber will automatically create this.

+

Format Strings

+

A format string is composed of three components, including signed-ness, bit-width and number of decimals.

A signed format string begins with fixed, which an unsigned format string begins with ufixed, followed by the width (in bits) and the number of decimals.

The width must be conguent to 0 mod 8 (i.e. (width % 8) == 0) and no larger than 256 bits and the number of decimals must be no larger than 80.

For example:

  • fixed128x18 is signed, 128 bits wide and has 18 decimals; this is useful for most purposes
  • fixed32x0 is signed, 32 bits wide and has 0 decimals; this would be the same as a ``int32_t` in C
  • ufixed32x0 is unsigned, 32 bits wide and has 0 decimals; this would be the same as a ``uint32_t` in C
  • fixed is shorthand for ``fixed128x18`
  • ufixed is shorthand for ``ufixed128x18`
+

Creating Instances

-

FixedFormat

-

TODO

+
FixedFormat . from ( value = "fixed128x18" ) FixedFormat

Returns a new instance of a FixedFormat defined by value. Any valid Format Strings may be passed in as well as any object which has any of signed, width and decimals defined, including a FixedFormat object.

+

Properties

+ +
fixedFormat . signed boolean

+
fixedFormat . width number

+
fixedFormat . decimals number

+
fixedFormat . name string

"fixed"

A shorthand for fixed128x80.

Creating Instances

The FixedNumber constructor cannot be called directly. There are several static methods for creating a FixedNumber.

-
BigNumber . from ( value [ , format = "fixed" ] ) FixedNumber

Returns an instance of a FixedNumber for value as a format.

-
BigNumber . fromBytes ( aBytesLike [ , format = "fixed" ] ) FixedNumber

Returns an instance of a FixedNumber for value as a format.

-
BigNumber . fromString ( value [ , format = "fixed" ] ) FixedNumber

Returns an instance of a FixedNumber for value as a format. The value must not contain more decimals than the format permits.

-
BigNumber . fromValue ( value [ , decimals = 0 [ , format = "fixed" ] ] ) FixedNumber

Returns an instance of a FixedNumber for value with decimals as a format.

+
FixedNumber . from ( value [ , format = "fixed" ] ) FixedNumber

Returns an instance of a FixedNumber for value as a format.

+
FixedNumber . fromBytes ( aBytesLike [ , format = "fixed" ] ) FixedNumber

Returns an instance of a FixedNumber for value as a format.

+
FixedNumber . fromString ( value [ , format = "fixed" ] ) FixedNumber

Returns an instance of a FixedNumber for value as a format. The value must not contain more decimals than the format permits.

+
FixedNumber . fromValue ( value [ , decimals = 0 [ , format = "fixed" ] ] ) FixedNumber

Returns an instance of a FixedNumber for value with decimals as a format.

Properties

fixednumber . format

The FixedFormat of fixednumber.

@@ -19,17 +28,17 @@

Math Operations

-
fixednumber . addUnsafe ( otherValue ) FixedNumber

Returns a new FixedNumber with the value of fixedvalue + otherValue.

-
fixednumber . subUnsafe ( otherValue ) FixedNumber

Returns a new FixedNumber with the value of fixedvalue otherValue.

-
fixednumber . mulUnsafe ( otherValue ) FixedNumber

Returns a new FixedNumber with the value of fixedvalue × otherValue.

-
fixednumber . divUnsafe ( otherValue ) FixedNumber

Returns a new FixedNumber with the value of fixedvalue ÷ otherValue.

-
fixednumber . round ( [ decimals = 0 ] ) FixedNumber

Returns a new FixedNumber with the value of fixedvalue rounded to decimals.

+
fixednumber . addUnsafe ( otherValue ) FixedNumber

Returns a new FixedNumber with the value of fixedvalue + otherValue.

+
fixednumber . subUnsafe ( otherValue ) FixedNumber

Returns a new FixedNumber with the value of fixedvalue otherValue.

+
fixednumber . mulUnsafe ( otherValue ) FixedNumber

Returns a new FixedNumber with the value of fixedvalue × otherValue.

+
fixednumber . divUnsafe ( otherValue ) FixedNumber

Returns a new FixedNumber with the value of fixedvalue ÷ otherValue.

+
fixednumber . round ( [ decimals = 0 ] ) FixedNumber

Returns a new FixedNumber with the value of fixedvalue rounded to decimals.

Conversion

-
fixednumber . toFormat ( format ) FixedNumber

Returns a new FixedNumber with the value of fixedvalue with format.

-
fixednumber . toHexString ( ) string

Returns a Hexstring representation of fixednumber.

-
fixednumber . toString ( ) string

Returns a string representation of fixednumber.

-
fixednumber . toUnsafeFloat ( ) float

Returns a floating-point JavaScript number value of fixednumber. Due to rounding in JavaScript numbers, the value is only approximate.

+
fixednumber . toFormat ( format ) FixedNumber

Returns a new FixedNumber with the value of fixedvalue with format.

+
fixednumber . toHexString ( ) string

Returns a Hexstring representation of fixednumber.

+
fixednumber . toString ( ) string

Returns a string representation of fixednumber.

+
fixednumber . toUnsafeFloat ( ) float

Returns a floating-point JavaScript number value of fixednumber. Due to rounding in JavaScript numbers, the value is only approximate.

Inspection

-
BigNumber . isFixedNumber ( value ) boolean

Returns true if and only if value is a FixedNumber.

\ No newline at end of file +
FixedNumber . isFixedNumber ( value ) boolean

Returns true if and only if value is a FixedNumber.

\ No newline at end of file diff --git a/docs/api/utils/hashing/README.md b/docs/api/utils/hashing/README.md index a459b20a7..bdd7f94e1 100644 --- a/docs/api/utils/hashing/README.md +++ b/docs/api/utils/hashing/README.md @@ -20,35 +20,35 @@ The [Cryptographic Hash Functions](https://en.wikipedia.org/wiki/Cryptographic_h are a specific family of hash functions. -#### *utils* . **keccak256** ( aBytesLike ) **=>** *[DataHexstring](../bytes)* +#### *ethers* . *utils* . **keccak256** ( aBytesLike ) **=>** *string< [DataHexstring](../bytes)< 32 > >* Returns the [KECCAK256](https://en.wikipedia.org/wiki/SHA-3) digest *aBytesLike*. -#### *utils* . **ripemd160** ( aBytesLike ) **=>** *[DataHexstring](../bytes)* +#### *ethers* . *utils* . **ripemd160** ( aBytesLike ) **=>** *string< [DataHexstring](../bytes)< 20 > >* Returns the [RIPEMD-160](https://en.m.wikipedia.org/wiki/RIPEMD) digest of *aBytesLike*. -#### *utils* . **sha256** ( aBytesLike ) **=>** *[DataHexstring](../bytes)* +#### *ethers* . *utils* . **sha256** ( aBytesLike ) **=>** *string< [DataHexstring](../bytes)< 32 > >* Returns the [SHA2-256](https://en.wikipedia.org/wiki/SHA-2) digest of *aBytesLike*. -#### *utils* . **sha512** ( aBytesLike ) **=>** *[DataHexstring](../bytes)* +#### *ethers* . *utils* . **sha512** ( aBytesLike ) **=>** *string< [DataHexstring](../bytes)< 64 > >* Returns the [SHA2-512](https://en.wikipedia.org/wiki/SHA-2) digest of *aBytesLike*. -#### *utils* . **computeHmac** ( algorithm , key , data ) **=>** *[DataHexstring](../bytes)* +#### *ethers* . *utils* . **computeHmac** ( algorithm , key , data ) **=>** *string< [DataHexstring](../bytes) >* Returns the [HMAC](https://en.wikipedia.org/wiki/HMAC) of *data* with *key* using the [Algorithm](./) *algorithm*. @@ -60,14 +60,14 @@ using the [Algorithm](./) *algorithm*. -#### *utils* . *SupportedAlgorithms* . **sha256** **=>** *string* +#### *ethers* . *utils* . *SupportedAlgorithm* . **sha256** **=>** *string* Use the [SHA2-256](https://en.wikipedia.org/wiki/SHA-2) hash algorithm. -#### *utils* . *SupportedAlgorithms* . **sha512** **=>** *string* +#### *ethers* . *utils* . *SupportedAlgorithm* . **sha512** **=>** *string* Use the [SHA2-512](https://en.wikipedia.org/wiki/SHA-2) hash algorithm. @@ -79,23 +79,23 @@ Common Hashing Helpers -#### *utils* . **hashMessage** ( message ) **=>** *[DataHexstring](../bytes)* +#### *ethers* . *utils* . **hashMessage** ( message ) **=>** *string< [DataHexstring](../bytes)< 32 > >* Computes the Ethereum message digest of *message*. Ethereum messages are -converted to UTF-8 bytes and prefixed with `x19Ethereum Signed Message:` +converted to UTF-8 bytes and prefixed with `\x19Ethereum Signed Message:` and the length of *message*. -#### *utils* . **id** ( text ) **=>** *[DataHexstring](../bytes)* +#### *ethers* . *utils* . **id** ( text ) **=>** *string< [DataHexstring](../bytes)< 32 > >* The Ethereum Identity function computs the keccak256 hash of the *text* bytes. -#### *utils* . **namehash** ( name ) **=>** *[DataHexstring](../bytes)* +#### *ethers* . *utils* . **namehash** ( name ) **=>** *string< [DataHexstring](../bytes)< 32 > >* Returns the [ENS Namehash](https://docs.ens.domains/contract-api-reference/name-processing#hashing-names) of *name*. @@ -111,7 +111,7 @@ When using the Solidity `abi.packEncoded(...)` function, a non-standard the tightly packing algorithm. -#### *utils* . **solidityPack** ( arrayOfTypes , arrayOfValues ) **=>** *[DataHexstring](../bytes)* +#### *ethers* . *utils* . **solidityPack** ( arrayOfTypes , arrayOfValues ) **=>** *string< [DataHexstring](../bytes) >* Returns the non-standard encoded *arrayOfValues* packed according to their respecive type in *arrayOfTypes*. @@ -119,7 +119,7 @@ their respecive type in *arrayOfTypes*. -#### *utils* . **solidityKeccak256** ( arrayOfTypes , arrayOfValues ) **=>** *[DataHexstring](../bytes)* +#### *ethers* . *utils* . **solidityKeccak256** ( arrayOfTypes , arrayOfValues ) **=>** *string< [DataHexstring](../bytes)< 32 > >* Returns the KECCAK256 of the non-standard encoded *arrayOfValues* packed according to their respective type in *arrayOfTypes*. @@ -127,7 +127,7 @@ according to their respective type in *arrayOfTypes*. -#### *utils* . **soliditySha256** ( arrayOfTypes , arrayOfValues ) **=>** *[DataHexstring](../bytes)* +#### *ethers* . *utils* . **soliditySha256** ( arrayOfTypes , arrayOfValues ) **=>** *string< [DataHexstring](../bytes)< 32 > >* Returns the SHA2-256 of the non-standard encoded *arrayOfValues* packed according to their respective type in *arrayOfTypes*. @@ -137,4 +137,4 @@ according to their respective type in *arrayOfTypes*. ----- -**Content Hash:** 53b7b2b1fe243aebd3d5ff29c578538d0d068b0ff60b3426f7208cbf9f13d312 \ No newline at end of file +**Content Hash:** 2fd8814fdbe671ecc9c4aa5a9e248528f076bc34c0a1c26caef769d704d24b8b \ No newline at end of file diff --git a/docs/api/utils/hashing/index.html b/docs/api/utils/hashing/index.html index 10d34d990..2e7db082b 100644 --- a/docs/api/utils/hashing/index.html +++ b/docs/api/utils/hashing/index.html @@ -1,24 +1,24 @@ -Hashing
+Hashing

Hashing Algorithms

Explain what hash functions are?

Cryptographic Hashing

The Cryptographic Hash Functions are a specific family of hash functions.

-
utils . keccak256 ( aBytesLike ) DataHexstring

Returns the KECCAK256 digest aBytesLike//.

-
utils . ripemd160 ( aBytesLike ) DataHexstring

Returns the RIPEMD-160 digest of aBytesLike//.

-
utils . sha256 ( aBytesLike ) DataHexstring

Returns the SHA2-256 digest of aBytesLike//.

-
utils . sha512 ( aBytesLike ) DataHexstring

Returns the SHA2-512 digest of aBytesLike//.

-
utils . computeHmac ( algorithm , key , data ) DataHexstring

Returns the HMAC of data with key using the Algorithm algorithm//.

-

HMAC Supported Algorithms

+
ethers . utils . keccak256 ( aBytesLike ) string< DataHexstring< 32 > >

Returns the KECCAK256 digest aBytesLike//.

+
ethers . utils . ripemd160 ( aBytesLike ) string< DataHexstring< 20 > >

Returns the RIPEMD-160 digest of aBytesLike//.

+
ethers . utils . sha256 ( aBytesLike ) string< DataHexstring< 32 > >

Returns the SHA2-256 digest of aBytesLike//.

+
ethers . utils . sha512 ( aBytesLike ) string< DataHexstring< 64 > >

Returns the SHA2-512 digest of aBytesLike//.

+
ethers . utils . computeHmac ( algorithm , key , data ) string< DataHexstring >

Returns the HMAC of data with key using the Algorithm algorithm//.

+

HMAC Supported Algorithms

-
utils . SupportedAlgorithms . sha256 string

Use the SHA2-256 hash algorithm.

-
utils . SupportedAlgorithms . sha512 string

Use the SHA2-512 hash algorithm.

+
ethers . utils . SupportedAlgorithm . sha256 string

Use the SHA2-256 hash algorithm.

+
ethers . utils . SupportedAlgorithm . sha512 string

Use the SHA2-512 hash algorithm.

Common Hashing Helpers

-
utils . hashMessage ( message ) DataHexstring

Computes the Ethereum message digest of message. Ethereum messages are converted to UTF-8 bytes and prefixed with x19Ethereum Signed Message: and the length of message.

-
utils . id ( text ) DataHexstring

The Ethereum Identity function computs the keccak256 hash of the text bytes.

-
utils . namehash ( name ) DataHexstring

Returns the ENS Namehash of name//.

+
ethers . utils . hashMessage ( message ) string< DataHexstring< 32 > >

Computes the Ethereum message digest of message. Ethereum messages are converted to UTF-8 bytes and prefixed with \x19Ethereum Signed Message: and the length of message.

+
ethers . utils . id ( text ) string< DataHexstring< 32 > >

The Ethereum Identity function computs the keccak256 hash of the text bytes.

+
ethers . utils . namehash ( name ) string< DataHexstring< 32 > >

Returns the ENS Namehash of name.

Solidity Hashing Algorithms

When using the Solidity abi.packEncoded(...) function, a non-standard tightly packed version of encoding is used. These functions implement the tightly packing algorithm.

-
utils . solidityPack ( arrayOfTypes , arrayOfValues ) DataHexstring

Returns the non-standard encoded arrayOfValues packed according to their respecive type in arrayOfTypes.

-
utils . solidityKeccak256 ( arrayOfTypes , arrayOfValues ) DataHexstring

Returns the KECCAK256 of the non-standard encoded arrayOfValues packed according to their respective type in arrayOfTypes.

-
utils . soliditySha256 ( arrayOfTypes , arrayOfValues ) DataHexstring

Returns the SHA2-256 of the non-standard encoded arrayOfValues packed according to their respective type in arrayOfTypes.

\ No newline at end of file +
ethers . utils . solidityPack ( arrayOfTypes , arrayOfValues ) string< DataHexstring >

Returns the non-standard encoded arrayOfValues packed according to their respecive type in arrayOfTypes.

+
ethers . utils . solidityKeccak256 ( arrayOfTypes , arrayOfValues ) string< DataHexstring< 32 > >

Returns the KECCAK256 of the non-standard encoded arrayOfValues packed according to their respective type in arrayOfTypes.

+
ethers . utils . soliditySha256 ( arrayOfTypes , arrayOfValues ) string< DataHexstring< 32 > >

Returns the SHA2-256 of the non-standard encoded arrayOfValues packed according to their respective type in arrayOfTypes.

\ No newline at end of file diff --git a/docs/api/utils/index.html b/docs/api/utils/index.html index f00286e48..82ed06c20 100644 --- a/docs/api/utils/index.html +++ b/docs/api/utils/index.html @@ -1,4 +1,4 @@ -Utilities
+Utilities \ No newline at end of file +
\ No newline at end of file diff --git a/docs/api/utils/properties/README.md b/docs/api/utils/properties/README.md new file mode 100644 index 000000000..864c4e28c --- /dev/null +++ b/docs/api/utils/properties/README.md @@ -0,0 +1,22 @@ +----- + +Documentation: [html](https://docs-beta.ethers.io/) + +----- + + +Property Utilities +================== + + + +#### *utils* . **resolveProperties** ( anObject ) **=>** *Promise< any >* + + + + + + + +----- +**Content Hash:** 6966c4808403140c68bb04e1fa15591474d5dd336cc882150ae390b0b80257f9 \ No newline at end of file diff --git a/docs/api/utils/properties/index.html b/docs/api/utils/properties/index.html new file mode 100644 index 000000000..63a38cc1a --- /dev/null +++ b/docs/api/utils/properties/index.html @@ -0,0 +1,4 @@ +Property Utilities
+

Property Utilities

+ +
utils . resolveProperties ( anObject ) Promise< any >

\ No newline at end of file diff --git a/docs/api/utils/signing-key/README.md b/docs/api/utils/signing-key/README.md new file mode 100644 index 000000000..48fdc44db --- /dev/null +++ b/docs/api/utils/signing-key/README.md @@ -0,0 +1,27 @@ +----- + +Documentation: [html](https://docs-beta.ethers.io/) + +----- + + +Signing Key +=========== + + + +#### *ethers* . *utils* . **verifyMessage** ( message , signature ) **=>** *string< [Address](../address) >* + +Returns the address that signed *message* producing *signature*. The +signature may have a non-canonical v (i.e. does not need to be 27 or 28), +in which case it will be normalized to compute the `recoveryParam` which +will then be used to compute the address; this allows systems which use +the v to encode additional data (such as [EIP-155](https://eips.ethereum.org/EIPS/eip-155)) +to be used since the v parameter is still completely non-ambiguous. + + + + + +----- +**Content Hash:** 91ee024442e5991be731bab1bf05310b3540825acc1c1c7dffa608eff450430b \ No newline at end of file diff --git a/docs/api/utils/signing-key/index.html b/docs/api/utils/signing-key/index.html new file mode 100644 index 000000000..d81467693 --- /dev/null +++ b/docs/api/utils/signing-key/index.html @@ -0,0 +1,4 @@ +Signing Keys
+

Signing Key

+ +
ethers . utils . verifyMessage ( message , signature ) string< Address >

Returns the address that signed message producing signature. The signature may have a non-canonical v (i.e. does not need to be 27 or 28), in which case it will be normalized to compute the `recoveryParam` which will then be used to compute the address; this allows systems which use the v to encode additional data (such as EIP-155) to be used since the v parameter is still completely non-ambiguous.

\ No newline at end of file diff --git a/docs/api/utils/strings/README.md b/docs/api/utils/strings/README.md index 57257b2e7..cb20cfb4c 100644 --- a/docs/api/utils/strings/README.md +++ b/docs/api/utils/strings/README.md @@ -35,14 +35,14 @@ since UTF-8 requires multiple bytes to encode international characters. -#### *utils* . **parseBytes32String** ( aBytesLike ) **=>** *string* +#### *ethers* . *utils* . **parseBytes32String** ( aBytesLike ) **=>** *string* Returns the decoded string represented by the `Bytes32` encoded data. -#### *utils* . **formatBytes32String** ( text ) **=>** *string* +#### *ethers* . *utils* . **formatBytes32String** ( text ) **=>** *string< [DataHexstring](../bytes)< 32 > >* Returns a `bytes32` string representation of *text*. If the length of *text* exceeds 31 bytes, it will throw an error. @@ -55,7 +55,7 @@ UTF-8 Strings -#### *utils* . **toUtf8Bytes** ( text [ , form=current ] ) **=>** *Uint8Array* +#### *ethers* . *utils* . **toUtf8Bytes** ( text [ , form=current ] ) **=>** *Uint8Array* Returns the UTF-8 bytes of *text*, optionally normalizing it using the [UnicodeNormalizationForm](./) *form*. @@ -63,12 +63,17 @@ Returns the UTF-8 bytes of *text*, optionally normalizing it using the -#### *utils* . **toUtf8CodePoints** ( aBytesLike [ , form=current ] ) **=>** *Array< number >* +#### *ethers* . *utils* . **toUtf8CodePoints** ( text [ , form=current ] ) **=>** *Array< number >* -Returns the Array of codepoints of *aBytesLike*, optionally normalizing it using the +Returns the Array of codepoints of *text*, optionally normalized using the [UnicodeNormalizationForm](./) *form*. -**Note:** This function correctly splits each user-perceived character into + + + +#### Note + +This function correctly splits each **user-perceived character** into its codepoint, accounting for surrogate pairs. This should not be confused with `string.split("")`, which destroys surrogate pairs, spliting between each UTF-16 codeunit instead. @@ -76,16 +81,19 @@ codeunit instead. -#### *utils* . **toUtf8String** ( aBytesLike [ , ignoreErrors=false ] ) **=>** *string* +#### *ethers* . *utils* . **toUtf8String** ( aBytesLike [ , onError=error ] ) **=>** *string* -Returns the string represented by the UTF-8 bytes of *aBytesLike*. This will -throw an error for invalid surrogates, overlong sequences or other UTF-8 issues, -unless *ignoreErrors* is specified. +Returns the string represented by the UTF-8 bytes of *aBytesLike*. + +The *onError* is a [Custom UTF-8 Error function](./) and if not specified +it defaults to the [error](./) function, which throws an error +on **any** UTF-8 error. -### UnicodeNormalizationForm +UnicodeNormalizationForm +------------------------ There are several [commonly used forms](https://en.wikipedia.org/wiki/Unicode_equivalence) @@ -93,14 +101,14 @@ when normalizing UTF-8 data, which allow strings to be compared or hashed in a s way. -#### *utils* . *UnicodeNormalizationForm* . **current** +#### *ethers* . *utils* . *UnicodeNormalizationForm* . **current** Maintain the current normalization form. -#### *utils* . *UnicodeNormalizationForm* . **NFC** +#### *ethers* . *utils* . *UnicodeNormalizationForm* . **NFC** The Composed Normalization Form. This form uses single codepoints which represent the fully composed character. @@ -110,7 +118,7 @@ For example, the **é** is a single codepoint, `0x00e9`. -#### *utils* . *UnicodeNormalizationForm* . **NFD** +#### *ethers* . *utils* . *UnicodeNormalizationForm* . **NFD** The Decomposed Normalization Form. This form uses multiple codepoints (when necessary) to compose a character. @@ -123,7 +131,7 @@ indicates the previous character should have an acute accent. -#### *utils* . *UnicodeNormalizationForm* . **NFKC** +#### *ethers* . *utils* . *UnicodeNormalizationForm* . **NFKC** The Composed Normalization Form with Canonical Equivalence. The Canonical representation folds characters which have the same syntactic representation @@ -135,7 +143,7 @@ codepoint `"0x2160"`, is folded into the capital letter I, `"0x0049"`. -#### *utils* . *UnicodeNormalizationForm* . **NFKD** +#### *ethers* . *utils* . *UnicodeNormalizationForm* . **NFKD** The Decomposed Normalization Form with Canonical Equivalence. See NFKC for more an example. @@ -152,6 +160,145 @@ it should **not** be considered a method to acheive *any* level of security from +Custom UTF-8 Error Handling +--------------------------- + + +When converting a string to its codepoints, there is the possibility +of invalid byte sequences. Since certain situations may need specific +ways to handle UTF-8 errors, a custom error handling function can be used, +which has the signature: + + +#### **errorFunction** ( reason , offset , bytes , output [ , badCodepoint ] ) **=>** *number* + +The *reason* is one of the [UTF-8 Error Reasons](./), *offset* is the index +into *bytes* where the error was first encountered, output is the list +of codepoints already processed (and may be modified) and in certain Error +Reasons, the *badCodepoint* indicates the currently computed codepoint, +but which would be rejected because its value is invalid. + +This function should return the number of bytes to skip past keeping in +mind the value at *offset* will already be consumed. + + + + +### UTF-8 Error Reasons + + + +#### *ethers* . *utils* . *Utf8ErrorReason* . **BAD_PREFIX** + +A byte was encountered which is invalid to begin a UTF-8 byte +sequence with. + + + + +#### *ethers* . *utils* . *Utf8ErrorReason* . **MISSING_CONTINUE** + +A UTF-8 sequence was begun, but did not have enough continuation +bytes for the sequence. For this error the *ofset* is the index +at which a continuation byte was expected. + + + + +#### *ethers* . *utils* . *Utf8ErrorReason* . **OUT_OF_RANGE** + +The computed codepoint is outside the range for valid UTF-8 +codepoints (i.e. the codepoint is greater than 0x10ffff). +This reason will pass the computed *badCountpoint* into +the custom error function. + + + + +#### *ethers* . *utils* . *Utf8ErrorReason* . **OVERLONG** + +Due to the way UTF-8 allows variable length byte sequences +to be used, it is possible to have multiple representations +of the same character, which means +[overlong sequences](https://en.wikipedia.org/wiki/UTF-8#Overlong_encodings) +allow for a non-distinguished string to be formed, which can +impact security as multiple strings that are otherwise +equal can have different hashes. + +Generally, overlong sequences are an attempt to circumvent +some part of security, but in rare cases may be produced by +lazy libraries or used to encode the null terminating +character in a way that is safe to include in a `char*`. + +This reason will pass the computed *badCountpoint* into the +custom error function, which is actually a valid codepoint, just +one that was arrived at through unsafe methods. + + + + +#### *ethers* . *utils* . *Utf8ErrorReason* . **OVERRUN** + +The string does not have enough characters remaining for the +length of this sequence. + + + + +#### *ethers* . *utils* . *Utf8ErrorReason* . **UNEXPECTED_CONTINUE** + +This error is similar to BAD_PREFIX, since a continuation byte +cannot begin a valid sequence, but many may wish to process this +differently. However, most developers would want to trap this +and perform the same operation as a BAD_PREFIX. + + + + +#### *ethers* . *utils* . *Utf8ErrorReason* . **UTF16_SURROGATE** + +The computed codepoint represents a value reserved for +UTF-16 surrogate pairs. +This reason will pass the computed surrogate half +*badCountpoint* into the custom error function. + + + + +### Provided UTF-8 Error Handling Functions + + +There are already several functions available for the most common +situations. + + +#### *ethers* . *utils* . *Utf8ErrorFuncs* . **error** + +The will throw an error on **any** error with a UTF-8 sequence, including +invalid prefix bytes, overlong sequences, UTF-16 surrogate pairs. + + + + +#### *ethers* . *utils* . *Utf8ErrorFuncs* . **ignore** + +This will drop all invalid sequences (by consuming invalid prefix bytes and +any following continuation bytes) from the final string as well as permit +overlong sequences to be converted to their equivalent string. + + + + +#### *ethers* . *utils* . *Utf8ErrorFuncs* . **replace** + +This will replace all invalid sequences (by consuming invalid prefix bytes and +any following continuation bytes) with the +[UTF-8 Replacement Character](https://en.wikipedia.org/wiki/Specials_%28Unicode_block%29#Replacement_character), +(i.e. U+FFFD). + + + + ----- -**Content Hash:** e38fe18f76e58587f7ed1c4558a5b3ec177eee1a5e71b4c88fa6d496154fdd8a \ No newline at end of file +**Content Hash:** c3856e40d58241c0a7f5bc29928731971ede8e8e8c75e6eda97778c9b952e1f0 \ No newline at end of file diff --git a/docs/api/utils/strings/index.html b/docs/api/utils/strings/index.html index 3021930af..f81934695 100644 --- a/docs/api/utils/strings/index.html +++ b/docs/api/utils/strings/index.html @@ -1,21 +1,39 @@ -Strings
+Strings

Strings

Tra la la

Bytes32String

A string in Solidity is length prefixed with its 256-bit (32 byte) length, which means that even short strings require 2 words (64 bytes) of storage.

In many cases, we deal with short strings, so instead of prefixing the string with its length, we can null-terminate it and fit it in a single word (32 bytes). Since we need only a single byte for the null termination, we can store strings up to 31 bytes long in a word.

Note

Strings that are 31 bytes long may contain fewer than 31 characters, since UTF-8 requires multiple bytes to encode international characters.

-
utils . parseBytes32String ( aBytesLike ) string

Returns the decoded string represented by the Bytes32 encoded data.

-
utils . formatBytes32String ( text ) string

Returns a bytes32 string representation of text. If the length of text exceeds 31 bytes, it will throw an error.

+
ethers . utils . parseBytes32String ( aBytesLike ) string

Returns the decoded string represented by the Bytes32 encoded data.

+
ethers . utils . formatBytes32String ( text ) string< DataHexstring< 32 > >

Returns a bytes32 string representation of text. If the length of text exceeds 31 bytes, it will throw an error.

UTF-8 Strings

-
utils . toUtf8Bytes ( text [ , form = current ] ) Uint8Array

Returns the UTF-8 bytes of text, optionally normalizing it using the UnicodeNormalizationForm form.

-
utils . toUtf8CodePoints ( aBytesLike [ , form = current ] ) Array< number >

Returns the Array of codepoints of aBytesLike, optionally normalizing it using the UnicodeNormalizationForm form.

Note: This function correctly splits each user-perceived character into its codepoint, accounting for surrogate pairs. This should not be confused with string.split(""), which destroys surrogate pairs, spliting between each UTF-16 codeunit instead.

-
utils . toUtf8String ( aBytesLike [ , ignoreErrors = false ] ) string

Returns the string represented by the UTF-8 bytes of aBytesLike. This will throw an error for invalid surrogates, overlong sequences or other UTF-8 issues, unless ignoreErrors is specified.

-

UnicodeNormalizationForm

+
ethers . utils . toUtf8Bytes ( text [ , form = current ] ) Uint8Array

Returns the UTF-8 bytes of text, optionally normalizing it using the UnicodeNormalizationForm form.

+
ethers . utils . toUtf8CodePoints ( text [ , form = current ] ) Array< number >

Returns the Array of codepoints of text, optionally normalized using the UnicodeNormalizationForm form.

+
Note

This function correctly splits each user-perceived character into its codepoint, accounting for surrogate pairs. This should not be confused with string.split(""), which destroys surrogate pairs, spliting between each UTF-16 codeunit instead.

+
ethers . utils . toUtf8String ( aBytesLike [ , onError = error ] ) string

Returns the string represented by the UTF-8 bytes of aBytesLike.

The onError is a Custom UTF-8 Error function and if not specified it defaults to the error function, which throws an error on any UTF-8 error.

+

UnicodeNormalizationForm

There are several commonly used forms when normalizing UTF-8 data, which allow strings to be compared or hashed in a stable way.

-
utils . UnicodeNormalizationForm . current

Maintain the current normalization form.

-
utils . UnicodeNormalizationForm . NFC

The Composed Normalization Form. This form uses single codepoints which represent the fully composed character.

For example, the é is a single codepoint, 0x00e9.

-
utils . UnicodeNormalizationForm . NFD

The Decomposed Normalization Form. This form uses multiple codepoints (when necessary) to compose a character.

For example, the é is made up of two codepoints, "0x0065" (which is the letter "e") and "0x0301" which is a special diacritic UTF-8 codepoint which indicates the previous character should have an acute accent.

-
utils . UnicodeNormalizationForm . NFKC

The Composed Normalization Form with Canonical Equivalence. The Canonical representation folds characters which have the same syntactic representation but different semantic meaning.

For example, the Roman Numeral I, which has a UTF-8 codepoint "0x2160", is folded into the capital letter I, "0x0049".

-
utils . UnicodeNormalizationForm . NFKD

The Decomposed Normalization Form with Canonical Equivalence. See NFKC for more an example.

-
Note

Only certain specified characters are folded in Canonical Equivalence, and thus it should not be considered a method to acheive any level of security from homoglyph attacks.

\ No newline at end of file +
ethers . utils . UnicodeNormalizationForm . current

Maintain the current normalization form.

+
ethers . utils . UnicodeNormalizationForm . NFC

The Composed Normalization Form. This form uses single codepoints which represent the fully composed character.

For example, the é is a single codepoint, 0x00e9.

+
ethers . utils . UnicodeNormalizationForm . NFD

The Decomposed Normalization Form. This form uses multiple codepoints (when necessary) to compose a character.

For example, the é is made up of two codepoints, "0x0065" (which is the letter "e") and "0x0301" which is a special diacritic UTF-8 codepoint which indicates the previous character should have an acute accent.

+
ethers . utils . UnicodeNormalizationForm . NFKC

The Composed Normalization Form with Canonical Equivalence. The Canonical representation folds characters which have the same syntactic representation but different semantic meaning.

For example, the Roman Numeral I, which has a UTF-8 codepoint "0x2160", is folded into the capital letter I, "0x0049".

+
ethers . utils . UnicodeNormalizationForm . NFKD

The Decomposed Normalization Form with Canonical Equivalence. See NFKC for more an example.

+
Note

Only certain specified characters are folded in Canonical Equivalence, and thus it should not be considered a method to acheive any level of security from homoglyph attacks.

+

Custom UTF-8 Error Handling

+

When converting a string to its codepoints, there is the possibility of invalid byte sequences. Since certain situations may need specific ways to handle UTF-8 errors, a custom error handling function can be used, which has the signature:

+
errorFunction ( reason , offset , bytes , output [ , badCodepoint ] ) number

The reason is one of the UTF-8 Error Reasons, offset is the index into bytes where the error was first encountered, output is the list of codepoints already processed (and may be modified) and in certain Error Reasons, the badCodepoint indicates the currently computed codepoint, but which would be rejected because its value is invalid.

This function should return the number of bytes to skip past keeping in mind the value at offset will already be consumed.

+

UTF-8 Error Reasons

+ +
ethers . utils . Utf8ErrorReason . BAD_PREFIX

A byte was encountered which is invalid to begin a UTF-8 byte sequence with.

+
ethers . utils . Utf8ErrorReason . MISSING_CONTINUE

A UTF-8 sequence was begun, but did not have enough continuation bytes for the sequence. For this error the ofset is the index at which a continuation byte was expected.

+
ethers . utils . Utf8ErrorReason . OUT_OF_RANGE

The computed codepoint is outside the range for valid UTF-8 codepoints (i.e. the codepoint is greater than 0x10ffff). This reason will pass the computed badCountpoint into the custom error function.

+
ethers . utils . Utf8ErrorReason . OVERLONG

Due to the way UTF-8 allows variable length byte sequences to be used, it is possible to have multiple representations of the same character, which means overlong sequences allow for a non-distinguished string to be formed, which can impact security as multiple strings that are otherwise equal can have different hashes.

Generally, overlong sequences are an attempt to circumvent some part of security, but in rare cases may be produced by lazy libraries or used to encode the null terminating character in a way that is safe to include in a char*.

This reason will pass the computed badCountpoint into the custom error function, which is actually a valid codepoint, just one that was arrived at through unsafe methods.

+
ethers . utils . Utf8ErrorReason . OVERRUN

The string does not have enough characters remaining for the length of this sequence.

+
ethers . utils . Utf8ErrorReason . UNEXPECTED_CONTINUE

This error is similar to BAD_PREFIX, since a continuation byte cannot begin a valid sequence, but many may wish to process this differently. However, most developers would want to trap this and perform the same operation as a BAD_PREFIX.

+
ethers . utils . Utf8ErrorReason . UTF16_SURROGATE

The computed codepoint represents a value reserved for UTF-16 surrogate pairs. This reason will pass the computed surrogate half badCountpoint into the custom error function.

+

Provided UTF-8 Error Handling Functions

+

There are already several functions available for the most common situations.

+
ethers . utils . Utf8ErrorFuncs . error

The will throw an error on any error with a UTF-8 sequence, including invalid prefix bytes, overlong sequences, UTF-16 surrogate pairs.

+
ethers . utils . Utf8ErrorFuncs . ignore

This will drop all invalid sequences (by consuming invalid prefix bytes and any following continuation bytes) from the final string as well as permit overlong sequences to be converted to their equivalent string.

+
ethers . utils . Utf8ErrorFuncs . replace

This will replace all invalid sequences (by consuming invalid prefix bytes and any following continuation bytes) with the UTF-8 Replacement Character, (i.e. U+FFFD).

\ No newline at end of file diff --git a/docs/api/utils/transactions/README.md b/docs/api/utils/transactions/README.md new file mode 100644 index 000000000..bf2a88270 --- /dev/null +++ b/docs/api/utils/transactions/README.md @@ -0,0 +1,205 @@ +----- + +Documentation: [html](https://docs-beta.ethers.io/) + +----- + + +Transactions +============ + + + +Types +----- + + + +### UnsignedTransaction + + +An unsigned transaction represents a transaction that has not been signed. + + +#### *unsignedTransaction* . **to** **=>** *string< [Address](../address) >* + + + + + + +#### *unsignedTransaction* . **nonce** **=>** *number* + + + + + + +#### *unsignedTransaction* . **gasLimit** **=>** *[BigNumber](../bignumber)* + + + + + + +#### *unsignedTransaction* . **gasPrice** **=>** *[BigNumber](../bignumber)* + + + + + + +#### *unsignedTransaction* . **data** **=>** *[BytesLike](../bytes)* + + + + + + +#### *unsignedTransaction* . **value** **=>** *[BigNumber](../bignumber)* + + + + + + +#### *unsignedTransaction* . **chainId** **=>** *number* + + + + + + +### Transaction + + +A generic object to represent a transaction. + + +#### *unsignedTransaction* . **hash** **=>** *string< [DataHexstring](../bytes)< 32 > >* + + + + + + +#### *unsignedTransaction* . **to** **=>** *string< [Address](../address) >* + + + + + + +#### *unsignedTransaction* . **from** **=>** *string< [Address](../address) >* + + + + + + +#### *unsignedTransaction* . **nonce** **=>** *number* + + + + + + +#### *unsignedTransaction* . **gasLimit** **=>** *[BigNumber](../bignumber)* + + + + + + +#### *unsignedTransaction* . **gasPrice** **=>** *[BigNumber](../bignumber)* + + + + + + +#### *unsignedTransaction* . **data** **=>** *[BytesLike](../bytes)* + + + + + + +#### *unsignedTransaction* . **value** **=>** *[BigNumber](../bignumber)* + + + + + + +#### *unsignedTransaction* . **chainId** **=>** *number* + + + + + + +#### *unsignedTransaction* . **r** **=>** *[BytesLike](../bytes)* + + + + + + +#### *unsignedTransaction* . **s** **=>** *[BytesLike](../bytes)* + + + + + + +#### *unsignedTransaction* . **v** **=>** *number* + + + + + + +Functions +--------- + + + +#### *ethers* . *utils* . **computeAddress** ( publicOrPrivateKey ) **=>** *string< [Address](../address) >* + +Compute the address of *publicOrPrivateKey*. If a public key is +provided, it may be either compressed or uncompressed. + + + + +#### *ethers* . *utils* . **parse** ( aBytesLike ) **=>** *[Transaction](./)* + +Parses the transaction properties from a serialized transactions. + + + + +#### *ethers* . *utils* . **recoverAddress** ( digest , aSignatureLike ) **=>** *string< [Address](../address) >* + +Computes the address that signed *digest* to get *aSignatureLike* using the +ecrecover algorithm. + + + + +#### *ethers* . *utils* . **serialize** ( transaction [ , signature ] ) **=>** *string< [DataHexstring](../bytes) >* + +Computes the serialized *transaction/, optionally signed with *signature//. If +signature is not presented, the unsigned serialized transaction is returned, which can +be used to compute the hash necessary to sign. + +This function uses EIP-155 if a chainId is provided, otherwise legacy serialization is +used. It is **highly** recommended to always specify a *chainId*. + + + + + +----- +**Content Hash:** 51f4a8594ba122a2c43d7b2cffdb2bf461f3212cea828e715a76c76ef8dd1ae1 \ No newline at end of file diff --git a/docs/api/utils/transactions/index.html b/docs/api/utils/transactions/index.html new file mode 100644 index 000000000..06b44f97a --- /dev/null +++ b/docs/api/utils/transactions/index.html @@ -0,0 +1,34 @@ +Transactions
+

Transactions

+ +

Types

+ +

UnsignedTransaction

+

An unsigned transaction represents a transaction that has not been signed.

+
unsignedTransaction . to string< Address >

+
unsignedTransaction . nonce number

+
unsignedTransaction . gasLimit BigNumber

+
unsignedTransaction . gasPrice BigNumber

+
unsignedTransaction . data BytesLike

+
unsignedTransaction . value BigNumber

+
unsignedTransaction . chainId number

+

Transaction

+

A generic object to represent a transaction.

+
unsignedTransaction . hash string< DataHexstring< 32 > >

+
unsignedTransaction . to string< Address >

+
unsignedTransaction . from string< Address >

+
unsignedTransaction . nonce number

+
unsignedTransaction . gasLimit BigNumber

+
unsignedTransaction . gasPrice BigNumber

+
unsignedTransaction . data BytesLike

+
unsignedTransaction . value BigNumber

+
unsignedTransaction . chainId number

+
unsignedTransaction . r BytesLike

+
unsignedTransaction . s BytesLike

+
unsignedTransaction . v number

+

Functions

+ +
ethers . utils . computeAddress ( publicOrPrivateKey ) string< Address >

Compute the address of publicOrPrivateKey. If a public key is provided, it may be either compressed or uncompressed.

+
ethers . utils . parse ( aBytesLike ) Transaction

Parses the transaction properties from a serialized transactions.

+
ethers . utils . recoverAddress ( digest , aSignatureLike ) string< Address >

Computes the address that signed digest to get aSignatureLike using the ecrecover algorithm.

+
ethers . utils . serialize ( transaction [ , signature ] ) string< DataHexstring >

Computes the serialized transaction/, optionally signed with signature//. If signature is not presented, the unsigned serialized transaction is returned, which can be used to compute the hash necessary to sign.

This function uses EIP-155 if a chainId is provided, otherwise legacy serialization is used. It is highly recommended to always specify a chainId.

\ No newline at end of file diff --git a/docs/cli/README.md b/docs/cli/README.md new file mode 100644 index 000000000..e3d41f2fc --- /dev/null +++ b/docs/cli/README.md @@ -0,0 +1,33 @@ +----- + +Documentation: [html](https://docs-beta.ethers.io/) + +----- + + +Command Line Interfaces +======================= + + + +* [Sandbox Utility](ethers) + * [Help](ethers) + * [Examples](ethers) +* [Assembler](asm) + * [Help](asm) + * [Examples](asm) +* [ENS](ens) + * [Help](ens) + * [Examples](ens) +* [TypeScript](typescript) + * [Help](typescript) + * [Examples](typescript) +* [Making Your Own](plugin) + * [CLI](plugin) + * [Plugin](plugin) + * [ArgParser](plugin) + + + +----- +**Content Hash:** 0ab5c6b4f0873f77215595622f14d5908f56d0215b385c9642af8a0fa4d1a90c \ No newline at end of file diff --git a/docs/cli/asm/README.md b/docs/cli/asm/README.md new file mode 100644 index 000000000..3be532e78 --- /dev/null +++ b/docs/cli/asm/README.md @@ -0,0 +1,47 @@ +----- + +Documentation: [html](https://docs-beta.ethers.io/) + +----- + + +Assembler +========= + + +The assembler Command-Line utility allows you to assemble EVM asm files +into deployable bytecode and disassemle EVM bytecode into human-readable +mnemonics. + + +Help +---- + + + +``` +Usage: + ethers-asm [ FILENAME ] [ OPTIONS ] + +OPTIONS + --disassemble Disassemble input bytecode + --define KEY=VALUE provide assembler defines + +OTHER OPTIONS + --debug Show stack traces for errors + --help Show this usage and exit + --version Show this version and exit +``` + + + +Examples +-------- + + +TODO examples + + + +----- +**Content Hash:** d5cc366b4a6de2f4f257de4e23d31c9d523e7c1c4bc9bdd28cfd256ee257c754 \ No newline at end of file diff --git a/docs/cli/asm/index.html b/docs/cli/asm/index.html new file mode 100644 index 000000000..2b95e7447 --- /dev/null +++ b/docs/cli/asm/index.html @@ -0,0 +1,9 @@ +Assembler
+

Assembler

+

The assembler Command-Line utility allows you to assemble EVM asm files into deployable bytecode and disassemle EVM bytecode into human-readable mnemonics.

+

Help

+ +
Usage:
   ethers-asm [ FILENAME ] [ OPTIONS ]

OPTIONS
  --disassemble               Disassemble input bytecode
  --define KEY=VALUE          provide assembler defines

OTHER OPTIONS
  --debug                     Show stack traces for errors
  --help                      Show this usage and exit
  --version                   Show this version and exit
+ +

Examples

+

TODO examples

\ No newline at end of file diff --git a/docs/cli/ens/README.md b/docs/cli/ens/README.md new file mode 100644 index 000000000..4333cbaf8 --- /dev/null +++ b/docs/cli/ens/README.md @@ -0,0 +1,101 @@ +----- + +Documentation: [html](https://docs-beta.ethers.io/) + +----- + + +ENS +=== + + + +Help +---- + + + +``` +Usage: + ethers-ens COMMAND [ ARGS ] [ OPTIONS ] + +COMMANDS + lookup [ NAME | ADDRESS [ ... ] ] + Lookup a name or address + commit NAME Submit a pre-commitment + [ --duration DAYS ] Register duration (default: 365 days) + [ --salt SALT ] SALT to blind the commit with + [ --secret SECRET ] Use id(SECRET) as the salt + [ --owner OWNER ] The target owner (default: current account) + reveal NAME Reveal a previous pre-commitment + [ --duration DAYS ] Register duration (default: 365 days) + [ --salt SALT ] SALT to blind the commit with + [ --secret SECRET ] Use id(SECRET) as the salt + [ --owner OWNER ] The target owner (default: current account) + set-controller NAME Set the controller (default: current account) + [ --address ADDRESS ] Specify another address + set-subnode NAME Set a subnode owner (default: current account) + [ --address ADDRESS ] Specify another address + set-resolver NAME Set the resolver (default: resolver.eth) + [ --address ADDRESS ] Specify another address + set-addr NAME Set the addr record (default: current account) + [ --address ADDRESS ] Specify another address + set-text NAME KEY VALUE Set a text record + set-email NAME EMAIL Set the email text record + set-website NAME URL Set the website text record + set-content NAME HASH Set the IPFS Content Hash + migrate-registrar NAME Migrate from the Legacy to the Permanent Registrar + transfer NAME NEW_OWNER Transfer registrant ownership + reclaim NAME Reset the controller by the registrant + [ --address ADDRESS ] Specify another address + +ACCOUNT OPTIONS + --account FILENAME Load from a file (JSON, RAW or mnemonic) + --account RAW_KEY Use a private key (insecure *) + --account 'MNEMONIC' Use a mnemonic (insecure *) + --account - Use secure entry for a raw key or mnemonic + --account-void ADDRESS Use an address as a void signer + --account-void ENS_NAME Add the resolved address as a void signer + --account-rpc ADDRESS Add the address from a JSON-RPC provider + --account-rpc INDEX Add the index from a JSON-RPC provider + --mnemonic-password Prompt for a password for mnemonics + --xxx-mnemonic-password Prompt for a (experimental) hard password + +PROVIDER OPTIONS (default: all + homestead) + --alchemy Include Alchemy + --etherscan Include Etherscan + --infura Include INFURA + --nodesmith Include nodesmith + --rpc URL Include a custom JSON-RPC + --offline Dump signed transactions (no send) + --network NETWORK Network to connect to (default: homestead) + +TRANSACTION OPTIONS (default: query network) + --gasPrice GWEI Default gas price for transactions(in wei) + --gasLimit GAS Default gas limit for transactions + --nonce NONCE Initial nonce for the first transaction + --yes Always accept Siging and Sending + +OTHER OPTIONS + --wait Wait until transactions are mined + --debug Show stack traces for errors + --help Show this usage and exit + --version Show this version and exit + +(*) By including mnemonics or private keys on the command line they are + possibly readable by other users on your system and may get stored in + your bash history file. This is NOT recommended. +``` + + + +Examples +-------- + + +TODO examples + + + +----- +**Content Hash:** 535334ba246058d715afd01bd59aa14948d6557aca5b2e4e0c4e997aa1eec864 \ No newline at end of file diff --git a/docs/cli/ens/index.html b/docs/cli/ens/index.html new file mode 100644 index 000000000..0a0e5ede9 --- /dev/null +++ b/docs/cli/ens/index.html @@ -0,0 +1,9 @@ +ENS
+

ENS

+ +

Help

+ +
Usage:
   ethers-ens COMMAND [ ARGS ] [ OPTIONS ]

COMMANDS
   lookup [ NAME | ADDRESS [ ... ] ]
                              Lookup a name or address
   commit NAME                Submit a pre-commitment
      [ --duration DAYS ]        Register duration (default: 365 days)
      [ --salt SALT ]            SALT to blind the commit with
      [ --secret SECRET ]        Use id(SECRET) as the salt
      [ --owner OWNER ]          The target owner (default: current account)
   reveal NAME                Reveal a previous pre-commitment
      [ --duration DAYS ]        Register duration (default: 365 days)
      [ --salt SALT ]            SALT to blind the commit with
      [ --secret SECRET ]        Use id(SECRET) as the salt
      [ --owner OWNER ]          The target owner (default: current account)
   set-controller NAME        Set the controller (default: current account)
      [ --address ADDRESS ]      Specify another address
   set-subnode NAME           Set a subnode owner (default: current account)
      [ --address ADDRESS ]      Specify another address
   set-resolver NAME          Set the resolver (default: resolver.eth)
      [ --address ADDRESS ]      Specify another address
   set-addr NAME              Set the addr record (default: current account)
      [ --address ADDRESS ]      Specify another address
   set-text NAME KEY VALUE    Set a text record
   set-email NAME EMAIL       Set the email text record
   set-website NAME URL       Set the website text record
   set-content NAME HASH      Set the IPFS Content Hash
   migrate-registrar NAME     Migrate from the Legacy to the Permanent Registrar
   transfer NAME NEW_OWNER    Transfer registrant ownership
   reclaim NAME               Reset the controller by the registrant
      [ --address ADDRESS ]      Specify another address

ACCOUNT OPTIONS
  --account FILENAME          Load from a file (JSON, RAW or mnemonic)
  --account RAW_KEY           Use a private key (insecure *)
  --account 'MNEMONIC'        Use a mnemonic (insecure *)
  --account -                 Use secure entry for a raw key or mnemonic
  --account-void ADDRESS      Use an address as a void signer
  --account-void ENS_NAME     Add the resolved address as a void signer
  --account-rpc ADDRESS       Add the address from a JSON-RPC provider
  --account-rpc INDEX         Add the index from a JSON-RPC provider
  --mnemonic-password         Prompt for a password for mnemonics
  --xxx-mnemonic-password     Prompt for a (experimental) hard password

PROVIDER OPTIONS (default: all + homestead)
  --alchemy                   Include Alchemy
  --etherscan                 Include Etherscan
  --infura                    Include INFURA
  --nodesmith                 Include nodesmith
  --rpc URL                   Include a custom JSON-RPC
  --offline                   Dump signed transactions (no send)
  --network NETWORK           Network to connect to (default: homestead)

TRANSACTION OPTIONS (default: query network)
  --gasPrice GWEI             Default gas price for transactions(in wei)
  --gasLimit GAS              Default gas limit for transactions
  --nonce NONCE               Initial nonce for the first transaction
  --yes                       Always accept Siging and Sending

OTHER OPTIONS
  --wait                      Wait until transactions are mined
  --debug                     Show stack traces for errors
  --help                      Show this usage and exit
  --version                   Show this version and exit

(*) By including mnemonics or private keys on the command line they are
    possibly readable by other users on your system and may get stored in
    your bash history file. This is NOT recommended.
+ +

Examples

+

TODO examples

\ No newline at end of file diff --git a/docs/cli/ethers/README.md b/docs/cli/ethers/README.md new file mode 100644 index 000000000..3873e3e41 --- /dev/null +++ b/docs/cli/ethers/README.md @@ -0,0 +1,283 @@ +----- + +Documentation: [html](https://docs-beta.ethers.io/) + +----- + + +Sandbox Utility +=============== + + +The sandbox utility provides a simple way to use the most common +ethers utilities required during learning, debuging and managing +interactions with the Ethereum network. + +If no command is given, it will enter a REPL interface with many +of the ethers utilities already exposed. + + +Help +---- + + + +``` +Usage: + ethers [ COMMAND ] [ ARGS ] [ OPTIONS ] + +COMMANDS (default: sandbox) + sandbox Run a REPL VM environment with ethers + init FILENAME Create a new JSON wallet + [ --force ] Overwrite any existing files + fund TARGET Fund TARGET with testnet ether + info [ TARGET ... ] Dump info for accounts, addresses and ENS names + send TARGET ETHER Send ETHER ether to TARGET form accounts[0] + [ --allow-zero ] Allow sending to the address zero + [ --data DATA ] Include data in the transaction + sweep TARGET Send all ether from accounts[0] to TARGET + sign-message MESSAGE Sign a MESSAGE with accounts[0] + [ --hex ] The message content is hex encoded + eval CODE Run CODE in a VM with ethers + run FILENAME Run FILENAME in a VM with ethers + wait HASH Wait for a transaction HASH to be mined + wrap-ether VALUE Deposit VALUE into Wrapped Ether (WETH) + unwrap-ether VALUE Withdraw VALUE from Wrapped Ether (WETH) + send-token TOKEN ADDRESS VALUE + Send VALUE tokens (at TOKEN) to ADDRESS + compile FILENAME Compiles a Solidity contract + [ --no-optimize ] Do not optimize the compiled output + [ --warnings ] Error on any warning + deploy FILENAME Compile and deploy a Solidity contract + [ --no-optimize ] Do not optimize the compiled output + [ --contract NAME ] Specify the contract to deploy + +ACCOUNT OPTIONS + --account FILENAME Load from a file (JSON, RAW or mnemonic) + --account RAW_KEY Use a private key (insecure *) + --account 'MNEMONIC' Use a mnemonic (insecure *) + --account - Use secure entry for a raw key or mnemonic + --account-void ADDRESS Use an address as a void signer + --account-void ENS_NAME Add the resolved address as a void signer + --account-rpc ADDRESS Add the address from a JSON-RPC provider + --account-rpc INDEX Add the index from a JSON-RPC provider + --mnemonic-password Prompt for a password for mnemonics + --xxx-mnemonic-password Prompt for a (experimental) hard password + +PROVIDER OPTIONS (default: all + homestead) + --alchemy Include Alchemy + --etherscan Include Etherscan + --infura Include INFURA + --nodesmith Include nodesmith + --rpc URL Include a custom JSON-RPC + --offline Dump signed transactions (no send) + --network NETWORK Network to connect to (default: homestead) + +TRANSACTION OPTIONS (default: query network) + --gasPrice GWEI Default gas price for transactions(in wei) + --gasLimit GAS Default gas limit for transactions + --nonce NONCE Initial nonce for the first transaction + --yes Always accept Siging and Sending + +OTHER OPTIONS + --wait Wait until transactions are mined + --debug Show stack traces for errors + --help Show this usage and exit + --version Show this version and exit + +(*) By including mnemonics or private keys on the command line they are + possibly readable by other users on your system and may get stored in + your bash history file. This is NOT recommended. +``` + + + +Examples +-------- + + + +### Creating Wallets + + + +``` +/home/ethers> ethers init wallet.json +Creating a new JSON Wallet - wallet.json +Keep this password and file SAFE!! If lost or forgotten +it CANNOT be recovered, by ANYone, EVER. +Choose a password: ****** +Confirm password: ****** +Encrypting... 100% +New account address: 0x485bcC23ae2E5038ec7ec9b8DCB2A6A6291cC003 +Saved: wallet.json + + +# If you are planning to try out the Ropsten testnet... +/home/ethers> ethers --network ropsten fund 0x485bcC23ae2E5038ec7ec9b8DCB2A6A6291cC003 +Transaction Hash: 0x8dc55b8f8dc8076acded97f9e3ed7d6162460c0221e2769806006b6d7d1156e0 +``` + + + +### Sending Ether and Tokens + + + +``` +# Sending ether +/home/ricmoo> ethers --account wallet.json send ricmoo.firefly.eth 0.123 +Password (wallet.json): ****** +Decrypting... 100% +Transaction: + To: 0x8ba1f109551bD432803012645Ac136ddd64DBA72 + From: 0xaB7C8803962c0f2F5BBBe3FA8bf41cd82AA1923C + Value: 0.123 ether + Nonce: 96 + Data: 0x + Gas Limit: 21000 + Gas Price: 1.2 gwei + Chain ID: 1 + Network: homestead +Send Transaction? (y/N/a) y +Response: + Hash: 0xc4adf8b379033d7ab679d199aa35e6ceee9a802ca5ab0656af067e911c4a589a + + +# Sending a token (SAI) +# NOTE: the contract address could be used instead but +# popular token contract addresses are also managed +# by ethers +/home/ricmoo> ethers --account wallet.json send-token sai.tokens.ethers.eth ricmoo.firefly.eth 1.0 +Sending Tokens: + To: 0x8ba1f109551bD432803012645Ac136ddd64DBA72 + Token Contract: 0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359 + Value: 1.0 +Password (wallet.json): ****** +Decrypting... 100% +Transaction: + To: 0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359 + From: 0xaB7C8803962c0f2F5BBBe3FA8bf41cd82AA1923C + Value: 0.0 ether + Nonce: 95 + Data: 0xa9059cbb0000000000000000000000008ba1f109551bd432803012645ac136ddd64dba720000000000000000000000000000000000000000000000000de0b6b3a7640000 + Gas Limit: 37538 + Gas Price: 1.0 gwei + Chain ID: 1 + Network: homestead +Send Transaction? (y/N/a) y +Response: + Hash: 0xd609ecb7e3b5e8d36fd781dffceede3975ece6774b6322ea56cf1e4d0a17e3a1 +``` + + + +### Signing Messages + + + +``` +/home/ethers> ethers --account wallet.json sign-message 'Hello World' +Password (wallet.json): ****** +Decrypting... 100% +Message: + Message: "Hello World" + Message (hex): 0x48656c6c6f20576f726c64 +Sign Message? (y/N/a) y +Signature + Flat: 0xca3f0b32a22a5ab97ca8be7e4a36b1e81d565c6822465d769f4faa4aa24539fb122ee5649c8a37c9f5fc8446593674159e3a7b039997cd6ee697a24b787b1a161b + r: 0xca3f0b32a22a5ab97ca8be7e4a36b1e81d565c6822465d769f4faa4aa24539fb + s: 0x122ee5649c8a37c9f5fc8446593674159e3a7b039997cd6ee697a24b787b1a16 + vs: 0x122ee5649c8a37c9f5fc8446593674159e3a7b039997cd6ee697a24b787b1a16 + v: 27 + recid: 0 +``` + + + +### Scripting + + +The `eval` command can be used to execute simple one-line scripts from +the command line to be passed into other commands or stored in script +environment variables. + + +``` +# Get the formatted balance of an account +/home/ethers> ethers --network ropsten --account wallet.json eval 'accounts[0].getBalance().then(b => formatEther(b))' +3.141592653589793238 + +# Get the current block number +/home/ethers> ethers --network rinkeby eval "provider.getBlockNumber()" +5761009 + +# Convert a Solidity signature to JSON +/home/ethers> ethers eval 'utils.Fragment.from("function balanceOf(address owner) view returns (uint)").format("json")' +{"type":"function","name":"balanceOf","constant":true,"stateMutability":"view","payble":false,"inputs":[{"type":"address","name":"owner"}],"ouputs":[{"type":"uint256"}]} + +# Compute a topic hash +/home/ricmoo> ethers eval 'id("Transfer(address,address,uint256")' +0xd99659a21de82e379975ce8df556f939a4ccb95e92144f38bb0dd35730ffcdd5 + +# Create a random mnemonic +/home/ricmoo> ethers eval 'Wallet.createRandom().mnemonic' +useful pond inch knock ritual matrix giggle attend dilemma convince coach amazing +``` + + + +### Using Mnemonics (with a password) + + +All mnemonic phrases have a password, but the default is to use the empty +string (i.e. `""`) as the password. If you have a password on your +mnemonic, the `--mnemonic-password` will prompt for the password to +use to decrypt the account. + + +``` +/home/ricmoo> ethers --account public-mnemonic.txt --mnemonic-password +Password (mnemonic): ****** +network: homestead (chainId: 1) +homestead> accounts[0].getAddress() + +'0x6d3F723EC1B73141AA4aC248c3ab34A5a1DAD776' +homestead> +``` + + + +### Using Mnemonics (with experimental memory-hard passwords) + + +The `--xxx-mnemonic-password` is similar to the `--mnemonic-password` options, +which uses a password to decrypt the account for a mnemonic, however it passes +the password through the [scrypt](https://en.wikipedia.org/wiki/Scrypt) +*password-based key derivation function* first, which is intentionally slow and makes +a brute-force attack far more difficult. + + +``` +/home/ricmoo> ethers --account mnemonic.txt --xxx-mnemonic-password +Password (mnemonic; experimental - hard): ****** +Decrypting... 100% +network: homestead (chainId: 1) +homestead> accounts[0].getAddress() + +'0x56FC8792cC17971C19bEC4Ced978beEA44711EeD' +homestead> +``` + + + +#### Note + +This is still an experimental feature (hence the `xxx`). + + + + + +----- +**Content Hash:** 92cdbc324ec6a29cc4cd55bf1cb14de1ef8a4512dbd2ab03d7304238269caed5 \ No newline at end of file diff --git a/docs/cli/ethers/index.html b/docs/cli/ethers/index.html new file mode 100644 index 000000000..cf666ac64 --- /dev/null +++ b/docs/cli/ethers/index.html @@ -0,0 +1,34 @@ +Sandbox Utility
+

Sandbox Utility

+

The sandbox utility provides a simple way to use the most common ethers utilities required during learning, debuging and managing interactions with the Ethereum network.

If no command is given, it will enter a REPL interface with many of the ethers utilities already exposed.

+

Help

+ +
Usage:
   ethers [ COMMAND ] [ ARGS ] [ OPTIONS ]

COMMANDS (default: sandbox)
   sandbox                    Run a REPL VM environment with ethers
   init FILENAME              Create a new JSON wallet
      [ --force ]                Overwrite any existing files
   fund TARGET                Fund TARGET with testnet ether
   info [ TARGET ... ]        Dump info for accounts, addresses and ENS names
   send TARGET ETHER          Send ETHER ether to TARGET form accounts[0]
      [ --allow-zero ]           Allow sending to the address zero
      [ --data DATA ]            Include data in the transaction
   sweep TARGET               Send all ether from accounts[0] to TARGET
   sign-message MESSAGE       Sign a MESSAGE with accounts[0]
      [ --hex ]                  The message content is hex encoded
   eval CODE                  Run CODE in a VM with ethers
   run FILENAME               Run FILENAME in a VM with ethers
   wait HASH                  Wait for a transaction HASH to be mined
   wrap-ether VALUE           Deposit VALUE into Wrapped Ether (WETH)
   unwrap-ether VALUE         Withdraw VALUE from Wrapped Ether (WETH)
   send-token TOKEN ADDRESS VALUE
                              Send VALUE tokens (at TOKEN) to ADDRESS
   compile FILENAME           Compiles a Solidity contract
      [ --no-optimize ]          Do not optimize the compiled output
      [ --warnings ]             Error on any warning
   deploy FILENAME            Compile and deploy a Solidity contract
      [ --no-optimize ]          Do not optimize the compiled output
      [ --contract NAME ]        Specify the contract to deploy

ACCOUNT OPTIONS
  --account FILENAME          Load from a file (JSON, RAW or mnemonic)
  --account RAW_KEY           Use a private key (insecure *)
  --account 'MNEMONIC'        Use a mnemonic (insecure *)
  --account -                 Use secure entry for a raw key or mnemonic
  --account-void ADDRESS      Use an address as a void signer
  --account-void ENS_NAME     Add the resolved address as a void signer
  --account-rpc ADDRESS       Add the address from a JSON-RPC provider
  --account-rpc INDEX         Add the index from a JSON-RPC provider
  --mnemonic-password         Prompt for a password for mnemonics
  --xxx-mnemonic-password     Prompt for a (experimental) hard password

PROVIDER OPTIONS (default: all + homestead)
  --alchemy                   Include Alchemy
  --etherscan                 Include Etherscan
  --infura                    Include INFURA
  --nodesmith                 Include nodesmith
  --rpc URL                   Include a custom JSON-RPC
  --offline                   Dump signed transactions (no send)
  --network NETWORK           Network to connect to (default: homestead)

TRANSACTION OPTIONS (default: query network)
  --gasPrice GWEI             Default gas price for transactions(in wei)
  --gasLimit GAS              Default gas limit for transactions
  --nonce NONCE               Initial nonce for the first transaction
  --yes                       Always accept Siging and Sending

OTHER OPTIONS
  --wait                      Wait until transactions are mined
  --debug                     Show stack traces for errors
  --help                      Show this usage and exit
  --version                   Show this version and exit

(*) By including mnemonics or private keys on the command line they are
    possibly readable by other users on your system and may get stored in
    your bash history file. This is NOT recommended.
+ +

Examples

+ +

Creating Wallets

+ +
/home/ethers> ethers init wallet.json
Creating a new JSON Wallet - wallet.json
Keep this password and file SAFE!! If lost or forgotten
it CANNOT be recovered, by ANYone, EVER.
Choose a password: ******
Confirm password: ******
Encrypting... 100%
New account address: 0x485bcC23ae2E5038ec7ec9b8DCB2A6A6291cC003
Saved:               wallet.json


# If you are planning to try out the Ropsten testnet...
/home/ethers> ethers --network ropsten fund 0x485bcC23ae2E5038ec7ec9b8DCB2A6A6291cC003
Transaction Hash: 0x8dc55b8f8dc8076acded97f9e3ed7d6162460c0221e2769806006b6d7d1156e0
+ +

Sending Ether and Tokens

+ +
# Sending ether
/home/ricmoo> ethers --account wallet.json send ricmoo.firefly.eth 0.123
Password (wallet.json): ******
Decrypting... 100%
Transaction:
  To:         0x8ba1f109551bD432803012645Ac136ddd64DBA72
  From:       0xaB7C8803962c0f2F5BBBe3FA8bf41cd82AA1923C
  Value:      0.123 ether
  Nonce:      96
  Data:       0x
  Gas Limit:  21000
  Gas Price:  1.2 gwei
  Chain ID:   1
  Network:    homestead
Send Transaction? (y/N/a) y
Response:
  Hash:  0xc4adf8b379033d7ab679d199aa35e6ceee9a802ca5ab0656af067e911c4a589a


# Sending a token (SAI)
# NOTE: the contract address could be used instead but
#       popular token contract addresses are also managed
#       by ethers
/home/ricmoo> ethers --account wallet.json send-token sai.tokens.ethers.eth ricmoo.firefly.eth 1.0
Sending Tokens:
  To:              0x8ba1f109551bD432803012645Ac136ddd64DBA72
  Token Contract:  0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359
  Value:           1.0
Password (wallet.json): ******
Decrypting... 100%
Transaction:
  To:         0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359
  From:       0xaB7C8803962c0f2F5BBBe3FA8bf41cd82AA1923C
  Value:      0.0 ether
  Nonce:      95
  Data:       0xa9059cbb0000000000000000000000008ba1f109551bd432803012645ac136ddd64dba720000000000000000000000000000000000000000000000000de0b6b3a7640000
  Gas Limit:  37538
  Gas Price:  1.0 gwei
  Chain ID:   1
  Network:    homestead
Send Transaction? (y/N/a) y
Response:
  Hash:  0xd609ecb7e3b5e8d36fd781dffceede3975ece6774b6322ea56cf1e4d0a17e3a1
+ +

Signing Messages

+ +
/home/ethers> ethers --account wallet.json sign-message 'Hello World'
Password (wallet.json): ******
Decrypting... 100%
Message:
  Message:        "Hello World"
  Message (hex):  0x48656c6c6f20576f726c64
Sign Message? (y/N/a) y
Signature
  Flat:   0xca3f0b32a22a5ab97ca8be7e4a36b1e81d565c6822465d769f4faa4aa24539fb122ee5649c8a37c9f5fc8446593674159e3a7b039997cd6ee697a24b787b1a161b
  r:      0xca3f0b32a22a5ab97ca8be7e4a36b1e81d565c6822465d769f4faa4aa24539fb
  s:      0x122ee5649c8a37c9f5fc8446593674159e3a7b039997cd6ee697a24b787b1a16
  vs:     0x122ee5649c8a37c9f5fc8446593674159e3a7b039997cd6ee697a24b787b1a16
  v:      27
  recid:  0
+ +

Scripting

+

The eval command can be used to execute simple one-line scripts from the command line to be passed into other commands or stored in script environment variables.

+
# Get the formatted balance of an account
/home/ethers> ethers --network ropsten --account wallet.json eval 'accounts[0].getBalance().then(b => formatEther(b))'
3.141592653589793238

# Get the current block number
/home/ethers> ethers --network rinkeby eval "provider.getBlockNumber()"
5761009

# Convert a Solidity signature to JSON
/home/ethers> ethers eval 'utils.Fragment.from("function balanceOf(address owner) view returns (uint)").format("json")' 
{"type":"function","name":"balanceOf","constant":true,"stateMutability":"view","payble":false,"inputs":[{"type":"address","name":"owner"}],"ouputs":[{"type":"uint256"}]}

# Compute a topic hash
/home/ricmoo> ethers eval 'id("Transfer(address,address,uint256")'
0xd99659a21de82e379975ce8df556f939a4ccb95e92144f38bb0dd35730ffcdd5

# Create a random mnemonic
/home/ricmoo> ethers eval 'Wallet.createRandom().mnemonic'
useful pond inch knock ritual matrix giggle attend dilemma convince coach amazing
+ +

Using Mnemonics (with a password)

+

All mnemonic phrases have a password, but the default is to use the empty string (i.e. "") as the password. If you have a password on your mnemonic, the --mnemonic-password will prompt for the password to use to decrypt the account.

+
/home/ricmoo> ethers --account public-mnemonic.txt --mnemonic-password
Password (mnemonic): ******
network: homestead (chainId: 1)
homestead> accounts[0].getAddress()
<Promise id=0 resolved>
'0x6d3F723EC1B73141AA4aC248c3ab34A5a1DAD776'
homestead>
+ +

Using Mnemonics (with experimental memory-hard passwords)

+

The --xxx-mnemonic-password is similar to the --mnemonic-password options, which uses a password to decrypt the account for a mnemonic, however it passes the password through the scrypt password-based key derivation function first, which is intentionally slow and makes a brute-force attack far more difficult.

+
/home/ricmoo> ethers --account mnemonic.txt --xxx-mnemonic-password
Password (mnemonic; experimental - hard): ******
Decrypting... 100%
network: homestead (chainId: 1)
homestead> accounts[0].getAddress()
<Promise id=0 resolved>
'0x56FC8792cC17971C19bEC4Ced978beEA44711EeD'
homestead>
+ +
Note

This is still an experimental feature (hence the xxx).

\ No newline at end of file diff --git a/docs/cli/index.html b/docs/cli/index.html new file mode 100644 index 000000000..d2bf0b58c --- /dev/null +++ b/docs/cli/index.html @@ -0,0 +1,4 @@ +Command Line Interfaces
+

Command Line Interfaces

+ +
\ No newline at end of file diff --git a/docs/cli/plugin/README.md b/docs/cli/plugin/README.md new file mode 100644 index 000000000..2f272cfb7 --- /dev/null +++ b/docs/cli/plugin/README.md @@ -0,0 +1,277 @@ +----- + +Documentation: [html](https://docs-beta.ethers.io/) + +----- + + +Making Your Own +=============== + + +The *cli* library is meant to make it easy to create command +line utilities of your own. + + +CLI +--- + + +A **CLI** handles parsing all the command-line flags, options and arguments +and instantiates a [Plugin](./) to process the command. + +A **CLI** may support multiple [Plugin](./)'s in which case the first +argument is used to determine which to run (or if no arguments, the default +plugin will be selected) or may be designed to be standalone, in which case +exactly one [Plugin](./) will be used and no command argument is allowed. + + +#### **addPlugin** ( command , pluginClass ) **=>** *void* + +Add a *plugin* class for the *command*. After all options and flags +have been consumed, the first argument will be consumed and the +associated plugin class will be instantiated and run. + + + + +#### **setPlugin** ( pluginClass ) **=>** *void* + +Set a dedicated [Plugin](./) class which will handle all input. This +may not be used in conjuction with addPlugin and will not automatically +accept a command from the arguments. + + + + +#### **showUsage** ( [ message="" [ , status=0 ] ] ) **=>** *never* + +Shows the usage help screen for the CLI and terminates. + + + + +#### **run** ( args ) **=>** *Promise< void >* + +Usually the value of *args* passed in will be `process.argv.slice(2)`. + + + + +Plugin +------ + + +Each **Plugin** manages each command of a CLI and is executed in phases. + +If the usage (i.e. help) of a CLI is requested, the static methods `getHelp` +and `getOptionHelp` are used to geneate the help screen. + +Otherwise, a plugin is instantiated and the `prepareOptions` is called. Each +plugin **must** call `super.prepareOptions`, otherwise the basic options are +not yet processed. During this time a Plugin should consume all the flags and +options it understands, since any left over flags or options will cause the +CLI to bail and issue an *unknown option* error. This should throw if a value +for a given option is invalid or some combination of options and flags is not +allowed. + +Once the prepareOptions is complete (the returned promise is resolved), the `prepareArguments` +is called. This should validate the number of arguments is expected and throw +and error if there are too many or too few arguments or if any arguments do not +make sense. + +Once the prepareArguments is complete (the returned promise is resolved), the `run` +is called. + + +#### *plugin* . **network** **=>** *[Network](../../api/providers/types)* + +The network this plugin is running for. + + + + +#### *plugin* . **provider** **=>** *[Provider](../../api/providers/provider)* + +The provider for this plugin is running for. + + + + +#### *plugin* . **accounts** **=>** *Array< [Signer](../../api/signer) >* + +The accounts passed into the plugin using `--account`, +`--account-rpc` and `--account-void` which this plugin can use. + + + + +#### *plugin* . **gasLimit** **=>** *[BigNumber](../../api/utils/bignumber)* + +The gas limit this plugin should use. This is null if unspecified. + + + + +#### *plugin* . **gasPrice** **=>** *[BigNumber](../../api/utils/bignumber)* + +The gas price this plugin should use. This is null if unspecified. + + + + +#### *plugin* . **nonce** **=>** *number* + +The initial nonce for the account this plugin should use. + + + + +### Methods + + + +#### *plugin* . **prepareOptions** ( argParser [ , verifyOnly=false ] ) **=>** *Promise< void >* + + + + + + +#### *plugin* . **prepareArgs** ( args ) **=>** *Promise< void >* + + + + + + +#### *plugin* . **run** ( ) **=>** *Promise< void >* + + + + + + +#### *plugin* . **getAddress** ( addressOrName [ , message="" , [ allowZero=false ] ] ) **=>** *Promise< string >* + +A plugin should use this method to resolve an address. If the resovled address is +the zero address and *allowZero* is not true, an error is raised. + + + + +#### *plugin* . **dump** ( header , info ) **=>** *void* + +Dumps the contents of *info* to the console with a *header* in a nicely +formatted style. In the future, plugins may support a JSON output format +which will automatically work with this method. + + + + +#### *plugin* . **throwUsageError** ( [ message="" ] ) **=>** *never* + +Stops exectuion of the plugin and shows the help screen of the plugin with +the optional *message*. + + + + +#### *plugin* . **throwError** ( message ) **=>** *never* + +Stops execution of the plugin and shows *message*. + + + + +### Static Methods + + + +#### *Plugin* . **getHelp** **=>** *Help* + +Each subclass should implement this static method which is used to +generate the help screen. + + + + +#### *Plugin* . **getOptionHelp** **=>** *Array< Help >* + +Each subclass should implement this static method if it supports +additional options which is used to generate the help screen. + + + + +ArgParser +--------- + + +The **ArgParser** is used to parse a command line into flags, options +and arguments. + + +``` +/home/ethers> ethers --account wallet.json --yes send ricmoo.eth 1.0 +# An Option ----------^ ^ ^ +# - name = "account" | | +# - value = "wallet.json" | | +# A Flag -----------------------------------+ | +# - name = "yes" | +# - value = true | +# Arguments ------------------------------------+ +# - count = 3 +# - [ "send", "ricmoo.eth", "1.0" ] +``` + + +Flags are simple binary options (such as the `--yes`), which are true if present +otherwise false. + +Options require a single parameter follow them on the command line +(such as `--account wallet.json`, which nhas the name `account` and the value +`wallet.json`) + +Arguments are all other values on the command line, and are not accessed through +the **ArgParser** directly. + +When a CLI is run, an **ArgParser** is used to validate the command line by using +prepareOptions, which consumes all flags and options leaving only the arguments +behind, which are then passed into prepareArgs. + + +#### *argParser* . **consumeFlag** ( name ) **=>** *boolean* + +Remove the flag *name* and return true if it is present. + + + + +#### *argParser* . **consumeMultiOptions** ( names ) **=>** *Array< {name:string,value:string} >* + +Remove all options which match any name in the Array of *names* +with their values returning the list (in order) of values. + + + + +#### *argParser* . **consumeOption** ( name ) **=>** *string* + +Remove the option with its value for *name* and return the value. This +will throw a UsageError if the option is included multiple times. + + + + +#### *argParser* . **consumeOptions** ( name ) **=>** *Array< string >* + +Remove all options with their values for *name* and return the list +(in order) of values. + + + + + +----- +**Content Hash:** 6ba720f007a15375ca684057e122c2acdb317b30f87b898e10fbe4c150169358 \ No newline at end of file diff --git a/docs/cli/plugin/index.html b/docs/cli/plugin/index.html new file mode 100644 index 000000000..681de4f2c --- /dev/null +++ b/docs/cli/plugin/index.html @@ -0,0 +1,38 @@ +Making Your Own
+

Making Your Own

+

The cli library is meant to make it easy to create command line utilities of your own.

+

+

A CLI handles parsing all the command-line flags, options and arguments and instantiates a Plugin to process the command.

A CLI may support multiple Plugin's in which case the first argument is used to determine which to run (or if no arguments, the default plugin will be selected) or may be designed to be standalone, in which case exactly one Plugin will be used and no command argument is allowed.

+
addPlugin ( command , pluginClass ) void

Add a plugin class for the command. After all options and flags have been consumed, the first argument will be consumed and the associated plugin class will be instantiated and run.

+
setPlugin ( pluginClass ) void

Set a dedicated Plugin class which will handle all input. This may not be used in conjuction with addPlugin and will not automatically accept a command from the arguments.

+
showUsage ( [ message = "" [ , status = 0 ] ] ) never

Shows the usage help screen for the CLI and terminates.

+
run ( args ) Promise< void >

Usually the value of args passed in will be process.argv.slice(2).

+

Plugin

+

Each Plugin manages each command of a CLI and is executed in phases.

If the usage (i.e. help) of a CLI is requested, the static methods getHelp and getOptionHelp are used to geneate the help screen.

Otherwise, a plugin is instantiated and the prepareOptions is called. Each plugin must call super.prepareOptions, otherwise the basic options are not yet processed. During this time a Plugin should consume all the flags and options it understands, since any left over flags or options will cause the CLI to bail and issue an unknown option error. This should throw if a value for a given option is invalid or some combination of options and flags is not allowed.

Once the prepareOptions is complete (the returned promise is resolved), the prepareArguments is called. This should validate the number of arguments is expected and throw and error if there are too many or too few arguments or if any arguments do not make sense.

Once the prepareArguments is complete (the returned promise is resolved), the run is called.

+
plugin . network Network

The network this plugin is running for.

+
plugin . provider Provider

The provider for this plugin is running for.

+
plugin . accounts Array< Signer >

The accounts passed into the plugin using –account, –account-rpc and –account-void which this plugin can use.

+
plugin . gasLimit BigNumber

The gas limit this plugin should use. This is null if unspecified.

+
plugin . gasPrice BigNumber

The gas price this plugin should use. This is null if unspecified.

+
plugin . nonce number

The initial nonce for the account this plugin should use.

+

Methods

+ +
plugin . prepareOptions ( argParser [ , verifyOnly = false ] ) Promise< void >

+
plugin . prepareArgs ( args ) Promise< void >

+
plugin . run ( ) Promise< void >

+
plugin . getAddress ( addressOrName [ , message = "" , [ allowZero = false ] ] ) Promise< string >

A plugin should use this method to resolve an address. If the resovled address is the zero address and allowZero is not true, an error is raised.

+
plugin . dump ( header , info ) void

Dumps the contents of info to the console with a header in a nicely formatted style. In the future, plugins may support a JSON output format which will automatically work with this method.

+
plugin . throwUsageError ( [ message = "" ] ) never

Stops exectuion of the plugin and shows the help screen of the plugin with the optional message.

+
plugin . throwError ( message ) never

Stops execution of the plugin and shows message.

+

Static Methods

+ +
Plugin . getHelp Help

Each subclass should implement this static method which is used to generate the help screen.

+
Plugin . getOptionHelp Array< Help >

Each subclass should implement this static method if it supports additional options which is used to generate the help screen.

+

ArgParser

+

The ArgParser is used to parse a command line into flags, options and arguments.

+
/home/ethers> ethers --account wallet.json --yes send ricmoo.eth 1.0
#  An Option ----------^                     ^   ^
#    - name =  "account"                     |   |
#    - value = "wallet.json"                 |   |
#  A Flag -----------------------------------+   |
#    - name  = "yes"                             |
#    - value = true                              |
#  Arguments ------------------------------------+
#    - count = 3
#    - [ "send", "ricmoo.eth", "1.0" ]
+

Flags are simple binary options (such as the –yes), which are true if present otherwise false.

Options require a single parameter follow them on the command line (such as –account wallet.json, which nhas the name account and the value wallet.json)

Arguments are all other values on the command line, and are not accessed through the ArgParser directly.

When a CLI is run, an ArgParser is used to validate the command line by using prepareOptions, which consumes all flags and options leaving only the arguments behind, which are then passed into prepareArgs.

+
argParser . consumeFlag ( name ) boolean

Remove the flag name and return true if it is present.

+
argParser . consumeMultiOptions ( names ) Array< {name:string,value:string} >

Remove all options which match any name in the Array of names with their values returning the list (in order) of values.

+
argParser . consumeOption ( name ) string

Remove the option with its value for name and return the value. This will throw a UsageError if the option is included multiple times.

+
argParser . consumeOptions ( name ) Array< string >

Remove all options with their values for name and return the list (in order) of values.

\ No newline at end of file diff --git a/docs/cli/typescript/README.md b/docs/cli/typescript/README.md new file mode 100644 index 000000000..705f22f99 --- /dev/null +++ b/docs/cli/typescript/README.md @@ -0,0 +1,49 @@ +----- + +Documentation: [html](https://docs-beta.ethers.io/) + +----- + + +TypeScript +========== + + + +Help +---- + + + +``` +Usage: + ethers-ts FILENAME [ ... ] [ OPTIONS ] + +OPTIONS + --output FILENAME Write the output to FILENAME (default: stdout) + --force Overwrite files if they already exist + --no-optimize Do not run the solc optimizer + --no-bytecode Do not include bytecode and Factory methods + +OTHER OPTIONS + --debug Show stack traces for errors + --help Show this usage and exit + --version Show this version and exit + +(*) By including mnemonics or private keys on the command line they are + possibly readable by other users on your system and may get stored in + your bash history file. This is NOT recommended. +``` + + + +Examples +-------- + + +TODO + + + +----- +**Content Hash:** 98fc4eb324759c1100fc61107b6a083a541209d41e18620237d2f8959e512b2a \ No newline at end of file diff --git a/docs/cli/typescript/index.html b/docs/cli/typescript/index.html new file mode 100644 index 000000000..288bc15ed --- /dev/null +++ b/docs/cli/typescript/index.html @@ -0,0 +1,9 @@ +TypeScript
+

TypeScript

+ +

Help

+ +
Usage:
   ethers-ts FILENAME [ ... ] [ OPTIONS ]

OPTIONS
  --output FILENAME           Write the output to FILENAME (default: stdout)
  --force                     Overwrite files if they already exist
  --no-optimize               Do not run the solc optimizer
  --no-bytecode               Do not include bytecode and Factory methods

OTHER OPTIONS
  --debug                     Show stack traces for errors
  --help                      Show this usage and exit
  --version                   Show this version and exit

(*) By including mnemonics or private keys on the command line they are
    possibly readable by other users on your system and may get stored in
    your bash history file. This is NOT recommended.
+ +

Examples

+

TODO

\ No newline at end of file diff --git a/docs/concepts/README.md b/docs/concepts/README.md index 633c0442a..c47eed55f 100644 --- a/docs/concepts/README.md +++ b/docs/concepts/README.md @@ -10,7 +10,8 @@ Concepts This is a very breif overview of some aspects of *Ethereum* -which developers can make use of or should be aware of. +and blockchains which developers can make use of or should +be aware of. * [Events](events) @@ -22,4 +23,4 @@ which developers can make use of or should be aware of. ----- -**Content Hash:** 1846ad5571101be31cf9617167b5cc53338c83c0fc9389da19c8dd9d4153558b \ No newline at end of file +**Content Hash:** d28f134e37610473fc3f0fd205f5928f30ee754cb7f9e13ad01a4ed9cf6dfc38 \ No newline at end of file diff --git a/docs/concepts/events/index.html b/docs/concepts/events/index.html index c2cf8ef23..969e94726 100644 --- a/docs/concepts/events/index.html +++ b/docs/concepts/events/index.html @@ -1,5 +1,5 @@ -Events
+Events

Events

Explain how topics and such work

Solidity Topics

-

How to compute the topic...

\ No newline at end of file +

How to compute the topic...

\ No newline at end of file diff --git a/docs/concepts/gas/index.html b/docs/concepts/gas/index.html index 05b5c3ca1..5bd80445e 100644 --- a/docs/concepts/gas/index.html +++ b/docs/concepts/gas/index.html @@ -1,7 +1,7 @@ -Gas
+Gas

Gas

Explain attack vectors

Gas Price

The gas price is used somewhat like a bid, indicating an amount you are willing to pay (per unit of execution) to have your transaction processed.

Gas Limit

-
\ No newline at end of file +
\ No newline at end of file diff --git a/docs/concepts/index.html b/docs/concepts/index.html index ffd4471c0..656dbe644 100644 --- a/docs/concepts/index.html +++ b/docs/concepts/index.html @@ -1,4 +1,4 @@ -Concepts
+Concepts

Concepts

-

This is a very breif overview of some aspects of Ethereum which developers can make use of or should be aware of.

-
\ No newline at end of file +

This is a very breif overview of some aspects of Ethereum and blockchains which developers can make use of or should be aware of.

+
\ No newline at end of file diff --git a/docs/contributing/index.html b/docs/contributing/index.html index 1b6bc6f7e..ce17e5ed8 100644 --- a/docs/contributing/index.html +++ b/docs/contributing/index.html @@ -1,5 +1,5 @@ -Contributing and Hacking
+Contributing and Hacking

Contributing and Hacking

The ethers.js library is something that I've written out of necessity, and has grown somewhat organically over time.

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:

  • Backwards-compatibility-breaking changes will not be accepted; they may be considered for the next major version
  • Security is important; adding dependencies require fairly convincing 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
  • 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 may not be accepted

In general, please start an issue before beginning a pull request, so we can have a public discussion and figure out the best way to address to problem/feature. :)

Building

-

use npm run auto-build

use npm run update-version

\ No newline at end of file +

use npm run auto-build

use npm run update-version

\ No newline at end of file diff --git a/docs/cookbook/index.html b/docs/cookbook/index.html index a64d123b8..08336b454 100644 --- a/docs/cookbook/index.html +++ b/docs/cookbook/index.html @@ -1,3 +1,3 @@ -Cookbook
+Cookbook

Cookbook

-

Cooking...

\ No newline at end of file +

Cooking...

\ No newline at end of file diff --git a/docs/documentation/README.md b/docs/documentation/README.md index b174328ed..afd74977f 100644 --- a/docs/documentation/README.md +++ b/docs/documentation/README.md @@ -32,13 +32,15 @@ itself have body. ``` -_DIRECTIVE: VALUE @ +_DIRECTIVE: VALUE @ @META BODY -DIRECTIVE: The directive name -VALUE: Optional; the value to pass to the directive -LINK: Optional; a name for internal linking -BODY: Optional; the directive body (certain directives only) +DIRECTIVE: The directive name +VALUE: Optional; the value to pass to the directive +LINK: Optional; a name for internal linking +META: Optional; extended directive functionality +PARAMETER: Optional; value to pass to extended directive functions +BODY: Optional; the directive body (certain directives only) ``` @@ -91,6 +93,20 @@ markdown body is indented. +#### **_note:** *TITLE* + +A *note* is placed in a blue bordered-box to draw attention to it. + + + + +#### **_warning:** *TITLE* + +A *warning* is placed in an orange bordered-box to draw attention to it. + + + + #### **_code:** *FILENAME* A *code* reads the **FILENAME** and depending on the extension @@ -147,10 +163,16 @@ _toc: some-file some-directory +_definition and reset the indentation. + +_note: Title +This is placed in a blue box. + +_warning: Title +This is placed in an orange box. + _null: This breaks out of a directive. For example, to end a - -_definition and reset the indentation. ``` @@ -193,6 +215,55 @@ This is a self-titled link [[https://ethereumorg]] and this +Configuration +------------- + + +Configuration is optional (but highly recommended) and may be either +a simple JSON file (config.json) or a JS file (config.js) placed in +the top of the source folder. + +TODO: example JSON and example JS + + +Extended Directive Functions +---------------------------- + + + +### @INHERIT + + +Adds an inherits description to a directive. The *markdown* may contain links. + +This extended directive function is available for: + + + +* _section +* _subsetion +* _heading + + +### @SRC + + +Calls the configuration `getSourceUrl(text, VALUE)` to get a URL which +will be linked to by a link next to the *directive*. + +This extended directive function requires an advanced `config.js` [Configuration](./) +file since it requires a JavaScript function. + +This extended directive function is available for: + + + +* _section +* _subsetion +* _heading +* _property + + ----- -**Content Hash:** 2d45e62661589ea3cdf50cc4da9faf63c33b7385840b31fddaf9d3cbe35d6015 \ No newline at end of file +**Content Hash:** 25456ca845a1572440a2c7a6658ef736782f92a39815df78455832aa8e13e5f4 \ No newline at end of file diff --git a/docs/documentation/index.html b/docs/documentation/index.html index da74d31e7..aac3333ae 100644 --- a/docs/documentation/index.html +++ b/docs/documentation/index.html @@ -1,11 +1,11 @@ -Flatworm Docs
+Flatworm Docs

Flatworm Docs

The Flatworm Docs rendering script is designed to be very simple, but provide enough formatting necessary for documenting JavaScript libraries.

A lot of its inspiration came from Read the Docs and the Sphinx project.

-

Fragments

+

Fragments

Flatworm Docs are made up of fragments. A fragment is either a lone body of markdown text, or a directive for specialized formatting, which may itself have body.

Directive Format

-
_DIRECTIVE: VALUE @<LINK>
BODY

DIRECTIVE: The directive name
VALUE:     Optional; the value to pass to the directive
LINK:      Optional; a name for internal linking
BODY:      Optional; the directive body (certain directives only)
+
_DIRECTIVE: VALUE @<LINK> @META<PARAMETER>
BODY

DIRECTIVE:  The directive name
VALUE:      Optional; the value to pass to the directive
LINK:       Optional; a name for internal linking
META:       Optional; extended directive functionality
PARAMETER:  Optional; value to pass to extended directive functions
BODY:       Optional; the directive body (certain directives only)

Flatworm Directives

@@ -14,14 +14,24 @@
_heading: TITLE

A heading has its TITLE in an H3 font. If an option is specified, it is available as a name for internal linking.

_definition: TERM

A definition has its TERM bolded and the markdown body is indented.

_property: SIGNATURE

A property has its JavaScript SIGNATURE formatted and the markdown body is indented.

+
_note: TITLE

A note is placed in a blue bordered-box to draw attention to it.

+
_warning: TITLE

A warning is placed in an orange bordered-box to draw attention to it.

_code: FILENAME

A code reads the FILENAME and depending on the extension adjusts it.

For JavaScript files, the file is executed, with //! replaced with the result of the last statement and //!error is replaced with the throw error. If the error state does not agree, rendering fails.

_toc:

A toc injects a Table of Contents, loading each line of the body as a filename and recursively loads the toc if present, otherwise all the sections and subsections.

_null:

A null is used to terminated a directive. For example, after a definition, the bodies are indented, so a null can be used to reset the indentation.

Examples

-
_section: Hello World @<link-to-this-section>

_subsection: Some Example @<link-to-this-subsection>

_heading: Large Bold Text @<link-to-this-heading>

_definition: Flatworm
A phylum of relatively **simple** bilaterian, unsegmented,
soft-bodied invertebrates.

_property: String.fromCharCode(code) => string
Returns a string created from //code//, a sequence of
UTF-16 code units.

_code: filename.js

_toc:
    some-file
    some-directory

_null:
This breaks out of a directive. For example, to end a

_definition and reset the indentation.
+
_section: Hello World @<link-to-this-section>

_subsection: Some Example @<link-to-this-subsection>

_heading: Large Bold Text @<link-to-this-heading>

_definition: Flatworm
A phylum of relatively **simple** bilaterian, unsegmented,
soft-bodied invertebrates.

_property: String.fromCharCode(code) => string
Returns a string created from //code//, a sequence of
UTF-16 code units.

_code: filename.js

_toc:
    some-file
    some-directory

_definition and reset the indentation.

_note: Title
This is placed in a blue box.

_warning: Title
This is placed in an orange box.

_null:
This breaks out of a directive. For example, to end a

Markdown

The markdown is simple and does not have the flexibility of other dialects, but allows for bold, italic, underlined, monospaced, super-scripted text, supporting links and lists.

**bold text**

//italic text//

__underlined text__

``monospace code``

^^superscript text^^

- This is a list
- With bullet points
- With a total of three items

This is separated by -- an en-dash.

This is separated by --- an em-dash.

This is a [Link to Ethereum](https://ethereum.org) and this
is an [Internal Link](some-link).

This is a self-titled link [[https://ethereumorg]] and this
[[some-link]] will use the title from its directives value.
-
\ No newline at end of file + +

Configuration

+

Configuration is optional (but highly recommended) and may be either a simple JSON file (config.json) or a JS file (config.js) placed in the top of the source folder.

TODO: example JSON and example JS

+

Extended Directive Functions

+ +

@INHERIT<markdown>

+

Adds an inherits description to a directive. The markdown may contain links.

This extended directive function is available for:

  • _section
  • _subsetion
  • _heading
+

@SRC<text>

+

Calls the configuration getSourceUrl(text, VALUE) to get a URL which will be linked to by a link next to the directive.

This extended directive function requires an advanced config.js Configuration file since it requires a JavaScript function.

This extended directive function is available for:

  • _section
  • _subsetion
  • _heading
  • _property
\ No newline at end of file diff --git a/docs/getting-started/index.html b/docs/getting-started/index.html index a9b0c1d4f..d238e4a1c 100644 --- a/docs/getting-started/index.html +++ b/docs/getting-started/index.html @@ -1,4 +1,4 @@ -Getting Started
+Getting Started

Getting Started

Installing

@@ -14,4 +14,4 @@

Web Browser

It is generally better practice (for security reasons) to copy the ethers library to your own webserver and serve it yourself.

For quick demos or prototyping though, it can be loaded in your Web Applications from our CDN.

<script src="https://cdn.ethers.io/lib/ethers-5.0.esm.min.js"
        type="application/javascipt"></script>
-
\ No newline at end of file +
\ No newline at end of file diff --git a/docs/hacking/index.html b/docs/hacking/index.html index 24b1705d9..a4280fbf8 100644 --- a/docs/hacking/index.html +++ b/docs/hacking/index.html @@ -1,4 +1,4 @@ -Hacking
+Hacking

Hacking

Things to keep in mind:

Supported Platforms

@@ -10,4 +10,4 @@

License

MIT...

Other Considerations

-

A common argument to Pull Requests is that they are simple, backwards compatible and

It is important to remember that a small change is something that we are required to support in perpetuity.

For example, adding support for an obscure platform, such as adding a dot-file to the root of the package, now carries the implication that we will continue keeping that dot-file up-to-date as new versions of that platform are released.

\ No newline at end of file +

A common argument to Pull Requests is that they are simple, backwards compatible and

It is important to remember that a small change is something that we are required to support in perpetuity.

For example, adding support for an obscure platform, such as adding a dot-file to the root of the package, now carries the implication that we will continue keeping that dot-file up-to-date as new versions of that platform are released.

\ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 7a3bb89ea..8c76243bc 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,10 +1,10 @@ -Documentation
+Documentation

What is ethers?

The ethers.js library aims to be a complete and compact library for interacting with the Ethereum Blockchain and its ecosystem. It was originally designed for use with ethers.io and has since expanded into a much more general-purpose library.

Features

  • Keep your private keys in your client, safe and sound
  • Import and export JSON wallets (Geth, Parity and crowdsale)
  • Import and export BIP 39 mnemonic phrases (12 word backup phrases) and HD Wallets (English, Italian, Japanese, Korean, Simplified Chinese, Traditional Chinese; more coming soon)
  • Meta-classes create JavaScript objects from any contract ABI, including ABIv2 and Human-Readable ABI
  • Connect to Ethereum nodes over JSON-RPC, INFURA, Etherscan, Nodesmith, Alchemy, or MetaMask.
  • ENS names are first-class citizens; they can be used anywhere an Ethereum addresses can be used
  • Tiny (~88kb compressed; 284kb uncompressed)
  • Complete functionality for all your Ethereum needs
  • Extensive documentation
  • Large collection of test cases which are maintained and added to
  • Fully TypeScript ready, with definition files and full TypeScript source
  • MIT License (including ALL dependencies); completely open source to do with as you please

Developer Documentation

- +
Gas
Help
Help
ENS
Help
Help
CLI

Legacy Documentation

-

This section will be kept up to date, linking to documentation of older versions of the library.

\ No newline at end of file +

This section will be kept up to date, linking to documentation of older versions of the library.

\ No newline at end of file diff --git a/docs/license/index.html b/docs/license/index.html index e5dbf4d0a..d620cc406 100644 --- a/docs/license/index.html +++ b/docs/license/index.html @@ -1,5 +1,5 @@ -License and Copyright
+License and Copyright

License and Copyright

The ethers library (including all dependencies) are available under the MIT License, which permits a wide variety of uses.

MIT License

-

Copyright © 2019 Richard Moore.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

\ No newline at end of file +

Copyright © 2019 Richard Moore.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

\ No newline at end of file diff --git a/docs/migration/index.html b/docs/migration/index.html index 4d86cefe3..59d07f212 100644 --- a/docs/migration/index.html +++ b/docs/migration/index.html @@ -1,7 +1,7 @@ -Migration Guide
+Migration Guide

Migration Guide

Migratimg...

From Web3

test

From ethers v4

-

test

\ No newline at end of file +

test

\ No newline at end of file diff --git a/docs/static/style.css b/docs/static/style.css index d4adcbec3..ab9c3e06e 100644 --- a/docs/static/style.css +++ b/docs/static/style.css @@ -351,6 +351,8 @@ div.breadcrumbs span.current { } .anchors a.source { + font-size: 14px; + font-weight: normal; right: 0; opacity: 0.3; transform: translate(100%, -50%); @@ -364,7 +366,14 @@ div.breadcrumbs span.current { opacity: 1; } - +.inherits { + font-weight: normal; + font-size: 16px; + font-style: italic; + position: absolute; + letter-spacing: 0.1ex; + padding-left: 25px; +} .definition { margin: 10px 0 0 15px; @@ -381,12 +390,13 @@ div.breadcrumbs span.current { .definition.container-box { border-radius: 5px; - left: 15px; + left: 48px; margin-bottom: 30px; margin-top: 30px; + overflow: hidden; padding: 0; position: relative; - width: 90%; + width: 80%; } .definition.container-box .term { @@ -398,7 +408,15 @@ div.breadcrumbs span.current { .definition.container-box p { font-size: 16px; - padding: 10px 30px; + padding: 0px 30px; +} + +.definition.container-box p:first-child { + padding-top: 15px; +} + +.definition.container-box p:last-child { + padding-bottom: 10px; } .definition.container-box.note { diff --git a/docs/testing/index.html b/docs/testing/index.html index 00e2995fd..d3743ac47 100644 --- a/docs/testing/index.html +++ b/docs/testing/index.html @@ -1,3 +1,3 @@ -Testing
+Testing

Testing

-

Here goes info about testing

\ No newline at end of file +

Here goes info about testing

\ No newline at end of file