forked from critesjosh/ethereum-address-generator-js
-
Notifications
You must be signed in to change notification settings - Fork 186
/
index.html
91 lines (91 loc) · 3.7 KB
/
index.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Generating Ethereum Accounts</title>
<link href="https://fonts.googleapis.com/css?family=M+PLUS+Rounded+1c" rel="stylesheet">
<link rel="stylesheet" href="main.css">
<title>Generating ETH accounts</title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<h1>Generating Ethereum accounts and signing transactions in Javascript</h1>
<div id="app">
<div>
<div><button v-on:click="generateNew">Generate New Mnemonic</button></div>
Mnemonic: <textarea v-model="mnemonic"></textarea>
<p>**Note that in this demonstration application, this mnemonic will generate different sets of keys than
<a href="https://metamaks.io">Metamask</a>
or <a href="https://myetherwallet.com">My Ether Wallet.</a>**</p>
</div>
<div v-if="privKey !== ''">
<p>Private Key: {{privKey.toString('hex')}}</p>
<p>Public Key: {{pubKey.toString('hex')}}</p>
<p>Ethereum address: {{ETHaddress}}</p>
<button v-on:click="signSampleLegacyTx">Sign sample Legacy transaction</button>
<button v-on:click="signSampleEIP1559Tx">Sign sample EIP1559 transaction</button>
</div>
<div v-if="recoveredLegacyAddress !== ''">
<h3>Legacy Transaction</h3>
<code>
{ nonce: '0x00',
gasPrice: '0x09184e72a000',
gasLimit: '0x2710',
to: '0x31c1c0fec59ceb9cbe6ec474c31c1dc5b66555b6',
value: '0x10',
data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057',
chainId: 3 }
</code>
<br><br>
<div>
<code>Signed raw tx: {
nonce: '0x00',
gasPrice: '0x09184e72a000',
gasLimit: '0x2710',
to: '0x31c1c0fec59ceb9cbe6ec474c31c1dc5b66555b6',
value: '0x00',
data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057',
chainId: 3,
v: {{getHex(signedLegacySample.v)}},
r: {{getHex(signedLegacySample.r)}},
s: {{getHex(signedLegacySample.s)}}
}</code>
</div>
<p>Recovered address: {{recoveredLegacyAddress}}</p>
</div>
<div v-if="recoveredEIP1559Address !== ''">
<h3>EIP1559 Transaction</h3>
<code>
{ nonce: '0x00',
type: 2,
maxPriorityFeePerGas: '0x09184e72a000', // not an accurate price
maxFeePerGas: '0x09184e72a000', // not an accurate price
gasLimit: '0x2710',
to: '0x31c1c0fec59ceb9cbe6ec474c31c1dc5b66555b6',
value: '0x10',
data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057',
chainId: 3 }
</code>
<br><br>
<div>
<code>Signed raw EIP1559 tx: {
nonce: '0x00',
type: 2,
gasPrice: '0x09184e72a000',
maxPriorityFeePerGas: '0x09184e72a000',
maxFeePerGas: '0x09184e72a000',
to: '0x31c1c0fec59ceb9cbe6ec474c31c1dc5b66555b6',
value: '0x00',
data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057',
chainId: 3,
v: {{getHex(signedEIP1559Sample.v)}},
r: {{getHex(signedEIP1559Sample.r)}},
s: {{getHex(signedEIP1559Sample.s)}}
}</code>
</div>
<p>Recovered address: {{recoveredEIP1559Address}}</p>
</div>
</div>
</body>
<script src="./bundle.js"></script>
</html>