RealStock

RealStock brings real stocks on-chain with tokens directly backed by off-chain stock purchases.

RealStock

Created At

ETHGlobal New Delhi

Project Description

RealStock bridges traditional finance and DeFi by issuing ERC-20 tokens that are directly backed by real stocks rather than synthetic price feeds. Users deposit USDT, choose a supported stock (AAPL, AMZN, MSFT, S&P 500), and Redstone’s oracle secures the price. When a buy request is made, Gelato Web3 functions trigger the Alpaca API to purchase the stock off-chain, then mint a matching on-chain token. Selling burns the token and releases USDT. This design delivers verifiable ownership, transparency, and true real-world asset exposure on Rootstock Testnet.

How it's Made

RealStock is a full-stack decentralized application combining Solidity smart contracts, off-chain automation, and a modern web frontend.

Smart Contracts (Foundry + Solidity)

  • Core contracts handle USDT deposits, ERC-20 minting/burning, and use OpenZeppelin v4.9.5 libraries for security and upgradeability.
  • Integrated Pyth price feed to wrap each buy/sell transaction with trusted oracle data.
  • Includes a Pausable feature so trading can be enabled or disabled depending on market hours.

Automation & Off-Chain Execution

  • Gelato Web3 Functions listen for BuyRequest and SellRequest events and call the Alpaca API to execute real stock trades on traditional exchanges.
  • After a trade is confirmed, Gelato calls mintRStock or burnRStock to reflect ownership on-chain.
  • Added a dedicated Market Function in Gelato that checks market status and calls the contract’s pause or unpause functions.
  • This ensures the contract only allows trading when markets are open and automatically restricts it when closed.

Frontend & Deployment

  • Frontend built with Next.js/TypeScript and wagmi/ethers.js for wallet connections.
  • Deployed on Ethereum Sepolia using mock USDT for testing.

Notable Hacks & Integrations

  • Coordinating asynchronous off-chain stock purchases with on-chain state was challenging; event-driven Gelato jobs keep everything atomic from the user’s perspective.
  • Mock USDT and test stocks allow a realistic trading flow without real capital.

This setup guarantees that each on-chain token is verifiably backed by a real stock trade, while the Market Function keeps trading aligned with live market hours.

background image mobile

Join the mailing list

Get the latest news and updates