Skip to main content
1 of 2
Ismael
  • 30.3k
  • 23
  • 54
  • 97

It fails because the compiler is looking for the concat function as a member of bytes type.

You can use concat as a regular function

return string(concat(bytes(api0xUrl),
                     concat(bytes(sellStr), 
                            ...)));

Another alternative is move concat to a library and use the using for mechanism.

library L {
    function concat(bytes memory a, bytes memory b) internal pure returns (bytes memory) {
        return abi.encodePacked(a, b);
    }
}

contract Swaper0x {
    using L for bytes;  // X.concat(Y) => concat(X, Y)

Now it should work as expected

return string(bytes(api0xUrl) // ---> error starts here
        .concat(bytes(sellStr))
Ismael
  • 30.3k
  • 23
  • 54
  • 97