コード例 #1
0
ファイル: dtrust.php プロジェクト: e-wiki/block_io-php
    $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;
// let's sign all the inputs we can, one key at a time
foreach ($keys as &$key) {
    foreach ($response->data->inputs as &$input) {
        // iterate over all the inputs
        $dataToSign = $input->data_to_sign;
        // the script sig we need to sign
        foreach ($input->signers as &$signer) {
            // iterate over all the signers for this input
            // find the key that can sign for the signer_public_key
            if ($key->getPublicKey() == $signer->signer_public_key) {
コード例 #2
0
ファイル: basic.php プロジェクト: e-wiki/block_io-php
    echo $e->getMessage() . "\n";
}
echo "\n\n";
echo "*** Create new address\n";
$getNewAddressInfo = "";
try {
    $getNewAddressInfo = $block_io->get_new_address(array('label' => 'shibetime1'));
    echo "New Address: " . $getNewAddressInfo->data->address . "\n";
    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";