-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendtoken.js
82 lines (80 loc) · 3.17 KB
/
sendtoken.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
async function Click1() {
try {
let z=document.getElementById('token-amt').value;
const accounts = await ethereum.request({
method: "eth_requestAccounts",
});
let s = "0x" + (z*1000000000000000000).toString(16);
// document.getElementById('address_show').innerText=accounts;
const txHash = await ethereum.request({
method: "eth_sendTransaction",
params: [
{
from: accounts[0], // The user's active address.
to: "0x2f318C334780961FB129D2a6c30D0763d9a5C970", // Required except during contract publications.
value: s, // Only required to send ether to the recipient from the initiating external account.
gasPrice: "0x09184e72a000", // Customizable by the user during MetaMask confirmation.
gas: "0x2710", // Customizable by the user during MetaMask confirmation.
},
],
});
console.log(txHash);
} catch (error) {
console.error(error);
}
}
// document
// .getElementById("sendtokenss")
// .addEventListener("click", async (event) => {
// try {
// alert("10");
// const accounts = await ethereum.request({
// method: "eth_requestAccounts",
// });
// alert("5");
// let s = "0x" + (3000000000000000000).toString(16);
// const txHash = await ethereum.request({
// method: "eth_sendTransaction",
// params: [
// {
// from: accounts[0], // The user's active address.
// to: "0x2f318C334780961FB129D2a6c30D0763d9a5C970", // Required except during contract publications.
// value: s, // Only required to send ether to the recipient from the initiating external account.
// gasPrice: "0x09184e72a000", // Customizable by the user during MetaMask confirmation.
// gas: "0x2710", // Customizable by the user during MetaMask confirmation.
// },
// ],
// });
// console.log(txHash);
// } catch (error) {
// console.error(error);
// }
// });
// document.addEventListener("DOMContentLoaded", () => {
// const button = document.getElementById("sendtokenss");
// button.addEventListener("click", async (event) => {
// try {
// const accounts = await ethereum.request({
// method: "eth_requestAccounts"
// });
// alert(accounts);
// document.getElementById('address_show').innerText=accounts;
// let s = "0x" + (3000000000000000000).toString(16);
// const txHash = await ethereum.request({
// method: "eth_sendTransaction",
// params: [
// {
// from: accounts, // The user's active address.
// to: "0x946Cdad10f564C4e428e19E8A3B727511980ee45", // Required except during contract publications.
// value: s, // Only required to send ether to the recipient from the initiating external account.
// gasPrice: "0x09184e72a000", // Customizable by the user during MetaMask confirmation.
// gas: "0x2710", // Customizable by the user during MetaMask confirmation.
// },
// ],
// });
// console.log(txHash);
// } catch (error) {
// console.error(error);
// }
// });
// });