Introducing Snorkel: Trustless Access to Cross-Chain States with t3rn
In the relentless pursuit of blockchain advancement, we constantly explore innovations that build bridges across different ecosystems. Today, we're excited to introduce Snorkel, a proof-of-concept interoperable application that demonstrates the potential of trustless cross-chain state access. Snorkel is underpinned by a suite of straightforward solidity smart contracts between the Eth2 testnet Sepolia and t3rn's contract registry, leveraging the power of the Eth2 Light Client.
Laying the Groundwork: An Insight into Snorkel
Snorkel operates by wrapping around the Uniswap smart contract interface, invoking the "getReserves()" function for any token pair and broadcasting the result as an event. This allows the main Snorkel component to decode and analyze the asset reserves via the Solidity Portal Precompile's access to the Eth2 Light Client.
The application employs the Portal Precompile Interface to retrieve the "PriceUpdate" event. This interface enables the contract to engage with the Light Client, providing specific methods to access various data.
On t3rn, we can deploy a corresponding contract that validates the inclusion of the event emitted in the preceding contract and decodes the parameters within the t3rn EVM. This mechanism, known as Portal access, empowers anyone to securely and trustlessly access cross-chain state. It should be noted that this mechanism relies on light clients and pure cryptography. While our example focuses on price data, this methodology can be extended to other forms of data, keeping in mind that it relies on integration with all light clients on t3rn.
A Deeper Dive into the Portal Precompile Interface
The PortalPrecompileInterface helps us construct our call to the Portal, streamlining the development process by abstracting internal encodings. To retrieve the latest height from any light client, we use the GetLatestFinalizedHeader method, with parameters encoded using a Solidity SDK function.
To access the Eth2 Light Client's latest height, the contract encodes the call to the portal using the sequence: [2, 9, 9, 9, 9]. Here, '2' acts as the selector for the "get latest height" method, and the four '9' bytes signify the ID of the Eth2 gateway registered with t3rn. As highlighted in our prior newsletter, the t3rn ABI Recoder translates these bytes into a corresponding operation connected with the Gateway Light Client. For those seeking a deeper understanding, the Solidity Interface used to interact with the Portal is available.
Unlocking New Possibilities: Snorkel in Action
Importantly, Snorkel eliminates the need for off-chain price oracle components, as all data derives from DEX prices. While our demonstration leverages Uniswap, the same interface can access asset prices from other Eth2 DEXs such as Sushi. This functionality can be enhanced by weighting prices based on volume or sourcing events from other Light Clients integrated with t3rn using the same Portal Interface.
Forwarding Interoperability: The Promise of Snorkel
The unveiling of Snorkel paints an optimistic picture of the future of cross-chain interoperability. It exhibits how Eth2 Light Clients can be harnessed to provide secure, trustless access to cross-chain state, significantly advancing the blockchain technology space. While Snorkel is a proof-of-concept, it undoubtedly embodies a groundbreaking development in our continuous quest for interoperability. Stay connected as we dive deeper into this extraordinary journey.
The future of Web3 is multichain. t3rn has been built to enable this new paradigm in multichain programming, which is trustless, fail-safe and interoperable. We believe in trust-free collaboration, therefore the network will offer open access for anyone to join and play a critical role as Collator, Executor, Attester or Contracts Registry Builder.Team t3rn will take a phased approach to rolling out the protocol, gradually releasing different features, showcasing and battle testing the network within a Substrate-based environment first before integrating with some of the foremost ecosystems in the industry.
t3rn is a multichain protocol that brings fail-safe, interoperable execution and smart contract composability to the Polkadot ecosystem and beyond.t3rn’s ultimate goal is to enable trust-free collaboration between blockchains and to create an ecosystem in which anyone can utilize and deploy an interoperable smart contract, in an ecosystem where developers are fairly rewarded for their contributions.
Turn multichain with t3rn.
👉 Subscribe to our newsletter: Join 15,000 subscribers for exclusive monthly updates and insights, directly from Maciej Baj, founder & CTO of t3rn. - no spam, unsubscribe anytime.