Update tutorial for xrpl4j v3

This PR updates all Java examples to utilize xrpl4j v3, which has slight different contracts as compared to v2.
This commit is contained in:
David Fuelling
2023-05-09 16:54:40 -06:00
parent 022f24c1e6
commit a18fe56cdf
7 changed files with 189 additions and 220 deletions

View File

@@ -1,28 +1,26 @@
// Construct a network client
HttpUrl rippledUrl = HttpUrl
.get("https://s.altnet.rippletest.net:51234/");
HttpUrl rippledUrl = HttpUrl.get("https://s.altnet.rippletest.net:51234/");
System.out.println("Constructing an XrplClient connected to " + rippledUrl);
XrplClient xrplClient = new XrplClient(rippledUrl);
// Create a Wallet using a WalletFactory
WalletFactory walletFactory = DefaultWalletFactory.getInstance();
Wallet testWallet = walletFactory.randomWallet(true).wallet();
// Create a random KeyPair
KeyPair randomKeyPair = Seed.ed25519Seed().deriveKeyPair();
System.out.println("Generated KeyPair: " + randomKeyPair);
// Get the Classic and X-Addresses from testWallet
Address classicAddress = testWallet.classicAddress();
XAddress xAddress = testWallet.xAddress();
// Derive the Classic and X-Addresses from testWallet
Address classicAddress = randomKeyPair.publicKey().deriveAddress();
XAddress xAddress = AddressCodec.getInstance().classicAddressToXAddress(classicAddress, true);
System.out.println("Classic Address: " + classicAddress);
System.out.println("X-Address: " + xAddress);
// Fund the account using the testnet Faucet
FaucetClient faucetClient = FaucetClient
.construct(HttpUrl.get("https://faucet.altnet.rippletest.net"));
FaucetClient faucetClient = FaucetClient.construct(HttpUrl.get("https://faucet.altnet.rippletest.net"));
faucetClient.fundAccount(FundAccountRequest.of(classicAddress));
System.out.println("Funded the account using the Testnet faucet.");
// Look up your Account Info
AccountInfoRequestParams requestParams =
AccountInfoRequestParams.of(classicAddress);
AccountInfoResult accountInfoResult =
xrplClient.accountInfo(requestParams);
AccountInfoRequestParams requestParams = AccountInfoRequestParams.of(classicAddress);
AccountInfoResult accountInfoResult = xrplClient.accountInfo(requestParams);
// Print the result
System.out.println(accountInfoResult);
System.out.println(accountInfoResult);