Surviving the API Apocalypse with AI: Waltio’s Odyssey on the XRP Ledger

Daniel Adam
Waltio Tech Team

--

Waltio encountered a significant hurdle when Ripple announced the discontinuation of support for crucial APIs, necessitating a complete overhaul of their transaction consolidation system for the XRP Ledger. To navigate this challenge, Waltio turned to artificial intelligence, specifically employing ChatGPT, to expedite the development process and achieve a thorough comprehension of the Ripple Epoch, which was crucial for precise timestamp interpretation. Furthermore, Waltio innovated an algorithm designed to scrutinize and merge transactions directly at the node level. This approach not only tackled technical difficulties but also enhanced the accuracy of the system through a series of iterative improvements guided by AI. The successful deployment of AI technologies not only rescued Waltio from potential irrelevance but also fortified the trust of their clients, ensuring the continuity of their services without disruption.

Brief

In the cryptocurrency universe, the XRP Ledger stands out as an innovative decentralized network, optimized for the speed and efficiency of transactions. However, behind its technological feats lie challenges for those who venture there.

A Drama Unfolds

In September 2023, Ripple announced the discontinuation of support for its essential APIs for accessing XRP blockchain data, pushing its users towards other alternatives. For Waltio and its users, it was a heavy blow. Meticulous integrations of the past became obsolete overnight, plunging our users into darkness, unable to retrieve their transaction history for tax declarations.

State of Affairs

This situation reveals a central dilemma in the use of third-party technologies: dependency. Previously, we benefited from “ready-to-use” data consolidation, saving precious time and development resources. Although convenient, this advantage highlighted our vulnerability to sudden changes in service providers.

Faced with this new reality, we were before a significant challenge: to rebuild our transaction consolidation system from scratch. The complexity of the task was heightened by the need to not only restructure operations but also to incorporate a comprehensive understanding of the business. This included grasping the concept of the Ripple Epoch, which is crucial for the accurate interpretation of transaction timestamps.

This is where artificial intelligence comes into play. Thanks to ChatGPT, equipped with exhaustive knowledge of the XRP Ledger documentation, we were able to accelerate our development as if we had a senior XRP Ledger developer by our side.

Ripple Epoch

A fundamental aspect of our work with the XRP Ledger was managing timestamps. Initially, we faced timestamps that, at first glance, seemed incorrect or inconsistent. This confusion was the starting point of a significant discovery thanks to our collaboration with AI.

Discovering the Ripple Epoch

A striking example of our collaboration with AI was the discovery of the Ripple Epoch. Handling timestamps that seemed erroneous, AI quickly directed us towards the solution: adjusting our system to account for the Ripple Epoch to obtain consistent dates.

The XRP Ledger uses its own time reference, known as “Ripple Epoch,” which counts the number of seconds elapsed since January 1, 2000, at 00:00 UTC. This method is similar to the Unix Epoch system, which begins on January 1, 1970, but with a key difference: the Ripple Epoch starts 946684800 seconds after the Unix Epoch.

Handling Timestamps: A Practical Example

To illustrate how this discovery was applied, consider the process of converting Ripple Epoch timestamps into a readable date format. Here’s how we proceeded:

function rippleEpochToUTC(rippleTimestamp) {
const rippleEpochStart = 946684800;
// Start of the Ripple Epoch in Unix seconds
const unixTimestamp = rippleTimestamp + rippleEpochStart;
// Conversion to Unix Epoch
const date = new Date(unixTimestamp * 1000);
// Conversion to milliseconds for JavaScript
return date.toUTCString();
// Formatting into a readable UTC date
}

const exampleTimestamp = 630720000;
// Example of a Ripple Epoch timestamp
console.log(rippleEpochToUTC(exampleTimestamp));
// Converts and displays the corresponding UTC date

This script illustrates how to adjust our systems to correctly interpret the timestamps of the XRP Ledger, transforming initially perplexing values into actionable and consistent information.

Caution with 32-Bit Variables

A crucial piece of advice when handling these timestamps is to ensure not to convert them to Unix Epoch in 32-bit variables, to avoid the risks of integer overflows. The use of adequately sized variables is recommended to properly manage these temporal values.

To Node or Not to Node: Technical Dive into the XRP Ledger

When Ripple’s API became obsolete, we faced the necessity to rebuild our transaction consolidation mechanism for the XRP Ledger. This meant moving from a simplified interface to direct interaction with the network nodes, a task both daunting and demanding.

Node-Level Analysis

In the XRP Ledger, each transaction can affect multiple “nodes” in the ledger, each representing a different aspect of the network’s state (such as account balances, trust relationships, or exchange offers). Understanding these modifications at the node level is crucial for accurately tracking fund movements and trades.

Example Code for Transaction Analysis

function getCurrencyBalanceDelta(dataset, currencyAddress, address) {
const affectedNodes = dataset.meta.AffectedNodes;
var delta = 0;
var assetDelta = {};

// Handle currencies other than XRP
if (currencyAddress != 'XRP') {
// Filter to find affected RippleState entries
let rippleStateEntries = affectedNodes.filter((node) => {
// Logic to identify relevant RippleState entries
return /* condition */;
});

// Calculate the balance delta for RippleState entries
if (rippleStateEntries.length > 0) {
// Logic to calculate the delta based on found entries
assetDelta[currencyAddress] = /* Delta calculation */;
}
} else {
// Specific handling for XRP
// Similar logic to filter and calculate the delta for XRP
}

return assetDelta;
}

This getCurrencyBalanceDelta function illustrates our approach to calculate the balance difference (delta) of a specific currency for a given address, by analyzing the nodes affected by a transaction. It distinguishes cases where the currency is XRP itself and where it involves other currencies managed via RippleState entries.

Technical Challenges and Solutions

  • Diversity of Nodes: Each node type (such as AccountRoot, RippleState) requires specific logic to interpret the changes. This implies a deep understanding of the structure and rules of the XRP Ledger.
  • Accuracy of Calculations: Balance delta calculations must be extremely precise, especially in the context of non-XRP currencies, where values can be affected by fluctuating exchange rates and trust relationships between addresses.
  • Interpreting Trade Transactions: Trades often involve complex changes in the balances of participants, requiring careful analysis of the affected nodes to reconstruct the exchanged amounts and concerned currencies.

Iterative Interpretation and Algorithm Improvement

Accessing and interpreting raw data at the XRP Ledger node level can be particularly challenging, especially without the mediation of an API consolidating this information intuitively. Faced with this complexity, building our algorithm to analyze and consolidate transactions relied on a unique iterative and collaborative approach with AI.

The Improvement Loop with ChatGPT

For each transaction to analyze, we proceeded in successive steps, starting by extracting the raw data and presenting it to ChatGPT for interpretation. This initial analysis allowed us to understand the implications of each node affected by the transaction and to identify recurring patterns and exceptions.

Applying the Algorithm to a Concrete Case

By applying this algorithm to the described transaction, where rsVMacM5CmJNSm7ybtsTH2fj8KvexkNskS offered to exchange 500 VGB for 418.698742 XRP, we were able to identify and calculate balance adjustments in RippleState nodes and modifications to market offers. This analysis revealed significant balance changes for the involved accounts and demonstrated the effectiveness of our algorithm in interpreting these complex transactions.

https://livenet.xrpl.org/transactions/28BB13205744A4E97C46CDFE969FADD6A55E4863E88A5C0C5A3594AB60FF1F77/raw

Armed with this information, we refined our algorithm, adjusting our processing logic to better capture and reflect the reality of transactions as recorded on the ledger. This iterative method played a crucial role in our ability to decrypt critical information often hidden in the technical details of node data.

Advantages of the Iterative Approach

This strategy offered several significant benefits:

  • Increased Accuracy: Each iteration cycle allowed us to refine our understanding of XRP Ledger transactions, progressively reducing gaps and inaccuracies in our algorithm.
  • Adaptability: The continuous learning process with AI enabled the development of an adaptable solution capable of handling the specific complexity of the XRP Ledger.
  • Efficiency in Development: This collaborative approach accelerated development, enabling a rapid response to user needs.

By navigating through the intricacies of node-level data, we were able to reconstruct a complete and accurate view of our users’ transactions. Although complex, this process strengthened our ability to provide reliable and precise services, even in the face of unexpected changes in the technological ecosystem.

The successful integration of this approach not only saved Waltio from obscurity but also strengthened our clients’ trust, ensuring uninterrupted and accurate service.

Conclusion

This episode perfectly illustrates how AI can support and accelerate development teams, going far beyond simple code generation. By quickly integrating project-specific business knowledge, it enables overcoming technical obstacles with unmatched efficiency. For a startup, this ability to adapt and innovate quickly is not just valuable; it’s crucial.

--

--

Daniel Adam
Waltio Tech Team

I'm Software Engineer, with both experiences in software development and DeFi algorithmic trading, I'm in charge of blockchain and platform integrations.