Decode calldata & return values for ContractCreateTx & ContractCallTx using the aepp-sdk-js


for visualizing that within I am currently trying to figure out how to decode this data after the transaction happend, assuming I am not involved in the transaction.

What information is necessary to decode all of the data and how can this be achieved using the aepp-sdk-js?

Example (TESTNET)


  • ct_2fi1isHPF8mzAzZvGEuFs8TYFLNutbqHuyKRLpCjg75oQknGuD


  • tx-hash
    • th_2onEA5Tq15ZYSLog13G1S84HDEf2LqE8JKCrXHgdU7v3e1KJSZ
  • calldata
    • cb_KxFE1kQfP4oEp9E=
  • code
  • ABI version
    • 3
  • VM version
    • 5


  • tx-hash
    • th_3kqL4vWNXYLjPN7hu5YtdsiKRJSRCxJyF5znrLUWjkreghrM2
  • calldata
    • cb_KxGzmcNWKwlIaZ8AoNGhJM4ZHvCOjS2Pv0JFBAE8m4quzsb3F4Xy7iDd86aIGyw4eg==
  • ABI version
    • 3
  • returnValue
    • unknown (how can I retrieve the return value???)

I would appreciate if anybody can help here. Maybe @nduchak.chain and @hanssv.chain can help me? :smiley:

  • is the information I listed above enough the be able to decode the calldata?
  • how can I obtain the returnValue of a ContractCallTx?

As we are using the middleware I know that there is an endpoint that returns a bit more information about the ContractCallTxs for a certain contract. This can for this specific case be retrieved by using the following endpoint:

However, this information currently cannot be retrieved for one specific contract call and additionally there is no possiblity to get the decoded value for the calldata of the ContractCreateTx. That is why I need a way to be able to decode this data by using the aepp-sdk-js or any other client-side library.



I’ve still never used the JS-SDK for anything non-trivial so I don’t know what can and can not be done there.

There are two APIs for decoding calldata in the HTTP compiler either you need the calldata + contract bytecode or calldata + contract source code in the first case you will get VM-types, but for FATE that is often good enough. The problematic part is user defined (datatype) types. In the second case you will get Sophia types.

1 Like

thanks for the input. in the scenario I am talking about I only know the bytecode in most cases. I will check that and also perform some tests with custom datatypes.

still the question remains how to get the return value for a ContractCallTx. how can I get that with the information mentioned above?

I’m not too familiar with middleware/aeternal @karol.chain might know?

The plain node has an endpoint for getting the call result /transactions/{hash}/info

1 Like

:+1:t2: that should be sufficient

I think for the aepp-sdk-js this is the right place to look at. just if anyone else is trying to achieve the same:

1 Like

New MDW is returning decoded arguments and return value, but old MDW is doing that as well. (at least for ContractCallTx)…

yes but the old/current middleware only returns the decoded values on an endpoint that returns all ContractCallTx of a certain contract.

currently it’s not possible to get the decoded values for a specific transaction. this is at least what I observed when analyzing it.

good to hear that this will be the case in the new middleware :slight_smile:

Hey @marc0olo, so basically you need this two compiler API:

Contract call result can be retrieved using “GetTransactionInfoByHash” Node API

1 Like