Steem Java-API V0.2.0 has been released – Update #6

The Steem Java-API has been released in Version 0.2.0 which includes Transactions and a lot more.

Hello together,

again, nearly two month have passed since V0.1.0 of the Steem-Java-Api-Wrapper has been released and I am sorry for that. But to make you happy again I want to share some great news with you: As you may have already seen in the last post I was able to sign and execute my first transaction with an API. Beside this great news I‘ve added some further improvements into this release and in this post we will stop through the details.

Rename the project?

But before we do so I have a question to you. I‘ve requested to add the API to http://steemtools.com and while I filled their request form I was thinking about the really really long name of this project. So what do you think about renaming the project to SteemJ? Please let me know it :)

SteemJLogo

Details of release 0.2.0

Here is a summary of things that have changed with V0.2.0:

  • Signing of Transactions with the correct Keys.
  • VoteOperation is now fully implemented.
  • Introduced "Asset" model
    • Before this change a price was just a String like "1.00 Steem". The new model allows to get the amount and the symbol separatly.
  • Introduced "Authority" model
    • The new model allows a more accurate handling of Keys returned from the Steem node.
  • The SteemAPIWrapperConfig is now singleton so it is no longer needed to pass it to every method.
  • The following parameters have been added to the SteemAPIWrapperConfig:
    • Timezone
    • Maximum expiration offset
    • PrivateKeys
  • The following methods are now supported:
    • getTransactionHex
    • verifyAuthority
    • broadcastTransaction
  • The amount and quality of Javadoc has been increased
  • API calls will only throw one Exception type instead of 4 now (The cause field contains furhter details of the root cause)
  • Removed the log4j2 configuration from the released Jar.

Examples

You can find more examples on GitHub.

Add the API-Wrapper to your project

Maven

File: pom.xml

    <dependency>
            <groupId>eu.bittrade.libs</groupId>
            <artifactId>steem-api-wrapper</artifactId>
            <version>0.2.0</version>
    </dependency>

Gradle

File: build.gradle

    allprojects {
        repositories {
            jcenter()
        }
    }
    dependencies {
            compile 'eu.bittrade.libs:steem-api-wrapper:0.2.0'
    }

Perform a VoteOperation

        // Change the default settings if needed.
        SteemApiWrapperConfig myConfig = SteemApiWrapperConfig.getInstance();

        myConfig.setTimeout(100000L);
        try {
            myConfig.setWebsocketEndpointURI(new URI("wss://this.piston.rocks"));
            myConfig.setSslVerificationDisabled(true);
        } catch (URISyntaxException e) {
            throw new RuntimeException("The given URI is not valid.", e);
        }
        myConfig.setPrivateKey(PrivateKeyType.POSTING, "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3");
        myConfig.setPrivateKey(PrivateKeyType.ACTIVE, "5KQasdf7ASD8weASdW37FSSsadfAImkwASd732QzDeyXtP79zk");

            // Create a new apiWrapper with your config object.
            SteemApiWrapper steemApiWrapper = new SteemApiWrapper();

            // Perform a transaction
            VoteOperation voteOperation = new VoteOperation();
            voteOperation.setAuthor("dez1337");
            voteOperation.setPermlink("steem-java-api-learned-to-speak-graphene-update-5");
            voteOperation.setVoter("dez1337");
            try {
            voteOperation.setWeight((short) 10000);
            } catch (InvalidActivityException e) {
                LOGGER.error("Weight was to high.", e);
            }

            Operation[] operations = { voteOperation };

            // Get the current RefBlockNum and RefBlockPrefix from the global properties.
            GlobalProperties globalProperties = steemApiWrapper.getDynamicGlobalProperties();
            int refBlockNum = (globalProperties.getHeadBlockNumber() & 0xFFFF);

            Transaction transaction = new Transaction();
            transaction.setRefBlockNum(refBlockNum);
            transaction.setRefBlockPrefix(globalProperties.getHeadBlockId());
            transaction.setOperations(operations);

            try {
                transaction.sign();
            } catch (SteemInvalidTransactionException e) {
                LOGGER.error("A propblem occured while signing your Transaction.", e);
            }
            steemApiWrapper.broadcastTransaction(transaction);
            
            LOGGER.info("The HEX representation of this transaction it {}.", steemApiWrapper.getTransactionHex(transaction));

Future plans

  • Implement all Transaction types (V0.2.X)
  • Implement subscription - API calls (V0.3.X)
  • Implement missing API calls (V0.4.X)

Summary

I think this release makes the project a lot more usable and the integration of transactions makes it possible to write more complex services or to develop a simple voting bot. Anyway there is still a lot to add and improve which I will need you help for: If you detect an issue or if you miss a feature please let me know in the comments or even better create an issue on GitHub. I will try my best to work on those as soon as possible.

If you want to make sure to never miss an update, just press the button below.

follow me
Source

Thats it for today! Thank you for reading and supporting me and this project - Best regards!

H2
H3
H4
3 columns
2 columns
1 column
4 Comments