oasin/laravel-bitgo-wallet

Bitgo blockchain service integration for laravel

dev-main 2024-07-07 17:50 UTC

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.