From 36e29d88eb49468f2de45929fad6e43b6aabadfa Mon Sep 17 00:00:00 2001 From: Arnold Daniels Date: Mon, 28 Mar 2022 14:46:27 +0200 Subject: [PATCH] Update code examples in README. [skip ci] --- README.md | 66 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 6fec43a..089511d 100644 --- a/README.md +++ b/README.md @@ -5,17 +5,17 @@ Python client library for interacting with LTO Network ## Accounts ### Create an account -The chain_id is 'L' for the MainNet and 'T' TestNet +The chain_id is 'L' for the mainnet and 'T' testnet ```python -from lto.accounts.account_factory import AccountFactory +from lto.accounts.ed25519 import AccountFactory account = AccountFactory(chain_id).create() ``` ### Create an account from seed ```python -from lto.accounts.account_factory import AccountFactory +from lto.accounts.ed25519 import AccountFactory account = AccountFactory(chain_id).create_from_seed(seed) ``` @@ -23,7 +23,7 @@ account = AccountFactory(chain_id).create_from_seed(seed) ### Create an account from public key ```python -from lto.accounts.account_factory import AccountFactory +from lto.accounts.ed25519 import AccountFactory account = AccountFactory(chain_id).create_from_public_key(public_key) ``` @@ -31,47 +31,51 @@ account = AccountFactory(chain_id).create_from_public_key(public_key) ### Create an account from private key ```python -from lto.accounts.account_factory import AccountFactory +from lto.accounts.ed25519 import AccountFactory account = AccountFactory(chain_id).create_from_private_key(private_key) ``` -## Executing Transactions: -First a transaction needs to be created: -### Ex Transfer Transaction -``` +## Executing Transactions + +### Create transaction +First a transaction needs to be created. + +```python from src.LTO.Transactions.Transfer import Transfer transaction = Transfer(recipient, amount) ``` -The Transaction needs then to be signed.
-In order to sign a transaction an account is needed (check at the beginning of the page the steps to create an account). -### Ex of signinig a transaction -``` +The Transaction needs then to be signed. In order to sign a transaction an account is needed. + +### Sign transaction + +```python transaction.sign_with(account) ``` -For last the transaction needs to be broadcasted to the node.
-In order to do so we need to connect to the node using the PublicNode class. +### Broadcast transaction -``` +For last the transaction needs to be broadcasted to the node. In order to do so we need to connect to the node using the PublicNode class. + +```python from src.LTO.PublicNode import PublicNode node = PublicNode(url) ``` -The url refers to the node, there are many nodes available, here there are two examples, one for the MainNet and one for the TestNet
+The url refers to the node, there are many nodes available, here there are two examples, one for the mainnet and one for the testnet -https://nodes.lto.network
-https://testnet.lto.network +* https://nodes.lto.network +* https://testnet.lto.network -### Ex of broadcasting a transaction -``` +```python transaction.broadcast_to(node) ``` ## Transactions + ### Transfer Transaction ```python -from src.lto.transactions.transfer import Transfer +from lto.transactions import Transfer transaction = Transfer(recipient, amount) ``` @@ -79,28 +83,28 @@ transaction = Transfer(recipient, amount) ### Mass Transfer Transaction ```python -from src.lto.transactions.mass_transfer import MassTransfer +from lto.transactions import MassTransfer transaction = MassTransfer(transfers) ``` ### Anchor Transaction ```python -import Anchor +from lto.transactions import Anchor transaction = Anchor(anchor) ``` ### Lease Transaction ```python -from src.lto.transactions.lease import Lease +from lto.transactions import Lease transaction = Lease(recipient, amount) ``` ### Cancel Lease Transaction ```python -from src.lto.transactions.cancel_lease import CancelLease +from lto.transactions import CancelLease transaction = CancelLease(lease_id) ``` @@ -108,7 +112,7 @@ transaction = CancelLease(lease_id) ### SetScript Transaction ```python -from src.lto.transactions.set_script import SetScript +from lto.transactions import SetScript transaction = SetScript(script) ``` @@ -116,7 +120,7 @@ transaction = SetScript(script) ### Sponsorship transaction ```python -from src.lto.transactions.sponsorship import Sponsorship +from lto.transactions import Sponsorship transaction = Sponsorship(recipient) ``` @@ -124,7 +128,7 @@ transaction = Sponsorship(recipient) ### Cancel Sponsorship transaction ```python -from src.lto.transactions.cancel_sponsorship import CancelSponsorship +from lto.transactions import CancelSponsorship transaction = CancelSponsorship(recipient) ``` @@ -132,14 +136,14 @@ transaction = CancelSponsorship(recipient) ### Association transaction ```python -from src.lto.transactions.association import Association +from lto.transactions import Association transaction = Association(recipient, association_type, anchor) ``` ### Revoke Association transaction ```python -from src.lto.transactions.revoke_association import RevokeAssociation +from lto.transactions import RevokeAssociation transaction = RevokeAssociation(recipient, association_type, anchor) ```