0

I search a way to find and interact with the view functions of a smart contract on Elrond blockchain.

I have many questions:

  1. How to reverse a wasm smart contract file ?
  2. How to get the abi.json of a smart contract ?
  3. How to get the get/view functions of a smart contract ?
  4. How to call a get/view function of a smart contract (sample code in Javascript) ?

Like in EtherScan:

enter image description here

I'm currently reading all the documentation of Elrond Developers, so please no "RTFM" message :)

Thanks !

Trash
  • 79
  • 4

1 Answers1

1

As far as I know, there is no way to compute the ABI of a contract unless you have access to its source code.

You can reverse-engineer the WASM file of a contract to some extent:

Copy the WASM code and convert it from hex to binary (using a tool such as http://tomeko.net/online_tools/hex_to_file.php?lang=en ).
Then, download the binary file and upload it to another tool to convert WASM to WAT (such as https://webassembly.github.io/wabt/demo/wasm2wat/ )
You can then copy the resulting code in your favorite editor and look for lines that looks like this:
(func $addLiquidity (export "addLiquidity") (type $t1)
This indicates that this contract has an endpoint named "addLiquidity", though I'm not sure if you can extract more info than that.

If you have access to the ABI though, you can interact with its views and endpoints using https://www.elrond-sc.com/ , erdjs or erdpy.

Napadelis
  • 19
  • 1