3

The title sums it up ;-) I'd like to move EOS tokens (say EOSDAC for example but any token will do it for my education) using the eosjs API...

I've tried to use Scatter.js and did that but it's not working:

import ScatterJS from 'scatterjs-core';

const scatter = ScatterJS.scatter;

const account = scatter.identity.accounts.find(x => x.blockchain === 'eos');
const eos = scatter.eos(network, Eos, eosOptions);
const transactionOptions = { authorization:[`${account.name}@${account.authority}`] };
var res = await eos.transfer(account.name,'testacc','100.0000 EOSDAC','', transactionOptions);

When executing that code I get the following error:

{
    "code":500,
    "message":"Internal Service Error",
    "error": {
        "code":3050003,
        "name":"eosio_assert_message_exception",
        "what":"eosio_assert_message assertion failure",
        "details":[
            {
                "message":"assertion failure with message: unable to find key",
                "file":"wasm_interface.cpp",
                "line_number":917,
                "method":"eosio_assert"
            },{
                "message":"pending console output: ",
                "file":"apply_context.cpp",
                "line_number":72,
                "method":"exec_one"
            }
        ]
    }
}

Can anybody help me figuring it out?

Many thanks in advance,

0

1 Answer 1

4

After searching the official doc and trying different approches I finally got it to work. I've used eos.transaction instead of eos.transfer and the following example is working for those interested:

var res = await eos.transaction({
    actions: [
    {
        account: "eosjackscoin", //has to be the smart contract name of the token you want to transfer - eosio for EOS or eosjackscoin for JKR for example
        name: "transfer",
        authorization: [{
            actor: account.name,
            permission: account.authority
        }
        ],
        data: {
            from: account.name,
            to: "destinationaccount",
            quantity: "50.0000 JKR",
            memo: ""
        }
    }]
});

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