In the following example:


should we pad the parameters values to 32 bytes? Because I have seen code like

if (!addressOfA.call(bytes4(keccak256("f1(bool,uint256)")), true, 3)) {

but according to the ABI specification, "true" and "3" should be padded, where clearly in the example are not.

  • 1
    There should be no space between your parameter values in the string that you hash: keccak256("f1(bool,uint256)") instead of keccak256("f1(bool, uint256)") – SCBuergel.eth Feb 11 '18 at 15:42
  • Thanks for pointing it out. But this is a minor detail. The question is still open. – Alejandro Muñoz Feb 11 '18 at 16:26

The padding is not needed, from the solidity documentation:

  • call, callcode and delegatecall

Furthermore, to interface with contracts that do not adhere to the ABI, the function call is provided which takes an arbitrary number of arguments of any type. These arguments are padded to 32 bytes and concatenated. One exception is the case where the first argument is encoded to exactly four bytes. In this case, it is not padded to allow the use of function signatures here

| improve this answer | |
  • Didn't read that part in the documentation. Thanks – Alejandro Muñoz Feb 13 '18 at 18:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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