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?


2 Answers 2


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.


It means that now you need to change your code to:

uint256 _unixTimestamp;
uint256 _timeExpired;

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.