I need to concatenate two strings in Solidity. I'm having problem with below code. I reveive message error:

Member "concat" not found or not visible after argument-dependent lookup in type(bytes storage pointer).

// SPDX-License-Identifier: MIT

pragma solidity ^0.4.0;

contract C {
    bytes s = "Storage";

    function f() public view {
        bytes memory a = bytes.concat(s, "Lit");

What's wrong with that code?

  • bytes.concat(s, "Lit") works from upper version of solidity ie. 0.8.11.
    – Wojtek
    Jan 30, 2022 at 15:36

1 Answer 1


This is because solidity doesn't have concat() method. Not sure why you assumed it, but please do check out docs or examples before using other languages' syntaxes.

The right way to do it would be as follows

bytes memory a = abi.encodePacked(s, "Lit");
  • 1
    Yes, I know that abi.encodePacked(s, "Lit") should work, but codewars doesn't compile it so after short research I'v found bytes.concat in solidity documentation examples and wanted to use it exacly the same. It look like it's available from Solidity v. ~0.8.11 thats the reason why my code hadn't worked. Thanks for help.
    – Wojtek
    Jan 30, 2022 at 15:32
  • I'm sorry about my comments. I really wasn't aware of the 0.8.11 update and wrongly assumed that you were trying to use javascript syntax like seen often on this site. My bad. Thanks for surfacing this new feature!
    – pbsh
    Jan 30, 2022 at 17:56
  • NP. Your answer was helpful to make deeper reserach in documentation. Thanks to it I discoverd the reason why I couldn't compile the example. ;)
    – Wojtek
    Jan 31, 2022 at 1:25

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.