Reputation: 1105
How to create a transaction with a fee embedded(All Balance)? blockcypher/php-client
/// Tx inputs
$input = new \BlockCypher\Api\TXInput();
$input->addAddress("n3D2YXwvpoPg8FhcWpzJiS3SvKKGD8AXZ4");
/// Tx outputs
$output = new \BlockCypher\Api\TXOutput();
$output->addAddress("mvwhcFDFjmbDWCwVJ73b8DcG6bso3CZXDj");
$output->setValue(10000000); // Satoshis (all balance)
/// Tx
$tx = new \BlockCypher\Api\TX();
$tx->addInput($input);
$tx->addOutput($output);
#Code ....
Upvotes: 0
Views: 149
Reputation: 1105
$output->setValue(-1);
If you want to automatically empty your input address(es) without knowing their exact value, your TX request object's value can be set to -1 to sweep all value from your input address(es) to your output address. Please be advised that this only works with a single output address.
Upvotes: 1