1
async function sendEos (sender, receiver ) {
 try{
const result = await api.transact({
    actions: [{
      account: 'eosio.token',      //'eosio.token',
      name: 'transfer',                //'transfer',
      authorization: [{
        actor: sender, //'useraaaaaaaa',
        permission: 'active',
      }],
      data: {
        from: sender,
        to: receiver,
        quantity: '1 EOS',
        memo: '',
      },
    }]
  }, {
    blocksBehind: 3,
    expireSeconds: 30,
  });
  console.dir(result);
}catch (e) {
console.log('\nCaught exception: ' + e);
if (e instanceof RpcError)
  console.log(JSON.stringify(e.json, null, 2))}};

Getting error:

Caught exception: Error: assertion failure with message: symbol precision mismatch (node:12620) UnhandledPromiseRejectionWarning: ReferenceError: RpcError is not defined
at sendEos (E:\EOSIO\transactEos.js:45:22)
at process._tickCallback (internal/process/next_tick.js:68:7)

What fields do I need to change? I hope someone can guide me. Thanks in advance!

0

The EOS precision you have provided here is 1 EOS and that is your error. The typical precision is 1.0000 EOS. If you also want your transaction to be signed and broadcasted to the network:

async function sendEos (sender, receiver ) {
 try{
const result = await api.transact({
    actions: [{
      account: 'eosio.token',      //'eosio.token',
      name: 'transfer',                //'transfer',
      authorization: [{
        actor: sender, //'useraaaaaaaa',
        permission: 'active',
      }],
      data: {
        from: sender,
        to: receiver,
        quantity: '1.0000 EOS',
        memo: '',
      },
    }]
  }, {
    sign: true,
    broadcast: true,
    keyProvider: 'Your private key here',
    blocksBehind: 3,
    expireSeconds: 30,
  });
  console.dir(result);
}catch (e) {
console.log('\nCaught exception: ' + e);
if (e instanceof RpcError)
  console.log(JSON.stringify(e.json, null, 2))}};
| improve this answer | |
  • Thank you. Do I need to do anything else for transaction to be broadcasted to the network? – AditiB Dec 12 '19 at 14:43
  • Nope, you don't need to – Lubo Kirov Dec 12 '19 at 15:47

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.