I know that I can get the weight of a transaction by converting the transaction hash into trits and count the trailing number of zeros.

import iota

def get_transaction_weight(transaction_hash):
     transaction_hash_trits = iota.TryteString.as_trits(iota.TransactionHash(transaction_hash))
     transaction_hash_trits_string = ''.join(map(str, transaction_hash_trits))
     transaction_hash_trits_without_trailing_zeros_string = transaction_hash_trits_string.rstrip('0')
     transaction_weight = len(transaction_hash_trits_string) - len(transaction_hash_trits_without_trailing_zeros_string)
     print('Weight: %d (Transaction: %s)' % (transaction_weight, transaction_hash))



In the IOTA whitepaper (page 5) the concepts of cumulative weight, score, depth and height of a transaction are introduced. Is this information available in practice or are these primarily theoretical concepts? One could walk the tangle. But that would take a lot of time, as one would need to walk every possible path from a transaction towards the genesis to get its score and height (as one needs to find the longest path to the genesis). Getting the cumulative weight and depth of a particular transaction is even more difficult as one would need to find all tips that directly or indirectly confirm this transaction (again to find the longest path to a tip).

So is there a way of getting any/all of cumulative weight, score, height and depth from the IOTA api for a particular transaction? Will there ever be?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.