-
Notifications
You must be signed in to change notification settings - Fork 1
/
page7.js
86 lines (75 loc) · 2.96 KB
/
page7.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// script.js
document.addEventListener("DOMContentLoaded", function () {
// Add click event listeners to buttons
const buttons = document.querySelectorAll(".review-button, .add-button, .exchange-button, .transfer-button");
buttons.forEach(button => {
button.addEventListener("click", () => {
alert("Button clicked: " + button.textContent);
});
});
// Example functionality for toggling active graph button
const graphButtons = document.querySelectorAll(".graph-btn");
graphButtons.forEach(button => {
button.addEventListener("click", () => {
graphButtons.forEach(btn => btn.classList.remove("active"));
button.classList.add("active");
});
const sourceSecretKey = 'SA...YOUR_SECRET_KEY_HERE';
const destinationId = 'GA...DESTINATION_ACCOUNT_ID_HERE';
const amount = '10.0'; // amount of XLM to send
const sourceKeypair = StellarSdk.Keypair.fromSecret(sourceSecretKey);
const sourcePublicKey = sourceKeypair.publicKey();
server.loadAccount(sourcePublicKey)
.then(account => {
const transaction = new StellarSdk.TransactionBuilder(account, {
fee: StellarSdk.BASE_FEE,
networkPassphrase: StellarSdk.Networks.PUBLIC
})
.addOperation(StellarSdk.Operation.payment({
destination: destinationId,
asset: StellarSdk.Asset.native(),
amount: amount
}))
.setTimeout(30)
.build();
transaction.sign(sourceKeypair);
return server.submitTransaction(transaction);
})
.then(result => {
console.log('Transaction successful:', result);
})
.catch(error => {
console.error('Transaction failed:', error);
const sourceSecretKey = 'SA...YOUR_SECRET_KEY_HERE';
const destinationId = 'GA...DESTINATION_ACCOUNT_ID_HERE';
const amount = '10.0'; // amount of XLM to send
const sourceKeypair = StellarSdk.Keypair.fromSecret(sourceSecretKey);
const sourcePublicKey = sourceKeypair.publicKey();
server.loadAccount(sourcePublicKey)
.then(account => {
const transaction = new StellarSdk.TransactionBuilder(account, {
fee: StellarSdk.BASE_FEE,
networkPassphrase: StellarSdk.Networks.PUBLIC
})
.addOperation(StellarSdk.Operation.payment({
destination: destinationId,
asset: StellarSdk.Asset.native(),
amount: amount
}))
.setTimeout(30)
.build();
transaction.sign(sourceKeypair);
return server.submitTransaction(transaction);
})
.then(result => {
console.log('Transaction successful:', result);
})
.catch(error => {
console.error('Transaction failed:', error);
});
const response = await.fetch(`https://friendbot.stellar.org?addr=${publicKey}`);
const result = await.response.json();
console.log(result); // Check if the funding was successful
});
});
});