Skip to content
This repository was archived by the owner on Jan 19, 2024. It is now read-only.

Commit 00c41af

Browse files
Add Python demo
1 parent 476f6e9 commit 00c41af

File tree

5 files changed

+349
-0
lines changed

5 files changed

+349
-0
lines changed

python/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Python Demo
2+
3+
![screenshot of demo in terminal](./python-demo.png)
4+
5+
Demonstrates [xpring-py](https://github.com/thejohnfreeman/xpring-py).
6+
7+
```
8+
$ poetry install
9+
$ poetry run python main.py
10+
```

python/main.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import time
2+
3+
import xpring
4+
5+
6+
url = '3.14.64.116:50051'
7+
seed = 'ss9unxUg8VgvDjWrogKGVDiRRz97n'
8+
recipient = 'rNJDvXkaBRwJYdeEcx9pchE2SecMkH3FLz'
9+
amount = '10'
10+
11+
print(f'Using rippled node located at: {url}')
12+
client = xpring.Client.from_url(url)
13+
14+
wallet = xpring.Wallet.from_seed(seed)
15+
address = wallet.address
16+
17+
print(f'Retrieving balance for {address}')
18+
balance = client.get_balance(address)
19+
print(f'Balance was {balance} drops!')
20+
21+
print('Sending:')
22+
print(f'- Drops: {amount}')
23+
print(f'- To: {recipient}')
24+
print(f'- From: {address}')
25+
signed_transaction = client.send(wallet, recipient, amount)
26+
client.submit(signed_transaction)
27+
28+
txid = signed_transaction['hash']
29+
print('Hash for transaction:')
30+
print(txid)
31+
32+
time.sleep(5)
33+
transaction_status = client.get_transaction_status(txid)
34+
print('Result for transaction is:')
35+
print(transaction_status.name)

0 commit comments

Comments
 (0)