diff options
author | chriseth <chris@ethereum.org> | 2018-06-28 00:29:01 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-28 00:29:01 +0800 |
commit | 4a842ecc823c2d4152cdf2639eb83f2318499f1c (patch) | |
tree | 7733ac8095862aa2a9b43b93706ba56df7460a16 /docs/abi-spec.rst | |
parent | ce4b233f8f58f04d564aedc3061e7ecb1bf9737a (diff) | |
parent | 92cb4acd8a748ef2cf6a00a5a9f41975c23127c2 (diff) | |
download | dexon-solidity-4a842ecc823c2d4152cdf2639eb83f2318499f1c.tar.gz dexon-solidity-4a842ecc823c2d4152cdf2639eb83f2318499f1c.tar.zst dexon-solidity-4a842ecc823c2d4152cdf2639eb83f2318499f1c.zip |
Merge pull request #4097 from ethereum/noPackedExceptForPacked
[BREAKING] call only takes a single argument and does not pad
Diffstat (limited to 'docs/abi-spec.rst')
-rw-r--r-- | docs/abi-spec.rst | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/docs/abi-spec.rst b/docs/abi-spec.rst index 21e67201..e4f8ed4f 100644 --- a/docs/abi-spec.rst +++ b/docs/abi-spec.rst @@ -559,7 +559,7 @@ would result in the JSON: Non-standard Packed Mode ======================== -Solidity supports a non-standard packed mode where: +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 @@ -577,3 +577,9 @@ More specifically, each statically-sized type takes as many bytes as its range h 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. + +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"``.
\ No newline at end of file |