-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfee-bump.js
61 lines (51 loc) · 1.49 KB
/
fee-bump.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
49
50
51
52
53
54
55
56
57
58
59
60
61
import {
Asset,
BASE_FEE,
Horizon,
Keypair,
Networks,
Operation,
TransactionBuilder,
} from "stellar-sdk";
const server = new Horizon.Server("https://horizon-testnet.stellar.org");
(async () => {
const sourceKeypair = Keypair.fromSecret(
"SAC4R57TC5MUT5U77WE5BB2RAM6XU5QVLQBIIY4YU3EP2SJPEDGZRQ3F"
);
const destinationKeypair = Keypair.fromSecret(
"SCQ5DB7BBEXBZQVOUEID7LLILJGOVXSNH2YOJIWQYR6XMMXBM43LYVHZ"
);
const feeKeypair = Keypair.fromSecret(
"SC73C2LSEHM2PPJ22E66PVCXZYIA36XISHWXIA5W5OAW2ITLB5OBR47H"
);
const sourceAccount = await server.loadAccount(sourceKeypair.publicKey());
const innerTransaction = new TransactionBuilder(sourceAccount, {
fee: BASE_FEE,
networkPassphrase: Networks.TESTNET,
})
.addOperation(
Operation.payment({
amount: "200",
asset: Asset.native(),
destination: destinationKeypair.publicKey(),
})
)
.setTimeout(30)
.build();
innerTransaction.sign(sourceKeypair);
console.log("Inner transaction has been signed correctly");
const feeBumpTransaction = new TransactionBuilder.buildFeeBumpTransaction(
feeKeypair,
BASE_FEE,
innerTransaction,
Networks.TESTNET
);
feeBumpTransaction.sign(feeKeypair);
console.log("Fee bump transaction has been signed correctly");
try {
const submit = await server.submitTransaction(feeBumpTransaction);
console.log(`Submitted transaction: ${submit.result_xdr}`);
} catch (error) {
console.error(error);
}
})();