I am trying to concatenate byte and uint in my project. I am using the following logic I found somewhere:

bytes data = abi.encodePacked("Gold_",Gold);

where Gold contains a uint8 number. The output of above line is: Gold_\u0004, where it should be: Gold_4

Anyone please tell me what is the issue? or Any other method that I should use to concatenate the string and uint8?

1 Answer 1


Don't know what you're trying to do (probably a better way than all this concatenation in solidity), but I'd probably convert the uint to a string and then concatenate the strings:

Uint to string methods: https://stackoverflow.com/questions/47129173/how-to-convert-uint-to-string-in-solidity

concat strings: How to concatenate strings in solidity?

  • Yes, Waited for the answer to this question and then Followed the above solution already. Accepting this Answer. Thanks! Commented Apr 11, 2022 at 6:54

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.