Interaction With WHALESHARES Blockchain on PHP [PHP Graphene Node Client v5.1.1]

Words
276
Reading
2 min
Listen
Play
8y

php-graphene-node-client

It is PHP API client for VIZ/STEEM/GOLOS/WHALESHARES blockchain

Github or packagist with MIT license. Author t3ran13@t3ran13 and active contributor semasping@semasping

In Release v5.1.1

  • raw data are sent to curl in abstact http connector
  • new HTTP/WS connectors were added for WHALESHARES blockchain
  • new api methods were added for WHALESHARES blockchain
  • broadcast was upated for working with WHALESHARES blockchain

WHALESHARES Blockchain

It is Steem fork wich was made by Bitshares community.

raw data are sent to curl in abstact http connector

The curlRequest method in HttpJsonRpcConnectorAbstract cooks itself sending data by CURL. Just send named array as $data parametr to curlRequest.

new HTTP/WS connectors were added for WHALESHARES blockchain

There are public nodes in HTTP connectors

There are public nodes in WS connectors

new api methods were added for WHALESHARES blockchain

There are availible methods

  • BroadcastTransactionCommand
  • BroadcastTransactionSynchronousCommand
  • GetAccountCountCommand
  • GetAccountHistoryCommand
  • GetAccountsCommand
  • GetAccountVotesCommand
  • GetActiveWitnessesCommand
  • GetApiByNameCommand
  • GetBlockCommand
  • GetBlockHeaderCommand
  • GetConfigCommand
  • GetContentCommand
  • GetContentRepliesCommand
  • GetCurrentMedianHistoryPriceCommand
  • GetDiscussionsByAuthorBeforeDateCommand
  • GetDiscussionsByBlogCommand
  • GetDiscussionsByCreatedCommand
  • GetDiscussionsByFeedCommand
  • GetDiscussionsByTrendingCommand
  • GetDynamicGlobalPropertiesCommand
  • GetFollowersCommand
  • GetOpsInBlock
  • GetTrendingCategoriesCommand
  • GetVersionCommand
  • GetWitnessesByVoteCommand
  • LoginCommand

Example of using

<?php

use GrapheneNodeClient\Connectors\Http\WhalesharesHttpJsonRpcConnector;
use GrapheneNodeClient\Commands\CommandQueryData;
use GrapheneNodeClient\Commands\Single\GetBlockCommand;

$connector = new WhalesharesHttpJsonRpcConnector();

$block_id = 13;
$commandQuery = new CommandQueryData();
$commandQuery->setParamByKey('0', $block_id);

$command = new Commands($connector );
$command = $command->get_block();
$answer = $command->execute($commandQuery);
//OR
$command = new GetBlockCommand($connector);
$answer = $command->execute(
    $commandQuery
);

//answer example
//Array
//(
//    [id] => 2
//    [result] => Array
//        (
//            [previous] => 002418bc813f920d631e2ebbe5afff94c26368ef
//            [timestamp] => 2018-11-03T11:06:51
//            [witness] => startail
//            [transaction_merkle_root] => ec7c1087743a4ca0a13ff3e6223a2f452fe68a63
//            [extensions] => Array
//                (
//                )
//            [witness_signature] => 1f64476993f46ab9980e017def574cc4cc28f0e5e772cb887329ff0a08def48a524f0a3b5630f8560d876fe7994974af2e04dbfac7c38b649375765954459d4a41
//            [transactions] => Array
//                (
//                  ....
//                )
//            [block_id] => 002418bdadacef24366eefba29e20fc5460a1d6f
//            [signing_key] => WLS8jVmgv4YkHfiHbn8Y3EhniGtxnD96LbiP5nqxbzA4Zv4G5xpXe
//            [transaction_ids] => Array
//                (
//                    [0] => 255b28f3665060b5c97c8bc99ee33b46db5c6ace
//                )
//        )
//)

broadcast was upated for working with WHALESHARES blockchain

It is availible next broadcast operations for WHALESHARES blockchain

  • OpVote
  • OpTransfer
  • OpComment
<?php
use GrapheneNodeClient\Connectors\Http\WhalesharesHttpJsonRpcConnector;
use GrapheneNodeClient\Tools\ChainOperations\OpComment;
use GrapheneNodeClient\Tools\ChainOperations\OpContent;
use GrapheneNodeClient\Tools\ChainOperations\OpTransfer;
use GrapheneNodeClient\Tools\ChainOperations\OpVote;


$connector = new WhalesharesHttpJsonRpcConnector();

//Post
$title2 = 'Test Post';
$answer = OpContent::doSynchronous(
    $connector,
    '5_posting_private_key',
    'guest123',
    strtolower(str_replace(' ', '-', Transliterator::encode(mb_strtolower($title2, 'utf-8'), Transliterator::LANG_RU))),
    $title2,
    $body,
    json_encode(['tags' => ['test']], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), //meta
    '', 
    ''
);

$answer = OpVote::doSynchronous(
    $connector,
    'guest123',//voter
    '5_posting_private_key',
    'volv',//author
    'tikhaya-okhota-otkrytie-sezona-1539526902',//post
    10000//weght
);

$answer = OpTransfer::doSynchronous(
    $connector,
    '5_active_private_key',
    'guest123',//from
    'php-node-client',//to
    '0.010 WLS',//amount
    'test php transfer'//memo
);

//answer example
//Array
//(
//    [id] => 4
//    [result] => Array
//        (
//            [id] => 255b28f3665060b5c97c8bc99ee33b46db5c6ace
//            [block_num] => 2365629
//            [trx_num] => 0
//            [expired] =>
//        )
//)

It is better with each commit

Commits were done by me in master branch

  • upd raw data are sent to curl in abstact http connector (last 14 days)
  • add new WHALESHARES ws/http connectors (last 14 days)
  • add new api methods for WHALESHARES blockchain (last 14 days)
  • add broadcast operations for WHALESHARES blockchain (last 14 days)

Compare v5.1.0-v5.1.1

Interaction With WHALESHARES Blockchain on PHP [PHP Graphene Node C... | Ecency