4

Should I analyze all the blocks or are there some methods in the eosjs library?

1
  • you should start your own node, and set the history plugin to filter your action
    – Jimmy Guo
    Commented Jul 12, 2018 at 2:48

3 Answers 3

3

You can simply request a node to give you the action history of an account.

Using cleos:

cleos --url https://api1.eosdublin.io get actions <EOS account name>

Using eosjs:

const eosjs = require("eosjs")
const eos = eosjs({
  httpEndpoint: 'https://api1.eosdublin.io',
  chainId: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906'
})

async function main() {
  const actions = (await eos.getActions('<EOS account name>')).actions
  console.log(actions.map(a => a.action_trace))
}

main().catch(error => {
  console.error(error)
  process.exit(1)
})
4
  • These actions are only system action of eosio, but not all contract actions.
    – Jimmy Guo
    Commented Jul 14, 2018 at 3:01
  • @Andres : I am facing the error like rror TypeError: eosjs is not a function Commented Jul 1, 2020 at 12:53
  • @Andres : I tied with terminal "cleos get actions bob" it will give response, may I know what is actual problem Commented Jul 1, 2020 at 13:09
  • @Codebrekers this answer was written using version 16.0.9 of eosjs. Nowadays, with eosjs v20.0.0, the API is different. You should check the documentation here: developers.eos.io/manuals/eosjs/latest/index Commented Jul 3, 2020 at 20:28
3
  1. Of course, eosjs provides method getActions. Here's an example:

    const Eos = require('eosjs');
    const api = new Eos({
        httpEndpoint: 'https://eos.greymass.com',
        chainId: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906',
    });
    api.getActions('wangruixiwww').then(console.log);
    
  2. You can send direct request to some API like this

    https://eospark.com/api/account/wangruixiwww/actions?action_type=token&show_trx_small=0&show_trx_in=1&show_trx_out=1&page=1&size=50

2
  • Nice suggestion, but you would depend on a centralized source instead of being able to query it from any node on the network. Commented Jul 14, 2018 at 0:17
  • @oxfn: it will give error like TypeError: Eos is not a constructor Commented Jul 1, 2020 at 13:06
0

You can try another node: cleos -u https://api.eosnewyork.io get actions

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.