-1

currently in ripple when i need to check how much is the minimum required to keep account valid there is a property called reserve base XRP is there something similar in stellar? because to write hard coded 1 XML is not what i am looking for. so i guess there must be a way to figure what is the minimum that requires to keep an account valid.

3 Answers 3

0

If you query the /accounts/{account_id} endpoint, the subentry_count will tell you how many sub entries the account has.

The reserve is basereserve * (2 + subentry_count)

5
  • i am still do not know how to get the "basereserve" for this equation - this as my main question. what is the way to get it? Jan 2, 2019 at 10:05
  • I might link it again... stellar.org/developers/guides/concepts/… :)
    – Synesso
    Jan 2, 2019 at 10:24
  • the basereserve is included in the ledger headers. Using the JS SDK, const ledger = await server.ledgers().order('desc').limit(1).call();, then get either base_reserve or base_reserve_in_stroops Jan 2, 2019 at 10:53
  • so, it does not always return same response? i mean 1 ledger can give base_reserve_in_stroops and the other base_reserve? and 100000000 in stroops is 1 xlm? btw, Synesso - i only now saw the link at the bottom of the page reffers to the param. Jan 2, 2019 at 14:11
  • The property name depends on the protocol version. I don't remember when it changed. I check for both of them. Jan 2, 2019 at 15:27
0

The minimum account balance is a function of the number of entries on the account.

Every account needs 2 x base reserve. Then an additional 1 base reserve for every entry. Entries include:

  • Trustlines
  • Offers
  • Signers; and
  • Data Entries

See minimum account balance in the documentation.

0

As Johan pointed out, you can find the base reserve or minimum balance required for a stellar account from subentry_count. Here is an example in Javascript.

const base_reserve = 0.5
basic.minbalance = function minbalance(req, result)
{
    StellarSdk.Network.useTestNetwork();
    server.accounts().accountId(req.query.PublicKey).call()
                .then(function (accountResult)
                {
                    var asset_count = accountResult.subentry_count;
                    var min_balance = ((2 + asset_count) * base_reserve);

                     result(null,
                    {
                        "count": asset_count, // gives number of assets with trustline
                        "min_balance": min_balance,

                    });
                });
  }

This is just a sample, ensure you have imported stellar-sdk,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.