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

in #utopian-io6 years ago

php-graphene-node-client

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

Github or packagist with MIT license. Author @t3ran13 and active contributor @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

  • wss://whaleshares.io/ws
  • ws://188.166.99.136:8090
  • ws://rpc.kennybll.com:8090

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

Sort:  

Thanks for the contribution, @t3ran13. Since Whaleshares is a fork of the Steem blockchain it's no surprise interacting with it will be very similar. Comparing "WhalesharesApiMethods.php" implemented in this contribution with the already existing "SteemitApiMethods.php" reflects this, as they are practically the same.

Because of this it wouldn't be fair to use the questionnaire to judge this contribution, so I won't. Instead I will assign a score solely on the amount of effort / work. I hope you understand.



Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Hello
Thx in any case. What is diff between questionnaire and score?

The questionnaire is used to determine the contribution's score.

i see. thx)

Click on the link to the questionnaire.

Thank you for your review, @amosbastian! Keep up the good work!

It is fun, your checking has more cost then my work))))

Hey, @t3ran13!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!