0

Contract fail to compile in IDE Remix.due to the following error:

TypeError: Data location must be "storage" or "memory" for parameter in function, but none was given.

version:0.5.6+commit.b259423e

I have no idea why this happened and i have not found any sufficient information on how i can fix it and was hoping you can help me. Thank you in Advance.

The error points to this function:

function bytesToAddress(bytes bys) pure private returns(address addr) {
        assembly {
            addr := mload(add(bys, 20))
        }
  • Change bytes bys to bytes memory bys. – goodvibration Mar 14 at 7:43
  • Thanks..that fix it but now points to the following: TypeError: "send" and "transfers" are only available for objects of type "address payable", not "address" The error poins to this line: msg.sender.transfer(amount); contractfunds.transfer(msg.value.mul(DEVWORK).div(1)); – fortza italia Mar 14 at 7:54
  • Thanks..that fix it but now points to the following: TypeError: "send" and "transfers" are only available for objects of type "address payable", not "address" The error poins to this line: msg.sender.transfer(amount); contractfunds.transfer(msg.value.mul(DEVWORK).div(1)); – fortza italia Mar 14 at 7:59
  • There are no send or transfer or msg.sender.transfer(amount); contractfunds.transfer(msg.value.mul(DEVWORK).div(1)) in your question!!! – goodvibration Mar 14 at 8:16
0

I think you need to specify them as addresses.

https://ethereum.stackexchange.com/a/65609/52189

I had a piece of code that had to change from :

user_address.transfer(this.balance); 

to in 0.5.0 solidity:

address(uint160(user_address)).transfer(address(this).balance); 
0

It needs to be

function bytesToAddress(bytes memory bys) ...

Hope it helps.

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.