Solidity ABI – Understanding ‘Warning: This Function Only Accepts a Single “bytes” Argument’

abisolidity

In this question the OP is running into a warning upon using the keccak256 function in Solidity:

Warning: This function only accepts a single "bytes" argument. Please use "abi.encodePacked(…)" or a similar function to encode the data.

uint256 _unixTimestamp;
uint256 _timeExpired;

bytes32 output = keccak256(msg.sender, _unixTimestamp, _timeExpired);

What is the rationale behind this error – why do I need to use abi.encodePacked and what does it do in comparison to using it just like shown above?

Best Answer

Prior to Solidity 0.5.0, both functioned the same way. The warning is part of the process of deprecating the variable-argument versions of keccak256 and other hash functions.

As of Solidity 0.5.0, sha3 has been removed. See https://github.com/ethereum/solidity/issues/3955 for details.