Pay Off a Loan
This tutorial shows how to pay off a Loan on the XRP Ledger and delete it. You calculate the final payment due, which includes the loan balance and any additional fees, pay it, and then remove the loan from the ledger.
- Section
- Tutorials
What you need
You need a basic understanding of the XRP Ledger and a client library. The examples use JavaScript with xrpl.js, Python with xrpl-py and Go with xrpl-go. The tutorial requires the LendingProtocol amendment, which the source lists as open for voting, and the LendingProtocolV1_1 amendment updates it. The JavaScript code expects both amendments, the Python and Go code only LendingProtocol.
Working out the payment
You load the borrower account, the loan ID and the MPT issuance ID, then check the loan's current status with the ledger_entry method. The TotalValueOutstanding field holds the remaining principal plus accrued interest. The LoanServiceFee is an additional fee charged per payment. Add the two together to get the total payment. Other fees, such as late or early payment fees, must be accounted for too.
Paying the loan
You create a LoanPay transaction with the total payment amount, sign it and submit it. A tesSUCCESS result code shows that it succeeded. Then you look at the Loan entry in the transaction metadata. If TotalValueOutstanding is absent there, the loan has been fully paid off and is ready for deletion.
Deleting the loan
You create a LoanDelete transaction to remove the paid loan from the XRP Ledger. Either the loan broker or the borrower can submit it, and in the example the borrower does. After a tesSUCCESS result, you confirm the removal with the ledger_entry method. If it returns an entryNotFound error, the loan has been deleted.
Good to know
A loan can only be deleted after it is fully paid off, or if the loan broker has defaulted it. Once deleted, the loan is completely removed from the XRP Ledger.
Source: xrpl.org. Read 6 December 2026.
Zerpedia states what the source says, in plain words, and gives no opinion. How Zerpedia is made