# Working together with Unity, Blazor, Nethereum and MUD by Juan Blanco | Devcon SEA

- Speakers: Juan Blanco
- Channel: [Devcon](https://streameth.org/devcon)
- Date: 2025-10-09
- Duration: 25:18
- Topics: Science & Technology
- Watch: https://streameth.org/watch/yt-27FnZdCxvos
- YouTube: https://www.youtube.com/watch?v=27FnZdCxvos

## Description

This is a project demo as part of the MUD Day CLS: autonomous worlds, onchain games, and explores how Unity, Blazor, Nethereum, and MUD integrate to build blockchain-based games and applications. It covers the overall architecture and structure of .NET projects, including smart contract integration and core logic. Key topics include Nethereum's integration with MUD systems and tables, extended code generation to support MUD, deployment strategies, bulk saving, data synchronization, and testing.

Speaker(s): Juan Blanco
Skill level: Intermediate
Track: [CLS] MUD Community-Led Session, by 0xPARC
Keywords: Architecture, Frameworks, Gaming

Follow us: https://twitter.com/efdevcon, https://twitter.com/ethereum, https://warpcast.com/devcon
Learn more about devcon: https://www.devcon.org/
Learn more about ethereum: https://ethereum.org/ 

Visit the https://archive.devcon.org/ to gain access to the entire library of Devcon talks with the ease of filtering, playlists, personalized suggestions, decentralized access on Swarm, IPFS and more.

Devcon is the Ethereum conference for developers, researchers, thinkers, and makers. 
Devcon SEA was held in Bangkok, Thailand on Nov 12 - Nov 15, 2024.
Devcon is organized and presented by the Ethereum Foundation. To find out more, please visit https://ethereum.foundation/

## Transcript

[Music] hi hi I'm Juan Blanco uh a bit about me I've been involved in the blockchain since uh two uh 2013 in ethereum 2015 I created ethereum and also the PS codee solid the extension H I have also been 24 years in donet and more n so mainly I'm pretty old um so neum neum the vision of neum is just to provide tools and Frameworks to sony.net developer can create applications and integrate with eion or even existing applications the visum has always been bringing the love of E to net and vice versa so what can you do with the net ecosystem and ethereum you can create desktop applications you can create mobile iot gaming uh as we're going to see here H web wasm as well as we can see here line of business applications like sap uh and of course Cloud integration and and you and using neion and you can have common logic that can work across so what the neum features so this is the same as any core uh client integration you have the the ne node just RPC smart Contra integration your rlp EVMS signing Avi encoding indexing L to support Etc we have all the standards and common protocols uh so you have like C no safe enss Etc Merles external well as if you don't want to create your uh wallet with neum like metamask wallet connect ass keyb Etc and ding neum prr so you can actually test how you eum integrates code generators and many templates like uh cwe bler Unity Etc so and what mod brings to the plate uh mod uh brings uh new data models and dynamic scheme is something that was we were really missing for create applications in gaming and data indexing something that we can actually rely on and and mainly the operability and be able to create new worlds and complex a applications so ethereum brings the new packages so we have ethereum mode mode uh so together you know now we can create these great applications and games that we couldn't do before for so how does this work you know so we've been fooding this H with Cafe Cosmos so so it has been fully tested there and and it it works you know so it's it's pretty pretty cool so what is Cafe Cosmos so Cafe Cosmos is a a is a game for uh management you manage resources you you cook H ER you can do many things in here we can see the Blazer version which is a web application uh as you can see you got the tools you can H you can put H fences there you are cooking Etc but obviously this is a web H application so it looks much better as a Unity site and so here we can see exactly the same view but actually in unity so yeah it looks much much better than HTML version um so how does it work underneath uh here is got a small diagram we can see in the top H we got the Placer uh a version the unity version of the front end all that connected to a player service which in itself it connects to the name space in the net version which is system service and table Services the the mod wrappers uh also includes a local state H just to keep the data locally and the logic and all that integrated with obviously the the node we have the the mod smart contracts and obviously custo systems and log processing and so on on the right hand side uh or left hand side you can see the stor processor you know so you have all the data stored to the database and in the other side you can see how we can create AET integration test and obviously deploy it using net so let's see how this work if we were adding some functionality to Cafe Cosmos so Cafe Cosmos would it be great yeah if you can have a crazy oven there but sadly uh I only have one simple oven you know but I don't have enough items to actually create my craft my crazy oven not not really really FC having this crazy oven so what if I could actually buy it in instead of crafting a and and created a catalog yeah so let's start how will it look like so so let's start with the smart contracts so first of all you know uh we'll create our in our mod config our our table you know so here we call a catalog item with a item id catalog ID and a price you know because we're going to buy it and then we will go and cogenerate it if because we are working working on wind Windows um normally with unity um you will have to use the kbass or wl2 because mod works better in an unit environment so once we H cogenerated our table we we can start working with it so how as you can see here we got the a new catalog system and then we can access the data there U for the catalog item then now we have a the price Etc and then it this integrates where our other Library so we can get the token balance that we have so we can do the purchases and validate it so now we got our system created what we're going to do um so etherum now includes a a new code generator so this code generator ER is is part of the is integrated with the BS code solidity extension so before ethereum you would have a simple code generator just to create your normal services so now but now has these mode extensions mod extensions for table generations and mod extensions for systems so once you created this you just go to BS station right click and there you go you can code generate it and then you got this files so so here you have the catalog item record your catalog table um a service your catalog system service your Catal syst service mode extension so let's have a look at this in detail so first first of all let's look at the table record a table record is a exactly uh the same as we have seen before you know it just Maps you it's just the representation of your catalog uh record you call the catalog item key and the catalog item value which in includes the IDS price Etc now we have the table service the table service is what allows us to quid directly the data uh uh from the smart contract so we can uh H get the records set the records or even use the the logs as you can see here we can set in we can set the records for example that will be our H crazy ovens so we're going to create a new item and it will have the item id of one and then the catalog uh ID of zero and get a price of five and we can also later on after Creator we can create you know the get the table record and also get the data directly from the logs once we have the um overall we could have a table repository the table repository is where all that data can be stored and and this is as you can see in the screen we created an in memory table repository obviously you can have a post Etc and that way we can create all extract all the data and store it locally or in memory or in a database and let's have a look how will this will look in the in the database so a neia now also includes a neum mode repositories EF package for for anybody familiar with net EF is the Entity framework which mainly provides a common provider for many data bases so you can H actually store the data there and a specialized version for postgress as we have uh a different way to store the data say post allows to to to store bytes um and once we start the processing this we get all the data here and as you can see this is all the data from the from the world system um very similar to what mod does uh in the JavaScript version and and you can see that everything is encoded there and um yeah M just can see the data but obviously because everything is encoded we want to be able to quate data so e it also includes a new predicate Builder which will allows to query the data and then using simple queries like uh equal not equal and or Etc so this will dynamically create some queries that it will uh create the database um but obviously uh sometimes we want to see the data in the database so is H also includes a new normalizer there which mainly will convert all the data and tables in the database um the previous versions also includes a race API as in case you obviously if you're working on webgl you will want to connect to that data H but in here we just leave it leave it on your own you know so because you might want to create different indexes this and and optimize the database once you have extracted all the data and recreated so we that was the data so what happens next you know let's look at the systems obviously want to integrate with the logic so first of all we have a we have our assistant service our assistant service is the normal neum uh cogenerated H service H so here we can access the method purchase purchase catalog item and but also there are extensions for uh to convert this uh service into a system service for mode and here we we see the the as is in the top we have the the catalog as the as the system name and also ways to do the deployment and in inet um once we got all the tables uh and the systems we can add it into our custom name space we just create some classes there and and then later on we connect all this into our player service who will integrate in your game and in here we can see we has a simple method which will do the purchas purchase item from catalog and wait for receipt is asnc and so mainly this will go into your land name space and you will go the systems go to the catalog and do the purchase and also afterwards it process all changes uh that will'll talk about it in a second so now we got the method we can connect it and create a simple uh Blazer or HTML UI so we can purchase our crazy and then put it in our Unity obviously I have to build the the unity uh UI yet but the beauty of having two different front ends is like I can test it in the htl version because building something Unity takes a lot much longer um so now we go local so talking about local estate so we as we can see before we were H we were talking about what happens after safe and I do a process of the changes so um sometimes you know we have seen many demos here like you you might want to constantly send transactions for every movement but in other ways you you can want to keep a local state with and and keep it in memory and batch uh um uh or bulk save all the data uh after many actions see this will reduce the number of transactions and then will save your gas so maintain a local estate what we do is keep it an IM memorable repository that's the one I was talking before but a in here what we do is when Once the user starts H the game we load all the data in the current state and any actions that we do we keep it in a separate uh object um also any actions that the user will make we keep it into a collection of actions that we that we keep in memory so later on we can batch those action so first so and obviously validate all the actions that we h we keeping memory using the logic in in net so what happens if I craft something or anything on the land so mainly I craft something then the logic H I'm I'm doing I'm doing the validation internally and keep on the all the logic in net and later on I just H once I'm finished and have done all these actions I use the Magnificent thing called system called multi-input and then and B all these operations into the into the node as a one single transaction um er once with all this save uh we want to synchronize the data and and instead of like having something in the background running as a processor we can use the the the logs of the receipt so the L of the receipts will bring all the changes that has happened on the database sorry in the in the blockchain uh and then what change can come from the chain so uh we can keep a logic in it but not everything so we have like uh things like XP Point changes level progress Etc so many the core logic that where people will normally cheat in your game we can keep it h we'll keep it obviously in in the evm so uh apart from this uh obviously we have deployment and testing so the Way That Neon deploys if you wanted to deploy with neion uh we we you NE has also the the mod smart contract so this just deployed as a US World Factory C then deploy your your your tables and then configure the the tables and the systems and register as well all the functions as well there this becomes very helpful because uh if you want to run your your integration testing against your net code you will constantly uh run in deployment configure you know configure all the data Etc and and then uh and then just just run the testing neion also includes some uh a little uh tools to to provide integration helpess integration for testing and also extension for like common uh development noes like harad or Amil and finally but not least you know one of the coolest thing about mod is got the delegate Authority so uh the capability to have temporary uh key private Keys Etc uh so you can H not having a link to your main uh account we have all the money Etc uh so this is also supported as well and this is going to be the basis uh as well for accru that we're going to uh I'm going to put in in eum uh later on uh as as you as is allow me to think about a better pattern to solve how to put a kind of stru there and wrapping up so we have seen how we have uh we can start with the blaz area a Unity front end as well all integrated with the player service um having our mod name space and sister saers and table ser services within net a local state all integrated with your any ethereum node and doing the store close processor to get all the data in the database do a deployment and integration testing all in the net World um yeah here's some links uh so so if you need to play around and yeah you ready thank you [Applause] all right um so same as before scand K could to ask question to ju because there are no questions yet I will ask questions so um you kind of rebuild the whole stack Inn net so what did you find what was hard about it what was surprisingly easy where were you able to reuse a lot of your work I'm kind of curious about about your journey doing that um obviously they the the hard part was encoding and decoding uh because you have pack so much data so I modified the neon AV to support the the the packing and the the coding of the pack and data um just mainly using the fix areas and but mainly I understanded there because actually fited very well you know because H we have all the pack functions that provides you know so it look actually fited very well as an extension uh on top of that in eum mode is where the specifics of the mod are put in place just to to the extra decoding and and and encoding so so that was the one of the hard Parts um the overall um I really really like this as you may know because uh you know I said nine years um as an example nine years ago when we're talking about uio I don't know if somebody remembers uio and we talk about the music Etc one of the main things like hey how what what do we do with the data you know how we can have some structured data yeah that we can actually put the artist and and so on the records Etc and we have all these huge debates you know how we're gonna what we're going to do with this uh fast forward nine years later uh ER now we can do it um because we're scaling uh before that is like hey let's put this in ipfs but where's the logic you know so love it you know it's fantastic you know so now we can actually you know just not just gaming you know the gam the gaming are great because obviously can provide some fantastic logic and Bowser application yeah so you've heard it here first one thinks mud can be used for anything not just gaming it's just the beginning um so we got one question from the audience which is how do you prevent data conflict in mod since you're not saving everything immediately to the chain thus you're saving to the stale game of the state to the stale game state that there's hundreds of players in the world right uh obviously the example that example is a for a single player within your confined line so it's obviously this is not based on a multiplayer uh environment uh so uh for that we'll have to think about it obviously it will be you will have to think about how to delimitate the that part of the data and so if you don't really want to constantly think and then say like hey you know this person is where you are working yeah and then and then and then that way allows you to keep that data uh without saving all the time obviously the other solution is like constantly sinking Etc but you if you got millions of users you eventually you're going to get some skillability yeah yeah I mean here it's because each player has a lock on their land essentially so that's why they can work offline okay makes sense uh we have another question here which is are you guys going to do this for goo or Unreal Engine um everything that works in unity Works in Godot uh the so yeah bullish for goo guys if you use Goo you can just use all of this yeah so this the that was that first slide so mainly every this works H using normal task Etc in net so mainly anything that works there it works in in any the part of donet and hence the example with a blazer because here you call a wasam Blazer app you know so that's not running in a web page it's main like fully wasn't there H so it will work in God do one thing is that God do the latest version for they are yet not supporting the the latest version of uh the net but that's mainly go net isus but but yeah and unreal uh I found the other day that there is a new extension plugin for unreal with unreal sharp uh if I remember the name because it's like very very new and so yeah you should be able to work with unreal as well who is do you know if the the unreal. net integration is from epic games or is it like a third party thing third party third party the the Epic GES was supporting another one but the that one is taale but this one it seems to be working but again it's only working on desktop and that's because obviously when you're starting hting thinking about aot and mobile Etc this gets a b more complicated but obviously desktop Mac and and and windows and Linux suit is all right yeah um someone says thank you for your vs code extensions you're Rock um can you guys scroll down a little bit as a 3D artist I wonder how are 3D assets integrated in mud as some can be very heavy with textures um obviously uh you will have to ask the unity Unity specialist on that uh but uh the unity assets are something completely different so obviously that's nothing to do with the mod framewor in itself so if you have something has very heavy the unity has ways to deploy things like no WL that you can do it dynamically uh so yeah I you can load dynamically the data um in our our game nothing is done dynamically yet H because uh well our the cafe CMAs game probably the assets are not very big it's not yet yeah yeah and I think for the person ask the questions um with Mod you don't need to store your assets in mod like assets are just about viewing the state only the the key State needs to be stored in mud I mean you can do it but I I don't think it's a good idea um okay I think that's it thanks again right thank you
