The smart contract takes a string as an input for the public key. I need to convert it into a public key object within the contract.
1 Answer
You would do it as follows:
eosio::public_key string_to_public_key(unsigned int const key_type, std::string const & public_key_str)
{
eosio::public_key public_key;
public_key.type = key_type; // Could be K1 or R1 enum
for(int i = 0; i < 33; ++i)
{
public_key.data.at(i) = public_key_str.at(i);
}
return public_key;
}