1

I am trying to send tokens from one account to another using eosjs & reactjs with the standard eosio.token contract but I have issues with the authority. Can someone please explain the meaning of the error message and share some resources on how authorities are used in EOS? I have tried reading the official documentation but I am still struggling to solve the issue.

Reacjs function:

static async tranfsferTokens (accountFrom, accountTo, quantity) {

try {
  (async () => { 
    console.log("Async func get_info");
    const resp = await api.transact({
    actions: [{
        account: 'eosio.token',
        name: 'transfer',
        authorization: [{
            actor: accountFrom,
            permission: 'active',
        }],
        data: {
            from: accountFrom,
            to: accountTo,
            quantity: quantity,
            memo: '',
        },
    }]
  }, {
    signatures: [signatureProvider],
    blocksBehind: 3,
    expireSeconds: 30,
  });
  pre.textContent += '\n\nTransaction pushed!\n\n' + JSON.stringify(resp, null, 2);
})();
} catch (e) {
  pre.textContent = '\nCaught exception: ' + e;
  if (e instanceof eosjs_jsonrpc.RpcError)
    pre.textContent += '\n\n' + JSON.stringify(e.json, null, 2);
}

}

Function call:

EosApiService.tranfsferTokens('alice', 'bob', '25 SYS');

Error message:

eosjs-rpcerror.js:26 Uncaught (in promise) Error: transaction declares authority '{"actor":"alice","permission":"active"}', but does not have signatures for it.
at new RpcError (eosjs-rpcerror.js:26)
at JsonRpc.eval (eosjs-jsonrpc.js:118)
at step (eosjs-jsonrpc.js:36)
at Object.eval [as next] (eosjs-jsonrpc.js:17)
at fulfilled (eosjs-jsonrpc.js:8)
  • You probably don't provide the necessary keys for alice via the signatureprovider. Also you probably don't want to send SYS and instead EOS. In any case alice and bob need to be created on your local chain and you need the keys for alice account to sign the transaction. – cmadh Jun 11 '19 at 2:50
  • 1
    Well actually I was doing everything of the above, but the problem was that I was providing only the owner key of alice. I added the active key also and it worked. – Viktor Gagaleski Jun 11 '19 at 19:56
0

I think the actor is wrong

have a look at this example

let transferAction = (async () => { const result = await api.transact( { actions: [ { account: "eosio.token", name: "transfer", authorization: [ { actor: "useraaaaaaaa", permission: "active" } ], data: { from: "useraaaaaaaa", to: "useraaaaaaab", quantity: "0.0001 SYS", memo: "" } } ] }, { blocksBehind: 3, expireSeconds: 30 } ); console.dir(result); })();

this is a transfer from "useraaaaaaaa" to "useraaaaaaab"

you are transfering from "accountFrom" to "accountTo" people who do not exist with no specification on amount and other things

| improve this answer | |
  • I think that I am doing the same as explained, userFrom is alice, and userTo is bob same as useraaaaaaaa and useraaaaaaab. Am I missing something in your answer :) ? – Viktor Gagaleski Jun 10 '19 at 21:29
  • I think he left the signatures: [signatureProvider], out. – TeeAttack42 Jun 11 '19 at 15:06
  • 1
    @TeeAttack42 you pointed in the right direction, thank you. The problem was that I was providing the owner key of alice, and because I have owner and active private keys I had to use the active key and it worked. Additionally, I had to add 25.0000 because I was getting precision error. – Viktor Gagaleski Jun 11 '19 at 20:03
0

I was getting the same error.

You need to set the keyProvider while initializing EOS with the private key for the fromAccount.

Multiple ways you can do this but I would suggest the way by setting JsSignatureProvider.

Another simple way you can use is by using the config Javascript Object with the options for Eos and setting it's key provider like so,

config.keyProvider = privateKey

eos = Eos(config).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.