forked from iotaledger/iota-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Brord van Wierst
committed
May 3, 2023
1 parent
b47cf99
commit b28f4a5
Showing
49 changed files
with
506 additions
and
232 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
NON_SECURE_USE_OF_DEVELOPMENT_MNEMONIC_1="endorse answer radar about source reunion marriage tag sausage weekend frost daring base attack because joke dream slender leisure group reason prepare broken river" | ||
NODE_URL="https://api.testnet.shimmer.network" | ||
FAUCET_URL="https://faucet.testnet.shimmer.network/api/enqueue" | ||
EXPLORER_URL="https://explorer.shimmer.network/testnet" | ||
STRONGHOLD_PASSWORD="some_hopefully_secure_password" |
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
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
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 |
---|---|---|
@@ -1,8 +1,16 @@ | ||
from iota_sdk import Client | ||
from dotenv import load_dotenv | ||
|
||
import json | ||
import os | ||
|
||
load_dotenv() | ||
|
||
node_url = os.environ.get('NODE_URL', 'https://api.testnet.shimmer.network') | ||
|
||
# Create a Client instance | ||
client = Client(nodes=['https://api.testnet.shimmer.network']) | ||
client = Client(nodes=[node_url]) | ||
|
||
# Get an outputs by its id | ||
output = client.get_output('0x1e857d380f813d8035e487b6dfd2ff4740b6775273ba1b576f01381ba2a1a44c0000') | ||
print(f'{output}') | ||
print(json.dumps(output, indent=4)) |
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 |
---|---|---|
@@ -1,8 +1,14 @@ | ||
from iota_sdk import Client | ||
from dotenv import load_dotenv | ||
import os | ||
|
||
load_dotenv() | ||
|
||
node_url = os.environ.get('NODE_URL', 'https://api.testnet.shimmer.network') | ||
|
||
# Create a Client instance | ||
client = Client(nodes=['https://api.testnet.shimmer.network']) | ||
client = Client(nodes=[node_url]) | ||
|
||
# Create and post a block without payload | ||
block = client.build_and_post_block() | ||
print(f'{block}') | ||
print(f'Empty block sent: {os.environ["EXPLORER_URL"]}/block/{block[0]}') |
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 |
---|---|---|
@@ -1,16 +1,23 @@ | ||
from iota_sdk import Client | ||
from dotenv import load_dotenv | ||
import json | ||
import os | ||
|
||
load_dotenv() | ||
|
||
node_url = os.environ.get('NODE_URL', 'https://api.testnet.shimmer.network') | ||
|
||
# Create a Client instance | ||
client = Client(nodes=['https://api.testnet.shimmer.network']) | ||
client = Client(nodes=[node_url]) | ||
|
||
# Fetch a block ID from the node | ||
block_id = client.get_tips()[0] | ||
print(f'{block_id}') | ||
block_id = client.get_tips() | ||
print(f'Block ids: {block_id}') | ||
|
||
# Get the metadata for the block | ||
metadata = client.get_block_metadata(block_id) | ||
print(f'{metadata}') | ||
metadata = client.get_block_metadata(block_id[0]) | ||
print(f'Block metadata: {json.dumps(metadata, indent=4)}') | ||
|
||
# Request the block by its id | ||
block = client.get_block_data(block_id) | ||
print(f'{block}') | ||
block = client.get_block_data(block_id[0]) | ||
print(f'Block: {json.dumps(block, indent=4)}') |
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 |
---|---|---|
@@ -1,9 +1,25 @@ | ||
from iota_sdk import Client, utf8_to_hex | ||
from iota_sdk import Client, utf8_to_hex, hex_to_utf8 | ||
from dotenv import load_dotenv | ||
import json | ||
import os | ||
|
||
load_dotenv() | ||
|
||
node_url = os.environ.get('NODE_URL', 'https://api.testnet.shimmer.network') | ||
|
||
# Create a Client instance | ||
client = Client(nodes=['https://api.testnet.shimmer.network']) | ||
client = Client(nodes=[node_url]) | ||
|
||
# Create and post a block with a tagged data payload | ||
block = client.build_and_post_block( | ||
tag=utf8_to_hex('hello'), data=utf8_to_hex('hello')) | ||
print(f'{block}') | ||
|
||
print(f'Data block sent: {os.environ["EXPLORER_URL"]}/block/{block[0]}') | ||
|
||
block = client.get_block_data(block[0]) | ||
print(f'Block data: {json.dumps(block, indent=4)}') | ||
|
||
payload = block['payload'] | ||
|
||
if payload and 'data' in payload and payload['data']: | ||
print(f'Decoded data: { hex_to_utf8(payload["data"]) }') |
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 |
---|---|---|
@@ -1,18 +1,25 @@ | ||
from iota_sdk import Client, MnemonicSecretManager | ||
from iota_sdk import Client, MnemonicSecretManager, Ed25519Address, Utils, AddressWithAmount | ||
from dotenv import load_dotenv | ||
import os | ||
|
||
load_dotenv() | ||
|
||
node_url = os.environ.get('NODE_URL', 'https://api.testnet.shimmer.network') | ||
|
||
# Create a Client instance | ||
client = Client(nodes=['https://api.testnet.shimmer.network']) | ||
client = Client(nodes=[node_url]) | ||
|
||
if 'NON_SECURE_USE_OF_DEVELOPMENT_MNEMONIC_1' not in os.environ: | ||
print(".env mnemonic is undefined, see .env.example") | ||
sys.exit(1) | ||
|
||
secret_manager = MnemonicSecretManager("flame fever pig forward exact dash body idea link scrub tennis minute " + | ||
"surge unaware prosper over waste kitten ceiling human knife arch situate civil") | ||
secret_manager = MnemonicSecretManager(os.environ['NON_SECURE_USE_OF_DEVELOPMENT_MNEMONIC_1']) | ||
|
||
options = { | ||
"output": { | ||
"address": 'rms1qzpf0tzpf8yqej5zyhjl9k3km7y6j0xjnxxh7m2g3jtj2z5grej67sl6l46', | ||
"amount": '1000000', | ||
} | ||
} | ||
output = AddressWithAmount( | ||
address= 'rms1qzpf0tzpf8yqej5zyhjl9k3km7y6j0xjnxxh7m2g3jtj2z5grej67sl6l46', | ||
amount= 1000000, | ||
) | ||
|
||
# Create and post a block with a transaction | ||
block = client.build_and_post_block(secret_manager, options) | ||
print(f'{block}') | ||
block = client.build_and_post_block(secret_manager, output=output) | ||
print(f'Block sent: {os.environ["EXPLORER_URL"]}/block/{block[0]}') |
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
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
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 |
---|---|---|
@@ -1,14 +1,20 @@ | ||
from iota_sdk import Client | ||
from dotenv import load_dotenv | ||
import os | ||
|
||
load_dotenv() | ||
|
||
node_url = os.environ.get('NODE_URL', 'https://api.testnet.shimmer.network') | ||
|
||
# Create a Client instance | ||
client = Client(nodes=['https://api.testnet.shimmer.network']) | ||
client = Client(nodes=[node_url]) | ||
|
||
# Fetch a block ID from the node | ||
block_id = client.get_tips()[0] | ||
print(f'{block_id}') | ||
print(f'Block id: {block_id}') | ||
|
||
# Get block raw | ||
block_raw = client.get_block_raw(block_id) | ||
|
||
# Print block raw | ||
print(f'{block_raw}') | ||
print(f'Block bytes: {block_raw}') |
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
Oops, something went wrong.