dsteem commentWithOptions()

in test •  11 days ago

I'm trying to use the dsteem commentWithOptions() function, I was having a lot of trouble. This post was created using dsteem's broadcast.commentWithOptions() function. I will now explain what happened. Everything below this text has been added after posting.

Alright first of all I was thinking I could simply pick and choose which options I wanted. No dice. If you want to use the commentWithOptions() function you have to provide all 7 options:

  • author
  • permlink
  • allow_votes
  • allow_curation_rewards
  • max_accepted_payout
  • percent_steem_dollars
  • extensions

I have no idea why author and permlink are required here. They are totally redundant and already listed as attributes in the comment object. If there is a reason why these would be different it escapes me.

My original intention was to test allow_curation_rewards. Can you really prevent curation and siphon all rewards to your own account? Is this really what it means or am I misinterpreting? I guess we'll find out, because this option has been disabled on this post.

This would be a pretty amazing development because I am going to wage a war on curation and show this platform how broken it is. Curation is a job for everyone, not just the elite. I propose a much different solution. I'll save that for another post though.


comment with options dsteem curation.png

I am also testing percent_steem_dollars. Can we really force the blockchain to create SBD? I doubt it but we will see.

On top of that I've also figured out how to add beneficiaries. These are basically like SMTs version 0.1.0. If you create an app that posts to the blockchain, you can add your account as a beneficiary and siphon off a percentage of the rewards for yourself. It's important to note that percents on the Steem API are measured by 1/10000 (0.01%) per point, so it takes 10000 points to reach 100%.

We can clearly see that I will get 1.5% beneficiary rewards. @fulltimegeek will get 2.22%. @krnel will get 1% and @taskmaster4450 will get 0.4%. I'll be monitoring this post and give an update when it pays out to report how much went where. The interesting thing about this is that you get an error if you don't put the accounts in alphabetical order.


error beneficiaries order.png

Weird.

Perhaps you're wondering why I had so much trouble posting this with dsteem. We'll, I kept getting the same errors over and over again.

permlink size error.png

This dreaded permlink size error had me very confused. I kept trying to change the length of my permlink to fix it, but nothing was working. I also thought there might be errors with the extension option. This is where you add beneficiaries and the formatting is completely unintuitive. I also didn't know what the json_metadata was for. There was just too much going on here, so I decided to use Occam's Razor to simplify the problem. Instead of posting a comment with options I would simply try posting a comment.

This is why I posted this previous post. I got the exact same error here, but now I knew that the extensions attribute wasn't causing the problem. Could it be that the error was talking about the blank parent_permlink? No... that can't be right... because it says so right in the Steemit API documentation:

comment parameters steem api.png

So everything should have been correct. However, my post still didn't have tags. Perhaps this is what the json_metadata was for? Who knows? dsteem has literally zero documentation outside of listing function inputs and outputs. Then, nine lines down, I noticed this:

comment operation example steem api.png

Gee, look at that. Not only is this confirmation that the json_metadata is used for tags, but the documentation has just contradicted itself within the same nine lines. Seriously, Steemit Inc. I address your fearless leader @ned. This is embarrassing. Is this the experience you want developers to have when interacting with the Steem blockchain? A bunch of disorganized documentation, terrible tutorials, and information that flat out contradicts itself on the same page? This is a joke.

Steemit should have NEVER put so much emphasis on SMTs. You're literally ignoring everything else and racing to the finish line, as if SMTs were the finish line. SMTs mean nothing if developers are going to be immediately fed up with how unprofessional and inefficient this entire learning curve is.

Honestly, what's the excuse for this? As if an entire blockchain doesn't have the resources to hire one full time person to clean up this mess. Maybe you should hire me? Dun know... it's not exactly the most exciting work. Then again, why hire me when I'm already trying to do it for free amirite?

We all know my stance on ERC-20 and SMTs. They are a shortsighted incentivizer fueled by greed. Personally, I will only create an SMT if I can show that it's even more fair and decentralized than Steem itself. It would be hilariously ironic for an SMT to roll in here and be superior to the genesis coin. Honestly, I hope to see the same thing with Ethereum. I would be great if a project like Golem was somehow valued higher than Ethereum itself.


Ranting-Homer.jpg

Rant Over

In any case, this is what ended up being the problem. Not only is a parent_permlink required for a top level post, it also counts as your main tag. Interestingly enough, by using the json_metadata attribute, I was able to choose more than 5 tags for my post. I'll do some more testing on this later so see if it can actually be exploited.

What else did I learn?

The extensions attribute looks so needlessly overcomplicated. It looks like an array of an array with a number followed by a beneficiaries object that contains an array of objects containing account names and percent weights. Seriously wtf. If you're wondering what that looks like:

    extensions: // [] is the valid empty option
        [
          [
            0,
            {
              "beneficiaries": [
                {"account": "edicted", "weight": 150},
                {"account": "fulltimegeek", "weight": 222},
                {"account": "krnel", "weight": 100},
                {"account": "taskmaster4450", "weight": 40}
              ]
            }
          ]
        ]

Hm yeah, it's not pretty. Like I said, "very unintuitive."

Here's the code I used to generate the first paragraph of this post:

<script src="https://unpkg.com/dsteem@latest/dist/dsteem.js"></script>

<script>
var client = new dsteem.Client('https://api.steemit.com')
var key = dsteem.PrivateKey.fromString("DELETED")
var comment =
    {
        author: "edicted",
        body: "I'm trying to use the dsteem commentWithOptions() function, "
            + "I was having a lot of trouble.  This post was created using "
            + "dsteem's broadcast.commentWithOptions() function. "
            + "I will now explain what happened. "
            + "Everything below this text has been added after posting. ",
        json_metadata: '{"tags":["utopian-io","curation","javascript","dsteem"]}',
        parent_author: "",
        parent_permlink: "test",
        permlink: "commentwithoptions",
        title: "dsteem commentWithOptions()"
    }
var options =
    {
        allow_curation_rewards: false,  // testing
        percent_steem_dollars: 10000,   // testing
        allow_votes: true,
        author: "edicted",
        permlink: "commentwithoptions",
        max_accepted_payout: "1000.000 SBD",
        extensions: // [] is the valid empty option
            [
              [
                0,
                {
                  "beneficiaries": [
                    {"account": "edicted", "weight": 150},
                    {"account": "fulltimegeek", "weight": 222},
                    {"account": "krnel", "weight": 100},
                    {"account": "taskmaster4450", "weight": 40}
                  ]
                }
              ]
            ]
    }
client.broadcast.commentWithOptions(
    comment, options, key).then(function(result){
       console.log('Included in block: ' + result.block_num)
    }, function(error) {
       console.error(error)
    })
</script>

You can see that I cleaned up the json_metadata a little.

  '{"tags":["utopian-io","curation","javascript","dsteem"]}'

The original examples use all double quotes, so they have to be escaped with \ so the compiler doesn't get confused.

"{\"tags\":[\"steemit\",\"example\",\"tags\"]}"

Changing the outside quotes to singles seemed much more readable.

I also learned that capital letters are not allowed in the permlink and max_accepted_payout requires a weird string called an 'asset' that has the currency label attached to it ("1000.000 SBD").

Baby steps.

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:  

@ned: @edicted, I think that you're failing to see the bigger picture here. SMTs are going to empower the entrepreneur and drive the development of new communities. If you wanted to you could create a Steem API SMT to empower developers like yourself into creating new possibilities on top of the greater Steem ecosystem. It's a win-win.

·

SMTs very well may be the great incentivizer that pays people for their work. It also might be a return to work ethic, because you can compartmentalize every function of Steem. If your SMT is better you'll be paid more.

I just think it's pretty obvious that SMTs should not be the number one priority at all costs. Steem made it this far and now they are trying to run farther without looking backwards and fixing all the ragtag rushed mistakes they made. This road is full of potholes.

I was going to say I was surprised that you of all people would make this argument. I just realized it was @ned all along lol. Nice.

Like I'm going to trust someone who wrote this in the whitepaper and then left it in:

Page 13 Steem Whitepaper

The actual distribution will depend upon the voting patterns of users, but we suspect that the vast majority
of the rewards will be distributed to the most popular content.

Page 1 Steem Bluepaper

This makes Steem a public publishing platform from which any Internet application may
pull and share data while rewarding those who contribute the most valuable content.

If this sentiment was ever actually believed it was quite naive. Leaving it there just makes you a liar. I guess I'd rather have a snake CEO over a fool.

Yeah using the API programmatically can be infuriating sometimes. Hard to debug, weird error messages. I tried to programmatically delegate and undelegate. Took a while to figure out.