<?php // # Fund multisig address (using builder) // // This sample code demonstrate how you can create a new transaction, as documented here at: // <a href="http://dev.blockcypher.com/#creating-transactions">http://dev.blockcypher.com/#creating-transactions</a> // // Destination address is a multisig address. // // API used: POST /v1/btc/main/txs/new require __DIR__ . '/../bootstrap.php'; $input = \BlockCypher\Builder\TXInputBuilder::aTXInput()->addAddress("n3D2YXwvpoPg8FhcWpzJiS3SvKKGD8AXZ4")->build(); $output = \BlockCypher\Builder\TXOutputBuilder::aTXOutput()->withScryptType("multisig-2-of-3")->withValue(1000)->addAddress("03798be8162d7d6bc5c4e3b236100fcc0dfee899130f84c97d3a49faf83450fd81")->addAddress("03dd9f1d4a39951013b4305bf61887ada66439ab84a9a2f8aca9dc736041f815f1")->addAddress("03c8e6e99c1d0b42120d5cf40c963e5e8048fd2d2a184758784a041a9d101f1f02")->build(); $tx = \BlockCypher\Builder\TXBuilder::aTX()->addTXInput($input)->addTXOutput($output)->build(); $txClient = new \BlockCypher\Client\TXClient($apiContexts['BTC.test3']); try { $txSkeleton = $txClient->create($tx); } catch (\Exception $ex) { ResultPrinter::printError("Created Multisig TX (fund multisig addr)", "TXSkeleton", null, $request, $ex); exit(1); } ResultPrinter::printResult("Created Multisig TX (fund multisig addr)", "TXSkeleton", $txSkeleton->getTx()->getHash(), $tx, $txSkeleton);
<?php // # Spend Multisig Funds (using builder) // // This sample code demonstrate how you can create a new transaction, as documented here at: // <a href="http://dev.blockcypher.com/#creating-transactions">http://dev.blockcypher.com/#creating-transactions</a> // // Destination address is a multisig address. // // API used: POST /v1/btc/main/txs/new // // This sample uses builders classes (optional). require __DIR__ . '/../bootstrap.php'; // BTC-TESTNET: 2NBbY8fbHRLjWXHqRvs8P996N82eTYic1yX $input = \BlockCypher\Builder\TXInputBuilder::aTXInput()->addAddress("033e88a5503dc09243e58d9e7a53831c2b77cac014415ad8c29cabab5d933894c1")->addAddress("02087f346641256d4ba19cc0473afaa8d3d1b903761b9220a915e1af65a12e613c")->addAddress("03051fa1586ff8d509125d3e25308b4c66fcf656b377bf60bfdb296a4898d42efd")->withScryptType("multisig-2-of-3")->build(); $output = \BlockCypher\Builder\TXOutputBuilder::aTXOutput()->addAddress("n3D2YXwvpoPg8FhcWpzJiS3SvKKGD8AXZ4")->withValue(1000)->build(); $tx = \BlockCypher\Builder\TXBuilder::aTX()->addTXInput($input)->addTXOutput($output)->build(); /// 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 (Spend Multisig Fund)", "TXSkeleton", null, $request, $ex); exit(1); } ResultPrinter::printResult("Created Multisig TX (Spend Multisig Fund)", "TXSkeleton", $txSkeleton->getTx()->getHash(), $tx, $txSkeleton);
<?php // # Create TX Sample (without sending it) // // This sample code demonstrate how you can create a new transaction, as documented here at: // <a href="http://dev.blockcypher.com/#creating-transactions">http://dev.blockcypher.com/#creating-transactions</a> // Destination address is a multisig address. // API used: POST /v1/bcy/test/txs/new require __DIR__ . '/../bootstrap.php'; // Create a new instance of TX object $tx = new \BlockCypher\Api\TX(); $input = \BlockCypher\Builder\TXInputBuilder::aTXInput()->addAddress("C5vqMGme4FThKnCY44gx1PLgWr86uxRbDm")->build(); $output = \BlockCypher\Builder\TXOutputBuilder::aTXOutput()->addAddress("C4MYFr4EAdqEeUKxTnPUF3d3whWcPMz1Fi")->withValue(1000)->build(); $tx = \BlockCypher\Builder\TXBuilder::aTX()->addTXInput($input)->addTXOutput($output)->build(); // For Sample Purposes Only. $request = clone $tx; $txClient = new \BlockCypher\Client\TXClient($apiContexts['BCY.test']); try { // ### Create New TX $txSkeleton = $txClient->create($tx); } catch (Exception $ex) { ResultPrinter::printError("Created TX BlockCypher Testnet", "TXSkeleton", null, $request, $ex); exit(1); } ResultPrinter::printResult("Created TX BlockCypher Testnet", "TXSkeleton", $txSkeleton->getTx()->getHash(), $request, $txSkeleton); return $txSkeleton;
<?php // # Create TX Sample (without sending it) // // This sample code demonstrate how you can create a new transaction, as documented here at: // <a href="http://dev.blockcypher.com/#creating-transactions">http://dev.blockcypher.com/#creating-transactions</a> // Destination address is a multisig address. // API used: POST /v1/doge/main/txs/new require __DIR__ . '/../bootstrap.php'; // Create a new instance of TX object $tx = new \BlockCypher\Api\TX(); $input = \BlockCypher\Builder\TXInputBuilder::aTXInput()->addAddress("DGKpPALLfKA2bfTXQmHrUCBuNsX5DBGvjH")->build(); $output = \BlockCypher\Builder\TXOutputBuilder::aTXOutput()->addAddress("DJ4bg6Reh5CHZEGYEfWFj6ubPWNL693ngM")->withValue(1000)->build(); $tx = \BlockCypher\Builder\TXBuilder::aTX()->addTXInput($input)->addTXOutput($output)->build(); // For Sample Purposes Only. $request = clone $tx; $txClient = new \BlockCypher\Client\TXClient($apiContexts['DOGE.main']); try { // ### Create New TX $txSkeleton = $txClient->create($tx); } catch (Exception $ex) { ResultPrinter::printError("Created TX Doge", "TXSkeleton", null, $request, $ex); exit(1); } ResultPrinter::printResult("Created TX Doge", "TXSkeleton", $txSkeleton->getTx()->getHash(), $request, $txSkeleton); return $txSkeleton;