Module show --out outputs in binary

I’m trying to read the source code of deployed modules on mainnet, using concordium-client module show 0c075b20d46db5c44e30afda431e5ebd637e71794a6f43b5d18f7337cf54b53c --out source.txt, however the output seems to be binary? Is there a flag to output non-binary? Or another method to read this?

The output of module show is a binary file that consists of 8 bytes of header (4 bytes version, 4 bytes length) followed by the binary wasm code. To convert this into a readable format, first strip the first 8 bytes of the file (e.g. using a simple text editor). Then you can use one of the tools in the WebAssembly Binary Toolkit to convert it to a readable format. wasm2wat will convert it into WebAssembly text format, while wasm2c and wasm-decompile will decompile it into C or C-like syntax, respectively.

Note that only compiled smart contracts are stored on the chain, and you should not expect to recover the original source code of the contract in this way.

1 Like