Skip to content

Commit 53572c4

Browse files
authored
Merge pull request #10 from MatejMecka/feat/challenge-1-learn
Learn Level 1: Challenge 1
2 parents a0eb401 + 58de3d9 commit 53572c4

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

Learn-Level-1/Challenge-1/main.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
"""
2+
Challenge 1: Create a Stellar Account
3+
"""
4+
from stellar_sdk import Server, Keypair, TransactionBuilder, Network
5+
import requests
6+
7+
# 1. Load Keys
8+
server = Server("https://horizon-testnet.stellar.org")
9+
stellar_quest_keypair = Keypair.from_secret("Shhhhh")
10+
quest_account_pub_key = stellar_quest_keypair.public_key
11+
quest_account_priv_key = stellar_quest_keypair.secret
12+
13+
# 2. Create Another account
14+
print("Loading Accounts...")
15+
16+
random_keypair = Keypair.random()
17+
random_keypair_pub_key = random_keypair.public_key
18+
random_keypair_priv_key = random_keypair.secret
19+
20+
# 3. Fund Another account using TestBot
21+
print("Funding Random Account...")
22+
23+
url = 'https://friendbot.stellar.org'
24+
response = requests.get(url, params={'addr': quest_account_pub_key})
25+
print(f"Friendbot responded with {response}")
26+
27+
28+
# 4. Use said account to fund my account
29+
print("Building Transaction...")
30+
31+
base_fee = server.fetch_base_fee()
32+
account = server.load_account(quest_account_pub_key)
33+
34+
transaction = (
35+
TransactionBuilder(
36+
source_account=account,
37+
network_passphrase=Network.TESTNET_NETWORK_PASSPHRASE,
38+
base_fee=base_fee,
39+
)
40+
.append_create_account_op(
41+
destination=random_keypair_pub_key,
42+
starting_balance="1000",
43+
)
44+
.build()
45+
)
46+
print('Signing Transaction...')
47+
transaction.sign(stellar_quest_keypair)
48+
response = server.submit_transaction(transaction)
49+
50+
print(f"This is the final response: {response}")
51+

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,13 @@ quest.
109109
* Challenge 8: Use SEP-0006 to acquire some MULT from testanchor.stellar.org
110110

111111
Your task today will be to use SEP-0006 to request a deposit of MULT issued by GDLD...FSMM from the testanchor.stellar.org endpoint.
112+
113+
-----
114+
115+
### Learn Level 1
116+
117+
* Challenge 1: Create an account on the Stellar network
118+
119+
In this quest, your challenge is to create an account by using the createAccount operation with the Quest Keypair located in the box on the right-hand side of this screen.
120+
121+

0 commit comments

Comments
 (0)