Ripple

ipple-lib 不使用 getTransactions 方法返回事務

  • May 30, 2018

我的程式碼是

const api = new RippleAPI({
 server: 'wss://s1.ripple.com'
});

api.connect();

   let isConnected = false;
   api.on('connected', () => {
     isConnected = true;
   });
     return api.getTransactions(address)
       .then((transactions) => {
         console.log(transactions);
       })
       .catch((err) => {
         console.log(err);
       })

但它實際上並沒有返回任何東西。[]它有一個用於交易的空數組。

如果您查看我正在查看的地址:https ://xrpcharts.ripple.com/#/graph/rqnfXCcsZRadjoj8tDQWYsP1pVyv3Ro7X

你會看到有一些交易。那麼為什麼 API 不返回任何內容呢?

你可以使用這樣的承諾鏈:

const RippleAPI = require('ripple-lib').RippleAPI; var test_server = 'wss://s2.ripple.com'; const api = new RippleAPI({ server: test_server // Public rippled server }); api.connect().then(() => { /* begin custom code ------------------------------------ */ const myAddress = 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn'; console.log('getting account info for', myAddress); return api.getTransactions(myAddress); }).then(info => { console.log(info); /* end custom code -------------------------------------- */ }).then(() => { return api.disconnect(); }).then(() => { console.log('done and disconnected.'); }).catch(console.error);

祝你好運)

引用自:https://bitcoin.stackexchange.com/questions/75163