Learn how to read onchain data from one blockchain to another using Hyperbridge GET requests!
In this tutorial, Roy from Polytope Labs shows how to:
✅ Turn a Solidity contract into a HyperApp
✅ Dispatch GET requests to read ERC20 balances on Ethereum Sepolia
✅ Receive and handle cross-chain responses securely
✅ Compute storage slots using the Hyperbridge SDK
✅ Test your contract on testnets with self-relaying
Hyperbridge enables trust-minimized cross-chain reads without bridges, oracles, or centralized intermediaries. Perfect for DeFi, gaming, governance, and multi-chain applications.
Tools Used:
- Solidity + Foundry
- Hyperbridge SDK
- OpenZeppelin Contracts
🔗 Resources & Links:
Notes from Roy, the Dev:
1. This tutorial videos show how easily you can determine the storage slot for the data you want, using the Hyperbridge sdk helper functions.
But in production, you may have to dynamically generate the target slot of your target contract on the destination chain, in your source contract. This is very common, for examples check how we determine the commitment slot in Intent Gateway contract.
2. You do not need to self relay on the mainnets we support. This video only demonstrates how you can self relay when you are in the testing phase of your contracts.
3. Treat the returned commitment as your request ID. Use the Message library's hash() utility on GetRequest to recompute the commitment from an incoming response and match it to your pending queries.
Timestamps / Chapters below so you can jump to the section you need.
0:00 - Introduction: What this tutorial covers
0:06 - Cross-chain GET request overview
0:30 - Project setup: Foundry + Node modules
1:05 - Installing dependencies (Hyperbridge core, Merkle tree, OpenZeppelin)
2:08 - Configuring Foundry to use node_modules
2:58 - Contract skeleton and coding start
3:04 - Turning a contract into a HyperApp
3:36 - Overriding host() function
4:10 - Constructor and host assignment
4:18 - Approving fee token for Hyperbridge
5:21 - Core functionality: GET requests
5:49 - Defining queryTokenBalance function
6:04 - Understanding commitment
6:39 - Constructing DispatchGet: destination, height, keys
9:08 - Setting timeout, fees, context
10:41 - Sending GET request through host
12:02 - Optional: Pay fees via native token
12:48 - Events for dispatch and response
13:57 - Storage mappings for pending commitments
15:07 - Returning commitment and marking pending
15:40 - Implementing onGetResponse
16:42 - Security checks and storage value decoding
19:48 - Marking request as complete
20:42 - Helper function to read stored values
20:47 - Recap: key steps for GET requests
22:03 - Constructing storage slot for ERC20 balance
24:23 - Using Hyperbridge SDK to get height and slot
25:59 - Running tests and using indexer
28:02 - Self-relay workflow on testnet
29:00 - Final tips and example repository
#Hyperbridge #Solidity #CrossChain #Web3 #Blockchain #Ethereum #SmartContracts #DeFi #NFTs