How to push transaction EOS Blockchain (eosjs - unsatisfied_authorization)?

537 Views Asked by At

I use Anchor Wallet.

This is init code

const privateKeys = ["myprivatekey"];

const signatureProvider = new JsSignatureProvider(privateKeys);
const rpc = new JsonRpc(config.mainnet, { fetch });
const api = new Api({ rpc, signatureProvider, textDecoder: new TextDecoder(), textEncoder: new TextEncoder() });

return {rpc, api};

Then i try to push transaction

    const transaction = await api.transact({
   actions: [{
     account: 'eosio',
     name: 'buyrambytes',
     authorization: [{
       actor: 'username',
       permission: 'active',
     }],
     data: {
       payer: 'username',
       receiver: 'username',
       bytes: 8192,
     },
   }]
  }, {
   blocksBehind: 3,
   expireSeconds: 30,
  });

(docs example)

and receive error

details: [
    {
      message: `transaction declares authority '{"actor":"username","permission":"active"}', but does not have signatures for it.`,
      file: 'authorization_manager.cpp',
      line_number: 643,
      method: 'get_required_keys'
    }
  ],
  json: {
    code: 401,
    message: 'UnAuthorized',
    error: {
      code: 3090003,
      name: 'unsatisfied_authorization',
      what: 'Provided keys, permissions, and delays do not satisfy declared authorizations',
      details: [Array]
    }
  }
}

Maybe i enter wrong private key (Anchor -> Export private key -> Copy key) or something else, idk.

All other functions (for exampe get_block etc.) works fine

1

There are 1 best solutions below

0
tanzim On

try with owner:

    authorization: [{
       actor: 'username',
       permission: 'owner',
     }],