When does the account require the eosio.code permission to do some action on its own?
I have run a contract on user1 and get the following error. Exception Details: 3090003 unsatisfied_authorization: Provided keys, permissions, and delays do not satisfy declared authorizations transaction declares authority '{"actor":"user1","permission":"owner"}', but does not have signatures for it under a provided delay of 0 ms, provided permissions [{"actor":"user1","permission":"eosio.code"}], It seems weird, and after I add the permission [email protected]. The nodeos still reported the same error.
So if you do cleos get account user1, do you see [email protected] satisfying user1@active?
Please note that [email protected] must be the satisfying permission for user1@active here, not as a child permission.
@andriantolie It worked! Thanks
@NeverLandFly How you solved this?
Solved like this
const addAuthToAccountPermission = async({
eosInstance,
accountName, permissionName,
accountAuth = null, keyAuth = null
}) => {
if (!accountName || !permissionName) throw new Error()
if (accountAuth == null && keyAuth == null) throw new Error()
const account = await eosInstance.getAccount(accountName)
const { required_auth, parent, perm_name } = account.permissions
.find(p => p.perm_name === permissionName)
let update_auth = {
accounts: [],
keys: []
}
if (typeof accountAuth === 'object') {
update_auth.accounts.push({
permission: accountAuth,
weight: 1
})
}
if (typeof keyAuth === 'string') {
update_auth.keys.push({
key: keyAuth,
weight: 1
})
}
const transaction = await eosInstance.transaction(tx => {
tx.updateauth({
account: accountName,
permission: perm_name,
parent: parent,
auth: {
threshold: required_auth.threshold,
waits: required_auth.waits,
accounts: [
...required_auth.accounts,
...update_auth.accounts
],
keys: [
...required_auth.keys,
...update_auth.keys
]
}
}, { authorization: `${accountName}@active` })
})
return transaction
}
@7flash nice solution!