From the Super Mario Wiki
Gameballs are capsules that come from the Gameball Machine, an item from Mario Party. This item appears in the Mushroom Shop after the Eternal Star map has been completed for the first time and at least 30 Minigames have been bought from the Mini-Game House. Players can buy a Gameball from the machine for three-hundred coins.
Every Gameball contains a random Minigame that has not been seen or purchased yet at the Mini-Game House. This provides an alternate way for players to unlock all Minigames; while the price changes at the Mini-Game House, the price for a Gameball stays at a consistent three-hundred coins.