1

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))
        }
4
  • Change bytes bys to bytes memory bys. Mar 14, 2019 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)); Mar 14, 2019 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)); Mar 14, 2019 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!!! Mar 14, 2019 at 8:16

2 Answers 2

2

It needs to be

function bytesToAddress(bytes memory bys) ...

Hope it helps.

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); 

Your Answer

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

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