I was using remix for basic solidity. Can someone explain if I'm using string.concat() why is it giving that error even if both types are string.
I tried the Docs as well but it gives the same error.
from solidity:
TypeError: Type bytes memory is not implicitly convertible to expected type string memory.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract test{
function hi(string memory name) pure public returns(string memory){
string memory greetings = string.concat("Hello", name);
return greetings;
}
}
Best Answer
The
string.concat
function was 'fixed' to take and return strings in solidity v0.8.12, so you should change thepragma solidity ^0.8.0
topragma solidity ^0.8.12
, for example: