NAME

Circle::Block - the block module for Circle::Chain SDK

VERSION

Version 0.03

SYNOPSIS

my $response = get_block_hashlist(0);
if ($response->{status} != 200) {
    croak 'cannot get block hash list:' . $response->{status};
}
my $data = $response->{data};
# process the block hash list data here.
my $hash = $data->[0];
$response = get_block($hash);
if ($response->{status} != 200) {
    croak 'cannot get block:' . $response->{status};
}
// process block data here.

DESCRIPTION

The module provides block functions.

EXPORT

Export the following methods in default:

our @EXPORT = qw(
  get_block_hashlist
  get_block
  get_block_header_list
  get_block_data
  get_blocktails_hashlist
  get_blocktails_po
  get_tx_by_txid
  search_tx_by_txid
  search_tx_by_address
  search_utxos
);

So you just use the module:

use Circle::Block;

METHODS

get_block_hashlist($base_height)

my $response = get_block_hashlist(0);
if ($response->{status} != 200) {
    croak 'cannot get block hash list:' . $response->{status};
}
my $data = $response->{data};
# process the block hash list data here.

get_block($hash)

my $hash = 'xxxxxxxxx';
my $response = get_block($hash);
if ($response->{status} != 200) {
    croak 'cannot get block:' . $response->{status};
}
my $data = $response->{data};
// process block data here.

get_block_header_list($base_height)

my $response = get_block_header_list(0);
if ($response->{status} != 200) {
    croak 'cannot get block header list:' . $response->{status};
}
my $data = $response->{data};
# process the block hash header list here.

get_block_data($hash)

my $hash = 'xxxxxxxxx';
my $response = get_block_data($hash);
if ($response->{status} != 200) {
    croak 'cannot get block data:' . $response->{status};
}
my $data = $response->{data};
// process block data here.

get_blocktails_hashlist($base_height)

my $response = get_blocktails_hashlist(0);
if ($response->{status} != 200) {
    croak 'cannot get block tails hashlist status: ' . $response->{status};
}
my $data = $response->{data};
// process block tails hash list here.

get_blocktails_po($hash)

my $hash = 'xxxxxxxxx';
my $response = get_blocktails_po($hash);
if ($response->{status} != 200) {
    croak 'cannot get block tails data:' . $response->{status};
}
my $data = $response->{data};
// process block tails here.

get_tx_by_txid($txid)

my $txid = 'xxxxxxxxx';
my $response = get_tx_by_txid($txid);
if ($response->{status} != 200) {
    croak 'cannot get tx by txid:' . $txid . ' status: ' . $response->{status};
}
my $data = $response->{data};
// process tx here.

search_tx_by_txid($txid)

my $txid = 'xxxxxxxxx';
my $response = search_tx_by_txid($txid);
if ($response->{status} != 200) {
    croak 'cannot search tx by txid:' . $txid . ' status: ' . $response->{status};
}
my $data = $response->{data};
// process tx list here.

search_tx_by_address(address, min_output_key, limit)

my $address = 'xxxxxxxxx';
my $response = search_tx_by_address($address, '', 100);
if ($response->{status} != 200) {
    croak 'cannot search tx by address:' . $address . ' status: ' . $response->{status};
}
my $data = $response->{data};
// process tx list here

address: the searched address min_output_key: the min output key to start with limit: the batch count for the search.

how to set min_output_key? In the response, we can get outputs:

my $min_output_key = $data->{minOutputKey};

search_utxos(address, min_output_key, limit)

my $address = 'xxxxxxxxx';
my $response = search_utxos($address, '', 100);
if ($response->{status} != 200) {
    croak 'cannot search utxos by address:' . $address . ' status: ' . $response->{status};
}
my $data = $response->{data};
// process utxos here.

address: the searched address min_output_key: the min output key to start with limit: the batch count for the search.

how to set min_output_key? In the response, we can get outputs:

my $outputs = $data->{outputs};
my $output = $outputs->[@{$outputs} - 1];
$min_output_key = $output->{txIdStr} . ':' . $output->{idx};

SEE ALSO

See Circle::Common for circle common module.

See Circle::Wallet for circle wallet module.

See Circle::User for circle user module.

COPYRIGHT AND LICENSE

Copyright 2024-2030 Charles li

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.