I have two addresses, _token1 and _token2. I would like to pack them into bytes data to pass it to a function.
bytes memory params = abi.encode(_token1, _token2);
The obtained params
is the concatenation of zero-padded data.
This can be decoded in a different function like this:
(address token1, address token2) = abi.decode(params, (address, address));
Since one address is 20 bytes, which is smaller than 32 bytes, we can get a short bytes by abi.encodePacked(_token1, _token2)
. My question is how can I decode this encodePacked
data?