I am trying to write a smart contract that changes the keys of an account (not itself). The transaction will be of course be authorized by the account for which the keys are changing.

I feel like it should look something like this:

       ("account", "myaccount")
       ("permission", "owner")
       ("parent", "")
       ("auth",  authority("EOS8djkstZzKVY7BsWkT3CMQjngXMSgtoM2g3VAS65wZw1JLC4fML", 1)).send();
  • It' possible, but take care your public key should not be string
    – Jimmy Guo
    Aug 3, 2018 at 4:48
  • Have you been able to include fc and use variant in your contract code? It seems they're not made to be used inside contracts Aug 3, 2018 at 18:59
  • No, I have not. I think you are correct. I saw it being used in the unit tests so I was trying to use it here. I'm sure there's a way to build it with some object. Maybe make_tuple()
    – Max
    Aug 3, 2018 at 19:12
  • @Max do you know if this action can be performed outside of cleos? Were you able to get it working? Oct 9, 2018 at 18:58

1 Answer 1


Yes, it is possible.

The action is in native.hpp in the eosio.system contract from eosio.cdt repository:

     void updateauth(  ignore<name>  account,
                       ignore<name>  permission,
                       ignore<name>  parent,
                       ignore<authority> auth ) {}

You would use it like this:

struct authority {
  uint32_t                                           threshold = 0;
  std::vector<eosiosystem::key_weight>               keys;
  std::vector<eosiosystem::permission_level_weight>  accounts;
  std::vector<eosiosystem::wait_weight>              waits;

  EOSLIB_SERIALIZE( authority, (threshold)(keys)(accounts)(waits) )

// Create the authority type for auth argument of updateauth action
authority newauth;
newauth.threshold = threshold;
eosio::permission_level permission(eosio::name("account_name"), eosio::name("account_permission"));
eosiosystem::permission_level_weight accountpermission{permission, weight};

// Send off the action to updateauth
eosio::action(eosio::permission_level(get_self(), eosio::name("active")), eosio::name("eosio"), eosio::name("updateauth"), std::tuple(eosio::name("account_name"), eosio::name("permission_name"), eosio::name("parent_name"), newauth) ).send();

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.