Skip to content

Potential precision loss with Number(value) in Tron transaction building #11228

@coderabbitai

Description

@coderabbitai

Issue Description

In packages/chain-adapters/src/tron/TronChainAdapter.ts around lines 219-225, the code uses Number(value) when building the transaction body for Tron transfers. This can cause precision loss for very large amounts that exceed Number.MAX_SAFE_INTEGER (~9 quadrillion).

While TRX has 6 decimals making this unlikely for normal transfers, large TRC20 token amounts could be affected.

Location

Current Code

body: JSON.stringify({
  owner_address: from,
  to_address: to,
  amount: Number(value),
  visible: true,
}),

Suggested Investigation

Verify whether the Tron API accepts string amounts, or if Number is required, document the limitation and add validation to ensure values don't exceed safe integer bounds.


Requested by @gomesalexandre

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions