Account0.py
from stellar_sdk.keypair import Keypair
pair = Keypair.random()
print(f"Secret: {pair.secret}")
# Secret:
print(f"Public Key: {pair.public_key}")
Account.py
import requests
public_key = "GD5WQZDL7TUYB3ZOYOVPZFDTWZUW54PIDFNTS5YYX5AXWD2ILI5EKPDX"
response = requests.get(f"https://friendbot.stellar.org?addr={public_key}")
if response.status_code == 200:
print(f"SUCCESS! You have a new account :)\n{response.text}")
else:
print(f"ERROR! Response: \n{response.text}")
Account3.py
from stellar_sdk.server import Server
server = Server("https://horizon-testnet.stellar.org")
public_key = "GD5WQZDL7TUYB3ZOYOVPZFDTWZUW54PIDFNTS5YYX5AXWD2ILI5EKPDX"
account = server.accounts().account_id(public_key).call()
for balance in account['balances']:
print(f"Type: {balance['asset_type']}, Balance: {balance['balance']}")
StellaPayment.py
from stellar_sdk.keypair import Keypair
from stellar_sdk.network import Network
from stellar_sdk.server import Server
from stellar_sdk.transaction_builder import TransactionBuilder
from stellar_sdk.exceptions import NotFoundError, BadResponseError, BadRequestError
server = Server("https://horizon-testnet.stellar.org")
source_key = Keypair.from_secret("SDQTUR3UHH2P7AZAX3GMHEBTOAM74OECYNEHZEUJVDBTM7HSYHWIF24P")
destination_id = "GD5WQZDL7TUYB3ZOYOVPZFDTWZUW54PIDFNTS5YYX5AXWD2ILI5EKPDX"
# First, check to make sure that the destination account exists.
# You could skip this, but if the account does not exist, you will be charged
# the transaction fee when the transaction fails.
try:
server.load_account(destination_id)
except NotFoundError:
# If the account is not found, surface an error message for logging.
raise Exception("The destination account does not exist!")
# If there was no error, load up-to-date information on your account.
source_account = server.load_account(source_key.public_key)
# Let's fetch base_fee from network
base_fee = server.fetch_base_fee()
# Start building the transaction.
transaction = (
TransactionBuilder(
source_account=source_account,
network_passphrase=Network.TESTNET_NETWORK_PASSPHRASE,
base_fee=base_fee,
)
# Because Stellar allows transaction in many currencies, you must specify the asset type.
# Here we are sending Lumens.
.append_payment_op(destination=destination_id, amount="10", asset_code="XLM")
# A memo allows you to add your own metadata to a transaction. It's
# optional and does not affect how Stellar treats the transaction.
.add_text_memo("Test Transaction")
# Wait a maximum of three minutes for the transaction
.set_timeout(10)
.build()
)
# Sign the transaction to prove you are actually the person sending it.
transaction.sign(source_key)
try:
# And finally, send it off to Stellar!
response = server.submit_transaction(transaction)
print(f"Response: {response}")
except (BadRequestError, BadResponseError) as err:
print(f"Something went wrong!\n{err}")
It worked perfact with Test defalut setting from the website [https://developers.stellar.org/docs/tutorials/create-account/]
But I can not find how to work with the main-net!!! I've spending times to find the example script for the main net of the lumen to use it! and also tried to find the main net settings as well But was not possible to find any~!
Can I get some help to use these example scripts to work with main-net?