Skip to main content

Quick Start

This guide will help you get started with Molpha, whether you want to create a data feed, consume feed data, or operate a verifier node.

Creating Your First Feed

Prerequisites

  • A Solana wallet with USDC for fees
  • An API endpoint you want to turn into a feed
  • Basic understanding of JSONPath selectors (optional)

Step 1: Connect Your Wallet

Visit the Molpha Dashboard and connect your Solana wallet.

Step 2: Create a Feed

  1. Click “Create Feed” in the dashboard
  2. Enter your feed details:
    • Feed ID: A unique identifier (e.g., btc-usd)
    • API Endpoint: The URL of your data source
    • JSONPath Selector: How to extract the value (e.g., $.bitcoin.usd)
    • Update Frequency: How often to fetch (e.g., every 60 seconds)
  3. Choose your subscription duration (30-365 days)
  4. Pay the creation fee in USDC

Step 3: Wait for Verification

Verifier nodes will start fetching from your API and submitting signed results. Once a quorum is reached, your feed becomes active.

Consuming Feed Data

On Solana

use anchor_lang::prelude::*;
use molpha::state::Feed;

#[derive(Accounts)]
pub struct ReadPrice<'info> {
    pub molpha_feed: Account<'info, Feed>,
}

pub fn read_price(ctx: Context<ReadPrice>) -> Result<()> {
    let feed = &ctx.accounts.molpha_feed;
    let latest_answer = feed.latest_answer;
    let value = latest_answer.value;
    let timestamp = latest_answer.timestamp;
    
    msg!("Latest value: {:?}", value);
    msg!("Timestamp: {}", timestamp);
    Ok(())
}
See the Solana Integration Guide for details.

On EVM Chains

import {IFeed} from "@molpha/contracts/interfaces/IFeed.sol";

contract MyConsumer {
    IFeed public feed;
    
    function readLatestPrice() external view returns (uint256 price, uint256 timestamp) {
        (bytes memory data, uint256 ts) = feed.getLatest();
        
        assembly {
            price := mload(add(data, 32))
        }
        
        return (price, ts);
    }
}
See the EVM Integration Guide for details.

Next Steps