PTB CLI - how to input type args

Below is the script for creating a simple NFT and listing it as a dynamic object field in a shared struct.

module ptb::ptb_einfach;

use std::string::{Self, String};
use sui::dynamic_object_field as dof;
use sui::sui::SUI;
use sui::balance::{Self, Balance};
use sui::coin::{Self, Coin};

const EInsufficientFunds: u64 = 0;
const EIncorrectPayment: u64 = 1;

public struct Shop has key, store {
    id: UID,
    purse: Balance<SUI>,
}

public struct Item has key, store {
    id: UID,
    name: String,
    price: u64,
}

fun init(ctx: &mut TxContext) {
    transfer::public_share_object(Shop {
        id: object::new(ctx),
        purse: balance::zero(),
    });
}

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

public fun list<T: key + store>(
    shop: &mut Shop,
    item: T) {
        dof::add(&mut shop.id, true, item);
}

I can execute it no problem with the simple CLI but when attempting to replicate with the PTB CLI, I fail to input the type argument when calling the list func. The PTB command is below

#!/usr/bin/bash
sui client ptb \
--move-call $PACKAGE::ptb_einfach::mint '"toulis"' 231 \
--assign item \
--assign shop @$SHOP \
--move-call $PACKAGE::ptb_einfach::list shop item

and the error I get obviously get is

Encountered error when building PTB:
  × Error when processing PTB
   ╭─[4:104]
 3 │ --assign shop @0xa58a9351a3c5e9563ea55cfb4688f9c28853fa2068da625f44e37d1adc17a0c5
 4 │ --move-call 0xbd09a93fbe5b007fd7771a4fdbece3e710608375212dc256c3bf6b0318b39788::ptb_einfach::list shop item 
   ·                                                                                                        ──┬─
   ·                                                                                                          ╰── Not enough type parameters supplied for Move call

What is the appropriate way of inputing the type arg for an item created and assigned in a previous command line?

2 Likes

hey! you will need to use the --type-argsflag to provide the type arguments for this move call.
You can check out all of the available flags with sui client call –-help command or check the same output in the official docs here https://docs.sui.io/references/cli/client#help

1 Like

Atha,

Thanx for the assist. Actually, I was already using –type-args when employing the simple sui client CLI. The question was how to do the same with the sui client ptb CLI. Finally it happened with a lot of blind & desperate trial and error as below:

#!/usr/bin/bash
sui client ptb \
--move-call $PACKAGE::ptb_einfach_T::list "<$ITYPE>" @$SHOP @$ITEM

where ITYPE is the ItemType as provided by the previous –move-call on function mint and stored as an env var.

Of course, the question remains how could one call both mint and list functions in the same PTB command.

I am trying to get a semblance of dexterity with the PTB CLI in order to be able to proceed with the SDK. The Rust SDK is a bit feisty for my weak stomach (and there is next to zero documentation) so I think I will throw in my lot with the TypeScript SDK.

Thanx again

1 Like

Pls check my resp at topic 49114

1 Like