Giter Site home page Giter Site logo

Comments (4)

liuyuejiang avatar liuyuejiang commented on July 29, 2024

Thank you Simon, how's it going?

from web3dart.

simolus3 avatar simolus3 commented on July 29, 2024

Was fixing the coverage tooling yesterday because it didn't work with Dart 2.3. Will take a look at this today. There is a dart library which implements jsonrpc over websockets, so hopefully it should be straightforward to implement.

from web3dart.

simolus3 avatar simolus3 commented on July 29, 2024

It's working on development now and can be used like this:

final client = Web3Client(rpcUrl, Client(), socketConnector: () {
return IOWebSocketChannel.connect(wsUrl).cast<String>();
});

You'll need to add a dependency on web_socket_channel: ^1.0.0 in your pubspec.yaml and import 'package:web_socket_channel/io.dart'. There are errors with ganache when unsubscribing from a stream which I still need to fix, but otherwise everything seems to work.

Also, when using websockets in a Flutter app, you should call dispose() on the client when the app goes into background and then create a new Web3Dart client when it's resumed. The OS might close the websocket (and therefore, the event streams), so it's better to make that explicit and restore them when the app comes back into foreground.

from web3dart.

simolus3 avatar simolus3 commented on July 29, 2024

Got it working, I'll merge it into master and release a new version soon. The previous comment still holds, especially the remarks about dispose(). When using infura, be aware that your wsUrl is wss://<NETWORK>.infura.io/ws/v3/YOUR-PROJECT-ID (note the /ws/).

from web3dart.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.