Analyzing VM scripts with neon-js

I want to convert VM scripts from RPC to a format that I can read from. I’m not sure what functions to use for this.

For e.g., if I pass DCEDXXkQj3E9IInpYgQmh20u1Mu+81lxEkDtQUGnbpKROxxBVuezJw== I want to get something searchable, so something like:

[“System.Contract.Call”, “PUSHDATA1”, “0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5”, “PUSHDATA1”, “registerCandidate”, “PUSHDATA1”, “035d79108f713d2089e9620426876d2ed4cbbef359711240ed4141a76e92913b1c”]

The important thing is that I can start with the script and have a way to match things like public keys, contract hashes, method names etc.

1 Like

You’re looking for a disassembler function. See:
extend OpToken for full disassembly support · Issue #579 · CityOfZion/neon-js · GitHub for an example.

Dora also has a built-in script disassembler that predates the neon-js support:

2 Likes

Thanks! For anyone else that follows that first link, the toInstruction function has been renamed prettyPrint, so the line I needed was:

Neon.sc.OpToken.fromScript(Neon.u.HexString.fromBase64("DCEDXXkQj3E9IInpYgQmh20u1Mu+81lxEkDtQUGnbpKROxxBVuezJw==").toBigEndian()).map(t => t.prettyPrint()).

1 Like