Skip to main content

haveno_dart 0.1.0 copy "haveno_dart: ^0.1.0" to clipboard
haveno_dart: ^0.1.0 copied to clipboard

Dart client library for the Haveno daemon gRPC API, ported from haveno-ts.

example/example.dart

// Usage example mirroring the haveno-ts README. Requires a running Haveno
// daemon with its gRPC API (or a gRPC-web proxy) at the given url.
import 'package:haveno_dart/haveno_dart.dart';

Future<void> main(List<String> args) async {
  final url = args.isNotEmpty ? args[0] : 'http://localhost:8080';
  final password = args.length > 1 ? args[1] : 'apitest';
  final alice = HavenoClient(url, password);
  try {
    print('Haveno version: ${await alice.getVersion()}');
    final balances = await alice.getBalances();
    print(
      'Available: ${HavenoUtils.atomicUnitsToXmr(balances.availableBalance.toString())} XMR',
    );
    final paymentAccounts = await alice.getPaymentAccounts();
    final myOffers = await alice.getMyOffers('ETH');
    final offers = await alice.getOffers('ETH', OfferDirection.BUY);
    print(
      '${paymentAccounts.length} payment accounts, '
      '${myOffers.length} own ETH offers, ${offers.length} ETH buy offers',
    );
    if (offers.isNotEmpty && paymentAccounts.isNotEmpty) {
      final trade = await alice.takeOffer(
        offers.first.id,
        paymentAccounts.first.id,
      );
      print('Took offer, trade id ${trade.tradeId}');
    }
  } on HavenoError catch (e) {
    print('Haveno error: $e');
  } finally {
    await alice.disconnect();
  }
}
0
likes
150
points
--
downloads

Documentation

API reference

Publisher

unverified uploader

Dart client library for the Haveno daemon gRPC API, ported from haveno-ts.

Homepage

License

unknown (license)

Dependencies

fixnum, grpc, protobuf

More

Packages that depend on haveno_dart