Tutorial: Create a prediction market on Etherlink
Prediction markets are platforms that allow users take a position on any event with a binary (true or false) outcome. For example, the question “Will Manchester United win the English Premier League in 2026?” has only two possible outcomes — Yes or No — because only one team can win the English premier league in any given season. Users can bet on Yes or No and the winners receive a portion of the total amount based on how much they bet on the winning outcome.
As an example of deploying and interacting with smart contracts on Etherlink, this tutorial walks through how to build a simple prediction market dApp, powered by a prediction market smart contract deployed on Etherlink and a simple frontend application.
This is a version of a tutorial originally posted as Build a Prediction Market on Etherlink. For more information about prediction markets, such as how the winners' shares are calculated based on their bets, see that tutorial.
Learning objectives
In this tutorial, you will learn:
- How to set up a development environment with Hardhat
- How to write a simple smart contract in Solidity
- How to create an Etherlink account and get Testnet tokens using the faucet
- How to test a smart contract locally
- How to use Hardhat to deploy the contract to Etherlink
- How to verify your contract on the Etherlink explorer
- How to create a frontend application to interact with the smart contract
Not included
This tutorial is not intended to be a complete course for developing smart contracts with Solidity or Hardhat or for developing frontend applications; the smart contract and frontend application in this tutorial are just examples. Also, the tools in this tutorial are only examples of tools that you can use with Etherlink. You can use many different smart contract and frontend development tools and technologies with Etherlink.
Disclaimer
The code is for education purposes and hasn’t been audited or optimized. You shouldn’t use this code in production.
Application source code
You can see the source code for the completed application here: https://github.com/trilitech/tutorial-applications/tree/main/etherlink-prediction.
When you are ready, go to Part 1: Write a contract.