Using Sui CLI

If you are a Sui developer, you can deploy to our Network with some minor changes to your workflow.

Initialize your environment

Initialize your Sui profile for your package development and add M2.

sui client new-env --rpc https://sui.testnet.m2.movementlabs.xyz:443 --alias m2

Now switch to the M2 environment:

sui client switch --env m2

You can now set your development environment with the following sequence of commands:

sui move new hello_world
cd hello_world
touch sources/hello_world.move
code .

Inside hello_wolrd.move you can paste the following code:

#[lint_allow(self_transfer)]

module hello_world::hello_world {

    use std::string;
    use sui::object::{Self, UID};
    use sui::transfer;
    use sui::tx_context::{Self, TxContext};

    struct HelloWorldObject has key, store {
        id: UID,
        text: string::String
    }

    public fun mint(ctx: &mut TxContext) {
        let object = HelloWorldObject {
            id: object::new(ctx),
            text: string::utf8(b"Hello World!")
        };
        transfer::public_transfer(object, tx_context::sender(ctx));
    }

}

After building your project, you can deploy it to the M2 testnet:

sui client publish --gas-budget 20000000

The object ID under the Published Objects section is the ID of your module. You can now call the mint function on your module with that object ID:

sui client call --function mint --module hello_world --package <package object ID> --gas-budget 10000000

Don't forget to replace <package object ID> with the object ID of your module from previous console output!

Congratulations! You have just written, published, and executed your Sui module on the Movement Network!

Make sure to take a look at our Movement CLI. Includes but not limited to the Sui CLI.

Last updated