Skip to content

Frontend SDK

The Frontend SDK provides a TypeScript/JavaScript library for building browser-based dApps on Wasichain. It handles wallet connection, transaction construction, contract queries, and event subscriptions.

Installation

npm install @wasichain/sdk

Connecting to a wallet

import { WasichainClient } from "@wasichain/sdk";

const client = await WasichainClient.connect();
const address = client.address;

The SDK automatically detects the Wasichain wallet extension. If the extension is not installed, connect() throws an error that the dApp can use to prompt the user to install it.

Querying contracts

const result = await client.queryContract(contractAddress, msgBytes);

Queries are read-only and do not require a signature or gas payment.

Sending transactions

const txHash = await client.execute(contractAddress, msgBytes, {
  funds: 1000n,
});

The SDK builds the transaction, requests a signature from the wallet extension, and submits it to the network. The returned hash can be used to poll for the transaction receipt.

Watching for events

client.onEvent(contractAddress, "transfer", (event) => {
  console.log("Transfer event:", event);
});