/intents-sports-ball

An example dApp built with Phat Functions to fulfill Sporty's intent

Primary LanguageSolidityMIT LicenseMIT

Intents Sports Ball Workshop

Sporty losing it all

Table of Contents

Background

Intents Sports Ball is a Sportsbook for betting on outcomes for sporting events like baseball, football, basketball, etc. However, the origins start with our creator named Sporty. Sporty can be seen above in the GIF dating back to 2012 where he lost everything betting his life savings on his team to win the sports game. In Sporty's words, "Daniels, why'd you throw it away Daniels! Daniels had a second leg to knee and he didn't even throw it in." This troubling event led to Sporty realizing he could make good with the Sharks if he could regain his losses by opening his own sportsbook.

Sporty had recently been reading about Intents where a phrase stuck out, "A transaction specifies the journey, while an intent specifies the destination." A light shined from the clouds and Sporty knew that all he needed to do was slap the word "Intents" on the product with the meta-intent being that all winnings go to Sporty's wallet as the destination. Sporty had perfected intents in his mind, and he left breadcrumbs of how he built the multi-trillion dollar dApp that made him the richest degen on plant Earth.

What Are Intents?

"An intent is a signed set of declarative constraints which allow a user to outsource transaction creation to a third party without relinquishing full control to the transacting party." - source

Intents Sports Ball is not a guide on how to build intents into your dApp, and all information around intents-based architecture in blockchain can be found in Banana SDK's awesome-intents repo.

Goals

Goals will be to teach developers different ways to build a cross-chain dApp with Phala Network's Phat Functions.

Goals include the following:

  • Implement Nestable NFTs for a User Profile NFT with nested NFTs of a user's bets using RMRK Nestable NFTs (ERC-6059).
  • Update a Telegram Group of latest info about sports game scores.
  • Query multiple API Endpoints to get sportsbook odds and latest results of the games bet on.
  • Connect to off-chain storage to publish a user bet's metadata.
  • Connect to an EVM Chain consumer contract and start making requests to the deployed Phat Function on Phala.

What Are Phat Functions?

For simplicity, Phat Functions enable you to request any API and send the data to your on-chain smart contract with Javascript/Typescript.

Phat Functions extend the functionalities of smart contracts, enabling them to read and control any existing services/data.

This means:

  1. a smart contract can learn about and control smart contracts on other blockchains, even without bridges, making cross-chain easy.
  2. a smart contract can read and control offchain data, like Web2 services, real world assets (RWA), and more.

This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a script that deploys that contract.

Try running some of the following tasks:

npx hardhat help
npx hardhat test
REPORT_GAS=true npx hardhat test
npx hardhat node
npx hardhat run scripts/deploy.ts