Utils

Usage

class Utils()

Utility functions for trtl-py.

  1. generate_pid()

Generates a random payment ID.

NO INPUT

Return type : str

#Expected Output
ca457fe7d0bec76f81f725187f5cca50bbbabdc72f82feab947dfbda6ab7c383

2. format_amount(amount)

Returns amount converted into user-friendly format. (Shells => TRTL)

Argument

Mandatory

Description

Data Type

amount

Yes

The amount in shells to be converted into user-friendly format.

int

Return type : float

#Expected Output
10.0

3. parse_amount(amount)

Returns user-friendly amount formatted into amount for internal representation. (TRTL => Shells)

Argument

Mandatory

Description

Data Type

amount

Yes

The amount in TRTL to convert into shells.

int / float

Return type : int

#Expected Output
10000

4. hexify(data)

Converts binary data into its hexadecimal representation and return it's decoded string. This can be used in the `extra` field when sending a transaction.

Argument

Mandatory

Description

Data Type

data

Yes

The binary data whose decoded string is to be returned.

str

Return type : str

#Expected Output
'537570657220736563726574206d657373616765'