Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brianwchou/hangman
Dapp that allows you to play Hangman on the Ethereum network
https://github.com/brianwchou/hangman
hangman solidity truffle truffle-development
Last synced: 3 months ago
JSON representation
Dapp that allows you to play Hangman on the Ethereum network
- Host: GitHub
- URL: https://github.com/brianwchou/hangman
- Owner: brianwchou
- Created: 2019-05-26T14:18:56.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-24T01:40:44.000Z (about 2 years ago)
- Last Synced: 2023-04-18T01:37:24.725Z (almost 2 years ago)
- Topics: hangman, solidity, truffle, truffle-development
- Language: JavaScript
- Homepage: http://guillotine.eth.link/
- Size: 2.52 MB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 40
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Hangman
Play hangman on the Ethereum network. (Available currently on Ropsten network)Hangman is a game where a player has limited attempts to guess a secret word. The player is allowed to guess a letter contained in the secret or guess the entire secret. Each incorrect guess uses an attempt. When all attempts have been made or if the word has been guessed correctly the game ends.
### Technical description
This project is centered around these two contracts: `HangmanFactory.sol` and `Hangman.sol`.
HangmanFactory is a Chainlink Client that will fetch a random word from the [Wikipedia](https://en.wikipedia.org/api/rest_v1/page/random/title) API. After the word is fetched, the factory will deploy an instance of Hangman with the random word and return the contract address to the UI. A new game display appears with guessword and letter inputs. A game over screen appears when the word has been guessed or there are no more avaliable attempts.### Local Setup
1. `npm install truffle -g`
2. `git clone [email protected]:brianwchou/Hangman.git`
3. `cd Hangman`
4. `yarn`
5. `yarn web:install`
5. `yarn truffle:compile`
5. `yarn truffle:migrate`
5. `yarn web:start`### Tech Framework
- chainlink
- truffle
- ganache-cli
- gnosis mock-contract
- ganache-time-traveler
- react
- ethers.js
- ipfs### Contracts
```javascript
+ HangmanFactory (ChainlinkClient, Ownable)
- [Pub] #
- [Pub] requestCreateGame #
- [Pub] fullfillCreateGame #
- [Prv] bytes32ToBytes
- [Pub] withdrawLink #
- [Pub] setUrl #
- [Pub] cancelRequest #+ Hangman (Ownable)
- [Ext] setSolution #
- [Ext] getUsedCharacters
- [Ext] makeCharGuess #
- [Prv] computeGuess
- [Ext] makeWordGuess #
- [Ext] getNumberOfCharacters
- [Ext] getCorrectlyGuessedCharacters
- [Prv] hasBitAtIndex($) = payable function
# = non-constant function
```### Running Unit Tests
```
yarn test
```### Running Integration Tests
Make sure you have `.env` file set up
```
MNEMONIC=""
INFURA_API_KEY=""
```
Then run:
```
yarn test-integration --network ropsten
```
If there is a failure check
```
//ROPSTEN TESTNET ADDRESS
const chainlinkTokenAddress = "0x20fE562d797A42Dcb3399062AE9546cd06f63280";
const chainlinkOracleAddress = "0xc99B3D447826532722E41bc36e644ba3479E4365";
const CHAINLINK_HTTP_GET_JSON_PARSE_JOB_ID = "76ca51361e4e444f8a9b18ae350a5725";
const PAYMENT = 1;
```
https://ropsten.explorer.chain.link/### Deployment
register ethereum name on [ENS](https://ens.domains/)Run the following:
```
ipfs daemon
cd web
yarn build
ipfs add -r build/
```
```
added QmaHNhLf89FacunsrZDpHBSvZ8khsm5seCBNJBy8tqHEKr build
2.87 MiB / 2.87 MiB
[====================] 100.00%
```Take last hash displayed and add it to content on ens public resolver
Followed directions [here](https://medium.com/the-ethereum-name-service/how-to-host-your-dapp-with-ipfs-ens-and-access-it-via-ethdns-c96046059d87)
Upload may take some time to propagate and be available.