How to call query function from Sui SDK

Let’s say I am creating an object of the type:

struct Table1 has key, store{
        id: UID,
        list: Table<String, bool>
    }

In the package, I have a function that checks if a String-type element is present on the table. This is the function that returns true if the element is present on the table using the contrains method for Table.

public fun check_channel(
        table: &mut Table1,
        element: String
    ): bool{
        return table::contains(&mut table.list, element)
    }

Now using the SJI TS SDK how can I call this function to query the table?

Hi @tahlil,

You can call this function using SuiClient.devInspectTransactionBlock. This function allows you to construct a transaction to call any function and access any object on-chain for inspection purposes (to read the chain state), but does not commit any of the effects of those transactions on-chain, so you can use it to call functions like this.

2 Likes