Betchya is a peer-to-peer betting/challenge dapp. Betchya allows users to challenge each other with bets of ether on events or actions that they will take.
A bet has 3 actors:
- Proposer: The person creating the bet who is challening the other person.
- Acceptor: The person being challenged by the proposer (bet counter party)
- Judge: The person (or oracle smart contract) that will independently judge the outcome of the bet.
- As a user I want to be able to easily challenge my friends for ETH for competitions
- As a user I want to be able to challenge my friends for ETH to establish new habits in my life, eg. go to the gym 3x a week
- As a user I want to be able to entrust an objective third party (other friend) to judge my challenge
- As a user I want to be able to challenge my friends to predict the price of ETH in the future
- As a user I want to be able to cancel challenges and allow for the funds to be retrieved in case of unexpected circumstances
- Install latest nodejs (suggestedly using http://linuxbrew.sh
- Clone repo from GitHut
git clone https://github.com/kimpers/betchya.git
- Install yarn
npm install -g yarn
- Install Ganache
npm install -g ganache-cli
- Open project directoru
cd betchya
then runyarn install
- Start ganache
ganache-cli
and copy the mnemonic - Run
yarn truffle migrate
- Import mnemonic you copied in previous step into metamask
- Set metamask to use private local network
- Create 3 additional accounts in metamask. Each should have 100 ETH.
- Run tests
yarn test
(orNODE_ENV=development truffle test
). All tests should pass (EthPriceJudge are skipped for convenience for now) - Run
yarn start
to start and go to http://localhost:3000 - Enjoy using Betchya
- Metamask should now have 4 accounts. Copy the address of account 3 & 4 and store them somewhere. Switch to account #2.
- Paste the address of account #3 into
ETH address of the challenged
- Paste the address of account #4 into
ETH address of the judge
- Write a short description, e.g. Go to the gym twice a week for 6 months.
- Input amount in ETH, eg. 1
- Click make bet and confirm in Metamask
- When you see a message that the bet was successful click on the current bets dropdown and select the bet.
- Now you can see details about the bet. Switch accounts in metamask to account #3 (the UI should automatically update)
- Click on
Accept bet
and approve the transaction. - When transaction has been mined switch to account #4
- Click on
Confirm judge
and approve the transaction. Let it get mined. - You should now be able to settle the bet. Select the winner in the dropdown eg Proposer (account #2) and press
Settle bet
. Let the transaction get mined. Then switch to account #2. - Click on withdraw ether and approve the transaction.
- You should now have received both deposits as the winner.
Betchya has an Oraclize contract for betting on the ETH-USD price on GDAX. This contract has not been incorperated in the UI yet but it can bet tested with the included unit tests. The Oraclize contract has been disabled initially due to the complex local development setup, follow these instructions to re-enable it and setup the environment.
- Start the ethereum-bridge:
yarn ethereum-bridge -a 9 --dev
. Wait for it to finish starting up. - Copy the line
OAR = OraclizeAddrResolverI(0x...);
from the output into clipboard. - Edit
contracts/EthPriceJudge.sol
and replace theOAR = OraclizeAddrResolverI(0x..)
in the constructor with the value that you copied. Save the file and close it. - Enable deployment of contract. Edit the file
migrations/2_deploy_contracts.js
and uncomment the line// await deployer.deploy(EthPriceJudge, Betchya.address)
so that deploys the contract. - Run
yarn truffle migrate
- Edit
test/ethPriceJudge.js
remove theskip
fromcontract.skip
so that it readscontract(
- Run
yarn test
and see how it the tests interact with the GDAX api through Oraclize.
- Project uses Oracle: Oracle integration (see Testing Oracle contract)
- Testnet Deployment: Contract deployed to Rinkeby (see
deployed_addresses.txt
) - IPFS: Betchya hosted on IPFS at https://ipfs.infura.io/ipfs/QmW34oYSpkREtEu7e2mxd8VBLKrenQECZcjr2zu9j3fk4b or https://gateway.ipfs.io/ipfs/QmW34oYSpkREtEu7e2mxd8VBLKrenQECZcjr2zu9j3fk4b(WARNING very slow to load, might require refresh if it gets stuck)