mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #4792 from ethereum/someABIDocFixes
Some style fixes to the ABI documentation.
This commit is contained in:
commit
62d6ec9b04
@ -205,7 +205,9 @@ Thus for our ``Foo`` example if we wanted to call ``baz`` with the parameters ``
|
|||||||
- ``0x0000000000000000000000000000000000000000000000000000000000000045``: the first parameter, a uint32 value ``69`` padded to 32 bytes
|
- ``0x0000000000000000000000000000000000000000000000000000000000000045``: the first parameter, a uint32 value ``69`` padded to 32 bytes
|
||||||
- ``0x0000000000000000000000000000000000000000000000000000000000000001``: the second parameter - boolean ``true``, padded to 32 bytes
|
- ``0x0000000000000000000000000000000000000000000000000000000000000001``: the second parameter - boolean ``true``, padded to 32 bytes
|
||||||
|
|
||||||
In total::
|
In total:
|
||||||
|
|
||||||
|
.. code-block:: none
|
||||||
|
|
||||||
0xcdcd77c000000000000000000000000000000000000000000000000000000000000000450000000000000000000000000000000000000000000000000000000000000001
|
0xcdcd77c000000000000000000000000000000000000000000000000000000000000000450000000000000000000000000000000000000000000000000000000000000001
|
||||||
|
|
||||||
@ -217,7 +219,9 @@ If we wanted to call ``bar`` with the argument ``["abc", "def"]``, we would pass
|
|||||||
- ``0x6162630000000000000000000000000000000000000000000000000000000000``: the first part of the first parameter, a ``bytes3`` value ``"abc"`` (left-aligned).
|
- ``0x6162630000000000000000000000000000000000000000000000000000000000``: the first part of the first parameter, a ``bytes3`` value ``"abc"`` (left-aligned).
|
||||||
- ``0x6465660000000000000000000000000000000000000000000000000000000000``: the second part of the first parameter, a ``bytes3`` value ``"def"`` (left-aligned).
|
- ``0x6465660000000000000000000000000000000000000000000000000000000000``: the second part of the first parameter, a ``bytes3`` value ``"def"`` (left-aligned).
|
||||||
|
|
||||||
In total::
|
In total:
|
||||||
|
|
||||||
|
.. code-block:: none
|
||||||
|
|
||||||
0xfce353f661626300000000000000000000000000000000000000000000000000000000006465660000000000000000000000000000000000000000000000000000000000
|
0xfce353f661626300000000000000000000000000000000000000000000000000000000006465660000000000000000000000000000000000000000000000000000000000
|
||||||
|
|
||||||
@ -234,7 +238,9 @@ If we wanted to call ``sam`` with the arguments ``"dave"``, ``true`` and ``[1,2,
|
|||||||
- ``0x0000000000000000000000000000000000000000000000000000000000000002``: the second entry of the third parameter.
|
- ``0x0000000000000000000000000000000000000000000000000000000000000002``: the second entry of the third parameter.
|
||||||
- ``0x0000000000000000000000000000000000000000000000000000000000000003``: the third entry of the third parameter.
|
- ``0x0000000000000000000000000000000000000000000000000000000000000003``: the third entry of the third parameter.
|
||||||
|
|
||||||
In total::
|
In total:
|
||||||
|
|
||||||
|
.. code-block:: none
|
||||||
|
|
||||||
0xa5643bf20000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000464617665000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003
|
0xa5643bf20000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000464617665000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003
|
||||||
|
|
||||||
@ -264,7 +270,7 @@ Finally, we encode the data part of the second dynamic argument, ``"Hello, world
|
|||||||
|
|
||||||
All together, the encoding is (newline after function selector and each 32-bytes for clarity):
|
All together, the encoding is (newline after function selector and each 32-bytes for clarity):
|
||||||
|
|
||||||
::
|
.. code-block:: none
|
||||||
|
|
||||||
0x8be65246
|
0x8be65246
|
||||||
0000000000000000000000000000000000000000000000000000000000000123
|
0000000000000000000000000000000000000000000000000000000000000123
|
||||||
@ -292,7 +298,7 @@ Then we encode the length and data of the second embedded dynamic array ``[3]``
|
|||||||
|
|
||||||
Then we need to find the offsets ``a`` and ``b`` for their respective dynamic arrays ``[1, 2]`` and ``[3]``. To calculate the offsets we can take a look at the encoded data of the first root array ``[[1, 2], [3]]`` enumerating each line in the encoding:
|
Then we need to find the offsets ``a`` and ``b`` for their respective dynamic arrays ``[1, 2]`` and ``[3]``. To calculate the offsets we can take a look at the encoded data of the first root array ``[[1, 2], [3]]`` enumerating each line in the encoding:
|
||||||
|
|
||||||
::
|
.. code-block:: none
|
||||||
|
|
||||||
0 - a - offset of [1, 2]
|
0 - a - offset of [1, 2]
|
||||||
1 - b - offset of [3]
|
1 - b - offset of [3]
|
||||||
@ -318,7 +324,7 @@ Then we encode the embedded strings of the second root array:
|
|||||||
|
|
||||||
In parallel to the first root array, since strings are dynamic elements we need to find their offsets ``c``, ``d`` and ``e``:
|
In parallel to the first root array, since strings are dynamic elements we need to find their offsets ``c``, ``d`` and ``e``:
|
||||||
|
|
||||||
::
|
.. code-block:: none
|
||||||
|
|
||||||
0 - c - offset for "one"
|
0 - c - offset for "one"
|
||||||
1 - d - offset for "two"
|
1 - d - offset for "two"
|
||||||
@ -349,7 +355,7 @@ Then we encode the length of the second root array:
|
|||||||
|
|
||||||
Finally we find the offsets ``f`` and ``g`` for their respective root dynamic arrays ``[[1, 2], [3]]`` and ``["one", "two", "three"]``, and assemble parts in the correct order:
|
Finally we find the offsets ``f`` and ``g`` for their respective root dynamic arrays ``[[1, 2], [3]]`` and ``["one", "two", "three"]``, and assemble parts in the correct order:
|
||||||
|
|
||||||
::
|
.. code-block:: none
|
||||||
|
|
||||||
0x2289b18c - function signature
|
0x2289b18c - function signature
|
||||||
0 - f - offset of [[1, 2], [3]]
|
0 - f - offset of [[1, 2], [3]]
|
||||||
@ -568,7 +574,9 @@ Through ``abi.encodePacked()``, Solidity supports a non-standard packed mode whe
|
|||||||
- types shorter than 32 bytes are neither zero padded nor sign extended and
|
- types shorter than 32 bytes are neither zero padded nor sign extended and
|
||||||
- dynamic types are encoded in-place and without the length.
|
- dynamic types are encoded in-place and without the length.
|
||||||
|
|
||||||
As an example encoding ``int8, bytes1, uint16, string`` with values ``-1, 0x42, 0x2424, "Hello, world!"`` results in ::
|
As an example encoding ``int8, bytes1, uint16, string`` with values ``-1, 0x42, 0x2424, "Hello, world!"`` results in:
|
||||||
|
|
||||||
|
.. code-block:: none
|
||||||
|
|
||||||
0xff42242448656c6c6f2c20776f726c6421
|
0xff42242448656c6c6f2c20776f726c6421
|
||||||
^^ int8(-1)
|
^^ int8(-1)
|
||||||
|
Loading…
Reference in New Issue
Block a user