0

Hi I am trying to use coinbase api in php.api implementation working fine, I can check balance, creat new address all this are working fine.But facing problem on request bitcoin. I am following coinbase official api librery , accroding documention on mentioned link request fund usage code is

use Coinbase\Wallet\Enum\CurrencyCode;
use Coinbase\Wallet\Resource\Transaction;
use Coinbase\Wallet\Value\Money;

$transaction = Transaction::request([
    'amount'      => new Money(8, CurrencyCode::USD),
    'description' => 'Burrito'
]);

$client->createAccountTransaction($transaction);

And I used exactly what they said, but I am getting error, bellow is my code

<?php
require_once('vendor/autoload.php');

use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;
use Coinbase\Wallet\Enum\CurrencyCode;
use Coinbase\Wallet\Resource\Transaction;
use Coinbase\Wallet\Value\Money;

$apiKey='xxxxxxx';
$apiSecret='xxxxxxx';
$configuration = Configuration::apiKey($apiKey, $apiSecret);
$client = Client::create($configuration);

$transaction = Transaction::request([
    'amount'      => new Money(8, CurrencyCode::USD),
    'description' => 'Burrito'
]);
$client->createAccountTransaction($transaction);
echo json_encode($client->decodeLastResponse());
?>

And error is

Fatal error: Uncaught TypeError: Argument 1 passed to Coinbase\Wallet\Client::createAccountTransaction() must be an instance of Coinbase\Wallet\Resource\Account, instance of Coinbase\Wallet\Resource\Transaction given, called in /file_path/file.php on line 19 and defined in /library_path /vendor/coinbase/coinbase/src/Client.php:359 Stack trace: #0 /file_path/file.php(19): Coinbase\Wallet\Client->createAccountTransaction(Object(Coinbase\Wallet\Resource\Transaction))

1 {main} thrown in /library_path /vendor/coinbase/coinbase/src/Client.php on line 359

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.