steemit / steem-js

Steem.js the official JavaScript library for Steem blockchain
https://www.npmjs.com/package/steem
MIT License
472 stars 225 forks source link

Error "AssertionError: Expected version 128, instead got 149" - What does it mean? Cannot make any posts... #321

Open osirisr opened 6 years ago

osirisr commented 6 years ago

Expected behavior

A successful API call - in this case, posting an article to STEEM.

Actual behavior

Get the following error code. No idea what it means since its not documented anywhere -_-

AssertionError: Expected version 128, instead got 149

How to reproduce

Run the following JS code:

<html>
<head><title>steem-js posting example</title>
<script src="//cdn.steemjs.com/lib/latest/steem.min.js"></script>
</head>
<body>

<script language="JavaScript">
var params = {};
params.postingKey = '...';
params.username   = '...';
params.title      = 'test';
params.article    = 'just a test';
params.permalink  = 'test435fdfs';

steem.api.setOptions({ url: 'https://api.steemit.com'});

function postArticle() {

  steem.broadcast.comment(
    params.postingKey, // posting wif
    '', // author, leave blank for new post
    '', // first tag
    params.username, // username
    params.permalink, // permlink
    params.title, // Title
    params.article , // Body of post
    // json metadata (additional tags, app name, etc)
    { tags: ['test'], app: 'steemit/1' }, // Json Metadata
    function (err, result) {
      if (err)
        alert('Failure! ' + err);
      else
        alert('Success!');
    }
  );
}

postArticle();
</script>

</body>

</html>

It looks like the steem.min.js file is too new or old for the "https://api.steemit.com" endpoint?

sriharsha1235 commented 6 years ago

Facing same issue any solutions

jnordberg commented 6 years ago

Sounds like an invalid private key, make sure you're not passing your public key

osirisr commented 6 years ago

Solution - I was using the wrong key. You should use the posting key for this kind of method. Posting keys typically start with STM. - Too bad this API has poor documentation and vague error messages.

sudguru commented 6 years ago

@osirisr what is posting key? how do you get it?

soorichu commented 6 years ago

I have same issue. What is public key? Is it different to the key is given when I sign up Steem?

BartolomeoItaliano commented 6 years ago

Hi @soorichu. When you sign up on steem, as password you pass in Seed for random number generator. With this seed you can always generate all your private keys. (The first 4 random number generator results are your private keys). With your private keys you generate all public keys and during registration process you pass to the STEEM blockchain this 4 public keys, which are some kind of your fingerprints.

If you want you may generate all your private keys without this seeding method, however in this case you will have to remember all 4 private keys instead of 1 password. In that case you won't have anything like "steem password".

nickberns commented 5 years ago

Quite annoying that this is not documented. Solution is to use private posting key.