From f01689ac77bc8f87fe9b6b8de3338bfa2cd87706 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 8 Aug 2018 21:47:40 +0200 Subject: Clarify packed encoding. --- docs/abi-spec.rst | 12 +++++------- 1 file 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 ` 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. -- cgit v1.2.3