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?

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.

| improve this answer | |
  • 2
    Thanks for the fantastic answer! It's precise and detailed. – Fu Song Jul 12 '18 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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