I'd like to declare a string value more than 20 bytes in Solidity. I use address type, but it only contains 20bytes. Could you tell me how to solve the problem?


There are bytes and string types. See Solidity docs:

Dynamically-sized byte array, see Arrays. Not a value-type!
Dynamically-sized UTF8-encoded string, see Arrays. Not a value-type!

As a rule of thumb, use bytes for arbitrary-length raw byte data and string for arbitrary-length string (utf-8) data. If you can limit the length to a certain number of bytes, always use one of bytes1 to bytes32 because they are much cheaper.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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