steem-js icon indicating copy to clipboard operation
steem-js copied to clipboard

setPendingTransactionCallback does not work. How to set callback on transaction received?

Open bartosz546 opened this issue 8 years ago • 6 comments

Hi :) I'm looking for a why to confirm transaction has got place with steem js library, maybe you know how to do it?

I want to create bot which do something after it receives money.

I thought this will give me opportunity to do this:

steem.api.setPendingTransactionCallback(cb, function(err, result) {
  console.log(err, result);
});

But it throws error with:

Uncaught TypeError: Cannot read property 'api' of undefined at e.value (steem.min.js:formatted:6784) at WebSocket. (steem.min.js:formatted:6709)

Than in the message from blockchain it gives me very long info starting with:

Error: 10 assert_exception: Assert Exception itr != _by_name.end(): no method with name 'set_pending_transaction_callback' {"name":"set_pending_transaction_callback","api":

Please give me advice I will follow you and upvote yor posts on SteemIt :)

bartosz546 avatar Nov 28 '17 13:11 bartosz546

I am also receiving the same exact error, did you find any work around?

deveshaggrawal19 avatar Jun 19 '18 12:06 deveshaggrawal19

same here

kradster avatar Jun 19 '18 12:06 kradster

There is no more support ?

tymmesyde avatar Apr 18 '19 19:04 tymmesyde

Hi guys, I manage to resolve my problem different and in my opinion a lot better way.

steem.api.getAccountHistoryAsync(steemAccountName, -1, limit) .then((res)=>{ // do sth }) .catch((err) => { throw new Error(err); });

And I just run this function whenever I want as some "refresh functionality" or you can do it in Interval.

I just get account history, filter upcoming transactions and then save the last transaction ID in Database. Next time when I check "if sth new happened" I get the transactionId saved in database and filter the most recent transactions.

Thanks to this solution even after short power down I am still synchronized with steem network.

bartosz546 avatar Apr 19 '19 07:04 bartosz546

This looks like a good workaround but it is quite similar to setInterval functionality.

deveshaggrawal19 avatar Apr 24 '19 16:04 deveshaggrawal19

Well in fact: steem.api.setPendingTransactionCallback(cb, function(err, result) { console.log(err, result); }); has setTimeout under the hood :)

bartosz546 avatar Apr 25 '19 08:04 bartosz546