Skip to content
Mehdi Bounya edited this page Jan 6, 2019 · 3 revisions

First, make sure you read Getting started. All the methods below will return the decoded JSON response from the server.

Contents

Loading library

You can load the library like this:

$this->load->library('blockchain', $config)

Or if you installed it using Composer:

$blockchain = new Blockchain($config);

And you can access the methods like this:

$blockchain->method_name();

$config is an associative array, available keys are:

  • guid - Blockchain Wallet Identifier. (the one used for login - Wallet ID)
  • main_password - Main Blockchain password.
  • second_password - You need to set this if double encryption is enabled .
  • api_code - You API code, required if you are going to use the create_wallet() function.
  • base_url - The base url used for the API. (default: http://127.0.0.1)
  • port - If you would like to set a custom port. (default: 3000)

Create wallet

create_wallet($password, $private_key = NULL, $email = NULL, $label = NULL)
  • password - The new wallet password, must be at least 10 characters.
  • private_key - A private key to add to the wallet (Wallet import format preferred). (optional)
  • email - An e-mail to associate to the new wallet. (optional)
  • label - A label to set for the wallet's first address. (Alphanumeric only) (optional)

Send funds

send($to, $amount, $from = NULL, $fee = NULL)
  • to - Recipient Bitcoin Address.
  • amount - Amount in satoshis.
  • from - Send from a specific Bitcoin Address. (Optional)
  • fee - Transaction fee value in satoshi. (Must be greater than default fee) (Optional)

Send to multiple addresses

send_many($recipients, $from = NULL, $fee = NULL)
  • recipients - Recipients Bitcoin Address as an associative array, 'address' => 'amount in satoshis'.
  • from - Send from a specific Bitcoin Address. (Optional)
  • fee - Transaction fee value in satoshi. (Must be greater than default fee) (Optional)

Get wallet balance

wallet_balance()

List addresses

list_addresses()

Get address balance

address_balance($address)
  • address - Bitcoin address to lookup.

Create new address

new_address($label = NULL)
  • label - The new address's label. (optional)