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.

gitcoinbot commented 3 years ago

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


This issue now has a funding of 7000.0041 ALGO (7350.0 USD @ $1.05/ALGO) attached to it.

eiriksfa commented 3 years ago

I will keep you updated in this thread if that is ok, updated work-plan (with link to backlog) will come in 1-2 weeks.

Mine77 commented 3 years ago

@eiriksfa sure just post your progress here would be great.

gitcoinbot commented 3 years ago

@eiriksfa 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

eiriksfa commented 3 years ago

Update to satisfy the gitcoinbot: Still only working on this part time (last day of my full-time job is next week). Have set up three simple "games" that I am experimenting on with ETH NFTs and Algorand NFTs (FPS, RPG and CCG style games)

gitcoinbot commented 3 years ago

@eiriksfa 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

gitcoinbot commented 3 years ago

@eiriksfa 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

eiriksfa commented 3 years ago

Not much to say since last update, haven't had much time (hectic period before vacation/job change). Had my last day yesterday though, so expect more frequent updates from now on.

michielmulders commented 3 years ago

@eiriksfa No problem! Just let us know updates on this. If it would happen that you won't be able to complete the bounty, ping us so we can assign another bounty hunter. Of course, we understand that it takes some time to create a well-functioning SDK so no pressure :)

gitcoinbot commented 3 years ago

@eiriksfa 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

gitcoinbot commented 3 years ago

@eiriksfa 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

eiriksfa commented 3 years ago

I have had some private stuff happening, and am suddenly in the process of moving. My office with my work PC is therefore now in the back of a truck... Right now I have set up some smaller test-games, and I have started designing the SDK with mocked public functions. Now, I am afraid that I will not be able to work much on this issue for a couple of weeks or so, but I would still very much like to continue working on the issue. I will let you decide if you want to assign someone else to finish the bounty, or wait for me to finish the moving process.

I suppose I could spend some time drafting the tutorials on this PC (that I am writing on) over the next couple of weeks though, so not a complete down-time.

Mine77 commented 3 years ago

Hi Erik,

If you don't mind I'll remove you from this bounty and re-open it for others. For the works you have done and you are going to do, you can still submit them via this bounty in the future: https://github.com/algorandfoundation/grow-algorand/issues/41

Wish you all the best.

On Tue, Jul 6, 2021 at 6:21 PM Eirik @.***> wrote:

I have had some private stuff happening, and am suddenly in the process of moving. My office with my work PC is therefore now in the back of a truck... Right now I have set up some smaller test-games, and I have started designing the SDK with mocked public functions. Now, I am afraid that I will not be able to work much on this issue for a couple of weeks or so, but I would still very much like to continue working on the issue. I will let you decide if you want to assign someone else to finish the bounty, or wait for me to finish the moving process.

I suppose I could spend some time drafting the tutorials on this PC (that I am writing on) over the next couple of weeks though, so not a complete down-time.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/algorandfoundation/grow-algorand/issues/52#issuecomment-874641438, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACZ4HJYJXPQ5UIY7T56RZ6DTWLKIXANCNFSM46WQK7SA .

eiriksfa commented 3 years ago

All right, I'll keep an eye out and re-apply if there are few other interested within the next two weeks :)

gitcoinbot commented 3 years ago

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


Work has been started.

These users each claimed they can complete the work by 265 years, 4 months from now. Please review their action plans below:

1) jasonboukheir has been approved to start work.

These are my assumptions and how I understand the bounty. I'm very excited for this bounty because I was planning on working on this in my free time anyway! (I'm already working on an elixir SDK implementation for Algorand!)

I will work on a C# plugin at www.github.com/CareBoo organization. I will make it available through the Unity Asset Store, but I will also make it available through an open unity package manager project (openupm.com). Unity themselves are eventually trying to move packages to the unity package manager, and many open-source projects use this as well.

My plan is to try and feature-match the py-algorand-sdk as I'm familiar with Python. I could also use the community provided Dotnet SDK as a starting point, but I'm thinking I should try to focus on the Algorand Foundation supported SDKs first and foremost. I'll need to make sure the crypto library I choose is widely used, well supported, and works within Unity.

I have experience optimizing with Unity's Burst Compiler; however, there aren't any Burst Compilable crypto libraries in the C# ecosystem. If I went this route, there would be more work required to try and leverage a Native plugin, and write out the API in C# to be accessed from C#. I realize that performance is an important consideration for game engines, so I think there's an argument for using a Native solution in favor of a full-C# solution. However, I think that's a stretch goal -- the main priority is safety.

I'd love to discuss this more if you have time! Again, super excited to see this bounty, and I'd love to help out bringing the SDKs! (Also let me know if there's an elixir SDK you're looking for, since I'm working on that now to try and better understand the SDK)

Learn more on the Gitcoin Issue Details page.

jasonboukheir commented 3 years ago

Hey there, I realize that the SDK should use Unity's framework where it makes sense (MonoBehaviours, ScriptableObjects, etc.), and it shouldn't just be a clone of the .NET SDK.

jasonboukheir commented 3 years ago

https://github.com/CareBoo/unity-algorand-sdk/tree/exp

Working out of this project and branch atm.

Mine77 commented 3 years ago

Thanks for the update. Lmk if there's anything we could help with.

On Fri, Jul 9, 2021 at 2:35 PM Jason Elie Bou Kheir < @.***> wrote:

https://github.com/CareBoo/unity-algorand-sdk/tree/exp

Working out of this project and branch atm.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/algorandfoundation/grow-algorand/issues/52#issuecomment-876951702, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACZ4HJY6ZRS55OOBPILLPQDTW2KCZANCNFSM46WQK7SA .

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

I'm still working out the datastructures for the code part of the SDK. I've got some tests already for the Mnemonic and Key. I'm still going through the Microsoft C# crypto APIs to see what options I have for the ed25519 curve key pairs and sha512 hashes.

I'm also still fleshing out an idea for the sample game. At the moment, I'd like to modify Unity's microgames because

  1. It would be easy
  2. Unity already uses the microgames as Unity Learn examples, so it would be easy for newbies to wrap their heads around
  3. There's already lots of documentation and resources from Unity on these microgames.

In the FPS microgame I could reward the player with an ASA weapon when they defeat a boss. I realize to prevent hackers in a game like that you would need to store the state of the game on the server, and the game would need to be networked to control when you reward the player with the ASA. I'm still working out the kinks here.

jasonboukheir commented 3 years ago

Quick Update:

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

Oh do I need to submit a WIP PR?

@Mine77 Is there a specific format for how I should submit that, or do I just fork this repo and link to the repo I'm working out of?

Updates: It's taking a while, but I'm finally close to being finished with the crypto API. I've got the libsodium binaries building for the unity platforms on macos, ios, and android, and added to the project. You can see the progress of that here: https://github.com/CareBoo/unity-libsodium. Someone on the unity forums recommended me to use https://github.com/microsoft/ClangSharp to generate the bindings, which will make it easy to work with in Unity.

Mine77 commented 3 years ago

Your submission should be a repo link, which could be based on a fork. Also please provide us with clear instructions on how to use it, so that we can test it when reviewing.

On Fri, Jul 16, 2021 at 12:37 AM Jason Elie Bou Kheir < @.***> wrote:

Oh do I need to submit a WIP PR?

@Mine77 https://github.com/Mine77 Is there a specific format for how I should submit that, or do I just fork this repo and link to the repo I'm working out of?

— 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-880847577, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACZ4HJ6IDAKUDQNOEWOGON3TX4FFPANCNFSM46WQK7SA .

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

Hi, I have a few updates:

I'm aiming to have account generation done tonight.

jasonboukheir commented 3 years ago

Updates:

So far, generated Key/Seed -> Mnemonic creates the correct set of 24 words. I don't have the Sha512 interop set up with libsodium yet, so the checksum isn't correct.

Working on now:

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

Hi,

Last night I got Sha512 added in from libsodium. I'm still implementing the account APIs

jasonboukheir commented 3 years ago

I ended up going down an interesting rabbit hole for SHA-512.

After adding SHA512 interop from libsodium, I began working on the checksum implementation for the mnemonic. I was hashing the seed with SHA512, then simply truncating the result to 256 bit as I assumed that's what SHA512/256 was. However, I kept getting the wrong result when comparing to the py-algorand-sdk!

Turns out that SHA 512/256 isn't just SHA 512 truncated to 256. It uses a completely different initialization vector. Unfortunately, libsodium doesn't provide a SHA 512/256 hashing function. Fortunately, it does provide a multipart hashing function, so it's easy to inject your own initialization vector.

Following FIPS definition for it here, I got the checksums working! :)

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

Hey there, quick update

I've finished building out all the API required to mimic py-algorand-sdk's algosdk.account API. To recap, here's the current functionality so far.

I'm working on signing messages atm

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

Hey there

I've been working on the transactions. I've got a first pass on the data models made from the documentation (Payment, keyreg, and assets). I need to update the asset transaction models since I haven't captured all the different types of asset transactions (which is the whole point of this SDK anyway hehehe).

When that's finished, I'll be working on signed transactions.

I also dug a little into the KMD. Since the KMD / wallet isn't 100% necessary, I'm going to make it a stretch goal for the delivery and work on it as a final piece.

jasonboukheir commented 3 years ago

I've added a MessagePack library into the SDK, and set up the transaction models to be serialized/deserialized. I'm currently working on verifying the serialization/deserialization logic is correct.

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

I'm still working on the serialization/deserialization of the transactions.

The serializer is keeping all the 0-value fields in the map, so I'm working on removing that.

jasonboukheir commented 3 years ago

Quick update,

I was running into a problem with the transaction library when deserializing generic transactions into type-specific transactions. (e.g., how do I deserialize a raw transaction -> payment transaction vs an asset transfer transaction?)

I wanted to keep gc allocations to a minimum. I was debating on using a c-union struct type, or just a large struct with all of the possible fields. I decided on using the latter because it avoids writing on overlapped fields.

I will still be working on the transaction logic this week. I still need to work out asset params, the application call logic, the state schema, and etc..

I'm thinking about pushing the application call support until later, and focus on the payment / asset transactions since those are the most necessary for this issue.

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

I don't have much to update from yesterday. Today I compared the transaction serialization with the python sdk. I found an issue where my Addresses weren't being serialized in their Base32 form. I fixed it, and the transaction serialization format looks good so far.

I'll be working on the signing logic next -- likely in the next couple days.

jasonboukheir commented 3 years ago

Got some basic signing logic in today. Signing a transaction then verifying its signature with the public key works.

I need to add support for the actual signed transaction to be serialized/deserialized now.

EDIT: Also wanted to add that the Message Pack library uses Span and ReadOnlySpan and requires .NET Framework. I don't think this is ideal, since

  1. Burst doesn't support spans.
  2. Managing DLL dependencies in unity projects can be a pain for the end user.
  3. Supporting .NET standard 2.0 would allow for more users.

I'm using a very small partof this library, and that's really just the reader/writer. Adding to the list of stretch goals, it would be cool to implement a simple message pack reader/writer that uses NativeStream so we could stick with .NET standard.

Mine77 commented 3 years ago

Hi Jason, Thanks for sharing updates these days. Let me know if you need our technical supports.

On Wed, Aug 4, 2021 at 7:33 AM Jason Elie Bou Kheir < @.***> wrote:

Got some basic signing logic in today. Signing a transaction then verifying its signature with the public key works.

I need to add support for the actual signed transaction to be serialized/deserialized now.

— 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-892234497, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACZ4HJ5MVNDBJZS5667WLJ3T3B4CXANCNFSM46WQK7SA . 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&utm_campaign=notification-email .

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

I have signed transactions serializing/deserializing and verifying properly for payment transactions. Tonight I'm hacking with algod.

I saw the developer office hours for the wallet mobile connect, and that looks cool. It would be sweet to get that in as a stretch goal. I've updated the project board here with some of those issues: https://github.com/CareBoo/unity-algorand-sdk/projects/1

(the project board is small, but I'm going to try to keep track of all the stretch goals and issues I see)

jasonboukheir commented 3 years ago

I'll be traveling until next Wednesday, so I won't have many updates until I get back. I plan to work on project planning / documentation since I'll be away from my computer.

This morning I'm trying to fix some CI issues before I fly out. I went ahead and build libsodium for ubuntu on linux64 and linux32 so the test runner can actually run libsodium tests.

EDIT:

Automated tests are working for linux! Yay!! :)

Mine77 commented 3 years ago

No problem I've snoozed the reminder for 10 days.

On Sun, Aug 8, 2021 at 12:42 AM Jason Elie Bou Kheir < @.***> wrote:

I'll be traveling until next Wednesday, so I won't have many updates until I get back. I plan to work on project planning / documentation since I'll be away from my computer.

This morning I'm trying to fix some CI issues before I fly out. I went ahead and build libsodium for ubuntu on linux64 and linux32 so the test runner can actually run libsodium tests.

— 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-894677110, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACZ4HJ47X47C6JLOUFUSVY3T3VPANANCNFSM46WQK7SA . 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&utm_campaign=notification-email .

jasonboukheir commented 3 years ago

Hi,

I'm back from my travels. I don't have too many updates atm, but I've started fleshing out the Algod Client. Here's a mega-issue regarding it: https://github.com/CareBoo/unity-algorand-sdk/issues/10

I'll continue adding in tasks via the task lists on there, and check them off when they're added in the feature branch

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

I'm still working on the Algod client.

I stubbed out all the V2 API, and the models required to implement it.

I'm working on implementing these models based on the schema in the documentation.

jasonboukheir commented 3 years ago

Quick update

I've gotten the framework for serializing C# models into REST API data to a point where I've started implementing the models. I added the Account Model tonight, and will do some more tomorrow.