aboutsummaryrefslogtreecommitdiffstats
path: root/docs/abi-spec.rst
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-08-09 03:47:40 +0800
committerGitHub <noreply@github.com>2018-08-09 03:47:40 +0800
commitf01689ac77bc8f87fe9b6b8de3338bfa2cd87706 (patch)
tree1d2dba3a375c6429e9c59abc7284794078100934 /docs/abi-spec.rst
parentd634d20b5b0dac3e5caf1741073fa123fdd56ab9 (diff)
downloaddexon-solidity-f01689ac77bc8f87fe9b6b8de3338bfa2cd87706.tar.gz
dexon-solidity-f01689ac77bc8f87fe9b6b8de3338bfa2cd87706.tar.zst
dexon-solidity-f01689ac77bc8f87fe9b6b8de3338bfa2cd87706.zip
Clarify packed encoding.
Diffstat (limited to 'docs/abi-spec.rst')
-rw-r--r--docs/abi-spec.rst12
1 files changed, 5 insertions, 7 deletions
diff --git a/docs/abi-spec.rst b/docs/abi-spec.rst
index ec84d123..be645b5c 100644
--- a/docs/abi-spec.rst
+++ b/docs/abi-spec.rst
@@ -565,14 +565,13 @@ Non-standard Packed Mode
Through ``abi.encodePacked()``, Solidity supports a non-standard packed mode where:
-- no :ref:`function selector <abi_function_selector>` is encoded,
- types shorter than 32 bytes are neither zero padded nor sign extended and
- dynamic types are encoded in-place and without the length.
-As an example encoding ``int1, 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 ::
0xff42242448656c6c6f2c20776f726c6421
- ^^ int1(-1)
+ ^^ int8(-1)
^^ bytes1(0x42)
^^^^ uint16(0x2424)
^^^^^^^^^^^^^^^^^^^^^^^^^^ string("Hello, world!") without a length field
@@ -582,8 +581,7 @@ and dynamically-sized types like ``string``, ``bytes`` or ``uint[]`` are encoded
their length field. This means that the encoding is ambiguous as soon as there are two
dynamically-sized elements.
-Note that constants will be packed using the minimum number of bytes required to store them.
-This means that, for example, ``abi.encodePacked(0) == abi.encodePacked(uint8(0)) == hex"00"`` and
-``abi.encodePacked(0x12345678) == abi.encodePacked(uint32(0x12345678)) == hex"12345678"``.
-
If padding is needed, explicit type conversions can be used: ``abi.encodePacked(uint16(0x12)) == hex"0012"``.
+
+Since packed encoding is not used when calling functions, there is no special support
+for prepending a function selector.