console-wallet-dapp-templ
v0.0.20
Published
> A lightweight SDK for connecting your Web3 applications to the **Console Wallet Extension** — enabling account access, connection status, message signing, and sending **Canton Coin** with ease.
Readme
🧩 Console DApp SDK
A lightweight SDK for connecting your Web3 applications to the Console Wallet Extension — enabling account access, connection status, message signing, and sending Canton Coin with ease.
🚀 Overview
Console DApp SDK is a developer-friendly library that allows any decentralized application (DApp) to seamlessly integrate with the Console Wallet browser extension.
It provides simple APIs to:
- 🔗 Connect your DApp to a user’s Console Wallet
- 👤 Access the active account and connection state
- ✍️ Request message signing to the wallet
- 💰 Send Canton Coin transactions securely and reliably
With just a few lines of code, you can authenticate users, sign data, or trigger Canton blockchain transactions — all through a unified SDK built for simplicity and safety.
⚙️ Key Features
| Feature | Description | | -------------------------- | -------------------------------------------------------------- | | 🔌 Easy Integration | One SDK import connects your app to Console Wallet instantly | | 👛 Account Access | Retrieve connected account address and chain info | | 🧾 Message Signing | Sign arbitrary messages or typed data directly from the wallet | | 💸 Transaction Support | Send Canton Coin with a simple API call | | 🔒 Secure by Design | Uses wallet’s native permissions and confirmation flows | | 🧠 Framework Agnostic | Works with React, Vue, or vanilla JS apps |
🧠 Why Use Console DApp SDK?
Instead of manually handling RPC connections or building custom wallet logic, console-wallet-dapp-templ provides a clean, unified interface for interacting with the Canton ecosystem.
It’s ideal for:
- Light start with Canton blockchain
- Web3 DApps that need wallet connection and signing
- Any app that interacts with Canton
🧠 Core Functionality
The Console DApp SDK provides a communication layer between your Web3 application and the Console Wallet Extension using the browser’s native window.postMessage API.
It handles all low-level messaging logic automatically, so you can focus on building your DApp — not managing communication details.
🔄 How It Works
When your DApp sends a request (e.g.,
connect(),signMessage(), orsendTransaction()),
the SDK transmits a structured message to the Console Wallet Extension viawindow.postMessage.Each outgoing request is assigned a unique request ID, which is included in both the request and the extension’s response.
The SDK listens for incoming responses from the extension, matches them to their original request using the ID,
and automatically resolves the corresponding Promise in your application.
This approach ensures reliable, asynchronous communication between the DApp and the extension — preventing race conditions, mismatched responses, or orphaned message handlers.
🧩 Benefits
- ✅ Fully type-safe and asynchronous API
- 🧭 No manual message listeners required
- 🛡️ Prevents response mismatch errors with per-request unique IDs
- ⚡ Lightweight and dependency-free
- 🧠 Extensible for future Console Wallet capabilities (multi-chain support, session management, etc.)
In short: the SDK abstracts all the complex message passing between your DApp and the wallet, providing a stable and predictable communication layer out of the box.
📡 Supported Requests
The SDK exposes several high-level request methods that communicate with the Console Wallet Extension through secure message passing.
Each request is automatically tagged with a unique request ID to ensure reliable response matching.
| Method | Description | Request Payload | Response |
| ---------------------- | -------------------------------------------------------------- | --------------------------------- | ----------------------- |
| getAccounts() | Retrieves the currently connected wallet account(s). | — | GetAccountsResponse |
| signMessage(message) | Requests the user to sign a message in hex or base 64 format. | { message: SignMessageRequest } | SignedMessageResponse |
| signSend(data) | Signs and broadcasts a transaction to send Canton Coin. | SignSendRequest | SignSendResponse |
| connect(data) | Prompts the users to connect their Console Wallet to the DApp. | ConnectRequest | boolean |
| getIsConnected() | Checks if the DApp is already connected to the wallet. | — | boolean |
🪄 Example
const handleSignSend = async () => {
if (!amount || !receiver || !expireDate) {
alert('Please fill all fields');
return;
}
try {
const activeAccount = await consoleWalletPixelplex.getAccounts();
const signResult = await consoleWalletPixelplex.signSend({
to: receiver,
from: activeAccount?.[0].party || '',
amount,
expireDate,
});
setResult(signResult.status ? 'Transaction signed successfully' : 'Transaction error');
} catch (error) {
console.error('Error signing transaction:', error);
setResult('Error signing transaction');
}
};📦 Installation
npm install console-wallet-dapp-templ
# or
yarn add console-wallet-dapp-templ
Before your DApp can interact with the Console Wallet Extension, it needs to initialize a connection session.
This step establishes secure communication between your web application and the user’s wallet.
🔌 Connecting Your DApp
The SDK provides a simple connect() method that requests permission from the user’s Console Wallet.
import { consoleWalletPixelplex } from 'console-wallet-dapp-templ';
const handleConnect = async () => {
try {
await consoleWalletPixelplex.connect({ name, icon });
} catch (error) {
console.error('Error checking connection:', error);
}
};
const handleCheckConnection = async () => {
try {
const isConnected = await consoleWalletPixelplex.getIsConnected();
setConnectionStatus(isConnected ? 'Connected' : 'Not connected');
} catch (error) {
console.error('Error checking connection:', error);
}
};