Quickstart
Issue your first asset on the Stellar network in one, single transaction!
- JavaScript
- Python
const {
Keypair,
Horizon,
TransactionBuilder,
Networks,
Operation,
Asset,
BASE_FEE,
} = require("@stellar/stellar-sdk");
// 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");
const account = await server.loadAccount(issuerKeypair.publicKey());
const abcAsset = new Asset("ABC", issuerKeypair.publicKey());
const transaction = new TransactionBuilder(account, {
fee: BASE_FEE,
networkPassphrase: Networks.TESTNET,
})
.addOperation(
Operation.changeTrust({
asset: abcAsset,
source: destinationKeypair,
}),
)
.addOperation(
Operation.payment({
destination: destinationKeypair.publicKey(),
asset: abcAsset,
amount: "100",
}),
)
.setTimeout(30)
.build();
transaction.sign(issuerKeypair, destinationKeypair);
const res = await server.submitTransaction(transaction);
console.log(`Transaction response: ${res}`);
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
issuer_keypair = Keypair.random()
destination_keypair = Keypair.random()
server = Server('https://horizon-testnet.stellar.org')
account = server.load_account(issuer_keypair.public_key)
abc_asset = Asset('ABC', issuer_keypair.public_key)
transaction = (
TransactionBuilder(
source_account=account,
network_passphrase=Network.TESTNET_NETWORK_PASSPHRASE,
base_fee=100,
)
.append_change_trust_op(
asset=abc_asset,
source=destination_keypair.public_key,
)
.append_payment_op(
destination=destination_keypair.public_key,
amount='100',
asset=abc_asset,
)
.set_timeout(30)
.build()
)
transaction.sign(issuer_keypair)
transaction.sign(destination_keypair)
res = server.submit_transaction(transaction)
print(f"Transaction response: {res}")