/// Tx inputs
$input = new \BlockCypher\Api\TXInput();
$input->addAddress("n3D2YXwvpoPg8FhcWpzJiS3SvKKGD8AXZ4");
/// Tx outputs
$output = new \BlockCypher\Api\TXOutput();
$output->setAddresses(array("03798be8162d7d6bc5c4e3b236100fcc0dfee899130f84c97d3a49faf83450fd81", "03dd9f1d4a39951013b4305bf61887ada66439ab84a9a2f8aca9dc736041f815f1", "03c8e6e99c1d0b42120d5cf40c963e5e8048fd2d2a184758784a041a9d101f1f02"));
$output->setScriptType("multisig-2-of-3");
$output->setValue(1000);
// Satoshis
/// Tx
$tx = new \BlockCypher\Api\TX();
$tx->addInput($input);
$tx->addOutput($output);
/// For Sample Purposes Only.
$request = clone $tx;
$txClient = new \BlockCypher\Client\TXClient($apiContexts['BTC.test3']);
try {
    $txSkeleton = $txClient->create($tx);
} catch (Exception $ex) {
    ResultPrinter::printError("Created Multisig TX (fund multisig address)", "TXSkeleton", null, $request, $ex);
    exit(1);
}
ResultPrinter::printResult("Created Multisig TX (fund multisig address)", "TXSkeleton", $txSkeleton->getTx()->getHash(), $request, $txSkeleton);
return $txSkeleton;
// ## TX request object:
//
// Source: <a href="https://live.blockcypher.com/btc-testnet/address/n3D2YXwvpoPg8FhcWpzJiS3SvKKGD8AXZ4/">n3D2YXwvpoPg8FhcWpzJiS3SvKKGD8AXZ4</a>
//
// Destination: <a href="https://live.blockcypher.com/btc-testnet/address/2Mu7dJvawNdhshTkKRXGAVLKdr2VA7Rs1wZ/">2Mu7dJvawNdhshTkKRXGAVLKdr2VA7Rs1wZ</a>
//
// Script type: multisig-2-of-3
require __DIR__ . '/../bootstrap.php';
/// Tx inputs
$input = new \BlockCypher\Api\TXInput();
$input->setWalletName("5596926E976A1149871172");
//$input->setWalletName("AC33394F28292099183");
$input->setWalletToken("c0afcccdde5081d6429de37d16166ead");
/// Tx outputs
$output = new \BlockCypher\Api\TXOutput();
$output->addAddress("mvwhcFDFjmbDWCwVJ73b8DcG6bso3CZXDj");
$output->setValue(1000);
// Satoshis
/// Tx
$tx = new \BlockCypher\Api\TX();
$tx->addInput($input);
$tx->addOutput($output);
/// For Sample Purposes Only.
$request = clone $tx;
$txClient = new \BlockCypher\Client\TXClient($apiContexts['BTC.test3']);
try {
    $output = $txClient->create($tx);
} catch (\BlockCypher\Exception\BlockCypherConnectionException $ex) {
    $data = $ex->getData();
    $txSkeleton = new \BlockCypher\Api\TXSkeleton($data);
    ResultPrinter::printError("Created TX", "TXSkeleton", null, $request, $ex);
    exit(1);
} catch (\Exception $ex) {
    ResultPrinter::printError("Created TX", "TXSkeleton", null, $request, $ex);
    exit(1);
}
ResultPrinter::printResult("Created TX", "TXSkeleton", $output->getTx()->getHash(), $request, $output);
return $output;
<?php

// # Get Transaction with confidence factor
// The TX resource allows you to retrieve details about a transaction including confidence factor.
//
// API called: '/v1/btc/main/txs/f854aebae...bd5063449'
require __DIR__ . '/../bootstrap.php';
$txClient = new \BlockCypher\Client\TXClient($apiContexts['BTC.main']);
try {
    $params = array('includeConfidence' => 'true');
    $transaction = $txClient->get('f854aebae95150b379cc1187d848d58225f3c4157fe992bcd166f58bd5063449', $params);
} catch (Exception $ex) {
    ResultPrinter::printError("Get TX", "TX", 'f854aebae95150b379cc1187d848d58225f3c4157fe992bcd166f58bd5063449', null, $ex);
    exit(1);
}
ResultPrinter::printResult("Get TX", "TX", $transaction->getHash(), null, $transaction);
return $transaction;
<?php

// # Fund Multisig Address Sample
//
// This sample code demonstrate how you can create a new transaction and send it to the network
// to fund a multisig address, as documented here at:
// <a href="http://dev.blockcypher.com/?javascript#multisig-transactions">http://dev.blockcypher.com/?javascript#multisig-transactions</a>
// API used: POST /v1/btc/main/txs/new and
// POST /v1/btc/main/txs/send
/** @var \BlockCypher\Api\TXSkeleton $txSkeleton */
$txSkeleton = (require 'CreateTransactionToFundMultisigAddress.php');
$txClient = new \BlockCypher\Client\TXClient($apiContexts['BTC.test3']);
// source addresses private keys
// private key in the same format as returned by Generate Address Endpoint:
// http://dev.blockcypher.com/?shell#generate-address-endpoint
$privateKeys = array("1551558c3b75f46b71ec068f9e341bf35ee6df361f7b805deb487d8a4d5f055e");
// ### Sign the TX
$txSkeleton = $txClient->sign($txSkeleton, $privateKeys);
// Source address: <a href="https://live.blockcypher.com/btc-testnet/address/n3D2YXwvpoPg8FhcWpzJiS3SvKKGD8AXZ4/">n3D2YXwvpoPg8FhcWpzJiS3SvKKGD8AXZ4</a>
// Destination addresses <a href="https://live.blockcypher.com/btc-testnet/address/2Mu7dJvawNdhshTkKRXGAVLKdr2VA7Rs1wZ/">2Mu7dJvawNdhshTkKRXGAVLKdr2VA7Rs1wZ</a>
// For sample purposes only.
$request = clone $txSkeleton;
try {
    // ### Send TX to the network
    $output = $txClient->send($txSkeleton);
} catch (Exception $ex) {
    ResultPrinter::printError("Sent Transaction (fund multisig address)", "TXSkeleton", null, $request, $ex);
    exit(1);
}
ResultPrinter::printResult("Sent Transaction (fund multisig address)", "TXSkeleton", $output->getTx()->getHash(), $request, $output);
return $output;
Ejemplo n.º 5
0
<?php

// # Get Multiple Transactions
// This method allows you to retrieve details about multiple transactions at once.
//
// API called: '/v1/btc/main/txs/950d61a...7de13a7;6370d4359...67b0780'
require __DIR__ . '/../bootstrap.php';
$txClient = new \BlockCypher\Client\TXClient($apiContexts['BTC.main']);
try {
    /// Transaction hash list
    $transactionList = array('950d61ab2f51ea877e6183c8210de1677d78e16abfd4103990c3703f17de13a7', '6370d43593fc47daf9443e0773faf289c54ca0bd9b92c2e538c77a6db67b0780');
    $transactions = $txClient->getMultiple($transactionList);
} catch (Exception $ex) {
    ResultPrinter::printError("Get Multiple Transactions", "Transactions", implode(",", $transactionList), null, $ex);
    exit(1);
}
ResultPrinter::printResult("Get Multiple Transactions", "Transactions", implode(",", $transactionList), null, $transactions);
return $transactions;
Ejemplo n.º 6
0
<?php

// # Decode Raw Transactions
// Without propagating it to the network.
//
// API called: '/v1/btc/main/txs/decode'
require __DIR__ . '/../bootstrap.php';
$hexRawTx = "01000000011935b41d12936df99d322ac8972b74ecff7b79408bbccaf1b2eb8015228beac8000000006b483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044ffffffff0240420f00000000001976a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac20da3c00000000001976a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac00000000";
/// For Sample Purposes Only.
$txHex = new \BlockCypher\Api\TXHex();
$txHex->setTx($hexRawTx);
$txClient = new \BlockCypher\Client\TXClient($apiContexts['BTC.main']);
try {
    /// Decode Raw Transaction
    $tx = $txClient->decode($hexRawTx);
} catch (Exception $ex) {
    ResultPrinter::printError("Decode Raw Transaction", "TX", $txHex, $ex);
    exit(1);
}
ResultPrinter::printResult("Decode Raw Transaction", "TX", null, $txHex, $tx);
<?php

// # Get Multiple Transactions Confidence
// More info about Confidence Factor: <a href="http://dev.blockcypher.com/?php#confidence-factor">http://dev.blockcypher.com/?php#confidence-factor</a>
//
// API called: '/v1/btc/main/txs/2b17f5...a871b;2b17f...bfa871b/confidence'
require __DIR__ . '/../bootstrap.php';
$txClient = new \BlockCypher\Client\TXClient($apiContexts['BTC.main']);
try {
    /// Transaction hash list
    $txhashList = array('950d61ab2f51ea877e6183c8210de1677d78e16abfd4103990c3703f17de13a7', '6370d43593fc47daf9443e0773faf289c54ca0bd9b92c2e538c77a6db67b0780');
    $txConfidences = $txClient->getMultipleConfidences($txhashList);
} catch (Exception $ex) {
    ResultPrinter::printError("Get Multiple Transaction Confidence", "TX Confidence", implode(",", $txhashList), null, $ex);
    exit(1);
}
ResultPrinter::printResult("Get Multiple Transaction Confidence", "TX Confidence", implode(",", $txhashList), null, $txConfidences);
return $txConfidences;
<?php

// # Get Transaction Confidence
// More info about Confidence Factor: <a href="http://dev.blockcypher.com/?php#confidence-factor">http://dev.blockcypher.com/?php#confidence-factor</a>
//
// API called: '/v1/btc/main/txs/2b17f5...a871b/confidence'
require __DIR__ . '/../bootstrap.php';
$txClient = new \BlockCypher\Client\TXClient($apiContexts['BTC.main']);
try {
    $txConfidence = $txClient->getConfidence('950d61ab2f51ea877e6183c8210de1677d78e16abfd4103990c3703f17de13a7');
} catch (Exception $ex) {
    ResultPrinter::printError("Get Only TX Confidence", "TX Confidence", '1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD', null, $ex);
    exit(1);
}
ResultPrinter::printResult("Get Only TX Confidence", "TX Confidence", $txConfidence->getTxhash(), null, $txConfidence);
return $txConfidence;
Ejemplo n.º 9
0
<?php

// # Push Raw Transaction to the Network
//
// API called: '/v1/btc/main/txs/push'
$hexRawTx = (require 'CreateTransactionWithThirdPartySoftware.php');
/// For Sample Purposes Only.
$txHex = new \BlockCypher\Api\TXHex();
$txHex->setTx($hexRawTx);
$txClient = new \BlockCypher\Client\TXClient($apiContexts['BTC.main']);
try {
    /// Push Raw Transaction
    $tx = $txClient->push($hexRawTx);
} catch (\Exception $ex) {
    ResultPrinter::printError("Push Raw Transaction", "TX", null, $txHex, $ex);
    exit(1);
}
ResultPrinter::printResult("Push Raw Transaction", "TX", null, $txHex, $tx);
<?php

// # Get Unconfirmed Transactions
// This method allows you to retrieve an array of the latest transactions relayed by nodes in a blockchain
// that haven’t been included in any blocks.
//
// API called: '/v1/btc/main/txs'
require __DIR__ . '/../bootstrap.php';
$txClient = new \BlockCypher\Client\TXClient($apiContexts['BTC.main']);
try {
    $txs = $txClient->getUnconfirmed();
} catch (Exception $ex) {
    ResultPrinter::printError("Get Unconfirmed Transactions", "TX[]", null, null, $ex);
    exit(1);
}
ResultPrinter::printResult("Get Unconfirmed Transactions", "TX[]", null, null, $txs);
return $txs;