xelis_dart_sdk 0.0.4 copy "xelis_dart_sdk: ^0.0.4" to clipboard
xelis_dart_sdk: ^0.0.4 copied to clipboard

Software Development Kit in Dart to build Apps for the Xelis Blockchain.

XELIS-DART-SDK #

Software Development Kit in Dart for Xelis Blockchain.

Features #

  • JSON-RPC Client to interact with daemon API.
  • Websocket channel to listen chain events.

Usage #

Use DaemonClientRepository to interact via JSON-RPC with a Xelis node.

Or use DaemonChannelRepository to create a websocket channel and receive events of your choice.

import 'package:xelis_dart_sdk/xelis_dart_sdk.dart';

Future<void> main() async {
  try {
    final daemonRepository = DaemonClientRepository(rpcAddress: localhostAddress)
      ..startRpcClient();
    final res = await daemonRepository.getInfo();
    print('result: $res');

    final daemonChannel = DaemonChannelRepository(rpcAddress: localhostAddress);
    await daemonChannel.connect();

    // After the connection, subscribe to the desired events,
    daemonChannel
      ..subscribeToNewBlock()
      ..subscribeToBlockOrdered()
    // Then add your callback and start listening.
      ..listenDaemonEvents(onNewBlock: print, onBlockOrdered: print);
  } catch (e) {
    print(e);
  }
  // exit(0);
}
0
likes
0
pub points
73%
popularity

Publisher

unverified uploader

Software Development Kit in Dart to build Apps for the Xelis Blockchain.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

convert, freezed_annotation, json_annotation, json_rpc_2, web_socket_channel

More

Packages that depend on xelis_dart_sdk