Skip to Content

Gumball Demo (Mainnet)

This demo showcases how the Morpher Oracle can be used to bring real-world price data on-chain in a secure and verifiable way. This version connects to the Radix Mainnet.

How It Works

The Gumball Machine is a simple demonstration of using signed price data from the Morpher Oracle to execute a transaction on the Radix network. Here’s the flow:

  1. Price Data Retrieval: The frontend requests the current XRD/USD price from the Morpher Oracle API.
  2. Data Signing: The Oracle signs this price data with its private key.
  3. Transaction Creation: The frontend creates a transaction manifest that includes the signed price data.
  4. On-Chain Verification: The smart contract verifies the signature using the Oracle’s public key.
  5. Transaction Execution: If the signature is valid, the transaction executes and mints a Gumball token.

This pattern can be applied to any DApp that needs real-world data on-chain, such as:

  • DEXs that need accurate price feeds
  • Lending platforms that need collateral value information
  • Prediction markets that need outcome verification
  • Gaming applications that need external randomness

Live Demo

Try out the Gumball Machine demo below:

Gumball Oracle Demo (Mainnet)

This demo shows how the Morpher Oracle works by pulling signed price data from a backend and using it directly inside a transaction manifest.

Current Price:1 USD = 1 Gumball

Connect your wallet to purchase a gumball

Gumball Machine

Technical Details

The Oracle uses BLS signatures to sign price data. These signatures are compact and can be efficiently verified on-chain.

When you click “Buy a Gumball,” the following happens:

  1. The frontend calls the Oracle API to get the current XRD/USD price with a signature
  2. The frontend constructs a transaction manifest that includes:
    • The signed price data
    • Instructions to call the Oracle component to verify the signature
    • Instructions to call the Gumball component to mint a token based on the verified price

Implementation Example

Here’s a simplified version of the transaction manifest that gets generated:

// This is a simplified example of the transaction manifest // Withdraw XRD to pay for the gumball CALL_METHOD Address("account_rdx_2_...") // Your account "withdraw" Address("resource_rdx_2_1tkn...") // XRD resource address Decimal("1.5"); // Amount based on current price // Call the gumball component with the signed price data // The gumball component will internally call the Oracle component to verify the data CALL_METHOD Address("component_rdx_2_1cr0...") // Gumball component "buy_gumball" Bucket("xrd_payment") "XRD/USD|0.05|..." // Signed price data string "0xf8d2..." // Signature

Integration Guide

To integrate the Morpher Oracle into your own DApp, see our Integration Guide.