-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path1_changeTrust.js
46 lines (37 loc) · 966 Bytes
/
1_changeTrust.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
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 txOptions = {
fee: await server.fetchBaseFee(),
networkPassphrase: Networks.TESTNET
};
const distributorAccount = await server.loadAccount(distributor.publicKey);
const breadAsset = new Asset("BRD", issuer.publicKey);
const changeTrustOpts = {
asset: breadAsset,
limit: "1000"
};
const transaction = new TransactionBuilder(distributorAccount, txOptions)
.addOperation(Operation.changeTrust(changeTrustOpts))
.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;
});