|
| 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 | +print("Connected to Testnet") |
| 12 | +# @chunk-end |
5 | 13 |
|
6 | 14 |
|
7 |
| -# Create a wallet using the testnet faucet: |
| 15 | +# @chunk {"steps": ["get-account-create-wallet-tag"]} |
| 16 | +# Create a wallet using the Testnet faucet: |
8 | 17 | # https://xrpl.org/xrp-testnet-faucet.html
|
9 |
| -from xrpl.wallet import generate_faucet_wallet |
| 18 | +print("\nCreating a new wallet and funding it with Testnet XRP...") |
10 | 19 | test_wallet = generate_faucet_wallet(client, debug=True)
|
| 20 | +test_account = test_wallet.classic_address |
| 21 | +print(f"Wallet: {test_account}") |
| 22 | +print(f"Account Testnet Explorer URL: ") |
| 23 | +print(f" https://testnet.xrpl.org/accounts/{test_account}") |
| 24 | +# @chunk-end |
11 | 25 |
|
12 |
| -# Create an account str from the wallet |
13 |
| -test_account = test_wallet.address |
14 | 26 |
|
| 27 | +# @chunk {"steps": ["get-account-x-address-tag"]} |
15 | 28 | # Derive an x-address from the classic address:
|
16 | 29 | # 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) |
| 30 | +print("\nGenerating an x-address from the classic address...") |
| 31 | +test_xaddress = addresscodec.classic_address_to_xaddress( |
| 32 | + test_account, |
| 33 | + tag=12345, |
| 34 | + is_test_network=True |
| 35 | +) |
| 36 | +print(f"Classic address: {test_account}") |
| 37 | +print(f"X-address: {test_xaddress}") |
| 38 | +# @chunk-end |
21 | 39 |
|
22 | 40 |
|
| 41 | +# @chunk {"steps": ["query-xrpl-tag"]} |
23 | 42 | # Look up info about your account
|
24 |
| -from xrpl.models.requests.account_info import AccountInfo |
| 43 | +print("\nGetting account info...") |
25 | 44 | acct_info = AccountInfo(
|
26 | 45 | account=test_account,
|
27 | 46 | ledger_index="validated",
|
28 | 47 | strict=True,
|
29 | 48 | )
|
| 49 | + |
30 | 50 | response = client.request(acct_info)
|
31 | 51 | result = response.result
|
32 |
| -print("response.status: ", response.status) |
33 |
| -import json |
| 52 | +print("Response Status: ", response.status) |
34 | 53 | print(json.dumps(response.result, indent=4, sort_keys=True))
|
| 54 | +# @chunk-end |
0 commit comments