algorandfoundation / grow-algorand

Grow Algorand and Earn ALGOs ❤️
90 stars 33 forks source link

Unity 3D Asset SDK #52

Open Mine77 opened 3 years ago

Mine77 commented 3 years ago

Overview

Description

What's the goal for this task?

Create a Unity3D Asset (SDK) in the Unity Asset Store. Utilize the Unity Runtime API function to facilitate large-scale automation and scalability of blockchain asset creation, minting, trading, and sending, as well as other blockchain-related features like wallet integration, smart contracts, and atomic transfers.

Benefits:

How it works (features)

  1. Acquire/create game coins through partnership, crowdfunding, or a cryptocurrency exchange.
  2. Mint blockchain-based gaming items such as custom in-game currencies, generic modifiable resources and/or unique items with NFTs, non-fungible tokens, such as mighty heroes, and unique game weapons.
  3. Once a game is released, gamers can complete quests and collect rewards and gather unique game items from vanished enemies, collect fungible resources, and earn gaming assets.
  4. Gamers can get items from in-game stores or trade with each other
  5. Gamers keep and own blockchain-based items in their wallets.
  6. Transfer/sell game assets back to the game coin, so game assets will always have value.

What is this task

With the Algorand Blockchain SDK, you can easily and rapidly build next-generation blockchain games in Unity—without writing a single line of blockchain code.

Why does this task need to be done

Over 50 percent of the games in the app stores are created with Unity. What are the benefits to the Algorand ecosystem? We can extend the application use cases to include gaming with a Unity plugin. I.e., more solutions are possible by using this plugin.

The Algorand Unity SDK would be similar in functionality to an Ethereum-based blockchain SDK by Enjin.

What are the requirements for the bounty taker?

To provide a platform that enables users to explore and take advantage of four key features:

What are the deliverables?

Create a package and publish it to the Asset Unity Store. In the tools and utilities section.

Judging Criteria and Metrics

Step by step document of how to use the SDK Asset plugin with a simple sample game as well, using this asset.

Submission Procedure

Other Requirements

For questions, reach out to Algorand on Discord.

jasonboukheir commented 3 years ago

Some more updates

gitcoinbot commented 3 years ago

@jasonboukheir Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

jasonboukheir commented 3 years ago

Updates:

I tried writing my own TaskCompletionSource to avoid the exception handling. Instead I'm gonna keep it simple and shim over the dependent APIs. Specifically, I'm writing wrappers around UnityWebRequest and UniTask. In the future, it will be good to provide optional support for UniTask if users would like to download it. In Unity 2021, UnityWebRequest has a NativeArray API that should be used instead. Using an adapter over both makes it easier to pick and choose features from either.

jasonboukheir commented 3 years ago

Updates:

I realized I was missing a lot of valuable, in-depth documentation from https://github.com/algorandfoundation/specs/blob/master/dev/ledger.md, so I'm referencing that regarding the models. It's good to know the max sizes of integers, bytes, strings, and arrays.

A lot of the models have nested arrays and storage, which are difficult to keep safely unmanaged (even with Unity's Native Collections). I'm using the reference above to see what can be stack allocated. If there are nested heap allocated arrays, I will prefer to use regular, managed C# objects until I can write out my own NativeContainer.

jasonboukheir commented 3 years ago

More updates:

I've gone through the specs and the ledger models are too large to be stack allocated. I don't want to force users to manage the memory of native collections if they don't want to, so from now on the Algo API models will be using managed C# objects.

I was spending some time trying to get the sandbox running in a github action as a service, but it failed miserably. I've disabled the tests that require the sandbox in the cloud.

jasonboukheir commented 3 years ago

Hey there, got some more updates (I don't think the bot is asking anymore??)

I'm almost finished with the AlgodClient Issue. I'm trying to debug why I'm getting a signing error when I try to test out a transaction.

There are 2 other areas that I still need to verify:

Mine77 commented 3 years ago

Thanks for the updating.

On Mon, Aug 30, 2021 at 8:38 AM Jason Elie Bou Kheir < @.***> wrote:

Hey there, got some more updates (I don't think the bot is asking anymore??)

I'm almost finished with the AlgodClient Issue https://github.com/CareBoo/unity-algorand-sdk/issues/10. I'm trying to debug why I'm getting a signing error when I try to test out a transaction.

There are 2 other areas that I still need to verify:

  • block format
  • teal compilation

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/algorandfoundation/grow-algorand/issues/52#issuecomment-907915564, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACZ4HJY52BDUVEHQNQBD7I3T7LHJRANCNFSM46WQK7SA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

jasonboukheir commented 3 years ago

One more update this evening:

🎉 I figured out what was wrong with my signing error and got a payment transaction verified on a sandbox network!

I'm thinking of putting the block and teal compilation endpoints on the back burner so I can start fleshing out the demo game, but I'll let y'all know tomorrow :)

Mine77 commented 3 years ago

sounds exciting! Keep it going :)

On Mon, Aug 30, 2021 at 12:52 PM Jason Elie Bou Kheir < @.***> wrote:

One more update this evening:

🎉 I figured out what was wrong with my signing error and got a payment transaction verified on a sandbox network!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/algorandfoundation/grow-algorand/issues/52#issuecomment-908027274, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACZ4HJYTRZHAZ2HZZF64LITT7MFB7ANCNFSM46WQK7SA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

jasonboukheir commented 3 years ago

Small update for today,

I got the GetBlock implemented and working at a high level. I couldn't find the documentation that outlines the total response for the block header data, and so I just used the fields that were returned. I likely missed out on some optional fields.

I have the TealCompile and models written out, but I don't know how to write a TEAL program, so it hasn't been tested. I also probably have some things wrong here.

I'm adding the above 2 as new issues to the project. I updated the exp branch, and here's the latest experimental release (with very rough algodclient support hehe): https://github.com/CareBoo/unity-algorand-sdk/releases/tag/v1.0.0-exp.14

jasonboukheir commented 3 years ago

I've been working on removing the requirement to use .NET Framework 4.x, and instead allow users to use .NET Standard 2.0. I should have some more updates this weekend.

jasonboukheir commented 3 years ago

Hey there,

I've made some good progress on removing the dependency for .NET Framework 4.x. I've got a simple JsonReader implemented and tested with valid Json.

jasonboukheir commented 3 years ago

Hey there, quick update.

I'm still working on fixing the code to be .NET Standard.

I should have it more updated tomorrow

jasonboukheir commented 3 years ago

I have implemented a simple JsonWriter, and I started working on a codegen to help make implementing the algo-api models easier.

Unity has a very useful API in the editor called TypeCache that lets me grab all the types / fields / methods defined with a c# attribute. It's not too difficult then to generate some code in the editor using System.CodeDom based on attributes.

Right now, when I add a new algo-api model, I have to

  1. Create a mapping from the algo-api field names to the field/property on the C# class and an IEqualityComparer<> if the field does not implement IEquatable<>
  2. Create a mapping of the C# class to the formatter that will convert it to an algo-api representation
  3. Create a mapping of the C# class to the mapping created in step 1

With the codegen, I will just have to

  1. Add an attribute to the class that defines the formatter to use
  2. Add an attribute to any fields that define what the algo-api name should be
jasonboukheir commented 3 years ago

I have the System.CodeDom code generator working. It generates the json mappings based on attributes I set on the models. I still need to do the following:

UPDATE: These are now all completed

jasonboukheir commented 3 years ago

I'm still working on implementing out MessagePackReader and MessagePackWriter that the models can use.

MessagePackReader is almost ready to test with the formatters. I expect I'll have that one tested and finished tomorrow.

jasonboukheir commented 3 years ago

I have all the formatters I'm using from MessagePakc working with the new readers/writers and the json readers/writers.

I'm still working on adding the [AlgoApiFormatter] codegen stuff, but I should be done this evening. Then I'm going to rerun the tests I ahve to make sure everything is still serializing/deserializing properly.

jasonboukheir commented 3 years ago

Okay, the latest experimental release has a big refactor to remove the .NET 4.8 dependency. There are also some refactors to fix some big developer pain points when adding new API models:

And the lines of code were reduced by 30,000... yup

jasonboukheir commented 3 years ago

hey there. I've added a few transaction models. I started working on the server client networking for the demo.

@Mine77 I'm not familiar with how the transfer of assets can produce royalties for the creator. I saw a demo that used the clawback address and smart contracts to create royalties. I'm going to go through that demo again, but I was wondering if there were any other resources you recommend I read to see how that could work.

Mine77 commented 3 years ago

The Algorand blockchain does not provide such a feature on the protocol layer. So mostly this will be realized with a smart contract.

I think it's ok if you are going to offer this to users as an application layer feature. However in that case, since it involves a contract, a code audit will be necessary.

I would suggest let's keep it to the base layer utilization for the time being. I.e. having all on-chain features accessible from Unity with this SDK.

Best, Haichao

On Tue, Sep 21, 2021 at 10:19 AM Jason Elie Bou Kheir < @.***> wrote:

hey there. I've added a few transaction models. I started working on the server client networking for the demo.

@Mine77 https://github.com/Mine77 I'm not familiar with how the transfer of assets can produce royalties for the creator. I saw a demo that used the clawback address and smart contracts to create royalties. I'm going to go through that demo again, but I was wondering if there were any other resources you recommend I read to see how that could work.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/algorandfoundation/grow-algorand/issues/52#issuecomment-923536543, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACZ4HJ35NXBO3CXVNM2JPETUC7TS7ANCNFSM46WQK7SA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

jasonboukheir commented 3 years ago

Thanks @Mine77 !

I'm still working on the networking layer, but in the meantime I've added LogicSig support.

jasonboukheir commented 3 years ago

I realized that I should avoid using Activator.CreateInstance so that all of the AlgoApiFormatters could be AOT compiled if need-be. So now, all of the used formatters will be explicitly added to the Formatter Lookup tables. Fixed a couple bugs around the LogicSig serialization.

jasonboukheir commented 3 years ago

One small update:

For the networking, I went ahead and added this project as a template to go off: https://docs-multiplayer.unity3d.com/docs/learn/bossroom

jasonboukheir commented 3 years ago

I started working on this issue: https://github.com/CareBoo/unity-algorand-sdk/issues/30 last night. I should have it finished this weekend since the framework is pretty much all there. The KMD client will be next and should be quick as well.

updates:

jasonboukheir commented 3 years ago

New experimental release with IndexerClient is out: https://github.com/CareBoo/unity-algorand-sdk/releases/tag/v1.0.0-exp.23

jasonboukheir commented 3 years ago

New exp release with a basic implementation of KmdClient is out: https://github.com/CareBoo/unity-algorand-sdk/releases/tag/v1.0.0-exp.24

jasonboukheir commented 2 years ago

currently writing tests for the indexer client and working out some bugs I've found -- my goal the end of this weekend is to have all of the API smoke-tested with the sandbox server.

jasonboukheir commented 2 years ago

Release v1.0.0-exp.25

I added some tests to the IndexerClient, and fixed a number of bugs. Can view the release to see the changes.

jasonboukheir commented 2 years ago

I've been working on adding integration tests for different clients.

Excited to have more of the tests built out for the KMD client and bugs fixed tomorrow.

jasonboukheir commented 2 years ago

I've got the keys endpoints of the kmd client working in integration tests. I'm working through the multisig parts rn.

michielmulders commented 2 years ago

@jasonboukheir Looking forward to a demo. How much time do you think you need to have a version ready that can be used by game developers? We would like to launch a gaming hackathon by the first of November if that's feasible for you? Let us know!

jasonboukheir commented 2 years ago

@michielmulders That is very exciting! I'd love to have it ready by then. How long does the review process take? i.e. when should I submit the demo to have it ready for the hackathon? I'm going to do a planning session tonight to track in detail and prioritize what I need to tackle to have it "complete", I can have a better time estimate then.

jasonboukheir commented 2 years ago

After looking at what's left, I think that's totally feasible if I prioritize certain things.

There are some stretch goals I'd love to add after I get the demo ready.

FYI here's the current project board and issue tracking: https://github.com/CareBoo/unity-algorand-sdk/projects/1

michielmulders commented 2 years ago

@jasonboukheir the docs and examples are important to really help devs. Board looks good, let's hope we can finish it by Nov 1. Also, the integration with WalletConnect/AlgoSigner would be very helpful to have that in as well. Thanks for doing all this work!

michielmulders commented 2 years ago

@jasonboukheir Can you share your Discord handle so I can contact you there? :) Thanks!

jasonboukheir commented 2 years ago

I'm aiming to have this completed by 1 week before Nov 1st. Most of the issues on the project board are the remaining items before this will be considered complete.

Updates since last time:

jasonboukheir commented 2 years ago

quick update since last time:

I'm currently working on adding XML docs to the public API and cleaning up some code. After that, I'll be working on the demo.

michielmulders commented 2 years ago

Perfect, looking forward! @jasonboukheir

jasonboukheir commented 2 years ago

I've been pretty busy at work this past week, so I haven't had a chance to get much done during the week.

Today, I've done a first pass through the code and added XML C# documentation where appropriate. I've also added DocFX support -- you can view the documentation website at https://careboo.github.io/unity-algorand-sdk/ which is pretty exciting.

I'll be working on the game demo and the Getting Started guide tomorrow.

jasonboukheir commented 2 years ago

I finished the quickstart guide, but I'm still working on the game demo at the moment. I'm also finishing up some of the work required to publish to the unity store.

michielmulders commented 2 years ago

Perfect, ping me once ready :)

jasonboukheir commented 2 years ago

quick update,

I've got some basic token rewards in the demo working if the player completes their objective. Working on a Weapons store that shows off atomic transfers. It will just be a simple single-weapon store, where the player can buy a rifle asset to use in the game.

Since it's a demo, the accounts aren't stored safely and securely. I added a way to generate accounts and assets to the editor if that wants to be updated.

I've also submitted the application to review for the AssetStore. Unfortunately, there's a 20-30 day time period before they even begin looking at the asset for approval. However, it's available on OpenUPM currently as a workaround. It's straightforward to download it from there or as a github package.

jasonboukheir commented 2 years ago

Hey there, here's an update from last time:

jasonboukheir commented 2 years ago

Version 1.1.0 has been released. There are 2 main parts to this release:

I'm currently working on adding logos and images that are different than the Algorand ones so I don't confuse anyone 😅

Mine77 commented 2 years ago

Thanks @jasonboukheir We've started to check your work. We will let you know once we've done that or if we have any questions. :)

gitcoinbot commented 2 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work for 7000.0041 ALGO (13580.0 USD @ $1.94/ALGO) has been submitted by:


jasonboukheir commented 2 years ago

Hi @Mine77 ,

There's been a recent update, and the asset is on the Unity Asset Store. Could you please verify?

gwcoleman86 commented 2 years ago

Hi,

My Name is Gabriel. I am working with Jason and Russ on this project. I have been working with Unity for more than eight years, and have been a professional Unity developer for almost five years. I am proficient in C#, JSON, NodeJS / JavaScript, PHP, HTML, PHP, and C++. Also have experience with Maya, Blender, and I am an Indie game developer on the side.

I have already made some contributions to the project, and I I have several tasks planned out to work both on the front and back end.

Some of the contributions I have already made and/or are in progress:

Some of the other tasks that are on my roadmap are:

Thanks,

Gabriel