Using cleos, we can set the permissions like this:

cleos set account permission <your-account> active '{"threshold": 1,"keys": [{"key": "<your-key>","weight": 1}],"accounts": [{"permission":{"actor":<contract-account>,"permission":"eosio.code"},"weight":1}]}' owner -p <your-account>

But can we do the above operation using eosjs?

2 Answers 2


Basically, pull the existing permission, change only what you need to change, then pass everything back to updateauth ..

async function getNewPermissions(accountName) {
  const account = await eos.getAccount(accountName)
  const perms = JSON.parse(JSON.stringify(account.permissions))
  return perms

const perms = await getNewPermissions(accountName)
console.log('New permissions =>', JSON.stringify(perms))
const updateAuthResult = await eos.transaction(tr => {

      for(const perm of perms) {

             account: accountName,
             permission: perm.perm_name,
             parent: perm.parent,
             auth: perm.required_auth
         }, {authorization: `${accountName}@owner`})


console.log('Success =>', JSON.stringify(updateAuthResult));

I hope this will help. Thank You.


In https://github.com/LimeChain/eoslime (uses eosjs behind the scene) there is a addPermission method, which you can use in order to accomplish your aim. It will add a permission for example eosio.code to your active authority.

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.