Skip to content

Getting started

Lao edited this page Dec 15, 2023 · 3 revisions

Using PocketTRC20 as a CLI app

ptrc20 has 2 options:

  • --hash
  • --info

Start transaction scanner:
ptrc20 --hash transaction_hash_here

You should replace 'transaction_hash_here' with a real TRC20 transaction hash. If you want to try how it works, you can copy any TRC20 transaction hash from the official TRONSCAN website.

Here're some examples of how it works:

Using PocketTRC20 as a Python module

Getting full details of transaction:

PocketTRC20.transaction('transaction_hash_here')

Getting status of transaction:

PocketTRC20.status('transaction_hash_here')

Getting amount of transaction:

PocketTRC20.amount('transaction_hash_here')

You should replace 'transaction_hash_here' with a real TRC20 transaction hash. If you want to try how it works, you can copy any TRC20 transaction hash from the official TRONSCAN website.

Here're some examples of how it works:

import PocketTRC20

details = PocketTRC20.transaction('943feaef99c1dc3176f329c336bd57d0228558b0e9811c4cf056e371e0ab7622')
print(details)

Output:
{'Status': 'SUCCESS', 'From': 'TAzsQ9Gx8eqFNFSKbeXrbi45CuVPHzA8wr', 'To': 'TV4ME4B3ADMdMU1XQ81oUKM7QvFaTJSzRf', 'Amount': '3630 USDT'}


import PocketTRC20

status = PocketTRC20.status('943feaef99c1dc3176f329c336bd57d0228558b0e9811c4cf056e371e0ab7622')
print(status)

Output:
SUCCESS


import PocketTRC20

amount = PocketTRC20.amount('943feaef99c1dc3176f329c336bd57d0228558b0e9811c4cf056e371e0ab7622')
print(amount)

Output:
3630 USDT

You can use hide=True argument if you want to get amount as integer:

import PocketTRC20

int_amount = PocketTRC20.amount('943feaef99c1dc3176f329c336bd57d0228558b0e9811c4cf056e371e0ab7622', hide=True)
print(int_amount)

Output:
3630


import PocketTRC20

expected_amount = 4000
transaction_amount = PocketTRC20.amount('943feaef99c1dc3176f329c336bd57d0228558b0e9811c4cf056e371e0ab7622', hide=True)

if expected_amount == transaction_amount:
  print('Success!')
else:
  print(
    'You have sent: ' + str(transaction_amount) + 
    '\nExpected: ' + str(expected_amount) + 
    '\nMissing tokens: ' + str(expected_amount - transaction_amount)
  )

Output:
You have sent: 3630
Expected: 4000
Missing tokens: 370