Welcome to the cyberpunk post-apocalyptic world of Diesel Attack
To earn and collect NFTs during the game you need a NEAR Wallet Account (on the testnet). 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 contract on the NEAR blockchain to mint NFTs 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. Created on NEAR RUST SDK. NFT arts are hosted on IPFS. The server itself is running on Fastify (Node.js framework).
GET /api/
returns greetings message (server status check)
Production server endpoint:
https://v1.dieselattack.com/api/
GET /api/mint-nft?nearid=<username.testnet>
mints NFT for player and returns a code of the collectible to a game client app. Where <username.testnet>
is the player's NEAR account on the testnet.
Production server endpoint:
https://v1.dieselattack.com/api/mint-nft?nearid=username.testnet
You can check it by yourself and mint NFT to your NEAR testnet account. No authentication needed. Just put your Testnet account address instead of
username
, browse it and check your NEAR wallet Collectibles section.
Server's NFT contract address: nfts.dieselattack.testnet
(See in Explorer)
appkey
token, where secret_token
is something like QmFzZTY0IGVuY29kaW5nIG9
:
GET /api/mint-nft?nearid=<username.testnet>&appkey=<secret_token>
References to the original documentation:
Installing the prerequisites
-
Sign up to the NEAR Testnet Wallet and follow the instructions: https://wallet.testnet.near.org
-
Install Rust with Rustup tool (recommended):
curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | sh
-
Install Wasm32:
rustup target add wasm32-unknown-unknown
-
On Ubuntu you may need to install Build-essential:
sudo apt install build-essential
-
Install NVM (Node.js version manager):
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
-
Add these lines to your
~/.bashrc
,~/.profile
, or~/.zshrc
file to have it automatically sourced (you may need to restart the session):export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
-
Install the latest LTS version of Node.js:
nvm install --lts
-
Install NPM package manager:
npm install -g npm@latest
-
Install Near-cli globally:
npm install -g near-cli
-
Install Corepack (Yarn version manager):
Node.js >=16.10:
corepack enable
Node.js <16.10:
npm i -g corepack
-
Activate the latest global Yarn version:
Node.js ^16.17 or >=18.6:
corepack prepare yarn@stable --activate
Node.js <16.17 or <18.6:
Take a look at the latest Yarn release, note the version number, and run:
corepack prepare yarn@<version> --activate
-
Install all the dependencies:
yarn
-
Build the smart-contract into WebAssembly:
yarn build
-
Deploy the contract to the dev account:
yarn deploy:dev
-
Run the local server:
yarn start:dev
-
Login to the testnet account:
near login
-
Set your values for
CONTRACT
andMASTER_ACCOUNT
in the deploy script./scripts/deploy.sh
. -
Make sure you have the executable permissions on the deploy script:
sudo chmod +x ./scripts/deploy.sh
-
Deploy the contract to the testnet account:
yarn deploy
-
Set your value for
CONTRACT_NAME
in the account config file./config/testnet-account.env
-
Run the local server:
yarn start
-
Run the testnet account test:
yarn test
-
Run the dev account test:
yarn test:dev
-
Run the local server test:
yarn test:server