Skip to main content

Feed Creation

Anyone can create a data feed on Molpha by connecting an API endpoint to the protocol. This guide walks you through the process.

Prerequisites

Before creating a feed, you’ll need:
  • API Endpoint — A publicly accessible API or protected API with credentials
  • JSONPath Selector — Knowledge of how to extract the value from the API response
  • Solana Wallet — With USDC for creation fees
  • Feed Configuration — Decide on update frequency and subscription duration

Creating a Feed

Step 1: Prepare Your API

Your API should return data in a consistent format. For example:
{
  "bitcoin": {
    "usd": 45000.50
  },
  "ethereum": {
    "usd": 2800.75
  }
}

Step 2: Define Your Feed Specification

A feed specification includes:
FieldDescriptionExample
feedIdUnique identifierbtc-usd
sourceAPI endpoint URLhttps://api.example.com/v1/price
selectorJSONPath to extract value$.bitcoin.usd
transformOptional transformationx => parseFloat(x).toFixed(2)
precisionDecimal places2
frequencyUpdate interval (seconds)60

Step 3: Submit via Dashboard

  1. Visit the Molpha Dashboard
  2. Click “Create Feed”
  3. Fill in your feed specification
  4. Choose subscription duration (30-365 days)
  5. Pay creation fee in USDC

Step 4: Verification

After submission:
  1. Verifier nodes start fetching from your API
  2. Nodes validate and sign results
  3. Once quorum is reached, feed becomes active
  4. Updates are published according to your specified frequency

Feed Types

Public API Feeds

Feeds using publicly accessible APIs require no special credentials:
  • Example: CoinGecko, public weather APIs
  • Setup: Just provide the API URL
  • Cost: Creation fee + subscription only

Protected API Feeds

Feeds requiring API keys use HashiCorp Vault:
  1. Register API key in Vault (via dashboard)
  2. Key is encrypted and stored securely
  3. Verifier nodes fetch credentials automatically
  4. Keys never touch the blockchain

Feed Management

Updating Feed Configuration

You can update:
  • Update frequency
  • API endpoint (requires re-verification)
  • Selector/transform logic
  • Subscription extension

Monitoring Feed Status

Dashboard shows:
  • Last update timestamp
  • Current value
  • Number of active verifiers
  • Uptime percentage
  • Recent updates history

Feed Lifecycle

  1. Draft — Created but not yet active
  2. Active — Receiving updates from verifiers
  3. Paused — Temporarily stopped (e.g., expired API key)
  4. Archived — Subscription expired, no longer updating

Best Practices

API Design

  • Stable endpoints — Use consistent API URLs
  • Clear structure — JSON responses with predictable schema
  • Rate limits — Ensure API can handle update frequency
  • Error handling — API should return clear error codes

Selector Design

  • Specific paths — Avoid ambiguous selectors
  • Consistent format — Value type should be consistent
  • Fallback values — Consider API failures

Security

  • Use HTTPS — Only use encrypted API endpoints
  • Rotate keys — Regularly update API credentials
  • Monitor usage — Check API usage in dashboard
  • Backup plans — Consider multiple API sources

Examples

Crypto Price Feed

{
  "feedId": "btc-usd",
  "source": "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd",
  "selector": "$.bitcoin.usd",
  "transform": "x => parseFloat(x).toFixed(2)",
  "precision": 2,
  "frequency": 60
}

Real-World Asset Feed

{
  "feedId": "nyc-housing-index",
  "source": "https://api.realestate.com/v1/nyc/index",
  "selector": "$.index.value",
  "transform": "x => Math.round(parseFloat(x))",
  "precision": 0,
  "frequency": 3600
}

Weather Feed

{
  "feedId": "nyc-temperature",
  "source": "https://api.weather.com/v1/current?city=nyc",
  "selector": "$.temperature",
  "transform": "x => Math.round(parseFloat(x))",
  "precision": 0,
  "frequency": 300
}

Troubleshooting

Feed Not Updating

  • Check API endpoint is accessible
  • Verify JSONPath selector is correct
  • Ensure API key is valid (for protected APIs)
  • Check feed status in dashboard

Incorrect Values

  • Verify selector extracts correct value
  • Check transformation logic
  • Review API response format
  • Submit a dispute if needed

High Costs

  • Reduce update frequency
  • Use public APIs when possible
  • Choose shorter subscription periods
  • Consider batch updates for multiple feeds

Next Steps