For the complete documentation index, see llms.txt. This page is also available as Markdown.

SubWallet

This guide shows how to integrate DotPassport SDK with SubWallet using the @subwallet/wallet-connect library.

Installation

# Install SubWallet Connect
npm install @subwallet/wallet-connect

# Install DotPassport SDK
npm install @dotpassport/sdk

Quick Start

import { getWalletBySource } from '@subwallet/wallet-connect';
import { DotPassportClient, createWidget } from '@dotpassport/sdk';

// 1. Get SubWallet
const subwallet = await getWalletBySource('subwallet-js');

// 2. Enable and get accounts
await subwallet.enable();
const accounts = await subwallet.getAccounts();
const address = accounts[0].address;

// 3. Use with DotPassport
const client = new DotPassportClient({ apiKey: 'your_api_key' });
const scores = await client.getScores(address);
console.log(`Reputation: ${scores.totalScore}`);

Complete Integration Guide

Step 1: Check for Wallet Installation

Step 2: Connect to Wallet

Step 3: Get User Accounts

Step 4: Subscribe to Account Changes

Step 5: Integrate with DotPassport


Complete React Example


Complete Vanilla JavaScript Example


Error Handling


Working with Multiple Networks

SubWallet supports multiple networks. Here's how to filter accounts by network:


Best Practices

1. Persist Connection State

2. Handle Wallet Disconnection

3. Optimize Widget Updates


Troubleshooting

Issue
Solution

"Wallet not installed"

Install SubWallet from subwallet.app

"No accounts found"

Create an account in SubWallet

"User rejected"

User declined connection - provide retry option

Widget not updating

Ensure widget.update() is called with new address

Extension not detected

Refresh the page after installing SubWallet


Last updated