|
| 1 | +# @chunk {"steps": ["connect-tag"]} |
1 | 2 | # Define the network client |
2 | 3 | from xrpl.clients import JsonRpcClient |
| 4 | +from xrpl.wallet import generate_faucet_wallet |
| 5 | +from xrpl.core import addresscodec |
| 6 | +from xrpl.models.requests.account_info import AccountInfo |
| 7 | +import json |
| 8 | + |
3 | 9 | JSON_RPC_URL = "https://s.altnet.rippletest.net:51234/" |
4 | 10 | client = JsonRpcClient(JSON_RPC_URL) |
| 11 | +# @chunk-end |
5 | 12 |
|
6 | 13 |
|
7 | | -# Create a wallet using the testnet faucet: |
| 14 | +# @chunk {"steps": ["get-account-create-wallet-tag"]} |
| 15 | +# Create a wallet using the Testnet faucet: |
8 | 16 | # https://xrpl.org/xrp-testnet-faucet.html |
9 | | -from xrpl.wallet import generate_faucet_wallet |
| 17 | +print("\nCreating a new wallet and funding it with Testnet XRP...") |
10 | 18 | test_wallet = generate_faucet_wallet(client, debug=True) |
11 | | - |
12 | | -# Create an account str from the wallet |
13 | | -test_account = test_wallet.address |
14 | | - |
15 | | -# Derive an x-address from the classic address: |
16 | | -# https://xrpaddress.info/ |
17 | | -from xrpl.core import addresscodec |
18 | | -test_xaddress = addresscodec.classic_address_to_xaddress(test_account, tag=12345, is_test_network=True) |
19 | | -print("\nClassic address:\n\n", test_account) |
20 | | -print("X-address:\n\n", test_xaddress) |
| 19 | +test_account = test_wallet.classic_address |
| 20 | +print(f"Wallet: {test_account}") |
| 21 | +print(f"Account Testnet Explorer URL: ") |
| 22 | +print(f" https://testnet.xrpl.org/accounts/{test_account}") |
| 23 | +# @chunk-end |
21 | 24 |
|
22 | 25 |
|
| 26 | +# @chunk {"steps": ["query-xrpl-tag"]} |
23 | 27 | # Look up info about your account |
24 | | -from xrpl.models.requests.account_info import AccountInfo |
| 28 | +print("\nGetting account info...") |
25 | 29 | acct_info = AccountInfo( |
26 | 30 | account=test_account, |
27 | 31 | ledger_index="validated", |
28 | 32 | strict=True, |
29 | 33 | ) |
| 34 | + |
30 | 35 | response = client.request(acct_info) |
31 | 36 | result = response.result |
32 | | -print("response.status: ", response.status) |
33 | | -import json |
| 37 | +print("Response Status: ", response.status) |
34 | 38 | print(json.dumps(response.result, indent=4, sort_keys=True)) |
| 39 | +# @chunk-end |
0 commit comments