├── .babelrc
├── .gitattributes
├── .gitignore
├── .travis.yml
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── README_zhTW.md
├── TODO.md
├── cardbattle.gif
├── contracts
├── LOLYAT.sol
├── LowBit.sol
└── Migrations.sol
├── dapp
├── .babelrc
├── .gitignore
├── CARD.md
├── README.md
├── config
│ ├── env.js
│ ├── jest
│ │ ├── cssTransform.js
│ │ └── fileTransform.js
│ ├── paths.js
│ ├── polyfills.js
│ ├── webpack.config.dev.js
│ ├── webpack.config.prod.js
│ └── webpackDevServer.config.js
├── package.json
├── public
│ ├── audio
│ │ └── arcades.mp3
│ ├── favicon.ico
│ ├── index.html
│ └── manifest.json
├── scripts
│ ├── build.js
│ ├── start.js
│ └── test.js
└── src
│ ├── .DS_Store
│ ├── actions
│ ├── LOLYATActions.js
│ ├── counterActions.js
│ ├── fetchingActions.js
│ ├── healthActions.js
│ ├── metaMaskActions.js
│ ├── simpleTokenActions.js
│ └── warningActions.js
│ ├── apis
│ ├── api.http
│ └── api.js
│ ├── components
│ ├── App.css
│ ├── App.js
│ ├── App.scss
│ ├── App.test.js
│ ├── Arena
│ │ ├── Arena.css
│ │ ├── Arena.scss
│ │ └── index.js
│ ├── BattleCard
│ │ ├── index.js
│ │ ├── style.css
│ │ └── style.scss
│ ├── Card
│ │ ├── Card.css
│ │ ├── Card.scss
│ │ └── index.js
│ ├── Contract.css
│ ├── Contract.js
│ ├── Contract.scss
│ ├── Counter.js
│ ├── Health.js
│ ├── IndexUi.js
│ ├── Loading
│ │ ├── Loading.css
│ │ ├── Loading.scss
│ │ └── index.js
│ ├── LoadingCoin
│ │ ├── index.js
│ │ ├── style.css
│ │ └── style.scss
│ ├── MetaMask
│ │ └── MetaMask.js
│ ├── NiftyAlert
│ │ └── index.js
│ ├── SendTransaction.js
│ ├── Top
│ │ ├── Title.js
│ │ └── Top.js
│ ├── Tutorial
│ │ ├── Tutorial.css
│ │ ├── Tutorial.scss
│ │ └── index.js
│ ├── Warning
│ │ └── Warning.js
│ ├── _mixinKeyframes.scss
│ ├── indexUi.css
│ └── indexUi.scss
│ ├── constants
│ └── actionTypes.js
│ ├── container
│ └── AppContainer.js
│ ├── images
│ ├── .DS_Store
│ ├── Elf0.png
│ ├── Elf1.png
│ ├── Elf2.png
│ ├── Elf3.png
│ ├── Tutorial.png
│ ├── addcard.png
│ ├── back.png
│ ├── bgfooter.png
│ ├── big.png
│ ├── cardtitle.png
│ ├── cloud.png
│ ├── contarctresult.png
│ ├── demo
│ │ ├── 15.png
│ │ ├── Pixel15.png
│ │ └── bg15.png
│ ├── draw.png
│ ├── draw_message.png
│ ├── footer.png
│ ├── fruit1.png
│ ├── fruit2.png
│ ├── game.png
│ ├── gameplaybtn.png
│ ├── gameplaytitle.png
│ ├── getcard.png
│ ├── getherobtn.png
│ ├── github-icon.png
│ ├── github-icon2.png
│ ├── goBack.png
│ ├── history.png
│ ├── inputETH.png
│ ├── ladder.png
│ ├── loading.png
│ ├── loadingicoin.png
│ ├── logo.png
│ ├── lostelf.png
│ ├── loveicon.png
│ ├── paayer.png
│ ├── playerbet.png
│ ├── playgame.png
│ ├── result.png
│ ├── select.png
│ ├── star1.png
│ ├── star2.png
│ ├── testCard1.png
│ ├── title.png
│ ├── title2.png
│ ├── titlelogo.png
│ ├── tree1.png
│ ├── tree2.png
│ ├── user
│ │ ├── user1.png
│ │ ├── user10.png
│ │ ├── user11.png
│ │ ├── user12.png
│ │ ├── user13.png
│ │ ├── user14.png
│ │ ├── user2.png
│ │ ├── user3.png
│ │ ├── user4.png
│ │ ├── user5.png
│ │ ├── user6.png
│ │ ├── user7.png
│ │ ├── user8.png
│ │ └── user9.png
│ ├── userresult.png
│ ├── winlogo.png
│ └── youlost.png
│ ├── index.css
│ ├── index.js
│ ├── lib
│ ├── LOLYAT.js
│ ├── LOLYAT.json
│ ├── LOLYATService.js
│ ├── LOLYATService.test.js
│ ├── LowBit.js
│ ├── LowBitService.js
│ ├── SimpleToken.json
│ ├── cryptoHerosGame.json
│ ├── simpleToken.js
│ ├── tokenService.js
│ ├── tokenService.test.js
│ └── web3Service.js
│ ├── reducers
│ ├── LOLYATOwnedReducer.js
│ ├── LOLYATOwnedTokenURIReducer.js
│ ├── LOLYATReducer.js
│ ├── counterReducer.js
│ ├── fetchingReducer.js
│ ├── healthReducer.js
│ ├── index.js
│ ├── initialState.js
│ ├── metaMaskReducer.js
│ ├── simpleTokenReducer.js
│ ├── systemReducer.js
│ └── warningReducer.js
│ ├── registerServiceWorker.js
│ ├── routes.js
│ ├── sagas
│ ├── LOLYATOwnedSaga.js
│ ├── LOLYATOwnedTokenURISaga.js
│ ├── LOLYATSaga.js
│ ├── healthSaga.js
│ ├── index.js
│ ├── simpleTokenSaga.js
│ └── watcher.js
│ └── store
│ └── configureStore.js
├── gamehistory.gif
├── herocollection.gif
├── icon.png
├── migrations
├── 1_initial_migration.js
└── 2_deploy_contract.js
├── package.json
├── test
├── cryptoHerosToken.test.js
└── util.js
└── truffle-config.js
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["env"]
3 | }
4 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | /build
3 |
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | yarn.lock
8 | package-lock.json
9 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - "9"
4 | - "8"
5 | - "7"
6 | - "6"
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | ## Issues
4 |
5 | We use GitHub issues to track public bugs. Please ensure your description is clear and has sufficient instructions to be able to reproduce the issue.
6 |
7 | ## Pull Requests
8 |
9 | * Fork the repo and create your branch from master.
10 | * If you've added code that should be tested, add tests.
11 | * Ensure the test suite passes.
12 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2018 Portal Network. https://www.portal.network
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | > Non-fungible token game
16 |
17 |
18 |
19 | This project is a crypto card game that uses [OpenZepplin](https://github.com/OpenZeppelin/openzeppelin-solidity).
20 |
21 | The contract is compiled and deployed under the ERC-721 non-fungible token standard with truffle framework. After deploying onto the Ethereum blockchain, users will be able to play the game by interacting with the smart contract through DAPP’s front-end interface.
22 |
23 | Acquiring game card:
24 | Users can acquire game cards using ETH. Every game card will have a game point on it, which will be used to determine the winner later in the game.
25 |
26 | ## Roles
27 |
28 | #### Card Collection
29 | Players can aquire card using ether. Each card will have a random points on it, which will be used to deternmine the winner in the card game.
30 |
31 | 
32 |
33 | #### Card Battle
34 | Once entered the game, players will need to choose a card to play for the round. Each round, the smart contract will randomly decide either card with larger or smaller point wins the round. At the same time, the smart contract will also randomly generate a number in order to compete with the player. Winner of the game will receive the price.
35 |
36 | 
37 |
38 | #### Dashboard
39 | You can view the card battle history about all the games you played.
40 |
41 | 
42 |
43 | ## ERC-721 Token
44 |
45 | ERC-721 non-fungible token:
46 | ERC-721 is a free, open standard that describes how to build non-fungible or unique tokens on the Ethereum blockchain. While most tokens are fungible (every token is the same as every other token), ERC-721 tokens are all unique (with unique ID).
47 |
48 | [Reference](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md)
49 |
50 |
51 | ## Contracts
52 | You can find contract detail under `contracts/` directory:
53 | - [`CryptoHerosGame.sol`](./contracts/CryptoHerosGame.sol):
54 | The implementation of game execution and rule.
55 |
56 | - [`CryptoHerosToken.sol`](./contracts/CryptoHerosToken.sol):
57 | The implementation of game cards purchase and generation.
58 |
59 | ## Technical stack
60 |
61 | ### Frontend
62 | - React
63 | - Redux
64 | - Saga
65 | - Web3(MetaMask)
66 |
67 | ### UI
68 | - Sass
69 | - Material-UI
70 |
71 | ### Smart contract/Solidity
72 | - Truffle
73 |
74 | ### Test environment/Private chain
75 | - ganache
76 |
77 | ## Requirements
78 |
79 | * NodeJS 8.0+ recommended.
80 | * Windows, Linux or Mac OS X.
81 |
82 | ## How To Install Dependencies
83 |
84 | First install required dependencies:
85 |
86 | You'll need local ethereum node, I recommend `ganache-cli`. You can install it from npm.
87 |
88 | ```
89 | npm install -g ganache-cli
90 | ```
91 |
92 | Install truffle:
93 |
94 | ```
95 | npm install -g truffle
96 | ```
97 |
98 | Then install contract dependencies:
99 |
100 | ```
101 | npm install
102 | ```
103 |
104 | ## How To Test
105 |
106 | First make sure that local ethereum node is running. Execute:
107 |
108 | ```
109 | ganache-cli --gasLimit 0xffffffffff -p 8545
110 | ```
111 |
112 | Now you can compile and deploy contracts:
113 |
114 | ```
115 | truffle compile && truffle migrate
116 | ```
117 |
118 | Run contract tests:
119 |
120 | ```
121 | truffle test
122 | ```
123 |
124 | ## Playground
125 |
126 | We already deployed contracts to [Ropsten](https://ropsten.etherscan.io/) network. You can play with them RIGHT NOW.
127 |
128 | | Contract | Token address | Transaction hash
129 | |------------------|---------------|---------------------
130 | | CryptoHerosGame | [0xb4FF27d8cD1C5b1e3D4BD8A8FFEBdA9BE9517a4b](https://ropsten.etherscan.io/address/0xb4ff27d8cd1c5b1e3d4bd8a8ffebda9be9517a4b) | [0x49bb8698e2951a0c7eb091038b500694cdf37c74ec51d6c98d91823dc9595b95](https://ropsten.etherscan.io/tx/0x49bb8698e2951a0c7eb091038b500694cdf37c74ec51d6c98d91823dc9595b95)
131 | | CryptoHerosToken | [0xa82Bc392bF65d03A796E1666d27594fB31De4B93](https://ropsten.etherscan.io/address/0xa82bc392bf65d03a796e1666d27594fb31de4b93) | [0xf41868e6b59020965831aac218e1a521b283ab4975f10a44cf0908f6ce586ad7](https://ropsten.etherscan.io/tx/0xf41868e6b59020965831aac218e1a521b283ab4975f10a44cf0908f6ce586ad7)
132 |
133 | ## Card List
134 |
135 | See [CARD.md](./dapp/CARD.md) for more information.
136 |
137 | ## Contributing
138 |
139 | See [CONTRIBUTING.md](./CONTRIBUTING.md) for how to help out.
140 |
141 | ## Licence
142 |
143 | See [LICENSE](./LICENSE) for details.
144 |
--------------------------------------------------------------------------------
/README_zhTW.md:
--------------------------------------------------------------------------------
1 |