Technical stack for games on NEAR
Generally, there are two approaches to building games with NEAR blockchain integration.

  1. 1. Everything’s stored on the blockchain including the game back end logic. In this case, the classic back-end part is not required almost.
  2. 2. The game back end logic is built in a classic way and the blockchain part contains integration with wallets, NFT assets, tokens, marketplaces etc.
In this article, we cover the second option, when the game logic is built and stored on the classic back-end, then connected with the blockchain part for smart-contracts synchronization, tokens, user balances (wallets) etc.
Web-based games
Game part technical stack: HTML, any JS framework (Pixi, ThreeJS, etc.)
Also, the game can have a custom backend. We personally build games backend with ASP.NET Core. Optionally for the back-end, SaaS options can be used, e.g. Firebase. In this option data which is not connected with the blockchain is stored and managed in a database on Firebase.
Connection with Near on the front end is made through the library near-api-js. Connection with Near on the backend is made with AssemblyScript (similar to TypeScript).
Also, if game is going to have some advanced UI, such as numerous menus, settings screens, leaderboards etc. front-end libraries like Angular, React or Vue can be used.
In this case, it’s better to use a create-near-app command for project creation. This way developer will avoid probable mistakes in project configuration according to Near requirements. Concrete front-end framework can be chosen with –frontend option; also, option –contract allow to set a language for your smart contract.
Wallets connection
The account should be created by the link Further integration is made through the method from the library near-api-js:
In the browser, user is redirected to, where he logs in his account. In case of the successful authorization, he automatically returns to the application web page. The wallet stays connected – Near is using browser’s local storage to store account keys.
Other wallets (e.g. Metamask, Trustwallet) require separate integrations. They do not conflict with Near wallet but don’t integrate with it. Metamask can only be connected if the user has an installed browser extension for this wallet. Trustwallet – connects to mobile applications, it is not yet clear how to integrate web applications with it.
Sync between the front-end / back-end and smart-contracts
The front-end of an app is built with any convenient technology (JS / TS, Angular, React, Pixi, Three, etc. – depending on the specifics of the project). When you need to establish a connection with the wallet (sign in, account data, payment) – methods of the near-api-js library are called.
Account data looks like this:
The amount, returned in the user’s wallet data, is in yocto. Using the method of the same library, you can convert it to Near:
Smart contact data looks like this:
The last two methods (getGreeting, setGreeting) are custom methods written in AssemblyScript:

  • setGreeting – adds a new entry to the smart contract (in this case, just a string).
  • getGreeting – returns the rows that were previously written to the contract.
  • These methods were implemented on the Near backend (a JS/TS project using the near-sdk-as library). It is also possible to work with account and contract data from your custom back-end using RPC endpoints (API calls) (an alternative to near-sdk-as, if you need to do everything on a backend that is not JS – for example, ASP.NET Core).
    Marketplaces on NEAR
    Now, 14 decentralized platforms for the exchange of non-fungible tokens have been created on the Near blockchain. Popular ones are Mintbase, Paras which offer their own libraries for integration.

  • Mintbase API
  • Paras API
  • Desktop and mobile games
    We included the details about building the mobile and/or web games with Unity. Other options when a game is built on Unreal Engine or other frameworks may also sense, but not specified here. There are different options for the technical stack to be used and here we cover the most common of them plus what we personally use. All options are available for both desktop and mobile platforms.

    Option #1 – Unity + web view

    In this case, all interactions with the wallet and smart-contracts will be done inside the web view, since the JS runtime is located there. Accordingly, the stack is the technology necessary to create the application itself, plus the same JS / TS for writing the script for interacting with the wallet and the smart contract itself. The sync with wallets, marketplaces, other smart contacts, and blockchain parts are built in the same way described above – inside the web view.

    Option #2 – Unity + Unity plugin for NEAR

    Guys from Metaseed built a great tool for direct integration of NEAR in Unity. Their Unity plugin for NEAR is open-source and can be used by anyone

    Option #3 – Electron + web view

    We also use Electron, that is built with JS/TS and allows to create desktop app builds. Other steps are similar to what’s described in Option #1.