-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.ts
32 lines (26 loc) · 894 Bytes
/
index.ts
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
import { PublicKey, SystemProgram, Transaction } from "@solana/web3.js";
const button = document.getElementById("submit")!;
const originalText = button.textContent;
button.addEventListener("click", async () => {
button.setAttribute("disabled", "true");
button.textContent = "sending...";
const transferTransaction = new Transaction().add(
SystemProgram.transfer({
fromPubkey: window.xnft.solana.publicKey,
toPubkey: new PublicKey("So11111111111111111111111111111111111111112"),
lamports: 1,
})
);
try {
const sig = await window.xnft.solana.sendAndConfirm(transferTransaction);
button.textContent = "sent, tx: " + sig;
} catch (err) {
console.error(err);
button.textContent = "tx error";
}
setTimeout(resetButton, 1000);
});
const resetButton = () => {
button.removeAttribute("disabled");
button.textContent = originalText;
};