-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path2_createAsset.js
47 lines (38 loc) · 977 Bytes
/
2_createAsset.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const {
accounts: { issuer, distributor },
serverUrl
} = require("./config.json");
const {
Server,
Networks,
Asset,
TransactionBuilder,
Operation,
Keypair
} = require("stellar-sdk");
const server = new Server(serverUrl);
const main = async () => {
const issuingAccount = await server.loadAccount(issuer.publicKey);
const breadAsset = new Asset("BRD", issuer.publicKey);
const txOptions = {
fee: await server.fetchBaseFee(),
networkPassphrase: Networks.TESTNET
};
const paymentOpts = {
asset: breadAsset,
destination: distributor.publicKey,
amount: "1000"
};
const transaction = new TransactionBuilder(issuingAccount, txOptions)
.addOperation(Operation.payment(paymentOpts))
.setTimeout(0)
.build();
transaction.sign(Keypair.fromSecret(issuer.secret));
await server.submitTransaction(transaction);
};
main()
.then(() => console.log("ok"))
.catch(e => {
console.log("Meh", e);
throw e;
});