{"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":"Transfer a Reserve Sponsorship","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, reassign, or end the reserve sponsorship on an existing ledger entry."},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"transfer-a-reserve-sponsorship","__idx":0},"children":["Transfer a Reserve Sponsorship"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This tutorial shows you how to use the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/references/protocol/transactions/types/sponsorshiptransfer"},"children":["SponsorshipTransfer transaction"]}," to create, reassign, or end ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/es-es/docs/concepts/accounts/sponsored-fees-and-reserves#how-sponsorship-works"},"children":["reserve sponsorship"]}," for an existing ledger entry. This example walks through all three operations on a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["DepositPreauth"]}," entry, but SponsorshipTransfer can also transfer sponsorship of account reserves."]},{"$$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 reserve sponsorship on an existing unsponsored ledger entry."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Reassign a reserve sponsorship from one sponsor to another."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["End a reserve sponsorship so the sponsee covers the reserve."]}]},{"$$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":"CodeBlock","attributes":{"file":"/_code-samples/sponsored-fees-and-reserves/js/transferReserveSponsorship.js","language":"js","header":{"controls":{"copy":{}}},"lang":"js","source":"import {\n  Client,\n  SponsorFlags,\n  SponsorshipTransferFlags,\n  signAsSponsor,\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":"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/transfer_reserve_sponsorship.py","language":"py","header":{"controls":{"copy":{}}},"lang":"py","source":"import json\nimport sys\n\nfrom xrpl.clients import JsonRpcClient\nfrom xrpl.models import (\n    DepositPreauth,\n    SponsorFlag,\n    SponsorshipTransfer,\n    SponsorshipTransferFlag,\n)\nfrom xrpl.transaction import autofill, sign, sign_as_sponsor, 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":["Fund three accounts: ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Sponsor A"]},", ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Sponsor B"]},", and the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["sponsee"]},"."]},{"$$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/transferReserveSponsorship.js","language":"js","header":{"controls":{"copy":{}}},"lang":"js","source":"// Create the wallets ----------------------\nconsole.log(`\\n=== Creating the sponsor and sponsee wallets... ===`)\nconst { wallet: sponsorA } = await client.fundWallet()\nconst { wallet: sponsorB } = await client.fundWallet()\nconst { wallet: sponsee } = await client.fundWallet()\n\nconsole.log(`Sponsor A address: ${sponsorA.address}`)\nconsole.log(`Sponsor B address: ${sponsorB.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/transfer_reserve_sponsorship.py","language":"py","header":{"controls":{"copy":{}}},"lang":"py","source":"# Create the wallets ----------------------\nprint(\"\\n=== Creating the sponsor and sponsee wallets... ===\")\nsponsor_a = generate_faucet_wallet(client)\nsponsor_b = generate_faucet_wallet(client)\nsponsee = generate_faucet_wallet(client)\n\nprint(f\"Sponsor A address: {sponsor_a.address}\")\nprint(f\"Sponsor B address: {sponsor_b.address}\")\nprint(f\"Sponsee address:   {sponsee.address}\")"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"4-create-an-unsponsored-ledger-entry","__idx":8},"children":["4. Create an unsponsored ledger entry"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Submit an unsponsored transaction. For this example, a ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/references/protocol/transactions/types/depositpreauth"},"children":["DepositPreauth transaction"]},"."]},{"$$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/transferReserveSponsorship.js","language":"js","header":{"controls":{"copy":{}}},"lang":"js","source":"// Create an unsponsored ledger entry ----------------------\n// The sponsee creates a DepositPreauth entry with no sponsorship fields, so it pays\n// the fee and the owner reserve for the resulting entry itself.\nconsole.log(`\\n=== Submitting unsponsored DepositPreauth transaction... ===`)\nconst depositPreauthTx = {\n  TransactionType: 'DepositPreauth',\n  Account: sponsee.address,\n  Authorize: sponsorA.address\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\nconst preauthNode = depositPreauthResponse.result.meta.AffectedNodes.find(\n  node => node.CreatedNode?.LedgerEntryType === 'DepositPreauth'\n)\nconst preauthID = preauthNode.CreatedNode.LedgerIndex\n\nconsole.log('DepositPreauth created successfully, with its reserve paid by the sponsee.')\nconsole.log(`DepositPreauth ID: ${preauthID}`)\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/transfer_reserve_sponsorship.py","language":"py","header":{"controls":{"copy":{}}},"lang":"py","source":"# Create an unsponsored ledger entry ----------------------\n# The sponsee creates a DepositPreauth entry with no sponsorship fields, so it pays\n# the fee and the owner reserve for the resulting entry itself.\nprint(\"\\n=== Submitting unsponsored DepositPreauth transaction... ===\")\ndeposit_preauth_tx = DepositPreauth(\n    account=sponsee.address,\n    authorize=sponsor_a.address,\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\npreauth_node = next(\n    node for node in deposit_preauth_response.result[\"meta\"][\"AffectedNodes\"]\n    if node.get(\"CreatedNode\", {}).get(\"LedgerEntryType\") == \"DepositPreauth\"\n)\npreauth_id = preauth_node[\"CreatedNode\"][\"LedgerIndex\"]\n\nprint(\"DepositPreauth created successfully, with its reserve paid by the sponsee.\")\nprint(f\"DepositPreauth ID: {preauth_id}\")\nprint(f\"Transaction URL: https://devnet.xrpl.org/transactions/{deposit_preauth_response.result['hash']}\")"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"5-create-the-sponsorship","__idx":9},"children":["5. Create the sponsorship"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Submit a SponsorshipTransfer transaction with the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tfSponsorshipCreate"]}," flag enabled, the unsponsored ledger entry's ID, and Sponsor A's address in the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Sponsor"]}," field."]},{"$$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/transferReserveSponsorship.js","language":"js","header":{"controls":{"copy":{}}},"lang":"js","source":"// Prepare SponsorshipTransfer transaction to start the sponsorship ----------------------\nconsole.log(`\\n=== Preparing SponsorshipTransfer transaction to start the sponsorship... ===`)\nconst createTx = {\n  TransactionType: 'SponsorshipTransfer',\n  Account: sponsee.address,\n  ObjectID: preauthID,\n  Flags: SponsorshipTransferFlags.tfSponsorshipCreate,\n  Sponsor: sponsorA.address,\n  SponsorFlags: SponsorFlags.spfSponsorReserve\n}\n\nvalidate(createTx)\nconst preparedCreateTx = await client.autofill(createTx)\n\nconsole.log(JSON.stringify(preparedCreateTx, 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/transfer_reserve_sponsorship.py","language":"py","header":{"controls":{"copy":{}}},"lang":"py","source":"# Prepare SponsorshipTransfer transaction to start the sponsorship ----------------------\nprint(\"\\n=== Preparing SponsorshipTransfer transaction to start the sponsorship... ===\")\ncreate_tx = SponsorshipTransfer(\n    account=sponsee.address,\n    object_id=preauth_id,\n    flags=SponsorshipTransferFlag.TF_SPONSORSHIP_CREATE,\n    sponsor=sponsor_a.address,\n    sponsor_flags=SponsorFlag.SPF_SPONSOR_RESERVE,\n)\ncreate_tx = autofill(create_tx, client)\n\nprint(json.dumps(create_tx.to_xrpl(), indent=2))"},"children":[]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Sponsor A co-signs the transaction, so it must sign the exact ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Fee"]}," amount it agrees to pay. Autofill the transaction before signing so the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Fee"]}," field is set; if the fee is added or changed after signing, the signature no longer matches the transaction."]},{"$$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/transferReserveSponsorship.js","language":"js","header":{"controls":{"copy":{}}},"lang":"js","source":"// Sign as the sponsee, then co-sign as Sponsor A ----------------------\nconsole.log(`\\n=== Submitting SponsorshipTransfer transaction... ===`)\nconst createSignedTx = signAsSponsor(sponsorA, sponsee.sign(preparedCreateTx).tx_blob)\nconst createResponse = await client.submitAndWait(createSignedTx.tx_blob)\n\nif (createResponse.result.meta.TransactionResult !== 'tesSUCCESS') {\n  const resultCode = createResponse.result.meta.TransactionResult\n  console.error('Error: Unable to start the sponsorship:', resultCode)\n  await client.disconnect()\n  process.exit(1)\n}\n\nlet fields = createResponse.result.meta.AffectedNodes.find(\n  node => node.ModifiedNode?.LedgerEntryType === 'DepositPreauth'\n).ModifiedNode.FinalFields\nconsole.log('Sponsorship started successfully!')\nconsole.log(`DepositPreauth reserve now sponsored by: ${fields.Sponsor}`)\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/transfer_reserve_sponsorship.py","language":"py","header":{"controls":{"copy":{}}},"lang":"py","source":"# Sign as the sponsee, then co-sign as Sponsor A ----------------------\nprint(\"\\n=== Submitting SponsorshipTransfer transaction... ===\")\ncreate_signed_tx = sign_as_sponsor(sponsor_a, sign(create_tx, sponsee))\ncreate_response = submit_and_wait(create_signed_tx.tx, client)\n\nif create_response.result[\"meta\"][\"TransactionResult\"] != \"tesSUCCESS\":\n    result_code = create_response.result[\"meta\"][\"TransactionResult\"]\n    print(f\"Error: Unable to start the sponsorship: {result_code}\")\n    sys.exit(1)\n\nfields = next(\n    node[\"ModifiedNode\"][\"FinalFields\"]\n    for node in create_response.result[\"meta\"][\"AffectedNodes\"]\n    if node.get(\"ModifiedNode\", {}).get(\"LedgerEntryType\") == \"DepositPreauth\"\n)\nprint(\"Sponsorship started successfully!\")\nprint(f\"DepositPreauth reserve now sponsored by: {fields['Sponsor']}\")\nprint(f\"Transaction URL: https://devnet.xrpl.org/transactions/{create_response.result['hash']}\")"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"6-reassign-the-sponsorship","__idx":10},"children":["6. Reassign the sponsorship"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To move the reserve sponsorship from Sponsor A to Sponsor B, submit a SponsorshipTransfer transaction with the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tfSponsorshipReassign"]}," flag enabled, the entry's ID, and Sponsor B's address in the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Sponsor"]}," field."]},{"$$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/transferReserveSponsorship.js","language":"js","header":{"controls":{"copy":{}}},"lang":"js","source":"// Prepare SponsorshipTransfer transaction to reassign the sponsorship ----------------\n// tfSponsorshipReassign moves the reserve to Sponsor B in one transaction. Only the\n// incoming sponsor has to consent; Sponsor A's obligation is released automatically.\nconsole.log(`\\n=== Preparing SponsorshipTransfer transaction to reassign the sponsorship... ===`)\nconst reassignTx = {\n  TransactionType: 'SponsorshipTransfer',\n  Account: sponsee.address,\n  ObjectID: preauthID,\n  Flags: SponsorshipTransferFlags.tfSponsorshipReassign,\n  Sponsor: sponsorB.address,\n  SponsorFlags: SponsorFlags.spfSponsorReserve\n}\n\nvalidate(reassignTx)\nconst preparedReassignTx = await client.autofill(reassignTx)\n\nconsole.log(JSON.stringify(preparedReassignTx, 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/transfer_reserve_sponsorship.py","language":"py","header":{"controls":{"copy":{}}},"lang":"py","source":"# Prepare SponsorshipTransfer transaction to reassign the sponsorship ----------------\n# tfSponsorshipReassign moves the reserve to Sponsor B in one transaction. Only the\n# incoming sponsor has to consent; Sponsor A's obligation is released automatically.\nprint(\"\\n=== Preparing SponsorshipTransfer transaction to reassign the sponsorship... ===\")\nreassign_tx = SponsorshipTransfer(\n    account=sponsee.address,\n    object_id=preauth_id,\n    flags=SponsorshipTransferFlag.TF_SPONSORSHIP_REASSIGN,\n    sponsor=sponsor_b.address,\n    sponsor_flags=SponsorFlag.SPF_SPONSOR_RESERVE,\n)\nreassign_tx = autofill(reassign_tx, client)\n\nprint(json.dumps(reassign_tx.to_xrpl(), indent=2))"},"children":[]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Sponsor B co-signs to accept the reserve obligation; Sponsor A does not need to sign."]},{"$$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/transferReserveSponsorship.js","language":"js","header":{"controls":{"copy":{}}},"lang":"js","source":"// Sign as the sponsee, then co-sign as Sponsor B ----------------------\nconsole.log(`\\n=== Submitting SponsorshipTransfer transaction... ===`)\nconst reassignSignedTx = signAsSponsor(sponsorB, sponsee.sign(preparedReassignTx).tx_blob)\nconst reassignResponse = await client.submitAndWait(reassignSignedTx.tx_blob)\n\nif (reassignResponse.result.meta.TransactionResult !== 'tesSUCCESS') {\n  const resultCode = reassignResponse.result.meta.TransactionResult\n  console.error('Error: Unable to reassign the sponsorship:', resultCode)\n  await client.disconnect()\n  process.exit(1)\n}\n\nfields = reassignResponse.result.meta.AffectedNodes.find(\n  node => node.ModifiedNode?.LedgerEntryType === 'DepositPreauth'\n).ModifiedNode.FinalFields\nconsole.log('Sponsorship reassigned successfully!')\nconsole.log(`DepositPreauth reserve now sponsored by: ${fields.Sponsor}`)\nconsole.log(`Transaction URL: https://devnet.xrpl.org/transactions/${reassignResponse.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/transfer_reserve_sponsorship.py","language":"py","header":{"controls":{"copy":{}}},"lang":"py","source":"# Sign as the sponsee, then co-sign as Sponsor B ----------------------\nprint(\"\\n=== Submitting SponsorshipTransfer transaction... ===\")\nreassign_signed_tx = sign_as_sponsor(sponsor_b, sign(reassign_tx, sponsee))\nreassign_response = submit_and_wait(reassign_signed_tx.tx, client)\n\nif reassign_response.result[\"meta\"][\"TransactionResult\"] != \"tesSUCCESS\":\n    result_code = reassign_response.result[\"meta\"][\"TransactionResult\"]\n    print(f\"Error: Unable to reassign the sponsorship: {result_code}\")\n    sys.exit(1)\n\nfields = next(\n    node[\"ModifiedNode\"][\"FinalFields\"]\n    for node in reassign_response.result[\"meta\"][\"AffectedNodes\"]\n    if node.get(\"ModifiedNode\", {}).get(\"LedgerEntryType\") == \"DepositPreauth\"\n)\nprint(\"Sponsorship reassigned successfully!\")\nprint(f\"DepositPreauth reserve now sponsored by: {fields['Sponsor']}\")\nprint(f\"Transaction URL: https://devnet.xrpl.org/transactions/{reassign_response.result['hash']}\")"},"children":[]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Only the sponsee can reassign a sponsorship, because the sponsee chooses which sponsor to rely on."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"7-end-the-sponsorship","__idx":11},"children":["7. End the sponsorship"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can end a sponsorship by submitting a SponsorshipTransfer transaction with the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tfSponsorshipEnd"]}," flag enabled. Either party can end a sponsorship, but this example has the sponsee submit the transaction. When the sponsor submits instead, it must also include the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Sponsee"]}," field. If it succeeds, the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Sponsor"]}," field is removed and the sponsee becomes responsible for the entry's reserve again."]},{"$$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/transferReserveSponsorship.js","language":"js","header":{"controls":{"copy":{}}},"lang":"js","source":"// Prepare SponsorshipTransfer transaction to end the sponsorship ----------------------\n// tfSponsorshipEnd takes no Sponsor field and needs no co-signature. If it\n// succeeds, the Sponsor field is removed and the sponsee becomes responsible for\n// the entry's reserve again.\nconsole.log(`\\n=== Preparing SponsorshipTransfer transaction to end the sponsorship... ===`)\nconst endTx = {\n  TransactionType: 'SponsorshipTransfer',\n  Account: sponsee.address,\n  ObjectID: preauthID,\n  Flags: SponsorshipTransferFlags.tfSponsorshipEnd\n}\n\nvalidate(endTx)\nconsole.log(JSON.stringify(endTx, 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/transfer_reserve_sponsorship.py","language":"py","header":{"controls":{"copy":{}}},"lang":"py","source":"# Prepare SponsorshipTransfer transaction to end the sponsorship ----------------------\n# tfSponsorshipEnd takes no Sponsor field and needs no co-signature. If it\n# succeeds, the Sponsor field is removed and the sponsee becomes responsible for\n# the entry's reserve again.\nprint(\"\\n=== Preparing SponsorshipTransfer transaction to end the sponsorship... ===\")\nend_tx = SponsorshipTransfer(\n    account=sponsee.address,\n    object_id=preauth_id,\n    flags=SponsorshipTransferFlag.TF_SPONSORSHIP_END,\n)\n\nprint(json.dumps(end_tx.to_xrpl(), indent=2))"},"children":[]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Because no co-signature is involved, the sponsee signs and submits on its own."]},{"$$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/transferReserveSponsorship.js","language":"js","header":{"controls":{"copy":{}}},"lang":"js","source":"// Submit the SponsorshipTransfer transaction to end the sponsorship ----------------------\nconsole.log(`\\n=== Submitting SponsorshipTransfer transaction... ===`)\nconst endResponse = await client.submitAndWait(endTx, {\n  wallet: sponsee,\n  autofill: true\n})\n\nif (endResponse.result.meta.TransactionResult !== 'tesSUCCESS') {\n  const resultCode = endResponse.result.meta.TransactionResult\n  console.error('Error: Unable to end the sponsorship:', resultCode)\n  await client.disconnect()\n  process.exit(1)\n}\n\nfields = endResponse.result.meta.AffectedNodes.find(\n  node => node.ModifiedNode?.LedgerEntryType === 'DepositPreauth'\n).ModifiedNode.FinalFields\nif (fields.Sponsor !== undefined) {\n  console.error('Error: The DepositPreauth entry still has a Sponsor field')\n  await client.disconnect()\n  process.exit(1)\n}\n\nconsole.log('Sponsorship ended successfully!')\nconsole.log(`The sponsee now pays the DepositPreauth entry's owner reserve again.`)\nconsole.log(`Transaction URL: https://devnet.xrpl.org/transactions/${endResponse.result.hash}`)\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/transfer_reserve_sponsorship.py","language":"py","header":{"controls":{"copy":{}}},"lang":"py","source":"# Submit the SponsorshipTransfer transaction to end the sponsorship ----------------------\nprint(\"\\n=== Submitting SponsorshipTransfer transaction... ===\")\nend_response = submit_and_wait(end_tx, client, sponsee)\n\nif end_response.result[\"meta\"][\"TransactionResult\"] != \"tesSUCCESS\":\n    result_code = end_response.result[\"meta\"][\"TransactionResult\"]\n    print(f\"Error: Unable to end the sponsorship: {result_code}\")\n    sys.exit(1)\n\nfields = next(\n    node[\"ModifiedNode\"][\"FinalFields\"]\n    for node in end_response.result[\"meta\"][\"AffectedNodes\"]\n    if node.get(\"ModifiedNode\", {}).get(\"LedgerEntryType\") == \"DepositPreauth\"\n)\nif \"Sponsor\" in fields:\n    print(\"Error: The DepositPreauth entry still has a Sponsor field\")\n    sys.exit(1)\n\nprint(\"Sponsorship ended successfully!\")\nprint(\"The sponsee now pays the DepositPreauth entry's owner reserve again.\")\nprint(f\"Transaction URL: https://devnet.xrpl.org/transactions/{end_response.result['hash']}\")\n"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"warning","name":"Warning"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Ending a ledger entry's sponsorship doesn't check whether the sponsee can cover the reserve it takes back. The sponsee can end up below its required reserve, which blocks it from creating new ledger entries until it funds the difference."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If the sponsored ledger entry is deleted instead, you don't need to end the sponsorship first. Deleting the entry releases the reserve obligation, which means the sponsor's ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SponsoringOwnerCount"]}," decreases and the reserve frees up."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"targeting-an-account-instead-of-a-ledger-entry","__idx":12},"children":["Targeting an Account Instead of a Ledger Entry"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Each step above passes an ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ObjectID"]}," to identify the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["DepositPreauth"]}," entry. To create, reassign, or end the sponsorship on an account's own reserve, omit ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ObjectID"]}," entirely: the transaction then applies to the account in the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Account"]}," field. The following differences apply when the target is an account:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The sponsor's ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SponsorSignature"]}," is required when creating or reassigning, not optional."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The counters the transaction moves are ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SponsoringAccountCount"]}," rather than ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SponsoringOwnerCount"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SponsoredOwnerCount"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Ending the sponsorship checks that the account can hold its own account reserve afterwards. If it can't, the transaction fails with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tecINSUFFICIENT_RESERVE"]},"."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Only the entry types listed under ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/es-es/docs/references/protocol/ledger-data/common-fields#sponsor"},"children":["Sponsor"]}," in the ledger entry common fields support sponsorship. Targeting any other type fails with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tecNO_PERMISSION"]},"."]},{"$$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/manage-a-sponsorship-pool"},"children":["Manage a Sponsorship Pool"]}]}]}]},{"$$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/sponsorshiptransfer"},"children":["SponsorshipTransfer 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":"Transfer a Reserve Sponsorship","id":"transfer-a-reserve-sponsorship","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 an unsponsored ledger entry","id":"4-create-an-unsponsored-ledger-entry","depth":3},{"value":"5. Create the sponsorship","id":"5-create-the-sponsorship","depth":3},{"value":"6. Reassign the sponsorship","id":"6-reassign-the-sponsorship","depth":3},{"value":"7. End the sponsorship","id":"7-end-the-sponsorship","depth":3},{"value":"Targeting an Account Instead of a Ledger Entry","id":"targeting-an-account-instead-of-a-ledger-entry","depth":2},{"value":"See Also","id":"see-also","depth":2}],"frontmatter":{"seo":{"description":"Create, reassign, or end the reserve sponsorship on an existing ledger entry.","title":"Transfer a Reserve Sponsorship"},"labels":["Accounts","Fees","Sponsorship"],"status":"not_enabled"},"editPage":{"to":"https://github.com/XRPLF/xrpl-dev-portal/tree/master/docs/tutorials/best-practices/account-management/transfer-a-reserve-sponsorship.md"},"lastModified":"2026-08-26T10:28:02.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/es-es/docs/tutorials/best-practices/account-management/transfer-a-reserve-sponsorship","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}