2

I have the follow from using const tx = api.deserializeTransaction(body.packed_trx);.

{
  "expiration": "1970-07-18T18:12:21.000",
  "ref_block_num": 1544,
  "ref_block_prefix": 84344837,
  "max_net_usage_words": 0,
  "max_cpu_usage_ms": 0,
  "delay_sec": 2,
  "context_free_actions": [],
  "actions": [
    {
      "account": "......k4..4",
      "name": "...k",
      "authorization": [],
      "data": ""
    },
    {
      "account": "",
      "name": ".....1c5..1k",
      "authorization": [],
      "data": ""
    }
  ],
  "transaction_extensions": []
}

I would like to derive the human readable action name from "name": ".....1c5..1k",. Ideally with eosjs.

1
  • Should eos-js not do this automatically when deserializing? – cmadh Oct 14 '20 at 16:11
2

The deserializeTransaction call should return the correct data already. It seems like it's trying to deserialize a transaction from a wrong transaction buffer. The expiration date and other fields don't make sense either. Make sure to parse it as an Uint8Array first. If body.packed_trx is a hex string, you can use this:

const txHex = body.packed_trx
const txBytes = new Uint8Array(Buffer.from(txHex, `hex`))
const deserializedTx = api.deserializeTransaction(txBytes);
console.log(`DESERIALIZED TX`, deserializedTx);

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.