Plugin for integrating the Nano cryptocurrency into the Unreal Engine 4.
Tested on Windows/Linux/MacOS/Android/iOS with Unreal Enginge 4.25.3
Features include: functions for processing blocks, creating seeds + reading/saving them to disk in password-protected encrypted files. Generating qr codes, listening for payments to single accounts, private key payouts and many more
1 - git clone https://github.com/wezrule/UE4NanoPlugin
2 - Open the project UENano.uproject
(if there is an error then right click and generate project files, open up and build manually)
3 - The rpc/websocket settings are located in NanoGameInstance blueprint (leave unchanged to use the publically available servers)
4 - Run the map, first create a seed then top up the account and try all the other functions (a video is coming soon demonstrating this)
- Copy
Plugins
folder to an Unreal Engine project root directory. - Build your project
- Modify the
config.js
settings to be applicable for your system. - Run the nano_node after enabling rpc and websocket in
config-node.toml
file. nano_node --daemon
npm install
./server.js
A nano node is required to be running which the websocket & http server (for RPC request) will talk with. Websocket & RPC should be enabled in the node-config.toml
nano file.
A http server (for RPC requests) is definitely needed for communicating with the nano node via JSON-RPC, a test node.js server is supplied for this called server.js
. A websocket server to receive notifications from nano network is highly recommended to make the most use of the plugin functionality. Another test server called websocket_node.js
is supplied for this, both are found in the ./TestServer directory. Running server.js
will also run websocket_node.js
. The websocket script makes 2 connections to the node, 1 is filtered output and 1 gets all websocket events (usual for visualisers). If you only need filtered output (recommended!) then disable allow_listen_all=false
in config.js
.
NanoBlueprintLibrary.cpp
contains various generic functions such as creating seeds, encrypting/decrypting them using AES with a password, converting to accounts, converting between Raw and Nano and various other things.
NanoWebsocket.cpp
maintains the websocket connection to the proxies.
NanoManager.cpp
is where the other functionality is located
Anything with *WaitForConfirmation in the name requires that the account being utilised has been Watch
ed. This means that the websocket filtered connection is listening for events for this account, this creates a better user experience as websocket events are received as soon as the node processing them. All these functions have fallback methods which involve polling the node periodically (generally every 5 seconds). Anything taking a Websocket argument doesn't require explicit listening (such as the listening payment and payout functions). For watching (and unwatching an account):
All setups should set the rpc url, the plugin is pretty useless without an RPC connection, set it after creating the object:
Following that construct the websocket and call SetupFilteredConfirmationMessageWebsocketListener
, the last step is crucial as it listens to the websocket and fires off the various delegates which are bounded. The websocket connection will continuously attempt to reconnect if connection is lost, but will never call OnConnect again (this is to prevent some re-initialization errors seen in plugin implementations)
Always check the Error
boolean in all event responses, e.g:
Recommendation setups for:
Listen to payment - Have 1 seed per arcade machine, start at first index then increment each time a payment is needed. This only checks pending blocks, don't have anything else pocketing these funds automatically. Every time a new payment is needed, move to the next index. Only 1 payment can be listening at any 1 time!
Create a QR code for the account/amount required:
It looks like this:
Then listen for the payment:
If wanting to cancel it:
For payouts do a similar process with showing a QR Code (use the variant taking a private key), and listen for payout:
Create seed for player and store it encrypted with password (also check for local seed files if they want to open them)
Send and wait for confirmation:
Process seed (as above)
Create block locally and hand off to server
Server does validation (checks block is valid) then does appropriate action
Automatically pocket any pending funds
Listen to all websocket confirmations
Get the account frontier (Note: is the account doesn't exist yet, the frontier points to the account, if wanting to use this result as a "previous", need to check if it exists the account and if so branch and change to 0!:
Checking if a block is confirmed:
There are various helpful videos, I suggest watching them in this order:
- Shows the plugin integrated with the ActionRPG sample game https://www.youtube.com/watch?v=gMtzOkaNnXc
- Video tutorial showing the test level: Coming soon
- Video tutorial showing how to integrate into a game: Coming soon
Limitations
- The test servers should not be used in production due to lack of security/ddos protection. Likely canditates for a future version are the NanoRPCProxy.
- Only supports state blocks (v1)
- RawToNano blueprint function does not check locale and always outputs a decimal point (.), but NanoToRaw does accept both commar (,) and period (.).
- File permissions are always requested on Android/iOS. Also unsure if seed fields won't always remain after uninstalling the app.
- Not tested on other platforms like consoles
- UNanoManager & UWebsocketManager must be GameInstance variables to maintain connections between levels.
Windows
C:\Users\<user>\AppData\Local\NanoGames
Linux
/home/<user>/NanoGames
MacOS
/Users/<user>/Library/NanoGames
Other (e.g Android/iOS)
<project folder>/NanoGames
Working on various other platforms:
You can of course also use this in C++ projects.
Any donation contributions are welcome: nano_15qry5fsh4mjbsgsqj148o8378cx5ext4dpnh5ex99gfck686nxkiuk9uouy