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 Answers 2

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.

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.

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.