I’m trying to analyze the transaction of this contract, but sometimes when I try to convert from wei to ether value of tokens I got comma in different position than expected. This is how I proceed:
1)Fetch all transactions from Moralis API.
2)Take the ABI of the contract, and from the tx_input I decode the transaction in this way:
contract = web3.eth.contract(address=Web3.toChecksumAddress(tx["to_address"]), abi=abi['result']) func_obj, func_params = contract.decode_function_input(tx["input"])
- I get the wei value of token sent to the contract selecting the
func_paramswith the following path
func_params['amountsInOutMarketMaxFee']in the case of
Everything is fine unless in some case when I try to convert some numbers from wei to ether value I got different numbers than seen in explorers. For example when I fetch the following transaction from the contract above: https://polygonscan.com/tx/0xa2d59655b42f947dc619f456553476f7b5929ef1ec6da229409dde9d6fb9629d I got the following value:
That’s the same amount you get from the decoded input in the blockchain explorer page. But if I try to convert the amount with the following function:
I got 13.04 while on the blockchain explorer the amount is 1.304 Why is there this lack? Thank you for the answers.