- Java 1.8 or higher
- Maven 3.5.0 or higher
git clone https://github.com/dispatchlabs/java-sdk.git
cd java-sdk
if macOS:brew install automake
brew install libtool
if Unix:apt-get install autoreconf
apt-get install libtool
then:sh build.sh
- Remember to set
-Djava.library.path="...secp256k1/.libs"
in your VM Arguments
System.out.println("Dispatch Labs SDK Example");
try {
Sdk sdk = new Sdk("10.0.1.2");
List<Contact> nodes = sdk.getDelegates();
Account fromAccount = sdk.createAccount();
Account toAccount = sdk.createAccount();
Receipt receipt = sdk.transferTokens(nodes.get(0), fromAccount, toAccount, 45);
System.out.println(receipt.getStatus());
// Pending?
while ((receipt = sdk.getLastStatus()).getStatus().equals(Receipt.Status.PENDING)) {
Thread.sleep(100);
}
System.out.println(receipt.getStatus());
// Get transactions.
List<Transaction> transactions = sdk.getTransactions(nodes.get(0));
System.out.println(transactions);
} catch (Throwable t) {
System.out.println(t);
}