-
Notifications
You must be signed in to change notification settings - Fork 67
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 to Get Transaction Record Receiver #220
Comments
Currently, we can think user have two kinds of asset - native asset and NEO vm contract asset. Native AssetOntology uses a dual token (ONT and ONG) model. ONT is the coin and can be used for staking in consensus, whereas ONG is the utility token used for on-chain services. Since the Ontology MainNet went live on June 30th, 2018, MainNet ONT has started to release ONG periodically. Both ONT and ONG are based on native vm contract, you can find the code in here and here. So, If you want to get the token's receiver, you need to do by following step:
String txHash = "f3c0f8bfb11531f534ac832b20865c60ea6eb41d7371c38b9a1e006871c56087";
String txJson = (String) ontSdk.getConnect().getTransactionJson(txHash);
JSONObject tx = JSON.parseObject(txJson);
System.out.println(tx.getString("Payload"));
$ python
>>> from ontology.utils.contract_data import ContractDataParser
>>> ContractDataParser.to_int('14')
20
>>> ContractDataParser.to_b58_address('46b1a18af6b7c9f8a4602f9f73eeb3030f0c29b7')
'ANDfjwrUroaVtvBguDtrWKRMyxFwvVwnZD'
>>> ContractDataParser.to_int('14')
20
>>> ContractDataParser.to_b58_address('feec06b79ed299ea06fcb94abac41aaf3ead7658')
'Af1n2cZHhMZumNqKgw9sfCNoTWu9de4NDn'
>>> ContractDataParser.to_int('08')
8
>>> ContractDataParser.to_utf8_str('7472616e73666572')
'transfer'
>>> ContractDataParser.op_code_to_int('51')
1
>>> ContractDataParser.to_int('16')
22
>>> ContractDataParser.to_utf8_str('4f6e746f6c6f67792e4e61746976652e496e766f6b65')
'Ontology.Native.Invoke'
>>> len('Ontology.Native.Invoke')
22 For more information, you can visit here. Neo Vm Contract AssetAll the Neo Vm contract assets are based on smart contract. If you want to get the token's receiver, you need to do by following step:
String txHash = "f3c0f8bfb11531f534ac832b20865c60ea6eb41d7371c38b9a1e006871c56087";
String txJson = (String) ontSdk.getConnect().getTransactionJson(txHash);
JSONObject tx = JSON.parseObject(txJson);
System.out.println(tx.getString("Payload"));
OEP-4, OEP-5 and OEP5 are more easier to decode, you can read the code structure in here. $ python
>>> from ontology.utils.contract_data import ContractDataParser
>>> ContractDataParser.op_code_to_int('5a')
10
>>> ContractDataParser.to_int('14')
20
>>> ContractDataParser.to_b58_address('feec06b79ed299ea06fcb94abac41aaf3ead7658')
'Af1n2cZHhMZumNqKgw9sfCNoTWu9de4NDn'
>>> ContractDataParser.to_b58_address('46b1a18af6b7c9f8a4602f9f73eeb3030f0c29b7')
'ANDfjwrUroaVtvBguDtrWKRMyxFwvVwnZD'
>>> ContractDataParser.op_code_to_int('53')
3
>>> ContractDataParser.to_int('08')
8
>>> ContractDataParser.to_reserve_hex_str('e94e5c8c35a9979e41ff712b9e9d3e7482b6db1d')
'1ddbb682743e9d9e2b71ff419e97a9358c5c4ee9' |
Transaction Bean No recipient
How to Get Recipient According to TXHASH
The text was updated successfully, but these errors were encountered: