Giter VIP home page Giter VIP logo

easyblockchain's Introduction

PHP Easy Blockchain Api

Requirement

  1. PHP >= 7.4
  2. Composer

Installation

$ composer require "stingbo/easyblockchain" -vvv

Usage

Tron

🚀 Quick Start
<?php

use EasyBlockchain\Factory;

$config = [
    'tron' => [
        'response_type' => 'array',
        'base_uri' => 'http://127.0.0.1:8090',
        'app_key' => 'YOUR TRON API KEY',
        'app_key_uri' => 'https://api.trongrid.io',
        'log' => [
            'default' => 'dev', // 默认使用的 channel,生产环境可以改为下面的 prod
            'channels' => [
                'dev' => [ // 测试环境
                    'driver' => 'daily',
                    'path' => '/tmp/tron.log',
                    'level' => 'debug',
                    'days' => 60,
                ],
                'prod' => [ // 生产环境
                    'driver' => 'daily',
                    'path' => '/tmp/tron.log',
                    'level' => 'debug',
                    'days' => 90,
                ],
            ],
        ],
    ],
];

// 调用通用API
$app = Factory::tron($config['tron']);
$app->client->get('/wallet/generateaddress');

// 调用Trongrid API,有APIKEY标识,则会自动在header里带上此参数,并调用app_key_uri的地址
$block_number = 88888;
$data = $app->client->get("/v1/blocks/{$block_number}/events", [
    'only_confirmed' => $params['only_confirmed'] ?? true,
    'limit' => $params['limit'] ?? 100,
    'fingerprint' => $params['fingerprint'] ?? '',
], 'APIKEY');

ETH

🚀 Quick Start
<?php

use EasyBlockchain\Factory;

$config = [
    'eth' => [
        'response_type' => 'array',
        'base_uri' => 'http://127.0.0.1:8545',
        'log' => [
            'default' => 'dev', // 默认使用的 channel,生产环境可以改为下面的 prod
            'channels' => [
                'dev' => [ // 测试环境
                    'driver' => 'daily',
                    'path' => '/tmp/eth.log',
                    'level' => 'debug',
                    'days' => 60,
                ],
                'prod' => [ // 生产环境
                    'driver' => 'daily',
                    'path' => '/tmp/eth.log',
                    'level' => 'debug',
                    'days' => 90,
                ],
            ],
        ],
    ],
];

$app = Factory::eth($config['eth']);
$result = $app->client->postJson('', [
    'jsonrpc' => '2.0',
    'method' => 'eth_accounts',
    'params' => [],
    'id' => 1,
]);

easyblockchain's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

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.