Base64 is a smart contract framework for Tournament-based prediction markets that was built for Coinbase's Onchain Summer Hackathon. It was built using Foundry by Yuga Cohler and Chris Nascone.
NOTE: These contracts are unaudited and potentially buggy. Use at your own risk!
demo.mov
(The above video uses random competitors and random results.)
A Tournament is the central smart contract of Base64. It consists of:
- Competitors: The entities that compete in the tournament. These can be anything, e.g. ERC-721 tokens, or FriendTech accounts. The number of competitors must be a power of 2 between 4 and 256 inclusive.
- Results: The mechanism for deciding the winner of any given match in the Tournament. This could be anything, e.g. random, or based on price.
- Participants: These are the onchain addresses that predict the results of the Tournament. There could be conditions on them, for example, that they are ENS holders.
The Participant with the most points at the end of the Tournament wins.
NOTE: Base64 does not accept bets/stakes and does not compute payouts to participants. However, a separate Escrow contract that depends on Base64 could be deployed to enable this functionality. Do so at your own risk!
Coming soon!
On Base Goerli:
$ forge build
$ forge test
$ forge fmt
$ forge snapshot
Start a local Ethereum Network by running
$ anvil
See the script
folder for a sequence of scripts to deploy Base64 on Base Goerli.
cast call <contract-address> "getBracket()(uint256[][])"
cast call <contract-address> "getTeam(uint256)((uint256,string))" 1
Use another private key for this transaction.
cast send \
--private-key <other-private-key> \
<contract-address> \
"submitEntry(uint256[][])" "[[1,3,5,7],[3,5],[3]]"
cast call <contract-address> "listParticipants()(address[])"
cast send --private-key <admin-private-key> \
--rpc-url "https://goerli.base.org/" \
--gas-limit 5000000 \
<contract-address> "advance()"