我正在尝试使用coinbase.com钱包API发送付款。我在GitHub上找到了一个代码,使用它我成功将付款发送到了LTC地址。这是代码:
<?php
include 'vendor/autoload.php';
$apiKey = 'MY_API_HERE';
$apiSecret = 'MY_SECRET_HERE';
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;
$configuration = Configuration::apiKey($apiKey, $apiSecret);
$client = Client::create($configuration);
use Coinbase\Wallet\Enum\CurrencyCode;
use Coinbase\Wallet\Resource\Transaction;
use Coinbase\Wallet\Value\Money;
$accountId = "MY_LTC_ACCOUNT_ID_HERE";
$account = $client->getAccount($accountId);
$transaction = Transaction::send([
'toBitcoinAddress' => 'PAYMENT_ADDRESS',
'amount' => new Money(AMOUNT_OF_LTC_HERE, CurrencyCode::LTC)
]);
try {
$client->createAccountTransaction($account, $transaction);
}
catch(Exception $e) {
echo $e->getMessage();
}
?>
我包含的文件在https://darkchannel.info/coinbase/vendor.zip
但是我不知道如何获取交易哈希(硬币交易ID)。
答案 0 :(得分:1)
您仍具有$transaction
的初始事务,因此在网络中创建事务后,您可以使用代码$transaction->getNetwork()-> getHash()
访问哈希。