NAME
Finance::Dogechain::Block - class representing blocks in the Dogechain API
SYNOPSIS
use Finance::Dogechain::Block;
my $block = Finance::Dogechain::Block(
block_id => '2750235'
);
for my $transaction ($block->{txs}->@*) { ... }
DESCRIPTION
Finance::Dogechain::Block
represents transactions in the Dogechain API. It inherits methods from Finance::Dogechain::Base
and provides several of its own.
METHODS
new( ua => ..., base_url => ..., block_id => '...' )
Creates a new instance of this object. You must provide a block_id
parameter, which is either the hash representing a block in the Dogecoin public ledger or the height of a block in the ledger.
Other default constructor values are:
ua
, a user agent. Defaults to an instance of Mojo::UserAgent.base_url
, the base URL path of the dogechain.info API (or an equivalent).
These attributes are available by instance methods block_id()
, ua()
, and base_url()
.
block()
Returns a JSON data structure representing the block corresponding to the block_id
, if that block is valid and can be accessed. Dogecoin transactions in the block will be replaced with Finance::Dogechain::Transaction
objects when possible.
Returns an undefined value (undef
in scalar context or an empty list in list context) if the HTTP call did not succeed.
Returns 0
if the HTTP call did succeed but the API returned an unsuccessful payload.
TO_JSON()
Returns a string representation of this object (its class and block_id
) so that you can serialize this object with JSON.
COPYRIGHT & LICENSE
Copyright 2021 chromatic, some rights reserved.
This program is free software. You can redistribute it and/or modify it under the same terms as Perl 5.32.