Yesterday, @steemit-market sent 20 STEEM to @steem2usdt because he/she wants to swap to USDT on Tron Blockchain (TRC-20), the status was showing “Pending Sent” in the Steem to USDT Swap Tool.
This isn’t normal – I took a look and investigated, and found out the invoke of API triggerSmartContract fails and says “Numeric Underflow” (Exception) see below
1 2 3 4 5 6 7 8 9 10 11 | const tx = await tronWeb.transactionBuilder.triggerSmartContract( CONTRACT, 'transfer(address,uint256)', options, [{ type: 'address', value: toAddress }, { type: 'uint256', value: parseFloat(amount * 1000000) }], tronWeb.address.toHex(fromAddress) ); |
const tx = await tronWeb.transactionBuilder.triggerSmartContract( CONTRACT, 'transfer(address,uint256)', options, [{ type: 'address', value: toAddress }, { type: 'uint256', value: parseFloat(amount * 1000000) }], tronWeb.address.toHex(fromAddress) );
The triggerSmartContract method is used to trigger a smart contract on Tron Blockchain e.g. TRC-20. The TRC-20 USDT is a smart contract aka token, and we need to trigger the contract’s method transfer in order to send USDT tokens from one address to another.
The USDT transaction was not showing on the tronscan (which is a Tron Blockchain Explorer) so it means the transaction fails locally and not yet pushed to the chain.
The problem is that the amount due to floating precision cannot be safely represented in the current type. The “parseFloat” function is causing the problem (Numeric Underflow Exception) here. After changing it to parseInt, the fund was safely sent out to the destination wallet address (Tron).
parseFloat method returns a float and parseInt returns a whole of integer. This is absolutely fine here because for example: 4.184999999 times 1000000 to convert to the SUN unit is 4184999.9999 which causes the underflow issue – but if we use parseInt, it will be 4184999 – or we can use the Math.round which rounds up to 41185000 and that is acceptable as well.
Robustness of the Swap Tool
This incident shows the correctness of the tool – only mark the status to “Sent” when the fund has been sent. The transactions on the steem blockchain are immutable database records which we can easily scan or lookup, so are the ones on the Tron Blockchain.
Tron Blockchain Posts
Here are some popular posts regarding the Tron Blockchain:- Beware of the Malicious Transactions on TRON Blockchain
- NodeJs Function to Check if a Tron Wallet Address is Valid and Activated
- Introduction to Shielded Contracts on Blockchain (EVM, TVM)
- Passive Income: Staking TRX on Tron Blockchain and Earn Voting Rewards (4.8% APR)
- TRON Blockchain: How to Send the USDT (TRC-20) Transacton using Python tronpy?
- How to Get Balance of TRX or USDT/USDD/USDC (TRC-20) Smart Contract Tokens on TRON Blockchain?
- Function to Return the USDT/USDD/USDC Contract Address on Tron Blockchain (Main Net, Nile, Shasta)
- How to Send/Transfer USDT/USDD/USDC on Tron Blockchain using Tronweb?
- Javascript Function to Send Trx on Tron Blockchain based on TronWeb
- How to Generate an Account on Tron Blockchain using Python SDK?
- How to Claim the Witness (Super Representative) Voting Rewards on Tron Blockchain using Node Js (Javascript)?
- Automate Freeze Balance on Tron Blockchain using NodeJs with TronWeb/TronGrid
- Python Tool of Base58 Decode Check
- TRON Blockchain: How to Check the Number of Peers the Tron Node is Connected to?
- TRON Blockchain: How to Check If a Node is synchronized and Fully Functional?
- How to Activate a TRON (TRX) Blockchain Wallet Address?
- Delayed Swap due to Numeric Underflow Bug by using Tron’s triggerSmartContract Method
Steem to the Moon🚀!
- You can rent Steem Power via rentsp!
- You can swap the TRON:TRX/USDT/USDD to STEEM via tron2steem!
- You can swap the STEEM/SBD to SOL (Solana) via steem2sol!
- You can swap the STEEM/SBD to ETH (Ethereum) via steem2eth!
- You can swap the STEEM/SBD to Tether USDT (TRC-20) via steem2usdt!
- You can swap the STEEM/SBD to TRX (TRON) via steem2trx!
- You can swap the STEEM/SBD to BTS (BitShares) via steem2bts!
- Register a free STEEM account at SteemYY!
- Steem Block Explorer
- ChatGPT/Steem Integration: You can type !ask command to invoke ChatGPT
- Steem Witness Table and API
- Other Steem Tools
–EOF (The Ultimate Computing & Technology Blog) —
loading...
Last Post: Teaching Kids Programming - Minimum Amount of Time to Fill Cups (Greedy Simulation Algorithm and Math)
Next Post: Teaching Kids Programming - Sum the Multiples in a Range using Venn Diagram (Math and Bruteforce Algorithm)