Skip to content

Explorer

John Smith edited this page Apr 26, 2020 · 2 revisions

[WIKI Home](Home) → Explorer API docs

Query balance of an arbitrary wallet

BigDecimal balance = NKNExplorer.Wallet.queryBalance("NKNTknBaGnWXK7UB1KgnhaXrpJJc4qbCvwqs");

Check validity of NKN address

Checks whether a given address is in correct NKN format and does not contain typos (unless the typos happen to be very very unlucky to pass address checksum)

String address = "NKNTknBaGnWXK7UB1KgnhaXrpJJc4qbCvwqs"; // Change/add/remove any char and see if it is still valid
System.out.println("Address " + address + " is " + (NKNExplorer.isAddressValid(address) ? "" : "not ") + "valid");

Resolve named address

Get the NKN address from a friendly name, registered using name service

String address = NKNExplorer.Wallet.resolveNamedAddress("somename");

Get subscribers

Get a list of subscribers to a given topic (and bucket)

final NKNExplorer.Subscription.Subscriber[] subscribers = NKNExplorer.Subscription.getSubscribers(topic, bucket);
System.out.println("Subscribers of '" + topic + "':");
for (NKNExplorer.Subscription.Subscriber s : subscribers) {
    System.out.println("  " + s.fullClientIdentifier + (s.meta.isEmpty() ? "" : ": " + s.meta));
}
System.out.println("Total: " + subscribers.length + " subs");