Skip to content

How to get storageKeys for storage subscription? #443

Answered by poka-IT
poka-IT asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you, his example works :)

So this is my test code working:

Future<void> startBlockListening() async {
  final storageBlockKeyQuery = [duniterApi.query.system.numberKey()];
  await duniterApi.rpc.state.subscribeStorage(
    storageBlockKeyQuery,
    (storageChangeSet) async {
      final blockNumber = await duniterApi.query.system.number();
      log.d(blockNumber);
    },
  );
}

final Map<String, StreamSubscription<StorageChangeSet>>
    _addressSubscriptionMap = {};

Future<void> startBalanceListening(String address) async {
  if (_addressSubscriptionMap[address] != null) return;
  final accountPubKey = Address.decode(address).pubkey;
  final storageAccountKeyQuery = [
    duniter…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by leonardocustodio
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants