fix: ensure precise HBAR to Wei conversion by formatting numeric amounts as strings.
This commit is contained in:
parent
e01f42778d
commit
eac1457f0a
@ -333,7 +333,9 @@
|
|||||||
const nonce = await web3.eth.getTransactionCount(fromAddress, 'pending');
|
const nonce = await web3.eth.getTransactionCount(fromAddress, 'pending');
|
||||||
|
|
||||||
// Convert HBAR to Wei (1 HBAR = 10^18 Wei in EVM context)
|
// Convert HBAR to Wei (1 HBAR = 10^18 Wei in EVM context)
|
||||||
const amountInWei = web3.utils.toWei(amount.toString(), 'ether');
|
|
||||||
|
const amountString = typeof amount === 'number' ? amount.toFixed(18) : amount.toString();
|
||||||
|
const amountInWei = web3.utils.toWei(amountString, 'ether');
|
||||||
|
|
||||||
// Prepare transaction object for gas estimation
|
// Prepare transaction object for gas estimation
|
||||||
let gasLimit = 21000; // Default for existing accounts
|
let gasLimit = 21000; // Default for existing accounts
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user