Skip to content

charonne/block-io-exercice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 

Repository files navigation

block-io-exercice

Make a testnet payment in php with block.io

Get a block.io account

Go on https://www.block.io and create an account (you can skip the Plan choice)
Choose Testnest -> Bitcoin (Testnet)
Click on Show API Keys and get the Bitcoin key

Install

Get the project

Clone this project, go in the project directory
cd block-io-exercice

Configure

Edit
index.php
and add your Bitcoin api key $apiKey = 'xxxx-xxxx-xxxx-xxxx';
and your pin password $pin = 'xxxxxx';

Test

Execute
php index.php
Then you should see the balance of the 2N6rmc2rcsFnPQHPskzVRGQ9XyHbEmyPudX address
You can verify on http://tbtc.blockr.io/address/info/2N6rmc2rcsFnPQHPskzVRGQ9XyHbEmyPudX (it's not block.io, but blockr.io services)

You might need to install some packages
apt-get update && apt-get -y install php5-curl php5-mcrypt

Exercice

Purpose

Make payments with the block.io PHP API

Details

Use the withdraw_from_addresses() function to make payments. Details are on the block.io PHP API documentation: https://www.block.io/api/simple/php
Note: You are identified in block.io with your API key, so you don't need to use any private key on the 'from_addresses' => 'ADDRESS1,ADDRESS2,...', just your block.io public key.

You can make a test payment on 2N6rmc2rcsFnPQHPskzVRGQ9XyHbEmyPudX
For your test, you can have free testnet bitcoins on https://testnet.manu.backend.hamburg/faucet

Improvement

You can use get_my_addresses() to automaticaly select the address with enough bitcoin.
Example:
$totalAmount = 0.001;
$blockAddresses = $block_io->get_my_addresses();
foreach($blockAddresses->data->addresses as $address) {
    if ($address->available_balance > $totalAmount) {
        $paymentAddress = $address->address;
        break;
    }
}

About

Make a testnet payment in php with block.io

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages