SocketConnector typedef

SocketConnector = StreamChannel<String> Function()

Signature for a function that opens a socket on which json-rpc operations can be performed.

Typically, this would be a websocket. The web_socket_channel package on pub is suitable to create websockets. An implementation using that library could look like this:

import "../../web3dart.dart";
import "package:web_socket_channel/io.dart";

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

Implementation

typedef SocketConnector = StreamChannel<String> Function();