Skip to content

Commit bda1da2

Browse files
committed
Add Get Started Walkthrough for Python
1 parent 7cb5f9a commit bda1da2

File tree

2 files changed

+139
-122
lines changed

2 files changed

+139
-122
lines changed
Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,54 @@
1+
# @chunk {"steps": ["connect-tag"]}
12
# Define the network client
23
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+
39
JSON_RPC_URL = "https://s.altnet.rippletest.net:51234/"
410
client = JsonRpcClient(JSON_RPC_URL)
11+
print("Connected to Testnet")
12+
# @chunk-end
513

614

7-
# Create a wallet using the testnet faucet:
15+
# @chunk {"steps": ["get-account-create-wallet-tag"]}
16+
# Create a wallet using the Testnet faucet:
817
# 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...")
1019
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
1125

12-
# Create an account str from the wallet
13-
test_account = test_wallet.address
1426

27+
# @chunk {"steps": ["get-account-x-address-tag"]}
1528
# Derive an x-address from the classic address:
1629
# 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
2139

2240

41+
# @chunk {"steps": ["query-xrpl-tag"]}
2342
# Look up info about your account
24-
from xrpl.models.requests.account_info import AccountInfo
43+
print("\nGetting account info...")
2544
acct_info = AccountInfo(
2645
account=test_account,
2746
ledger_index="validated",
2847
strict=True,
2948
)
49+
3050
response = client.request(acct_info)
3151
result = response.result
3252
print("response.status: ", response.status)
33-
import json
3453
print(json.dumps(response.result, indent=4, sort_keys=True))
54+
# @chunk-end

0 commit comments

Comments
 (0)