i am using unreal engine ( c++ ) , so i have no fancy browsers apis / wallet or anything …
now regarding your last point , the client is interacting with Daedalus / cardano-wallet locally , its not a server-based wallet
Okay, that’s better. Users still have to trust your application, but if they do not fully they can probably just use an extra wallet just for that game.
But having Daedalus (or at least cardano-node and cardano-wallet) running locally is a pretty hefty dependency. You could consider implementing more of a minimal wallet app using libraries like cardano-serialization-lib or Lucid and APIs like Blockfrost, Koios, Dandelion, … to interact with the chain.
I am also using a C++ game engine and then generating web assembly builds for cross-platform accessibility. The game client can make requests to back-end restful controllers which does any other Cardano things I need through blockfrost API or directly on nodes etc.
You should never need private keys to be submitted/transmitted and frankly users would not trust your app if you tried that, nor should they.
Example from my game: Minting a playable character flows like this more or less …
Client: State machine handles the signals to determine if they need to connect wallet, have a wallet, etc. This enables and disables buttons and interfaces in the GUI and displays tool tip hints and highlighting as needed to direct users.
User: In the “connected wallet” state with a browser based CIP 30 wallet selected/identified they can now Click/Tap/Touch the “hatch” button if they have found an egg in game. That makes a JS call out via wallet account/asset API (is ADA >= 5?) and if true we then make a HTTPS request to my back end.
Server: Restful API controller parses and validates the request, calls a service to PRNG roll a character sheet, token meta data, minting transaction, calc fees, etc, etc. Persists the open minting Tx to a SQL database then returns the response to be signed by user wallet.
Client: If status OK (200) then we submit this Tx via JS to their wallet to be signed. The wallet does it’s thing and they verify everything looks legit, type in their spend password or whatever, and approve or reject the Tx. If they sign it we take the CBOR hex and fire it off to the back end on a different HTTPS route.
Server: Validates the signed Tx, looks up the matching Tx in database, verifies CRC checks, witness, etc. If everything checks out and looks good the policy holding key signs it (multi-sig) and then submits to to Cardano node to actually mint token and fold it into the ledger. Response tells client to continue or handle error accordingly.
Client: If status OK (200) then the response has the pool.pm link to view the new token. Of course they can also just look at their wallet or continue on with the game as the next time they go to the “gym” screen I’ll check their wallet with JS call out for dino tokens and load them up to be selected.
User: Selects their new token and goes off to battle with it or whatever they want to do next.
The potential downside of this transparency is a clever user can see what type, stats, etc they are getting before signing but if the user really wants to sit there “rolling Tx” until they get what they want that is fine unless they get carried away and trigger the flood gate or subsequent bans on back end by trying to automate minting with code or something … not sure why anyone would do that.
P.S. the most important part of this is next time when they connect a wallet that already has a dino token we don’t need to do any of this nonsense. Find the token in the wallet via JS can be done entirely on the front end and once a character is selected the state machine can move along and things like battles become available … having a token in a wallet without any ADA is good enough to “sign in” at this point.
I don’t really know Unreal. Can you describe how the connection to the browser is made. Having JS available in Unreal is one thing, but the CIP-30 API lives inside one browser and I don’t even know if it is Chrome, Edge, Brave, … How is the IPC to that browser done?
thank you for your answers ,
i guess the JS route using this : Unreal.js in Code Plugins - UE Marketplace
can help … so i redirect things to his browser wallet … but yeah i wanted something that just utilizes cardano-wallet & player wont need to look to his browser wallets or anything
i know it might look heavy ? but with mithril node incoming , sync up time wont be an issue … player can just download & install Daedalus , open the game and everything works no need to setup or go back and fourth to a browser… my current issue is i want to verify the wallet without sending & waiting for a transaction
There is no Tx to query read-only data. You can use the wallet assets API to see what is there and most of the wallets simply relay this requests to the blockchain kind of like how you can look things up on a blockchain explorer without any Tx or fees.
eg imagine you have a game in a PS5 right ? how you wanna use a browser there? , anyway im just trying to push cardano integration in game as much as i can & see where the limits are.
ideally i guess games wont integrate wallets at all … everything will be centralized and they would offer you a possibility to transfer your ingame assets to ur wallet of choice… and vice versa
Mithril will be lighter, but it will still be a full node. My main wallet app is a browser wallet and I’d guess for most people into NFTs and stuff it will be the same, since they want to connect to marketplaces, browser-based metaverse thingies, … So, the expected way is dApp connection, I’d think.
I don’t have the $$$$$ or excruciating patience it would take to even imagine building that infrastructure. I am targeting HTML5 deploys only so that people on laptops, tablets, and mobile can use their existing browsers. If you want to play on Xbox or something you’ll have to figure out how to get your Cardano wallet extension into the Edge browser app on your own
indeed , i am targeting Blockchain based open world games ( MMOs , World Building , Survival etc…) …
true metaverse experiences…im just experimenting here . no production stuff yet … but i guess what i need is more like a feature missing from cardano-wallet server API or i am not understanding it very well .
It indeed looks like cardano-wallet is missing that. It’s not the best API, anyway. Even if you don’t want to do a dApp connection, it might be worthwhile to use Unreal-JS and then Lucid with a connection to Blockfrost or Koios. Saves you the whole Daedalus thing.