Reputation: 365
I have a bitcoin address created using blockcypher and I would like to transfer some bitcoins from it (already made a deposit) to another address.
I am using the blockcypher php client to create the transaction using the sample code https://www.blockcypher.com/dev/bitcoin/?php#creating-transactions and https://github.com/blockcypher/php-client/blob/master/sample/transaction-api/CreateTransaction.php, I get the error
Class 'Mdanter\Ecc\Math\Gmp' not found in C:\xampp\htdocs\cck\vendor\bitwasp\bitcoin\src\Math\Math.php on line 8
I checked file the vendor and there is Gmp file or class in Mdanter\Ecc\Math\Gmp, so i edited the math.php file and edited line 6 to use \Mdanter\Ecc\Math\GmpMath as Gmp; and now get the error like the one in https://github.com/blockcypher/php-client/issues/21
My code is as below
require_once __DIR__.'/vendor/autoload.php';
use BlockCypher\Auth\SimpleTokenCredential;
use BlockCypher\Rest\ApiContext;
use BlockCypher\Api\TX as DD;
use BlockCypher\Client\TXClient;
// ... other classes
$apiContext = ApiContext::create(
'main', 'btc', 'v1',
new SimpleTokenCredential('4e3a287e603f48c994d978dab061084a'),
array('log.LogEnabled' => true, 'log.FileName' => 'BlockCypher.log', 'log.LogLevel' => 'DEBUG') );
$tx = new DD();
// Tx inputs
$input = new \BlockCypher\Api\TXInput();
$input->addAddress("1DZR2kUCa5HTyVZLY8TWFf2ZfjhWgsgNtf");
$tx->addInput($input);
// Tx outputs
$output = new \BlockCypher\Api\TXOutput();
$output->addAddress("1Mye4sZmd9rzjY6yUw19etZhzeVU2q1kcj");
$output->setValue(1000); // Satoshis
$tx->addOutput($output);
// Tx amount
$txClient = new TXClient($apiContext);
$txSkeleton = $txClient->create($tx);
$privateKeys = array("3ed07ff3e458fabb8b99b723002f4817eebd5fc11f9c76fdd9c200090c04fd1c");
$txSkeleton = $txClient->sign($txSkeleton, $privateKeys);
$txSkeleton = $txClient->send($txSkeleton);
Upvotes: 0
Views: 1445
Reputation: 569
The problem was caused by a bad dependency configuration in one of the php-client dependencies. It was fixed. More info:
https://github.com/blockcypher/php-client/issues/21
You only need to update php-client to the latest release.
Upvotes: 1