<?php

// # Create, Sign and Send MicroTX
// This sample code demonstrate how you can create, sign and send a new microtransaction, as documented here at:
// <a href="http://dev.blockcypher.com/#microtransaction-endpoint">http://dev.blockcypher.com/#microtransaction-endpoint</a>
//
// API used: POST /v1/btc/main/txs/micro
require __DIR__ . '/../bootstrap.php';
/// New MicroTX
$microTX = new \BlockCypher\Api\MicroTX();
$microTX->setFromPubkey("02d4e3404e175923adf89c932fab96758716f6a0a896890f2494c5d9141eb3f543")->setToAddress("C4MYFr4EAdqEeUKxTnPUF3d3whWcPMz1Fi")->setValueSatoshis(10000);
$microTXClient = new \BlockCypher\Client\MicroTXClient($apiContexts['BCY.test']);
try {
    /// Create
    $microTXToSign = $microTXClient->create($microTX);
    ResultPrinter::printResult("Created MicroTX", "MicroTX", $microTXToSign->getHash(), $microTX, $microTXToSign);
    /// Sign
    $microTXSigned = $microTXToSign->sign("2c2cc015519b79782bd9c5af66f442e808f573714e3c4dc6df7d79c183963cff");
    // Hex private key
    /// Send
    $microTXSent = $microTXClient->send($microTXSigned);
    ResultPrinter::printResult("Send MicroTX", "MicroTX", $microTXSent->getHash(), $microTXSigned, $microTXSent);
} catch (Exception $ex) {
    ResultPrinter::printError("Created, Sign and Send MicroTX", "MicroTX", null, null, $ex);
    exit(1);
}
<?php

// # Create MicroTX
// Sending private key to the server (server-side signing).
//
// This sample code demonstrate how you can create a new micro transaction, as documented here at:
// <a href="http://dev.blockcypher.com/#microtransaction-endpoint">http://dev.blockcypher.com/#microtransaction-endpoint</a>
//
// API used: POST /v1/btc/main/txs/micro
require __DIR__ . '/../bootstrap.php';
// Addresses used in this sample:
//
// Source : <a href="https://live.blockcypher.com/bcy/address/C5vqMGme4FThKnCY44gx1PLgWr86uxRbDm/">C5vqMGme4FThKnCY44gx1PLgWr86uxRbDm</a>
//
// Destination: <a href="https://live.blockcypher.com/bcy/address/C4MYFr4EAdqEeUKxTnPUF3d3whWcPMz1Fi/">C4MYFr4EAdqEeUKxTnPUF3d3whWcPMz1Fi</a>
$microTX = new \BlockCypher\Api\MicroTX();
$microTX->setFromPrivate("2c2cc015519b79782bd9c5af66f442e808f573714e3c4dc6df7d79c183963cff");
$microTX->setToAddress("C4MYFr4EAdqEeUKxTnPUF3d3whWcPMz1Fi");
$microTX->setValueSatoshis(10000);
/// For Sample Purposes Only.
$request = clone $microTX;
$microTXClient = new \BlockCypher\Client\MicroTXClient($apiContexts['BCY.test']);
try {
    $output = $microTXClient->create($microTX);
} catch (Exception $ex) {
    ResultPrinter::printError("Created MicroTX Via PrivateKey", "MicroTX", null, $request, $ex);
    exit(1);
}
ResultPrinter::printResult("Created MicroTX Via PrivateKey", "MicroTX", $output->getHash(), $request, $output);
return $output;