leonardocustodio / polkadart

Polkadart provides developers the ability to query a node and interact with the Polkadot or Substrate chains using Dart.
Apache License 2.0
25 stars 14 forks source link

Which Api can get dot balance? #352

Closed weixuefeng closed 11 months ago

leonardocustodio commented 11 months ago

Hello @weixuefeng , you can do the following to get the DOT balance of an account

  final provider = Provider.fromUri(Uri.parse('wss://rpc.polkadot.io'));
  final api = Polkadot(provider);
  final publicKey =
      '0x0353088f335f7fac10c98dd4db07f1bb87b6f966b9491ae5a87fa8a6b233aabd';
  final account = await api.query.system.account(decodeHex(publicKey));
  print(account.toJson());
  await api.disconnect();

Please note you need to use polkadart_cli to generate the queries/rpcs/etc.

weixuefeng commented 11 months ago

when i call dart run polkadart_cli:generate -v, i got error:

Building package executable...
Failed to build polkadart_cli:generate:
../../../.pub-cache/hosted/xx/watcher-1.0.2/lib/src/constructable_file_system_event.dart:7:57: Error: The class 'FileSystemEvent' can't be extended, implemented, or mixed in outside of its library because it's a sealed class.
abstract class _ConstructableFileSystemEvent implements FileSystemEvent {
                                                        ^
Failed to build polkadart_cli:generate:
../../../.pub-cache/hosted/xx/watcher-1.0.2/lib/src/constructable_file_system_event.dart:7:57: Error: The class 'FileSystemEvent' can't be extended, implemented, or mixed in outside of its library because it's a sealed class.
abstract class _ConstructableFileSystemEvent implements FileSystemEvent {
weixuefeng commented 11 months ago

dart pub upgrade helped