1

I know how to do the other way round but don't know how to convert from name to account_name unless I convert it to string first. Please help. Thanks.

2

Name structure contains "account_name value" attribute. Look at "eosiolib\types.hpp"

account_name is just uint64_t; (eosiolib\types.h)

So you can:

account_name a = N("accname"); //eq of string_to_name(..)
name n = name {a};
a = n;
string accname = n.to_string();

Look at hello\hello.cpp for example.

| improve this answer | |
1

Maybe this code can be useful:

account_name eosio_name = eosio::string_to_name(user); // convert to EOSIO name from variable

Where user is: std::string user.

This is basically a method to convert an std::string to uint64_t.

| improve this answer | |

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.