检测 Provider
部分 provider 方法需要用户在浏览器中安装 OneKey 扩展后才能调用。
调用异步方法 detectWalletInstalled,检查扩展是否已安装。
如果未安装 OneKey,我们建议将用户重定向到我们的网站 。完整代码如下所示。
const installed = await provider.detectWalletInstalled();
if (installed) {
await provider.request({ method: 'near_accounts' });
} else {
window.open('https://www.onekey.so');
}最后更新于