Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

call events into dApp #187

Open
HosseinAsadi opened this issue Aug 12, 2021 · 4 comments
Open

call events into dApp #187

HosseinAsadi opened this issue Aug 12, 2021 · 4 comments

Comments

@HosseinAsadi
Copy link

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?

@simolus3
Copy link
Owner

Does eth.chainChanged not work either?

@HosseinAsadi
Copy link
Author

:(

nop

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

@HosseinAsadi
Copy link
Author

generally How can I call a custom event?

@DrasiusMajere
Copy link

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)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants