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}`);
});