Basic MultiSig Wallet API ()

Our Basic Multi-Signature addresses by default require two signatures for all withdrawals: yours, and Block.io's. This method provides exponentially higher security for your Wallets and applications than single-signature addresses. This way, you spend coins yourself, without trusting Block.io with your credentials.

All addresses generated using this API are considered Green, i.e., they can send and receive funds without waiting for confirmations. This is possible since Block.io guarantees coins can never be spent twice. Furthermore, all transactions occur on the Blockchain.

If you require a more elaborate configuration to customize your applications' security, inquire about our Distributed Trust framework by going here. This framework allows up to 5 signatures per address. The use cases are endless!

Getting Started

First, you will need your API Keys, which we provide for Bitcoin, Dogecoin, Litecoin, and their Testnets. These API Keys are located in your Wallet. You are required to use an API Key when you interact with Block.io. It tells Block.io which network (e.g., Bitcoin) you wish to perform actions on.

Installing the Library

Fork me on GitHub

You can download and install the official PHP library using Composer:


"block_io-php/block_io-php": "1.1.3"
      

Or manually require it in your PHP project (download from here):


require_once 'path/to/block_io.php';
      

This library requires the mCrypt, GMP, and cURL extensions to work.

Before you start using the PHP library in your code, initialize it like so:


> $apiKey = "YOUR API KEY FOR BITCOIN, DOGECOIN, OR LITECOIN";
> $version = 2; // API version
> $pin = "YOUR SECRET PIN";
> $block_io = new BlockIo($apiKey, $pin, $version);

If you're using Windows, you must do the following to make the library work properly:

  • 1. Download this file to a directory of your choice
  • 2. Make PHP use this file to validate Block.io's SSL certificate by adding this line to your php.ini:
    
    curl.cainfo=c:\path\to\cacert.pem
          

Now you're good to go. Here's an example call:


> $newAddressInfo = $block_io->get_new_address(array('label' => 'shibe1'));
      

Methods for Handling Addresses

Get New Address

Returns a newly generated address, and its unique(!) label generated by Block.io. You can optionally specify a custom label.


$block_io->get_new_address();
$block_io->get_new_address(array('label' => 'LABEL'));
      

Get a new address with a random label

API KEY: (Your API Keys are in your Wallet)

Get a new address with a given label

API KEY: (Your API Keys are in your Wallet)

LABEL:


Get Balance

Returns the balance of your entire Bitcoin, Litecoin, or Dogecoin account (i.e., the sum of balances of all addresses/users within it) as numbers to 8 decimal points, as strings.


$block_io->get_balance();
      

Get account balance

API KEY: (Your API Keys are in your Wallet)


Get My Addresses

Returns the (unarchived) addresses, their labels, user ids, and balances on your account.

Do not use this if you plan on having more than 2,500 addresses on your account. Use get_address_balance (below) instead.


$block_io->get_my_addresses();
      

Get my addresses

API KEY: (Your API Keys are in your Wallet)


Get My Addresses (No Balances)

Returns all the (unarchived) addresses, their labels, and user ids on your account.


$block_io->get_my_addresses_without_balances();
      

Get my addresses without balances

API KEY: (Your API Keys are in your Wallet)


Get Address Balance

Returns the balance of the specified addresses, or labels.

Can be used to query balances for external (non-account) addresses. If an external address' balance is returned, its user_id and label fields will be null.


$block_io->get_address_balance(array('addresses' => 'ADDRESS1,ADDRESS2,...'));
$block_io->get_address_balance(array('labels' => 'LABEL1,LABEL2,...'));
      

Get the balance of a given address

API KEY: (Your API Keys are in your Wallet)

ADDRESSES:

Get the balance of an address with a given label

API KEY: (Your API Keys are in your Wallet)

LABELS:


Get Address By Label

Returns the address specified by a label.


$block_io->get_address_by_label(array('label' => 'LABEL'));
      

Get the address for a given label

API KEY: (Your API Keys are in your Wallet)

LABEL:

Withdrawal Methods

Overview

Block.io eases your burden of storing information regarding users' addresses, labels, and user IDs. Below, we provide various methods that allow you to make fine-grained withdrawals from your account(s). You can withdraw from any addresses, from specific addresses, from specific user ids, and from specific labels, and you can send the specified amounts to up to 2500 destination addresses, users, or labels in a single API call.

The amount withdrawn must at least be 2 DOGE, 0.00002 BTC, or 0.002 LTC. Please keep at least 1 DOGE, 0.0002 BTC, or 0.001 LTC for network fees. There are no Block.io fees. Larger transactions (in bytes) will incur larger amounts of network fees as per Bitcoin/Dogecoin/Litecoin specifications. As of 06/09/15, you can now specify an additional parameter priority={low,medium,high} to increase the network fee paid in the given transaction. More specifically, priorities of low, medium, high will pay 1x, 2x, and 3x the minimum network fees possible on the network, respectively. As of 07/07/15, network fees will auto-scale according to network loads if the priority parameter is not provided.

Ensuring Uniqueness of Withdrawals Client-side human or machine error can lead to multiple executions of the same withdrawal request. If such an error occurs, you will lose money. To ensure the uniqueness of withdrawal requests, you can specify a nonce=value parameter with your withdrawal requests, where value is an alpha-numeric string between 1 and 64 characters long. Withdrawal requests that provide duplicate nonces less than 1 hour apart will be rejected. This is an optional but recommended security measure.

Withdraw

Withdraws amount of coins from any addresses in your account to up to 2500 destination addresses.

Effective 02/10/15: If you have more than 2500 unarchived addresses on your account, you cannot use this method for withdrawal. Please use the more granular withdraw_from_addresses, and withdraw_from_labels methods instead.


$block_io->withdraw(array('amounts' => 'AMOUNT1,AMOUNT2,...', 'to_addresses' => 'ADDRESS1,ADDRESS2,...'));
      

Withdraw amount and send to upto 2500 addresses

API KEY: (Your API Keys are in your Wallet)

AMOUNTS:

TO ADDRESSES:

PIN:


Withdraw From Addresses

Withdraws AMOUNT coins from upto 2500 addresses at a time, and deposits it to up to 2500 destination addresses.


$block_io->withdraw_from_addresses(array('amounts' => 'AMOUNT1,AMOUNT2,...', 'from_addresses' => 'ADDRESS1,ADDRESS2,...', 'to_addresses' => 'ADDRESS1,ADDRESS2,...'));
      

Withdraw amount from specific addresses and send it to up to 2500 addresses

API KEY: (Your API Keys are in your Wallet)

AMOUNTS:

FROM ADDRESSES:

TO ADDRESSES:

PIN:


Withdraw From Labels

Withdraws AMOUNT coins from upto 2500 labels at a time, and deposits it to upto 2500 destination addresses, or labels.


$block_io->withdraw_from_labels(array('amounts' => 'AMOUNT1,AMOUNT2,...', 'from_labels' => 'LABEL1,LABEL2,...', 'to_addresses' => 'ADDRESS1,ADDRESS2,...'));
$block_io->withdraw_from_labels(array('amounts' => 'AMOUNT1,AMOUNT2,...', 'from_labels' => 'LABEL1,LABEL2,...', 'to_labels' => 'LABEL1,LABEL2,...'));
      

Withdraw amount from specific labels and send it to upto 2500 destination addresses

API KEY: (Your API Keys are in your Wallet)

AMOUNTS:

FROM LABELS:

TO ADDRESSES:

PIN:

Withdraw amount from specific labels and send it to upto 2500 labels

API KEY: (Your API Keys are in your Wallet)

AMOUNTS:

FROM LABELS:

TO LABELS:

PIN:

The amounts=AMOUNT1,AMOUNT2,... and to_addresses=ADDRESS1,ADDRESS2,... parameters specify that destination ADDRESS1 will receive AMOUNT1, ADDRESS2 will receive AMOUNT2, etc. The source addresses (from_addresses=...) will need at least SUM(AMOUNT1,AMOUNT2...)+Network Fees in balances for this withdrawal to succeed.


Estimate Network Fee

Estimates the Network Fee you will need to pay when you make a withdrawal request. The Network Fee is required by the Bitcoin/Dogecoin/etc. networks, not Block.io.

Please use the same parameters as you would with any withdrawal API call; only one example is given below.


$block_io->get_network_fee_estimate(array('amounts' => 'AMOUNT1,AMOUNT2,...', 'to_addresses' => 'ADDRESS1,ADDRESS2,...'));
      

Estimate network fee to be paid on withdrawal of given amounts to upto 2500 addresses

API KEY: (Your API Keys are in your Wallet)

AMOUNTS:

TO ADDRESSES:

Address Archival Methods

Archiving of addresses help you control account bloat due to a large number of addresses.

When an address is archived, it is:

  • Not displayed in your wallet dashboard.
  • Not included in the get_my_addresses API call.
  • Not used to get available account balance.
  • Not used as a withdrawal address, unless specified.

Address archival can greatly enhance the operational security of your applications by allowing you to move coins to new addresses without clogging your API call responses.

Archive Addresses

Archives upto 100 addresses in a single API call. Addresses can be specified by their labels.


$block_io->archive_addresses(array('addresses' => 'ADDRESS1,ADDRESS2,...'));
$block_io->archive_addresses(array('labels' => 'LABEL1,LABEL2,...'));
      

Archive an address on your account

API KEY: (Your API Keys are in your Wallet)

ADDRESSES:


Unarchive Addresses

Unarchives upto 100 addresses in a single API call. Addresses can be specified by their labels.


$block_io->unarchive_addresses(array('addresses' => 'ADDRESS1,ADDRESS2,...'));
$block_io->unarchive_addresses(array('labels' => 'LABEL1,LABEL2,...'));
      

Unarchive an address on your account

API KEY: (Your API Keys are in your Wallet)

ADDRESSES:


Get My Archived Addresses

Returns all the archived addresses, their labels, and user ids on your account.


$block_io->get_my_archived_addresses();
      

Get my archived addresses

API KEY: (Your API Keys are in your Wallet)

Misc. Methods

Get Current Price

Returns the prices from the largest exchanges for Bitcoin, Dogecoin, or Litecoin, specified by the API Key. Specifying the base currency is optional.


$block_io->get_current_price();
$block_io->get_current_price(array('price_base' => 'BASE CURRENCY'));
      

Get current price of Bitcoin, Dogecoin, or Litecoin in all base currencies

API KEY: (Your API Keys are in your Wallet)

Get current price of Bitcoin, Dogecoin, or Litecoin in a given base currency

API KEY: (Your API Keys are in your Wallet)

PRICE BASE:

Is Green Address?

Returns an array of Block.io Green Addresses. Funds sent from Green Addresses are guaranteed by Block.io, and can be used immediately on receipt with zero network confirmations. This API call does not need an API Key.


$block_io->is_green_address(array('addresses' => 'ADDRESS1,ADDRESS2,...'));
      

Verify if a given address is a Block.io Green Address

ADDRESSES:

Is Green Transaction?

Returns an array of transactions that were sent by Block.io Green Addresses. Funds sent from Green Addresses are guaranteed by Block.io, and can be used immediately on receipt with zero network confirmations. This API call does not need an API Key.


$block_io->is_green_transaction(array('transaction_ids' => 'TXID1,TXID2,...'));
      

Verify if a given transaction was sent by a Block.io Green Address

TRANSACTION IDS:

Get Transactions

Returns various data for the last 25 transactions spent or received. You can optionally specify a before_tx parameter to get earlier transactions.

You can use this method to query for addresses that are not on your account.

Each result provides a confidence rating that shows the network's belief in the transaction's viability. This is useful if you need to validate transactions quickly (for e.g., in retail store settings) without waiting for confirmations. We recommend waiting for confidence ratings to reach 0.90-0.99 for unconfirmed transactions if you need to validate it. For unconfirmed transactions, you are also provided with the number of nodes (propagated_by_nodes) on the Network that approve of the given unconfirmed transaction (out of 150 sampled nodes).

If a double spend is detected for an unconfirmed transaction, its confidence rating falls to 0.0.


$block_io->get_address_balance(array('type' => 'sent'));
$block_io->get_address_balance(array('type' => 'received'));

$block_io->get_address_balance(array('type' => 'sent', 'before_tx' => 'TXID'));
$block_io->get_address_balance(array('type' => 'received', 'before_tx' => 'TXID'));

$block_io->get_address_balance(array('type' => 'received', 'addresses' => 'ADDRESS1,ADDRESS2,...'));
$block_io->get_address_balance(array('type' => 'received', 'user_ids' => 'USERID1,USERID2,...'));
$block_io->get_address_balance(array('type' => 'received', 'labels' => 'LABEL1,LABEL2,...'));

$block_io->get_address_balance(array('type' => 'sent', 'before_tx' => 'TXID', 'addresses' => 'ADDRESS1,ADDRESS2,...'));
$block_io->get_address_balance(array('type' => 'received', 'before_tx' => 'TXID', 'addresses' => 'ADDRESS1,ADDRESS2,...'));

...
      

Get the last 25 transactions for all addresses

API KEY: (Your API Keys are in your Wallet)

TYPE:

Get the last 25 transactions for specific addresses

API KEY: (Your API Keys are in your Wallet)

TYPE:

ADDRESSES:

Get 25 transactions for all addresses before a transaction occurred

API KEY: (Your API Keys are in your Wallet)

TYPE:

BEFORE TX: