Skip to content

RedStone Oracles Enabling DeFi on TON Blockchain 

  • by

A leading oracle provider, is now integrated with TON to enhance the blockchain’s capabilities, particularly in DeFi. Let’s explore this case study.

What is TON?

The Open Network (TON) is a decentralized internet platform comprising key components, including TON Blockchain, TON DNS, TON Storage, and TON Sites. TON Blockchain serves as the central protocol, unifying the TON Ecosystem’s infrastructure. TON’s primary focus lies in fostering widespread cross-chain interoperability within a highly scalable and secure framework. With the capacity to handle millions of transactions per second (TPS), TON aims to accommodate hundreds of millions of users in the future. TON Blockchain acts as a distributed supercomputer, often referred to as a “superserver,” with the mission of offering diverse products and services to support the realization of a decentralized vision for the new internet.

TON x RedStone Integration

Explore our showroom, the app and the GitHub repository for more insights.

TON represents a fundamentally distinct network compared to others, characterized by its asynchronous and fully decentralized nature. Consequently, adapting the common RedStone approaches, both core and classic, required a shift in mindset to align with our integration goals. Achieving integration on TON demanded a departure from the straightforward contract-to-contract reading found in other blockchains. Instead, TON contracts necessitate the transmission of messages, the core communication mechanism, followed by the patient anticipation of an asynchronous response. This response may traverse a complex transaction route involving numerous other contracts, none of which can engage in synchronous communication. It is essential to bear in mind crucial aspects such as the sender’s identity, message structure, and the validity of responses to contract-initiated requests.

Integration Challenges

The data structures within the FunC language, specifically introduced for TON contract development, diverge significantly from commonly used languages like Solidity or Rust. These structures are notably low-level and come with inherent limitations. To build complex data structures such as lists, developers use basic elements like tuples, large integers (up to 257 bits), and ‘cells’—a unique but complex component in TON’s programming. Notably, a cell’s value must remain below 1023(!) bits, with up to 4 cell-leaves allowed. This imposes constant consideration of these constraints while performing computations, processing data, or sending messages. On the flip side, constructing a cell and subsequently reading from it carries a substantial computational cost for each instance. Hence, developers must strive to efficiently pack as much data as possible into a single cell, ensuring careful parsing to prevent overflows.

To overcome the unique challenges posed by TON, we undertook the task of restructuring our RedStone Payload data, which is transmitted to contracts. While we typically send it “as is” as a flat byte-array-like structure for other blockchains, TON demanded a different approach. We had to transform it into a tree-like structure composed of smaller nodes and leaves to accommodate TON’s limitations. For a detailed insight into how we achieved this, you can refer to our documentation: TON RedStone Payload Packing.

In TON, contracts bear the cost not only for the size of the stored data structures but also for the duration they remain stored. This may seem unusual, especially when transactions are required to cover storage expenses incurred by someone else at a previous time. Additionally, contracts must account for computation costs, even in cases where those computations are rejected, as well as any subsequent actions resulting from those computations. Consequently, TON contracts must either maintain their own funds or ensure that the initial transaction predicts and covers all future expenses incurred throughout the entire process.

What’s next?

Looking ahead, RedStone plans to develop a robust relayer system for consistent price updates, roll out smart contract templates for easy integration, and expand data feeds to match the growing needs of TON’s DeFi sector. We are developing automatic relayers to publish prices, monitoring their activity for uninterrupted service. Smart contract templates using TON Connect will empower developers, while consumer examples showcase the use of RedStone’s numeric values. We’ll also evaluate the needs of protocols and deploy production infrastructure for in-demand asset prices. To maintain reliability, we’ll implement robust monitoring services. RedStone is committed to driving the growth of DeFi on TON, offering essential tools and expanding the ecosystem with valuable data feeds. Stay tuned for updates as we progress.

About RedStone

RedStone is revolutionizing the Oracles industry by implementing a novel modular design and 3 tailor-made data consumption models. You can build the new generation of DeFi & Web3 protocols based on RedStone’s versatile data offering of long-tail, Lp, and Ecosystem-native tokens, as well as Real World Data and custom feeds.

Join RedStone’s community: Twitter | Discord | Telegram