I'm trying to sign and broadcast ETH transaction, but it seems like I'm struggling to calculate the correct fee. Here's sample data I use to sign a transaction:
maxPriorityFeePerGas: 0x1
maxFeePerGas: 0xe0c1e0193ba0
gasLimit: 0x5208
to: 0x........................................
value: 0x17fd5b2c13bf40
data: 0x
Balance of the wallet: 0.006999615780748 ETH
If my calculation (and understanding) is correct, I should not pay more than 247123293060000 wei for the transaction (maxFeePerGas). The amount I'm trying to send is 6999615780748000 (value). Both together make 6999615800000000 wei (0.006999615780748 ETH) - the exact balance of my wallet. So, at least in theory, I should have enough to pay the transaction. And yet, when I try to broadcast it to the RPC it returns "insufficient funds for gas * price + value".
I've been playing with the fees and amount I send for ~a week now. Another error I've seen quite a few times is "tx fee (7.29 ether) exceeds the configured cap (1.00 ether)". This is what makes me believe my calculation is wrong. I'm passing all parameters as wei. Maybe this is where things go wrong?
It would be great if someone can find the mistake here. Many thanks in advance.