Unable to publish package w/ the PTB CLI

I am new to the SUI Client PTB CLI and facing the following: I wrote a simple Move script minting an NFT (just one entry fun). The code builds fine, tests fine and executes succesfully on either the SuiScan interface or with SUI CLI. However, when I try to publish it with the PTB command

sui client ptb –publish “.”

I get the following error

Encountered error when building PTB:
  × Error when processing PTB
   ╭────
 1 │ --publish . 
   · ─────┬─────
   ·      ╰── Failed to publish the Move module(s), reason: Modules must all have 0x0 as their addresses. Violated by module ModuleId { address: 318a59ccf6a47e2c8ae747d0d05940e1aecde93a6b19ffece1d55f4b95e871af, name: Identifier("myptb") }
   ╰────

I anyone has any clue on what gives, pls be kind enough to inform.

I thank you in advance.

P.S. I run the command from the folder w/ the sources subdir and the move.toml file.

can you please your move.toml file, or even better the repo with the move project?

1 Like

Thank you for the interest.

Move.toml

[package]

name = “try”

edition = “2024.beta” # edition = “legacy” to use legacy (pre-2024) Move

[dependencies]

[addresses]

try = “0x0”

[dev-dependencies]

[dev-addresses]

try.move

module try::myptb;

use std::string::{Self, String};

public struct AdminCap has key, store {
    id: UID,
}

public struct Cat has key, store {
    id: UID,
    name: String,
    age: u64,
}

fun init(ctx: &mut TxContext) {
    transfer::public_transfer(AdminCap {
        id: object::new(ctx),
    }, tx_context::sender(ctx));
}

public fun mint(
    _: &AdminCap,
    name: vector<u8>,
    age: u64,
    ctx: &mut TxContext): Cat {
        Cat {
        id: object::new(ctx),
        name: string::utf8(name),
        age,
    }
}

I fail to publish w/ the command

sui client ptb publish".”

and I am succesfull with

sui client publish

Furthermore, when I try to mint with the ptb commands

export PACKAGE=<Package ID>
export ACAP=<AdminCap UID>

sui client ptb \
--move-call sui::tx_context::sender \
--assign sender \
--move-call $PACKAGE::myptb::mint @$ACAP "pikachu" 1 \
--assign mycat \
--transfer-objects [mycat] sender

it fails because the mint function yields no output due to not being able to create the String assigned to name. However, if I go inside the code and explicitly enter the name as in

name: string::utf8(b"pikachu"),

and of course omit adding a name arg input in the ptb –move-call, then it works fine.

Any ideas?

Thank you

Is there a specific reason you are trying to publish the module through ptb? If you just want detailed effects you can use :

sui client publish --json