1

I've been struggling with that for a couple days and I'm crawling out for help now ;-) I've been using eosjs to parse the Actions of an account but all I can see are the transactions created by the account, not the one it received. How can I get the eos.getActions("accountname", pos, offset) to work on incoming transactions as well?

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)
});

1 Answer 1

1

eos.getActions() is actually a wrapper of /history/get_actions RPC API which is provided by the history_api_plugin of nodeos. For this API endpoint, account_name is the name of the account who signed and sent/was sent to this transaction. However, the majority of public eosio full nodes do not provide this data as it will cost huge amount of their RAM and other computing resources.

https://developers.eos.io/eosio-nodeos/reference#get_actions-1

While I was doing experiments, https://eosbp.atticlab.net is one of the rare BP API endpoints who provided this data. Full nodes need to set filter-on in config.ini in order to retain and provide this data. Nowadays very few BPs do so.

In your case, you are recommended to utilize mongodb for query purposes. You can checkout the mongo_db_plugin for nodeos. (https://developers.eos.io/eosio-nodeos/docs/mongo_db_plugin)

With mongo_db_plugin, you can save all the action data into your mongodb instance and query anyway you like in mongodb. E.g. actions are saved in the action_traces mongo collection.

db.action_traces.find({'act.account': 'newdexpocket', 'act.authorization.actor': 'newdexpocket'})

For better query performance, please add index for 'act.account' and 'act.authorization.actor'.

db.action_traces.createIndexes([{'act.authorization.actor': 1}, {'act.account': 1}], {background: true})

Btw, history_api_plugin is deprecated since eosio v1.2.0 and may be removed in the future. You should consider starting your migration before it's too late.

7
  • Hi, many thanks for your answer it's super helpful. Can you ELI5 how to use the mango_db_plugin? I'm not sure I'm following that bit.The documentation does speak about using Mongo and I'm a bit familliar with it but how do I connect the mongo db with eos? Are there public mongo collections on BP endpoints or should I run a local node? Where's the connection point here? I've read the doc but something is missing or I don't understand the full logic, I get it that the plugin is an eosio plugin but how do I use that with NODEJs for example? Thanks in advance for your help ;-)
    – Linda
    Commented Nov 14, 2018 at 20:50
  • Hi @Linda! You will need to have a full node of eos and set it up with mongo_db_plugin. It's currently not a super easy task to get done. You can check this repo out: github.com/EOS-BP-Developers/eosio-mongodb-queries
    – Tong Shen
    Commented Nov 14, 2018 at 23:37
  • @Linda And for setting up nodeos, please follow these documentations: 1. Get the eosio code: developers.eos.io/eosio-nodeos/docs/getting-the-code ; 2. Build eosio: developers.eos.io/eosio-nodeos/docs/autobuild-script ; 3. Set it up as non-producing node: developers.eos.io/eosio-nodeos/docs/configuration-file developers.eos.io/eosio-nodeos/docs/…
    – Tong Shen
    Commented Nov 14, 2018 at 23:41
  • @Linda And please remember, the mongodb instance may take over 400GB of disk space if you enable only action_traces collection, or over 1TB if you enable all collections. The syncing process may take days to catch up, or you can download the full data snapshot of the blockchain from eosnode.tools/blocks and replay.
    – Tong Shen
    Commented Nov 14, 2018 at 23:50
  • @Linda In the meantime, you can try the API provided by atticlab eosbp.atticlab.net . It has the actions data.
    – Tong Shen
    Commented Nov 15, 2018 at 4:52

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.