oasin / laravel-bitgo-wallet
Bitgo blockchain service integration for laravel
dev-main
2024-07-07 17:50 UTC
Requires
- php: ^8.1
- ext-readline: *
- guzzlehttp/guzzle: ^7.4
- illuminate/contracts: ^10.10|^11.0
- illuminate/support: ^10.0|^11.0
- spatie/laravel-package-tools: ^1.9.2|^1.16.4
Requires (Dev)
- jetbrains/phpstorm-attributes: ^1.0
- larastan/larastan: ^2.1
- laravel/pint: ^1.1
- launchdarkly/launchdarkly-php: ^6.0
- nunomaduro/collision: ^7.0|^8.1
- orchestra/testbench: ^8.2
- pestphp/pest: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^11.0
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2024-11-07 18:37:18 UTC
README
You can install the package via composer:
composer require khomerikik/laravel-bitgo-wallet
You can publish the config file with:
php artisan vendor:publish --provider="Khomeriki\BitgoWallet\BitgoServiceProvider"
This is the contents of the published config file:
Usage
Generate a wallet with webhooks
use Khomeriki\BitgoWallet\Facades\Wallet; $wallet = Wallet::init(coin: 'tbtc') ->generate(label: 'wallet label', passphrase: 'password') ->addWebhook(numConfirmations: 0) ->addWebhook(numConfirmations: 1); return $wallet;
Add webhook on a wallet with custom callback url
use Khomeriki\BitgoWallet\Facades\Wallet; $wallet = Wallet::init(coin: 'tbtc', id: 'wallet-id') ->addWebhook( numConfirmations: 3, callbackUrl: 'https://your-domain.com/api/callback' ); return $wallet;
Generate address on an existing wallet
use Khomeriki\BitgoWallet\Facades\Wallet; $wallet = Wallet::init(coin: 'tbtc', id: 'your-wallet-id') ->generateAddress(label: 'address label'); return $wallet->address;
Check maximum spendable amount on a wallet
use Khomeriki\BitgoWallet\Facades\Wallet; $maxSpendable = Wallet::init(coin: 'tbtc', id: 'your-wallet-id') ->getMaximumSpendable(); return $maxSpendable;
Get all the transactions on wallet
use Khomeriki\BitgoWallet\Facades\Wallet; $transfers = Wallet::init(coin: 'tbtc', id: 'your-wallet-id') ->getTransfers(); return $transfers;
Get transfer by transfer id
use Khomeriki\BitgoWallet\Facades\Wallet; $transfer = Wallet::init(coin: 'tbtc', id: 'your-wallet-id') ->getTransfer(transferId: 'transferId'); return $transfer;
Send transfer from a wallet
use Khomeriki\BitgoWallet\Data\Requests\TransferData;use Khomeriki\BitgoWallet\Data\Requests\TransferRecipientData;use Khomeriki\BitgoWallet\Facades\Wallet; //you can add as many recipients as you need :) $recipient = TransferRecipientData::fromArray([ 'amount' => 4934, 'address' => 'address' ]); $recipientOne = TransferRecipientData::fromArray([ 'amount' => 4934, 'address' => 'address' ]); $transferData = TransferData::fromArray([ 'walletPassphrase' => 'test', 'recipients' => [$recipient, $recipientOne] ]); $result = Wallet::init('tbtc', 'wallet-id')->sendTransfer($transferData); return $result;
Testing
composer test
Credits
License
The MIT License (MIT). Please see License File for more information.