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::GetAccount;

  # Set the public key as Base58 address.
  my $PublicKeyBase58 = "TY2fJ7AcsnQhfW3UJ1cjEUak5vkM87KC6R";

  # Set the output format flag.
  my $OutputFlag = ["RAW"|"STR"|""];

  # Set the visible switch.
  my $VisibleSwitch = ["True"|"False"|""];

  # Set the address check flag.
  my $CheckFlag = ["True"|"False"|""];

  # Request the account info from the mainnet.
  my $account_info = GetAccount({
      PublicAddr => $PublicKeyBase58
      [, VisibleSwitch => $VisibleSwitch]
      [, AddrCheck => $CheckFlag]
      [, OutputFlag => $OutputFlag]
  });

  # Print the account info into the terminal window.
  print $account_info;

DESCRIPTION

The module requests the account information of an Tron account from the Tron blockchain using the so-called full-node HTTP API from the Tron developer network. The module is designed for use with Tron Mainnet. For HTTP requests the methods POST or GET can be used in general. For the method GetAccount the needed method is POST. The payload of the HTTP request consists of the key 'address' and the key 'visible' and the related values. The switch 'visible' can be set to "True" or "False". If the switch is set to "True" a Base58 address is used. If the switch is set to "False" a Hex address is used. A request of the service API results in a response in JSON format. The module returns formatted string JSON data as well as unformated raw JSON data based on the output format flag. The parsing of the account information is done by a separate module.

METHOD

  GetAccount()

OPTIONS

The named subroutine argument key PublicAddr and value is mandatory, the named subroutine arguments keys OutputFlag as well as VisibleSwitch and there values are optional. The value of key PublicAddr can be a Base58 address or a Hex address. The value of key VisibleSwitch can be "True" or "False".

  PublicAddr: Base58 address => VisibleSwitch: True
  PublicAddr: Hex address    => VisibleSwitch: False

If the given combination is not valid, an error will be returned from the request.

The subroutine argument key AddrCheck and his value controls if the given combination address and visible should be checked. If visible is not set in a correct way, the value will be corrected if the flag is "True" and if the flag is "False" it will not be corrected.

The subroutine argument key OutputFlag and his value controls wether the output is raw JSON or or formatted JSON.

EXAMPLES

Example 1

  # Load the required module.
  use CryptoTron::GetAccount;

  # Set the public key as Base58 address.
  my $PublicKeyBase58 = "TY2fJ7AcsnQhfW3UJ1cjEUak5vkM87KC6R";

  # Set the output format flag.
  my $OutputFlag = "RAW";

  # Set the visible switch.
  my $VisibleSwitch = "True";

  # Set the address check flag.
  my $CheckFlag = "True";

  # Request the account info from the mainnet.
  my $account_info = GetAccount({
      PublicAddr => $PublicKeyBase58,
      AddrCheck => $CheckFlag,
      VisibleSwitch => $VisibleSwitch,
      OutputFlag => $OutputFlag
  });

  # Print the account info into the terminal window.
  print $account_info;

Example 2

  # Load the required module.
  use CryptoTron::GetAccount;

  # Set the public key as Base58 address.
  my $PublicKeyBase58 = "TY2fJ7AcsnQhfW3UJ1cjEUak5vkM87KC6R";

  # Set the output format flag.
  my $OutputFlag = "STR";

  # Request the account info from the mainnet.
  my $response = GetAccount({PublicAddr => $PublicKeyBase58});

  # Print the account info into the terminal window.
  print $response;

LIMITATIONS

The module is working with the Tron Mainnet, but not with other existing Tron Testnets.

OPEN ISSUES

None

ERROR CODES

None

NOTES

None

BUGS

None

TODO

None

SEE ALSO

CryptoTron::JsonHttp

CryptoTron:ParseAccount

CryptoTron:AddressCheck

CryptoTron:AddressConvert

File::Basename

TRON Developer Hub

AUTHOR

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

COPYRIGHT AND LICENSE

Copyright (C) 2022 by Dr. Peter Netz

This library is free software; you can redistribute it and/or modify it under the same terms of The MIT License. For more details, see the full text of the license in the attached file LICENSE in the main module folder. This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.