Updated documentation source.

This commit is contained in:
Richard Moore 2020-02-17 17:56:13 -05:00
parent f9c1a24787
commit 067d96062a
No known key found for this signature in database
GPG Key ID: 665176BE8E9DC651
38 changed files with 1318 additions and 184 deletions

@ -0,0 +1,88 @@
_title: Utilities
_section: Utilities @<asm-utilities>
_subsection: Assembler
The assembler utilities allow parsing and assembling an
[Ethers ASM Dialect](asm-dialect) source file.
_property: asm.parse(code) => [[asm-node]] @<asm-parse> @SRC<asm/assembler>
Parse an ethers-format assembly file and return the [[asm-ast]].
_property: asm.assemble(node) => string<[[datahexstring]]> @SRC<asm/assembler:function.assemble>
Performs assembly of the [[asm-ast]] //node// and return the
resulting bytecode representation.
_subsection: Disassembler
The **Disassembler** utilities make it easy to convert bytecode
into an object which can easily be examined for program structure.
_property: asm.disassemble(bytecode) => [[asm-bytecode]] @SRC<asm/assembler>
Returns an array of Operations given //bytecode//.
_property: asm.formatBytecode(operations) => string @SRC<asm/assembler>
Create a formatted output of an array of [[asm-operation]].
_heading: Bytecode @<asm-bytecode> @INHERIT<Array\<[[asm-operation]]\>>
Each arary index represents an operation, collapsing multi-byte operations
(i.e. ``PUSH``) into a single operation.
_property: bytecode.getOperation(offset) => [[asm-operation]]
Get the operation at a given //offset// into the bytecode. This ensures that
the byte at //offset// is an operation and not data contained within a ``PUSH``,
in which case null it returned.
_heading: Operation @<asm-operation>
An **Operation** is a single command from a disassembled bytecode
stream.
_property: operation.opcode => [[asm-opcode]]
The opcode for this Operation.
_property: operation.offset => number
The offset into the bytecode for this Operation.
_property: operation.pushValue => string<[[datahexstring]]>
If the opcode is a ``PUSH``, this is the value of that push
_subsection: Opcode @<asm-opcode> @SRC<asm/opcodes:class.Opcode>
_property: asm.Opcode.from(valueOrMnemonic) => [[asm-opcode]]
Create a new instnace of an Opcode for a given numeric value
(e.g. 0x60 is PUSH1) or mnemonic string (e.g. "PUSH1").
_heading: Properties
_property: opcode.value => number
The value (bytecode as a number) of this opcode.
_property: opcode.mnemonic => string
The mnemonic string of this opcode.
_property: opcode.delta => number
The number of items this opcode will consume from the stack.
_property: opcode.alpha => number
The number of items this opcode will push onto the stack.
_property: opcode.doc => string
A short description of what this opcode does.
_property: opcode.isMemory() => "read" | "write" | "full"
Returns true if the opcode accesses memory.
_property: opcode.isStatic() => boolean
Returns true if the opcode cannot change state.
_property: opcode.isJump() => boolean
Returns true if the opcode is a jumper operation.
_property: opcode.isPush() => number
Returns 0 if the opcode is not a ``PUSH*``, or the number
of bytes this opcode will push if it is.

@ -1,78 +1,17 @@
_title: Assembly
_title: Abstract Syntax Tree
_section: Assembly @<asm>
_section: Abstract Syntax Tree @<asm-ast>
_subsection: Opcode @<asm-opcode>
_property: asm.Opcode.from(valueOrMnemonic) => [[asm-opcode]]
Create a new instnace of an Opcode for a given numeric value
(e.g. 0x60 is PUSH1) or mnemonic (e.g. "PUSH1").
_property: opcode.value => number
The value (bytecode as a number) of this opcode.
_property: opcode.mnemonic => string
The mnemonic string of this opcode.
_property: opcode.delta => number
The number of items this opcode will consume from the stack.
_property: opcode.alpha => number
The number of items this opcode will push onto the stack.
_property: opcode.doc => string
A short description of what this opcode does.
_property: opcode.isMemory() => boolean
Returns true if the opcode accesses memory.
_property: opcode.isStatic() => boolean
Returns true if the opcode cannot change state.
_property: opcode.isJump() => boolean
Returns true if the opcode is a jumper operation.
_property: opcode.isPush() => number
Returns 0 if the opcode is not a ``PUSH*``, or the number
of bytes this opcode will push if it is.
_subsection: Assembler
_heading: Operation @<asm-operation>
An **Operation** is a single command from a disassembled bytecode
stream.
_property: operation.opcode => [[asm-opcode]]
_property: operation.offset => number
_property: operation.pushValue => string
_heading: Functions
_property: asm.parse(code) => [[asm-node]] @SRC<asm/assembler>
Parse an ethers-format assembly file and return the [[asm-ast]].
_property: asm.assemble(node) => string<[[datahexstring]]> @SRC<asm/assembler:function.assemble>
Performs assembly of the [[asm-ast]] //node// and return the
resulting bytecode representation.
_property: asm.disassemble(bytecode) => Array<[[asm-operation]]> @SRC<asm/assembler>
Returns an array of Operations given //bytecode//.
In addition to a standard array, the return also has a
``getOperation(offset)`` method, which can be used to get
the operation at a given byte offset, which prevents access
to internal ``PUSH`` bytes (i.e. safe JUMPDEST).
_property: asm.formatBytecode(operations) => string @SRC<asm/assembler>
Create a formatted output of an array of [[asm-operation]].
_subsection: Abstract Syntax Tree @<asm-ast>
Parsing an file using the [Ethers ASM Grammar](link-ethers-asm-grammar)
will generate an Abstract Syntax Tree. The root node will always
Parsing a file using the [Ethers ASM Dialect](asm-dialect) will
generate an Abstract Syntax Tree. The root node will always
be a [[asm-scopenode]] whose name is ``_``.
To parse a file into an Abstract Syntax tree, use the [parse](asm-parse)
function.
_subsection: Types
_heading: Location @<asm-location>
_property: offset => number
@ -85,6 +24,10 @@ _property: source => string
The source code of this node.
_subsection: Nodes
@TODO: Place a diagram here showing the hierarchy
_heading: Node @<asm-node> @SRC<asm:class.Node>
_property: node.tag => string
@ -112,6 +55,19 @@ value should be taken verbatim and no ``PUSH`` operation shoud be
added, otherwise false.
_heading: PopNode @<asm-popnode> @INHERIT<[[asm-valuenode]]> @SRC<asm:class.PopNode>
A **PopNode** is used to store a place-holder for an implicit pop from the
stack. It represents the code for an implicit place-holder (i.e. ``$$``) or an
explicit place-holder (e.g. ``$1``), which indicates the expect stack position
to consume.
_property: literalNode.index => number
The index this **PopNode** is representing. For an implicit place-holder
this is ``0``.
_heading: LinkNode @<asm-linknode> @INHERIT<[[asm-valuenode]]> @SRC<asm:class.LinkNode>
A **LinkNode** represents a link to another [[asm-node]]'s data,
@ -192,3 +148,5 @@ will use when resolving offset locations, using ``@myScope{ ... }``.
_property: scopeNode.statements => Array<[[asm-node]]>
The list of child nodes for this scope.

@ -0,0 +1,117 @@
_title: Ethers ASM Dialect
_section: Ethers ASM Dialect @<asm-dialect>
This provides a quick, high-level overcview of the **Ethers ASM Dialect**
for EVM, which is defined by the [Ethers ASM Dialect Grammar](link-ethers-asm-grammar)
Once a program is compiled by a higher level langauge into ASM (assembly),
or hand-coded directly in ASM, it needs to be assembled into bytecode.
The assembly process performs a very small set of operations and is
intentionally simple and closely related to the underlying EVM bytecode.
Operations include embedding programs within programs (for example the
deployment bootstrap has the runtime embedded in it) and computing the
necessary offsets for jump operations.
The [Command-Line Assembler](cli-asm) can be used to assemble an
//Ethers ASM Dialect// file or to disassemble bytecode into its
human-readable (ish) opcodes and literals.
_subsection: Opcodes @<asm-dialect-opcode>
An **Opcode** may be provided in either a //functional// or
//instructional// syntax. For Opcodes that require parameters,
the //functional// syntax is recommended and the //instructional//
syntax will raise a warning.
@TODO: Examples
_subsection: Labels @<asm-dialect-label>
A **Label** is a position in the program which can be jumped to. A
``JUMPDEST`` is automatically added to this point in the assembled
output.
@TODO: Exmaples
_subsection: Literals @<asm-dialect-literal>
A **Literal** puts data on the stack when executed using a ``PUSH``
operation.
A **Literal** can be provided using a [[datahexstring]] or a decimal
byte value.
@TODO: exmples
_subsection: Comments @<asm-dialect-comment>
To enter a comment in the **Ethers ASM Dialect**, any text following
a semi-colon (i.e. ``;``) is ignored by the assembler.
_subsection: Scopes @<asm-dialect-scope>
A common case in Ethereum is to have one program embedded in another.
The most common use of this is embedding a Contract **runtime bytecode**
within a **deployment bytecode**, which can be used as **init code**.
When deploying a program to Ethereum, an **init transaction** is used. An
//init transaction// has a null ``to`` address and contains bytecode in
the ``data``. This ``data`` bytecode is a program, that when executed
returns some other bytecode as a result, this restul is the bytecode
to be installed.
Therefore it is important that embedded code uses jumps relative to itself,
not the entire program it is embedded in, which also means that a jump
can **only** target its own scope, no parent or child scopes. This is
enforced by the assembler.
A scope may access the offset of any child [[asm-dialect-datasegment]] or
child [[asm-dialect-scope]] (with respect to itself) and may access the length
of any [[asm-dialect-datasegment]] or [[asm-dialect-scope]] anywhere in the program.
Every program in the **Ethers ASM Dialect** has a top-leve scope named ``_``.
_subsection: Data Segment @<asm-dialect-datasegment>
A **Data Segment** allows arbitrary data to be embedded into a program,
which can be useful for lookup tables or deploy-time constants.
An emtpty **Data Segment** can also be used when a labelled location is
required, but without the ``JUMPDEST`` which a [[asm-dialect-label]] adds.
@TODO: Example
_subsection: Links @<asm-dialect-links>
A **Link** allows access to a [[asm-dialect-scope]], [[asm-dialect-datasegment]] or [[asm-dialect-label]].
To access the byte offset of a labelled item, use ``$foobar``.
For a [[asm-dialect-label]], the target must be directly reachable within this scope. For
a [[asm-dialect-datasegment]] or a [[asm-dialect-scope]], it can be inside the same scope or any
child scope.
For a [[asm-dialect-datasegment]] or a [[asm-dialect-label]], there is an additional type of
**Link**, which provides the length of the data or bytecode respectively. A
**Length Link** is accessed by ``#foobar`` and is pushed on the stack as a
literal.
_subsection: Stack Placeholders @<asm-dialect-placeholder>
@TODO: exampl
_subsection: Evaluation and Excution @<asm-dialect-scripting>

@ -0,0 +1,8 @@
_title: Assembly
_section: Assembly
_toc:
dialect
api
ast

@ -26,7 +26,7 @@ _definition: **Supported Networks**
- Homestead (Mainnet)
- Ropsten (proof-of-work testnet)
- Rinkeby (proof-of-Authority testnet)
- Rinkeby (proof-of-authority testnet)
- G&ouml;rli (clique testnet)
- Kovan (proof-of-authority testnet)
@ -40,7 +40,7 @@ _definition: **Supported Networks**
- Homestead (Mainnet)
- Ropsten (proof-of-work testnet)
- Rinkeby (proof-of-Authority testnet)
- Rinkeby (proof-of-authority testnet)
- G&ouml;rli (clique testnet)
- Kovan (proof-of-authority testnet)
@ -53,7 +53,7 @@ _definition: **Supported Networks**
- Homestead (Mainnet)
- Ropsten (proof-of-work testnet)
- Rinkeby (proof-of-Authority testnet)
- Rinkeby (proof-of-authority testnet)
- G&ouml;rli (clique testnet)
- Kovan (proof-of-authority testnet)

@ -56,6 +56,9 @@ The ``sighash`` format is **insufficient** to re-create the original [[abi-fragm
since it discards modifiers such as indexed, anonymous, stateMutability, etc.
_subsection: Interface @<abi-interface> @SRC<abi/interface:class.Interface>
TODO
_subsection: Fragment @<abi-fragment> @SRC<abi/fragments:class.Fragment>
An ABI is a collection of **Fragments**, where each fragment specifies:

@ -3,7 +3,16 @@ _title: Big Number
_section: BigNumber @<bignumber>
Explain about BigNumber here...
Many operations in Ethereum operation on numbers which are
[outside the range of safe values](notes-safenumbers) to use
in JavaScript.
A **BigNumber** is an object which safely allows mathematic operations
on numbers of any magnitude.
Most operations which need to return a value will return a **BigNumber**
and parameters which accept values will generally accept them.
_heading: Importing
@ -25,10 +34,10 @@ _definition: **//BytesLike//**
A [BytesLike](byteslike) Object, such as an Array or Uint8Array.
_definition: **//BigNumber//**
An existing BigNumber instance.
An existing [[bignumber]] instance.
_definition: **//number//**
A number that is within the safe range for JavaScript numbers.
A number that is within the [safe range](link-js-maxsafe) for JavaScript numbers.
_definition: **//BigInt//**
A JavaScript [BigInt](link-js-bigint)
@ -129,7 +138,7 @@ _property: bignumber.toString() => string @SRC<bignumber:BigNumber.toString>
Returns the value of //bignumber// as a base-10 string.
_property: bignumber.toHexString() => string<[[datahexstring]]> @SRC<bignumber:BigNumber.toHexString>
Returns the value of //bignumber// as a base-16, `0x`-prefixed [hexstring](hexstring).
Returns the value of //bignumber// as a base-16, ``0x``-prefixed [[datahexstring]].
_heading: Inspection
@ -142,11 +151,13 @@ _heading: Examples
_code: bignumber-examples.js
_subsection: Notes
A few short notes on numbers...
This section is a for a couple of questions that come up frequently.
_heading: Why can't I just use numbers?
_heading: Why can't I just use numbers? @<notes-safenumbers>
The first problem many encounter when dealing with Ethereum is
the concept of numbers. Most common currencies are broken down
@ -173,3 +184,61 @@ The functions [parseEther( etherString )](http://linkto) and
between string representations, which are displayed to or entered
by the user and Big Number representations which can have
mathematical operations handled safely.
_heading: Why not BigNumber.js, BN.js, BigDecimal, etc?
Everyone has their own favourite Big Number library, and once someone
has choosen one, it becomes part of their identity, like their editor,
vi vs emacs. There are over 100 Big Number libraries on [npm](link-npm-query-bignumber).
One of the biggest differences between the Ethers [[bignumber]] object and
other libraries is that it is immutable, which is very important when
dealing with the asynchronous nature of the blockchain.
Capturing the value is not safe in async functions, so immutability
protects us from easy to make mistakes, which is not possible on the
low-level library's objects which supports myriad in-place operations.
Second, the Ethers [[bignumber]] provides all the functionality required
internally and should generally be sufficient for most developers while
not exposing some of the more advanced and rare functionality. So it will
be eaiser to swap out the underlying library without impacting consumers.
For example, if [[link-npm-bnjs]] was exposed, someone may use the
greatest-common-denominator functions, which would then be functionality
the replacing library should also provide to ensure anyone depending on
that functionality is not broken.
_heading: Why BN.js??
The reason why [[link-npm-bnjs]] is used internally as the big
number is because that is the library used by [[link-npm-elliptic]].
Therefore it **must** be included regardless, so we leverage that
library rather than adding another Big Number library, which would
mean two different libraries offering the same functionality.
This has saved about 85kb (80% of this library size) of library size
over other libraries which include separate Big Number libraries for
various purposes.
_heading: Why not allow us to set a global Big Number library?
Another comment that comes up frequently is tha desire to specify a
global user-defined Big Number library, which all functions would
return.
This becomes problematic since your code may live along side other
libraries or code that use Ethers. In fact, even Ethers uses a lot
of the public functions internally.
If you, for example, used a library that used ``a.plus(b)`` instead
of ``a.add(b)``, this would break Ethers when it tries to compute
fees internally, and other libraries likely have similar logic.
But, the [[bignumber]] prototype is exposed, so you can always add a
``toMyCustomBigNumber()`` method to all [[bignumber]]'s globally
which is safe.

@ -134,3 +134,7 @@ _property: utils.splitSignature(aSignatureLikeOrBytesLike) => [[signature]] @<u
Return the full expanded-format of //aSignaturelike// or a flat-format [[datahexstring]].
Any missing properties will be computed.
_subsection: Random Bytes
_property: ethers.utils.randomBytes(length) => Uint8Array
Return a new Uint8Array of //length// random bytes.

@ -11,38 +11,38 @@ _code: constants-import.js
_subsection: Bytes
_property: constants.AddressZero => string<[Address](address)> @<constants-addresszero> @SRC<constants>
_property: ethers.constants.AddressZero => string<[Address](address)> @<constants-addresszero> @SRC<constants>
The Address Zero, which is 20 bytes (40 nibbles) of zero.
_property: constants.HashZero => string<[[datahexstring]]<32>> @<constants-hashzero> @SRC<constants>
_property: ethers.constants.HashZero => string<[[datahexstring]]<32>> @<constants-hashzero> @SRC<constants>
The Hash Zero, which is 32 bytes (64 nibbles) of zero.
_subsection: Strings
_property: constants.EtherSymbol => string @<constants-ethersymbol> @SRC<constants>
_property: ethers.constants.EtherSymbol => string @<constants-ethersymbol> @SRC<constants>
The Ether symbol, **&Xi;**.
_subsection: BigNumber
_property: constants.NegativeOne => [[bignumber]] @<constants-negativeone> @SRC<constants>
_property: ethers.constants.NegativeOne => [[bignumber]] @<constants-negativeone> @SRC<constants>
The BigNumber value representing ``"-1"``.
_property: constants.Zero => [[bignumber]] @<constants-zero> @SRC<constants>
_property: ethers.constants.Zero => [[bignumber]] @<constants-zero> @SRC<constants>
The BigNumber value representing ``"0"``.
_property: constants.One => [[bignumber]] @<constants-one> @SRC<constants>
_property: ethers.constants.One => [[bignumber]] @<constants-one> @SRC<constants>
The BigNumber value representing ``"1"``.
_property: constants.Two => [[bignumber]] @<constants-two> @SRC<constants>
_property: ethers.constants.Two => [[bignumber]] @<constants-two> @SRC<constants>
The BigNumber value representing ``"2"``.
_property: constants.WeiPerEther => [[bignumber]] @<constants-weiperether> @SRC<constants>
_property: ethers.constants.WeiPerEther => [[bignumber]] @<constants-weiperether> @SRC<constants>
The BigNumber value representing ``"1000000000000000000"``, which is the
number of Wei per Ether.
_property: constants.MaxUint256 => [[bignumber]] @<constants-maxuint256> @SRC<constants>
_property: ethers.constants.MaxUint256 => [[bignumber]] @<constants-maxuint256> @SRC<constants>
The BigNumber value representing the maximum ``uint256`` value.

@ -2,20 +2,50 @@ _title: Encoding Utilies
_section: Encoding Utilities
_property: utils.base58.decode(textData) => Uin8Array
_subsection: Base58
_property: ethers.utils.base58.decode(textData) => Uin8Array
Return a typed Uint8Array representation of //textData// decoded using
base-58 encoding.
_property: utils.base58.encode(aBytesLike) => string
_property: ethers.utils.base58.encode(aBytesLike) => string
Return //aBytesLike// encoded as a string using the base-58 encoding.
_property: utils.base64.decode(textData) => Uin8Array
_subsection: Base64
_property: ethers.utils.base64.decode(textData) => Uin8Array
Return a typed Uint8Array representation of //textData// decoded using
base-64 encoding.
_property: utils.base64.encode(aBytesLike) => string
_property: ethers.utils.base64.encode(aBytesLike) => string
Return //aBytesLike// encoded as a string using the base-64 encoding.
_subsection: Recursive-Length Prefix
The [[link-rlp]] encoding is used throughout Ethereum to serialize nested
structures of Arrays and data.
_property: ethers.utils.RLP.encode(dataObject) => string<[[datahexstring]]>
Encode a structured Data Object into its RLP-encoded representation.
Each Data component may be an valid [[byteslike]].
_property: ethers.utils.RLP.decode(aBytesLike) => [DataObject](rlp-dataobject)
Decode an RLP-encoded //aBytesLike// into its structured Data Object.
All Data components will be returned as a [[datahexstring]].
_heading: Data Object @<rlp-dataobject>
A **Data Object** is a recursive structure which is used to serialize many
internal structures in Ethereum. Each **Data Object** can either be:
- Binary Data
- An Array of **Data Objects** (i.e. this recursively includes Nesting)
_definition: **Examples**
- ``"0x1234"``
- ``[ "0x1234", [ "0xdead", "0xbeef" ], [ ] ]``

@ -2,54 +2,9 @@ _title: Fixed Number
_section: FixedNumber @<fixednumber>
_subsection: FixedFormat @<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 [[fixedformatstring]]
directly into the [[fixednumber]] will automatically create this.
_heading: Format Strings @<fixedformatstring>
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`
_heading: Creating Instances
_property: FixedFormat.from(value = "fixed128x18") => [[fixedformat]] @<fixednumber-from> @SRC<bignumber/fixednumber:FixedFormat.from>
Returns a new instance of a **FixedFormat** defined by //value//. Any valid [[fixedformatstring]]
may be passed in as well as any object which has any of ``signed``, ``width`` and ``decimals``
defined, including a [[fixedformat]] object.
_heading: Properties
_property: fixedFormat.signed => boolean
_property: fixedFormat.width => number
_property: fixedFormat.decimals => number
_property: fixedFormat.name => string
_definition: **//"fixed"//**
A shorthand for ``fixed128x80``.
A **FixedNumber** is a fixed-width (in bits) number with an internal
base-10 divisor, which allows it to represent a decimal fractional
component.
_subsection: Creating Instances
@ -117,3 +72,57 @@ _heading: Inspection
_property: FixedNumber.isFixedNumber(value) => boolean @SRC<bignumber/fixednumber>
Returns true if and only if //value// is a **FixedNumber**.
_subsection: FixedFormat @<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 [[fixedformatstring]]
directly into the [[fixednumber]] will automatically create this.
_heading: Format Strings @<fixedformatstring>
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`
_heading: Creating Instances
_property: FixedFormat.from(value = "fixed128x18") => [[fixedformat]] @<fixednumber-from> @SRC<bignumber/fixednumber:FixedFormat.from>
Returns a new instance of a **FixedFormat** defined by //value//. Any valid [[fixedformatstring]]
may be passed in as well as any object which has any of ``signed``, ``width`` and ``decimals``
defined, including a [[fixedformat]] object.
_heading: Properties
_property: fixedFormat.signed => boolean
The signed-ness of //fixedFormat//, true if negative values are supported.
_property: fixedFormat.width => number
The width (in bits) of //fixedFormat//.
_property: fixedFormat.decimals => number
The number of decimal points of //fixedFormat//.
_property: fixedFormat.name => string
The name of the //fixedFormat//, which can be used to recreate the format
and is the string that the Solidity language uses to represent this format.
_definition: **//"fixed"//**
A shorthand for ``fixed128x80``.

@ -0,0 +1,127 @@
_title: HD Wallet
_section: HD Wallet
TODO: Explain [BIP32](link-bip-32) [BIP-39](link-bip-39) and whatnot here...
_subsection: Types
_heading: Constants @<hdnode-defaultpath> @SRC<hdnode:defaultPath>
_property: ethers.utils.defaultPath => "m/44'/60'/0'/0/0"
The default path for Ethereum in an HD Wallet
_heading: Mnemonic @<hdnode-mnemonic>
_property: mnemonic.phrase => string
The mnemonic phrase for this mnemonic. It is 12, 15, 18, 21 or 24 words long
and separated by the whitespace specified by the ``locale``.
_property: mnemonic.path => string
The HD path for this mnemonic.
_property: mnemonic.locale => string
The language of the wordlist this mnemonic is using.
_subsection: HDNode @<hdnode> @SRC<hdnode:class.HDNode>
_heading: Creating Instances
_property: ethers.HDNode.fromMnemonic(phrase [, password [, wordlist ] ]) => [[hdnode]] @SRC<hdnode>
Return the [[hdnode]] for //phrase// with the optional //password//
and //wordlist//.
_property: ethers.HDNode.fromSeed(aBytesLike) => [[hdnode]] @SRC<hdnode>
Return the [[hdnode]] for the seed //aBytesLike//.
_property: ethers.HDNode.fromExtendedKey(extendedKey) => [[hdnode]] @SRC<hdnode>
Return the [[hdnode]] for the //extendedKey//. If //extendedKey// was
neutered, the **HDNode** will only be able to compute addresses and not
private keys.
_heading: Properties
_property: hdNode.privateKey => string<[[datahexstring]]<32>>
The private key for this HDNode.
_property: hdNode.publicKey => string<[[datahexstring]]<33>>
The (compresses) public key for this HDNode.
_property: hdNode.fingerprint => string<[[datahexstring]]<4>>
The fingerprint is meant as an index to quickly match parent and
children nodes together, however collisions may occur and software
should verify matching nodes.
Most developers will not need to use this.
_property: hdNode.parentFingerprint => string<[[datahexstring]]<4>>
The fingerprint of the parent node. See //fingerprint// for more
details.
Most developers will not need to use this.
_property: hdNode.address => string<[[address]]>
The address of this HDNode.
_property: hdNode.mnemonic => [[hdnode-mnemonic]]
The mnemonic of this HDNode, if known.
_property: hdNode.path => string
The path of this HDNode, if known. If the //mnemonic// is also known,
this will match ``mnemonic.path``.
_property: hdNode.chainCode => string<[[datahexstring]]<32>>
The chain code is used as a non-secret private key which is then used
with EC-multiply to provide the ability to derive addresses without
the private key of child non-hardened nodes.
Most developers will not need to use this.
_property: hdNode.index => number
The index of this HDNode. This will match the last component of
the //path//.
Most developers will not need to use this.
_property: hdNode.depth => number
The depth of this HDNode. This will match the number of components
(less one, the ``m/``) of the //path//.
Most developers will not need to use this.
_property: hdNode.extendedKey => string
A serialized string representation of this HDNode. Not all properties
are included in the serialization, such as the mnemonic and path, so
serializing and deserializing (using the ``fromExtendedKey`` class
method) will result in reduced information.
_heading: Methods
_property: hdNode.neuter() => [[hdnode]] @SRC<hdnode>
Return a new instance of //hdNode// with its private key removed
but all otehr properties preserved. This ensures that the key
can not leak the private key of itself or any derived children,
but may still be used to compute the addresses of itself and
any non-hardened children.
_property: hdNode.derivePath(path) => [[hdnode]] @SRC<hdnode>
Return a new [[hdnode]] which is the child of //hdNode// found
by deriving //path//.
_subsection: Other Functions
_property: ethers.utils.mnemonicToSeed(phrase [ , password]) => string<[[datahexstring]]<64>> @SRC<hdnode>
Convert a mnemonic phrase to a seed, according to [BIP-39](link-bip-39).
_property: ethers.utils.mnemonicToEntropy(phrase [ , wordlist ]) => string<[[datahexstring]]> @SRC<hdnode>
Convert a mnemonic phrase to its entropy, according to [BIP-39](link-bip-39).
_property: ethers.utils.isValidMnemonic(phrase [ , wordlist ]) => boolean @SRC<hdnode>
Returns true if //phrase// is a valid mnemonic phrase, by
testing the checksum.

@ -6,13 +6,20 @@ These utilities are used extensively within the library, but
are also quite useful for application developers.
_toc:
address
abi
address
bignumber
bytes
constants
display-logic
encoding
fixednumber
hashing
hdnode
logger
properties
signing-key
strings
transactions
web
wordlists

@ -0,0 +1,92 @@
_title: Logger
_section: Logger @<logger>
_subsection: Errors @<logger-errors>
_property: Logger.errors.UNKNOWN_ERROR
A generic unknown error.
_property: Logger.errors.NOT_IMPLEMENTED
The operation is not implemented.
_property: Logger.errors.UNSUPPORTED_OPERATION
The operation is not supported.
_property: Logger.errors.NETWORK_ERROR
An Ethereum network validation error, such as an invalid chain ID.
_property: Logger.errors.SERVER_ERROR
There was an error communicating with a server.
_property: Logger.errors.TIMEOUT
A timeout occurred.
_property: Logger.errors.BUFFER_OVERRUN
The amount of data needed is more than the amount of data required,
which would cause the data buffer to read past its end.
_property: Logger.errors.NUMERIC_FAULT
There was an invalid operation done on numeric values.
Common cases of this occur when there is [[link-wiki-overflow]],
[[link-wiki-underflow]] in fixed numeric types or division by zero.
_property: Logger.errors.MISSING_NEW
An object is a Class, but is now being called with ``new``.
_property: Logger.errors.INVALID_ARGUMENT
The type or value of an argument is invalid. This will generally also
include the ``name`` and ``value`` of the argument. Any function which
accepts sensitive data (such as a private key) will include the string
``[REDACTED]]`` instead of the value passed in.
_property: Logger.errors.MISSING_ARGUMENT
An expected parameter was not specified.
_property: Logger.errors.UNEXPECTED_ARGUMENT
Too many parameters we passed into a function.
_property: Logger.errors.CALL_EXCEPTION
An attempt to call a blockchain contract (getter) resulted in a
revert or other error.
_property: Logger.errors.INSUFFICIENT_FUNDS
The account is attempting to make a transaction which costs more than is
available.
A sending account must have enough ether to pay for the value, the gas limit
(at the gas price) as well as the intrinsic cost of data. The intrinsic cost
of data is 4 gas for each zero byte and 68 gas for each non-zero byte.
_property: Logger.errors.NONCE_EXPIRED
The nonce being specified has already been used in a mined transaction.
_property: Logger.errors.REPLACEMENT_UNDERPRICED
When replacing a transaction, by using a nonce which has already been sent to
the network, but which has not been mined yet the new transaction must specify
a higher gas price.
This error occurs when the gas price is insufficient to //bribe// the transaction
pool to prefer the new transaction over the old one. Generally, the new gas price
should be about 50% + 1 wei more, so if a gas price of 10 gwei was used, the
replacement should be 15.000000001 gwei.
_property: Logger.errors.UNPREDICTABLE_GAS_LIMIT
When estimating the required amount of gas for a transaction, a node is queried for
its best guess.
If a node is unable (or unwilling) to predict the cost, this error occurs.
The best remedy for this situation is to specify a gas limit in the transaction
manually.
This error can also indicate that the transaction is expected to fail regardless,
if for example an account with no tokens is attempting to send a token.
_subsection: Creating instances
_property: new ethers.utils.Logger(version)
Create a new logger which will include //version// in all errors thrown.

@ -2,6 +2,10 @@ _title: Property Utilities
_section: Property Utilities
_property: utils.resolveProperties(anObject) => Promise<any> @<utils-resolveproperties> @SRC<properties>
_property: ethers.utils.checkPropertoes() => void
_property: ethers.utils.deepCopy(anObject) => any
_property: ethers.utils.defineReadOnly(anObject, name, value) => void
_property: ethers.utils.getStatic(aConstructor, key) => any
_property: ethers.utils.resolveProperties(anObject) => Promise<any> @<utils-resolveproperties> @SRC<properties>
_property: ethers.utils.shallowCopy(anObject) => any

@ -1,7 +1,37 @@
_title: Signing Keys
_section: Signing Key
_section: Signing Key @<utils-signingkey>
_property: new ethers.utils.SigningKey(privateKey)
Create a new SigningKey for //privateKey//.
_property: signingKey.privateKey => string<[[datahexstring]]<32>>
The private key for this Signing Key.
_property: signingKey.publicKey => string<[[datahexstring]]<65>>
The uncompressed public key for this Signing Key. It will always be
65 bytes (130 nibbles) and begine with ``0x04``.
_property: signingKey.compressedPublicKey => string<[[datahexstring]]<33>>
The compressed public key for this Signing Key. It will always be
33 bytes (66 nibbles) and begine with either ``0x02`` or ``0x03``.
_property: signingKey.signDisgest(digest) => [[signature]]
Sign the //digest// and return the signature.
_property: signingKey.computeSharedSecret(otherKey) => string<[[datahexstring]]<32>>
Compute the ECDH shared secret with //otherKey//. The //otherKey// may be
either a public key or a private key, but generally will be a public key from
another party.
It is best practice that each party computes the hash of this before using it
as a symmetric key.
_property: SigningKey.isSigningKey(anObject) => boolean
Returns true if //anObject// is a SigningKey.
_subsection: Other Functions
_property: ethers.utils.verifyMessage(message, signature) => string<[[address]]> @<utils-verifymessage> @SRC<wallet>
Returns the address that signed //message// producing //signature//. The
@ -10,3 +40,10 @@ 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](link-eip-155))
to be used since the v parameter is still completely non-ambiguous.
_property: ethers.utils.recocverPublicKey(digest, signature) => string<[[datahexstring]]<65>> @<utils-recoverpublickey>
_property: ethers.utils.computePublicKey(key [, compressed = false ]) => string<[[datahexstring]]> @<utils-computepublickey>
Computes the public key of //key//, optionally compressing it. The //key//
can be any form of public key (compressed or uncompressed) or a private
key.

@ -5,49 +5,96 @@ _section: Transactions @<utils-transactions>
_subsection: Types
_heading: UnsignedTransaction @<types-unsignedtransaction>
An unsigned transaction represents a transaction that has not been signed.
An unsigned transaction represents a transaction that has not been
signed and its values are flexible as long as they are not ambiguous.
_property: unsignedTransaction.to => string<[Address](address)>
The addres this transaction is to.
_property: unsignedTransaction.nonce => number
The nonce of this transaction.
_property: unsignedTransaction.gasLimit => [[bignumber]]
_property: unsignedTransaction.gasLimit => [[bignumberish]]
The gas limit for this transaction.
_property: unsignedTransaction.gasPrice => [[bignumber]]
_property: unsignedTransaction.gasPrice => [[bignumberish]]
The gas price for this transaction.
_property: unsignedTransaction.data => [[byteslike]]
The data for this transaction.
_property: unsignedTransaction.value => [[bignumber]]
_property: unsignedTransaction.value => [[bignumberish]]
The value (in wei) for this transaction.
_property: unsignedTransaction.chainId => number
The chain ID for this transaction. If the chain ID is 0 or null,
then [[link-eip-155]] is disabled and legacy signing is
used, unless overridden in a signature.
_heading: Transaction @<types-transaction>
A generic object to represent a transaction.
_property: unsignedTransaction.hash => string<[[datahexstring]]<32>>
_property: transaction.hash => string<[[datahexstring]]<32>>
The transaction hash, which can be used as an identifier for
//transaction//. This is the keccak256 of the serialized RLP encoded
representation of //transaction//.
_property: unsignedTransaction.to => string<[Address](address)>
The address //transaction// is to.
_property: unsignedTransaction.from => string<[Address](address)>
_property: transaction.from => string<[Address](address)>
The address //transaction// is from.
_property: unsignedTransaction.nonce => number
_property: transaction.nonce => number
The nonce for //transaction//. Each transaction sent to the network
from an account includes this, which ensures the order and
non-replayability of a transaction. This must be equal to the current
number of transactions ever sent to the network by the **from** address.
_property: unsignedTransaction.gasLimit => [[bignumber]]
_property: transaction.gasLimit => [[bignumber]]
The gas limit for //transaction//. An account must have enough ether to
cover the gas (at the specified **gasPrice**). Any unused gas is
refunded at the end of the transaction, and if there is insufficient gas
to complete execution, the effects of the trasaction are reverted, but
the gas is **fully consumed** and an out-of-gas error occurs.
_property: unsignedTransaction.gasPrice => [[bignumber]]
_property: transaction.gasPrice => [[bignumber]]
The price (in wei) per unit of gas for //transaction//.
_property: unsignedTransaction.data => [[byteslike]]
_property: transaction.data => [[byteslike]]
The data for //transaction//. In a contract this is the call data.
_property: unsignedTransaction.value => [[bignumber]]
_property: transaction.value => [[bignumber]]
The value (in wei) for //transaction//.
_property: unsignedTransaction.chainId => number
_property: transaction.chainId => number
The chain ID for //transaction//. This is used as part of
[[link-eip-155]] to prevent replay attacks on different
networks.
_property: unsignedTransaction.r => [[byteslike]]
For example, if a transaction was made on ropsten with an account
also used on homestead, it would be possible for a transaction
signed on ropsten to be executed on homestead, which is likely
unintended.
_property: unsignedTransaction.s => [[byteslike]]
There are situations where replay may be desired, however these
are very rare and it is almost always recommended to specify the
chain ID.
_property: unsignedTransaction.v => number
_property: transaction.r => string<[[datahexstring]]<32>>
The r portion of the elliptic curve signatures for //transaction//.
This is more accurately, the x coordinate of the point r (from
which the y can be computed, along with v).
_property: transaction.s => string<[[datahexstring]]<32>>
The s portion of the elliptic curve signatures for //transaction//.
_property: transaction.v => number
The v portion of the elliptic curve signatures for //transaction//.
This is used to refine which of the two possible points a given
x-coordinate can have, and in [[link-eip-155]] is additionally
used to encode the chain ID into the serialized transaction.
_subsection: Functions
@ -64,9 +111,18 @@ Computes the address that signed //digest// to get //aSignatureLike// using the
ecrecover algorithm.
_property: ethers.utils.serialize(transaction [ , signature ]) => string<[[datahexstring]]> @<utils-serialize> @SRC<transactions>
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.
Computes the serialized //transaction//, optionally serialized with
the a //signature//. If //signature// is not present, 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//.
This function uses [[link-eip-155]] if a chainId is provided,
otherwise legacy serialization is used. It is **highly** recommended
to always specify a //chainId//.
If //signature// includes a chain ID (explicitly or implicitly by using an
[[link-eip-155]] ``v`` or ``_vs``) it will be used to compute the
chain ID.
If there is a mismatch between the chain ID of //transaction// and //signature//
an error is thrown.

@ -0,0 +1,66 @@
_title: Web Utilities
_section: Web Utilities
_property: ethers.utils.fetchJson(urlOrConnectionInfo [, json [ , processFunc ] ]) => Promise<any> @<web-fetchjson>
Fetch and parse the JSON content from //urlOrConnectionInfo//, with the
optiona body //json// and optionally processing the result with //processFun//
before returning it.
_property: ethers.utils.poll(pollFunc [, options ]) => Promise<any> @<web-poll>
Repeatedly call pollFunc using the [[web-polloptions]] until it returns a
value other than undefined.
_heading: Connection Info @<web-connectioninfo>
_property: connection.url => string
The URL to connect to.
_property: connection.user => string
The username to use for [[link-wiki-basicauth]].
The default is null (i.e. do not use basic authentication)
_property: connection.password => string
The password to use for [[link-wiki-basicauth]].
The default is null (i.e. do not use basic authentication)
_property: connection.allowInsecureAuthentication => boolean
Allow [[link-wiki-basicauth]] over non-secure HTTP. The default is false.
_property: connection.timeout => number
How long to wait before rejecting with a //timeout// error.
_property: connection.headers => { [ key: string]: string }
Additional headers to include in the connection.
_heading: Poll Options @<web-polloptions>
_property: options.timeout => number
The amount of time allowed to ellapse before triggering a timeout
error.
_property: options.floor => number
The minimum time limit to allow for [[link-wiki-backoff]].
The default is 0s.
_property: options.ceiling => number
The maximum time limit to allow for [[link-wiki-backoff]].
The default is 10s.
_property: options.interval => number
The interval used during [[link-wiki-backoff]] calculation.
The default is 250ms.
_property: options.retryLimit => number
The number of times to retry in the event of an error or //undefined// is
returned.
_property: options.onceBlock => [[provider]]
If this is specified, the polling will wait on new blocks from
//provider// before attempting the //pollFunc// again.

@ -0,0 +1,60 @@
_title: Wordlists
_section: Wordlists @<wordlists>
_subsection: Wordlist @<wordlist>
_property: wordlist.locale => string
The locale for this wordlist.
_property: wordlist.getWord(index) => string
Returns the word at //index//.
_property: wordlist.getWordIndex(word) => number
Returns the index of //word// within the wordlist.
_property: wordlist.split(mnemonic) => Array<string>
Returns the mnemonic split into each individual word, according to a
locale's valid whitespace character set.
_property: wordlist.join(words) => string
Returns the mnemonic by joining //words// together using the
whitespace that is standard for the locale.
_property: Wordlist.check(wordlists) => string<[[datahexstring]]<32>>
Checks that all words map both directions correctly and return the
hash of the lists. Sub-classes should use this to validate the wordlist
is correct against the official wordlist hash.
_property: Wordlist.register(wordlist [ , name ]) => string<[[datahexstring]]<32>>
Register a wordlist with the list of wordlists, optionally overriding
the registered //name//.
_subsection: Languages @<wordlist-languages>
_property: ethers.wordlists.cz => Wordlist
The Czech [[wordlist]].
_property: ethers.wordlists.en => Wordlist
The English [[wordlist]].
_property: ethers.wordlists.es => Wordlist
The Spanish [[wordlist]].
_property: ethers.wordlists.fr => Wordlist
The French [[wordlist]].
_property: ethers.wordlists.it => Wordlist
The Italian [[wordlist]].
_property: ethers.wordlists.js => Wordlist
The Japanese [[wordlist]].
_property: ethers.wordlists.ko => Wordlist
The Korean [[wordlist]].
_property: ethers.wordlists.zh_cn => Wordlist
The Simplified Chinese [[wordlist]].
_property: ethers.wordlists.zh_tw => Wordlist
The Traditional Chinese [[wordlist]].

@ -0,0 +1,11 @@
/home/ethers> ethers-asm SimpleStore.asm
0x602a6000556044601160003960446000f334601e5760003560e01c80632096525514602457806355241077146030575b60006000fd5b60005460005260206000f35b6024361415601e5760043560005560006000f3
# Piping in ASM source code
/home/ethers> cat SimpleStore.asm | ethers-asm
# Same as above
# Setting a define which the ASM file checks and adds a checksum
/home/ethers> ethers-asm --define checksum SimpleStore.asm
0x602a6000556065601160003960656000f334601e5760003560e01c80632096525514602457806355241077146030575b60006000fd5b60005460005260206000f35b6024361415601e5760043560005560006000f37f10358310d664c9aeb4bf4ce7a10a6a03176bd23194c8ccbd3160a6dac90774d6

@ -0,0 +1,57 @@
/home/ethers> ethers-asm --disassemble SimpleStore.bin
0000 : 0x2a ; #1
0002 : 0x00 ; #1
0004 : SSTORE
0005 : 0x44 ; #1
0007 : 0x11 ; #1
0009 : 0x00 ; #1
000b : CODECOPY
000c : 0x44 ; #1
000e : 0x00 ; #1
0010 : RETURN
0011 : CALLVALUE
0012 : 0x1e ; #1
0014 : JUMPI
0015 : 0x00 ; #1
0017 : CALLDATALOAD
0018 : 0xe0 ; #1
001a : SHR
001b : DUP1
001c : 0x20965255 ; #4
0021 : EQ
0022 : 0x24 ; #1
0024 : JUMPI
0025 : DUP1
0026 : 0x55241077 ; #4
002b : EQ
002c : 0x30 ; #1
002e : JUMPI
002f*: JUMPDEST
0030 : 0x00 ; #1
0032 : 0x00 ; #1
0034 : REVERT
0035*: JUMPDEST
0036 : 0x00 ; #1
0038 : SLOAD
0039 : 0x00 ; #1
003b : MSTORE
003c : 0x20 ; #1
003e : 0x00 ; #1
0040 : RETURN
0041*: JUMPDEST
0042 : 0x24 ; #1
0044 : CALLDATASIZE
0045 : EQ
0046 : ISZERO
0047 : 0x1e ; #1
0049 : JUMPI
004a : 0x04 ; #1
004c : CALLDATALOAD
004d : 0x00 ; #1
004f : SSTORE
0050 : 0x00 ; #1
0052 : 0x00 ; #1
0054 : RETURN
/home/ethers> cat SimpleStore.bin | ethers-asm --disassemble
# Same as above

@ -2,8 +2,11 @@ Usage:
ethers-asm [ FILENAME ] [ OPTIONS ]
OPTIONS
--disassemble Disassemble input bytecode
--define KEY=VALUE provide assembler defines
--disassemble Disassemble input bytecode
--ignore-warnings Ignore warnings
--pic generate position independent code
--target LABEL output LABEL bytecode (default: _)
OTHER OPTIONS
--debug Show stack traces for errors

@ -0,0 +1,48 @@
; SimpleStore (uint)
; Set the inital value of 42
sstore(0, 42)
; Init code to deploy myContract
codecopy(0, $myContract, #myContract)
return(0, #myContract)
@myContract {
; Non-payable
jumpi($error, callvalue)
; Get the Sighash
shr({{= 256 - 32 }}, calldataload(0))
; getValue()
dup1
{{= sighash("getValue()") }}
jumpi($getValue, eq)
; setValue(uint)
dup1
{{= sighash("setValue(uint)") }}
jumpi($setValue, eq)
; No matching signature
@error:
revert(0, 0)
@getValue:
mstore(0, sload(0))
return (0, 32)
@setValue:
; Make sure we have exactly a uint
jumpi($error, iszero(eq(calldatasize, 36)))
; Store the value
sstore(0, calldataload(4))
return (0, 0)
; There is no *need* for the PUSH32, it just makes
; decompiled code look nicer
@checksum[
{{= (defines.checksum ? concat([ Opcode.from("PUSH32"), id(myContract.source) ]): "0x") }}
]
}

@ -0,0 +1,3 @@
0x602a6000556044601160003960446000f334601e5760003560e01c8063209652
0x5514602457806355241077146030575b60006000fd5b60005460005260206000
0xf35b6024361415601e5760043560005560006000f3

@ -1,17 +1,83 @@
_title: Assembler
_section: Assembler
_section: Assembler @<cli-asm>
The assembler Command-Line utility allows you to assemble the
[Ethers ASM Dialect](asm-dialect) into deployable EVM bytecode
and disassemle EVM bytecode into human-readable mnemonics.
The assembler Command-Line utility allows you to assemble EVM asm files
into deployable bytecode and disassemle EVM bytecode into human-readable
mnemonics.
_subsection: Help
_code: asm-help.txt
_subsection: Examples
TODO examples
_subsection: Example Input Files
_definition: **SimpleStore.asm**
_code: asm-simplestore-asm.txt
_definition: **SimpleStore.bin**
_code: asm-simplestore-bin.txt
_note: Note: Bytecode File Syntax
A bin file may be made up of multiple blocks of bytecode, each may
optionally begin with a ``0x`` prefix, all of which **must** be of
even length (since bytes are required, with 2 nibbles per byte)
All whitespace is ignored.
_subsection: Assembler Examples
The assembler converts an [Ethers ASM Dialect](asm-dialect) into
bytecode by running multiple passes of an assemble stage, each pass
more closely approximating the final result.
This allows small portions of the bytecode to be massaged and tweaked
until the bytecode stablizes. This allows for more compact jump
destinations and for code to be include more advanced meta-programming
techniques.
_code: asm-examples-assemble.txt
_heading: Options
_definition: **-\-define KEY=VALUE** //or// **-\-define FLAG**
This allows key/value pairs (where the value is a string) and
flags (which the value is ``true``) to be passed along to the
assembler, which can be accessed in
[Scripting Blocks](asm-dialect-scripting), such as ``{{= defined.someKey }}``.
_definition: **-\-ignore-warnings**
By default any warning will be treated like an error. This enabled
by-passing warnings.
_definition: **-\-pic**
When a program is assembled, the labels are usually given as an
absolute byte position, which can be jumped to for loops and
control flow. This means that a program must be installed at a specific
location.
Byt specifying the **Position Independent Code** flag, code
will be generated in a way such that all offsets are relative, allowing
the program to be moved without any impact to its logic.
This does incur an additional gsas cost of 8 gas per offset access though.
_definition: **-\-target LABEL**
All programs have a root scope named ``_`` which is by default
assembled. This option allows another labelled target (either a
[[asm-dialect-scope]] or a [[asm-dialect-datasegment]] to be
assembled instead. The entire program is still assembled per usual,
so this only impacts which part of the program is output.
_subsection: Disassembler Examples
A disassembled program shows offsets and mnemonics for the given
bytecode. This format may change in the future to be more
human-readable.
_code: asm-examples-disassemble.txt

@ -158,6 +158,7 @@ module.exports = {
"link-jsonrpc": "https:/\/github.com/ethereum/wiki/wiki/JSON-RPC",
"link-mit": "https:/\/en.m.wikipedia.org/wiki/MIT_License",
"link-namehash": "https:/\/docs.ens.domains/contract-api-reference/name-processing#hashing-names",
"link-rlp": { name: "Recursive Length Prefix", url: "https:/\/github.com/ethereum/wiki/wiki/RLP" },
"link-ethersio": "https:/\/ethers.io/",
"link-ethers-docs": "https:/\/docs.ethers.io/",
@ -165,17 +166,26 @@ module.exports = {
"link-ethers-npm": "https:/\/www.npmjs.com/search?q=%40ethersproject%2F",
"link-ethers-asm-grammar": "https:/\/github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/asm/grammar.jison",
"link-eip-155": "https:/\/eips.ethereum.org/EIPS/eip-155",
"link-eip-155": { name: "EIP-155", url: "https:/\/eips.ethereum.org/EIPS/eip-155" },
"link-eip-609": "https:/\/eips.ethereum.org/EIPS/eip-609",
"link-eip-1014": "https:/\/eips.ethereum.org/EIPS/eip-1014",
"link-eip-2098": "https:/\/eips.ethereum.org/EIPS/eip-2098",
"link-bip-39": "https://en.bitcoin.it/wiki/BIP_0039",
"link-bip-32": "https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki",
"link-npm-elliptic": { name: "elliptic", url: "https:/\/www.npmjs.com/package/elliptic" },
"link-npm-bnjs": { name: "BN.js", url: "https:/\/www.npmjs.com/package/bn.js" },
"link-npm-query-bignumber": "https:/\/www.npmjs.com/search?q=bignumber",
"link-js-array": "https:/\/developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array",
"link-js-bigint": "https:/\/developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt",
"link-js-maxsafe": "https:/\/developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER#Description",
"link-js-typedarray": "https:/\/developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray",
"link-ricmoo-humanreadableabi": "https:/\/blog.ricmoo.com/human-readable-contract-abis-in-ethers-js-141902f4d917",
"link-wiki-basicauth": { name: "Basic Authentication", url: "https:/\/en.wikipedia.org/wiki/Basic_access_authentication" },
"link-wiki-backoff": { name: "Exponential Backoff", url: "https:/\/en.wikipedia.org/wiki/Exponential_backoff" },
"link-wiki-bloomfilter": "https:/\/en.wikipedia.org/wiki/Bloom_filter",
"link-wiki-cryptographichash": "https:/\/en.wikipedia.org/wiki/Cryptographic_hash_function",
"link-wiki-homoglyph": "https:/\/en.wikipedia.org/wiki/IDN_homograph_attack",
@ -190,6 +200,7 @@ module.exports = {
"link-wiki-utf8-replacement": "https:/\/en.wikipedia.org/wiki/Specials_%28Unicode_block%29#Replacement_character",
"link-wiki-scrypt": "https:/\/en.wikipedia.org/wiki/Scrypt",
"link-wiki-sha3": "https:/\/en.wikipedia.org/wiki/SHA-3",
"link-wiki-overflow": { name: "overflow", url: "https:/\/en.wikipedia.org/wiki/Integer_overflow" },
"link-wiki-underflow": { name: "arithmetic underflow", url: "https:/\/en.wikipedia.org/wiki/Arithmetic_underflow" },
}
};

@ -0,0 +1,8 @@
// v4
new ethers.utils.BigNumber(someValue)
ethers.utils.bigNumberify(someValue);
// v5
// - Constructor is private
// - Removed `bigNumberify`
ethers.BigNumber.from(someValue)

@ -0,0 +1,7 @@
// v4
ethers.utils.BigNumber
ethers.utils.BigNumberish
// v5
ethers.BigNumber
ethers.BigNumberish

@ -0,0 +1 @@
TODO

@ -0,0 +1,29 @@
// v4
ethers.errors.UNKNOWN_ERROR
ethers.errors.*
errors.setCensorship(censorship, permanent)
errors.setLogLevel(logLevel)
errors.checkArgumentCount(count, expectedCount, suffix)
errors.checkNew(self, kind)
errors.checkNormalize()
errors.throwError(message, code, params)
errors.warn(...)
errors.info(...)
// v5
ethers.utils.Logger.errors.UNKNOWN_ERROR
ethers.utils.Logger.errors.*
Logger.setCensorship(censorship, permanent)
Logger.setLogLevel(logLevel)
const logger = new ethers.utils.Logger(version);
logger.checkArgumentCount(count, expectedCount, suffix)
logger.checkNew(self, kind)
logger.checkNormalize()
logger.throwError(message, code, params)
logger.warn(...)
logger.info(...)

@ -0,0 +1,64 @@
_title: ethers v4 to v5
_section: Migration: From Ethers v4
_subsection: BigNumber
_heading: Namespace
Since [[bignumber]] is used quite frequently, it has been moved to
the top level of the umbrella package.
_code: bignumber-namespace.txt
_heading: Creating Instances
The ``bigNumberify`` method was always preferred over the constructor
since it could short-circuit an object instantiation for [[bignumber]
objects (since they are immutable). This has been moved to a static
``from`` class method.
_code: bignumber-creating.txt
_subsection: Contracts
_code: contracts.txt
_subsection: Errors
_heading: Namespace
All errors now belong to the [[logger]] class and the related functions
have been moved to [[logger]] instances, which can include a per-package
version string.
Global error fucntions have been moved [[logger]] class methods.
_code: errors.txt
_subsection: Interface
The [[abi-interface]] object has undergone the most dramatic changes.
It is no longer a meta-class and now has methods that simplify handling
contract interface operations without the need for object inspection and
special edge cases.
_heading: Functions
_code: interface-functions.txt
_heading: Events
_code: interface-events.txt
_heading: Inspection
Interrogating properties about a function or event can now (mostly) be
done directly on the [[abi-fragment]] object.
_code: interface-inspection.txt
_subsection: Utilities
_heading: Renaming
_code: utils.txt
_subsection: Wallet
_heading: Mnemonic Phrases
The **mnemonic** phrase and related properties have been merged into
a single ``mnemonic`` object, which also now includes the ``locale``.
_code: wallet.txt

@ -0,0 +1,7 @@
// v4 (example: Transfer(address indexed, address indexed, uint256)
interface.events.Transfer.encodeTopics(values)
interface.events.Transfer.decode(data, topics)
// v5
interface.encodeFilterTopics("Transfer", values)
interface.encodeEventLog("Transfer", data, topics)

@ -0,0 +1,14 @@
// v4 (example: "transfer(address to, uint amount)")
interface.functions.transfer.encode(to, amount)
interface.functions.transfer.decode(callData)
// v5
interface.encodeData("transfer", [ to, amount ])
interface.decodeResult("transfer", data)
// Or you can use any compatible signature or Fragment objects.
// Notice that signature normalization is performed for you,
// e.g. "uint" and "uint256" will be automatically converted
interface.encodeData("transfer(address,uint)", [ to, amount ])
interface.decodeResult("transfer(address to, uint256 amount)", data)

@ -0,0 +1,48 @@
// v4
interface.functions.transfer.name
interface.functions.transfer.inputs
interface.functions.transfer.outputs
interface.functions.transfer.payable
interface.functions.transfer.gas
// v5
const functionFragment = interface.getFunction("transfer")
functionFragment.name
functionFragment.inputs
functionFragment.outputs
functionFragment.payable
functionFragment.gas
// v4; type is "call" or "transaction"
interface.functions.transfer.type
// v5; constant is true (i.e. "call") or false (i.e. "transaction")
functionFragment.constant
// v4
interface.events.Transfer.anonymous
interface.events.Transfer.inputs
interface.events.Transfer.name
// v5
const eventFragment = interface.getEvent("Transfer");
eventFragment.anonymous
eventFragment.inputs
eventFragment.name
// v4
const functionSig = interface.functions.transfer.signature
const sighash = interface.functions.transfer.sighash
const eventSig = interface.events.Transfer.signature
const topic = interface.events.Transfer.topic
// v5
const functionSig = functionFragment.format()
const sighash = interface.getSighash(functionFragment)
const eventSig = eventFragment.format()
const topic = interface.getTopic(eventFragment)

@ -0,0 +1 @@
TODO

@ -0,0 +1,9 @@
// v4
wallet.mnemonic
wallet.path
// v5
// - Mnemonic phrase and path are a Mnemonic object
// - Note: wallet.mnemonic is null if there is no mnemonic
wallet.mnemonic.phrase
wallet.mnemonic.path

@ -2,12 +2,9 @@ _title: Migration Guide
_section: Migration Guide
Migratimg...
Here are some migration guides when upgrading from older versions
of Ethers or other libraries.
_subsection: From Web3
test
_subsection: From ethers v4
test
_toc:
web3
ethers-v4

@ -0,0 +1,15 @@
_title: Migration: From Web3.js
_section: Migration: From Web3.js
TODO
_subsection: Contracts
_subsection: Providers
_subsection: Numbers
_subsection: Utilities