The Minimal Viable Oracle (MVO) is a repository that demonstrates how to connect Ethereum to any real-world API using the oracle pattern. Smart contracts typically cannot access off-chain data directly, so the MVO provides a way to query external data that is not provided by common oracle providers in the Web3 space. In this tutorial, the MVO shows how to create a set of contracts that enable you to draw random cards from a standard 52-card deck.
To install and set up the MVO, follow these steps:
.env file and define the environment variables
PRIVATE_KEY. You can use the example in
.example.env as a reference.
npx hardhat run scripts/1_deploy-contracts.js --network rinkeby. This will deploy the contracts and verify them on etherscan. It may take up to three minutes. This script will also create a file called
map.json that keeps track of the addresses of the deployed contracts. If it doesn't work on Windows, create the
map.json file manually and insert the addresses of the deployed contracts. You can refer to
map.example.json for inspiration.
npx hardhat run scripts/2_listen-to-oracle-requests.js --network rinkeby. This script fetches data from the API and sends it to the oracle contract. It runs in the background and won't log anything.
npx hardhat run scripts/2_listen-to-client-fulfillments.js --network rinkeby. This script listens for the
ClientFulfillment event from the
npx hardhat run scripts/3_draw-cards.js --network rinkeby. This script triggers the "oracle flow" and draws 52 cards from a single deck without shuffling. You can adjust the number of cards to draw. Make sure you have some testnet Ether in your wallet, as each request sends 0.001 ETH to the oracle.
The Minimal Viable Oracle (MVO) is a repository that provides a way to connect Ethereum smart contracts to external APIs using the oracle pattern. It allows you to query real-world data that is not provided by common oracle providers in the Web3 space. The MVO includes a tutorial on how to create contracts to draw random cards from a standard 52-card deck. The installation guide provides step-by-step instructions for setting up the MVO in your local environment.