Adding Console.log to stdlib

For new Move developers, It’s difficult to debug. Console.log is a useful tool in javascript, I have introduced it to Move as a stdlib module, I am wondering if it’s possible to make a PR to official repo?

Here’s example:

import 0x0.Console;

main() {
    let x: u64;
    let addr: address;
    let b: bool;
    let constant: vector<u8>;
    let r: u64;

    constant = h"aaaaaaaa";
    x = 100;
    b = true;
    addr = 0x0;

    r = Console.log<bool>(&b);
    r = Console.log<address>(&addr);
    r = Console.log<u64>(&x);
    r = Console.log<vector<u8>>(&constant);


Here is what you see in console.

Vector(U8)=>Value(Container(RefCell { value: U8([170, 170, 170, 170]) }))
1 Like

Agreed that this is a pain and a printing utility is needed! We have a similar PR ( in flight, but would love to hear your feedback/compare notes.

1 Like

OK, thanks, Let’s discuss this topic there.

You guys did much better than I did.

@sam are there any proposals/tools that run move script locally. This is also important for Move developers

The end-to-end testing framework makes it easy to run scripts and modules locally against the genesis state.

It would be nice to have some additional tools to run a script against a particular historical state (e.g., "run this script on the state after the 100th block). This isn’t currently on our roadmap, but all of the ingredients for building this should be there (VM + state sync + transaction) if someone from the community was interested in contributing!

I used this framework before. Those comments really make me confused. thanks for sharing this blog. I am much clear right now.

I would love to contribute in this tool. and my plan is similar to yours.
But I prefer to load states from genesis, rather than state sync. if we want run script on historical block, we can export the states at that block, then loaded these states into local runner. What do you think?

The execution of this tool will be similar to test framework and more close to real running environment.

1 Like

Awesome! That would be really useful for us.

That sounds like a great plan to me.

1 Like