0

I have a script that uses the Blockchain API to check the current balance on all my accounts one by one. When I reach a certain balance I sweep to a master account.

Am I using the correct code here as I am having errors checking the balance on accounts.

my $mech = WWW::Mechanize->new();
$mech->get("http://blockexplorer.com/q/getreceivedbyaddress/".$btcaddress);   # Check transactions on each address as per masterlist
my $getreceived = $mech->content;

$mech->get("http://blockexplorer.com/q/addressbalance/".$btcaddress);   # Check balance on of each address as per master list
my $addressbalance = $mech->content;

I can check transaction volume ok to reconcile with my accounts but I want to know the current final balance too so I can check that box also.

1
  • Looks fine. What specific error are you having?
    – Nick ODell
    Commented Nov 24, 2015 at 23:31

1 Answer 1

1

Just ran almost the exact same code in perl and this works:

#!/usr/bin/perl

use WWW::Mechanize;

my $btcaddress = "1Enn7YW22vBGvCWrsPQN7vDhnQCYhy221V";

my $mech = WWW::Mechanize->new();
$mech->get("http://blockexplorer.com/q/getreceivedbyaddress/" . $btcaddress);   # Check transactions on each address as per masterlist
my $getreceived = $mech->content;

print $getreceived . "\n";

$mech->get("http://blockexplorer.com/q/addressbalance/".$btcaddress);   # Check balance on of each address as per master list
my $addressbalance = $mech->content;

print $addressbalance . "\n";

Note the address is a random one I found on blockchain.info.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.