The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

CryptoTron::GetAccount - Perl extension for use with the blockchain of the crypto coin Tron.

SYNOPSIS

  use CryptoTron::ParseAccount;

  # Initialise the variable $balance.
  my $balance = 0;

  # Set the JSON data.
  my $json_data = '{"balance": 1000000000, 
                    "frozen": [{"frozen_balance": 2000000000}],
                    "account_resource": {"frozen_balance_for_energy": {"frozen_balance": 300000000}}}';

  # Get the total balance.
  $balance = TotalBalance($json_data);
  print $balance;

  # Get the free balance.
  $balance = FreeBalance($json_data);
  print $balance;

  # Get the frozen balance.
  $balance = FrozenBalance($json_data);
  print $balance;

DESCRIPTION

The module consists of methods for parsing raw JSON data. The raw JSON data can come from the module CryptoTron::GetAccount or other sources, as long it is a valid JSON object.

A distinction is made between a freely available Tron amount and a frozen Tron amount. The frozen Tron amount differs in ENERGY and BANDWIDTH. The Tron amount of interest is output with a decimal point and has a maximum of 6 digits after the decimal point.

If the raw JSON data is malformed, an exception is captured silently. The resulting amount values will be set to zero.

METHODS

Methods implemented so far:

  TotalBalance()

  FreeBalance()

  FrozenBalance()

  CreateTime()

  LastWithdrawTime()

  NextWithdrawTime()

SEE ALSO

CryptoTron::GetAccount

POSIX

JSON::PP

Try::Catch

AUTHOR

Dr. Peter Netz, <ztenretep@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2022 by Dr. Peter Netz

The MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.