GithubHelp home page GithubHelp logo

blockavel / lara-block-io Goto Github PK

View Code? Open in Web Editor NEW
24.0 8.0 14.0 90 KB

A Laravel Package/Facade for the Block.io API

License: MIT License

PHP 100.00%
blockchain bitcoin bitcoin-wallet bitcoin-api laravel-5-package facade dogecoin litecoin laravel block-io

lara-block-io's Introduction

blockavel/lara-block-io

GitHub license Build Status StyleCI

A Laravel package/facade for the Block.io API PHP wrapper.

This repository implements a simple Service Provider of the Block.io client, and makes it easily accessible via a Facade in Laravel >= 5.

See @BlockIo/block_io-php and the BlockIo PHP API docs for more information about the PHP wrapper of the Block.io API and its interfaces.

Requirements

Create an account at Block.io and take note of your API key under Account > Dashboard.

The BlockIo library requires the 'mcrypt' (please note that mcrypt has been deprecated for php7.1), 'gmp', and 'cURL' extensions for PHP as well as the 'bcmath' library. To enable these, please see:

-mCrypt Installation Guide

-GMP Installation Guide

-cURL Installation Guide

-bcmath Installation Guide

Installation using Composer

In your terminal application move to the root directory of your laravel project using the cd command and require the project as a dependency using composer.

composer require blockavel/lara-block-io

This will add the following lines to your composer.json and download the project and its dependencies to your projects ./vendor directory:

// 

./composer.json
{
    "name": "blockavel/lara-block-io",
    "description": "A dummy project used to test the Laravel Block.io Facade.",

    // ...

    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.2.*",
        "blockavel/lara-block-io": "1.0.*",
        // ...
    },

    //...
}

Usage

In order to use the static interface we must customize the application configuration to tell the system where it can find the new service. Open the file config/app.php and add the following lines ([a], [b]):

// config/app.php

return [

    // ...

    'providers' => [

        // ...

        /*
         * Package Service Providers...
         */
        Blockavel\LaraBlockIo\LaraBlockIoServiceProvider::class, // [a]

        /*
         * Application Service Providers...
         */
        App\Providers\AppServiceProvider::class,
        App\Providers\AuthServiceProvider::class,
        App\Providers\EventServiceProvider::class,
        App\Providers\RouteServiceProvider::class,

    ],

    // ...

    'aliases' => [

        'App' => Illuminate\Support\Facades\App::class,
        'Artisan' => Illuminate\Support\Facades\Artisan::class,

        // ...

        'LaraBlockIo' => 'Blockavel\LaraBlockIo\LaraBlockIoFacade', // [b]
        'Hash' => Illuminate\Support\Facades\Hash::class,

        // ...
    ],

];

Publish Vendor

lara-block-io requires a connection configuration. To get started, you'll need to publish all vendor assets running:

php artisan vendor:publish

This will create a config/larablockio.php file in your app that you can modify to set your configuration. Make sure you check for changes compared to the original config file after an upgrade.

Now you should be able to use the facade within your application. Ex:

namespace App;

use Illuminate\Database\Eloquent\Model;

class BlockIoTest extends Model
{
    /**
     * Get the balance information associated with a Bitcoin Dogecoin,
     * or Litecoin account.
     *
     * @return object Contains balance information
     */
     
    public function test()
    {
        return LaraBlockIo::getBalanceInfo();
    }
}

List of Available Methods

Balance and Network Info

// BlockIo getter method, returns a BlockIo object.
LaraBlockIo::getBlockIo();
// Get the balance information associated with a Bitcoin Dogecoin, or Litecoin account.
LaraBlockIo::getBalanceInfo();
// Get the Network associated with your API KEY.
LaraBlockIo::getNetwork();  
// Get the balance associated with all your addresses in the selected network.
LaraBlockIo::getAvailableBalance();
// Get the the balance that's pending confirmation in the selected network.
LaraBlockIo::getPendingReceivedBalance();
// Get address(es) balance by specified address(es).
LaraBlockIo::getAddressesBalanceByAddress($addresses);
// Get address(es) balance by specified label(s).
LaraBlockIo::getAddressesBalanceByLabels($labels);
// Get user(s) balance.
LaraBlockIo::getUsersBalance($userIds);
// Get network fee estimate for transacting (withdrawing, sending).
LaraBlockIo::getNetworkFeeEstimate($amounts, $addresses);

Addresses

// Create new address.
LaraBlockIo::createAddress($label); 
// Get all the (unarchived) addresses information.
LaraBlockIo::getAddressesInfo();
// Get all the (unarchived) addresses information without balance.
LaraBlockIo::getAddressesInfoWithoutBalances(); 
// Get the (unarchived) addresses associated with your account.
LaraBlockIo::getAddresses(); 
// Get the (unarchived) addresses associated with your account without balance.
LaraBlockIo::getAddressesWithoutBalances();
// Get address by label.
LaraBlockIo::getAddressByLabel($label);
// Get all the users associated with your account in a given network.
LaraBlockIo::getUsers()
// Get a user's address.
LaraBlockIo::getUserAddress($userId);

Withdraw

// Withdraws amount of coins from any addresses in your account.
LaraBlockIo::withdraw($amounts, $toAddresses, $nonce = null);
// Withdraws amount of coins from specific addresses in your account.
LaraBlockIo::withdrawFromAddressesToAddresses($amounts, $fromAddresses, $toAddresses, $nonce = null);
LaraBlockIo::withdrawFromLabelsToLabels($amounts, $fromLabels, $toLabels, $nonce = null);
LaraBlockIo::withdrawFromLabelsToAddresses($amounts, $fromLabels, $toAddresses, $nonce = null);

Archive

// Archive adress(es).
LaraBlockIo::archiveAddressesByAddress($addresses);
LaraBlockIo::archiveAddressesByLabels($labels);
// Unarchive address(es)
LaraBlockIo::unarchiveAddressesByAddress($addresses);
LaraBlockIo::unarchiveAddressesByLabels($labels);
// Returns all the archived addresses.
LaraBlockIo::getArchivedAddresses();

Transactions

// Returns various data for transactions spent or received.
LaraBlockIo::getTransactionsByAddresses($type, $addresses, $beforeTx = null);
LaraBlockIo::getTransactionsByLabels($type, $labels, $beforeTx = null);
LaraBlockIo::getTransactionsByUserIds($type, $userIds, $beforeTx = null);
LaraBlockIo::getReceivedTransactions($beforeTx = null);
LaraBlockIo::getSentTransactions($beforeTx = null);
// Returns the prices from the largest exchanges for the given network.
LaraBlockIo::getCurrentPrice($baseCurrency = null);
// Returns an array of transactions that were sent by Block.io Green Addresses.
LaraBlockIo::isGreenTransaction($txIds);
// Get pending transactions.
LaraBlockIo::getNotConfirmedTxs($toAddress, $confidenceThreshold);

DTrust

// Get all dtrust addresses.
LaraBlockIo::getDTrustAddresses();
// Create a MultiSig address.
LaraBlockIo::createMultiSigAddress($label, $reqSigs, $s1, $s2, $s3 = null, $s4 = null);
// Get details of a dtrust address associated with a given label.
LaraBlockIo::getDTrustInfoByLabel($label);
// Perform a MultiSig withdraw.
LaraBlockIo::multiSigWithdraw($label, $toAddresses, $amount);
// Returns a MultiSig withdraw object for signing.
LaraBlockIo::getMultiSigWithdraw($referenceId);
// Sign MultiSig withdraw.
LaraBlockIo::signMultiSigWithdraw($reference_id, $passphrase);
// Returns sent dtrust transactions.
LaraBlockIo::getSentDTrustTransactions($beforeTx = null);
// Returns received dtrust transactions.
LaraBlockIo::getReceivedDTrustTransactions($beforeTx = null);
// Returns information associated with dtrust transactions.
LaraBlockIo::getDtrustTransactionsByAddresses($type, $addresses, $beforeTx = null);
LaraBlockIo::getDtrustTransactionsByLabels($type, $labels, $beforeTx = null);
LaraBlockIo::getDTrustTransactionsByUserIds($type, $userIds, $beforeTx = null);
// Get balance associated with dtrust addresses.
LaraBlockIo::getDTrustAddressBalance($addresses);
// Archive dtrust addresses.
LaraBlockIo::archiveDTrustAddress($addresses);
// Unarchive dtrust addresses.
LaraBlockIo::unarchiveDTrustAddress($addresses);
// Get archived addresses.
LaraBlockIo::getArchivedDTrustAddresses();
// Get estimated network fee for dtrust transactions.
LaraBlockIo::getNetworkDTrustFeeEstimate($amounts, $fromAddress, $toAddress);

Sweep Funds

// Sweep funds from external address to a BlockIo address.
LaraBlockIo::sweepFromAddress($fromAddress, $toAddress, $privateKey);

Testing

Unit Tests are created with PHPunit and orchestra/testbench, they can be ran with ./vendor/bin/phpunit.

Contributing

Find an area you can help with and do it. Open source is about collaboration and open participation. Try to make your code look like what already exists or better and submit a pull request. Also, if you have any ideas on how to make the code better or on improving the scope and functionality please contact any of the contributors.

License

MIT License.

lara-block-io's People

Contributors

alejandro-carstens avatar narrator avatar scrutinizer-auto-fixer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lara-block-io's Issues

Implementation in Laravel 5.6

Hello, I'm new using composer and laravel.
But I'm trying to implement this package in my project, I used the file with requice_once before, now I want to know how I can call this class inside the controller in laravel. Can you help me? I've done the whole implementation, but I do not know how to call the functions.

Mcyrpt

Hello .. WHat do u mean by mcrypt as been deprecated in php7.1 . Am using php 7.2 and i want to enable mcrypt but am having problem. Thanks

GMP install on homestead

Im having issues installing GMP on my vagrant homestead box (PHP 7.0.13). Is there a failsafe way to go about doing that? Would be a nice addition to the readme. Looking forward to trying this out.

vagrant@homestead:~/Code/myapp$ sudo apt-get install php7.0-gmp
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  php7.0-gmp
0 upgraded, 1 newly installed, 0 to remove and 44 not upgraded.
Need to get 20.7 kB of archives.
After this operation, 97.3 kB of additional disk space will be used.
Err:1 http://ppa.launchpad.net/ondrej/php/ubuntu xenial/main amd64 php7.0-gmp amd64 7.0.13-1+deb.sury.org~xenial+1
  404  Not Found
E: Failed to fetch http://ppa.launchpad.net/ondrej/php/ubuntu/pool/main/p/php7.0/php7.0-gmp_7.0.13-1+deb.sury.org~xenial+1_amd64.deb  404  Not Found

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

mcrypt is deprecated

i use php 7.1.1 and mcrypt is deprecated in my php version.Is there any way around it in other to enable me access the withdraw method.

Class 'App\LaraBlockIo' not found

Hi,

I am trying to implement Block.io get_network_fee_estimate($arr),

when we try
return LaraBlockIo::get_network_fee_estimate($arr);
we getting error
Class 'App\LaraBlockIo' not found,

$arr['amounts'] = 95;
$arr['to_addresses'] = '3BFGYeQC7uSp5pfS7ebs8AN2xQ6VCxtAbs';
we already set in larablockio.php
'apiKey' => env('1059-809b-1b8c-4527'),
'pin' => env('Behala345'),
'version' => env('BLOCKIO_VERSION', 2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.