khomerikik/laravel-bitgo-wallet

Bitgo blockchain service integration for laravel


README

68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f737570706f72742d756b7261696e652e7376673f743d31

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.