-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransaction-loggers.js
27 lines (24 loc) · 1.25 KB
/
transaction-loggers.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
import webThree from 'web3'
const unit = require('ethjs-unit');
export function gasPriceInEther (gasPrice, web3) {
const s1 = gasPrice * 21000
const totalEther = web3.fromWei(s1.toString(), "ether")
console.log('\n# of ethere the gasPrice costs - web3 ', totalEther)
const s2 = 20
const s3 = web3.toWei(s2.toString(), "gwei") * 21000
const totalEtherFromVideo = web3.fromWei(s3.toString(), "ether")
console.log('# of ether the gasPrice costs - tutorial', totalEtherFromVideo)
}
export function rawTxData (inputs, rawTx) {
console.log('\nINPUTS TO RAW TRANSACTION\n', inputs)
console.log('\nRAW TRANSACTION\n', rawTx)
}
export function weiAmountBeingSent (ether) {
const value = ether
// console.log('wei - web3 PRE caluclation ')
const weiCalculated = unit.toWei(value.toString(),'ether') // value 0.003 ether is 3000000000000000 wei // WORKS
console.log('wei - web3 caluclation ', weiCalculated) // **TODO** logs <BN: aa87bee538000> instead of 3000000000000000
const weiEtherConverter = 3000000000000000 // https://etherconverter.online/ .003 ether is 3000000000000000 wei
console.log('wei - etherconverter.online calculation ', weiEtherConverter)
return weiCalculated
}