Programming Diary #2: Mixing it up with SteemJ, Broadcasting Steem transactions in Java, and Posting to Steem from a GUI

in hive-192037 •  4 months ago  (edited)

After several days of spinning my wheels, I finally have some progress to report. Here's another update on my activity learning to use Java for interaction with Steem's Steem Links Community.



Pixabay license: source

After the holiday, I returned to work, so my programming time has been substantially limited this week, but I still found some time during the last two week-ends. Most of my programming time was spent trying to figure out how to submit a Steem transaction through SteemJ. It turns out that the version of SteemJ that I had downloaded was not functional for that purpose. Although I had been able to read information from the blockchain, I was not able to broadcast a transaction. After giving up on that version, I tried out a couple others until I finally found one that enabled me to broadcast a transaction. Once that was accomplished, I was quickly able to plug it into the previously created form and use the form to drive the transactions.

Basically, I met three goals during the past two week-ends:

  • Prove that I can broadcast something to the Steem blockchain using Java and SteemJ
  • Prove that I can use a button from a Java/Swing form to broadcast something to the Steem blockchain
  • Prove that I can collect data from a Java/Swing form and use it to populate a Steem post.

I also did some playing around with form design.

Here are some details about my progress during the last two week-ends.

Finding a suitable version of SteemJ

Basically, all of the programming time from my previous post until yesterday was spent troubleshooting the reason why I couldn't broadcast a transaction. I probably spent about 2 days working with the original version of SteemJ that I had downloaded, then yesterday, I finally gave up on that version and hunted around for other options. In the end, the configuration I found that works was to put these settings into my pom.xml file.


Once I found that configuration, it became very simple to meet the first goal, broadcasting a transaction to the Steem blockchain.

Transacting on the Steem blockchain (with or without a GUI)

For testing, I am using the Steem account, @social. I have no idea who created this account, but its posting key was intentionally released to the public, which turns out to be convenient for a purpose like this, where I don't want to risk accidental disclosure of my own key during testing. I modeled my code after this example, which describes how to set up a key and post a comment. After some simple substitutions, I came up with this code to set the keys:

SteemJConfig myConfig = SteemJConfig.getInstance();
myConfig.setDefaultAccount(new AccountName("social"));

List<ImmutablePair<PrivateKeyType, String>> privateKeys = new ArrayList<>();
privateKeys.add(new ImmutablePair<>(PrivateKeyType.POSTING, 
myConfig.getPrivateKeyStorage().addAccount(myConfig.getDefaultAccount(), privateKeys);

And this code to submit a post:

SteemJ steemJ = new SteemJ();
steemJ.createPost(String Title, String Body, String[] { "list", "of", "tags"} );

Conveniently, Netbeans knows how to set up the necessary imports, but here they are, just for reference:


  • SteemJ imports


import eu.bittrade.libs.steemj.SteemJ;
import eu.bittrade.libs.steemj.base.models.AccountName;
import eu.bittrade.libs.steemj.base.models.Permlink;
import eu.bittrade.libs.steemj.configuration.SteemJConfig;
import eu.bittrade.libs.steemj.enums.PrivateKeyType;
import java.util.ArrayList;

Using Java/Swing forms with SteemJ to create and submit Steem transactions

After I had this sort of thing working in a throwaway program, I went ahead and moved into the SteemLinksCreator form that I had cobbled together before my previous Programming Diary. The form now looks like this:


And the actions necessary to create a post are:

  1. Paste a URL into the form.
  2. Click on the AutoPopulate button
  3. Fill out additional fields that don't populate automatically
  4. Click on the "Generate HTML/Markdown" button
  5. Inspect the output text area to make sure it looks correct
  6. Press the "Post to Steem" button.

And here is a sample post, Confirmed: Your iPhone is lying to you | ZDNet - ZDNet.


After a frustrating few days fighting with the older version of SteemJ, I'm finally pleased with the progress I made yesterday and today. There's a long way to go to have something that I'd want to put in front of anyone other than myself, but I think that all of the fundamental building blocks are now in place. In no particular order, here are just some of the things I plan to add, when time allows:

  • Figure out how to download the functional version of SteemJ and update its dependencies to current versions.
  • Manual entry of account name and Posting key (in a password field).
  • Add fields to specify tags.
  • Figure out how to apply beneficiary settings to a post through SteemJ.
  • Provide a checkbox and entry field to set @penny4thoughts as a beneficiary and specify the percentage.
  • Figure out how to scrape the publication date from a web site using jSoup.
  • Put min/max lengths on blockquotes and author commentary.
  • Require a publication date.
  • Protect against accidentally double-posting from the same form data.
  • Protect against accidentally clearing the form before posting. (thanks for the suggestion, @cmp2020!)
  • Add the ability to "preview" a post before submitting to the blockchain.
  • Lots of error handling, all over the place.

Additionally, I have a puzzle to solve with Netbeans. For some reason, the Palette chooser for GUI design disappeared from Netbeans on my laptop. I have no idea how I managed to get rid of it, but I would like to figure out how to get that back. Adding graphical objects like buttons and text fields is more cumbersome without it.

I am not sure if anyone still has access to the @steemj wallet, but I'm setting it as 5% beneficiary, anyway. Hopefully the developer can still benefit from that. If not, it removes the rewards from circulation.

Thank you for your time and attention.

As a general rule, I up-vote comments that demonstrate "proof of reading".

Steve Palmer is an IT professional with three decades of professional experience in data communications and information systems. He holds a bachelor's degree in mathematics, a master's degree in computer science, and a master's degree in information systems and technology management. He has been awarded 3 US patents.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Most of my programming time was spent trying to figure out how to submit a Steem transaction through SteemJ.

This scares me. A lot. None of the SteemJ libraries are in a programming language that I'm particularly familiar with and I can't see an alternative to SteemJ. And without something that can send messages, my PoC will just be a pretty waste of time.

I think I have my day planned now 😩😨😱

What's the end-game for your efforts beyond auto-generating content for Steem Links?

What's the end-game for your efforts beyond auto-generating content for Steem Links?

I don't really have a concrete end game. Mostly, I just think that Steem needs a "high velocity" form of content that doesn't sacrifice too much by way of quality (whatever "quality" means), so this is my little step in that direction. Also, there are some other ideas that I'd like to implement if I develop the skills I would need.

I am very interested in learning to post with steemj. If I have a lot of free time, I will learn to use it, but I not sure my laptop specs can be used.
I have seen the results of your post on @social.


I am very happy to use your app, but you have not released it to the public yet.

When do you plan to publish your creation?

What I like the most is that it is easy to use when it comes out I will test it with my secondary steem-science account every day as there is a lot of information to share daily on SteemLinks.

one day I hope to be like you have done this.
Honestly, I really want to learn

There's no time like the present! ;-)

thank you, I really hope someday you will teach me about it

Hi @remlaps ,You are very focused on the subject, I think you will achieve your goals, he analyzed you as a persistent and active man, two basic qualities in entrepreneurial people.

I don't know anything about programming. Once I have to practise simple html and css form. Though that were not any programming language, I little understand that. Anyway, in this modern era of technology, knowledge about programming is good. I see you are an expert of programming. I hope you can do the best in future.....

I've never done anything with CSS. I wouldn't know where to start. And I haven't done much with HTML since the 1990s, so you're ahead of me on both of those!

Very hard work it takes more effort All the best for your project great continuation👍

What is the last HF version that SteemJ was maintained until??

Based on the datestamp in the dependency, I'm guessing it was maintained until September of 2018. From where I am, I can't check what hardfork that was... 17/18 maybe? I'll try to check tomorrow.

HF20 was on Sept. 25, 2018, so I guess this SteemJ version: 0.4.6-20180926-01, is 3 hardforks behind. That's the most recent (functioning) release that I've been able to find.

Damn. A lot of changes would be missing then

It definitely needs to be modernized, but I think nearly all of its operational functionality is still in place.

Here's one of the announcements for HF21. I just scanned through it, and most of the changes seem to be irrelevant for an API wrapper like SteemJ. They mostly affected the witness nodes.

HF21 was on August 27, 2019, and HF22 was two days later. As I recall, HF22 was a stability update, so probably not much needed for that.

Of course, HF23 was implemented as a countermeasure against people who were attacking the blockchain, so again, possibly not much that would be relevant to an API wrapper.

I think the biggest challenges for SteemJ will be the needs to deal with bugs, add features, and accommodate future hardforks, especially since SMTs may still be out there in the realm of the possible. As I begin to get familiar with it, I'm already finding features that I'd like to see added.

The API wrapper is by itself old, is what I mean. It would be missing some of the modern APIs like the bridge APIs, the ability to deal with communities, and stuff. But yea. Would definitely work for the most part.

Yeah, that's true. Good point. It doesn't seem like anything was ever done to enable community features.

It's really interesting and confusing to see all these codes... I really want to.learn and I'll be very much happy and grateful if you can please spare sometime to teach me... If you don't mind, I'll like you to share your WhatsApp number with me please