@abi.encodePacked
ABI non-standard packed encoding, matching Solidity's abi.encodePacked.
On-chain (@abi.encodePacked!): Live values are cut to their packed width and live string/bytes values pass through whole, at most 4 per call; the type list, arrays and tuples stay constant.
Returns: bytes
Syntax
Section titled “Syntax”@abi.encodePacked(types ...values)Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
types | string | Comma-separated Solidity types (e.g. "address,uint256") |
[...values] | any | Values to encode, one per type |
Examples
Section titled “Examples”# Pack an address and amountset $packed @abi.encodePacked("address,uint256" @me 1e18)print $packedOn-chain face (@abi.encodePacked!)
Section titled “On-chain face (@abi.encodePacked!)”Packed encoding is pure composition over byte concatenation, so the face
is one concat call: constants encode at composition time and merge into
single hex runs, each live word value is cut to its packed width through
one slice (an address to its 20 bytes, a uint64 to 8, a full-width
word passes whole), and a live string/bytes value contributes its
decoded payload raw. The type list, array and tuple values must be
constants, and at most 4 values may be live — each live part past the
first is re-resolved by every later offset. All-constant calls fold to
the plain face's exact bytes at composition.
See Also
Section titled “See Also”- @abi.encode — standard ABI encoding
- @abi.encodeCall — ABI-encode a function call
- @abi.decode — decode ABI-encoded data