2

Suppose A sent a transaction to SC(smart contract), including structured data, for example:

{"intention":"like","target":"ae16xx0...."}

As usual, this transaction will be stored on all nodes in the network. Then, for some node X, how to get and deserialize this {"intention":"like","target":"ae16xx0...."},and make use of the data?

1 Answer 1

2

Yes there is. You can get this data from nodes that are running with the history_plugin plugin. You could use the HTTP API directly as in /v1/history/get_transaction, or you could use cleos:

cleos --url https://api1.eosdublin.io get transaction <Transaction ID>

You could also use eosjs:

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

async function main() {
  const transaction = await eos.getTransaction('<Transaction ID>')
  console.log(transaction)
}

main().catch(error => {
  console.error(error)
  process.exit(1)
})

You then just need to inspect the data that is returned and you will find the actions executed in the transaction and their respective parameter data.

1
  • 2
    Thanks for the fantastic answer! It's precise and detailed.
    – Fu Song
    Commented Jul 12, 2018 at 16:14

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.