-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSourcecode.html
More file actions
55 lines (36 loc) · 1.27 KB
/
Copy pathSourcecode.html
File metadata and controls
55 lines (36 loc) · 1.27 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Text Field and Button Example</title>
</head>
<body>
<form>
<label for="inputText">Enter SOL Token: </label>
<input type="text" id="inputText" name="inputText">
<button type="button" onclick="submitForm()">Submit</button>
</form>
<script src="https://unpkg.com/@solana/web3.js@latest/lib/index.iife.min.js"></script>
<script>
const { Connection, PublicKey} = solanaWeb3;
</script>
<script>
function submitForm() {
// transfer some solana to that address if user enters (---------insert your solana devnet id here---------)
var solanaPublicKey = document.getElementById("inputText").value;
//Copied code
// connection
const connection = new Connection("https://api.devnet.solana.com");
let publicKeyObject = new PublicKey (solanaPublicKey)
const fn = (async () => {
// 1e9 lamports = 10^9 lamports = 1 SOL
let txhash = await connection.requestAirdrop(publicKeyObject, 1e9);
console.log(`txhash: ${txhash}`);
// end of copied
const inputText = document.getElementById("inputText").value;
alert("You entered: " + inputText);
});
fn();
}
</script>
</body>
</html>