Skip to content

Commit

Permalink
make asset issuance quickstart examples work
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeUrban committed Sep 25, 2024
1 parent 254e557 commit 775e1a1
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions docs/tokens/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,29 @@ Issue your first asset on the Stellar network in **one, single transaction**!
<CodeExample>

```js
const {
import {
Keypair,
Horizon,
TransactionBuilder,
Networks,
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());

Expand All @@ -36,7 +43,7 @@ const transaction = new TransactionBuilder(account, {
.addOperation(
Operation.changeTrust({
asset: abcAsset,
source: destinationKeypair,
source: destinationKeypair.publicKey(),
}),
)
.addOperation(
Expand All @@ -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)
Expand Down Expand Up @@ -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']}")
```

</CodeExample>

0 comments on commit 775e1a1

Please sign in to comment.