{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/es-ES/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["amendment-disclaimer","tabs","tab","code-snippet","admonition"]},"type":"markdown"},"seo":{"title":"Manage a Sponsorship Pool","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":"Agentic Transactions","description":"XRPL AI Starter Kit to help autonomous agents discover, set up, and execute agentic transactions on the XRP Ledger.","includeFiles":["docs/agents/**/*.*"],"excludeFiles":[]},{"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 xrpld and Clio servers.","includeFiles":["docs/infrastructure/**/*.*"],"excludeFiles":["docs/infrastructure/index.md","docs/infrastructure/*/index.md","docs/infrastructure/installation/build-run-xrpld-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":"Create, spend, top up, and delete a pre-funded sponsorship pool on the XRP Ledger."},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"manage-a-sponsorship-pool","__idx":0},"children":["Manage a Sponsorship Pool"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This tutorial shows you how to manage a pre-funded ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/es-es/docs/concepts/accounts/sponsored-fees-and-reserves#how-sponsorship-works"},"children":["sponsorship"]}," pool as a sponsor. The example creates a pool, checks what it spends, tops it up, and deletes it to reclaim any unspent XRP."]},{"$$mdtype":"Tag","name":"AmendmentDisclaimer","attributes":{"name":"Sponsor","compact":false,"statusOnly":false,"mode":""},"children":[]},{"$$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":["Create a sponsorship pool and track what it spends."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Update a pool to adjust its fee allocation and reserve allowance."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Delete a pool to return the remaining funds to the sponsor."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"prerequisites","__idx":2},"children":["Prerequisites"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To complete this tutorial, you should:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Have a basic understanding of the XRP Ledger and ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/es-es/docs/concepts/accounts/sponsored-fees-and-reserves"},"children":["Sponsored Fees and Reserves"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Have an XRP Ledger client library set up in your development environment. This page provides examples for the following:",{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["JavaScript"]}," with the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/XRPLF/xrpl.js"},"children":["xrpl.js library"]},". See ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/es-es/docs/tutorials/get-started/get-started-javascript"},"children":["Get Started Using JavaScript"]}," for setup steps."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Python"]}," with the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/XRPLF/xrpl-py"},"children":["xrpl-py library"]},". See ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/es-es/docs/tutorials/get-started/get-started-python"},"children":["Get Started Using Python"]}," for setup steps."]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"source-code","__idx":3},"children":["Source Code"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can find the complete source code for this tutorial's example in the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/XRPLF/xrpl-dev-portal/tree/master/_code-samples/sponsored-fees-and-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":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"JavaScript","disable":false},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["From the code sample folder, use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["npm"]}," to install dependencies:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"npm install\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["From the code sample folder, set up a virtual environment and use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["pip"]}," to install dependencies:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"python3 -m venv .venv\nsource .venv/bin/activate\npip install -r requirements.txt\n","lang":"bash"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"2-set-up-the-client","__idx":6},"children":["2. Set up the client"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Import the necessary libraries and instantiate a client to connect to the XRPL. This example imports:"]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"JavaScript","disable":false},"children":[{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["xrpl"]},": Used for XRPL client connection, transaction submission, and wallet handling. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SponsorshipSetFlags"]}," holds the flags that update and delete the pool."]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/sponsored-fees-and-reserves/js/manageSponsorshipPool.js","language":"js","header":{"controls":{"copy":{}}},"lang":"js","source":"import {\n  Client,\n  SponsorFlags,\n  SponsorshipSetFlags,\n  validate\n} from 'xrpl'\n\n// Connect to the network ----------------------\nconst client = new Client('wss://s.devnet.rippletest.net:51233')\nawait client.connect()"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["xrpl"]},": Used for XRPL client connection, transaction submission, and wallet handling. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SponsorshipSetFlag"]}," holds the flags that update and delete the pool."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["json"]},": Used for formatting JSON data."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sys"]},": Used to exit on transaction failures."]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/sponsored-fees-and-reserves/py/manage_sponsorship_pool.py","language":"py","header":{"controls":{"copy":{}}},"lang":"py","source":"import json\nimport sys\n\nfrom xrpl.clients import JsonRpcClient\nfrom xrpl.models import (\n    AccountInfo,\n    DepositPreauth,\n    SponsorFlag,\n    SponsorshipSet,\n    SponsorshipSetFlag,\n)\nfrom xrpl.transaction import submit_and_wait\nfrom xrpl.wallet import generate_faucet_wallet\n\n# Set up client ----------------------\nclient = JsonRpcClient(\"https://s.devnet.rippletest.net:51234\")"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"3-create-the-wallets","__idx":7},"children":["3. Create the wallets"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Create and fund the sponsor and the sponsee accounts."]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"JavaScript","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/sponsored-fees-and-reserves/js/manageSponsorshipPool.js","language":"js","header":{"controls":{"copy":{}}},"lang":"js","source":"// Create the sponsor and sponsee wallets ----------------------\nconsole.log(`\\n=== Creating the sponsor and sponsee wallets... ===`)\nconst { wallet: sponsor } = await client.fundWallet()\nconst { wallet: sponsee } = await client.fundWallet()\n\nconsole.log(`Sponsor address: ${sponsor.address}`)\nconsole.log(`Sponsee address: ${sponsee.address}`)"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/sponsored-fees-and-reserves/py/manage_sponsorship_pool.py","language":"py","header":{"controls":{"copy":{}}},"lang":"py","source":"# Create the sponsor and sponsee wallets ----------------------\nprint(\"\\n=== Creating the sponsor and sponsee wallets... ===\")\nsponsor = generate_faucet_wallet(client)\nsponsee = generate_faucet_wallet(client)\n\nprint(f\"Sponsor address: {sponsor.address}\")\nprint(f\"Sponsee address: {sponsee.address}\")"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"4-create-the-pool","__idx":8},"children":["4. Create the pool"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Submit a ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/references/protocol/transactions/types/sponsorshipset"},"children":["SponsorshipSet transaction"]}," to create the pool."]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"JavaScript","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/sponsored-fees-and-reserves/js/manageSponsorshipPool.js","language":"js","header":{"controls":{"copy":{}}},"lang":"js","source":"// Prepare SponsorshipSet transaction ----------------------\n// FeeAmountDelta adds 1 XRP to the fee pool, MaxFee caps the pool's contribution\n// to any single transaction, and RemainingOwnerCountDelta allows five sponsored ledger entries.\nconsole.log(`\\n=== Preparing SponsorshipSet transaction... ===`)\nconst createPoolTx = {\n  TransactionType: 'SponsorshipSet',\n  Account: sponsor.address,\n  Sponsee: sponsee.address,\n  FeeAmountDelta: '1000000',\n  MaxFee: '1000',\n  RemainingOwnerCountDelta: 5\n}\n\nvalidate(createPoolTx)\nconsole.log(JSON.stringify(createPoolTx, null, 2))"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/sponsored-fees-and-reserves/py/manage_sponsorship_pool.py","language":"py","header":{"controls":{"copy":{}}},"lang":"py","source":"# Prepare SponsorshipSet transaction ----------------------\n# FeeAmountDelta adds 1 XRP to the fee pool, MaxFee caps the pool's contribution\n# to any single transaction, and RemainingOwnerCountDelta allows five sponsored ledger entries.\nprint(\"\\n=== Preparing SponsorshipSet transaction... ===\")\ncreate_pool_tx = SponsorshipSet(\n    account=sponsor.address,\n    sponsee=sponsee.address,\n    fee_amount_delta=\"1000000\",\n    max_fee=\"1000\",\n    remaining_owner_count_delta=5,\n)\n\nprint(json.dumps(create_pool_tx.to_xrpl(), indent=2))"},"children":[]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Only the sponsor can create a pool, so it signs and submits the transaction alone. The metadata returns the new Sponsorship entry's ID."]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"JavaScript","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/sponsored-fees-and-reserves/js/manageSponsorshipPool.js","language":"js","header":{"controls":{"copy":{}}},"lang":"js","source":"// Submit the SponsorshipSet transaction ----------------------\nconsole.log(`\\n=== Submitting SponsorshipSet transaction... ===`)\nconst createResponse = await client.submitAndWait(createPoolTx, {\n  wallet: sponsor,\n  autofill: true\n})\n\nif (createResponse.result.meta.TransactionResult !== 'tesSUCCESS') {\n  const resultCode = createResponse.result.meta.TransactionResult\n  console.error('Error: Unable to create the sponsorship:', resultCode)\n  await client.disconnect()\n  process.exit(1)\n}\n\nconst sponsorshipNode = createResponse.result.meta.AffectedNodes.find(\n  node => node.CreatedNode?.LedgerEntryType === 'Sponsorship'\n)\nconsole.log('Sponsorship created successfully!')\nconsole.log(`Sponsorship ID: ${sponsorshipNode.CreatedNode.LedgerIndex}`)\nconsole.log(`Transaction URL: https://devnet.xrpl.org/transactions/${createResponse.result.hash}`)"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/sponsored-fees-and-reserves/py/manage_sponsorship_pool.py","language":"py","header":{"controls":{"copy":{}}},"lang":"py","source":"# Submit the SponsorshipSet transaction ----------------------\nprint(\"\\n=== Submitting SponsorshipSet transaction... ===\")\ncreate_response = submit_and_wait(create_pool_tx, client, sponsor)\n\nif create_response.result[\"meta\"][\"TransactionResult\"] != \"tesSUCCESS\":\n    result_code = create_response.result[\"meta\"][\"TransactionResult\"]\n    print(f\"Error: Unable to create the sponsorship: {result_code}\")\n    sys.exit(1)\n\nsponsorship_node = next(\n    node for node in create_response.result[\"meta\"][\"AffectedNodes\"]\n    if node.get(\"CreatedNode\", {}).get(\"LedgerEntryType\") == \"Sponsorship\"\n)\nprint(\"Sponsorship created successfully!\")\nprint(f\"Sponsorship ID: {sponsorship_node['CreatedNode']['LedgerIndex']}\")\nprint(f\"Transaction URL: https://devnet.xrpl.org/transactions/{create_response.result['hash']}\")"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"warning","name":"Warning"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Sponsorship entry appears in both accounts' owner directories, which makes it a ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/es-es/docs/concepts/accounts/deleting-accounts#deletion-blockers"},"children":["deletion blocker"]}," for the sponsor and the sponsee alike. Neither account can be deleted until the pool is."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"5-spend-part-of-the-pool","__idx":9},"children":["5. Spend part of the pool"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Spend part of the pool by submitting a ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/references/protocol/transactions/types/depositpreauth"},"children":["DepositPreauth transaction"]}," that draws the fee and one owner reserve from the pool."]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"JavaScript","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/sponsored-fees-and-reserves/js/manageSponsorshipPool.js","language":"js","header":{"controls":{"copy":{}}},"lang":"js","source":"// Spend part of the pool ----------------------\n// The sponsee creates a DepositPreauth entry, drawing the fee and one owner reserve\n// from the pool.\nconsole.log(`\\n=== Submitting sponsored DepositPreauth transaction... ===`)\nconst depositPreauthTx = {\n  TransactionType: 'DepositPreauth',\n  Account: sponsee.address,\n  Authorize: sponsor.address,\n  Sponsor: sponsor.address,\n  SponsorFlags: SponsorFlags.spfSponsorFee | SponsorFlags.spfSponsorReserve\n}\nvalidate(depositPreauthTx)\n\nconst depositPreauthResponse = await client.submitAndWait(depositPreauthTx, {\n  wallet: sponsee,\n  autofill: true\n})\n\nif (depositPreauthResponse.result.meta.TransactionResult !== 'tesSUCCESS') {\n  const resultCode = depositPreauthResponse.result.meta.TransactionResult\n  console.error('Error: Unable to create the preauthorization:', resultCode)\n  await client.disconnect()\n  process.exit(1)\n}\n\nlet fields = depositPreauthResponse.result.meta.AffectedNodes.find(\n  node => node.ModifiedNode?.LedgerEntryType === 'Sponsorship'\n).ModifiedNode.FinalFields\nconsole.log('Sponsorship pool:')\nconsole.log(`  Fee amount:            ${fields.FeeAmount} drops`)\nconsole.log(`  Owner reserves count:  ${fields.RemainingOwnerCount}`)\nconsole.log(`Transaction URL: https://devnet.xrpl.org/transactions/${depositPreauthResponse.result.hash}`)"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/sponsored-fees-and-reserves/py/manage_sponsorship_pool.py","language":"py","header":{"controls":{"copy":{}}},"lang":"py","source":"# Spend part of the pool ----------------------\n# The sponsee creates a DepositPreauth entry, drawing the fee and one owner reserve\n# from the pool.\nprint(\"\\n=== Submitting sponsored DepositPreauth transaction... ===\")\ndeposit_preauth_tx = DepositPreauth(\n    account=sponsee.address,\n    authorize=sponsor.address,\n    sponsor=sponsor.address,\n    sponsor_flags=SponsorFlag.SPF_SPONSOR_FEE | SponsorFlag.SPF_SPONSOR_RESERVE,\n)\ndeposit_preauth_response = submit_and_wait(deposit_preauth_tx, client, sponsee)\n\nif deposit_preauth_response.result[\"meta\"][\"TransactionResult\"] != \"tesSUCCESS\":\n    result_code = deposit_preauth_response.result[\"meta\"][\"TransactionResult\"]\n    print(f\"Error: Unable to create the preauthorization: {result_code}\")\n    sys.exit(1)\n\nfields = next(\n    node[\"ModifiedNode\"][\"FinalFields\"]\n    for node in deposit_preauth_response.result[\"meta\"][\"AffectedNodes\"]\n    if node.get(\"ModifiedNode\", {}).get(\"LedgerEntryType\") == \"Sponsorship\"\n)\nprint(\"Sponsorship pool:\")\nprint(f\"  Fee amount:            {fields['FeeAmount']} drops\")\nprint(f\"  Owner reserves count:  {fields['RemainingOwnerCount']}\")\nprint(f\"Transaction URL: https://devnet.xrpl.org/transactions/{deposit_preauth_response.result['hash']}\")"},"children":[]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Sponsorship entry's ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["FeeAmount"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["RemainingOwnerCount"]}," fields drop accordingly."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"6-top-up-the-pool","__idx":10},"children":["6. Top up the pool"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Send another SponsorshipSet transaction for the same sponsee to change the pool's allowances."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["FeeAmountDelta"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["RemainingOwnerCountDelta"]}," apply changes to the current allowances. Positive deltas add budget and negative deltas reduce it. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["MaxFee"]}," remains an absolute per-transaction cap."]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"Note"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The pool doesn't automatically regain ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["RemainingOwnerCount"]}," when a sponsored ledger entry is deleted or reassigned. Those actions free the sponsor's reserve and lower its ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SponsoringOwnerCount"]},", but the pool's spent reserve allowance remains spent. Top the pool up with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["RemainingOwnerCountDelta"]}," to sponsor more ledger entries."]}]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"JavaScript","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/sponsored-fees-and-reserves/js/manageSponsorshipPool.js","language":"js","header":{"controls":{"copy":{}}},"lang":"js","source":"// Prepare SponsorshipSet transaction to top up the pool ----------------------\n// A second SponsorshipSet on the same sponsee applies deltas to the current allowances.\n// Here the sponsor adds another 1 XRP of fee budget and five more reserve units.\nconsole.log(`\\n=== Preparing SponsorshipSet transaction to top up sponsorship pool... ===`)\nconst updatePoolTx = {\n  TransactionType: 'SponsorshipSet',\n  Account: sponsor.address,\n  Sponsee: sponsee.address,\n  FeeAmountDelta: '1000000',\n  MaxFee: '1000',\n  RemainingOwnerCountDelta: 5\n}\n\nvalidate(updatePoolTx)\nconsole.log(JSON.stringify(updatePoolTx, null, 2))"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/sponsored-fees-and-reserves/py/manage_sponsorship_pool.py","language":"py","header":{"controls":{"copy":{}}},"lang":"py","source":"# Prepare SponsorshipSet transaction to top up the pool ----------------------\n# A second SponsorshipSet on the same sponsee applies deltas to the current allowances.\n# Here the sponsor adds another 1 XRP of fee budget and five more reserve units.\nprint(\"\\n=== Preparing SponsorshipSet transaction to top up sponsorship pool... ===\")\nupdate_pool_tx = SponsorshipSet(\n    account=sponsor.address,\n    sponsee=sponsee.address,\n    fee_amount_delta=\"1000000\",\n    max_fee=\"1000\",\n    remaining_owner_count_delta=5,\n)\n\nprint(json.dumps(update_pool_tx.to_xrpl(), indent=2))"},"children":[]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The sponsor submits the update, and the metadata shows the entry's raised ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["FeeAmount"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["RemainingOwnerCount"]},"."]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"JavaScript","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/sponsored-fees-and-reserves/js/manageSponsorshipPool.js","language":"js","header":{"controls":{"copy":{}}},"lang":"js","source":"// Submit the SponsorshipSet transaction to top up the pool ----------------------\nconsole.log(`\\n=== Submitting SponsorshipSet transaction... ===`)\nconst updateResponse = await client.submitAndWait(updatePoolTx, {\n  wallet: sponsor,\n  autofill: true\n})\n\nif (updateResponse.result.meta.TransactionResult !== 'tesSUCCESS') {\n  const resultCode = updateResponse.result.meta.TransactionResult\n  console.error('Error: Unable to update the sponsorship:', resultCode)\n  await client.disconnect()\n  process.exit(1)\n}\n\nfields = updateResponse.result.meta.AffectedNodes.find(\n  node => node.ModifiedNode?.LedgerEntryType === 'Sponsorship'\n).ModifiedNode.FinalFields\nconsole.log('Sponsorship pool topped up successfully:')\nconsole.log(`  Fee amount:            ${fields.FeeAmount} drops`)\nconsole.log(`  Owner reserves count:  ${fields.RemainingOwnerCount}`)\nconsole.log(`Transaction URL: https://devnet.xrpl.org/transactions/${updateResponse.result.hash}`)"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/sponsored-fees-and-reserves/py/manage_sponsorship_pool.py","language":"py","header":{"controls":{"copy":{}}},"lang":"py","source":"# Submit the SponsorshipSet transaction to top up the pool ----------------------\nprint(\"\\n=== Submitting SponsorshipSet transaction... ===\")\nupdate_response = submit_and_wait(update_pool_tx, client, sponsor)\n\nif update_response.result[\"meta\"][\"TransactionResult\"] != \"tesSUCCESS\":\n    result_code = update_response.result[\"meta\"][\"TransactionResult\"]\n    print(f\"Error: Unable to update the sponsorship: {result_code}\")\n    sys.exit(1)\n\nfields = next(\n    node[\"ModifiedNode\"][\"FinalFields\"]\n    for node in update_response.result[\"meta\"][\"AffectedNodes\"]\n    if node.get(\"ModifiedNode\", {}).get(\"LedgerEntryType\") == \"Sponsorship\"\n)\nprint(\"Sponsorship pool topped up successfully:\")\nprint(f\"  Fee amount:            {fields['FeeAmount']} drops\")\nprint(f\"  Owner reserves count:  {fields['RemainingOwnerCount']}\")\nprint(f\"Transaction URL: https://devnet.xrpl.org/transactions/{update_response.result['hash']}\")"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"7-delete-the-pool","__idx":11},"children":["7. Delete the pool"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Submit a SponsorshipSet transaction with the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tfDeleteObject"]}," flag enabled to delete the Sponsorship entry and return the unspent ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["FeeAmount"]}," to the sponsor. The example looks up the sponsor's balance with the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/references/http-websocket-apis/public-api-methods/account-methods/account_info"},"children":["account_info method"]}," first, so it can compare the balance after the deletion."]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"JavaScript","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/sponsored-fees-and-reserves/js/manageSponsorshipPool.js","language":"js","header":{"controls":{"copy":{}}},"lang":"js","source":"// Prepare SponsorshipSet transaction to delete the sponsorship ----------------------\n// tfDeleteObject returns the unspent FeeAmount to the sponsor. Ledger entries the\n// pool already paid reserves for stay sponsored until they're transferred or deleted.\nconsole.log(`\\n=== Preparing SponsorshipSet transaction to delete the sponsorship... ===`)\nconst balanceBeforeResponse = await client.request({\n  command: 'account_info',\n  account: sponsor.address,\n  ledger_index: 'validated'\n})\nconst sponsorBalanceBefore = BigInt(\n  balanceBeforeResponse.result.account_data.Balance\n)\n\nconst deletePoolTx = {\n  TransactionType: 'SponsorshipSet',\n  Account: sponsor.address,\n  Sponsee: sponsee.address,\n  Flags: SponsorshipSetFlags.tfDeleteObject\n}\n\nvalidate(deletePoolTx)\nconsole.log(JSON.stringify(deletePoolTx, null, 2))"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/sponsored-fees-and-reserves/py/manage_sponsorship_pool.py","language":"py","header":{"controls":{"copy":{}}},"lang":"py","source":"# Prepare SponsorshipSet transaction to delete the sponsorship ----------------------\n# tfDeleteObject returns the unspent FeeAmount to the sponsor. Ledger entries the\n# pool already paid reserves for stay sponsored until they're transferred or deleted.\nprint(\"\\n=== Preparing SponsorshipSet transaction to delete the sponsorship... ===\")\nsponsor_balance_before = int(\n    client.request(\n        AccountInfo(account=sponsor.address, ledger_index=\"validated\")\n    ).result[\"account_data\"][\"Balance\"]\n)\n\ndelete_pool_tx = SponsorshipSet(\n    account=sponsor.address,\n    sponsee=sponsee.address,\n    flags=SponsorshipSetFlag.TF_DELETE_OBJECT,\n)\n\nprint(json.dumps(delete_pool_tx.to_xrpl(), indent=2))"},"children":[]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The sponsor submits the deletion, and the metadata confirms the Sponsorship entry is deleted."]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"JavaScript","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/sponsored-fees-and-reserves/js/manageSponsorshipPool.js","language":"js","header":{"controls":{"copy":{}}},"lang":"js","source":"// Submit the SponsorshipSet transaction to delete the sponsorship ----------------------\nconsole.log(`\\n=== Submitting SponsorshipSet transaction... ===`)\nconst deleteResponse = await client.submitAndWait(deletePoolTx, {\n  wallet: sponsor,\n  autofill: true\n})\n\nif (deleteResponse.result.meta.TransactionResult !== 'tesSUCCESS') {\n  const resultCode = deleteResponse.result.meta.TransactionResult\n  console.error('Error: Unable to delete the sponsorship:', resultCode)\n  await client.disconnect()\n  process.exit(1)\n}\n\nconst deletedNode = deleteResponse.result.meta.AffectedNodes.find(\n  node => node.DeletedNode?.LedgerEntryType === 'Sponsorship'\n)\nconsole.log('Sponsorship deleted successfully!')\nconsole.log(`Transaction URL: https://devnet.xrpl.org/transactions/${deleteResponse.result.hash}`)"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/sponsored-fees-and-reserves/py/manage_sponsorship_pool.py","language":"py","header":{"controls":{"copy":{}}},"lang":"py","source":"# Submit the SponsorshipSet transaction to delete the sponsorship ----------------------\nprint(\"\\n=== Submitting SponsorshipSet transaction... ===\")\ndelete_response = submit_and_wait(delete_pool_tx, client, sponsor)\n\nif delete_response.result[\"meta\"][\"TransactionResult\"] != \"tesSUCCESS\":\n    result_code = delete_response.result[\"meta\"][\"TransactionResult\"]\n    print(f\"Error: Unable to delete the sponsorship: {result_code}\")\n    sys.exit(1)\n\ndeleted_node = next(\n    node for node in delete_response.result[\"meta\"][\"AffectedNodes\"]\n    if node.get(\"DeletedNode\", {}).get(\"LedgerEntryType\") == \"Sponsorship\"\n)\nprint(\"Sponsorship deleted successfully!\")\nprint(f\"Transaction URL: https://devnet.xrpl.org/transactions/{delete_response.result['hash']}\")"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"Note"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Deleting a pool does not revoke sponsorship on ledger entries that already consumed its reserve allowance. Those entries stay sponsored until the sponsorship ends through a ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/references/protocol/transactions/types/sponsorshiptransfer"},"children":["SponsorshipTransfer transaction"]}," with the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tfSponsorshipEnd"]}," flag, or until the entries are deleted."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"8-verify-the-sponsor-reclaimed-xrp","__idx":12},"children":["8. Verify the sponsor reclaimed XRP"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Send another ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/references/http-websocket-apis/public-api-methods/account-methods/account_info"},"children":["account_info method"]}," request to compare the sponsor's balance before and after the deletion. The sponsor gets the pool's unspent ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["FeeAmount"]}," back, minus the transaction fee paid to submit the delete transaction."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Deleting the Sponsorship entry also releases the sponsor's owner reserve requirement, but that does not appear as an XRP balance increase. The balance check only shows the returned ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["FeeAmount"]}," minus the delete transaction fee."]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"JavaScript","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/sponsored-fees-and-reserves/js/manageSponsorshipPool.js","language":"js","header":{"controls":{"copy":{}}},"lang":"js","source":"// Show the reclaimed XRP ----------------------\nconsole.log(`\\n=== Reclaimed Funds ===`)\nconst balanceAfterResponse = await client.request({\n  command: 'account_info',\n  account: sponsor.address,\n  ledger_index: 'validated'\n})\nconst sponsorBalanceAfter = BigInt(\n  balanceAfterResponse.result.account_data.Balance\n)\nconst deleteFee = BigInt(deleteResponse.result.tx_json.Fee)\n\nconsole.log(`Unspent fee amount returned from pool: ${deletedNode.DeletedNode.FinalFields.FeeAmount} drops`)\nconsole.log(`Sponsor balance \"before\" deletion:     ${sponsorBalanceBefore} drops`)\nconsole.log(`Sponsor balance \"after\" deletion:      ${sponsorBalanceAfter} drops`)\nconsole.log(`Delete transaction (fee paid):         ${deleteFee} drops`)\n\nawait client.disconnect()\n"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/_code-samples/sponsored-fees-and-reserves/py/manage_sponsorship_pool.py","language":"py","header":{"controls":{"copy":{}}},"lang":"py","source":"# Show the reclaimed XRP ----------------------\nprint(\"\\n=== Reclaimed Funds ===\")\nsponsor_balance_after = int(\n    client.request(\n        AccountInfo(account=sponsor.address, ledger_index=\"validated\")\n    ).result[\"account_data\"][\"Balance\"]\n)\ndelete_fee = int(delete_response.result[\"tx_json\"][\"Fee\"])\n\nprint(f\"Unspent fee amount returned from pool: {deleted_node['DeletedNode']['FinalFields']['FeeAmount']} drops\")\nprint(f\"Sponsor balance \\\"before\\\" deletion:     {sponsor_balance_before} drops\")\nprint(f\"Sponsor balance \\\"after\\\" deletion:      {sponsor_balance_after} drops\")\nprint(f\"Delete transaction (fee paid):         {delete_fee} drops\")\n"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"see-also","__idx":13},"children":["See Also"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Concepts:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/es-es/docs/concepts/accounts/sponsored-fees-and-reserves"},"children":["Sponsored Fees and Reserves"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/es-es/docs/concepts/accounts/reserves"},"children":["Reserves"]}]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Tutorials:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/es-es/docs/tutorials/best-practices/account-management/sponsor-a-transaction-by-co-signing"},"children":["Sponsor a Transaction by Co-Signing"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/es-es/docs/tutorials/best-practices/account-management/sponsor-a-transaction-with-a-pre-funded-pool"},"children":["Sponsor a Transaction with a Pre-funded Pool"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/es-es/docs/tutorials/best-practices/account-management/transfer-a-reserve-sponsorship"},"children":["Transfer a Reserve Sponsorship"]}]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["References:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/references/protocol/transactions/types/sponsorshipset"},"children":["SponsorshipSet transaction"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/references/protocol/transactions/types/depositpreauth"},"children":["DepositPreauth transaction"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/references/protocol/ledger-data/ledger-entry-types/sponsorship"},"children":["Sponsorship ledger entry"]}]}]}]}]}]},"headings":[{"value":"Manage a Sponsorship Pool","id":"manage-a-sponsorship-pool","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 the client","id":"2-set-up-the-client","depth":3},{"value":"3. Create the wallets","id":"3-create-the-wallets","depth":3},{"value":"4. Create the pool","id":"4-create-the-pool","depth":3},{"value":"5. Spend part of the pool","id":"5-spend-part-of-the-pool","depth":3},{"value":"6. Top up the pool","id":"6-top-up-the-pool","depth":3},{"value":"7. Delete the pool","id":"7-delete-the-pool","depth":3},{"value":"8. Verify the sponsor reclaimed XRP","id":"8-verify-the-sponsor-reclaimed-xrp","depth":3},{"value":"See Also","id":"see-also","depth":2}],"frontmatter":{"seo":{"description":"Create, spend, top up, and delete a pre-funded sponsorship pool on the XRP Ledger.","title":"Manage a Sponsorship Pool"},"labels":["Accounts","Fees","Sponsorship"],"status":"not_enabled"},"editPage":{"to":"https://github.com/XRPLF/xrpl-dev-portal/tree/master/docs/tutorials/best-practices/account-management/manage-a-sponsorship-pool.md"},"lastModified":"2026-08-26T10:28:02.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/es-es/docs/tutorials/best-practices/account-management/manage-a-sponsorship-pool","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}