Getting started with Java + sample code

This commit is contained in:
nkramer44
2021-05-04 11:00:54 -04:00
parent 5f7da18409
commit e79a0494b1
4 changed files with 344 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
// Construct a network client
final HttpUrl rippledUrl = HttpUrl.get("https://s.altnet.rippletest.net:51234/");
XrplClient xrplClient = new XrplClient(rippledUrl);
// Create a Wallet using a WalletFactory
final WalletFactory walletFactory = DefaultWalletFactory.getInstance();
final Wallet testWallet = walletFactory.randomWallet(true).wallet();
// Get the Classic and X-Addresses from testWallet
final Address classicAddress = testWallet.classicAddress();
final XAddress xAddress = testWallet.xAddress();
System.out.println("Classic Address: " + classicAddress);
System.out.println("X-Address: " + xAddress);
// Fund the account using the testnet Faucet
final FaucetClient faucetClient = FaucetClient.construct(HttpUrl.get("https://faucet.altnet.rippletest.net"));
faucetClient.fundAccount(FundAccountRequest.of(classicAddress));
// Look up your Account Info
final AccountInfoRequestParams requestParams = AccountInfoRequestParams.of(classicAddress);
final AccountInfoResult accountInfoResult = xrplClient.accountInfo(requestParams);
System.out.println(accountInfoResult);