This repository has been archived by the owner on Jan 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #290 from lzpap/tutorial_4
docs: Add new tutorials 4a, 4b, 4c and 5
- Loading branch information
Showing
5 changed files
with
390 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 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 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.