2

I'm looking for a way to get the latest transaction recorded on a particular account. For example, I'm trying to get the latest transaction for "newdexpocket", how can I do that using nodejs?

Here's my code so far (-1 for pos isn't working, unfortunately):

const Eos = require('eosjs');

// Connect to a testnet or mainnet
const chain = {
    main: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906', // main network
    jungle: '038f4b0fc8ff18a4f0842a8f0564611f6e96e8535901dd45e43ac8691a1c4dca', // jungle testnet
    sys: 'cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f' // local developer
};

const config = {
    expireInSeconds: 60,
    broadcast: true,
    verbose: false,
    sign: true,
    debug: false,
    httpEndpoint: 'https://api.eosnewyork.io',
    chainId: chain.main,
    //keyProvider: ['PrivateKeys...'], // WIF string or array of keys.. 
};

//const eos = Eos(config);
const eos = Eos(config);

eos.getActions("newdexpocket", 100000, 100).then(result => {
    console.log(result);
}).catch(error => {
    console.error(error)
});
2
  • Can you add a link to the documentation or source for this method? If you're referring to the history plugin, I think it is being deprecated and other methods will better suite your needs.
    – Ami Heines
    Commented Nov 15, 2018 at 10:00
  • Thanks for your answer, I did some research on my side as well and you're right, the plugin is being deprecated so I'll have to follow your advise and seek for alternative elsewhere ;-) Just in case, would you happen to know what's suppose to replace the history_plugin?
    – Linda
    Commented Nov 15, 2018 at 13:09

2 Answers 2

1

This may have change since you asked this question, however -1 for pos should work as expected.

Example using curl to get most recent action for newdexpocket:

curl --request POST --url https://nodes.get-scatter.com:443/v1/history/get_actions --header 'content-type: application/json' --data '{"pos":"-1","offset":"-1","account_name":"newdexpocket"}'

0

Demux is not a replacement for the history plugin but the right tool for this use case. Look for the demux example.

Your Answer

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

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