$pubKeyStr = $keys[0]->getPublicKey() . "," . $keys[1]->getPublicKey() . "," . $keys[2]->getPublicKey() . "," . $keys[3]->getPublicKey(); $dTrustAddress = ""; echo "*** Creating Address with 4 Signers, and 3 Required Signatures: " . "\n"; try { $response = $block_io->get_new_dtrust_address(array('label' => 'dTrust1', 'public_keys' => $pubKeyStr, 'required_signatures' => 3)); $dTrustAddress = $response->data->address; } catch (Exception $e) { // print the exception below for debugging // echo "Exception: " . $e->getMessage() . "\n"; // the label must exist, let's get its address then $dTrustAddress = $block_io->get_dtrust_address_by_label(array('label' => 'dTrust1'))->data->address; } echo "*** Address with Label=dTrust1: " . $dTrustAddress . "\n"; // let's deposit some testnet coins into this address try { $response = $block_io->withdraw(array('amounts' => '5.1', 'to_addresses' => $dTrustAddress)); echo "*** Deposit Proof (Tx ID): " . $response->data->txid . "\n"; } catch (Exception $e) { echo "Exception: " . $e->getMessage() . "\n"; } // let's get our dtrust address' balance $response = $block_io->get_dtrust_address_balance(array('label' => 'dTrust1')); echo "*** dTrust1 Available Balance: " . $response->data->available_balance . " " . $response->data->network . "\n\n"; echo "*** Beginning Withdrawal from dTrust1 to Testnet Default Address: " . "\n"; // let's withdraw coins from dTrust1 and send to the non-dTrust address labeled 'default' $destAddress = $block_io->get_address_by_label(array('label' => 'default'))->data->address; echo "**** Destination Address: " . $destAddress . "\n"; $response = $block_io->withdraw_from_dtrust_address(array('from_labels' => 'dTrust1', 'to_addresses' => $destAddress, 'amounts' => '2.0')); echo "*** Inputs to sign? " . count($response->data->inputs) . "\n"; $refid = $response->data->reference_id; $counter = 0;
echo "Label: " . $getNewAddressInfo->data->label . "\n"; } catch (Exception $e) { echo $e->getMessage() . "\n"; } echo "\n\n"; try { echo "Getting address for Label='shibetime1'\n"; $getAddressInfo = $block_io->get_address_by_label(array('label' => 'shibetime1')); echo "Status: " . $getAddressInfo->status . "\n"; } catch (Exception $e) { echo $e->getMessage() . "\n"; } echo "Label has Address: " . $block_io->get_address_by_label(array('label' => 'shibetime1'))->data->address . "\n"; echo "\n\n"; echo "***Send 1% of coins on my account to the address labeled 'shibetime1'\n"; // Use high decimal precision for any math on coins. They can be 8 decimal places at most, or the system will reject them as invalid amounts. $sendAmount = bcmul($getBalanceInfo->data->available_balance, '0.01', 8); echo "Available Amount: " . $getBalanceInfo->data->available_balance . " " . $getBalanceInfo->data->network . "\n"; # detour: let's get an estimate of the network fee we'll need to pay for this transaction # use the same parameters you will provide to the withdrawal method get an accurate response $estNetworkFee = $block_io->get_network_fee_estimate(array('to_address' => $getAddressInfo->data->address, 'amount' => $sendAmount)); echo "Estimated Network Fee: " . $estNetworkFee->data->estimated_network_fee . " " . $estNetworkFee->data->network . "\n"; echo "Withdrawing 1% of Available Amount: " . $sendAmount . " " . $getBalanceInfo->data->network . "\n"; try { $withdrawInfo = $block_io->withdraw(array('to_address' => $getAddressInfo->data->address, 'amount' => $sendAmount)); echo "Status: " . $withdrawInfo->status . "\n"; echo "Executed Transaction ID: " . $withdrawInfo->data->txid . "\n"; echo "Network Fee Charged: " . $withdrawInfo->data->network_fee . " " . $withdrawInfo->data->network . "\n"; } catch (Exception $e) { echo $e->getMessage() . "\n"; }