import{getWallets}from'@talismn/connect-wallets';import{DotPassportClient,createWidget}from'@dotpassport/sdk';// 1. Get available walletsconstinstalledWallets=getWallets().filter(wallet=>wallet.installed);// 2. Find and enable Talismanconsttalisman=installedWallets.find(w=>w.extensionName==='talisman');awaittalisman.enable('My DApp');// 3. Get accountsconstaccounts=awaittalisman.getAccounts();constaddress=accounts[0].address;// 4. Use with DotPassportconstclient=newDotPassportClient({apiKey:'your_api_key'});constscores=awaitclient.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
Best Practices
1. Persist Connection State
2. Handle Multiple Wallets
3. Optimize Widget Updates
Troubleshooting
Issue
Solution
"Wallet not found"
Ensure Talisman extension is installed and enabled
import { getWallets } from '@talismn/connect-wallets';
function checkWalletInstalled(): boolean {
const wallets = getWallets();
const talisman = wallets.find(w => w.extensionName === 'talisman');
return talisman?.installed ?? false;
}
if (!checkWalletInstalled()) {
// Show install prompt
window.open('https://talisman.xyz/download', '_blank');
}
import { getWallets, Wallet } from '@talismn/connect-wallets';
async function connectTalisman(): Promise<Wallet> {
const wallets = getWallets();
const talisman = wallets.find(w => w.extensionName === 'talisman');
if (!talisman) {
throw new Error('Talisman wallet not found');
}
if (!talisman.installed) {
throw new Error('Talisman is not installed');
}
// Enable the wallet - this prompts user for permission
await talisman.enable('DotPassport App');
return talisman;
}
import { WalletAccount } from '@talismn/connect-wallets';
async function getAccounts(wallet: Wallet): Promise<WalletAccount[]> {
const accounts = await wallet.getAccounts();
if (accounts.length === 0) {
throw new Error('No accounts found. Please create an account in Talisman.');
}
return accounts;
}
// Usage
const wallet = await connectTalisman();
const accounts = await getAccounts(wallet);
console.log('Available accounts:');
accounts.forEach(acc => {
console.log(`- ${acc.name}: ${acc.address}`);
});