Observed since 21 Oct, 09:16 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
@0xobelisk/client
Tookit for interacting with move eps framework
Unified client creation layer for Dubhe framework with multi-chain support.
# Install the client package
npm install @0xobelisk/client
# Peer dependencies (automatically installed in most cases)
npm install @0xobelisk/sui-client @0xobelisk/graphql-client @0xobelisk/grpc-client @0xobelisk/ecs
| Blockchain | Status | Import Path |
|---|---|---|
| Sui | ✅ Ready | @0xobelisk/client/sui |
| Aptos | 🚧 Coming Soon | @0xobelisk/client/aptos |
| Initia | 🚧 Coming Soon | @0xobelisk/client/initia |
| Rooch | 🚧 Coming Soon | @0xobelisk/client/rooch |
import { createClient } from '@0xobelisk/client/sui';
import { Transaction } from '@0xobelisk/sui-client';
import metadata from './contracts/metadata.json';
// Create client with configuration
const client = createClient({
network: 'devnet',
packageId: '0x123...',
metadata,
credentials: {
secretKey: process.env.PRIVATE_KEY
}
});
// Access all clients from the bundle
const { contract, graphqlClient, grpcClient, ecsWorld, address } = client;
console.log('Connected as:', address);
// Execute a transaction
const tx = new Transaction();
const result = await contract.tx.counter_system.inc({ tx });
console.log('Transaction result:', result);
const client = createClient({
network: 'testnet',
packageId: '0x456...',
metadata,
credentials: {
mnemonics: 'your twelve word mnemonic phrase here...'
},
endpoints: {
fullnodeUrls: ['https://custom-rpc.example.com'],
graphql: 'https://graphql.example.com/graphql',
websocket: 'wss://graphql.example.com/graphql',
grpc: 'https://grpc.example.com'
}
});
const client = createClient({
network: 'mainnet',
packageId: '0x789...',
metadata,
credentials: { secretKey: '...' },
options: {
enableBatchOptimization: true,
cacheTimeout: 10000,
debounceMs: 200,
reconnectOnError: true
}
});
The @0xobelisk/client package can be used directly in browsers via a UMD bundle, perfect for vanilla JavaScript projects, Cocos Engine, Flutter WebView, and other browser environments.
<!-- Latest version -->
<script src="https://unpkg.com/@0xobelisk/client@latest/dist/browser/obelisk-client.min.js"></script>
<!-- Specific version (recommended for production) -->
<script src="https://unpkg.com/@0xobelisk/client@1.2.0/dist/browser/obelisk-client.min.js"></script>
<script src="./node_modules/@0xobelisk/client/dist/browser/obelisk-client.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<title>Obelisk Client Demo</title>
</head>
<body>
<h1>Dubhe Client Browser Example</h1>
<button id="connect">Connect</button>
<div id="result"></div>
<!-- Load the client -->
<script src="https://unpkg.com/@0xobelisk/client@latest/dist/browser/obelisk-client.min.js"></script>
<script>
// Access via global variable
const { createClient } = window.ObeliskClient;
document.getElementById('connect').addEventListener('click', async () => {
try {
// Create client
const client = createClient({
network: 'devnet',
packageId: '0x123...',
metadata: {...}, // Your contract metadata
credentials: {
secretKey: 'your-private-key'
}
});
// Use the client
const { contract, address } = client;
document.getElementById('result').innerHTML =
`Connected as: ${address}`;
// Execute transaction
const tx = new Transaction();
const result = await contract.tx.counter_system.inc({ tx });
console.log('Transaction result:', result);
} catch (error) {
console.error('Error:', error);
document.getElementById('result').innerHTML =
`Error: ${error.message}`;
}
});
</script>
</body>
</html>
// In your Cocos Creator script
const { Component } = cc;
cc.Class({
extends: Component,
onLoad() {
// Access ObeliskClient from window
const { createClient } = window.ObeliskClient;
this.client = createClient({
network: 'mainnet',
packageId: '0xabc...',
metadata: this.contractMetadata,
credentials: {
secretKey: this.privateKey
}
});
console.log('Dubhe client initialized:', this.client.address);
},
async executeTransaction() {
const tx = new Transaction();
const result = await this.client.contract.tx.game_system.move({
tx,
params: [this.x, this.y]
});
console.log('Move result:', result);
}
});
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
class DubheWebView extends StatefulWidget {
@override
_DubheWebViewState createState() => _DubheWebViewState();
}
class _DubheWebViewState extends State<DubheWebView> {
late final WebViewController controller;
@override
void initState() {
super.initState();
controller = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..loadHtmlString('''
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/@0xobelisk/client@latest/dist/browser/obelisk-client.min.js"></script>
</head>
<body>
<script>
const { createClient } = window.ObeliskClient;
// Initialize client
window.dubheClient = createClient({
network: 'testnet',
packageId: '0x123...',
metadata: {...}
});
// Expose functions to Flutter
window.executeMove = async (x, y) => {
const tx = new Transaction();
const result = await window.dubheClient.contract.tx.move({
tx,
params: [x, y]
});
return JSON.stringify(result);
};
</script>
</body>
</html>
''');
}
Future<void> callMove(int x, int y) async {
final result = await controller.runJavaScriptReturningResult(
'window.executeMove($x, $y)'
);
print('Move result: $result');
}
@override
Widget build(BuildContext context) {
return WebViewWidget(controller: controller);
}
}
The package provides two versions:
| File | Size | Use Case |
|---|---|---|
obelisk-client.js | ~241 KB | Development (with source maps) |
obelisk-client.min.js | ~242 KB | Production (optimized) |
When loaded in the browser, all exports are available under window.ObeliskClient:
// Available functions
window.ObeliskClient.createClient;
window.ObeliskClient.createClientWithValidation;
window.ObeliskClient.validateClientConfig;
window.ObeliskClient.isNetworkType;
If you're using TypeScript in a browser environment, you can still get type safety:
declare global {
interface Window {
ObeliskClient: typeof import('@0xobelisk/client/sui');
}
}
const { createClient } = window.ObeliskClient;
createClient(config: ClientConfig): DubheClientBundleCreates a complete Dubhe client bundle with all necessary instances.
ClientConfig)| Property | Type | Required | Description |
|---|---|---|---|
network | NetworkType | ✅ | Network: 'mainnet', 'testnet', 'devnet', 'localnet' |
packageId | string | ✅ | Contract package ID |
metadata | any | ✅ | Contract metadata (from dubhe schemagen) |
dubheSchemaId | string | ❌ | Dubhe Schema ID for enhanced features |
dubheMetadata | any | ❌ | Dubhe metadata for GraphQL/ECS |
credentials | object | ❌ | Authentication credentials |
endpoints | object | ❌ | Custom service endpoints |
options | object | ❌ | Performance and behavior options |
credentials?: {
secretKey?: string; // Private key (base64 or hex)
mnemonics?: string; // 12 or 24 word mnemonic phrase
}
endpoints?: {
fullnodeUrls?: string[]; // RPC node URLs (multiple for redundancy)
graphql?: string; // GraphQL endpoint (default: http://localhost:4000/graphql)
websocket?: string; // WebSocket endpoint (default: ws://localhost:4000/graphql)
grpc?: string; // gRPC endpoint (default: http://localhost:8080)
}
options?: {
enableBatchOptimization?: boolean; // Default: true
cacheTimeout?: number; // Default: 5000 (ms)
debounceMs?: number; // Default: 100 (ms)
reconnectOnError?: boolean; // Default: true
}
DubheClientBundle){
contract: Dubhe; // Main contract client
graphqlClient: DubheGraphqlClient; // GraphQL query client
grpcClient: DubheGrpcClient; // gRPC client
ecsWorld: DubheECSWorld; // ECS World for entity queries
metadata: SuiMoveNormalizedModules; // Contract metadata
network: NetworkType; // Network type
packageId: string; // Package ID
dubheSchemaId?: string; // Schema ID (if provided)
address: string; // User address
options?: {...}; // Options used
}
createClientWithValidation(config: Partial<ClientConfig>): DubheClientBundleCreates a client with strict configuration validation. Throws descriptive errors for invalid configurations.
try {
const client = createClientWithValidation(externalConfig);
} catch (error) {
console.error('Invalid configuration:', error.message);
}
validateClientConfig(config: Partial<ClientConfig>): asserts config is ClientConfigValidates a configuration object. Useful for pre-validation before client creation.
const config = loadFromFile();
validateClientConfig(config); // Throws if invalid
// config is now guaranteed to be valid
import { Transaction } from '@0xobelisk/sui-client';
const client = createClient({
/* ... */
});
// Execute a contract method
const tx = new Transaction();
await client.contract.tx.my_system.my_method({
tx,
params: [arg1, arg2]
});
// Query contract state
const result = await client.contract.query.my_system.get_value({
tx: new Transaction()
});
// Query indexed data
const data = await client.graphqlClient.query({
query: `
query GetEntities {
entities {
id
components
}
}
`
});
// Subscribe to real-time updates
client.graphqlClient.subscribe({
query: `
subscription OnEntityUpdate {
entityUpdated {
id
components
}
}
`,
onData: (data) => {
console.log('Entity updated:', data);
}
});
// Get all entities
const entities = client.ecsWorld.getEntities();
// Query entities with specific components
const filtered = client.ecsWorld.queryEntities({
with: ['Position', 'Velocity']
});
// Watch for entity changes
client.ecsWorld.watchEntity(entityId, (entity) => {
console.log('Entity changed:', entity);
});
// High-performance queries via gRPC
const response = await client.grpcClient.query({
method: 'GetEntity',
params: { entityId: '0x123...' }
});
| Package | Use Case | Dependencies |
|---|---|---|
@0xobelisk/sui-client | Low-level contract interactions | None |
@0xobelisk/client | Unified client for any platform | sui-client, etc |
@0xobelisk/react | React applications with hooks | React, client |
When to use @0xobelisk/client:
When to use @0xobelisk/sui-client:
pnpm build
pnpm type-check
pnpm lint
pnpm watch
Apache-2.0
Contributions welcome! Please read our contributing guidelines and submit PRs to the main repository.
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
tmpEnvironment{
"local_name": "tmp",
"alias": false,
"peer_metadata": null
} | ^0.2.1 | runtime |
huskyEnvironment{
"local_name": "husky",
"alias": false,
"peer_metadata": null
} | ^8.0.3 | runtime |
assertEnvironment{
"local_name": "assert",
"alias": false,
"peer_metadata": null
} | ^2.0.0 | runtime |
colortsEnvironment{
"local_name": "colorts",
"alias": false,
"peer_metadata": null
} | ^0.1.63 | runtime |
processEnvironment{
"local_name": "process",
"alias": false,
"peer_metadata": null
} | ^0.11.10 | runtime |
keccak256Environment{
"local_name": "keccak256",
"alias": false,
"peer_metadata": null
} | ^1.0.6 | runtime |
@mysten/bcsEnvironment{
"local_name": "@mysten/bcs",
"alias": false,
"peer_metadata": null
} | ^0.7.3 | runtime |
superstructEnvironment{
"local_name": "superstruct",
"alias": false,
"peer_metadata": null
} | ^1.0.3 | runtime |
@scure/bip39Environment{
"local_name": "@scure/bip39",
"alias": false,
"peer_metadata": null
} | ^1.2.1 | runtime |
@mysten/sui.jsEnvironment{
"local_name": "@mysten/sui.js",
"alias": false,
"peer_metadata": null
} | ^0.41.0 | runtime |
ts-retry-promiseEnvironment{
"local_name": "ts-retry-promise",
"alias": false,
"peer_metadata": null
} | ^0.7.0 | runtime |
tsupEnvironment{
"local_name": "tsup",
"alias": false,
"peer_metadata": null
} | ^7.1.0 | development |
dotenvEnvironment{
"local_name": "dotenv",
"alias": false,
"peer_metadata": null
} | ^16.3.1 | development |
eslintEnvironment{
"local_name": "eslint",
"alias": false,
"peer_metadata": null
} | ^8.43.0 | development |
ts-nodeEnvironment{
"local_name": "ts-node",
"alias": false,
"peer_metadata": null
} | ^10.9.1 | development |
typedocEnvironment{
"local_name": "typedoc",
"alias": false,
"peer_metadata": null
} | ^0.24.8 | development |
prettierEnvironment{
"local_name": "prettier",
"alias": false,
"peer_metadata": null
} | ^2.8.8 | development |
@types/tmpEnvironment{
"local_name": "@types/tmp",
"alias": false,
"peer_metadata": null
} | ^0.2.3 | development |
typescriptEnvironment{
"local_name": "typescript",
"alias": false,
"peer_metadata": null
} | ^5.0.4 | development |
@types/nodeEnvironment{
"local_name": "@types/node",
"alias": false,
"peer_metadata": null
} | ^20.5.0 | development |
lint-stagedEnvironment{
"local_name": "lint-staged",
"alias": false,
"peer_metadata": null
} | ^13.2.3 | development |
tsconfig-pathsEnvironment{
"local_name": "tsconfig-paths",
"alias": false,
"peer_metadata": null
} | ^4.2.0 | development |
@commitlint/cliEnvironment{
"local_name": "@commitlint/cli",
"alias": false,
"peer_metadata": null
} | ^17.6.6 | development |
@commitlint/prompt-cliEnvironment{
"local_name": "@commitlint/prompt-cli",
"alias": false,
"peer_metadata": null
} | ^17.6.6 | development |
eslint-config-prettierEnvironment{
"local_name": "eslint-config-prettier",
"alias": false,
"peer_metadata": null
} | ^8.8.0 | development |
eslint-plugin-prettierEnvironment{
"local_name": "eslint-plugin-prettier",
"alias": false,
"peer_metadata": null
} | ^4.2.1 | development |
@typescript-eslint/parserEnvironment{
"local_name": "@typescript-eslint/parser",
"alias": false,
"peer_metadata": null
} | ^5.60.1 | development |
@commitlint/config-conventionalEnvironment{
"local_name": "@commitlint/config-conventional",
"alias": false,
"peer_metadata": null
} | ^17.6.6 | development |
@typescript-eslint/eslint-pluginEnvironment{
"local_name": "@typescript-eslint/eslint-plugin",
"alias": false,
"peer_metadata": null
} | ^5.60.1 | development |
@mysten/sui.jsEnvironment{
"local_name": "@mysten/sui.js",
"alias": false,
"peer_metadata": null
} | ^0.41.0 | peer |
Source distribution
{
"shasum": "6e6f2829429555d57f7ee07d8e9e6ef27238f405",
"tarball": "https://registry.npmjs.org/@0xobelisk/client/-/client-0.4.6.tgz",
"fileCount": 48,
"integrity": "sha512-ydUu74XwE9KVdXwdFYf4vM5WHQ+zDP95Oe7gfyXZ7w0xutrqHvgrtgu6AfWNJfs6umX2fhxiZDlvZX8lj6FlUA==",
"signatures": [
{
"sig": "MEUCIQCedkVsWDF2+ydZkCRPSjP9CnzP5icb3MLeTa8Xy+ZGsAIgF0vYl7wjrCZTNIDSurvbZARj1Vv+pvRb9uHsgpqvBiw=",
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
}
],
"unpackedSize": 482810
}Observed since 21 Oct, 09:16 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:2014fd1d5ca667418f61ba5c20a7b99fab1cf606954cc59c30e10d65536d446e