Ethereum Unity3D Boilerplate Questions

I have a fix for the iOS issue. Testing that and a couple other things. I should have a merge to main by the end of the day unless I run into any issues.

1 Like

Is there any way to check if a transaction is reverted or failed? I’m using SendTransactionAsync method to make a transaction, but it didn’t return any values if the transaction is reverted. Also, I can’t understand if the transaction is failed or not.

if you use /transaction/{transaction_hash} endpoint,
you should see receipt_status": "1" if it is one, it passed, but if it is 0, it failed

1 Like

Thanks for the great support !

Hi,

I am creating a React app with Moralis SDK that also hosts a Unity game on the client side.

The goal is to prevent the user from having to authenticate both in React and Unity. We have Player data stored in the Moralis Mongo DB that inherits the ACL of the User. We would like to access the Player data on the Unity game load and update player data on game level completion.

Is it possible to safely use the initial authorization used in the react code to authenticate within the unity game at the same time? If not, is it possible to safely pass data into the Unity canvas utilizing the auth present in React?

1 Like

Yes it is. When the user authenticates in the REACT app, a sessionToken is returned within the user object. Pass this to the Unity App.

When the Unity Game starts instead of loading the Authentication scene, initialize Moralis as normal and then run

MoralisInterface.GetClient().UserFromSession(SESSIONTOKEN_HERE);

This will load the user from the sessionToken. The loaded user will be set to the the CurrentUser and other Moralis interactions happens normally.

awesome! I will try this out, many thanks.

1 Like

Just an update - I have a couple of failing integration tests that I am working through (unrelated to the iOS fix) so I have not merged to main yet.

If you want a head start the dev branch is bugs/issue_81. This is a use at your own risk situation though. As I mentioned, not all tests are currently passing.

The update has been merged and posted to the repo.

1 Like

Wuuut :raised_hands:t4::raised_hands:t4::raised_hands:t4::raised_hands:t4:

Any advice on how to update the files without uninstall + reinstall on Unity ?

1 Like

Read through before doing :slight_smile: If you made any changes to the Moralis files (not under example) you will lose these changes.

  1. Backup your project!!!
  2. Download the new release (currently moralisweb3sdk_v1_1_0.unitypackage)
  3. Under Assets->MoralisWeb3ApiSdk DELETE:
    a. Folder: Moralis
    b. Folders: All three WalletConnect folders
    c. The seven (7) moralis script files in the MoralisWeb3ApiSdk folder.
  4. Under Assets delete the WebGLTemplates.
  5. Drag the release package into the Assets folder.
  6. When the import window appears, deselect and then re-select the Eamples option, this excludes any unchanged files.
  7. Import the package.
  8. If any of your custom files are now missing, re-apply from your backup copy.
1 Like

Does the SDK work just as well with Unity 2D builds?

1 Like

Yes, though we do not have any examples of this yet.

Hi, I want to achieve three things for Unity WebGL.

  • Checking the user’s wallet (Metamask) network such as eth, bsc, polygon etc.
  • Sending the wallet configuration request to Metamask.
  • Sending the adding coin request to Metamask.

Here are some examples of my questions. Can we achieve this using webgl?

1 Like

After building the project for desktop (PC) is anyone able to connect wallet with QR?

1 Like

Yes - what is the issue you are seeing?

Sorry it took a day to get back - I had to research through these.

The current version of the brawer wallet bridge is not returning this information though it is available from the wallet. The other build types (those that use Wallet Connect instead of Web3) already return this information so this looks like a good feature to add.

If you are referring to the icon and message that appear for the connection request then yes you can modify this to send you own information. If you are referring to something else please let me know.

Do you mean transferring coins and tokens from one account to another, accepting payments, minting tokens and NFTs? Yes, Moralis SDK enables you to do this.

If you mean I have a token but it does not show up in Metamask, programmatically make Metamask show the token, then no. However you can use the Web3Api endpoints and operations to retrieve and display any (on the supported chains) balance, tokens owned, NFTs owned by the connected wallet.

Regards,

David

1 Like

Hi there !
Digging your AwardableController script, amazing stuff!
Is there a way to have a glimpse at the smart contract ? or template ?

It seems strange that the player has to sign the transaction when claiming the nft. Is to make him pay the fees ?
also, i am interested in how you automated the transfer from the contract (and contract owner) to the player (without having to sign each transaction manually)

Thanks a lot !

1 Like

yes, the player pay the fees
there is no automation, the player pay the fees and collect the nft so, the contract owner isnt needed
@dgoodrich for the smart contract

1 Like

Thank you!

Sure, with the caveat that they are for demo purposes only.

Not signing at that point - as @0xprof mentioned this is to authorize payment of the gas fees.

I used two contracts, one to hold the NFTs, the second was used to call the first contract to perform the original mint and is written so that the second contract is the owner of the NFTs. This allows the single call transfer :slight_smile:

1 Like