aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-09-27 18:08:48 +0800
committerGitHub <noreply@github.com>2017-09-27 18:08:48 +0800
commitf9e43cf9209e011dae8eb3ea8faa2cb33836af60 (patch)
treeb2959b2ffc28c2be6d13f290a9c08030e3c04e60
parent809d5ce128e76501538a3d143252e6caef7ee862 (diff)
parenta7592fa8016401b4674faa5059b0ae00dc7ece68 (diff)
downloaddexon-solidity-f9e43cf9209e011dae8eb3ea8faa2cb33836af60.tar.gz
dexon-solidity-f9e43cf9209e011dae8eb3ea8faa2cb33836af60.tar.zst
dexon-solidity-f9e43cf9209e011dae8eb3ea8faa2cb33836af60.zip
Merge pull request #2974 from ethereum/docs-abi-tight
Document packed ABI
-rw-r--r--docs/abi-spec.rst19
-rw-r--r--docs/miscellaneous.rst6
-rw-r--r--docs/units-and-global-variables.rst6
3 files changed, 25 insertions, 6 deletions
diff --git a/docs/abi-spec.rst b/docs/abi-spec.rst
index 29d98645..0361458f 100644
--- a/docs/abi-spec.rst
+++ b/docs/abi-spec.rst
@@ -442,3 +442,22 @@ would result in the JSON:
"outputs": []
}
]
+
+.. _abi_packed_mode:
+
+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
+- 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 ::
+
+ 0x0142242448656c6c6f2c20776f726c6421
+ ^^ uint1(1)
+ ^^ bytes1(0x42)
+ ^^^^ uint8(0x2424)
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^ string("Hello, world!") without a length field
diff --git a/docs/miscellaneous.rst b/docs/miscellaneous.rst
index 6d6c25ac..6c0efa9e 100644
--- a/docs/miscellaneous.rst
+++ b/docs/miscellaneous.rst
@@ -322,10 +322,10 @@ Global Variables
- ``assert(bool condition)``: abort execution and revert state changes if condition is ``false`` (use for internal error)
- ``require(bool condition)``: abort execution and revert state changes if condition is ``false`` (use for malformed input or error in external component)
- ``revert()``: abort execution and revert state changes
-- ``keccak256(...) returns (bytes32)``: compute the Ethereum-SHA-3 (Keccak-256) hash of the (tightly packed) arguments
+- ``keccak256(...) returns (bytes32)``: compute the Ethereum-SHA-3 (Keccak-256) hash of the :ref:`(tightly packed) arguments <abi_packed_mode>`
- ``sha3(...) returns (bytes32)``: an alias to ``keccak256``
-- ``sha256(...) returns (bytes32)``: compute the SHA-256 hash of the (tightly packed) arguments
-- ``ripemd160(...) returns (bytes20)``: compute the RIPEMD-160 hash of the (tightly packed) arguments
+- ``sha256(...) returns (bytes32)``: compute the SHA-256 hash of the :ref:`(tightly packed) arguments <abi_packed_mode>`
+- ``ripemd160(...) returns (bytes20)``: compute the RIPEMD-160 hash of the :ref:`(tightly packed) arguments <abi_packed_mode>`
- ``ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns (address)``: recover address associated with the public key from elliptic curve signature, return zero on error
- ``addmod(uint x, uint y, uint k) returns (uint)``: compute ``(x + y) % k`` where the addition is performed with arbitrary precision and does not wrap around at ``2**256``
- ``mulmod(uint x, uint y, uint k) returns (uint)``: compute ``(x * y) % k`` where the multiplication is performed with arbitrary precision and does not wrap around at ``2**256``
diff --git a/docs/units-and-global-variables.rst b/docs/units-and-global-variables.rst
index 887535da..7af97376 100644
--- a/docs/units-and-global-variables.rst
+++ b/docs/units-and-global-variables.rst
@@ -116,13 +116,13 @@ Mathematical and Cryptographic Functions
``mulmod(uint x, uint y, uint k) returns (uint)``:
compute ``(x * y) % k`` where the multiplication is performed with arbitrary precision and does not wrap around at ``2**256``.
``keccak256(...) returns (bytes32)``:
- compute the Ethereum-SHA-3 (Keccak-256) hash of the (tightly packed) arguments
+ compute the Ethereum-SHA-3 (Keccak-256) hash of the :ref:`(tightly packed) arguments <abi_packed_mode>`
``sha256(...) returns (bytes32)``:
- compute the SHA-256 hash of the (tightly packed) arguments
+ compute the SHA-256 hash of the :ref:`(tightly packed) arguments <abi_packed_mode>`
``sha3(...) returns (bytes32)``:
alias to ``keccak256``
``ripemd160(...) returns (bytes20)``:
- compute RIPEMD-160 hash of the (tightly packed) arguments
+ compute RIPEMD-160 hash of the :ref:`(tightly packed) arguments <abi_packed_mode>`
``ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns (address)``:
recover the address associated with the public key from elliptic curve signature or return zero on error
(`example usage <https://ethereum.stackexchange.com/q/1777/222>`_)