Initialization
Any wallets that are installed, should initialize an AlgorandProvider
object and assign it to window.algorand
.
First, we will need to check if the window.algorand
object exists:
- Javascript
- TypeScript
if (!window.algorand) {
throw new Error('no wallets are installed!');
}
if (!window.algorand) {
throw new Error('no wallets are installed!');
}
If the window.algorand
object exists, we can check what wallets have been added:
- Javascript
- TypeScript
const wallets = window.algorand.getWallets();
console.log(wallets);
// ['agora-wallet', 'another-awesome-wallet']
import type { AlgorandProvider } from '@agoralabs-sh/algorand-provider';
const wallets: string[] = (window.algorand as AlgorandProvider).getWallets();
console.log(wallets);
// ['agora-wallet', 'another-awesome-wallet']
When we have confirmed that the window.algorand
object exists and contains wallets, we can proceed to enabling the dApp with a wallet.