Getting Started
You must initialize the BrowserProvider by passing it the provider object injected by the user's wallet.
import { Mitum, BrowserProvider } from '@mitumjs/mitumjs';
// 1. Check if the wallet (e.g., Fact Wallet) is installed
if (!window.imfact) {
alert('Fact Wallet is not installed!');
throw new Error('Fact Wallet provider not found.');
}
// 2. Initialize the BrowserProvider by wrapping the wallet's injected object
const provider = new BrowserProvider(window.imfact);
// 3. You can now use the provider to interact with the wallet
async function connectWallet() {
try {
const accounts = await provider.requestAccounts();
console.log('User permitted these accounts:', accounts);
} catch (error) {
console.error('Connection failed:', error.message);
}
}Last updated