Is there a way to debug or test Move contracts that depend on modules only available on mainnet?

Is there a way to debug or test Move contracts that depend on modules only available on mainnet?

I’m running into the following error:

Error: MoveAbort(MoveLocation {
    module: ModuleId {
        address: 0000000000000000000000000000000000000000000000000000000000000002,
        name: Identifier("dynamic_field")
    },
    function: 11,
    instruction: 0,
    function_name: Some("borrow_child_object")
}, 1) in command 1

The problem is that my code uses multiple dynamic_field operations, and I can’t tell which part is actually causing this abort.

Has anyone found a good way to debug or trace this kind of error when the relevant modules are only deployed on mainnet?

Hi! You can do end-to-end debugging with dryRun:
https://docs.sui.io/sui-api-ref#sui_dryruntransactionblock

From the error we know:

  • The failure is in PTB command 1 (0-indexed)

  • It’s coming from the dynamic_field module with EFieldDoesNotExist (code 1)

If that command includes multiple dynamic_field accesses, check each access manually to pinpoint the exact failing call.

If you try dryRun, it will show the same error - where it literally happens. No call stack or other information related to the execution of lines before the error.

What I can think of now is dividing a whole function into smaller functions and call those functions in one execution. In this way, I can minimize the “suspicious” area in my code.