In a smart contract where the token name and symbol are defined, is unicode supported or should these be ASCII only characters?

As below, would it be a valid contract or token symbol?

    constructor() public
    ERC721("✕ray Ýour ℤen", "✕Ýℤ")  

3 Answers 3


As mentioned by Linum Labs, that approach can be used for Solidity v 0.7 and higher. If you want to use an older version,

From docs:

\uNNNN (Unicode escape)

You will need to convert Unicode character to escape sequence, for example:

✕ray Ýour ℤen

will be

\u2715ray \u00ddour \u2124en

And Important NOTE from docs:

Any Unicode line terminator which is not a newline (i.e. LF, VF, FF, CR, NEL, LS, PS) is considered to terminate the string literal. Newline only terminates the string literal if it is not preceded by a \.



Just as a quick note, you mention "smart contracts" in the question, but give code that looks like Solidity, and also have a Solidity tag in your question, so I assume that the question's focus is Solidity. Different languages may handle Unicode differently, so the answer can change from language to language.

Solidity (v0.7 and higher)

(see hack3r_0m's answer for older versions of Solidity)

From the docs:

While regular string literals can only contain ASCII, Unicode literals – prefixed with the keyword unicode – can contain any valid UTF-8 sequence. They also support the very same escape sequences as regular string literals.

string memory a = unicode"Hello 😃";

This means the code as provided in the question would not work (regular strings are ASCII-encoded), but that by prefacing the string with unicode, it should work.


In Python 3.x the built-in string type uses utf-8 encoding. As such, our assumption is that Unicode characters should be natively supported in strings. Remix seems to be down for us at the moment, so we don't have a simple way to test this at the moment.


Nope, write (unicode"✕ray Ýour ℤen",unicode"✕Ýℤ"). e.g.

ERC721(unicode"✕ray Ýour ℤen", unicode"✕Ýℤ"){

actully openzeppelin is updated, now code will look like:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";

contract RayYourEn is ERC721 {
    constructor() ERC721(unicode"✕ray Ýour ℤen", unicode"✕Ýℤ") {}

    function _baseURI() internal pure override returns (string memory) {
        return "https://foo.foo";

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.