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

Commit

Permalink
Add Python demo
Browse files Browse the repository at this point in the history
  • Loading branch information
thejohnfreeman committed Mar 4, 2020
1 parent 476f6e9 commit fc7f573
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
10 changes: 10 additions & 0 deletions python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Python Demo

![screenshot of demo in terminal](./python-demo.png)

Demonstrates [xpring-py](https://github.com/thejohnfreeman/xpring-py).

```
$ poetry install
$ poetry run python main.py
```
35 changes: 35 additions & 0 deletions python/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import time

import xpring


url = '3.14.64.116:50051'
seed = 'ss9unxUg8VgvDjWrogKGVDiRRz97n'
recipient = 'rNJDvXkaBRwJYdeEcx9pchE2SecMkH3FLz'
amount = '10'

print(f'Using rippled node located at: {url}')
client = xpring.Client.from_url(url)

wallet = xpring.Wallet.from_seed(seed)
address = wallet.address

print(f'Retrieving balance for {address}')
balance = client.get_balance(address)
print(f'Balance was {balance} drops!')

print('Sending:')
print(f'- Drops: {amount}')
print(f'- To: {recipient}')
print(f'- From: {address}')
signed_transaction = client.send(wallet, recipient, amount)
client.submit(signed_transaction)

txid = signed_transaction['hash']
print('Hash for transaction:')
print(txid)

time.sleep(5)
transaction_status = client.get_transaction_status(txid)
print('Result for transaction is:')
print(transaction_status.name)
16 changes: 16 additions & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[tool.poetry]
name = "xpring-demo"
version = "1.0.0"
description = "Demonstration of xpring-py"
authors = ["Xpring Engineering"]
license = "MIT"

[tool.poetry.dependencies]
python = "^3.6"
xpring = {version = "^0.4.3", extras = ["py"]}

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
Binary file added python/python-demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fc7f573

Please sign in to comment.