Jump to content
Sign in to follow this  
SneakyFish5

Need help with getServerInfo

Recommended Posts

Hello!

I'm working on a bug right now that when sending XRP from the wallet that dips into reserve, it uses up the transaction fee but doesn't get recorded onto the ledger. Put simply, transaction never happens but fee is used. I've got the error message setup perfectly and it works when the xrp reserve amount is hardcoded as 20. As you all know, this amount can change so I want it to be pulled from the api. I've tried numerous ways to do this but I just can't figure out how to get the value of 'reserveBaseXRP' out of it using getServerInfo() method. If anyone has any clue how to do this, please let me know.

Thank you very much!

P.S. Sorry if this is a noob question, still a learner at JS

Share this post


Link to post
Share on other sites

There is no way that transaction is not "recorded" on the ledger and the amount of XRPs in your account decreases. Transaction can sometime fail and consume fee, but it is still "recorded".

Why you can't get 'reserveBaseXRP'? 

I wouldn't bother with this property. You can just hardcode a constant in your code instead.

 

Share this post


Link to post
Share on other sites

Ok my bad, recorded was probably the wrong word. Yes, failing is the better term and it consumes the fee. 

As for just hardcoding it, there’s a bit of a problem. I’m just working on someone else’s app and the owner wanted values to be pulled from ripple-lib. Even if he didn’t want it, I would code it this way because:

1. Don’t need to change value then get it approved again on AppStore, etc. It’s all automatic.

2. Since it’s automatic, if the owner suddenly leaves or goes inactive on the app, then the reserve amount can still be up to date. 

Share this post


Link to post
Share on other sites

I'm not sure what API you're using exactly, but you should have either fields like:

            "reserve_base_xrp" : 20,
            "reserve_inc_xrp" : 5
 

or

            "reserve_base" : 20000000,
            "reserve_inc" : 5000000,
 

The top is in XRP, the bottom in drops. The reserve base is the minimum reserve for every account. The reserve increment is the additional amount for each owned object. You can find an account's number of owned objects with whatever version of the "get account info" API you have access to. You should have an "OwnerCount" field that will tell you how many objects that account owns.

If all else fails, you can query ledger state entry 4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A651 which has the current network fee settings. Some version of this:

{ " command" : "ledger_entry", "ledger_index" : "validated", "index" : "4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A651", "binary" : false }

Will produce this:

      "node" : {
         "BaseFee" : "000000000000000A",
         "Flags" : 0,
         "LedgerEntryType" : "FeeSettings",
         "ReferenceFeeUnits" : 10,
         "ReserveBase" : 20000000,
         "ReserveIncrement" : 5000000,
         "index" : "4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A651"
      }
 

Share this post


Link to post
Share on other sites

Well 2 things I should mention:

1. I'm coding an app for the AppStore (the app ToastWallet) and since it's an app I'm unsure how you would go about getting the console. 

2. Here is my current code but whenever I run it, the app just loads forever:

Quote

remote.getServerInfo().then(obj => {
    var xrpreserveamount = obj.validatedLedger.reserveBaseXRP;
});
.catch( function(e) {

});

Sorry if this is completely wrong, still a learner :P

Share this post


Link to post
Share on other sites
8 hours ago, SneakyFish5 said:

cheeky bump for help :P 

Variable xrpreserveamount gets assigned or not? 

It is unclear what you mean by " the app just loads forever" (why it shouldn't "load forever"? You don't exit the process or something like that). It is also not clear how you run this app (in nodejs?).

You need to be more specific if you want some help.

However, I doubt many people here have experience with anything related to RippleAPI outside of the context of nodejs and browser.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...