public function testSatoshiConversion()
 {
     $toSatoshi = [["0.00000001", "1", 1], [1.0E-8, "1", 1], ["0.29560000", "29560000", 29560000], [0.2956, "29560000", 29560000], ["1.0000009", "100000090", 100000090], [1.0000009, "100000090", 100000090], ["1.00000009", "100000009", 100000009], [1.00000009, "100000009", 100000009], ["21000000.00000001", "2100000000000001", 2100000000000001.0], [21000000.00000001, "2100000000000001", 2100000000000001.0], ["21000000.0000009", "2100000000000090", 2100000000000090.0], [21000000.0000009, "2100000000000090", 2100000000000090.0], ["21000000.00000009", "2100000000000009", 2100000000000009.0], [21000000.00000009, "2100000000000009", 2100000000000009.0], ["210000000.00000009", "21000000000000009", 2.100000000000001E+16], [210000000.0000001, "21000000000000009", 2.100000000000001E+16]];
     $toBTC = [["1", "0.00000001"], [1, "0.00000001"], ["29560000", "0.29560000"], [29560000, "0.29560000"], ["100000090", "1.00000090"], [100000090, "1.00000090"], ["100000009", "1.00000009"], [100000009, "1.00000009"], ["2100000000000001", "21000000.00000001"], [2100000000000001.0, "21000000.00000001"], ["2100000000000090", "21000000.00000090"], [2100000000000090.0, "21000000.00000090"], ["2100000000000009", "21000000.00000009"], [2100000000000009.0, "21000000.00000009"], ["21000000000000009", "210000000.00000009"], [2.100000000000001E+16, "210000000.00000009"], ["210000000000000009", "2100000000.00000009"], [2.1E+17, "2100000000.00000009"], ["2100000000000000009", "21000000000.00000009"], [2.1E+18, "21000000000.00000009"]];
     foreach ($toSatoshi as $i => $test) {
         $btc = $test[0];
         $satoshiString = $test[1];
         $satoshiInt = $test[2];
         $string = BlocktrailSDK::toSatoshiString($btc);
         $this->assertEquals($satoshiString, $string, "[{$i}] {$btc} => {$satoshiString} =? {$string}");
         $this->assertTrue($satoshiString === $string, "[{$i}] {$btc} => {$satoshiString} ==? {$string}");
         $int = BlocktrailSDK::toSatoshi($btc);
         $this->assertEquals($satoshiInt, $int, "[{$i}] {$btc} => {$satoshiInt} =? {$int}");
         $this->assertTrue($satoshiInt === $int, "[{$i}] {$btc} => {$satoshiInt} ==? {$int}");
     }
     foreach ($toBTC as $i => $test) {
         $satoshi = $test[0];
         $btc = $test[1];
         $this->assertEquals($btc, BlocktrailSDK::toBTC($satoshi), "[{$i}] {$satoshi} => {$btc}");
         $this->assertTrue($btc === BlocktrailSDK::toBTC($satoshi), "[{$i}] {$satoshi} => {$btc}");
     }
     $this->markTestIncomplete("@TODO: test toBTCString");
 }
<?php

use Blocktrail\SDK\BlocktrailSDK;
require_once __DIR__ . "/../vendor/autoload.php";
$client = new BlocktrailSDK("YOUR_APIKEY_HERE", "YOUR_APISECRET_HERE");
// $client->setCurlDebugging();
// GET request
echo "\n -- Get Address Data -- \n";
$address = $client->address("1dice8EMZmqKvrGE4Qc9bUFf9PX3xaYDp");
var_dump($address['address'], $address['balance'], BlocktrailSDK::toBTC($address['balance']));
// POST Request
echo "\n -- Verify Address -- \n";
$address = "16dwJmR4mX5RguGrocMfN9Q9FR2kZcLw2z";
$signature = "HPMOHRgPSMKdXrU6AqQs/i9S7alOakkHsJiqLGmInt05Cxj6b/WhS7kJxbIQxKmDW08YKzoFnbVZIoTI2qofEzk=";
$result = $client->verifyAddress($address, $signature);
var_dump($result);
// Dealing with numbers
echo "\n -- 123456789 Satoshi to BTC -- \n";
var_dump(BlocktrailSDK::toBTC(123456789));
echo "\n -- 1.23456789 BTC to Satoshi -- \n";
var_dump(BlocktrailSDK::toSatoshi(1.23456789));
use Blocktrail\SDK\BlocktrailSDK;
use Blocktrail\SDK\Connection\Exceptions\ObjectNotFound;
use Blocktrail\SDK\Wallet;
use Blocktrail\SDK\WalletInterface;
require_once __DIR__ . "/../vendor/autoload.php";
$client = new BlocktrailSDK("MY_APIKEY", "MY_APISECRET", "BTC", true, 'v1');
// $client->setVerboseErrors();
// $client->setCurlDebugging();
/**
 * @var $wallet             \Blocktrail\SDK\WalletInterface
 * @var $backupMnemonic     string
 */
try {
    /** @var Wallet $wallet */
    $wallet = $client->initWallet(["identifier" => "example-wallet", "passphrase" => "example-strong-password"]);
} catch (ObjectNotFound $e) {
    list($wallet, $primaryMnemonic, $backupMnemonic, $blocktrailPublicKeys) = $client->createNewWallet(["identifier" => "example-wallet", "passphrase" => "example-strong-password", "key_index" => 9999]);
    $wallet->doDiscovery();
}
// var_dump($wallet->deleteWebhook());
// var_dump($wallet->setupWebhook("http://www.example.com/wallet/webhook/example-wallet"));
// print some new addresses
var_dump($wallet->getAddressByPath("M/9999'/0/0"), $wallet->getAddressByPath("M/9999'/0/1"));
// print the balance
list($confirmed, $unconfirmed) = $wallet->getBalance();
var_dump($confirmed, BlocktrailSDK::toBTC($confirmed));
var_dump($unconfirmed, BlocktrailSDK::toBTC($unconfirmed));
// send a payment (will fail unless you've send some BTC to an address part of this wallet)
$addr = $wallet->getNewAddress();
var_dump($wallet->pay([$addr => BlocktrailSDK::toSatoshi(0.001)]));