This repository was archived by the owner on Jan 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 126
docs: Add new tutorials 4a, 4b, 4c and 5 #290
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| from iota import Iota, Seed | ||
|
|
||
| # Generate a random seed, or use one you already have (for the devnet) | ||
| print('Generating a random seed...') | ||
| my_seed = Seed.random() | ||
| # my_seed = Seed(b'MYCUSTOMSEED') | ||
| print('Your seed is: ' + str(my_seed)) | ||
|
|
||
| # Declare an API object | ||
| api = Iota( | ||
| adapter='https://nodes.devnet.iota.org:443', | ||
| seed=my_seed, | ||
| testnet=True, | ||
| ) | ||
|
|
||
| print('Generating the first unused address...') | ||
| # Generate the first unused address from the seed | ||
| response = api.get_new_addresses() | ||
|
|
||
| addy = response['addresses'][0] | ||
|
|
||
| print('Your new address is: ' + str(addy)) | ||
| print('Go to https://faucet.devnet.iota.org/ and enter you address to receive free devnet tokens.') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| from iota import Iota, Address | ||
| import time | ||
|
|
||
| # Put your address from Tutorial 4.a here | ||
| my_address = Address(b'YOURADDRESSFROMTHEPREVIOUSTUTORIAL') | ||
|
|
||
| # Declare an API object | ||
| api = Iota(adapter='https://nodes.devnet.iota.org:443', testnet=True) | ||
|
|
||
| # Script actually runs until you load up your address | ||
| success = False | ||
|
|
||
| while not success: | ||
| print('Checking balance on the Tangle for a specific address...') | ||
| # API method to check balance | ||
| response = api.get_balances(addresses=[my_address]) | ||
|
|
||
| # response['balances'] is a list! | ||
| if response['balances'][0]: | ||
| print('Found the following information for address ' + str(my_address) + ':') | ||
| print('Balance: ' + str(response['balances'][0]) + 'i') | ||
| success = True | ||
| else: | ||
| print('Zero balance found, retrying in 30 seconds...') | ||
| time.sleep(30) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| from iota import Iota, Seed | ||
| from pprint import pprint | ||
| import time | ||
|
|
||
| # Put your seed from Tutorial 4.a here | ||
| my_seed = Seed(b'YOURSEEDFROMTHEPREVIOUSTUTORIAL99999999999999999999999999999999999999999999999999') | ||
|
|
||
| # Declare an API object | ||
| api = Iota( | ||
| adapter='https://nodes.devnet.iota.org:443', | ||
| seed=my_seed, | ||
| testnet=True | ||
| ) | ||
|
|
||
| # Script actually runs until it finds balance | ||
| success = False | ||
|
|
||
| while not success: | ||
| print('Checking account information on the Tangle...') | ||
| # Gather addresses, balance and bundles | ||
| response = api.get_account_data() | ||
|
|
||
| # response['balance'] is an integer! | ||
| if response['balance']: | ||
| print('Found the following information based on your seed:') | ||
| pprint(response) | ||
| success = True | ||
| else: | ||
| print('Zero balance found, retrying in 30 seconds...') | ||
| time.sleep(30) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.