Welcome to the cyberpunk post-apocalyptic world of Diesel Attack
Diesel Attack is a hardcore 2D-platformer with web3 economy based on utility NFTs and SBTs on TON blockchain. Desktop web version for now, mobile apps are coming soon.
To earn TON coins and collect NFTs and SBTs during the game you need a TON Wallet. We never ask you for keys.
Table of Contents
This is the source of the backend API server of the RPG 2D-sidescroller game Diesel Attack. It implements smart contracts on the TON blockchain to mint NFTs and SBTs for players during the game on the fly.
When a game client app sends a request to the server using API, a player gets a new weapon or ship as NFT based on the weighted random algorithm. Also, players get SBTs for completing the levels and speedrun records. While they need to connect a TON wallet only once starting the game. And NFT and SBT minting operations are totally free for users.
- The game is developed on Unity, built with WebGL & deployed at https://play.dieselattack.com.
- Smart contracts are used for on-chain data storage and for minting NFTs and SBTs on the fly, written in FunC.
- Backend API server is running on Fastify (Node.js framework) implementing Tonweb SDK.
- Orbs TON Access RPC network provides unrestricted decentralized access to the TON blockchain.
- Ton Connect 2.0 provides TON authorization in the game.
- NFTs and SBTs source images are hosted on IPFS using NFT.Storage.
- AWS EC2 & Route53 are used for both game and backend servers hosting & load balancing.
- TWA is to be used for voting functionality integration inside the Telegram app (to be implemented).
- Unity WebGL client app (the game)
- Backend API server handling requests
- Smart contract minting NFTs on the fly
- TON Connect 2.0 Unity WebGL integration
- Smart contract minting SBTs on the fly
- Smart contract storing players database completely on-chain
- Smart contract funding and distributing Prize Pool
- TWA dapp for voting and for quick access to leaderboard on-the-go
- iOS and Android client apps, mobile web version
Request:
GET /v2/
returns greetings message (server status check)
Response:
Diesel Attack NFT Game Backend API Server 2.1.8
Production server endpoint:
https://api.dieselattack.com/v2/
Request:
GET /v2/mint-nft?id=<address>&apikey=<secret_token>
mints NFT for player and returns an id of the collectible (weapons for now) and a link to just minted nft on explorer. Where <address>
is the player's TON wallet friendly address on the mainnet. And <secret_token>
is a client app hashed secret token. The response time is less than 1 second.
Response:
{ "success": <true/false>, "rewardType": <gun/ship/shield>,"rewardNum": <index>, "link": <just minted nft on blockchain explorer>, "errorMsg": <error message if any> }
Production server endpoint:
Until 31.03 you can check it out by yourself and mint NFT to your TON wallet. Just put your TON wallet address instead of
address
. No keys needed. Browse it and check your wallet NFT section.
Request:
GET /v2/mint-sbt?id=<address>&reward=<type>&num=<index>&apikey=<secret_token>
mints SBT for player and returns an id of the collectible and a link to just minted sbt on explorer. Where <address>
is the player's TON wallet address on the mainnet, <type>
is a type of the reward in the game, <index>
is an id of the reward. And <secret_token>
is a client app hashed secret token.
Response:
{ "success": <true/false>, "link": <just minted sbt on blockchain explorer>, "errorMsg": <error message if any> }
Production server endpoint (not implemented yet):
Apikey
, only the game app one!
Temporal ApiKey (valid until 31.03.23): e0965cbdf5ba6694039715cf642b44d9a007607294daf4579d8fff62a52016ba
Diesel Attack wallet official address: dieselattack.ton
(View on Tonscan)
Diesel Attack NFT Collection official address: EQB4LidmxGVV2_73UBiAAyQ8nv30u1SRP5_qIpv6UZPG_DOB
(View on Tonscan)
References to the original documentation:
FunC smart contracts will be compiled and saved as HEX code into the
build
directory in project root. It must be created with appropriate access permissions before building.
-
Install all the dependencies:
yarn
-
Build the smart-contract into WebAssembly:
yarn build
Credentials are stored in
env
directory in project root and used as environment variables. It must be created with appropriate access permissions before deploying.It should contain the next files:
apikey.env
withAPIKEY=""
in it - client app secret token.wallet_key.env
withSECRET_KEY=""
in it - contract owner wallet secret key in Base64 encoding.Server generates
api.log
file in project root directory. It must have appropriate access permissions.
-
Deploy the contract to the TON mainnet (workchain 0):
yarn deploy
-
Run the server:
yarn start
- Run the smart contract test: (not implemented yet)
yarn test