Skip to main content

Quickstart

Issue your first asset on the Stellar network in one, single transaction!

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}`);