Skip to content

Instantly share code, notes, and snippets.

@dabit3
Last active May 27, 2025 12:37
Show Gist options
  • Save dabit3/8e1846427e29e77d943b6cbf1bf6a493 to your computer and use it in GitHub Desktop.
Save dabit3/8e1846427e29e77d943b6cbf1bf6a493 to your computer and use it in GitHub Desktop.
Prompting a WAVS price oracle AVS for a sports score oracle AVS - https://docs.wavs.xyz/overview

I want to create a similar oracle to the ETH Price Oracle at components/eth-price-oracle, but I want it to use the SportRadar API.

I want to set and reference the SportRadar API key from the Makefile, I do not want to use an .env file..

The request parameters for calling the SportRadar API look like this:

curl --request GET \
     --url 'https://api.sportradar.com/ncaamb/trial/v8/en/games/fa15684d-0966-46e7-a3f8-f1d378692109/boxscore.json?api_key={insert-api-key} \
     --header 'accept: application/json'

I want the make scores-exec command to look like this:

scores-exec:
	@$(WAVS_CMD) exec --log-level=info --data /data/.docker --home /data \
	--component "/data/compiled/sports_scores_oracle.wasm" \
	--input "0x$(shell printf '%s' "$(GAME_ID)|$(SPORTRADAR_API_KEY)" | hexdump -v -e '/1 "%02x"')"

So that I can call this command, only passing in the BASKETBALL_GAME_ID parameter (the SportRadar API Key should be read from the Makefile).

make scores-exec BASKETBALL_GAME_ID="fa15684d-0966-46e7-a3f8-f1d378692109"

And the code should properly convert the BASKETBALL_GAME_ID parameter to hex-encoded bytes.

The response data is structured like this, though all I want to get back is the home_team, away_team, home_score, away_score, and status values:

{
  "id": "fa15684d-0966-46e7-a3f8-f1d378692109",
  "title": "CBC - Semifinals - Game 1",
  "status": "closed",
  "coverage": "full",
  "neutral_site": true,
  "scheduled": "2025-04-05T17:30:00+00:00",
  "conference_game": false,
  "attendance": 2972,
  "lead_changes": 1,
  "times_tied": 3,
  "clock": "00:00",
  "half": 2,
  "track_on_court": true,
  "entry_mode": "LDE",
  "clock_decimal": "00:00",
  "broadcasts": [
    {
      "type": "TV",
      "locale": "National",
      "network": "FOX"
    }
  ],
  "time_zones": {
    "venue": "US/Pacific",
    "home": "US/Mountain",
    "away": "US/Central"
  },
  "season": {
    "id": "b2e4c0e0-5571-47c3-ab8b-1db65d74234e",
    "year": 2024,
    "type": "PST",
    "name": "Post-season Tournaments"
  },
  "home": {
    "name": "Broncos",
    "alias": "BSU",
    "market": "Boise State",
    "id": "c1c54dbf-805c-47fc-a707-c803e94db2a4",
    "points": 69,
    "rank": 0,
    "remaining_timeouts": 2,
    "scoring": [
      {
        "type": "half",
        "number": 1,
        "sequence": 1,
        "points": 33
      },
      {
        "type": "half",
        "number": 2,
        "sequence": 2,
        "points": 36
      }
    ],
    "leaders": {
      "points": [
        {
          "full_name": "Tyson Degenhart",
          "jersey_number": "2",
          "id": "53e5c39b-f43d-4d01-af64-4d1d56136391",
          "position": "F",
          "primary_position": "NA",
          "statistics": {
            "minutes": "35:00",
            "field_goals_made": 9,
            "field_goals_att": 17,
            "field_goals_pct": 52.9,
            "three_points_made": 4,
            "three_points_att": 9,
            "three_points_pct": 44.4,
            "two_points_made": 5,
            "two_points_att": 8,
            "two_points_pct": 62.5,
            "blocked_att": 2,
            "free_throws_made": 4,
            "free_throws_att": 5,
            "free_throws_pct": 80,
            "offensive_rebounds": 0,
            "defensive_rebounds": 8,
            "rebounds": 8,
            "assists": 2,
            "turnovers": 0,
            "steals": 2,
            "blocks": 0,
            "assists_turnover_ratio": 0,
            "personal_fouls": 2,
            "tech_fouls": 0,
            "flagrant_fouls": 0,
            "pls_min": -3,
            "points": 26,
            "double_double": false,
            "triple_double": false,
            "effective_fg_pct": 64.7,
            "efficiency": 29,
            "efficiency_game_score": 22.3,
            "fouls_drawn": 4,
            "offensive_fouls": 0,
            "points_in_paint": 8,
            "points_in_paint_att": 6,
            "points_in_paint_made": 4,
            "points_in_paint_pct": 66.7,
            "points_off_turnovers": 5,
            "true_shooting_att": 19.2,
            "true_shooting_pct": 67.7,
            "coach_ejections": 0,
            "coach_tech_fouls": 0,
            "second_chance_pts": 2,
            "second_chance_pct": 0
          }
        }
      ],
      "rebounds": [
        {
          "full_name": "Tyson Degenhart",
          "jersey_number": "2",
          "id": "53e5c39b-f43d-4d01-af64-4d1d56136391",
          "position": "F",
          "primary_position": "NA",
          "statistics": {
            "minutes": "35:00",
            "field_goals_made": 9,
            "field_goals_att": 17,
            "field_goals_pct": 52.9,
            "three_points_made": 4,
            "three_points_att": 9,
            "three_points_pct": 44.4,
            "two_points_made": 5,
            "two_points_att": 8,
            "two_points_pct": 62.5,
            "blocked_att": 2,
            "free_throws_made": 4,
            "free_throws_att": 5,
            "free_throws_pct": 80,
            "offensive_rebounds": 0,
            "defensive_rebounds": 8,
            "rebounds": 8,
            "assists": 2,
            "turnovers": 0,
            "steals": 2,
            "blocks": 0,
            "assists_turnover_ratio": 0,
            "personal_fouls": 2,
            "tech_fouls": 0,
            "flagrant_fouls": 0,
            "pls_min": -3,
            "points": 26,
            "double_double": false,
            "triple_double": false,
            "effective_fg_pct": 64.7,
            "efficiency": 29,
            "efficiency_game_score": 22.3,
            "fouls_drawn": 4,
            "offensive_fouls": 0,
            "points_in_paint": 8,
            "points_in_paint_att": 6,
            "points_in_paint_made": 4,
            "points_in_paint_pct": 66.7,
            "points_off_turnovers": 5,
            "true_shooting_att": 19.2,
            "true_shooting_pct": 67.7,
            "coach_ejections": 0,
            "coach_tech_fouls": 0,
            "second_chance_pts": 2,
            "second_chance_pct": 0
          }
        }
      ],
      "assists": [
        {
          "full_name": "Alvaro Cardenas",
          "jersey_number": "11",
          "id": "6839ceb0-51a8-41c9-a8bb-81902f521f22",
          "position": "G",
          "primary_position": "NA",
          "statistics": {
            "minutes": "36:00",
            "field_goals_made": 2,
            "field_goals_att": 8,
            "field_goals_pct": 25,
            "three_points_made": 0,
            "three_points_att": 3,
            "three_points_pct": 0,
            "two_points_made": 2,
            "two_points_att": 5,
            "two_points_pct": 40,
            "blocked_att": 1,
            "free_throws_made": 0,
            "free_throws_att": 0,
            "free_throws_pct": 0,
            "offensive_rebounds": 0,
            "defensive_rebounds": 1,
            "rebounds": 1,
            "assists": 9,
            "turnovers": 6,
            "steals": 1,
            "blocks": 1,
            "assists_turnover_ratio": 1.5,
            "personal_fouls": 1,
            "tech_fouls": 0,
            "flagrant_fouls": 0,
            "pls_min": -7,
            "points": 4,
            "double_double": false,
            "triple_double": false,
            "effective_fg_pct": 25,
            "efficiency": 5,
            "efficiency_game_score": 1.1,
            "fouls_drawn": 3,
            "offensive_fouls": 0,
            "points_in_paint": 4,
            "points_in_paint_att": 5,
            "points_in_paint_made": 2,
            "points_in_paint_pct": 40,
            "points_off_turnovers": 0,
            "true_shooting_att": 8,
            "true_shooting_pct": 25,
            "coach_ejections": 0,
            "coach_tech_fouls": 0,
            "second_chance_pts": 2,
            "second_chance_pct": 0
          }
        }
      ]
    }
  },
  "away": {
    "name": "Cornhuskers",
    "alias": "NEB",
    "market": "Nebraska",
    "id": "f8b1bf00-5b73-4ac4-98c0-ec554027ae32",
    "points": 79,
    "rank": 0,
    "remaining_timeouts": 1,
    "scoring": [
      {
        "type": "half",
        "number": 1,
        "sequence": 1,
        "points": 39
      },
      {
        "type": "half",
        "number": 2,
        "sequence": 2,
        "points": 40
      }
    ],
    "leaders": {
      "points": [
        {
          "full_name": "Juwan Gary",
          "jersey_number": "4",
          "id": "87b03cde-95ed-4535-a0e4-1f68fc9da312",
          "position": "F",
          "primary_position": "NA",
          "statistics": {
            "minutes": "38:00",
            "field_goals_made": 7,
            "field_goals_att": 12,
            "field_goals_pct": 58.3,
            "three_points_made": 4,
            "three_points_att": 4,
            "three_points_pct": 100,
            "two_points_made": 3,
            "two_points_att": 8,
            "two_points_pct": 37.5,
            "blocked_att": 0,
            "free_throws_made": 3,
            "free_throws_att": 3,
            "free_throws_pct": 100,
            "offensive_rebounds": 3,
            "defensive_rebounds": 6,
            "rebounds": 9,
            "assists": 0,
            "turnovers": 0,
            "steals": 0,
            "blocks": 3,
            "assists_turnover_ratio": 0,
            "personal_fouls": 1,
            "tech_fouls": 0,
            "flagrant_fouls": 0,
            "pls_min": 12,
            "points": 21,
            "double_double": false,
            "triple_double": false,
            "effective_fg_pct": 75,
            "efficiency": 29,
            "efficiency_game_score": 21,
            "fouls_drawn": 2,
            "offensive_fouls": 0,
            "points_in_paint": 6,
            "points_in_paint_att": 7,
            "points_in_paint_made": 3,
            "points_in_paint_pct": 42.9,
            "points_off_turnovers": 2,
            "true_shooting_att": 13.32,
            "true_shooting_pct": 78.8,
            "coach_ejections": 0,
            "coach_tech_fouls": 0,
            "second_chance_pts": 4,
            "second_chance_pct": 0
          }
        }
      ],
      "rebounds": [
        {
          "full_name": "Juwan Gary",
          "jersey_number": "4",
          "id": "87b03cde-95ed-4535-a0e4-1f68fc9da312",
          "position": "F",
          "primary_position": "NA",
          "statistics": {
            "minutes": "38:00",
            "field_goals_made": 7,
            "field_goals_att": 12,
            "field_goals_pct": 58.3,
            "three_points_made": 4,
            "three_points_att": 4,
            "three_points_pct": 100,
            "two_points_made": 3,
            "two_points_att": 8,
            "two_points_pct": 37.5,
            "blocked_att": 0,
            "free_throws_made": 3,
            "free_throws_att": 3,
            "free_throws_pct": 100,
            "offensive_rebounds": 3,
            "defensive_rebounds": 6,
            "rebounds": 9,
            "assists": 0,
            "turnovers": 0,
            "steals": 0,
            "blocks": 3,
            "assists_turnover_ratio": 0,
            "personal_fouls": 1,
            "tech_fouls": 0,
            "flagrant_fouls": 0,
            "pls_min": 12,
            "points": 21,
            "double_double": false,
            "triple_double": false,
            "effective_fg_pct": 75,
            "efficiency": 29,
            "efficiency_game_score": 21,
            "fouls_drawn": 2,
            "offensive_fouls": 0,
            "points_in_paint": 6,
            "points_in_paint_att": 7,
            "points_in_paint_made": 3,
            "points_in_paint_pct": 42.9,
            "points_off_turnovers": 2,
            "true_shooting_att": 13.32,
            "true_shooting_pct": 78.8,
            "coach_ejections": 0,
            "coach_tech_fouls": 0,
            "second_chance_pts": 4,
            "second_chance_pct": 0
          }
        }
      ],
      "assists": [
        {
          "full_name": "Brice Williams",
          "jersey_number": "3",
          "id": "440bf773-5021-4ef0-8953-3e8bcad1e07b",
          "position": "G",
          "primary_position": "NA",
          "statistics": {
            "minutes": "38:00",
            "field_goals_made": 4,
            "field_goals_att": 8,
            "field_goals_pct": 50,
            "three_points_made": 1,
            "three_points_att": 2,
            "three_points_pct": 50,
            "two_points_made": 3,
            "two_points_att": 6,
            "two_points_pct": 50,
            "blocked_att": 0,
            "free_throws_made": 5,
            "free_throws_att": 6,
            "free_throws_pct": 83.3,
            "offensive_rebounds": 0,
            "defensive_rebounds": 5,
            "rebounds": 5,
            "assists": 6,
            "turnovers": 1,
            "steals": 0,
            "blocks": 0,
            "assists_turnover_ratio": 6,
            "personal_fouls": 3,
            "tech_fouls": 0,
            "flagrant_fouls": 0,
            "pls_min": 10,
            "points": 14,
            "double_double": false,
            "triple_double": false,
            "effective_fg_pct": 56.3,
            "efficiency": 23,
            "efficiency_game_score": 13.1,
            "fouls_drawn": 7,
            "offensive_fouls": 1,
            "points_in_paint": 4,
            "points_in_paint_att": 4,
            "points_in_paint_made": 2,
            "points_in_paint_pct": 50,
            "points_off_turnovers": 2,
            "true_shooting_att": 10.64,
            "true_shooting_pct": 65.8,
            "coach_ejections": 0,
            "coach_tech_fouls": 0,
            "second_chance_pts": 0,
            "second_chance_pct": 0
          }
        }
      ]
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment