/**
  * @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;
     }
 }
 /**
  * @param $walletName
  * @param $coinSymbol
  * @param $token
  * @return BlockCypherWallet
  */
 public function createWallet($walletName, $coinSymbol, $token)
 {
     $apiContext = $this->apiContextFactory->getApiContext($coinSymbol, $token);
     $walletClient = new WalletClient($apiContext);
     // Create BlockCypher wallet
     $bcWallet = new BlockCypherWallet();
     $bcWallet->setToken($token);
     $bcWallet->setName($walletName);
     return $walletClient->create($bcWallet);
 }
<?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 testCreate($obj, $mockApiContext, $mockBlockCypherRestCall)
 {
     $mockBlockCypherRestCall->expects($this->any())->method('execute')->will($this->returnValue(WalletTest::getJson()));
     $result = $obj->create(WalletTest::getObject(), array(), $mockApiContext, $mockBlockCypherRestCall);
     $this->assertNotNull($result);
 }