simolus3/web3dart

call events into dApp

HosseinAsadi opened this issue · 4 comments

Hi

I need to listen some event into my dApp project

Inside your suggested document, listen to each event as follows

final eth = window.ethereum;
if (eth != null)
eth!.stream('chainChanged').listen((event) {
showSnackBar(event.toString());
});

but this does not work at all

do you have any suggestion for me?

Does eth.chainChanged not work either?

:(

nop

if(eth != null)
eth!.chainChanged.listen((event) {
showSnackBar(event.toString());
});

generally How can I call a custom event?

This is for listening metamask events:
In dart_wrappers.dart file replace:

Stream stream(String eventName) {
return _EventStream(this, eventName);
}

With this or whatever you like as long as you cast the stream, for sure there are other better ways to acomplish this matter, but the problem seems to be on casting issues

Stream stream(String eventName) {
return _EventStream(this, eventName).cast();
}

On the other hand, Event API in metamask tell us that "chainchanged" should be returned a String instead of "int"

Stream get chainChanged => stream('chainChanged').cast();
Stream get chainChanged => stream('chainChanged').cast();

I'm testing the package in order to use metamask in web, desktop and android with the same library using other providers.

When I send a transaction to a contract it would be nice nonce field was autocalculated instead always call "getTransactionCount" on the signer(credentials)