0

I found out, that I can pass different data types (as argument), even if the Solidity method takes only uint data type, why is that possible?

Example:

function test (uint _param) public {
   //do smth
}
test(address(ADDRESS_VAR))

1 Answer 1

1

There is no data type in the calldata. They are all coded as hexadecimal. So if you pass to the contract an address like this: 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, EVM thinks, "ok, there is no problem. It is a number". Because you can convert it to uint: 697323163401596485410334513241460920685086001293.

2
  • 1
    Thanks, I was asking this because I found out that I can maliciously modify state variables of a contract using a delegate call, even when it's a different type than what the function wants. This helped a lot, thanks!!
    – David
    Commented Jun 2, 2022 at 20:35
  • You're welcome! You are right, this method gives facilities in the delegatecall attacks. Because of that, anyone who uses delegatecall, he has to know what he is doing. Commented Jun 3, 2022 at 7:22

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.