diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-11-22 20:30:04 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-22 20:30:04 +0800 |
commit | 7fc7fa4293707a6540c3483fcc133e0934e8f229 (patch) | |
tree | 19ab8dd84b4f2055736912c0f8072c0cae13519d | |
parent | be34b574bf386faf414001c7cb11063c6fe7b6f6 (diff) | |
parent | 88e1b68aafa72ad653d9d72d2c57cd4ed7d75e82 (diff) | |
download | dexon-solidity-7fc7fa4293707a6540c3483fcc133e0934e8f229.tar.gz dexon-solidity-7fc7fa4293707a6540c3483fcc133e0934e8f229.tar.zst dexon-solidity-7fc7fa4293707a6540c3483fcc133e0934e8f229.zip |
Merge pull request #3231 from ethereum/chriseth-patch-2
More explanation about the packed encoding.
-rw-r--r-- | docs/abi-spec.rst | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/docs/abi-spec.rst b/docs/abi-spec.rst index 8bd6d1a7..c93ce25b 100644 --- a/docs/abi-spec.rst +++ b/docs/abi-spec.rst @@ -451,13 +451,18 @@ Non-standard Packed Mode Solidity supports a non-standard packed mode where: - no :ref:`function selector <abi_function_selector>` is encoded, -- short types are not zero padded and +- 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 ``uint1, bytes1, uint8, string`` with values ``1, 0x42, 0x2424, "Hello, world!"`` results in :: +As an example encoding ``int1, bytes1, uint16, string`` with values ``-1, 0x42, 0x2424, "Hello, world!"`` results in :: - 0x0142242448656c6c6f2c20776f726c6421 - ^^ uint1(1) + 0xff42242448656c6c6f2c20776f726c6421 + ^^ int1(-1) ^^ bytes1(0x42) - ^^^^ uint8(0x2424) + ^^^^ uint16(0x2424) ^^^^^^^^^^^^^^^^^^^^^^^^^^ string("Hello, world!") without a length field + +More specifically, each statically-sized type takes as many bytes as its range has +and dynamically-sized types like ``string``, ``bytes`` or ``uint[]`` are encoded without +their length field. This means that the encoding is ambiguous as soon as there are two +dynamically-sized elements. |