Steem Java-API learned to speak Graphene #Update 5

Hay ho,

I spend the easter weekend and the last afternoons after work to push the Steem-Java-Api again.

Api
Source

My target was to implement the broadcast_transaction method, the general signing mechanism and a first operation type. And what can I say? A first implementation is done and can be found on the master branch at GitHub - BUT it was quite hard to find all the required information and a lot of "trial and error" was required to get this done. At this point I have to say thanks to @Xeroc again whose article "Transaction Signing in a Nutshell" and some Issues from him on GitHub helped me a lot to get the things running.

Test it on your own

For those who would like to try it: Build the Steem-Java-Api locally, add the Jar to your project and try the sample code below:

            SteemApiWrapper steemApiWrapper = new SteemApiWrapper(myConfig);

            VoteOperation voteOperation = new VoteOperation();
            voteOperation.setAuthor("timcliff");
            voteOperation.setPermlink("reports-from-the-witnesses-2017-04-02");
            voteOperation.setVoter("dez1337");
            voteOperation.setWeight((short) 10000);

            Operation[] operations = { voteOperation };

            // GET RefBlockNum and RefBlockPrefix
            GlobalProperties globalProperties = steemApiWrapper.getDynamicGlobalProperties();
            int refBlockNum = (globalProperties.getHeadBlockNumber() & 0xFFFF);


            Transaction transaction = new Transaction();
            transaction.setExpirationDate("2017-04-19T19:56:17UTC");
            transaction.setRefBlockNum(refBlockNum);
            transaction.setRefBlockPrefix(globalProperties.getHeadBlockId());
            transaction.setOperations(operations);

            List<ECKey> wifKeys = new ArrayList<>();
            ECKey postingKey = DumpedPrivateKey.fromBase58(null, "YOURPRIVATEKEY").getKey();
            wifKeys.add(postingKey);

            transaction.sign(wifKeys);
            steemApiWrapperbroadcastTransaction(transaction);

The main reason why this has not been released is that I am not completly happy with the implementation as it is right now - I still have a lot of ideas to improve this and will try to push those things in the upcoming days. If you do not want to miss that great moment make sure to press the button below! :)

follow me
Source

Thanks for reading and best regards!

H2
H3
H4
3 columns
2 columns
1 column
2 Comments