Catalog npm
Back to packageRELEASE DETAILS

1.2.0-pre.61

npm

@0xobelisk/sui-client

Tookit for interacting with move eps framework

blockchainmoveobelisk labssui
Published4 Aug 2025
Direct dependencies39
Transitive dependenciesNot calculated

README

Current package documentation

Dubhe Client SDK

Dubhe is a client-agnostic SDK that supports various platforms including browsers, Node.js, and the COCOS game engine. It provides a simple interface to interact with your Sui Move contracts.

Getting Started

Prerequisites

Before using the SDK, make sure you have:

  1. Created and deployed your contract using the Dubhe CLI
  2. Obtained the packageId after deployment

Data Model Setup

First, define your contract's configuration using DubheConfig:

import { DubheConfig } from '@0xobelisk/sui-common';

export const dubheConfig = {
  name: 'counter',
  description: 'counter',
  systems: ['counter'],
  schemas: {
    counter: {
      structure: {
        value: 'StorageValue<u32>'
      }
    }
  }
} as DubheConfig;

Generate the contract code using CLI:

dubhe schemagen --config-path dubhe.config.ts

Initializing the Client

There are two ways to initialize the Dubhe client:

  1. Using dynamic metadata loading:
import { loadMetadata, Dubhe, NetworkType } from '@0xobelisk/sui-client';

const network = 'devnet' as NetworkType;
const packageId = 'YOUR_PACKAGE_ID';

const metadata = await loadMetadata(network, packageId);
const dubhe = new Dubhe({
  networkType: network,
  packageId: packageId,
  metadata: metadata,
  secretKey: privkey
});
  1. Using pre-saved metadata (recommended for better performance):
import metadata from './metadata.json';

const dubhe = new Dubhe({
  networkType: network,
  packageId: packageId,
  metadata: metadata,
  secretKey: privkey
});

Executing Transactions

To call contract methods:

import { Transaction } from '@0xobelisk/sui-client';

// Create transaction
const tx = new Transaction();
const params = [
  /* your parameters */
];

// Execute transaction
const response = await dubhe.tx.counter_system.inc(tx, params);

// For wallet integration
await dubhe.tx.counter_system.inc(tx, params, undefined, true);
const response = await dubhe.signAndSendTxn(tx);

Querying Data

To query contract state:

const tx = new Transaction();
const params = [
  /* your parameters */
];
const result = await dubhe.query.counter_system.get(tx, params);

// For BCS encoded results
const decodedData = dubhe.view(result);

BCS Data Decoding

The SDK provides a view() method to decode BCS-encoded return values from contract queries.

Supported Types

  • Basic types (u8, u16, u32, u64, u128, u256)
  • Boolean
  • String
  • Vector
  • Struct
  • Option
  • Custom objects

Example with Complex Types

// Example contract return type
struct GameState {
    score: u64,
    player_name: String,
    is_active: bool,
    items: vector<Item>
}

// Query and decode
const tx = new Transaction();
const result = await dubhe.query.game_system.get_state(tx, params);
const decodedState = dubhe.view(result);

Known Limitations

⚠️ Important Note:

  1. The current implementation cannot automatically decode enum types due to limitations in Sui metadata.
  2. Some complex nested structures might require additional handling.

Entity Key Generation

Dubhe provides three methods for generating entity keys:

// From object ID
const objectKey = await dubhe.entity_key_from_object(objectId);

// From string data
const bytesKey = await dubhe.entity_key_from_bytes('hello');

// From number
const numberKey = await dubhe.entity_key_from_u256(123);

Query Owned Objects

To query objects owned by a specific address:

const owner = '0xfa99b5b0463fcfb7d0203c701a76da5eda21a96190eb1368ab36a437cc89195e';
const ownedObjects = await dubhe.getOwnedObjects(owner);

Best Practices

  1. Use pre-saved metadata for better performance in production
  2. Implement proper error handling for BCS decoding
  3. Consider the limitations of enum type handling when designing your contract return types

Support

For more information or support, please visit our GitHub repository or join our community channels.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 39

Native requirements
39 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
tmp
Environment
{
  "local_name": "tmp",
  "alias": false,
  "peer_metadata": null
}
^0.2.1runtime
husky
Environment
{
  "local_name": "husky",
  "alias": false,
  "peer_metadata": null
}
^8.0.3runtime
assert
Environment
{
  "local_name": "assert",
  "alias": false,
  "peer_metadata": null
}
^2.1.0runtime
bech32
Environment
{
  "local_name": "bech32",
  "alias": false,
  "peer_metadata": null
}
^2.0.0runtime
colorts
Environment
{
  "local_name": "colorts",
  "alias": false,
  "peer_metadata": null
}
^0.1.63runtime
process
Environment
{
  "local_name": "process",
  "alias": false,
  "peer_metadata": null
}
^0.11.10runtime
valibot
Environment
{
  "local_name": "valibot",
  "alias": false,
  "peer_metadata": null
}
0.36.0runtime
keccak256
Environment
{
  "local_name": "keccak256",
  "alias": false,
  "peer_metadata": null
}
^1.0.6runtime
pluralize
Environment
{
  "local_name": "pluralize",
  "alias": false,
  "peer_metadata": null
}
^8.0.0runtime
tweetnacl
Environment
{
  "local_name": "tweetnacl",
  "alias": false,
  "peer_metadata": null
}
^1.0.3runtime
@mysten/bcs
Environment
{
  "local_name": "@mysten/bcs",
  "alias": false,
  "peer_metadata": null
}
^1.6.3runtime
@mysten/sui
Environment
{
  "local_name": "@mysten/sui",
  "alias": false,
  "peer_metadata": null
}
^1.35.0runtime
superstruct
Environment
{
  "local_name": "superstruct",
  "alias": false,
  "peer_metadata": null
}
^1.0.3runtime
@scure/bip39
Environment
{
  "local_name": "@scure/bip39",
  "alias": false,
  "peer_metadata": null
}
^1.3.0runtime
@noble/curves
Environment
{
  "local_name": "@noble/curves",
  "alias": false,
  "peer_metadata": null
}
^1.4.2runtime
@noble/hashes
Environment
{
  "local_name": "@noble/hashes",
  "alias": false,
  "peer_metadata": null
}
^1.4.0runtime
@suchipi/femver
Environment
{
  "local_name": "@suchipi/femver",
  "alias": false,
  "peer_metadata": null
}
^1.0.0runtime
@types/pluralize
Environment
{
  "local_name": "@types/pluralize",
  "alias": false,
  "peer_metadata": null
}
^0.0.33runtime
ts-retry-promise
Environment
{
  "local_name": "ts-retry-promise",
  "alias": false,
  "peer_metadata": null
}
^0.7.1runtime
jest
Environment
{
  "local_name": "jest",
  "alias": false,
  "peer_metadata": null
}
^29.7.0development
tsup
Environment
{
  "local_name": "tsup",
  "alias": false,
  "peer_metadata": null
}
^7.1.0development
dotenv
Environment
{
  "local_name": "dotenv",
  "alias": false,
  "peer_metadata": null
}
^16.3.1development
eslint
Environment
{
  "local_name": "eslint",
  "alias": false,
  "peer_metadata": null
}
^8.56.0development
ts-node
Environment
{
  "local_name": "ts-node",
  "alias": false,
  "peer_metadata": null
}
^10.9.1development
typedoc
Environment
{
  "local_name": "typedoc",
  "alias": false,
  "peer_metadata": null
}
^0.27.9development
prettier
Environment
{
  "local_name": "prettier",
  "alias": false,
  "peer_metadata": null
}
3.3.3development
@types/tmp
Environment
{
  "local_name": "@types/tmp",
  "alias": false,
  "peer_metadata": null
}
^0.2.5development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^5.2.2development
@types/jest
Environment
{
  "local_name": "@types/jest",
  "alias": false,
  "peer_metadata": null
}
^29.5.14development
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
^20.8.7development
lint-staged
Environment
{
  "local_name": "lint-staged",
  "alias": false,
  "peer_metadata": null
}
^15.0.2development
tsconfig-paths
Environment
{
  "local_name": "tsconfig-paths",
  "alias": false,
  "peer_metadata": null
}
^4.2.0development
@commitlint/cli
Environment
{
  "local_name": "@commitlint/cli",
  "alias": false,
  "peer_metadata": null
}
^18.0.0development
@commitlint/prompt-cli
Environment
{
  "local_name": "@commitlint/prompt-cli",
  "alias": false,
  "peer_metadata": null
}
^18.0.0development
eslint-config-prettier
Environment
{
  "local_name": "eslint-config-prettier",
  "alias": false,
  "peer_metadata": null
}
^9.1.0development
eslint-plugin-prettier
Environment
{
  "local_name": "eslint-plugin-prettier",
  "alias": false,
  "peer_metadata": null
}
^5.0.1development
@typescript-eslint/parser
Environment
{
  "local_name": "@typescript-eslint/parser",
  "alias": false,
  "peer_metadata": null
}
^6.8.0development
@commitlint/config-conventional
Environment
{
  "local_name": "@commitlint/config-conventional",
  "alias": false,
  "peer_metadata": null
}
^18.0.0development
@typescript-eslint/eslint-plugin
Environment
{
  "local_name": "@typescript-eslint/eslint-plugin",
  "alias": false,
  "peer_metadata": null
}
^6.8.0development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "3fae30c318fded7088702a563c7334d82e377187",
  "tarball": "https://registry.npmjs.org/@0xobelisk/sui-client/-/sui-client-1.2.0-pre.61.tgz",
  "fileCount": 55,
  "integrity": "sha512-j1NGZ0KoUwmpoQCsKRW4n/k7XFFL7jVPCAiFSdZPpMBHY3kKEIuXCi9ZsoaleuFFMWHbnPwxBhQ3r6ZX2NZohg==",
  "signatures": [
    {
      "sig": "MEUCICMm3L07yhiuhl36ESofjI2foKD3X7p88RZZGWpje2J9AiEA47OTxfdaRgNgvz3APLZodyv8TwfjIJPaVGraS0gEqk0=",
      "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
    }
  ],
  "unpackedSize": 678103
}

Repository

PENDING
0xobelisk/obelisk-engine

Shared repository data · GitHub

License detected in repository
Not collected

Repository

PENDING
0xobelisk/dubhe

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 21 Oct, 09:22 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:9f3b13affa66c6f5ef8a42b89a078d7da32cebc3cd384d290f013dec07fab9d5

Other collected versions

2.0.029 Jun1.2.0-pre.12522 Jun1.2.0-pre.12419 May1.2.0-pre.12318 May1.2.0-pre.12213 May1.2.0-pre.12112 MayView all collected versions →