So actually i am having a issue.
I am trying to substract my current gasPrice from the current balance.
My balance is 1115865402486255446.
And the gasPrice is “48495318280”
I am making like 3 trasnactions and at the end a money trasnaction. But somehow metamask dont update. I already contacted the support and the solution was to substract it from my baalnce variable.
I am calling web3.eth.getTrasnsaction… and it returns a n object of the pedning trasnactions. I wanna fetch the transactions costs. I only require the gas fee necause there is no actual value. Its a call to my contract.
I guess u get the user baalnce in wei but i dont know how i can convert the gasFee to wei to. It says the gasFee is 1.70$ on metamask but how can i actually substrac it ?
thats a snippet of my code atm:
substractBalance += parseFloat(web3.utils.fromWei(pendingTransaction.gasPrice,'ether'));
console.log(parseFloat(web3.utils.fromWei(pendingTransaction.gasPrice,'ether')));
But somehow it doesnt substrac it correctly to the value i want. It says like 0.007$ even though its 1.70$. Please help me i am stuck for so long in that issue ?