-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
38 lines (28 loc) · 1.01 KB
/
main.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
process.env.CTH = "1" // select cheapETH as network
const { Keychain } = require('ethereum-keychain')
// load private key file
const { readFileSync } = require('fs')
const pvtKey = readFileSync('./.private-key.txt').toString().trim()
if (!pvtKey) {
console.error("private key is empty - generate, backup and load a private key first")
process.exit(1)
}
// initialize keychain
wallet = new Keychain({ store: { "__ethereum-keychain_": pvtKey } })
// prints wallet address
wallet.info()
;(async () => {
// prints info fetched from the node
await wallet.netInfo()
// simplest example - send a test transaction to your address
// await wallet.sendTXSelf()
// full tx example:
const address = wallet.address // your address
const value = 1000000000000 // value in wei - minimal value that you can send (0.000001 cETH)
// send transaction
const txHash = await wallet.send({ to: address, value })
console.log("TX:", txHash)
// prints info after transaction
await wallet.netInfo()
process.exit()
})()