NAME
Finance::Dogechain::Transaction - class representing transactions in the Dogechain API
SYNOPSIS
use Finance::Dogechain::Transaction;
my $tx = Finance::Dogechain::Transaction->new(
tx_id => '9b7707711014114bdfc6352d803e3175a8dfa25eb2b7fcfb6e29e0a031cf2d27'
);
for my $input_address (map { $_->{address} } $tx->inputs->@*) { ... }
for my $output_address (map { $_->{address} } $tx->outputs->@*) { ... }
DESCRIPTION
Finance::Dogechain::Transaction
represents transactions in the Dogechain API. It inherits methods from Finance::Dogechain::Base
and provides several of its own.
METHODS
new( ua => ..., base_url => ..., tx_id => '...' )
Creates a new instance of this object. You must provide a tx_id
parameter, which is a hash which represents a valid transaction in the Dogecoin public 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 tx_id()
, ua()
, and base_url()
.
transaction()
Returns a JSON data structure representing the transaction corresponding to the tx_id
, if that transaction is valid and can be accessed. Dogecoin addresses in the transaction's inputs and outputs will be replaced with Finance::Dogechain::Address
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.
inputs()
Returns a reference to an array of hashes representing transaction inputs.
outputs()
Returns a reference to an array of hashes representing transaction outputs.
TO_JSON()
Returns a string representation of this object (its class and tx_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.