diff --git a/docs/tokens/quickstart.mdx b/docs/tokens/quickstart.mdx index 244763dda..b3690f92e 100644 --- a/docs/tokens/quickstart.mdx +++ b/docs/tokens/quickstart.mdx @@ -10,7 +10,7 @@ Issue your first asset on the Stellar network in **one, single transaction**! ```js -const { +import { Keypair, Horizon, TransactionBuilder, @@ -18,14 +18,21 @@ const { Operation, Asset, BASE_FEE, -} = require("@stellar/stellar-sdk"); +} from "stellar-sdk"; + +const horizonUrl = "https://horizon-testnet.stellar.org"; +const friendbotUrl = "https://friendbot.stellar.org"; -// Don't forget to fund these accounts, somehow. Have you met Friendbot? -// https://developers.stellar.org/docs/tutorials/create-account#create-account const issuerKeypair = Keypair.random(); const destinationKeypair = Keypair.random(); -const server = new Horizon.Server("https://horizon-testnet.stellar.org"); +console.log(`issuer keys:\n${issuerKeypair.publicKey()}\n${issuerKeypair.secret()}\n`); +console.log(`destination account keys:\n${issuerKeypair.publicKey()}\n${issuerKeypair.secret()}\n`); + +await fetch(friendbotUrl + `?addr=${issuerKeypair.publicKey()}`); +await fetch(friendbotUrl + `?addr=${destinationKeypair.publicKey()}`); + +const server = new Horizon.Server(horizonUrl); const account = await server.loadAccount(issuerKeypair.publicKey()); const abcAsset = new Asset("ABC", issuerKeypair.publicKey()); @@ -36,7 +43,7 @@ const transaction = new TransactionBuilder(account, { .addOperation( Operation.changeTrust({ asset: abcAsset, - source: destinationKeypair, + source: destinationKeypair.publicKey(), }), ) .addOperation( @@ -51,17 +58,25 @@ const transaction = new TransactionBuilder(account, { transaction.sign(issuerKeypair, destinationKeypair); const res = await server.submitTransaction(transaction); -console.log(`Transaction response: ${res}`); +console.log(`transaction hash:\n${res.hash}`); ``` ```python +import requests from stellar_sdk import Asset, Keypair, Network, Server, TransactionBuilder -## Don't forget to fund these accounts, somehow. Have you met Friendbot? -## https://developers.stellar.org/docs/tutorials/create-account#create-account +horion_url = "https://horizon-testnet.stellar.org" +friendbot_url = "https://friendbot.stellar.org" + issuer_keypair = Keypair.random() destination_keypair = Keypair.random() +print(f"issuer keys:\n{issuer_keypair.public_key}\n{issuer_keypair.secret}\n") +print(f"issuer keys:\n{destination_keypair.public_key}\n{destination_keypair.secret}\n") + +requests.get(f"{friendbot_url}?addr={issuer_keypair.public_key}") +requests.get(f"{friendbot_url}?addr={destination_keypair.public_key}") + server = Server('https://horizon-testnet.stellar.org') account = server.load_account(issuer_keypair.public_key) abc_asset = Asset('ABC', issuer_keypair.public_key) @@ -89,7 +104,7 @@ transaction.sign(issuer_keypair) transaction.sign(destination_keypair) res = server.submit_transaction(transaction) -print(f"Transaction response: {res}") +print(f"Transaction hash:\n{res['hash']}") ```