├── .gitignore ├── LICENSE ├── README.md ├── contracts ├── GameLand.sol ├── Greeter.sol ├── MyNFT.sol └── TestERC721.sol ├── hardhat.config.js ├── package-lock.json ├── package.json ├── ppts ├── gameland_cn.pptx └── gameland_en.pptx ├── scripts ├── deploy.js └── sample-script.js ├── test └── gameland.js └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .env 3 | 4 | #Hardhat files 5 | cache 6 | artifacts 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GameLand 2 | A GameFi NFT rent protocol. 3 | 4 | Leveraging the blockchain game service market with experiential innovation 5 | 6 | ## Presentation 7 | https://v.youku.com/v_show/id_XNTgwNjg2NzA5Ng==.html 8 | 9 | ## High-Level Concept (Abstract) 10 | Gameland as a Gamefi platform aims to help users experience high-end games at the lowest price, provide users a rental platform with integrating experience and revenue, and lower the boundary between players and games。 11 | This multi-dimensional enriches the blockchain game itself and brings new upgrades to the blockchain game 12 | 13 | 14 | ## Our Vision 15 | The Gameland vision is to bring affordable game experience with an NFT for trustless, secure, and quick rentability in cross-platform way by gathering all the rentable items like user accounts or tools from different online gaming platforms and list them in order for people who are interested in renting one or some of them for either fun game experience or profit. 16 | Moreover, we want the community to benefit from this. We aim to fulfill the vision of a true DAO where each member is rewarded, to the extent that they are active participants in the community. All of the Origin products will be under the umbrella of this DAO. 17 | The initial and core Origin product is a protocol layer that enables peer to peer renting of ERC-721 non-fungible tokens (NFTs) on Ethereum Mainnet 18 | 19 | Gameland architecture in future will be multi-chained as most of the different chain games are on different public chains. 20 | The nature of NFT chain-crossing is different from the token one. Therefore, Gameland plan to establish multiple Chain Wallet smart contract leasing protocols on the platform to implement the cross chain NFT leasing system. 21 | 22 | 23 | ## Technology Stack 24 | * Client Framework - React + Typescript 25 | * Ethereum development environment - Solidity + Hardhat 26 | * Ethereum Web Client Library - Web3.js&Truffle/Ether.js&Waffle 27 | 28 | ## User Case(Ether only ) 29 | - Lenders(Lending an NFT) 30 | * On Gameland’s platform a user can lend one or multiple NFTs. By doing so this saves multiple rental transaction costs and merges them into one single cost 31 | * Lending implies transferring the NFT to our “escrow” smart contract to list it for rent 32 | * The NFT "Lender" specifies the following: 33 | * The Rental Price (how much you wish to be compensated daily; this is the daily borrow price) 34 | * The NFT Price (this is the collateral a borrower most put up to rent) 35 | * Max Rental Period (maximum number of days you wish to lend out your NFT) 36 | 37 | - Borrowers(Renting an NFT) 38 | * The “Borrower” must specify the duration (in days) that they would like to borrow the NFT for 39 | * This duration then gets multiplied by the lender's set rental price, the NFT price (collateral) gets added in, to arrive at the total rent price 40 | * This total rent price gets deducted from the borrower’s balance and sent to the Gameland contract which acts as an escrow 41 | * The NFT is then sent to the "Borrower" after successful transaction 42 | * The NFT price (collateral) is stored in Gameland’s contract and is returned to the NFT “Borrower” only upon successful return of the NFT to the “Lender” (NFT "Lender") 43 | * In the case that the NFT is not returned on time (rental duration has passed), the collateral can be claimed by the lender from the Gameland contract 44 | 45 | ## The process works as follow: 46 | * Lenders fill up the name, nature of the item and upload the image of it. 47 | * Gameland will then use the information above as a file and send it to IPFS to generate a CID 48 | * The CID and the lender address will be the parameters to call our ERC721 contract to mint a NFT 49 | * To call the functions at Gameland on UI, the NFT ID will be used to fetch the corresponding CID and the showcase will be rendered 50 | 51 | ## Road map 52 | Q3 2021 53 | * Testnet launch : including lending, borrowing, withdraw and liquidation etc. 54 | 55 | 56 | Q4 2021 57 | * Bugs fixing and function optimizations: imposing a fine as penalty instead of confiscating the collaterals 58 | * Collateral Free Rentals: direct project integrations with NFT games/projects enabling collateral free renting 59 | * L2 Solutions Support: Polygon 60 | * DAO Launch/Rollout : including Game Guild DAO and Gameland Governance DAO 61 | * Further blockchains/defi integrations (e.g: Aave and Compound): according to market demands/activity 62 | * Full Rental Statistics Dashboard 63 | * Live leaderboard showing top renters and lenders (With special NFT rewards to gamify experience) 64 | 65 | ## Tentative Milestones 66 | * UI building (1week) & Testing 67 | * Testnet launch(2weeks) : including lending, borrowing, withdraw and liquidation etc. 68 | * Bugs fixing and function optimizations(2weeks): imposing a fine as penalty instead of confiscating the collaterals 69 | 70 | ### Tentative future features 71 | Origin Oracle has three roles: Game NFT aggregation, Game NFT Price Discoverer and Data Verification Node. 72 | 1. Firstly, the origin collection node collects the attributes of NFTs (e.g AXIS) with different scarcity and varieties and the transaction prices in the market in different periods through trading platforms such as Opensea, and the system forms a certain value evaluation standard model. 73 | 2. Secondly, the game NFT price discoverer collects the price of the market game NFT in the origin game Dao and feeds the price to the origin system. After the system collects the price, a unified database is formed. Everyone can participate in the Oracle service and become a node in the Oracle system network 74 | 3. The data verification node is responsible for data verification and storage, providing more secure and reliable data and reducing malicious quotations. 75 | Dao governance mode, therefore, in the process of benchmarking the price range above, it is also necessary to carry out access constraints, governance and incentive measures for the corresponding participants, so that the dam can realize the quotation under normal rules and prevent quotation errors. So as to complete the pricing process of NFT 76 | -------------------------------------------------------------------------------- /contracts/GameLand.sol: -------------------------------------------------------------------------------- 1 | //SPDX-License-Identifier: Unlicense 2 | pragma solidity ^0.8.0; 3 | 4 | import "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol"; 5 | 6 | contract GameLand is ERC721Holder { 7 | //all nft programes 8 | address[] public nfts; 9 | address public owner; 10 | 11 | constructor() { 12 | owner = msg.sender; 13 | } 14 | 15 | struct Nft { 16 | //price in ether 17 | uint256 daily_price; 18 | uint256 duration; 19 | uint256 collatoral; 20 | uint256 total_amount; 21 | } 22 | 23 | struct borrowInfo { 24 | address borrower; 25 | uint256 due_date; 26 | } 27 | 28 | //NFT => (borrower, due_date) 29 | mapping(uint256 => borrowInfo) public borrow_status; 30 | 31 | //NFT => basci_info 32 | mapping(uint256 => Nft) public nft_basic_status; 33 | 34 | // nft => address, origin owner 35 | mapping(uint256 => address) public nft_owner; 36 | 37 | //if a NFT is borrowed or not 38 | mapping(uint256 => bool) public borrow_or_not; 39 | 40 | //nft_programe address to their position 41 | mapping(address => uint256) public programe_number; 42 | 43 | event Received(address from, address to, uint256 gameland_nft_id); 44 | 45 | event Withdrew(address from, address to, uint256 gameland_nft_id); 46 | 47 | event Rented(address from, address to, uint256 gameland_nft_id); 48 | 49 | event Confiscated(address caller, uint256 gameland_nft_id); 50 | 51 | modifier onlyOwner() { 52 | require(msg.sender == owner, "Not owner"); 53 | _; 54 | } 55 | 56 | function add_nft_program(address nft_programe_address) public onlyOwner { 57 | nfts.push(nft_programe_address); 58 | uint256 how_many_nft_programes_has_in_gameland = nfts.length; 59 | programe_number[nft_programe_address] = 60 | how_many_nft_programes_has_in_gameland - 61 | 1; 62 | } 63 | 64 | //NFT owner transfer the ownership to Gameland, set price, duration, collatoral in eth 65 | //need approval 66 | function deposit( 67 | uint256 daily_price, 68 | uint256 duration, 69 | //这是NFT合约里给NFT的id,用来直接作为参数调用合约,是从opensea api获取到的那个token_id字段 70 | uint256 nft_id, 71 | uint256 collatoral, 72 | //opensea api中的 primary_asset_contracts。address 73 | address nft_programe_address, 74 | // 前端计算,gameland_nft_id = uint(string(programe_index)+string(nft_id)),其中program_index=programe_number[nft_programe_address] 75 | uint256 gameland_nft_id 76 | ) public { 77 | //this function will check everything about nft 78 | (bool success, ) = nft_programe_address.call( 79 | abi.encodeWithSignature( 80 | "safeTransferFrom(address,address,uint256)", 81 | msg.sender, 82 | address(this), 83 | nft_id 84 | ) 85 | ); 86 | require(success); 87 | uint256 total_amount = daily_price * duration + collatoral; 88 | nft_basic_status[gameland_nft_id] = Nft( 89 | daily_price, 90 | duration, 91 | collatoral, 92 | total_amount 93 | ); 94 | nft_owner[gameland_nft_id] = msg.sender; 95 | borrow_or_not[gameland_nft_id] = false; 96 | emit Received(msg.sender, address(this), gameland_nft_id); 97 | } 98 | 99 | //owner withdraw the nft when it is not borrowed 100 | function withdrawnft( 101 | uint256 nft_id, 102 | address nft_programe_address, 103 | uint256 gameland_nft_id 104 | ) public { 105 | require(!borrow_or_not[gameland_nft_id], "The nft is borrowed"); 106 | require( 107 | msg.sender == nft_owner[gameland_nft_id], 108 | "Only owner can withdraw NFT" 109 | ); 110 | (bool success, ) = nft_programe_address.call( 111 | abi.encodeWithSignature( 112 | "safeTransferFrom(address,address,uint256)", 113 | address(this), 114 | msg.sender, 115 | nft_id 116 | ) 117 | ); 118 | require(success); 119 | delete nft_basic_status[gameland_nft_id]; 120 | delete nft_owner[gameland_nft_id]; 121 | delete borrow_or_not[gameland_nft_id]; 122 | emit Withdrew(address(this), msg.sender, gameland_nft_id); 123 | } 124 | 125 | // this function will transfer the rent to the owner 126 | function rent( 127 | uint256 nft_id, 128 | address nft_programe_address, 129 | uint256 gameland_nft_id 130 | ) public payable { 131 | require( 132 | nft_basic_status[gameland_nft_id].total_amount <= msg.value, 133 | "Not enough amount" 134 | ); 135 | require(!borrow_or_not[gameland_nft_id], "Already been borrowed"); 136 | (bool success, ) = nft_programe_address.call( 137 | abi.encodeWithSignature( 138 | "safeTransferFrom(address,address,uint256)", 139 | address(this), 140 | msg.sender, 141 | nft_id 142 | ) 143 | ); 144 | require(success); 145 | uint256 price = nft_basic_status[gameland_nft_id].daily_price * 146 | nft_basic_status[gameland_nft_id].duration; 147 | 148 | uint256 pay_to_owner = price - (price * 3) / 100; 149 | (bool rent_success, ) = nft_owner[gameland_nft_id].call{ 150 | value: pay_to_owner 151 | }(""); 152 | require(rent_success); 153 | 154 | uint256 duration = nft_basic_status[gameland_nft_id].duration; 155 | borrow_or_not[gameland_nft_id] = true; 156 | //fixed duration time 157 | borrow_status[gameland_nft_id] = borrowInfo( 158 | msg.sender, 159 | duration * 1 days + block.timestamp 160 | ); 161 | emit Rented(address(this), msg.sender, gameland_nft_id); 162 | } 163 | 164 | // borrower return the nft 165 | //need approval 166 | function _return( 167 | uint256 nft_id, 168 | address nft_programe_address, 169 | uint256 gameland_nft_id 170 | ) public { 171 | require( 172 | borrow_or_not[gameland_nft_id], 173 | "the nft has not been borrowed" 174 | ); 175 | (bool success, ) = nft_programe_address.call( 176 | abi.encodeWithSignature( 177 | "safeTransferFrom(address,address,uint256)", 178 | msg.sender, 179 | address(this), 180 | nft_id 181 | ) 182 | ); 183 | require(success); 184 | 185 | (bool collatoral_success, ) = borrow_status[gameland_nft_id] 186 | .borrower 187 | .call{value: nft_basic_status[gameland_nft_id].collatoral}(""); 188 | require(collatoral_success); 189 | 190 | delete borrow_status[gameland_nft_id]; 191 | delete borrow_or_not[gameland_nft_id]; 192 | 193 | emit Received(msg.sender, address(this), gameland_nft_id); 194 | } 195 | 196 | //owner take the collatoral when the borrower failed to return the nft 197 | function confiscation(uint256 gameland_nft_id) public { 198 | require( 199 | borrow_or_not[gameland_nft_id], 200 | "the nft has not been borrowed" 201 | ); 202 | require( 203 | msg.sender == nft_owner[gameland_nft_id], 204 | "Only owner can confiscate" 205 | ); 206 | require( 207 | borrow_status[gameland_nft_id].due_date <= block.timestamp, 208 | "Not yet" 209 | ); 210 | (bool success, ) = nft_owner[gameland_nft_id].call{ 211 | value: nft_basic_status[gameland_nft_id].collatoral 212 | }(""); 213 | require(success); 214 | nft_owner[gameland_nft_id] = borrow_status[gameland_nft_id].borrower; 215 | delete borrow_status[gameland_nft_id]; 216 | delete borrow_or_not[gameland_nft_id]; 217 | emit Confiscated(msg.sender, gameland_nft_id); 218 | } 219 | 220 | //added by ting 221 | function get_all_nfts() public view returns (address[] memory) { 222 | return nfts; 223 | } 224 | 225 | //added by ting 226 | function get_nft_allinfo(uint256 gameland_nft_id) 227 | public 228 | view 229 | returns ( 230 | uint256, 231 | uint256, 232 | uint256, 233 | uint256 234 | ) 235 | { 236 | return ( 237 | nft_basic_status[gameland_nft_id].daily_price, 238 | nft_basic_status[gameland_nft_id].duration, 239 | nft_basic_status[gameland_nft_id].collatoral, 240 | nft_basic_status[gameland_nft_id].total_amount 241 | ); 242 | } 243 | 244 | //Get the borrower, due_date, added by ting 245 | function get_borrow_info(uint256 gameland_nft_id) 246 | public 247 | view 248 | returns (address, uint256) 249 | { 250 | return ( 251 | borrow_status[gameland_nft_id].borrower, 252 | borrow_status[gameland_nft_id].due_date 253 | ); 254 | } 255 | 256 | //Check a NFT is borrowed or not, added by ting 257 | function check_the_borrow_status(uint256 gameland_nft_id) 258 | public 259 | view 260 | returns (bool) 261 | { 262 | return borrow_or_not[gameland_nft_id]; 263 | } 264 | 265 | //Query the owner of a NFT, added by ting 266 | function query_the_nft_owner(uint256 gameland_nft_id) 267 | public 268 | view 269 | returns (address) 270 | { 271 | return nft_owner[gameland_nft_id]; 272 | } 273 | } 274 | -------------------------------------------------------------------------------- /contracts/Greeter.sol: -------------------------------------------------------------------------------- 1 | //SPDX-License-Identifier: Unlicense 2 | pragma solidity ^0.8.0; 3 | 4 | import "hardhat/console.sol"; 5 | 6 | contract Greeter { 7 | string private greeting; 8 | 9 | constructor(string memory _greeting) { 10 | console.log("Deploying a Greeter with greeting:", _greeting); 11 | greeting = _greeting; 12 | } 13 | 14 | function greet() public view returns (string memory) { 15 | return greeting; 16 | } 17 | 18 | function setGreeting(string memory _greeting) public { 19 | console.log("Changing greeting from '%s' to '%s'", greeting, _greeting); 20 | greeting = _greeting; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /contracts/MyNFT.sol: -------------------------------------------------------------------------------- 1 | //SPDX-License-Identifier: Unlicense 2 | pragma solidity ^0.8.0; 3 | 4 | import "hardhat/console.sol"; 5 | import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; 6 | 7 | contract MyNFT is ERC721 { 8 | constructor() ERC721("MyNFT", "MyNFT") {} 9 | 10 | function mint(address to, uint256 tokenId) external { 11 | _safeMint(to, tokenId, ""); 12 | } 13 | } -------------------------------------------------------------------------------- /contracts/TestERC721.sol: -------------------------------------------------------------------------------- 1 | //SPDX-License-Identifier: Unlicense 2 | pragma solidity ^0.8.0; 3 | 4 | import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; 5 | import "@openzeppelin/contracts/utils/Counters.sol"; 6 | 7 | 8 | contract GameItem is ERC721URIStorage { 9 | using Counters for Counters.Counter; 10 | Counters.Counter private _tokenIds; 11 | 12 | constructor() ERC721("GameItem", "ITM") {} 13 | 14 | function awardItem(address player, string memory tokenURI) 15 | public 16 | returns (uint256) 17 | { 18 | _tokenIds.increment(); 19 | 20 | uint256 newItemId = _tokenIds.current(); 21 | _mint(player, newItemId); 22 | _setTokenURI(newItemId, tokenURI); 23 | 24 | return newItemId; 25 | } 26 | } -------------------------------------------------------------------------------- /hardhat.config.js: -------------------------------------------------------------------------------- 1 | require("@nomiclabs/hardhat-waffle"); 2 | 3 | // Replace this private key with your Ropsten account private key 4 | // To export your private key from Metamask, open Metamask and 5 | // go to Account Details > Export Private Key 6 | // Be aware of NEVER putting real Ether into testing accounts 7 | 8 | 9 | // This is a sample Hardhat task. To learn how to create your own go to 10 | // https://hardhat.org/guides/create-task.html 11 | task("accounts", "Prints the list of accounts", async (taskArgs, hre) => { 12 | const accounts = await hre.ethers.getSigners(); 13 | 14 | for (const account of accounts) { 15 | console.log(account.address); 16 | } 17 | }); 18 | 19 | const AURORA_PRIVATE_KEY = process.env.AURORA_PRIVATE_KEY; 20 | 21 | // You need to export an object to set up your config 22 | // Go to https://hardhat.org/config/ to learn more 23 | /** 24 | * @type import('hardhat/config').HardhatUserConfig 25 | */ 26 | module.exports = { 27 | solidity: "0.8.4", 28 | 29 | }; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "devDependencies": { 3 | "@nomiclabs/hardhat-ethers": "^2.0.2", 4 | "@nomiclabs/hardhat-waffle": "^2.0.1", 5 | "chai": "^4.3.4", 6 | "ethereum-waffle": "^3.4.0", 7 | "ethers": "^5.4.7", 8 | "hardhat": "^2.6.4" 9 | }, 10 | "name": "origin", 11 | "version": "1.0.0", 12 | "main": "index.js", 13 | "dependencies": { 14 | "dotenv": "^9.0.2", 15 | "@openzeppelin/contracts": "^4.3.1" 16 | }, 17 | "scripts": { 18 | "test": "mocha" 19 | }, 20 | "author": "", 21 | "license": "ISC", 22 | "description": "", 23 | "optionalDependencies": { 24 | "fsevents": "^2.3.2" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ppts/gameland_cn.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandotio/GameLand/648c028ed5903bf54168b5c7b95425f7c288600a/ppts/gameland_cn.pptx -------------------------------------------------------------------------------- /ppts/gameland_en.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandotio/GameLand/648c028ed5903bf54168b5c7b95425f7c288600a/ppts/gameland_en.pptx -------------------------------------------------------------------------------- /scripts/deploy.js: -------------------------------------------------------------------------------- 1 | // We require the Hardhat Runtime Environment explicitly here. This is optional 2 | // but useful for running the script in a standalone fashion through `node