simolus3 / web3dart

Ethereum library, written in Dart.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

isConnected to dApp browsers like metamask

HosseinAsadi opened this issue · comments

Hi there

I want to check that my pwa dapp is connect to any dApp browsers like metamask or not

so i have below code

final eth = window.ethereum;
if (eth != null)
eth!.isConnected();

but this always return true!!

do you have suggestion for me?

Good catch, I've fixed this in 3adef15.

I am using the latest version but it still returns true! :(

web3dart 2.1.4

I've just published version 2.2.0 which contains the fix.

thank you so much

Hi there

I want to check that my pwa dapp is connect to any dApp browsers like metamask or not

so i have below code

final eth = window.ethereum;
if (eth != null)
eth!.isConnected();

but this always return true!!

do you have suggestion for me?

It still is!!
@simolus3

I can't reproduce this. We have this example:

final eth = window.ethereum;
if (eth == null) {
print('MetaMask is not available');
return;
}

When I run dart pub global webdev serve, it prints "MetaMask is not available" in a browser without metamask and opens the pop-up for browsers that have the plugin installed.

no no
I did not mean that!

if (eth != null)
eth!.isConnected();

isConnected()

What is the task of this?

because this function always return true with eth != null !!

In fact, I want to check to see do my dApp is connect to the metamask or not

for example if not connect, I call
eth!.requestAccount();

@simolus3