HomeGuidesAPI ReferenceChangelog
GuidesAPI ReferenceCommunityDiscordBlogFAQBug BountyAnnouncementsChange Log
Guides

Voting & SRs

listWitnesses

List all witnesses that current API node is connected to.

listWitnesses()

RETURN

WitnessList object.

EXAMPLE

wrapper.listWitnesses();

The result is:

witnesses {
    address: "A\243]\347\020{\304h\231\270\365\273\030\306\036\262\340\334\2649\340"
    voteCount: 1000008562
    url: "http://SR8.com"
    totalProduced: 514523
    totalMissed: 805
    latestBlockNum: 13925240
    latestSlotNum: 538255669
    isJobs: true
  }
  ...

voteWitness

Vote for a witness.

voteWitness(ownerAddress, votes)

PARAMS

  1. ownerAddress(String)*

owner address, default hexString.

  1. votes(Map)*

key: 'vote_address' stands for the address of the witness you want to vote, default hexString.

value: 'vote_count' stands for the number of votes you want to vote.

RETURN

TransactionExtention, including execution results.

THROWS

IllegalException, if fail to vote witness.

EXAMPLE

witness.put("TG7RHXaL7E9rqSkBavX7s1vtikoz6np6bD","1");
TransactionExtention transaction = wrapper.voteWitness("TLtrDb1udekjDumnrf3EVeke3Q6pHkZxjm",witness);
Transaction signedTxn = wrapper.signTransaction(transaction);
String ret = wrapper.broadcastTransaction(signedTxn);

The result is:

90b1738e0ead46e52f1550d7e5b619136ecf715cc43a728737b86b1a5bf633a3