/**
  * @param string $token
  * @return bool
  */
 public function authenticate($token)
 {
     $apiContext = $this->apiContextFactory->getApiContext(self::AUTH_WALLET_COIN_SYMBOL, $token);
     $walletClient = new WalletClient($apiContext);
     try {
         // Create BlockCypher wallet
         $bcWallet = new BlockCypherWallet();
         $bcWallet->setToken($token);
         $bcWallet->setName(self::AUTH_WALLET_NAME);
         $bcWallet = $walletClient->create($bcWallet);
         if ($bcWallet && $bcWallet->getName() == self::AUTH_WALLET_NAME) {
             return true;
         } else {
             return false;
         }
     } catch (BlockCypherConnectionException $e) {
         if ($e->getCode() == self::ERROR_WALLET_ALREADY_EXISTS) {
             return true;
         } else {
             return false;
         }
     } catch (\Exception $e) {
         return false;
     }
 }
<?php

// Run on console:
// php -f .\sample\wallet-api\AddAddressesToWalletEndpoint.php
require __DIR__ . '/../bootstrap.php';
use BlockCypher\Api\AddressList;
use BlockCypher\Auth\SimpleTokenCredential;
use BlockCypher\Client\WalletClient;
use BlockCypher\Rest\ApiContext;
$apiContext = ApiContext::create('main', 'btc', 'v1', new SimpleTokenCredential('c0afcccdde5081d6429de37d16166ead'), array('mode' => 'sandbox', 'log.LogEnabled' => true, 'log.FileName' => 'BlockCypher.log', 'log.LogLevel' => 'DEBUG'));
$walletClient = new WalletClient($apiContext);
$addressList = AddressList::fromAddressesArray(array("13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j"));
$wallet = $walletClient->addAddresses('alice', $addressList);
ResultPrinter::printResult("Add Addresses to a Wallet Endpoint", "Wallet", 'alice', $addressList, $wallet);
<?php

// Run on console:
// php -f .\sample\wallet-api\RemoveAddressesFromWalletEndpoint.php
require __DIR__ . '/../bootstrap.php';
use BlockCypher\Api\AddressList;
use BlockCypher\Auth\SimpleTokenCredential;
use BlockCypher\Client\WalletClient;
use BlockCypher\Rest\ApiContext;
$apiContext = ApiContext::create('main', 'btc', 'v1', new SimpleTokenCredential('c0afcccdde5081d6429de37d16166ead'), array('mode' => 'sandbox', 'log.LogEnabled' => true, 'log.FileName' => 'BlockCypher.log', 'log.LogLevel' => 'DEBUG'));
$walletClient = new WalletClient($apiContext);
// List of addresses to be removed from the wallet
$addressList = AddressList::fromAddressesArray(array("13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j"));
$wallet = $walletClient->removeAddresses('alice', $addressList);
ResultPrinter::printResult("Remove Addresses From Wallet Endpoint", "Wallet", 'alice', $addressList, $wallet);
<?php

// Run on console:
// php -f .\sample\wallet-api\WalletAddressesEndpoint.php
require __DIR__ . '/../bootstrap.php';
use BlockCypher\Auth\SimpleTokenCredential;
use BlockCypher\Client\WalletClient;
use BlockCypher\Rest\ApiContext;
$apiContext = ApiContext::create('main', 'btc', 'v1', new SimpleTokenCredential('c0afcccdde5081d6429de37d16166ead'), array('mode' => 'sandbox', 'log.LogEnabled' => true, 'log.FileName' => 'BlockCypher.log', 'log.LogLevel' => 'DEBUG'));
$walletClient = new WalletClient($apiContext);
$addressList = $walletClient->getWalletAddresses('alice');
ResultPrinter::printResult("Wallet Addresses endpoint", "AddressList", 'alice', null, $addressList);
<?php

// Run on console:
// php -f .\sample\wallet-api\GenerateAddressInWalletEndpoint.php
require __DIR__ . '/../bootstrap.php';
use BlockCypher\Auth\SimpleTokenCredential;
use BlockCypher\Client\WalletClient;
use BlockCypher\Rest\ApiContext;
$apiContext = ApiContext::create('main', 'btc', 'v1', new SimpleTokenCredential('c0afcccdde5081d6429de37d16166ead'), array('mode' => 'sandbox', 'log.LogEnabled' => true, 'log.FileName' => 'BlockCypher.log', 'log.LogLevel' => 'DEBUG'));
$walletClient = new WalletClient($apiContext);
$walletGenerateAddressResponse = $walletClient->generateAddress('alice');
ResultPrinter::printResult("Generate Address In Wallet Endpoint", "Wallet", 'alice', null, $walletGenerateAddressResponse);
<?php

// Run on console:
// php -f .\sample\wallet-api\CreateWalletEndpoint.php
require __DIR__ . '/../bootstrap.php';
use BlockCypher\Api\Wallet;
use BlockCypher\Auth\SimpleTokenCredential;
use BlockCypher\Client\WalletClient;
use BlockCypher\Rest\ApiContext;
$apiContext = ApiContext::create('main', 'btc', 'v1', new SimpleTokenCredential('c0afcccdde5081d6429de37d16166ead'), array('mode' => 'sandbox', 'log.LogEnabled' => true, 'log.FileName' => 'BlockCypher.log', 'log.LogLevel' => 'DEBUG'));
// Create a new instance of Wallet object
$wallet = new Wallet();
$wallet->setName('alice');
$wallet->setAddresses(array("1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"));
// For Sample Purposes Only.
$request = clone $wallet;
$walletClient = new WalletClient($apiContext);
$createdWallet = $walletClient->create($wallet);
ResultPrinter::printResult("Created Wallet End Point", "Wallet", $createdWallet->getName(), $request, $createdWallet);
 /**
  * @dataProvider mockProvider
  * @param WalletClient $obj
  * @param PHPUnit_Framework_MockObject_MockObject|ApiContext $mockApiContext
  * @param PHPUnit_Framework_MockObject_MockObject|BlockCypherRestCall $mockBlockCypherRestCall
  */
 public function testDelete($obj, $mockApiContext, $mockBlockCypherRestCall)
 {
     $mockBlockCypherRestCall->expects($this->any())->method('execute')->will($this->returnValue(true));
     $result = $obj->delete(WalletTest::getObject()->getName(), array(), $mockApiContext, $mockBlockCypherRestCall);
     $this->assertNotNull($result);
 }
<?php

// Run on console:
// php -f .\sample\wallet-api\GetWalletEndpoint.php
require __DIR__ . '/../bootstrap.php';
use BlockCypher\Auth\SimpleTokenCredential;
use BlockCypher\Client\WalletClient;
use BlockCypher\Rest\ApiContext;
$apiContext = ApiContext::create('main', 'btc', 'v1', new SimpleTokenCredential('c0afcccdde5081d6429de37d16166ead'), array('mode' => 'sandbox', 'log.LogEnabled' => true, 'log.FileName' => 'BlockCypher.log', 'log.LogLevel' => 'DEBUG'));
$walletClient = new WalletClient($apiContext);
$wallet = $walletClient->get('alice');
ResultPrinter::printResult("Get a Wallet", "Wallet", $wallet->getName(), null, $wallet);
<?php

// Run on console:
// php -f .\sample\wallet-api\DeleteWalletEndpoint.php
require __DIR__ . '/../bootstrap.php';
use BlockCypher\Auth\SimpleTokenCredential;
use BlockCypher\Client\WalletClient;
use BlockCypher\Rest\ApiContext;
$apiContext = ApiContext::create('main', 'btc', 'v1', new SimpleTokenCredential('c0afcccdde5081d6429de37d16166ead'), array('mode' => 'sandbox', 'log.LogEnabled' => true, 'log.FileName' => 'BlockCypher.log', 'log.LogLevel' => 'DEBUG'));
$walletClient = new WalletClient($apiContext);
$result = $walletClient->delete('alice');
ResultPrinter::printResult("Delete Wallet Endpoint", "Wallet", 'alice', null, $result);
 /**
  * @param $walletName
  * @param $coinSymbol
  * @param $token
  * @return \string[]
  */
 public function getWalletAddresses($walletName, $coinSymbol, $token)
 {
     $apiContext = $this->apiContextFactory->getApiContext($coinSymbol, $token);
     $walletClient = new WalletClient($apiContext);
     $addressList = $walletClient->getWalletAddresses($walletName);
     $addresses = $addressList->getAddresses();
     return $addresses;
 }