Package Logo
sm_bridge_indexer
sm_bridge_indexer@v0.2.0
Total Downloads
7
Published
3 weeks ago
Publisher
User Avatar dicksonoche

Readme

sm_bridge_indexer

A Substreams package that indexes Wormhole cross‑chain messages on Token Bridge and SPL‑Token mint/burn events on Solana, alongside block metadata. Designed as a reference implementation for real‑time bridge analytics and dashboards.

Initialized via substreams init on the sol‑minimal template, then scaled up for maximum complexity and usefulness.


Installation & Quick Start

# 1. Build your Substreams Wasm
substreams build
# 2. Authenticate (if you haven’t yet)
substreams auth
# 3. Launch the interactive GUI
substreams gui
# 4. (Optional) Publish to Substreams Registry
substreams registry login
substreams registry publish

Modules & Handlers

map_filter_wormhole

  • Kind: map
  • Input: solana:blocks_without_votes
  • Output: proto:wormhole.v1.Instructions

Descrription:

  • Iterates each transaction in every block
  • Filters by Wormhole program IDs:
    • worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth (Core)
    • wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb (Token Bridge)
  • Emits raw instruction data, account keys, and program IDs

map_decode_wormhole

  • Kind: map
  • Input: map_filter_wormhole
  • Output: proto:wormhole.v1.WormholeMessage

Description:

  • Scans the filtered instructions for the first PostMessage (instruction tag = 1) from the Core program
  • Parses:
    • Payload length (bytes 1–4)
    • Payload bytes
    • Sequence number (8 bytes immediately following the payload)
  • Emits a structured message with fields:
    • emitter (account that posted the message)
    • sequence (Verifiable Action Approval sequence)
    • payload (raw payload bytes)

map_spl_mint_burn

  • Kind: map
  • Input: solana:blocks_without_votes
  • Output: proto:spl.v1.MintOrBurnEvent

Description:

  • Filters instructions by the SPL Token program ID: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
  • Manually decodes MintTo (7) and Burn (8) instructions:
    • Reads the first byte of data to identify the instruction
    • Parses the next 8 bytes as a little‑endian u64 amount
    • Maps account indices to mint and owner fields
    • Emits { mint, owner, amount, is_mint }

map_my_data

  • Kind: map
  • Input: solana:blocks_without_votes
  • Output: proto:mydata.v1.MyData

Description:

  • Captures basic block metadata:
    • block_hash, block_slot, block_timestamp
    • transactions_len (number of txns)
    • instructions_len (total instructions)

Complexity of the Substreams

  • Starts from sol-minimal template but hand‑crafts three extra specialized modules.
  • Manual decoding of both Wormhole cross‑chain instructions and SPL Token events—far beyond auto‑generated scaffolding.

Usage & Consumption

  • CLI & GUI ready: substreams run or substreams gui.
  • Outputs Protobuf‑typed streams, ideal for SQL sinks, JSON APIs, dashboards.

Innovation of the Product/Concept

  • Real‑time bridge message indexing on Solana.
  • Merges off‑chain Veifiable Action Approvals(VAAs) semantics (sequence, payload) with on‑chain asset movements.

Clarity in Business Model

  • Data service: deliver live bridge analytics to DeFi platforms.
  • Compliance tool: audit Veifiable Action Approvals(VAAs) & large token movements.
  • SaaS dashboard: tiered API for historical & real‑time queries.

Real‑World Usefulness & Market Potential

  • Bridges underpin multi‑chain liquidity—monitoring them is mission‑critical.
  • Provides transparency & risk metrics for treasuries, AMMs, and cross‑chain protocols.

User Impact

  • Empowers developers to plug in a reference indexer.
  • Equips analysts/traders with actionable bridge‑flow insights.
  • Enhances user trust via transparent, real‑time bridge statistics integrated into Web3 apps.# sm_wormhole_bridgeidx

Documentation

Modules

Maps icon
Maps

map
map_bridge_messages

545e6080c7d930b0ef56fec4bb9a6551427a5d26
map map_bridge_messages (
solana:blocks_without_votessf.solana.type.v1.Block
)  -> wormhole_bridge.message.v1.WormholeMessages
substreams gui sm-bridge-indexer@v0.2.0 map_bridge_messages

map
map_token_transfers

d3dd85b90a9bfc3662cffc5033b7013173b25fa4
substreams gui sm-bridge-indexer@v0.2.0 map_token_transfers

map
map_nft_transfers

475061db5ca304c2ef2c0871935e55e5926a941f
substreams gui sm-bridge-indexer@v0.2.0 map_nft_transfers

map
solana:blocks_without_votes

0be93a73c65aa8ec2de4b1a47209edeea493ff29
map solana:blocks_without_votes (
)  -> sf.solana.type.v1.Block
substreams gui sm-bridge-indexer@v0.2.0 solana:blocks_without_votes

map
solana:v020:blocks_without_votes

0be93a73c65aa8ec2de4b1a47209edeea493ff29
map solana:v020:blocks_without_votes (
)  -> sf.solana.type.v1.Block

blocks_without_votes allows you to consume a full Solana Block without Vote instructions (Vote111111111111111111111111111111111111111). If you consume it on HISTORICAL data (+1000 blocks from HEAD), you will be reading from the StreamingFast cache, thus saving costs on the amount of TB read.

substreams gui sm-bridge-indexer@v0.2.0 solana:v020:blocks_without_votes
Block Indexes icon
Block Indexes

blockIndex
solana:program_ids_without_votes

811466d12743a8b02be8ba6649cfa9a24aa1af62
substreams gui sm-bridge-indexer@v0.2.0 solana:program_ids_without_votes
Protobuf

Protobuf Docs Explorer

wormhole_bridge.nft.v1
sol.transactions.v1
sf.solana.type.v1
sol.instructions.v1
wormhole_bridge.message.v1
wormhole_bridge.token.v1