Aptos Bytecode / ABI to move file?

429 views Asked by At

I have an address with some deployed modules, is there a way for me to translate the Bytecode / ABI info to a file.move so it will be human readable?

2

There are 2 answers

0
Daniel Porteous On BEST ANSWER

By default, the source for a Move module is included when it is published on chain. If that is the case, you can download it like this:

aptos move download --account 6286dfd5e2778ec069d5906cd774efdba93ab2bec71550fa69363482fbd814e7 --package other

See this answer for much more information on the topic: How do I call a function in a different Move module / smart contract?

As for converting from bytecode to source, this is technically possible, but we have no tooling to support it today. Stay posted!

0
Daniel Porteous On

The previous answer states that decompilation is not possible. Now it is! Aptos Labs + Verichains recently released a decompiler for this purpose. The source code won't be an exact match syntactically of the original code, but it should be semantically identical.

# Install Revela. The CLI needs this separate tool to decompile the bytecode.
aptos update revela

# Download the package from on chain, in this case MoveStdlib.
aptos move download --account 0x1 --bytecode --package MoveStdlib

# Decompile!
aptos move decompile --package-path MoveStdlib/bytecode_modules

The output should be in MoveStdlib/bytecode_modules. Look for files with the .mv.move extension.

Learn more here: https://aptoslabs.medium.com/move-revealed-the-revela-decompiler-b206eaf48b45.