I need to be able to convert a name/account_name to a string for some processing in my smart contract. I have found and used the string_to_name function for converting in the other direction, but cannot find an equivalent to the name_to_string function. I saw a reference to name having a to_string() method, but the compiler disagreed with its existence and threw errors.

What function is available to perform this conversion?

1 Answer 1


Use the name struct. 'name' is defined in types.hpp.

For example, if you have the variable user of type account_name, you can print the user as follows:

auto n = name{user};
print("Hello, ", n);

std::string str = n.to_string();
  • I tried this, and was told by the compiler that name didn't have a to_string method on it. Jun 21, 2018 at 15:42
  • 1
    Discovered that the source code for the type.hpp file that was being included was out of date. Updated to the most recent version of the header and things work now. Jun 21, 2018 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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