Steemit::WsClient - perl bindings to steem made easy

in #utopian-io5 years ago (edited)


What is the project about?

I was exploring steem and it pained me that there are no Perl bindings to interact with steem. So I made it my quest to implement a perl module wich would allow the comunity to write applications in Perl to interact with steem.

It all started with some tutorials wher i explained Howto write a steemit client in perl and i want to come back to them. Unfortunately, i quickly realized that when it comes to transaction signing there were some hurdles to overcome since perl was lacking some basic suport methods when it comes to ECDSA functionality.

Diverging from the original howtos I made the existing code into a perl module on CPAN and then came the hard part of:

implementing a BASE58 encoding package

there were already some packages which did the job but wither they were based in the fickr-base58 or they were using Math::GMPz instead of Math::BigInt so i wrote a new module Steemit::Base58 class for handeling this task.

The interface is rather simple:

use Steemit::Base58;                                                                                                                                                                                                                       

my $binary = Steemit::Base58::decode_base58( $base58_string ); 
my $base58 = Steemit::Base58::encode_base58( $binary );

this was needed in order to read out the Wallet import format used originally by bitcoin, which is also used in steem.

So far so good but this was actually still the easy part. Next we needed some elliptic curve cryptography things for signing and key transformations.

implementing a new ECDSA module

There are already a new ECDSA modules up on cpan but all were lacking the functionality and code quality that was needed in order to implement all required features. Luckily there was one package Math::EllipticCurve::Prime::Point hat already handles the basic elliptic curve arithmetic well. So only the functionality on top had to be developed.

This brougt then to light the Steemit::ECDSA package. It currently supports the following methods:

sub ecdsa_sign;
sub is_signature_canonical_canonical;
sub bytes_32_sha256;
sub ecdsa_verify;
sub calcPubKeyRecoveryParam;
sub recoverPubKey;
sub get_compressed_public_key;
sub get_recovery_factor;
sub point_from_x;
sub recover_y;
sub get_public_key_point;

They were all needed in order to generate a valid signature for a transaction and broadcast it to steemd node. Currently this is all bundeled up under.

Finally it had to be bgought together in the Steemit::WsClient package. This is the main module of the distribution wich should then be used to write applications.

Existing features

  • accessing all database-api calls fo steem like ( getting posts, author information, comments, the blockchain state.....)
  • a vote method that allows you to cast a vote on a discussion.

An example would be:

use Modern::Perl;

use FindBin;
use lib "$FindBin::Bin/perlSteemit/lib/";

use Steemit::WsClient;

my $steem = Steemit::WsClient->new( posting_key => '<your private posting key as listed on the steemit site>' );

my $discussions = $steem->get_discussions_by_created({
      tag => 'utopian-io',
      limit => 1,
      truncate_body => 1,
my $discussion = pop @$discussions;
$steem->vote( $discussion );

it can also be used for data extraction like calculating the average reputation of the authors of the last utopian posts:

use Steemit::WsClient;
my $foo = Steemit::WsClient->new();
my $steem = Steemit::WsClient->new( url => 'https://some.steemit.d.node.address');
say "Initialized Steemit::WsClient client with url ".$steem->url;
#get the last 99 discussions with the tag utopian-io
#truncate the body since we dont care here
my $discussions = $steem->get_discussions_by_created({
      tag => 'utopian-io',
      limit => 99,
      truncate_body => 100,
#extract the author names out of the result
my @author_names = map { $_->{author} } @$discussions;
say "last 99 authors: ".join(", ", @author_names);
#load the author details
my $authors = $steem->get_accounts( [@author_names] );
#say Dumper $authors->[0];
#calculate the reputation average
my $reputation_sum = 0;
for my $author ( @$authors ){
   $reputation_sum += int( $author->{reputation} / 1000_000_000 );
say "Average reputation of the last 99 utopian authors: ". ( int( $reputation_sum / scalar(@$authors) )  / 100 );

Technology Stack

  • the package requires a Perl environment > 5.10
  • openssl packages need to be installed for https communication: libssl-dev libssl1.0-dev zlib1g-dev
  • libgmp-dev is almost optional but for for decent permformance, you will need it.


Currently the basic functionality is there but now comes the time for further improvements.

  • more documentation is needed in order to make everything more acessible
  • posting content is currently not implemented
  • more tests have to be written
  • more convinient input handling in the ECDSA package
  • making some of the submodules into their own distributions may help kickstart more devellopment in the perl crypto space since in my research i noticed that a lot of concepts in various crypto projects are based on the same basics used in bitcoin originally

How to contribute?

  • the whole procent is up on githup and im happy for issue reports or pull requests
  • you can contact me on steem or via my cpan mail adress [email protected]

Posted on - Rewarding Open Source Contributors


Fantastic! @hoffmann I will attempt to incorporate it into my Perl application. I will post and comment on the progress as I make it.

Hey @hoffmann I am @utopian-io. I have just upvoted you!


  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!


Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord

Thank you for the contribution. It has been approved.

You can contact us on Discord.

@hoffmann, Upvote is the only thing I can support you.

Congratulations @hoffmann! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes
Award for the total payout received

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

Upvote this notification to help all Steemit users. Learn why here!

Coin Marketplace

STEEM 0.18
TRX 0.05
JST 0.022
BTC 17037.43
ETH 1262.94
USDT 1.00
SBD 2.11