Should I analyze all the blocks or are there some methods in the eosjs
library?
3 Answers
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)
})
-
These actions are only system action of eosio, but not all contract actions. 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
Of course,
eosjs
provides methodgetActions
. 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);
You can send direct request to some API like this
-
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