-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblockchain.js
More file actions
38 lines (31 loc) · 1.17 KB
/
blockchain.js
File metadata and controls
38 lines (31 loc) · 1.17 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
// BEACUSE I AM USING GANACHE IN COMMAND LINE
const ethers = require("ethers")
const fs = require("fs-extra")
require("dotenv").config()
async function main() {
const provider = new ethers.providers.JsonRpcProvider(process.env.RPC_URL)
const encryptedJson = fs.readFileSync("./.encryptedKey.json", "utf8")
let wallet = new ethers.Wallet.fromEncryptedJsonSync(
encryptedJson,
process.env.PRIVATE_KEY_PASSWORD
)
wallet = await wallet.connect(provider)
// const balance = await wallet.getBalance();
// const balanceInEth = ethers.utils.formatEther(balance);
// console.log(balanceInEth);
// const nonce = await wallet.getTransactionCount();
// console.log(nonce);
// const gasPrice = await provider.getGasPrice();
// const gasPriceInWei = ethers.utils.formatUnits(gasPrice, 'wei');
// console.log(gasPriceInWei);
const transactionRecipt = await provider.getTransactionReceipt(
"0x514e6c011c1a03f64b3ec72a7042e107f6d0ad70da82da0fd38515008f1cd5af"
)
console.log(transactionRecipt)
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})