Inspiration
In NEAR ecosystem there is not so much dynamic and interactive games that is already launched. Launch new game that is connected to blockchain require different skills for both sides: game and blockchain development as well as connection between this parts.
Main questions for game developers who want join web3 space: how to connect blockchain and how to use NFT or FT in my game. In other side blockchain developers that want develop game should find someone with game-engine knowledge.
Great solution for both sides: ct.js is free and open-source game engine that allow to use JavaScript for building your own 2D games. But there is new question: how connect this game engine with NEAR blockchain to get all benefits - fast, secure and cheap transactions, great community and documentation!
What it does
I developed connector module for ct.js game-engine that allow to connect any game to smart-contract using NEAR-API-JS. Module contain predefined methods and functionality: connect and disconnect account, get connection status, user wallet address, read and store data in blockchain. All this functionality allow anyone to spend more time for game development and simplify blockchain usage by using predefined methods and variables.
You can connect two smart-contracts to build your custom logic or use second smart-contract for fungible token or communication with external smart-contracts (for example you can call paras.id and connect your game directly to marketplace functionality).
With this module you can cover all your needs: write smart-contract on NEAR Blockchain and develop your game using only JavaScript!
How we built it
- Learn ct.js game engine.
- Create module (catmod) for connecting NEAR-API-JS.
- Add multiple smart-contracts support.
- Test module by creating my own game: Space Ranger, where you mint NFT, read and store data in NEAR Blockchain.
- Deployed game smart-contract to NEAR testnet. Repo: https://github.com/VlodkoMr/ct.js-near-sample-contract
- Deployed game to test domain.
Challenges we ran into
- How to create module in ct.js and connect NEAR Blockchain.
- How deal with network and user account in the game.
- How to handle transactions in the game and support more custom logic (support 2 contract usage).
- How to simplify module usage and calls.
- How to build some interesting game example.
Accomplishments that we're proud of
- Simple usage and full readme documentation with examples.
- Support any game that can be build by ct.js.
- Predefined methods that allow developer spend more time for building game and less time to deal with manual stuff in blockchain.
- Interesting demo game that demonstrate how to use module: connect user NEAR account, read data from blockchain (get user NFT list and scores), store data in blockchain using you own smart-contract (mint NFT, store earned coins, reset energy).
What's next for ct.js Connector - ct.js module
- Publish as official module for ct.js.
- Add support for multiple wallet connectors.
- Create interesting games and support other developers with game development.
Built With
- ct.js
- javascript
- near-api-js
Log in or sign up for Devpost to join the conversation.