0

Here is my code that attempts to do EOS transfer using eosio.token smart-contract:

import { Api, JsonRpc } from 'eosjs';
import { JsSignatureProvider } from 'eosjs/dist/eosjs-jssig.js';


const privateKey = process.env.privateKey;

const signatureProvider = new JsSignatureProvider([privateKey]); // will require modification on production
const rpc = new JsonRpc('https://eos.greymass.com');
const api = new Api({ rpc, signatureProvider });

(async () => {
  try {
    const transaction = await api.transact({
        "actions": [{
        "account": "eosio.token",
        "name": "transfer",
        "data": {
          "from": "my_account",
          "to": "my_friends_account",
          "quantity": "1.000000 USDT",
          "memo": "swap"
        },
        "authorization": [
          {
            "actor": "my_account",
            "permission": "active"
          }
        ]
      }]}, 
    {
      blocksBehind: 3,
      expireSeconds: 30,
    });
    console.log('Transaction successful:', JSON.stringify(transaction));
  } catch (e) {
    console.error('Transaction failed:', JSON.stringify(e));
  }
})();

But once i launch it i run into error:

Transaction failed: {"details":[{"message":"assertion failure with message: unable to find key","file":"cf_system.cpp","line_number":14,"method":"eosio_assert"},{"message":"eosio.token <= eosio.token::transfer pending console output:","file":"apply_context.cpp","line_number":134,"method":"exec_one"}],"json":{"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":"cf_system.cpp","line_number":14,"method":"eosio_assert"},{"message":"eosio.token <= eosio.token::transfer pending console output: ","file":"apply_context.cpp","line_number":134,"method":"exec_one"}]}}}

Getting data with RPC is working, but interactions that require signatureProvider are failing. Im running windows x64 so that might be a problem (it is a problem with cleos for example so im forced to dockerize it, but it introduces a whole much more problems like unreachable Public API Nodes and I still dont know how to get around this.

PS: Additionally i tried playing around with decimals, which did not help, i checked privateKey variable with debug and it indeed has a private key of my_account. Tested on local node, greymass, eosrio, eossweden. Every single one has the same error. Sadly cant test reachability with cleos because as said previously, cleos does not work on my OS.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.