From 849a6ba8f2250db4a944fa4f1f1a22c793036962 Mon Sep 17 00:00:00 2001 From: Jake Cahill <45230295+JakeSCahill@users.noreply.github.com> Date: Mon, 16 Dec 2019 17:11:14 +0000 Subject: [PATCH 1/3] Add zero-value transaction example --- README.md | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index af7e91d7..61ac18b0 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,40 @@ print(response) ## Examples -You can find an example project in the [examples](https://github.com/iotaledger/iota.py/tree/master/examples) directory. +We have a list of test cases in the [`examples` directory](https://github.com/iotaledger/iota.py/tree/master/examples) that you can use as a reference when developing apps with IOTA. + +Here's how you could send a zero-value transaction, using the library. For the guide, see the [documentation portal](https://docs.iota.org/docs/client-libraries/0.1/how-to-guides/python/send-your-first-bundle). + +```python +# You don't need a seed to send zero-value transactions +api = Iota('https://nodes.devnet.iota.org:443', testnet = True) + +# Define a message to send. +# This message must include only ASCII characters. +message = TryteString.from_unicode('Hello world') + +# Define an address. +# This does not need to belong to anyone or have IOTA tokens. +# It must only contain a maximum of 81 trytes +# or 90 trytes with a valid checksum +address = 'ZLGVEQ9JUZZWCZXLWVNTHBDX9G9KZTJP9VEERIIFHY9SIQKYBVAHIMLHXPQVE9IXFDDXNHQINXJDRPFDXNYVAPLZAW' + +# Define a zero-value transaction object +# that sends the message to the address +tx = ProposedTransaction( + address = Address(address), + message = message, + value = 0 +) + +# Create a bundle from the `ProposedTransaction` object +# and send the transaction to the node +result = api.send_transfer(transfers = [tx]) + +print('Bundle: ') + +print(result['bundle'].hash) +``` ## Supporting the project From 7b000415fd48acdd6b1cbef3ccfd5193157da537 Mon Sep 17 00:00:00 2001 From: Jake Cahill <45230295+JakeSCahill@users.noreply.github.com> Date: Tue, 17 Dec 2019 11:10:44 +0000 Subject: [PATCH 2/3] Update README.md Co-Authored-By: Phoenix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 61ac18b0..58f594b1 100644 --- a/README.md +++ b/README.md @@ -140,7 +140,7 @@ tx = ProposedTransaction( # Create a bundle from the `ProposedTransaction` object # and send the transaction to the node -result = api.send_transfer(transfers = [tx]) +result = api.send_transfer(transfers=[tx]) print('Bundle: ') From e578c0c04c7579f54b9507d0624839cf0c2617cb Mon Sep 17 00:00:00 2001 From: Jake Cahill <45230295+JakeSCahill@users.noreply.github.com> Date: Tue, 17 Dec 2019 11:10:51 +0000 Subject: [PATCH 3/3] Update README.md Co-Authored-By: Phoenix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 58f594b1..6d196632 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ Here's how you could send a zero-value transaction, using the library. For the g ```python # You don't need a seed to send zero-value transactions -api = Iota('https://nodes.devnet.iota.org:443', testnet = True) +api = Iota('https://nodes.devnet.iota.org:443', testnet=True) # Define a message to send. # This message must include only ASCII characters.