-
Notifications
You must be signed in to change notification settings - Fork 2
/
4_tokenDistribution.js
48 lines (39 loc) · 1.01 KB
/
4_tokenDistribution.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
48
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 distributorAccount = await server.loadAccount(distributor.publicKey);
const breadAsset = new Asset("BRD", issuer.publicKey);
const txOptions = {
fee: await server.fetchBaseFee(),
networkPassphrase: Networks.TESTNET
};
const manageSellOfferOpts = {
selling: breadAsset,
buying: Asset.native(),
amount: "1000",
price: "1.00000000"
};
const transaction = new TransactionBuilder(distributorAccount, txOptions)
.addOperation(Operation.manageSellOffer(manageSellOfferOpts))
.setTimeout(0)
.build();
transaction.sign(Keypair.fromSecret(distributor.secret));
await server.submitTransaction(transaction);
};
main()
.then(() => console.log("ok"))
.catch(e => {
console.log("Meh", e);
throw e;
});