{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["tabs","tab","code-snippet"]},"redocly_category":"Documentation","type":"markdown"},"seo":{"title":"Calculate Account Reserves","siteUrl":"https://xrpl.org/","llmstxt":{"hide":false,"title":"XRPL Developer Portal & Documentation","description":"Explore XRP Ledger documentation, blogs, and other blockchain developer resources needed to start building and integrating with the ledger.","details":{"content":"XRP Ledger concepts, use cases, tutorials, references, and other blockchain developer resources. Also, stay up to date with release announcements and more through the XRPL Blog."},"sections":[{"title":"Introduction","description":"A high-level introduction to the XRP Ledger.","includeFiles":["docs/introduction/**/*.*","about/faq.md"],"excludeFiles":["docs/introduction/index.md"]},{"title":"Use Cases","description":"Real-world applications and business scenarios for the XRP Ledger.","includeFiles":["docs/use-cases/**/*.*"],"excludeFiles":["docs/use-cases/index.md","docs/use-cases/defi/index.md"]},{"title":"Concepts","description":"Core concepts including accounts, tokens, transactions, consensus, and more.","includeFiles":["docs/concepts/**/*.*"],"excludeFiles":["docs/concepts/index.md","docs/concepts/decentralized-storage/index.md","docs/concepts/payment-types/index.md"]},{"title":"Tutorials","description":"Step-by-step guides for building on the XRP Ledger in JavaScript, Python, Go, and more.","includeFiles":["docs/tutorials/**/*.*"],"excludeFiles":[]},{"title":"References","description":"Protocol specification, transaction types, ledger entries, and API methods.","includeFiles":["docs/references/**/*.*"],"excludeFiles":["docs/references/xrp-api.md","docs/references/data-api.md","docs/references/protocol/index.md","docs/references/protocol/ledger-data/ledger-entry-types/index.md","docs/references/protocol/transactions/index.md","docs/references/protocol/transactions/types/index.md","docs/references/http-websocket-apis/api-conventions/index.md","docs/references/http-websocket-apis/public-api-methods/*/index.md","docs/references/http-websocket-apis/admin-api-methods/*/index.md"]},{"title":"Infrastructure","description":"Install, configure, and troubleshoot rippled and Clio servers.","includeFiles":["docs/infrastructure/**/*.*"],"excludeFiles":["docs/infrastructure/index.md","docs/infrastructure/*/index.md","docs/infrastructure/installation/build-run-rippled-in-reporting-mode.md","docs/infrastructure/configuration/data-retention/index.md","docs/infrastructure/configuration/server-modes/index.md"]},{"title":"Blog (2023+)","description":"Recent XRPL Blog posts (showing 2023 and newer).","includeFiles":["blog/2023/**/*.*","blog/2024/**/*.*","blog/2025/**/*.*","blog/2026/**/*.*"],"excludeFiles":[]},{"title":"Resources","description":"Developer resources and contribution guidelines.","includeFiles":["resources/**/*.*"],"excludeFiles":["resources/index.md"]}],"excludeFiles":[]},"description":"Look up and calculate base and owner reserve requirements for an XRPL account."},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"calculate-account-reserves","__idx":0},"children":["Calculate Account Reserves"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This tutorial demonstrates how to look up and calculate the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/concepts/accounts/reserves"},"children":["reserve requirements"]}," for an XRP Ledger account. Reserves are the minimum amount of XRP an account must hold based on its activity on the ledger."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"goals","__idx":1},"children":["Goals"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["By the end of this tutorial, you should be able to:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Look up an account's current ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/concepts/accounts/reserves#base-reserve-and-owner-reserve"},"children":["base"]}," and incremental reserve values."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Determine an account's ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/concepts/accounts/reserves#owner-reserves"},"children":["owner reserve"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Calculate an account's total reserve requirement."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"prerequisites","__idx":2},"children":["Prerequisites"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To complete this tutorial, you need:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["A basic understanding of the XRP Ledger."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["An XRP Ledger ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/references/client-libraries"},"children":["client library"]}," set up."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"source-code","__idx":3},"children":["Source Code"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can find this tutorial's example source code in the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/XRPLF/xrpl-dev-portal/tree/master/_code-samples/calculate-reserves"},"children":["code samples section of this website's repository"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"steps","__idx":4},"children":["Steps"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"1-install-dependencies","__idx":5},"children":["1. Install dependencies"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Install dependencies for your language from the code sample folder."]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"div","attributes":{"label":"JavaScript","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"npm install xrpl\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"div","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"pip install xrpl-py\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"div","attributes":{"label":"Go","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"go mod tidy\n","lang":"bash"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"2-set-up-client","__idx":6},"children":["2. Set up client"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Import the XRPL library and create a client connection."]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"div","attributes":{"label":"JavaScript","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/calculate-reserves/js/calculate_reserves.js","language":"js","header":{"controls":{"copy":{}}},"lang":"js","source":"// Set up client ----------------------\n\nimport xrpl from 'xrpl'\n\nconst client = new xrpl.Client('wss://xrplcluster.com')\nawait client.connect()\n"},"children":[]}]},{"$$mdtype":"Tag","name":"div","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/calculate-reserves/py/calculate_reserves.py","language":"py","header":{"controls":{"copy":{}}},"lang":"py","source":"# Set up client ----------------------\n\nclient = JsonRpcClient(\"https://xrplcluster.com\")\n"},"children":[]}]},{"$$mdtype":"Tag","name":"div","attributes":{"label":"Go","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/calculate-reserves/go/calculate_reserves.go","language":"go","header":{"controls":{"copy":{}}},"lang":"go","source":"// Set up client ----------------------\n\npackage main\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"github.com/Peersyst/xrpl-go/xrpl/currency\"\n\t\"github.com/Peersyst/xrpl-go/xrpl/queries/account\"\n\t\"github.com/Peersyst/xrpl-go/xrpl/queries/server\"\n\t\"github.com/Peersyst/xrpl-go/xrpl/transaction/types\"\n\t\"github.com/Peersyst/xrpl-go/xrpl/websocket\"\n)\n\nfunc main() {\n\tclient := websocket.NewClient(\n\t\twebsocket.NewClientConfig().\n\t\t\tWithHost(\"wss://xrplcluster.com\"),\n\t)\n\tdefer client.Disconnect()\n\n\tif err := client.Connect(); err != nil {\n\t\tpanic(err)\n\t}\n\n\t"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"3-look-up-reserve-values","__idx":7},"children":["3. Look up reserve values"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Retrieve the base and incremental reserve values using the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/references/http-websocket-apis/public-api-methods/server-info-methods/server_info"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["server_info"]}]}," or ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/references/http-websocket-apis/public-api-methods/server-info-methods/server_state"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["server_state"]}]}," method. This example uses ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["server_state"]}," to return reserve values as integer drops, avoiding floating-point precision issues."]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"div","attributes":{"label":"JavaScript","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/calculate-reserves/js/calculate_reserves.js","language":"js","header":{"controls":{"copy":{}}},"lang":"js","source":"// Look up reserve values ----------------------\n\nconst serverState = await client.request({ command: 'server_state' })\nconst validatedLedger = serverState.result.state.validated_ledger\n\nconst baseReserveDrops = validatedLedger.reserve_base\nconst reserveIncDrops = validatedLedger.reserve_inc\n\nconsole.log(`Base reserve: ${xrpl.dropsToXrp(baseReserveDrops)} XRP`)\nconsole.log(`Incremental reserve: ${xrpl.dropsToXrp(reserveIncDrops)} XRP`)\n"},"children":[]}]},{"$$mdtype":"Tag","name":"div","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/calculate-reserves/py/calculate_reserves.py","language":"py","header":{"controls":{"copy":{}}},"lang":"py","source":"# Look up reserve values ----------------------\n\nresponse = client.request(ServerState())\nvalidated_ledger = response.result[\"state\"][\"validated_ledger\"]\n\nbase_reserve = validated_ledger[\"reserve_base\"]\nreserve_inc = validated_ledger[\"reserve_inc\"]\n\nprint(f\"Base reserve: {drops_to_xrp(str(base_reserve))} XRP\")\nprint(f\"Incremental reserve: {drops_to_xrp(str(reserve_inc))} XRP\")\n"},"children":[]}]},{"$$mdtype":"Tag","name":"div","attributes":{"label":"Go","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/calculate-reserves/go/calculate_reserves.go","language":"go","header":{"controls":{"copy":{}}},"lang":"go","source":"\t// Look up reserve values ----------------------\n\n\tres, err := client.Request(&server.StateRequest{})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tvar serverState server.StateResponse\n\tif err := res.GetResult(&serverState); err != nil {\n\t\tpanic(err)\n\t}\n\n\tbaseReserve := serverState.State.ValidatedLedger.ReserveBase\n\treserveInc := serverState.State.ValidatedLedger.ReserveInc\n\n\tbaseReserveXrp, err := currency.DropsToXrp(strconv.FormatUint(uint64(baseReserve), 10))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treserveIncXrp, err := currency.DropsToXrp(strconv.FormatUint(uint64(reserveInc), 10))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Printf(\"Base reserve: %v XRP\\n\", baseReserveXrp)\n\tfmt.Printf(\"Incremental reserve: %v XRP\\n\", reserveIncXrp)\n\n\t"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"4-look-up-owner-count","__idx":8},"children":["4. Look up owner count"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Call ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/references/http-websocket-apis/public-api-methods/account-methods/account_info"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["account_info"]}]}," and take ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["account_data.OwnerCount"]}," to retrieve an account's total number of objects."]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"div","attributes":{"label":"JavaScript","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/calculate-reserves/js/calculate_reserves.js","language":"js","header":{"controls":{"copy":{}}},"lang":"js","source":"// Look up owner count ----------------------\n\nconst address = 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn' // replace with any address\nconst accountInfo = await client.request({ command: 'account_info', account: address })\nconst ownerCount = accountInfo.result.account_data.OwnerCount\n"},"children":[]}]},{"$$mdtype":"Tag","name":"div","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/calculate-reserves/py/calculate_reserves.py","language":"py","header":{"controls":{"copy":{}}},"lang":"py","source":"# Look up owner count ----------------------\n\naddress = \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\"  # replace with any address\nresponse = client.request(AccountInfo(account=address))\nowner_count = response.result[\"account_data\"][\"OwnerCount\"]\n"},"children":[]}]},{"$$mdtype":"Tag","name":"div","attributes":{"label":"Go","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/calculate-reserves/go/calculate_reserves.go","language":"go","header":{"controls":{"copy":{}}},"lang":"go","source":"\t// Look up owner count ----------------------\n\n\taddress := types.Address(\"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\") // replace with any address\n\taccountInfo, err := client.GetAccountInfo(&account.InfoRequest{Account: address})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\townerCount := accountInfo.AccountData.OwnerCount\n\n\t"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"5-calculate-total-reserve","__idx":9},"children":["5. Calculate total reserve"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Once you have the owner count, you can calculate the account's total reserve. The total reserve is the base reserve plus the incremental reserve multiplied by the owner count."]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"div","attributes":{"label":"JavaScript","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/calculate-reserves/js/calculate_reserves.js","language":"js","header":{"controls":{"copy":{}}},"lang":"js","source":"// Calculate total reserve ----------------------\n\nconst totalReserveDrops = baseReserveDrops + (ownerCount * reserveIncDrops)\nconsole.log(`Owner count: ${ownerCount}`)\nconsole.log(`Total reserve: ${xrpl.dropsToXrp(totalReserveDrops)} XRP`)\n\nawait client.disconnect()\n"},"children":[]}]},{"$$mdtype":"Tag","name":"div","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/calculate-reserves/py/calculate_reserves.py","language":"py","header":{"controls":{"copy":{}}},"lang":"py","source":"# Calculate total reserve ----------------------\n\ntotal_reserve = base_reserve + (owner_count * reserve_inc)\nprint(f\"Owner count: {owner_count}\")\nprint(f\"Total reserve: {drops_to_xrp(str(total_reserve))} XRP\")\n"},"children":[]}]},{"$$mdtype":"Tag","name":"div","attributes":{"label":"Go","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/calculate-reserves/go/calculate_reserves.go","language":"go","header":{"controls":{"copy":{}}},"lang":"go","source":"\t// Calculate total reserve ----------------------\n\n\ttotalReserve := baseReserve + (uint(ownerCount) * reserveInc)\n\n\ttotalReserveXrp, err := currency.DropsToXrp(strconv.FormatUint(uint64(totalReserve), 10))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Printf(\"Owner count: %v\\n\", ownerCount)\n\tfmt.Printf(\"Total reserve: %v XRP\\n\", totalReserveXrp)\n}\n"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"see-also","__idx":10},"children":["See Also"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Concepts:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/concepts/accounts/reserves"},"children":["Reserves"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Tutorials:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/tutorials/sample-apps/build-a-desktop-wallet-in-python#3-display-an-account"},"children":["Calculate and Display the Reserve Requirement (Python)"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["References:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/references/http-websocket-apis/public-api-methods/server-info-methods/server_info"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["server_info"]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/references/http-websocket-apis/public-api-methods/server-info-methods/server_state"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["server_state"]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/references/http-websocket-apis/public-api-methods/account-methods/account_info"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["account_info"]}]}]}]}]},"headings":[{"value":"Calculate Account Reserves","id":"calculate-account-reserves","depth":1},{"value":"Goals","id":"goals","depth":2},{"value":"Prerequisites","id":"prerequisites","depth":2},{"value":"Source Code","id":"source-code","depth":2},{"value":"Steps","id":"steps","depth":2},{"value":"1. Install dependencies","id":"1-install-dependencies","depth":3},{"value":"2. Set up client","id":"2-set-up-client","depth":3},{"value":"3. Look up reserve values","id":"3-look-up-reserve-values","depth":3},{"value":"4. Look up owner count","id":"4-look-up-owner-count","depth":3},{"value":"5. Calculate total reserve","id":"5-calculate-total-reserve","depth":3},{"value":"See Also","id":"see-also","depth":2}],"frontmatter":{"seo":{"description":"Look up and calculate base and owner reserve requirements for an XRPL account.","title":"Calculate Account Reserves"},"labels":["Accounts"]},"editPage":{"to":"https://github.com/XRPLF/xrpl-dev-portal/tree/master/docs/tutorials/best-practices/account-management/calculate-reserves.md"},"lastModified":"2026-04-06T17:51:32.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/tutorials/best-practices/account-management/calculate-reserves","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}