New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How does the method determine the transaction type of 'approved' or 'transferred'? #111
Comments
@gedowangvs97 For Tronscan, 'approved' or 'transferred' is only a description of the contract method called in this transaction. For the method specified by TRC standard, Tronscan will translate it to more readable statement with more obvious key information, for example, for approve transaction. About how to determine the transaction type of the transaction which get through "getTransactionById" API, "raw_data.contract[0].type is the transaction type. For the type of triggerSmartContract, the invocation method can be obtained through "raw_data. contract[0]. parameter. value. data" filed, and the first 4 bytes is the method, we need to decode the data, please refer to the guide. |
public static final String APPROVE_FUNC_ID_BY_KECCAK256 =
Hex.toHexString(
new Keccak.Digest256().digest("approve(address,uint256)".getBytes())
).substring(0, 8); String data = Hex.toHexString(triggerSmartContract.getData().toByteArray());
if (!TronConstants.APPROVE_FUNC_ID_BY_KECCAK256 .equals(funcId)) {
...
} |
How to get this fundId field? if (!TronConstants.APPROVE_FUNC_ID_BY_KECCAK256 .equals(funcId)) { |
https://developers.tron.network/docs/parameter-encoding-and-decoding String funcId = data.substring(0, 8); |
approve TxId: String funcId = data.substring(0, 8); public static final String APPROVE_FUNC_ID_BY_KECCAK256 = Why are the above two values different? |
There should be no any space in the function method. Remove all the spaces and it will be "approve(address,uint256)" |
Yes, I made a stupid mistake and have corrected it. |
“getTransactionById” How does the method determine the transaction type of 'approved' or 'transferred'? Or is there any way to tell the difference?
Demo TxId:
232a8da14f777c360ec398568ae828852a60d64507fb482b118c922b1cb8cdbe
42eb88afe779f8e639cc758f688b192f9f2988db69a6f0c87e3282347b3b7635
The text was updated successfully, but these errors were encountered: