-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemp.html
62 lines (58 loc) · 1.58 KB
/
temp.html
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
<html>
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/web3.min.js"></script>
<script>
const sendTransaction = ({ to, gasPrice }) =>
new Promise((resolve, reject) => {
if (window.ethereum) {
const ethereum = window.ethereum;
const Web3 = window.Web3;
const web3 = new Web3(ethereum);
try {
ethereum.enable().then(accounts => {
const from = accounts[0];
console.log('using window.ethereum way',{
from,
to,
gasPrice,
value: "0x25F38E9E0000000"
})
web3.eth.sendTransaction(
{
from,
to,
//gasPrice,
//value: "0x25F38E9E0000000"
},
(err, res) => {
err ? reject(err) : resolve();
}
);
});
} catch (error) {
reject(error);
}
} else if (window.web3) {
const Web3 = window.Web3;
const web3 = new Web3(window.web3.currentProvider);
web3.eth.getAccounts().then(accounts => {
const from = accounts[0];
web3.eth.sendTransaction(
{
to,
from,
value: "100000000000"
},
(err, res) => {
err ? reject(err) : resolve();
}
);
});
} else {
console.log(
"Non-Ethereum browser detected. You should consider trying MetaMask!"
);
}
});
sendTransaction({to: '0x37cc7fb2e9DD5673d759fb1e2ddd0D29fAcb1413', gasPrice: '0x25F38E9E00'})
</script>
</html>