eldarqa/bitaps-wallet-api

Bitaps PHP API

v1.0.0 2021-01-17 15:57 UTC

This package is auto-updated.

Last update: 2024-09-08 20:29:01 UTC


README

License Scrutinizer code quality (GitHub/Bitbucket) Build Status GitHub release (latest SemVer)

Bitaps 钱包 API

此仓库提供了 Bitaps 钱包 API(https://developer.bitaps.com/wallet)的 PHP 方法。此包支持 API 所有的货币(BTC、LTC、BHC、ETH)以及所有端点(主网、测试网、TOR 主网)

需求

  • PHP 7.4 或更高版本
  • cURL

安装

composer require eldarqa/bitaps-wallet-api

如何使用

别忘了设置您的端点 :) https://developer.bitaps.com/wallet#API_endpoint

1. 创建钱包

// use Bitaps\WalletAPI\WalletAPI;

$endpoint = "https://api.bitaps.com/btc/testnet/v1";

$api = new WalletAPI($endpoint);
$create = $api->createWallet(); 
// it's recommended to set the password, just use: $api->createWallet($callbackLink, $password);

// $create->getWalletId();

2. 创建钱包支付地址

// use Bitaps\WalletAPI\WalletAPI;

$endpoint = "https://api.bitaps.com/btc/testnet/v1";
$walletId = "your wallet ID";
$password = "your password (if requires)"; 

$api = new WalletAPI($endpoint, $walletId, $password);
$address = $api->addAddress();

//$address->getAddress(); 

3. 发送支付

// use Bitaps\WalletAPI\WalletAPI;

$endpoint = "https://api.bitaps.com/btc/testnet/v1";
$walletId = "your wallet ID";
$password = "your password (if requires)"; 

$api = new WalletAPI($endpoint, $walletId, $password);

$receiverAddress = "abcdefg123456xxxx";
$receiverAmount = 30000; // In Satoshi

$payment = $api->addPayment($receiverAddress, $receiverAmount)->pay();

//$receivers = $payment->getTxList();
//
//foreach ($receivers as $receiver) {
//    var_dump($receiver->getTxHash());
//}

您可以添加更多接收者

$receiverAddress = "abcdefg123456xxxx";
$receiverAmount = 30000; // In Satoshi

$secondReceiverAddress = "qwerty25525woo";
$secondReceiverAmount = 40000; // In Satoshi

$thirdReceiverAddress = "zyxwe135679zzz";
$thirdReceiverAmount = 50000; // In Satoshi


$payment = $api->addPayment($receiverAddress, $receiverAmount)
               ->addPayment($secondReceiverAddress, $secondReceiverAmount)
               ->addPayment($thirdReceiverAddress, $thirdReceiverAmount)
               ->pay();

4. 钱包状态

// use Bitaps\WalletAPI\WalletAPI;

$endpoint = "https://api.bitaps.com/btc/testnet/v1";
$walletId = "your wallet ID";
$password = "your password (if requires)"; 

$api = new WalletAPI($endpoint, $walletId, $password);

$state = $api->getWalletState();

//$state->getBalanceAmount();

5. 钱包交易列表

// use Bitaps\WalletAPI\WalletAPI;

$endpoint = "https://api.bitaps.com/btc/testnet/v1";
$walletId = "your wallet ID";
$password = "your password (if requires)"; 

$api = new WalletAPI($endpoint, $walletId, $password);

$transactions = $api->getTransactions();

//$transactions->getTransactions();
//$transactions->getPendingTransactions();

6. 钱包地址列表

// use Bitaps\WalletAPI\WalletAPI;

$endpoint = "https://api.bitaps.com/btc/testnet/v1";
$walletId = "your wallet ID";
$password = "your password (if requires)"; 

$api = new WalletAPI($endpoint, $walletId, $password);

$addresses = $api->getAddresses();

//foreach ($addresses->getTxList() as $address)
//{
//    $address->getReceivedAmount();
//}

7. 钱包地址交易列表

// use Bitaps\WalletAPI\WalletAPI;

$endpoint = "https://api.bitaps.com/btc/testnet/v1";
$walletId = "your wallet ID";
$password = "your password (if requires)"; 

$api = new WalletAPI($endpoint, $walletId, $password);

$address = "abcde123456789fghijkl";
$transactions = $api->getAddressTransactions($address);

//$transactions->getTransactions();
//$transactions->getPendingTransactions();

8. 每日钱包统计数据

// use Bitaps\WalletAPI\WalletAPI;

$endpoint = "https://api.bitaps.com/btc/testnet/v1";
$walletId = "your wallet ID";
$password = "your password (if requires)"; 

$api = new WalletAPI($endpoint, $walletId, $password);

$statistics = $api->getDailyStatistics();

//foreach ($statistics->getDayList() as $data)
//{
//    $data->getBalanceAmount();
//}