LogoNAVI Protocol SDKS

WalletClient

WalletClient provides a unified interface for interacting with the Sui blockchain. It integrates transaction signing, module management, and various DeFi operations.

The client option is optional — it defaults to the public mainnet fullnode (same as v1). Pass your own client for a private endpoint, auth headers, or a non-mainnet network, as shown in the examples below.

Initialization

Import Dependencies

import { WalletClient, WatchSigner, WebSigner } from '@naviprotocol/wallet-client'
import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519"

Private Key Wallet

Create a wallet client using a private key to perform all blockchain operations:

import { SuiGrpcClient } from '@mysten/sui/grpc'

const suiClient = new SuiGrpcClient({ network: 'mainnet', baseUrl: process.env.SUI_GRPC_ENDPOINT! })

// Create wallet client from private key
const walletClient = new WalletClient({
    client: {
        network: 'mainnet',
        grpc: { client: suiClient }
    },
    signer: Ed25519Keypair.fromSecretKey(privateKey)
})

// Get wallet address
console.log('Wallet address:', walletClient.address)

grpc also accepts a convenience endpoint form — grpc: { url, headers? } — and the SDK constructs the SuiGrpcClient internally. Passing a constructed client (shown above) is recommended so auth metadata and transport stay under your control and one instance is reused across the SDK.

Watch-Only Wallet

Use a watch-only wallet to view wallet information but cannot execute transactions:

import { SuiGrpcClient } from '@mysten/sui/grpc'

const suiClient = new SuiGrpcClient({ network: 'mainnet', baseUrl: process.env.SUI_GRPC_ENDPOINT! })

// Create watch-only wallet client
const walletClient = new WalletClient({
    client: {
        network: 'mainnet',
        grpc: { client: suiClient }
    },
    signer: new WatchSigner('0xc41d2d2b2988e00f9b64e7c41a5e70ef58a3ef835703eeb6bf1bd17a9497d9fe')
})

// Can view balances and portfolio
await walletClient.balance.updatePortfolio()
const portfolio = walletClient.balance.portfolio
const pools = await walletClient.lending.getPools()

// Cannot execute transaction operations (will throw error)
// await walletClient.swap.swap(...) // ❌ Error

Browser Extension Wallet

Create an adapter for browser environment (PC, Mobile) extension wallets:

import { SuiGrpcClient } from '@mysten/sui/grpc'

const suiClient = new SuiGrpcClient({ network: 'mainnet', baseUrl: process.env.SUI_GRPC_ENDPOINT! })

// Browser extension wallet adapter
class WebSignerAdapter extends WebSigner {
    constructor(address: string) {
        super(address)
    }

    // Sign and execute transaction
    async signAndExecuteTransaction({ transaction, client }) {
        // Implement interaction logic with browser extension
        // For example: call Sui Wallet, Ethos Wallet, etc.
        return await this.walletExtension.signAndExecuteTransaction(transaction)
    }

    // Sign transaction
    async signTransaction(bytes: Uint8Array) {
        return await this.walletExtension.signTransaction(bytes)
    }

    // Sign personal message
    async signPersonalMessage(bytes: Uint8Array) {
        return await this.walletExtension.signPersonalMessage(bytes)
    }
}

// Create browser wallet client
const walletClient = new WalletClient({
    client: {
        network: 'mainnet',
        grpc: { client: suiClient }
    },
    signer: new WebSignerAdapter('0x...')
})