Skip to content

ddboy19912/crosschain-balance-aggregator

Repository files navigation

🌉 Cross-Chain Balance Aggregator

Query ERC20 and Substrate token balances directly from on-chain storage — no smart contract deployment needed. This app uses Hyperbridge storage queries, providing fast and verifiable balance lookups across multiple networks.

🚀 Features

  • 🔗 Query ERC20 balances across Ethereum, Polygon, and Arbitrum
  • ⚡ Direct storage-level reads (no RPC eth_call or contracts)
  • 🧩 Substrate (AssetHub/Hyperbridge) address querying
  • 🧮 Powered by Hyperbridge SDK

🛠️ Installation

pnpm install
pnpm install @hyperbridge/sdk viem @polkadot/util-crypto scale-ts

⚙️ Environment Setup

Create a .env.local file in the root of the project:

VITE_APP_POLYGON_RPC_URL=
VITE_APP_ETHEREUM_RPC_URL=
VITE_APP_ARBITRUM_RPC_URL=

You can use Alchemy, Infura, or any RPC that supports debug_traceCall.

🧩 Project Structure

src/
├── services/
│   └── balance-query.ts       # Balance fetch via Hyperbridge Storage queries
├── config/
│   └── chain.ts      # Supported EVM chains
│   └── constants.ts      # Constants
│   └── tokens.ts      # All supported tokens
├── utils/
│   └── substrateStorage.ts   # Substrate storage queries
└── App.tsx                   # UI + integration

🧠 How It Works

🔹 EVM Chains

  • Uses Hyperbridge SDK to calculate the ERC20 balanceOf storage slot
  • Reads the slot directly via eth_getStorageAt
  • Decodes the balance using token decimals

🔹 Substrate Chains

  • Derives storage keys for System.Account and Assets.Account
  • Queries balances via state_getStorage
  • Decodes SCALE-encoded values using scale-ts

🧰 Scripts

npm run dev      # Start development server
npm run build    # Build production app
npm run lint     # Check code quality

About

Query ERC20 and Substrate token balances directly from on-chain storage — no smart contract deployment needed. This app uses Hyperbridge storage queries, providing fast and verifiable balance lookups across multiple networks.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors