You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The sendTrx and sendTrc10 methods in TronWeb (with TS) accept the amount argument as a JavaScript number, which can be unsafe due to the limitations of JavaScript's Number type. The maximum safe integer in JavaScript (Number.MAX_SAFE_INTEGER) is 9,007,199,254,740,991.
Specific Concerns: sendTrx Method:
The maximum value that can be safely passed to the amount parameter in sendTrx is 9,007,199,254.740992.
This value translates to nine billion seven million one hundred ninety-nine thousand two hundred fifty-four TRX and seven hundred forty thousand nine hundred ninety-two millionths.
However, the current TRX supply in MAINNET is 86,216,962,115 TRX, which translates to eighty-six billion two hundred sixteen million nine hundred sixty-two thousand one hundred fifteen TRX.
This is significantly higher than the maximum safe value for the sendTrx function, meaning transactions involving large amounts of TRX cannot be handled reliably.
TRC10 tokens can have a precision of up to 16 decimal places. When transferring large amounts of TRC10 tokens with high precision, the limitations of JavaScript's Number type can cause rounding errors or loss of accuracy.
Suggested Solution:
Change the amount argument type in sendTrx and sendTrc10 from number to string or BigInt to safely handle large and precise values.
Add validation and conversion mechanisms to ensure compatibility with the Tron blockchain's requirements for these amounts.
The text was updated successfully, but these errors were encountered:
tronweb version: 6.0.0
The sendTrx and sendTrc10 methods in TronWeb (with TS) accept the amount argument as a JavaScript number, which can be unsafe due to the limitations of JavaScript's Number type. The maximum safe integer in JavaScript (Number.MAX_SAFE_INTEGER) is 9,007,199,254,740,991.
Specific Concerns:
sendTrx Method:
The maximum value that can be safely passed to the amount parameter in sendTrx is 9,007,199,254.740992.
This value translates to nine billion seven million one hundred ninety-nine thousand two hundred fifty-four TRX and seven hundred forty thousand nine hundred ninety-two millionths.
However, the current TRX supply in MAINNET is 86,216,962,115 TRX, which translates to eighty-six billion two hundred sixteen million nine hundred sixty-two thousand one hundred fifteen TRX.
This is significantly higher than the maximum safe value for the sendTrx function, meaning transactions involving large amounts of TRX cannot be handled reliably.
FE:
sendTrc10:
TRC10 tokens can have a precision of up to 16 decimal places. When transferring large amounts of TRC10 tokens with high precision, the limitations of JavaScript's Number type can cause rounding errors or loss of accuracy.
Suggested Solution:
Change the amount argument type in sendTrx and sendTrc10 from number to string or BigInt to safely handle large and precise values.
Add validation and conversion mechanisms to ensure compatibility with the Tron blockchain's requirements for these amounts.
The text was updated successfully, but these errors were encountered: