-
Notifications
You must be signed in to change notification settings - Fork 24
API usage
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.
- Loading library
- Create wallet
- Send funds
- Send to multiple addresses
- Get wallet balance
- List addresses
- Get address balance
- Create new address
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($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($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_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)
wallet_balance()
list_addresses()
address_balance($address)
-
address
- Bitcoin address to lookup.
new_address($label = NULL)
-
label
- The new address's label. (optional)