-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayment.js
44 lines (37 loc) · 1.06 KB
/
payment.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
const {
Networks,
Server,
TransactionBuilder,
Operation,
Keypair,
Asset
} = require("stellar-sdk");
const { ade, emeka } = require("./accounts");
const server = new Server("https://horizon-testnet.stellar.org");
const adePaymentToemeka = async () => {
const txOptions = {
fee: await server.fetchBaseFee(),
networkPassphrase: Networks.TESTNET
};
const adeAccount = await server.loadAccount(ade.publicKey);
const paymentTx = new TransactionBuilder(adeAccount, txOptions)
.addOperation(
Operation.payment({
amount: "1000",
asset: Asset.native(),
destination: emeka.publicKey
})
)
.setTimeout(0)
.build();
paymentTx.sign(Keypair.fromSecret(ade.secret));
paymentTx.sign(Keypair.fromSecret(emeka.secret));
await server.submitTransaction(paymentTx);
};
adePaymentToemeka()
.then(() => {
console.log("Transaction complete");
})
.catch(e => {
console.log(e.response.data.extras.result_codes);
});